Issue #427 Right click on editor tab support

Change-Id: Ia9240a01c145c81bbf98268d4df5fd2242ca7987

Former-commit-id: a4965d6bf9 [formerly 202bd0adf8] [formerly d2d3a245b3] [formerly aa000b4b06 [formerly d2d3a245b3 [formerly 7597db5bbc0642072143e4c7ea0291108154eb40]]]
Former-commit-id: aa000b4b06
Former-commit-id: a6d73562ce75aff32ab9bfe5f1b0ddce7553fd0c [formerly 6aae45687a]
Former-commit-id: 9792be406a
This commit is contained in:
Nate Jensen 2012-03-29 10:44:08 -05:00
parent afa5959912
commit 274e2df586
9 changed files with 439 additions and 1 deletions

View file

@ -149,4 +149,12 @@
name="Map">
</editor>
</extension>
<extension
point="com.raytheon.viz.ui.editorMenuAddition">
<editorMenuAddition
class="com.raytheon.uf.viz.collaboration.ui.actions.ShareEditorAction"
name="Share Editor"
icon="icons/add_correction.gif">
</editorMenuAddition>
</extension>
</plugin>

View file

@ -79,12 +79,14 @@ public class CollaborationUtils {
}
/**
* Get an descriptor for the file in the icon directory.
* Get an descriptor for the file in the icon directory. DEPRECATED: Use
* IconUtil instead
*
* @param name
* - file name
* @return imageDescriptor
*/
@Deprecated
public static ImageDescriptor getImageDescriptor(String name) {
String iconPath = "icons" + File.separator;
URL url = FileLocator.find(Activator.getDefault().getBundle(),

View file

@ -0,0 +1,59 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.ui.actions;
import com.raytheon.viz.ui.actions.ContributedEditorMenuAction;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 21, 2012 mnash Initial creation
*
* </pre>
*
* @author mnash
* @version 1.0
*/
public class ShareEditorAction extends ContributedEditorMenuAction {
@Override
public boolean shouldBeVisible() {
// TODO only return true if you are the DataProvider on a session AND
// the editor is not already shared
if (true) {
return true;
}
return true;
}
@Override
public void run() {
// TODO need to add this editor to the list of editors associated with
// the collaboration session
}
}

View file

@ -51,6 +51,7 @@ Export-Package: com.raytheon.uf.viz.core,
com.raytheon.uf.viz.core.font,
com.raytheon.uf.viz.core.geom,
com.raytheon.uf.viz.core.globals,
com.raytheon.uf.viz.core.icon,
com.raytheon.uf.viz.core.interp,
com.raytheon.uf.viz.core.jobs,
com.raytheon.uf.viz.core.legend,

View file

@ -0,0 +1,86 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.core.icon;
import java.io.File;
import java.net.URL;
import org.eclipse.core.internal.registry.osgi.OSGIUtils;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.resource.ImageDescriptor;
import org.osgi.framework.Bundle;
/**
* Utilities for using icons in Viz
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 29, 2012 njensen Initial creation
*
* </pre>
*
* @author njensen
* @version 1.0
*/
@SuppressWarnings("restriction")
public class IconUtil {
/**
* Creates an ImageDescriptor for an icon
*
* @param bundleName
* the name of the bundle to find the icon in
* @param name
* the name of the icon
* @return the ImageDescriptor corresponding to the icon
*/
public static ImageDescriptor getImageDescriptor(String bundleName,
String name) {
return getImageDescriptor(OSGIUtils.getDefault().getBundle(bundleName),
name);
}
/**
* Creates an ImageDescriptor for an icon
*
* @param bundle
* the bundle to find the icon in
* @param name
* the name of the icon
* @return the ImageDescriptor corresponding to the icon
*/
public static ImageDescriptor getImageDescriptor(Bundle bundle, String name) {
String path = null;
if (!name.startsWith("icons")) {
path = "icons" + File.separator + name;
} else {
path = name;
}
URL url = FileLocator.find(bundle, new Path(path), null);
return ImageDescriptor.createFromURL(url);
}
}

View file

@ -3,7 +3,17 @@ package com.raytheon.viz.ui.personalities.awips;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.dialogs.MessageDialog;
@ -28,11 +38,15 @@ import org.eclipse.ui.internal.presentations.util.ISystemMenu;
import org.eclipse.ui.presentations.IPresentablePart;
import org.eclipse.ui.presentations.IStackPresentationSite;
import com.raytheon.uf.viz.core.icon.IconUtil;
import com.raytheon.viz.ui.EditorUtil;
import com.raytheon.viz.ui.actions.ContributedEditorMenuAction;
import com.raytheon.viz.ui.editor.AbstractEditor;
public class VizEditorSystemMenu implements ISystemMenu {
private static final String EDITOR_MENU_EXTENSION_POINT = "com.raytheon.viz.ui.editorMenuAddition";
private static class CustomCloseAll extends SystemMenuCloseAll {
private IStackPresentationSite presentation;
@ -139,6 +153,8 @@ public class VizEditorSystemMenu implements ISystemMenu {
private SystemMenuCloseAll closeAll;
private List<ContributedEditorMenuAction> userContributionActions;
private ActionFactory.IWorkbenchAction openAgain;
/**
@ -178,6 +194,47 @@ public class VizEditorSystemMenu implements ISystemMenu {
menuManager.add(closeAll);
menuManager.add(new Separator());
menuManager.add(openAgain);
// grab any user contributed items using an extension point
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint point = registry
.getExtensionPoint(EDITOR_MENU_EXTENSION_POINT);
if (point != null) {
menuManager.add(new Separator());
userContributionActions = new ArrayList<ContributedEditorMenuAction>();
for (IExtension ext : point.getExtensions()) {
IConfigurationElement[] element = ext
.getConfigurationElements();
for (final IConfigurationElement el : element) {
Object ob;
try {
ob = el.createExecutableExtension("class");
ContributedEditorMenuAction action = (ContributedEditorMenuAction) ob;
String icon = el.getAttribute("icon");
if (icon != null) {
action.setImageDescriptor(IconUtil
.getImageDescriptor(el.getContributor()
.getName(), icon));
}
action.setId(el.getAttribute("name"));
action.setText(el.getAttribute("name"));
// action.setImageDescriptor(newImage)
userContributionActions.add(action);
} catch (CoreException e) {
// TODO Auto-generated catch block. Please revise as
// appropriate.
// statusHandler.handle(Priority.PROBLEM,
// e.getLocalizedMessage(), e);
e.printStackTrace();
}
}
}
// loop through and add all the actions
for (Action act : userContributionActions) {
menuManager.add(act);
}
}
}
String getMoveMenuText() {
@ -202,6 +259,36 @@ public class VizEditorSystemMenu implements ISystemMenu {
maximize.update();
close.setTarget(currentSelection);
// loop through all the contributed actions and update them as necessary
List<ContributedEditorMenuAction> shouldBeShown = new ArrayList<ContributedEditorMenuAction>();
List<ContributedEditorMenuAction> shouldBeHidden = new ArrayList<ContributedEditorMenuAction>();
for (ContributedEditorMenuAction action : userContributionActions) {
action.setPart(currentSelection);
if (action.shouldBeVisible()) {
shouldBeShown.add(action);
} else {
shouldBeHidden.add(action);
}
}
for (IContributionItem item : menuManager.getItems()) {
if (item instanceof ActionContributionItem) {
IAction action = ((ActionContributionItem) item).getAction();
if (shouldBeShown.contains(action)) {
shouldBeShown.remove(action);
} else if (shouldBeHidden.contains(action)) {
menuManager.remove(item);
}
}
}
if (shouldBeShown.size() > 0) {
for (ContributedEditorMenuAction action : shouldBeShown) {
menuManager.add(action);
}
}
Menu aMenu = menuManager.createContextMenu(parent);
menuManager.update(true);
aMenu.setLocation(displayCoordinates.x, displayCoordinates.y);

View file

@ -24,6 +24,7 @@
<extension-point id="contextualMenu" name="contextualMenu" schema="schema/contextualMenu.exsd"/>
<extension-point id="perspectiveManager" name="perspectiveManager" schema="schema/perspectiveManager.exsd"/>
<extension-point id="com.raytheon.uf.viz.ui.mouse.action" name="Mouse Preference" schema="schema/mousePreference.exsd"/>
<extension-point id="editorMenuAddition" name="editorMenuAddition" schema="schema/editorMenuAddition.exsd"/>
<extension
point="org.eclipse.ui.views">

View file

@ -0,0 +1,113 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="com.raytheon.viz.ui" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appInfo>
<meta.schema plugin="com.raytheon.viz.ui" id="editorMenuAddition" name="editorMenuAddition"/>
</appInfo>
<documentation>
[Enter description of this extension point.]
</documentation>
</annotation>
<element name="extension">
<annotation>
<appInfo>
<meta.element />
</appInfo>
</annotation>
<complexType>
<sequence>
<element ref="editorMenuAddition" minOccurs="1" maxOccurs="unbounded"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute translatable="true"/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>
<element name="editorMenuAddition">
<complexType>
<attribute name="class" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="icon" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
<appInfo>
<meta.section type="since"/>
</appInfo>
<documentation>
[Enter the first release in which this extension point appears.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="examples"/>
</appInfo>
<documentation>
[Enter extension point usage example here.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="apiinfo"/>
</appInfo>
<documentation>
[Enter API information here.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="implementation"/>
</appInfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
</annotation>
</schema>

View file

@ -0,0 +1,81 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.ui.actions;
import org.eclipse.jface.action.Action;
import org.eclipse.ui.internal.presentations.ISelfUpdatingAction;
import org.eclipse.ui.presentations.IPresentablePart;
/**
* Every type of user contributed action to the editor should extend this class
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 21, 2012 mnash Initial creation
*
* </pre>
*
* @author mnash
* @version 1.0
*/
@SuppressWarnings("restriction")
public class ContributedEditorMenuAction extends Action implements
ISelfUpdatingAction {
private IPresentablePart part;
/**
*
*/
public ContributedEditorMenuAction() {
// TODO Auto-generated constructor stub
}
@Override
public void update() {
// do nothing to for this class
}
@Override
public boolean shouldBeVisible() {
return true;
}
/**
* @param part
* the part to set
*/
public void setPart(IPresentablePart part) {
this.part = part;
}
/**
* @return the part
*/
public IPresentablePart getPart() {
return part;
}
}