trace/tracebuilder/com.nokia.tracebuilder.view/src/com/nokia/tracebuilder/action/TraceBuilderGlobalAction.java
changeset 10 ed1c9f64298a
equal deleted inserted replaced
9:14dc2103a631 10:ed1c9f64298a
       
     1 /*
       
     2  * Copyright (c) 2008 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  * Base class for all global action objects of Trace Builder
       
    17  *
       
    18  */
       
    19 package com.nokia.tracebuilder.action;
       
    20 
       
    21 import org.eclipse.core.commands.ExecutionEvent;
       
    22 import org.eclipse.core.commands.ExecutionException;
       
    23 import org.eclipse.core.commands.IHandler;
       
    24 import org.eclipse.core.commands.IHandlerListener;
       
    25 
       
    26 import com.nokia.tracebuilder.engine.TraceBuilderGlobals;
       
    27 import com.nokia.tracebuilder.model.TraceBuilderException;
       
    28 
       
    29 /**
       
    30  * Base class for all global action objects of Trace Builder
       
    31  * 
       
    32  */
       
    33 public abstract class TraceBuilderGlobalAction implements IHandler {
       
    34 
       
    35 	/**
       
    36 	 * Constructor
       
    37 	 */
       
    38 	public TraceBuilderGlobalAction() {
       
    39 	}
       
    40 
       
    41 	/*
       
    42 	 * (non-Javadoc)
       
    43 	 * 
       
    44 	 * @see org.eclipse.core.commands.IHandler#addHandlerListener(org.eclipse.core
       
    45 	 *      .commands.IHandlerListener)
       
    46 	 */
       
    47 	public void addHandlerListener(IHandlerListener handlerListener) {
       
    48 	}
       
    49 
       
    50 	/*
       
    51 	 * (non-Javadoc)
       
    52 	 * 
       
    53 	 * @see org.eclipse.core.commands.IHandler#dispose()
       
    54 	 */
       
    55 	public void dispose() {
       
    56 	}
       
    57 
       
    58 	/*
       
    59 	 * (non-Javadoc)
       
    60 	 * 
       
    61 	 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.
       
    62 	 *      ExecutionEvent)
       
    63 	 */
       
    64 	public Object execute(ExecutionEvent event) throws ExecutionException {
       
    65 		try {
       
    66 			if (TraceBuilderGlobals.isViewRegistered()) {
       
    67 				doRun();
       
    68 			}
       
    69 		} catch (TraceBuilderException e) {
       
    70 			TraceBuilderGlobals.getEvents().postError(e);
       
    71 		}
       
    72 
       
    73 		return null;
       
    74 	}
       
    75 
       
    76 	/*
       
    77 	 * (non-Javadoc)
       
    78 	 * 
       
    79 	 * @see org.eclipse.core.commands.IHandler#isEnabled()
       
    80 	 */
       
    81 	public boolean isEnabled() {
       
    82 		return true;
       
    83 	}
       
    84 
       
    85 	/*
       
    86 	 * (non-Javadoc)
       
    87 	 * 
       
    88 	 * @see org.eclipse.core.commands.IHandler#isHandled()
       
    89 	 */
       
    90 	public boolean isHandled() {
       
    91 		return true;
       
    92 	}
       
    93 
       
    94 	/*
       
    95 	 * (non-Javadoc)
       
    96 	 * 
       
    97 	 * @see org.eclipse.core.commands.IHandler#removeHandlerListener(org.eclipse.
       
    98 	 *      core.commands.IHandlerListener)
       
    99 	 */
       
   100 	public void removeHandlerListener(IHandlerListener handlerListener) {
       
   101 	}
       
   102 
       
   103 	/**
       
   104 	 * Runs this action
       
   105 	 * 
       
   106 	 * @throws TraceBuilderException
       
   107 	 *             if processing fails, shows an error dialog based on the
       
   108 	 *             exception content
       
   109 	 */
       
   110 	protected abstract void doRun() throws TraceBuilderException;
       
   111 
       
   112 }