org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/internal/deployment/DeploymentTargetTypeDescriptor.java
author Eugene Ostroukhov <eugeneo@symbian.org>
Thu, 29 Jul 2010 10:00:34 -0700
changeset 458 5ff93668b08c
parent 457 f1087591ff71
child 460 c0bff5ed874c
permissions -rw-r--r--
Emulator deployment was added
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     1
/**
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     2
 * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     3
 * All rights reserved.
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     5
 * under the terms of the License "Eclipse Public License v1.0"
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     8
 *
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     9
 * Initial Contributors:
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    10
 * Symbian Foundation - initial contribution.
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    11
 * Contributors:
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    12
 * Description:
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    13
 * Overview:
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    14
 * Details:
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    15
 * Platforms/Drives/Compatibility:
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    16
 * Assumptions/Requirement/Pre-requisites:
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    17
 * Failures and causes:
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    18
 */
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    19
package org.symbian.tools.mtw.internal.deployment;
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    20
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    21
import java.util.Map;
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    22
import java.util.WeakHashMap;
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    23
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    24
import org.eclipse.core.runtime.CoreException;
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    25
import org.eclipse.core.runtime.IConfigurationElement;
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    26
import org.eclipse.core.runtime.IProgressMonitor;
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    27
import org.eclipse.core.runtime.jobs.ISchedulingRule;
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    28
import org.eclipse.jface.resource.ImageDescriptor;
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    29
import org.symbian.tools.mtw.core.projects.IMTWProject;
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    30
import org.symbian.tools.mtw.ui.MTWCoreUI;
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    31
import org.symbian.tools.mtw.ui.deployment.IDeploymentTarget;
456
12b549765c34 Refactoring and adding better bluetooth target decoration
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
    32
import org.symbian.tools.mtw.ui.deployment.IDeploymentTargetType;
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    33
456
12b549765c34 Refactoring and adding better bluetooth target decoration
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
    34
public final class DeploymentTargetTypeDescriptor implements IDeploymentTargetType {
12b549765c34 Refactoring and adding better bluetooth target decoration
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
    35
    public class NullProvider implements IDeploymentTargetType {
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    36
        public IDeploymentTarget[] getTargets(IMTWProject project) {
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    37
            return null;
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    38
        }
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    39
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    40
        public void discoverTargets(IProgressMonitor monitor) throws CoreException {
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    41
            // Do nothing
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    42
        }
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    43
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    44
        public IDeploymentTarget findTarget(IMTWProject project, String id) {
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    45
            return null;
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    46
        }
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    47
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    48
        public boolean targetsDiscovered() {
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    49
            return true;
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    50
        }
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    51
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    52
        public ISchedulingRule getSchedulingRule(IDeploymentTarget target) {
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    53
            return null; // No scheduling
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    54
        }
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    55
    }
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    56
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    57
    private static final DeploymentTargetWrapper[] NO_TARGETS = new DeploymentTargetWrapper[0];
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    58
    private final IConfigurationElement element;
456
12b549765c34 Refactoring and adding better bluetooth target decoration
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
    59
    private IDeploymentTargetType type;
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    60
    private final Map<IDeploymentTarget, DeploymentTargetWrapper> wrappers = new WeakHashMap<IDeploymentTarget, DeploymentTargetWrapper>();
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    61
    private ImageDescriptor imageDescriptor = null;
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    62
456
12b549765c34 Refactoring and adding better bluetooth target decoration
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
    63
    public DeploymentTargetTypeDescriptor(IConfigurationElement element) {
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    64
        this.element = element;
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    65
    }
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    66
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    67
    public boolean supports(IMTWProject project) {
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    68
        // We will support more declarative filtering later
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    69
        return true;
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    70
    }
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    71
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    72
    public DeploymentTargetWrapper[] getTargets(IMTWProject project) {
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    73
        final DeploymentTargetWrapper[] targets = wrap(getProvider().getTargets(project));
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    74
        return targets != null ? targets : NO_TARGETS;
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    75
    }
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    76
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    77
    private DeploymentTargetWrapper[] wrap(IDeploymentTarget[] targets) {
458
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
    78
        if (targets == null) {
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
    79
            return new DeploymentTargetWrapper[0];
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
    80
        } else {
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
    81
            final DeploymentTargetWrapper[] w = new DeploymentTargetWrapper[targets.length];
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
    82
            for (int i = 0; i < targets.length; i++) {
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
    83
                w[i] = wrap(targets[i]);
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    84
            }
458
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
    85
            return w;
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    86
        }
458
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
    87
    }
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
    88
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
    89
    private DeploymentTargetWrapper wrap(final IDeploymentTarget target) {
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
    90
        DeploymentTargetWrapper wrapper = wrappers.get(target);
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
    91
        if (wrapper == null) {
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
    92
            wrapper = new DeploymentTargetWrapper(target, this);
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
    93
            wrappers.put(target, wrapper);
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
    94
        }
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
    95
        return wrapper;
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    96
    }
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    97
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    98
    public void discoverTargets(IProgressMonitor monitor) throws CoreException {
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    99
        getProvider().discoverTargets(monitor);
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   100
    }
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   101
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   102
    public IDeploymentTarget findTarget(IMTWProject project, String id) {
458
5ff93668b08c Emulator deployment was added
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 457
diff changeset
   103
        return wrap(getProvider().findTarget(project, id));
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   104
    }
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   105
456
12b549765c34 Refactoring and adding better bluetooth target decoration
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   106
    private synchronized IDeploymentTargetType getProvider() {
12b549765c34 Refactoring and adding better bluetooth target decoration
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   107
        if (type == null) {
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   108
            try {
456
12b549765c34 Refactoring and adding better bluetooth target decoration
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   109
                type = (IDeploymentTargetType) element.createExecutableExtension("class");
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   110
            } catch (CoreException e) {
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   111
                MTWCoreUI.log("Cannot instantiate provider " + getId(), e);
456
12b549765c34 Refactoring and adding better bluetooth target decoration
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   112
                type = new NullProvider();
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   113
            }
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   114
        }
456
12b549765c34 Refactoring and adding better bluetooth target decoration
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   115
        return type;
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   116
    }
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   117
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   118
    public String getId() {
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   119
        return element.getAttribute("id");
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   120
    }
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   121
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   122
    public boolean targetsDiscovered() {
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   123
        return getProvider().targetsDiscovered();
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   124
    }
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   125
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   126
    public int getPriority() {
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   127
        final String attribute = element.getAttribute("priority");
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   128
        if (attribute != null && attribute.trim().length() > 0) {
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   129
            try {
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   130
                return Integer.parseInt(attribute);
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   131
            } catch (NumberFormatException e) {
457
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
   132
                MTWCoreUI.log("%s is not a valid priority value for %s provider", attribute, getId());
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   133
            }
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   134
        }
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   135
        return 0;
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   136
    }
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   137
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   138
    public ImageDescriptor getImageDescriptor() {
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   139
        if (imageDescriptor == null) {
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   140
            final String image = element.getAttribute("icon");
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   141
            if (image == null) {
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   142
                imageDescriptor = ImageDescriptor.getMissingImageDescriptor();
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   143
            } else {
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   144
                imageDescriptor = MTWCoreUI.imageDescriptorFromPlugin(element.getNamespaceIdentifier(), image);
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   145
            }
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   146
        }
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   147
        return imageDescriptor;
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   148
    }
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   149
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   150
    public ISchedulingRule getSchedulingRule(IDeploymentTarget target) {
456
12b549765c34 Refactoring and adding better bluetooth target decoration
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 455
diff changeset
   151
        return type.getSchedulingRule(target);
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   152
    }
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   153
457
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
   154
    @Override
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
   155
    public int hashCode() {
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
   156
        final int prime = 31;
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
   157
        int result = 1;
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
   158
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
   159
        return result;
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
   160
    }
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
   161
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
   162
    @Override
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
   163
    public boolean equals(Object obj) {
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
   164
        if (this == obj) {
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
   165
            return true;
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
   166
        }
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
   167
        if (obj == null) {
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
   168
            return false;
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
   169
        }
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
   170
        if (getClass() != obj.getClass()) {
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
   171
            return false;
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
   172
        }
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
   173
        DeploymentTargetTypeDescriptor other = (DeploymentTargetTypeDescriptor) obj;
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
   174
        if (getId() == null) {
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
   175
            if (other.getId() != null) {
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
   176
                return false;
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
   177
            }
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
   178
        } else if (!getId().equals(other.getId())) {
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
   179
            return false;
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
   180
        }
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
   181
        return true;
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
   182
    }
f1087591ff71 Targets presentation can be customized
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 456
diff changeset
   183
455
5da55957c779 Bluetooth support was refactored on top of a new frameworks
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   184
}