trace/tracebuilder/com.nokia.tracebuilder.view/src/com/nokia/tracebuilder/action/TraceBuilderGlobalAction.java
changeset 10 ed1c9f64298a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trace/tracebuilder/com.nokia.tracebuilder.view/src/com/nokia/tracebuilder/action/TraceBuilderGlobalAction.java	Wed Jun 23 14:35:40 2010 +0300
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ * Base class for all global action objects of Trace Builder
+ *
+ */
+package com.nokia.tracebuilder.action;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.commands.IHandlerListener;
+
+import com.nokia.tracebuilder.engine.TraceBuilderGlobals;
+import com.nokia.tracebuilder.model.TraceBuilderException;
+
+/**
+ * Base class for all global action objects of Trace Builder
+ * 
+ */
+public abstract class TraceBuilderGlobalAction implements IHandler {
+
+	/**
+	 * Constructor
+	 */
+	public TraceBuilderGlobalAction() {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.core.commands.IHandler#addHandlerListener(org.eclipse.core
+	 *      .commands.IHandlerListener)
+	 */
+	public void addHandlerListener(IHandlerListener handlerListener) {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.core.commands.IHandler#dispose()
+	 */
+	public void dispose() {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.
+	 *      ExecutionEvent)
+	 */
+	public Object execute(ExecutionEvent event) throws ExecutionException {
+		try {
+			if (TraceBuilderGlobals.isViewRegistered()) {
+				doRun();
+			}
+		} catch (TraceBuilderException e) {
+			TraceBuilderGlobals.getEvents().postError(e);
+		}
+
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.core.commands.IHandler#isEnabled()
+	 */
+	public boolean isEnabled() {
+		return true;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.core.commands.IHandler#isHandled()
+	 */
+	public boolean isHandled() {
+		return true;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.core.commands.IHandler#removeHandlerListener(org.eclipse.
+	 *      core.commands.IHandlerListener)
+	 */
+	public void removeHandlerListener(IHandlerListener handlerListener) {
+	}
+
+	/**
+	 * Runs this action
+	 * 
+	 * @throws TraceBuilderException
+	 *             if processing fails, shows an error dialog based on the
+	 *             exception content
+	 */
+	protected abstract void doRun() throws TraceBuilderException;
+
+}