Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonald.g.dunne2018-06-14 13:53:11 -0400
committerDonald Dunne2018-06-26 10:27:29 -0400
commit446e18a4ebda8cea761353e8d22205c36580bd2c (patch)
tree3a26cc4182e58decec1da0fab888e3a98e0c0c99
parent08d69e4cd80cc3ab8e4e0a23853d19af124a400f (diff)
downloadorg.eclipse.osee-446e18a4ebda8cea761353e8d22205c36580bd2c.tar.gz
org.eclipse.osee-446e18a4ebda8cea761353e8d22205c36580bd2c.tar.xz
org.eclipse.osee-446e18a4ebda8cea761353e8d22205c36580bd2c.zip
feature: Add Open-With menu to AE relations section
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/OpenContributionItem.java49
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/RelationsComposite.java113
2 files changed, 42 insertions, 120 deletions
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/OpenContributionItem.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/OpenContributionItem.java
index 0f17ae11d1..d411c1f2a0 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/OpenContributionItem.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/OpenContributionItem.java
@@ -121,28 +121,38 @@ public class OpenContributionItem extends ContributionItem {
@Override
public void fill(final Menu parent, int index) {
+ fill(parent, index, true);
+ }
+
+ public void fill(final Menu parent, int index, boolean includeOpen) {
if (index == -1) {
index = parent.getItemCount();
}
- IContributionItem openItem = createDefaultOpenItem();
- openItem.fill(parent, index);
- MenuItem open = parent.getItem(0);
- if (open != null) {
- open.setEnabled(parent.isEnabled());
+ if (includeOpen) {
+ IContributionItem openItem = createDefaultOpenItem();
+ openItem.fill(parent, index);
+ MenuItem open = parent.getItem(0);
+ if (open != null) {
+ open.setEnabled(parent.isEnabled());
+ }
}
- final MenuItem item = new MenuItem(parent, SWT.CASCADE, index + 1);
- item.setText("Open With");
+ MenuItem openWithMenuItem = null;
+ if (includeOpen) {
+ openWithMenuItem = new MenuItem(parent, SWT.CASCADE, index + 1);
+ } else {
+ openWithMenuItem = new MenuItem(parent, SWT.CASCADE, index);
+ }
+ openWithMenuItem.setText("Open With");
- Menu subMenu = new Menu(item);
+ Menu subMenu = new Menu(openWithMenuItem);
fillOpenWithSubMenu(subMenu);
- item.setMenu(subMenu);
- item.setEnabled(isMenuEnabled(subMenu));
+ openWithMenuItem.setMenu(subMenu);
- final OpenWithOnShowListener listener = new OpenWithOnShowListener(item);
+ final OpenWithOnShowListener listener = new OpenWithOnShowListener(openWithMenuItem);
parent.addMenuListener(listener);
- item.addDisposeListener(new DisposeListener() {
+ openWithMenuItem.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
@@ -171,15 +181,6 @@ public class OpenContributionItem extends ContributionItem {
}
};
- private static boolean isMenuEnabled(Menu menu) {
- for (MenuItem item : menu.getItems()) {
- if (item.isEnabled()) {
- return true;
- }
- }
- return false;
- }
-
private IContributionItem createDefaultOpenItem() {
clearDefaultOpenItem();
defaultOpenItem = createContributionItem(DEFAULT_OPEN_CMD_ID, null);
@@ -188,7 +189,7 @@ public class OpenContributionItem extends ContributionItem {
private Collection<IContributionItem> createOpenWithItems() {
clearOpenWithItems();
- List<Artifact> artifacts = getSelectedArtifacts();
+ Collection<Artifact> artifacts = getSelectedArtifacts();
boolean readOnly = false;
if (!artifacts.isEmpty()) {
for (Artifact art : artifacts) {
@@ -270,7 +271,7 @@ public class OpenContributionItem extends ContributionItem {
return toReturn;
}
- private List<Artifact> getSelectedArtifacts() {
+ private Collection<Artifact> getSelectedArtifacts() {
List<Artifact> toReturn = Collections.emptyList();
ISelectionProvider selectionProvider = getSelectionProvider();
if (selectionProvider != null) {
@@ -306,7 +307,6 @@ public class OpenContributionItem extends ContributionItem {
Menu subMenu = new Menu(parentItem);
fillOpenWithSubMenu(subMenu);
parentItem.setMenu(subMenu);
- parentItem.setEnabled(isMenuEnabled(subMenu));
}
@Override
@@ -356,4 +356,5 @@ public class OpenContributionItem extends ContributionItem {
}
}
}
+
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/RelationsComposite.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/RelationsComposite.java
index a106c0b17c..96c1708334 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/RelationsComposite.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/RelationsComposite.java
@@ -16,7 +16,6 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
-import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import org.eclipse.jface.dialogs.MessageDialog;
@@ -40,12 +39,12 @@ import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.AccessPolicy;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.ISelectedArtifact;
+import org.eclipse.osee.framework.skynet.core.artifact.ISelectedArtifacts;
import org.eclipse.osee.framework.skynet.core.relation.RelationManager;
import org.eclipse.osee.framework.skynet.core.relation.RelationTypeSideSorter;
+import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
import org.eclipse.osee.framework.ui.plugin.util.HelpUtil;
import org.eclipse.osee.framework.ui.skynet.RelationOrderContributionItem.SelectionListener;
-import org.eclipse.osee.framework.ui.skynet.action.RevealInExplorerAction;
-import org.eclipse.osee.framework.ui.skynet.artifact.massEditor.MassArtifactEditor;
import org.eclipse.osee.framework.ui.skynet.internal.Activator;
import org.eclipse.osee.framework.ui.skynet.internal.ServiceUtil;
import org.eclipse.osee.framework.ui.skynet.render.RendererManager;
@@ -75,7 +74,7 @@ import org.eclipse.swt.widgets.TreeColumn;
/**
* @author Ryan D. Brooks
*/
-public class RelationsComposite extends Composite implements ISelectedArtifact {
+public class RelationsComposite extends Composite implements ISelectedArtifact, ISelectedArtifacts {
private TreeViewer treeViewer;
private Tree tree;
private NeedSelectedArtifactListener needSelectedArtifactListener;
@@ -87,8 +86,7 @@ public class RelationsComposite extends Composite implements ISelectedArtifact {
// the index of column order
private static int COLUMN_ORDER = 1;
- private MenuItem openMenuItem, wordPreviewItem, editMenuItem, viewRelationTreeItem, deleteRelationMenuItem,
- massEditMenuItem, deleteArtifactMenuItem, revealInArtifactExporerMenuItem;
+ private MenuItem openMenuItem, viewRelationTreeItem, deleteRelationMenuItem, deleteArtifactMenuItem;
private final Artifact artifact;
private final RelationLabelProvider relationLabelProvider;
@@ -140,6 +138,7 @@ public class RelationsComposite extends Composite implements ISelectedArtifact {
treeViewer.setLabelProvider(relationLabelProvider);
treeViewer.setUseHashlookup(true);
treeViewer.setInput(artifact);
+ AWorkbench.getActivePage().getActivePart().getSite().setSelectionProvider(treeViewer);
treeViewer.addDoubleClickListener(new DoubleClickListener());
tree.addMouseListener(new MouseListener() {
@@ -205,13 +204,10 @@ public class RelationsComposite extends Composite implements ISelectedArtifact {
popupMenu.addMenuListener(needSelectedArtifactListener);
createOpenMenuItem(popupMenu);
- createWordPreviewMenuItem(popupMenu);
- // createOpenWithMenuItem(popupMenu);
- new MenuItem(popupMenu, SWT.SEPARATOR);
- createEditMenuItem(popupMenu);
- createMassEditMenuItem(popupMenu);
- new MenuItem(popupMenu, SWT.SEPARATOR);
- createRevealInArtifactExplorerMenuItem(popupMenu);
+
+ OpenContributionItem contrib = new OpenContributionItem(getClass().getSimpleName() + ".open");
+ contrib.fill(popupMenu, -1, false);
+
new MenuItem(popupMenu, SWT.SEPARATOR);
createViewRelationTreeMenuItem(popupMenu);
new MenuItem(popupMenu, SWT.SEPARATOR);
@@ -284,41 +280,6 @@ public class RelationsComposite extends Composite implements ISelectedArtifact {
deleteArtifactMenuItem.setEnabled(true);
}
- private void createRevealInArtifactExplorerMenuItem(final Menu parentMenu) {
- revealInArtifactExporerMenuItem = new MenuItem(parentMenu, SWT.CASCADE);
- revealInArtifactExporerMenuItem.setText("&Reveal in Artifact Explorer");
- revealInArtifactExporerMenuItem.setImage(ImageManager.getImage(FrameworkImage.MAGNIFY));
- needSelectedArtifactListener.addArtifactEnabled(revealInArtifactExporerMenuItem);
- final RelationsComposite fRelComp = this;
- revealInArtifactExporerMenuItem.addSelectionListener(new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- new RevealInExplorerAction(fRelComp).run();
- }
- });
-
- revealInArtifactExporerMenuItem.setEnabled(true);
- }
-
- private void createMassEditMenuItem(final Menu parentMenu) {
- massEditMenuItem = new MenuItem(parentMenu, SWT.CASCADE);
- massEditMenuItem.setText("&Mass Edit");
- massEditMenuItem.setImage(ImageManager.getImage(FrameworkImage.ARTIFACT_EDITOR));
- needSelectedArtifactListener.add(massEditMenuItem);
- massEditMenuItem.addSelectionListener(new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
-
- performMassEdit(selection);
- }
- });
-
- massEditMenuItem.setEnabled(true);
- }
-
private void createViewRelationTreeMenuItem(Menu menu) {
viewRelationTreeItem = new MenuItem(menu, SWT.PUSH);
viewRelationTreeItem.setText("&View Relation Table Report");
@@ -362,35 +323,6 @@ public class RelationsComposite extends Composite implements ISelectedArtifact {
}
}
- private void createWordPreviewMenuItem(Menu parentMenu) {
- wordPreviewItem = new MenuItem(parentMenu, SWT.PUSH);
- wordPreviewItem.setText("Open Preview");
- needSelectedArtifactListener.addArtifactEnabled(wordPreviewItem);
- wordPreviewItem.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- openWordViewer((IStructuredSelection) treeViewer.getSelection());
- }
- });
- }
-
- private void openWordViewer(IStructuredSelection selection) {
- List<Artifact> artifacts = new ArrayList<>();
-
- for (Object object : selection.toArray()) {
- if (object instanceof WrapperForRelationLink) {
- WrapperForRelationLink link = (WrapperForRelationLink) object;
- artifacts.add(link.getOther());
- }
- }
- RendererManager.openInJob(artifacts, PresentationType.PREVIEW);
- }
-
- private void performMassEdit(IStructuredSelection selection) {
- Set<Artifact> selectedArtifacts = getSelectedArtifacts(selection);
- MassArtifactEditor.editArtifacts("Mass Edit", selectedArtifacts);
- }
-
private Set<Artifact> getSelectedArtifacts(IStructuredSelection selection) {
Set<Artifact> selectedArtifacts = new HashSet<>();
Iterator<?> iter = selection.iterator();
@@ -404,25 +336,6 @@ public class RelationsComposite extends Composite implements ISelectedArtifact {
return selectedArtifacts;
}
- private void createEditMenuItem(Menu parentMenu) {
- editMenuItem = new MenuItem(parentMenu, SWT.PUSH);
- editMenuItem.setText("&Edit");
-
- needSelectedArtifactListener.add(editMenuItem);
- editMenuItem.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
- Object object = selection.getFirstElement();
-
- if (object instanceof WrapperForRelationLink) {
- RendererManager.openInJob(((WrapperForRelationLink) object).getOther(),
- PresentationType.SPECIALIZED_EDIT);
- }
- }
- });
- }
-
private void createExpandAllMenuItem(Menu parentMenu) {
MenuItem menuItem = new MenuItem(parentMenu, SWT.PUSH);
menuItem.setText("Expand All\tCtrl+X");
@@ -669,4 +582,12 @@ public class RelationsComposite extends Composite implements ISelectedArtifact {
return null;
}
+ @Override
+ public Collection<Artifact> getSelectedArtifacts() {
+ if (!treeViewer.getSelection().isEmpty()) {
+ return getSelectedArtifacts((IStructuredSelection) treeViewer.getSelection());
+ }
+ return java.util.Collections.emptyList();
+ }
+
}

Back to the top