srcanaapps/depexplorer/com.nokia.s60tools.appdep/src/com/nokia/s60tools/appdep/ui/actions/SetNewRootComponentListViewAction.java
changeset 0 a02c979e8dfd
equal deleted inserted replaced
-1:000000000000 0:a02c979e8dfd
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "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 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18  
       
    19 package com.nokia.s60tools.appdep.ui.actions;
       
    20 
       
    21 import org.eclipse.jface.action.Action;
       
    22 
       
    23 import com.nokia.s60tools.appdep.core.AppDepSettings;
       
    24 import com.nokia.s60tools.appdep.core.ITargetPlatform;
       
    25 import com.nokia.s60tools.appdep.core.model.ComponentPropertiesData;
       
    26 import com.nokia.s60tools.appdep.resources.ImageKeys;
       
    27 import com.nokia.s60tools.appdep.resources.ImageResourceManager;
       
    28 import com.nokia.s60tools.appdep.resources.Messages;
       
    29 import com.nokia.s60tools.appdep.ui.views.listview.ListView;
       
    30 import com.nokia.s60tools.appdep.ui.views.main.MainView;
       
    31 
       
    32 /**
       
    33  * Sets selected component as new root component.
       
    34  * Available in component list view.
       
    35  */
       
    36 public class SetNewRootComponentListViewAction extends Action {
       
    37 	
       
    38 	/**
       
    39 	 * Component list view reference.
       
    40 	 */
       
    41 	private final ListView listView;
       
    42 	
       
    43 	/**
       
    44 	 * Constructor.
       
    45 	 * @param view Reference to the view.
       
    46 	 */
       
    47 	public SetNewRootComponentListViewAction(ListView view){
       
    48 		this.listView = view;
       
    49 		
       
    50 		setText(Messages.getString("SetNewRootComponentListViewAction.SetNewRoot_Action_Text")); //$NON-NLS-1$
       
    51 		setToolTipText(Messages.getString("SetNewRootComponentListViewAction.SetNewRoot_Action_Tooltip")); //$NON-NLS-1$
       
    52 		
       
    53 		
       
    54         /*******************************************************************************
       
    55          * This piece of the graphic is taken/modified from a graphic that is made 
       
    56          * available under the terms of the Eclipse Public License v1.0.
       
    57          *
       
    58          * See 'com.nokia.s60tools.appdep.resources.ImageResourceManager' 
       
    59          * for detailed information about the original graphic.
       
    60          *  
       
    61          *******************************************************************************/        
       
    62 		setImageDescriptor(ImageResourceManager.
       
    63 								getImageDescriptor(ImageKeys.NEW_ROOT_ACTION));				
       
    64 	}
       
    65 	
       
    66 	/* (non-Javadoc)
       
    67 	 * @see org.eclipse.jface.action.IAction#run()
       
    68 	 */
       
    69 	public void run() {
       
    70 
       
    71 		try {
       
    72 			Object obj = listView.getComponentListSelectedElement();
       
    73 
       
    74 			MainView.abortCurrentlyOngoingSearches();
       
    75 			
       
    76 			// The object is for sure an instance of ComponentPropertiesData
       
    77 			ComponentPropertiesData propData = (ComponentPropertiesData) obj;
       
    78 			String selectedComponentName = propData.getFilename();
       
    79 			ITargetPlatform targetPlatform = propData.getTargetPlatform();
       
    80 			
       
    81 			AppDepSettings st = AppDepSettings.getActiveSettings();
       
    82 			st.setCurrentlyAnalyzedComponentName(selectedComponentName);
       
    83 			st.setCurrentlyAnalyzedComponentTargetPlatform(targetPlatform);
       
    84 			MainView.update();
       
    85 						
       
    86 			// Remember to always call AbstractMainViewAction
       
    87 			// base class implementation
       
    88 			super.run();
       
    89 		} catch (Exception e) {
       
    90 			e.printStackTrace();
       
    91 		}
       
    92 		
       
    93 	}
       
    94 		
       
    95 }