sysperfana/analyzetoolext/com.nokia.s60tools.analyzetool/src/com/nokia/s60tools/analyzetool/ui/actions/CompileWithAtool.java
changeset 1 1050670c6980
child 6 f65f740e69f9
equal deleted inserted replaced
0:5ad7ad99af01 1:1050670c6980
       
     1 /*
       
     2  * Copyright (c) 2008-2009 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:  Definitions for the class CompileWithAtoolS60
       
    15  *
       
    16  */
       
    17 
       
    18 package com.nokia.s60tools.analyzetool.ui.actions;
       
    19 
       
    20 import org.eclipse.core.resources.IProject;
       
    21 import org.eclipse.jface.action.IAction;
       
    22 import org.eclipse.jface.viewers.ISelection;
       
    23 import org.eclipse.jface.viewers.IStructuredSelection;
       
    24 import org.eclipse.ui.IObjectActionDelegate;
       
    25 import org.eclipse.ui.IWorkbenchPart;
       
    26 import org.eclipse.ui.PartInitException;
       
    27 
       
    28 import com.nokia.s60tools.analyzetool.Activator;
       
    29 import com.nokia.s60tools.analyzetool.builder.BuilderUtil;
       
    30 import com.nokia.s60tools.analyzetool.global.Constants;
       
    31 import com.nokia.s60tools.analyzetool.ui.IActionListener;
       
    32 
       
    33 /**
       
    34  * Class to compile project with atool.exe.
       
    35  *
       
    36  * @author kihe
       
    37  *
       
    38  */
       
    39 public class CompileWithAtool implements IObjectActionDelegate {
       
    40 
       
    41 	/** project reference.*/
       
    42 	public IProject project;
       
    43 
       
    44 	/**
       
    45 	 * Constructor.
       
    46 	 */
       
    47 	public CompileWithAtool() {
       
    48 		super();
       
    49 	}
       
    50 
       
    51 	/**
       
    52 	 * Opens AnalyzeTool view and activates/deactivates build with AnalyzeTool.
       
    53 	 *
       
    54 	 * @param action User selected action
       
    55 	 */
       
    56 	public void run(IAction action) {
       
    57 
       
    58 		// open AnalyzeTool window
       
    59 		try {
       
    60 			Activator.getDefault().getWorkbench().getActiveWorkbenchWindow()
       
    61 					.getActivePage().showView(Constants.ANALYZE_TOOL_VIEW_ID,
       
    62 							null, org.eclipse.ui.IWorkbenchPage.VIEW_CREATE);
       
    63 		} catch (PartInitException pie) {
       
    64 			pie.printStackTrace();
       
    65 		}
       
    66 
       
    67 		IActionListener listener = Activator.getActionListener();
       
    68 		if (listener != null) {
       
    69 			listener.runAction(project, Constants.ACTIONS.RUN_BUILD);
       
    70 		}
       
    71 	}
       
    72 
       
    73 	/**
       
    74 	 * Listening selection changed events and updates AnalyzeTool
       
    75 	 * "build with AnalyzeTool" action state.
       
    76 	 *
       
    77 	 * @param action User selected action
       
    78 	 *
       
    79 	 * @param selection User selection
       
    80 	 */
       
    81 	public void selectionChanged(IAction action, ISelection selection) {
       
    82 
       
    83 		try {
       
    84 			project = (IProject) ((IStructuredSelection) selection)
       
    85 					.getFirstElement();
       
    86 			BuilderUtil util = new BuilderUtil();
       
    87 			action.setChecked(util.isNatureEnabled(project));
       
    88 		} catch (Exception e) {
       
    89 			e.printStackTrace();
       
    90 		}
       
    91 	}
       
    92 
       
    93 	/**
       
    94 	 * Sets the active part for the delegate.
       
    95 	 *
       
    96 	 * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
       
    97 	 *
       
    98 	 * @param action User selected action
       
    99 	 *
       
   100 	 * @param targetPart Workbench Part
       
   101 	 */
       
   102 	public void setActivePart(IAction action, IWorkbenchPart targetPart) {
       
   103 		// MethodDeclaration/Block[count(BlockStatement) = 0 and
       
   104 		// @containsComment = 'false']
       
   105 	}
       
   106 
       
   107 }