org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/internal/deployment/targets/AdapterFactory.java
changeset 460 c0bff5ed874c
parent 458 5ff93668b08c
equal deleted inserted replaced
459:c278f0c8917f 460:c0bff5ed874c
       
     1 /**
       
     2  * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of the License "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Symbian Foundation - initial contribution.
       
    11  * Contributors:
       
    12  * Description:
       
    13  * Overview:
       
    14  * Details:
       
    15  * Platforms/Drives/Compatibility:
       
    16  * Assumptions/Requirement/Pre-requisites:
       
    17  * Failures and causes:
       
    18  */
       
    19 package org.symbian.tools.mtw.internal.deployment.targets;
       
    20 
       
    21 import org.eclipse.core.runtime.IAdapterFactory;
       
    22 import org.eclipse.jface.resource.ImageDescriptor;
       
    23 import org.eclipse.ui.model.IWorkbenchAdapter;
       
    24 import org.eclipse.ui.model.WorkbenchAdapter;
       
    25 
       
    26 @SuppressWarnings("rawtypes")
       
    27 public class AdapterFactory implements IAdapterFactory {
       
    28     private final IWorkbenchAdapter adapter = new WorkbenchAdapter() {
       
    29         @Override
       
    30         public ImageDescriptor getImageDescriptor(Object object) {
       
    31             if (object instanceof ExternalApplicationDeploymentType) {
       
    32                 return ImageDescriptor.createFromImageData(((ExternalApplicationDeploymentType) object).getProgram()
       
    33                         .getImageData());
       
    34             }
       
    35             return super.getImageDescriptor(object);
       
    36         }
       
    37 
       
    38         public String getLabel(Object object) {
       
    39             if (object instanceof ExternalApplicationDeploymentType) {
       
    40                 return ((ExternalApplicationDeploymentType) object).getName();
       
    41             }
       
    42             return super.getLabel(object);
       
    43         };
       
    44     };
       
    45 
       
    46     public Object getAdapter(Object adaptableObject, Class adapterType) {
       
    47         if (adaptableObject instanceof ExternalApplicationDeploymentType
       
    48                 && IWorkbenchAdapter.class.isAssignableFrom(adapterType)) {
       
    49             return adapter;
       
    50         }
       
    51         return null;
       
    52     }
       
    53 
       
    54     public Class[] getAdapterList() {
       
    55         return new Class[] { IWorkbenchAdapter.class };
       
    56     }
       
    57 
       
    58 }