From: Francois Chouinard Date: Wed, 3 Mar 2010 14:36:15 +0000 (+0000) Subject: [Bug293101] Context menu fix: removed the unimplemented menu choices and enabled... X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=f0fb96021108b510f3ed4a7e7c2b4be943f4fa5c;p=deliverable%2Ftracecompass.git [Bug293101] Context menu fix: removed the unimplemented menu choices and enabled the remaining Open --- diff --git a/org.eclipse.linuxtools.lttng.ui/plugin.xml b/org.eclipse.linuxtools.lttng.ui/plugin.xml index 2e184da49f..55bf5083f7 100644 --- a/org.eclipse.linuxtools.lttng.ui/plugin.xml +++ b/org.eclipse.linuxtools.lttng.ui/plugin.xml @@ -261,12 +261,12 @@ label="Close Project" style="push"> - - + - - - - - - - - - - - - + + + + + + + + + diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/ProjectView.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/ProjectView.java index 0f64981954..7199752029 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/ProjectView.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/ProjectView.java @@ -161,7 +161,7 @@ public class ProjectView extends TmfView { private boolean waitForCompletion = true; - private void selectExperiment(LTTngExperimentNode experiment) { + public void selectExperiment(LTTngExperimentNode experiment) { String expId = experiment.getName(); if (fSelectedExperiment != null) fSelectedExperiment.deregister(); diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/handlers/OpenExperimentHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/handlers/OpenExperimentHandler.java index 023d99d588..c7948b4dbb 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/handlers/OpenExperimentHandler.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/handlers/OpenExperimentHandler.java @@ -16,8 +16,12 @@ 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 org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.linuxtools.lttng.ui.views.project.ProjectView; import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngExperimentNode; -import org.eclipse.swt.widgets.MessageBox; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; /** @@ -34,6 +38,23 @@ public class OpenExperimentHandler implements IHandler { // ------------------------------------------------------------------------ public boolean isEnabled() { + // Check if we are closing down + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window == null) + return false; + + // Check if a trace is selected + IWorkbenchPage page = window.getActivePage(); + if (!(page.getActivePart() instanceof ProjectView)) + return false; + + // Check if a trace is selected + ISelection selection = page.getSelection(ProjectView.ID); + if (selection instanceof StructuredSelection) { + Object element = ((StructuredSelection) selection).getFirstElement(); + fExperiment = (element instanceof LTTngExperimentNode) ? (LTTngExperimentNode) element : null; + } + return (fExperiment != null); } @@ -48,16 +69,15 @@ public class OpenExperimentHandler implements IHandler { public Object execute(ExecutionEvent event) throws ExecutionException { - MessageBox mb = new MessageBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); - mb.setText("Open Experiment"); - mb.setMessage("Not implemented yet"); - mb.open(); + // Set the selection to the project + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + ProjectView projectView = (ProjectView) page.getActivePart(); - return null; - } + if (projectView != null) { + projectView.selectExperiment(fExperiment); + } - public void dispose() { - // TODO Auto-generated method stub + return null; } // ------------------------------------------------------------------------ @@ -72,4 +92,9 @@ public class OpenExperimentHandler implements IHandler { // TODO Auto-generated method stub } + public void dispose() { + // TODO Auto-generated method stub + + } + }