Revision c3ea5968
Added by Patrick Plitzner over 10 years ago
- added creation of FieldUnits via wizard to bulk editor
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/command/DynamicNewObjectMenu.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 2 |
/** |
3 | 3 |
* Copyright (C) 2007 EDIT |
4 |
* European Distributed Institute of Taxonomy
|
|
4 |
* European Distributed Institute of Taxonomy |
|
5 | 5 |
* http://www.e-taxonomy.eu |
6 |
*
|
|
6 |
* |
|
7 | 7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
8 | 8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
9 | 9 |
*/ |
... | ... | |
26 | 26 |
import org.eclipse.ui.actions.CompoundContributionItem; |
27 | 27 |
import org.eclipse.ui.handlers.IHandlerService; |
28 | 28 |
|
29 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType; |
|
30 | 29 |
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator; |
31 | 30 |
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorUtil; |
32 | 31 |
import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorConstants; |
... | ... | |
42 | 41 |
public class DynamicNewObjectMenu extends CompoundContributionItem { |
43 | 42 |
private static final Logger logger = Logger |
44 | 43 |
.getLogger(DynamicNewObjectMenu.class); |
45 |
|
|
44 |
|
|
46 | 45 |
private IHandlerService handlerService = (IHandlerService) BulkEditorUtil.getService(IHandlerService.class); |
47 | 46 |
private Map<Object, String> classLabelPairs; |
48 | 47 |
/* (non-Javadoc) |
... | ... | |
51 | 50 |
/** {@inheritDoc} */ |
52 | 51 |
@Override |
53 | 52 |
protected IContributionItem[] getContributionItems() { |
54 |
|
|
53 |
|
|
55 | 54 |
classLabelPairs = getClassLabelPairs(); |
56 |
|
|
55 |
|
|
57 | 56 |
return new IContributionItem[] { |
58 | 57 |
new ContributionItem() { |
59 |
public void fill(Menu menu, int index){ |
|
58 |
@Override |
|
59 |
public void fill(Menu menu, int index){ |
|
60 | 60 |
for(final Object key : classLabelPairs.keySet()){ |
61 | 61 |
createMenuItem(menu, key); |
62 |
}
|
|
62 |
} |
|
63 | 63 |
} |
64 | 64 |
} |
65 | 65 |
}; |
... | ... | |
70 | 70 |
menuItem.setText(classLabelPairs.get(key)); |
71 | 71 |
menuItem.addSelectionListener(new SelectionListener(){ |
72 | 72 |
|
73 |
public void widgetDefaultSelected(SelectionEvent e) {} |
|
73 |
@Override |
|
74 |
public void widgetDefaultSelected(SelectionEvent e) {} |
|
74 | 75 |
|
75 |
public void widgetSelected(SelectionEvent ev) { |
|
76 |
@Override |
|
77 |
public void widgetSelected(SelectionEvent ev) { |
|
76 | 78 |
Event event = new Event(); |
77 | 79 |
event.data = key; |
78 | 80 |
event.text = classLabelPairs.get(key); |
... | ... | |
82 | 84 |
logger.error("Error executing command", e); |
83 | 85 |
throw new RuntimeException("Error executing command", e); |
84 | 86 |
} |
85 |
}
|
|
87 |
} |
|
86 | 88 |
}); |
87 |
|
|
88 |
//FIXME:3.3MC Need corresponding Details Viewer section for FieldUnit |
|
89 |
if(key == SpecimenOrObservationType.FieldUnit){ |
|
90 |
menuItem.setEnabled(false); |
|
91 |
} |
|
92 | 89 |
} |
93 |
|
|
90 |
|
|
94 | 91 |
/** |
95 | 92 |
* Get class label pairs from Annotated Line Editor's entity creator. |
96 | 93 |
* @return |
... | ... | |
99 | 96 |
IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); |
100 | 97 |
if (editor != null){ |
101 | 98 |
IEditorInput input = editor.getEditorInput(); |
102 |
|
|
99 |
|
|
103 | 100 |
if(input instanceof AbstractBulkEditorInput){ |
104 | 101 |
IEntityCreator<?> entityCreator = ((AbstractBulkEditorInput) input).getEntityCreator(); |
105 | 102 |
return entityCreator.getKeyLabelPairs(); |
106 | 103 |
} |
107 | 104 |
} |
108 |
|
|
105 |
|
|
109 | 106 |
return null; |
110 |
}
|
|
107 |
} |
|
111 | 108 |
} |
Also available in: Unified diff