package org.csstudio.trends.databrowser;

import org.csstudio.trends.databrowser.ploteditor.PlotEditor;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;

/** Action connected to workbench menu action set for opening a new editor.
 *  @author Kay Kasemir
 */
public class NewDataBrowserAction implements IWorkbenchWindowActionDelegate
{
	public void init(IWorkbenchWindow window)
	{ /* NOP */ }

	public void selectionChanged(IAction action, ISelection selection)
    { /* NOP */ }

	public void run(IAction action)
	{
		PlotEditor.createInstance();
	}

	public void dispose()
    { /* NOP */ }
}

@@ -179,24 +179,58 @@
 ISelection;%0A
+import org.eclipse.ui.IWorkbench;%0A
 import org.e
@@ -257,16 +257,16 @@
 Window;%0A
-
 import o
@@ -310,16 +310,92 @@
 elegate;
+%0Aimport org.eclipse.ui.PlatformUI;%0Aimport org.eclipse.ui.WorkbenchException;
 %0A%0A/** Ac
@@ -752,16 +752,16 @@
 ion)%0A%09%7B%0A
-
 %09%09PlotEd
@@ -783,16 +783,421 @@
 ance();%0A
+%09%09// Try to switch to the DataBrowser perspective%0A%09%09// (suggested by Helge Rickens)%0A        final IWorkbench workbench = PlatformUI.getWorkbench();%0A        final IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();%0A        try%0A        %7B%0A            workbench.showPerspective(Perspective.ID, window);%0A        %7D%0A        catch (WorkbenchException ex)%0A        %7B%0A            // Never mind%0A        %7D%0A
 %09%7D%0A%0A%09pub

switch persepctive