Revision 8fca041b
Added by Patrick Plitzner about 10 years ago
- added new dynamic context menu for DerivateSearchView
- cleaned up code
.gitattributes | ||
---|---|---|
487 | 487 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/operation/DeleteConceptRelationOperation.java -text |
488 | 488 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/BioCaseEditorInput.java -text |
489 | 489 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/DataImportEditor.java -text |
490 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/DataImportEditorContextMenu.java -text |
|
490 | 491 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/DataImportEditorInput.java -text |
491 | 492 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/GbifImportEditor.java -text |
492 | 493 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/GbifImportEditorInput.java -text |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/DataImportEditorContextMenu.java | ||
---|---|---|
1 |
package eu.etaxonomy.taxeditor.editor.view.dataimport; |
|
2 |
|
|
3 |
import org.eclipse.jface.action.ContributionItem; |
|
4 |
import org.eclipse.jface.action.IContributionItem; |
|
5 |
import org.eclipse.jface.viewers.ISelection; |
|
6 |
import org.eclipse.swt.SWT; |
|
7 |
import org.eclipse.swt.widgets.Event; |
|
8 |
import org.eclipse.swt.widgets.Listener; |
|
9 |
import org.eclipse.swt.widgets.Menu; |
|
10 |
import org.eclipse.swt.widgets.MenuItem; |
|
11 |
import org.eclipse.ui.IEditorPart; |
|
12 |
import org.eclipse.ui.IWorkbenchWindow; |
|
13 |
import org.eclipse.ui.PlatformUI; |
|
14 |
import org.eclipse.ui.actions.CompoundContributionItem; |
|
15 |
|
|
16 |
public class DataImportEditorContextMenu extends CompoundContributionItem { |
|
17 |
|
|
18 |
/* (non-Javadoc) |
|
19 |
* @see org.eclipse.ui.actions.CompoundContributionItem#getContributionItems() |
|
20 |
*/ |
|
21 |
@Override |
|
22 |
protected IContributionItem[] getContributionItems() { |
|
23 |
IContributionItem[] contributionItems = new IContributionItem[] { |
|
24 |
new ContributionItem() { |
|
25 |
@Override |
|
26 |
public void fill(Menu menu, int index) { |
|
27 |
final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); |
|
28 |
final IEditorPart activeEditor = window.getActivePage().getActiveEditor(); |
|
29 |
final ISelection selection = window.getActivePage().getSelection(); |
|
30 |
MenuItem item = new MenuItem(menu, SWT.NONE); |
|
31 |
item.setText("Save Specimen"); |
|
32 |
item.addListener(SWT.Selection, new Listener() { |
|
33 |
|
|
34 |
@Override |
|
35 |
public void handleEvent(Event event) { |
|
36 |
System.out.println("listener"); |
|
37 |
} |
|
38 |
}); |
|
39 |
System.out.println(activeEditor); |
|
40 |
System.out.println(selection); |
|
41 |
} |
|
42 |
} |
|
43 |
}; |
|
44 |
return contributionItems; |
|
45 |
} |
|
46 |
|
|
47 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/contextMenu/DerivateViewContextMenu.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import org.eclipse.jface.action.IContributionItem; |
4 | 4 |
import org.eclipse.ui.actions.CompoundContributionItem; |
5 |
import org.eclipse.ui.menus.IWorkbenchContribution; |
|
6 |
import org.eclipse.ui.services.IServiceLocator; |
|
7 | 5 |
|
8 |
public class DerivateViewContextMenu extends CompoundContributionItem implements IWorkbenchContribution { |
|
9 |
|
|
10 |
private IServiceLocator serviceLocator; |
|
6 |
public class DerivateViewContextMenu extends CompoundContributionItem { |
|
11 | 7 |
|
12 | 8 |
/* (non-Javadoc) |
13 | 9 |
* @see org.eclipse.ui.actions.CompoundContributionItem#getContributionItems() |
... | ... | |
19 | 15 |
new SingleReadSequenceContextMenu() |
20 | 16 |
}; |
21 | 17 |
return contributionItems; |
22 |
// Collection<IContributionItem> contributionItems = new ArrayList<IContributionItem>(); |
|
23 |
// // build a couple of command-based contribution parameters |
|
24 |
// CommandContributionItemParameter pAA = new CommandContributionItemParameter( |
|
25 |
// serviceLocator, |
|
26 |
// null, |
|
27 |
// "eu.etaxonomy.taxeditor.editor.view.derivate.unlinkSingleRead", |
|
28 |
// SWT.PUSH); |
|
29 |
// pAA.label = "Remove from Sequence"; |
|
30 |
// |
|
31 |
// // create actual contribution items and add them to the given additions reference |
|
32 |
// CommandContributionItem itemAA = new CommandContributionItem(pAA); |
|
33 |
// itemAA.setVisible(true); |
|
34 |
// contributionItems.add(itemAA); |
|
35 |
// IContributionItem[] contributionItemsArray = new IContributionItem[contributionItems.size()]; |
|
36 |
// return contributionItems.toArray(contributionItemsArray); |
|
37 |
} |
|
38 |
|
|
39 |
/* (non-Javadoc) |
|
40 |
* @see org.eclipse.ui.menus.IWorkbenchContribution#initialize(org.eclipse.ui.services.IServiceLocator) |
|
41 |
*/ |
|
42 |
@Override |
|
43 |
public void initialize(IServiceLocator serviceLocator) { |
|
44 |
this.serviceLocator = serviceLocator; |
|
45 |
|
|
46 | 18 |
} |
47 | 19 |
|
48 |
/* (non-Javadoc) |
|
49 |
* @see org.eclipse.ui.actions.CompoundContributionItem#dispose() |
|
50 |
*/ |
|
51 |
@Override |
|
52 |
public void dispose() { |
|
53 |
super.dispose(); |
|
54 |
this.serviceLocator = null; |
|
55 |
} |
|
56 |
|
|
57 |
|
|
58 | 20 |
} |
Also available in: Unified diff