srcanaapps/depexplorer/com.nokia.s60tools.appdep/src/com/nokia/s60tools/appdep/ui/actions/ComponentIsUsedByMainViewAction.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 java.util.ArrayList;
       
    22 
       
    23 import org.eclipse.core.runtime.jobs.Job;
       
    24 
       
    25 import com.nokia.s60tools.appdep.core.AppDepSettings;
       
    26 import com.nokia.s60tools.appdep.core.data.ComponentNode;
       
    27 import com.nokia.s60tools.appdep.core.data.ComponentParentNode;
       
    28 import com.nokia.s60tools.appdep.core.job.UsedByOtherComponentsJob;
       
    29 import com.nokia.s60tools.appdep.core.model.ComponentPropertiesData;
       
    30 import com.nokia.s60tools.appdep.plugin.AppDepPlugin;
       
    31 import com.nokia.s60tools.appdep.resources.ImageKeys;
       
    32 import com.nokia.s60tools.appdep.resources.ImageResourceManager;
       
    33 import com.nokia.s60tools.appdep.resources.Messages;
       
    34 import com.nokia.s60tools.appdep.ui.views.main.MainView;
       
    35 import com.nokia.s60tools.appdep.util.AppDepConsole;
       
    36 
       
    37 /**
       
    38  * Starts is used by query from main view's component tree.
       
    39  */
       
    40 public class ComponentIsUsedByMainViewAction extends AbstractMainViewAction{
       
    41 	
       
    42 	/**
       
    43 	 * Result array from is used by query.
       
    44 	 */
       
    45 	ArrayList<ComponentPropertiesData> resultComponentsArrayList = null;
       
    46 
       
    47 	/**
       
    48 	 * Constructor.
       
    49 	 * @param view Reference to the view.
       
    50 	 */
       
    51 	public ComponentIsUsedByMainViewAction(MainView view){
       
    52 		super(view);
       
    53 		
       
    54 		setText(Messages.getString("ComponentIsUsedByMainViewAction.IsUsedBy_Action_Text")); //$NON-NLS-1$
       
    55 		setToolTipText(Messages.getString("ComponentIsUsedByMainViewAction.IsUsedBy_Action_Tooltip")); //$NON-NLS-1$
       
    56 	
       
    57 		
       
    58         /*******************************************************************************
       
    59          * This piece of the graphic is taken/modified from a graphic that is made 
       
    60          * available under the terms of the Eclipse Public License v1.0.
       
    61          *
       
    62          * See 'com.nokia.s60tools.appdep.resources.ImageResourceManager' 
       
    63          * for detailed information about the original graphic.
       
    64          *  
       
    65          *******************************************************************************/        
       
    66 		setImageDescriptor(ImageResourceManager.
       
    67 							getImageDescriptor(ImageKeys.IS_USED_BY_ACTION));				
       
    68 	}
       
    69 	
       
    70 	/* (non-Javadoc)
       
    71 	 * @see org.eclipse.jface.action.IAction#run()
       
    72 	 */
       
    73 	public void run() {
       
    74 		Object obj = view.getComponentTreeSelectedElement();
       
    75 					
       
    76 		if(obj == null){
       
    77 			// We might get null-selections when
       
    78 			// tree is expanded/collapsed.
       
    79 			return;
       
    80 		}
       
    81 
       
    82 		// Component is for sure a component node
       
    83 		ComponentNode node = (ComponentNode) obj;
       
    84 		String componentName;
       
    85 		//If component was a generic component and is replaced with concrete component, must do search with original name
       
    86 		if(node instanceof ComponentParentNode){
       
    87 			ComponentParentNode parentNode = (ComponentParentNode)node;
       
    88 			if(parentNode.wasGenericComponent()){
       
    89 				componentName = parentNode.getOriginalName();
       
    90 			}
       
    91 			else{
       
    92 				componentName = node.getName();							
       
    93 			}
       
    94 		}else{
       
    95 			componentName = node.getName();			
       
    96 		}
       
    97 		
       
    98 
       
    99 		AppDepSettings settings = AppDepSettings.getActiveSettings();
       
   100 		if(settings.getCurrentlyAnalyzedComponentName() != null){
       
   101 			AppDepConsole.getInstance().println(Messages.getString("ComponentIsUsedByMainViewAction.IsUsedBy_Query_Start_Console_Msg") //$NON-NLS-1$
       
   102                     + componentName + "'..."); //$NON-NLS-1$
       
   103 			
       
   104 			resultComponentsArrayList = new ArrayList<ComponentPropertiesData>();
       
   105 			Job jb = new UsedByOtherComponentsJob(Messages.getString("ComponentIsUsedByMainViewAction.IsUsedBy_Job_Title_Text"), settings, //$NON-NLS-1$
       
   106 													componentName,
       
   107 													null,
       
   108 													null,
       
   109 													resultComponentsArrayList,
       
   110 													AppDepPlugin.getCurrentlyActivePage());
       
   111 			
       
   112 			// We do not want cache generation to block other 
       
   113 			// jobs and therefore using the lowest priority
       
   114 			jb.setPriority(Job.DECORATE);
       
   115 			jb.schedule();
       
   116 		}
       
   117 				
       
   118 		// Remember to always call AbstractMainViewAction
       
   119 		// base class implementation
       
   120 		super.run();		
       
   121 	}
       
   122 }