- added new dynamic context menu for DerivateSearchView
authorPatric Plitzner <p.plitzner@bgbm.org>
Wed, 11 Jun 2014 15:16:30 +0000 (15:16 +0000)
committerPatric Plitzner <p.plitzner@bgbm.org>
Wed, 11 Jun 2014 15:16:30 +0000 (15:16 +0000)
 - cleaned up code

.gitattributes
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/DataImportEditorContextMenu.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/contextMenu/DerivateViewContextMenu.java

index d36abbcde5edad0c84d5e301aeb07005823c51fc..657db6d5049278c8465539abd5c411ad2bd904ff 100644 (file)
@@ -487,6 +487,7 @@ eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/c
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/operation/DeleteConceptRelationOperation.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/BioCaseEditorInput.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/DataImportEditor.java -text
+eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/DataImportEditorContextMenu.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/DataImportEditorInput.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/GbifImportEditor.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/GbifImportEditorInput.java -text
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/DataImportEditorContextMenu.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/DataImportEditorContextMenu.java
new file mode 100644 (file)
index 0000000..0013ea3
--- /dev/null
@@ -0,0 +1,47 @@
+package eu.etaxonomy.taxeditor.editor.view.dataimport;
+
+import org.eclipse.jface.action.ContributionItem;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.CompoundContributionItem;
+
+public class DataImportEditorContextMenu extends CompoundContributionItem {
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.actions.CompoundContributionItem#getContributionItems()
+     */
+    @Override
+    protected IContributionItem[] getContributionItems() {
+        IContributionItem[] contributionItems = new IContributionItem[] {
+                new ContributionItem() {
+                    @Override
+                    public void fill(Menu menu, int index) {
+                        final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+                        final IEditorPart activeEditor = window.getActivePage().getActiveEditor();
+                        final ISelection selection = window.getActivePage().getSelection();
+                        MenuItem item = new MenuItem(menu, SWT.NONE);
+                        item.setText("Save Specimen");
+                        item.addListener(SWT.Selection, new Listener() {
+
+                            @Override
+                            public void handleEvent(Event event) {
+                                System.out.println("listener");
+                            }
+                        });
+                        System.out.println(activeEditor);
+                        System.out.println(selection);
+                    }
+                }
+        };
+        return contributionItems;
+    }
+
+}
index 1871cb626f3ac92990125268c74a9d724a9c415a..b03172f35d895bb0de2fd1efece6f638ec2cd076 100644 (file)
@@ -2,12 +2,8 @@ package eu.etaxonomy.taxeditor.editor.view.derivate.contextMenu;
 
 import org.eclipse.jface.action.IContributionItem;
 import org.eclipse.ui.actions.CompoundContributionItem;
-import org.eclipse.ui.menus.IWorkbenchContribution;
-import org.eclipse.ui.services.IServiceLocator;
 
-public class DerivateViewContextMenu extends CompoundContributionItem implements IWorkbenchContribution {
-
-    private IServiceLocator serviceLocator;
+public class DerivateViewContextMenu extends CompoundContributionItem  {
 
     /* (non-Javadoc)
      * @see org.eclipse.ui.actions.CompoundContributionItem#getContributionItems()
@@ -19,40 +15,6 @@ public class DerivateViewContextMenu extends CompoundContributionItem implements
                 new SingleReadSequenceContextMenu()
         };
         return contributionItems;
-//        Collection<IContributionItem> contributionItems = new ArrayList<IContributionItem>();
-//        // build a couple of command-based contribution parameters
-//        CommandContributionItemParameter pAA = new CommandContributionItemParameter(
-//                serviceLocator,
-//                null,
-//                "eu.etaxonomy.taxeditor.editor.view.derivate.unlinkSingleRead",
-//                SWT.PUSH);
-//        pAA.label = "Remove from Sequence";
-//
-//        // create actual contribution items and add them to the given additions reference
-//        CommandContributionItem itemAA = new CommandContributionItem(pAA);
-//        itemAA.setVisible(true);
-//        contributionItems.add(itemAA);
-//        IContributionItem[] contributionItemsArray = new IContributionItem[contributionItems.size()];
-//        return contributionItems.toArray(contributionItemsArray);
-    }
-
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.menus.IWorkbenchContribution#initialize(org.eclipse.ui.services.IServiceLocator)
-     */
-    @Override
-    public void initialize(IServiceLocator serviceLocator) {
-        this.serviceLocator = serviceLocator;
-
     }
 
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.actions.CompoundContributionItem#dispose()
-     */
-    @Override
-    public void dispose() {
-        super.dispose();
-        this.serviceLocator = null;
-    }
-
-
 }