<extension
point="org.eclipse.ui.menus">
<menuContribution
- locationURI="popup:org.eclipse.ui.popup.any?after=additions">
+ allPopups="false"
+ locationURI="popup:org.eclipse.ui.popup.any?after=group.open">
<command
commandId="org.eclipse.linuxtools.tmf.ui.openFile"
label="%command.OpenFile.label"
</with>
</visibleWhen>
</command>
+ <command
+ commandId="org.eclipse.ui.navigate.openResource"
+ disabledIcon="/icons/dlcl16/open.gif"
+ icon="/icons/elcl16/open.gif"
+ label="%command.open"
+ mnemonic="%command.open.mnemonic"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="selection">
+ <count
+ value="1">
+ </count>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <or>
+ <instanceof
+ value="org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement">
+ </instanceof>
+ <instanceof
+ value="org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement">
+ </instanceof>
+ <instanceof
+ value="org.eclipse.linuxtools.tmf.ui.project.model.TmfAnalysisOutputElement">
+ </instanceof>
+ </or>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ <menuContribution
+ locationURI="popup:org.eclipse.ui.popup.any?after=additions">
<separator
name="org.eclipse.linuxtools.tmf.ui.separator1"
visible="true">
name="org.eclipse.linuxtools.tmf.ui.separator0"
visible="true">
</separator>
- <command
- commandId="org.eclipse.ui.navigate.openResource"
- disabledIcon="/icons/dlcl16/open.gif"
- icon="/icons/elcl16/open.gif"
- label="%command.open"
- mnemonic="%command.open.mnemonic"
- style="push">
- <visibleWhen
- checkEnabled="false">
- <with
- variable="selection">
- <count
- value="1">
- </count>
- <iterate
- ifEmpty="false"
- operator="and">
- <or>
- <instanceof
- value="org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement">
- </instanceof>
- <instanceof
- value="org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement">
- </instanceof>
- <instanceof
- value="org.eclipse.linuxtools.tmf.ui.project.model.TmfAnalysisOutputElement">
- </instanceof>
- </or>
- </iterate>
- </with>
- </visibleWhen>
- </command>
<command
commandId="org.eclipse.ui.edit.copy"
disabledIcon="icons/dtool16/copy_edit.gif"
/*******************************************************************************
-* Copyright (c) 2012, 2013 Ericsson
+* Copyright (c) 2012, 2014 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
package org.eclipse.linuxtools.internal.tmf.ui.project.handlers;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement;
import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.OpenWithMenu;
import org.eclipse.ui.navigator.CommonActionProvider;
import org.eclipse.ui.navigator.ICommonActionConstants;
import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+import org.eclipse.ui.navigator.ICommonMenuConstants;
import org.eclipse.ui.navigator.ICommonViewerSite;
import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
private DeleteAction deleteAction;
private RefreshAction refreshAction;
+ private IWorkbenchPage page;
+
/**
* Default constructor
*/
ICommonViewerSite viewSite = aSite.getViewSite();
if (viewSite instanceof ICommonViewerWorkbenchSite) {
ICommonViewerWorkbenchSite workbenchSite = (ICommonViewerWorkbenchSite) viewSite;
- openAction = new OpenAction(workbenchSite.getPage(), workbenchSite.getSelectionProvider());
- deleteAction = new DeleteAction(workbenchSite.getPage(), workbenchSite.getSelectionProvider());
- refreshAction = new RefreshAction(workbenchSite.getPage(), workbenchSite.getSelectionProvider());
+ page = workbenchSite.getPage();
+ openAction = new OpenAction(page, workbenchSite.getSelectionProvider());
+ deleteAction = new DeleteAction(page, workbenchSite.getSelectionProvider());
+ refreshAction = new RefreshAction(page, workbenchSite.getSelectionProvider());
+ }
+ }
+
+ @Override
+ public void fillContextMenu(IMenuManager menu) {
+ ISelection selection = getContext().getSelection();
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+ if (structuredSelection.size() == 1 && structuredSelection.getFirstElement() instanceof TmfTraceElement) {
+ TmfTraceElement traceElement = (TmfTraceElement) structuredSelection.getFirstElement();
+ if (traceElement.getResource() instanceof IFile) {
+ MenuManager openWithMenu = new MenuManager(Messages.TmfActionProvider_OpenWith);
+ openWithMenu.add(new OpenWithMenu(page, traceElement.getResource()));
+ menu.insertAfter(ICommonMenuConstants.GROUP_OPEN_WITH, openWithMenu);
+ }
+ }
}
}