package eu.etaxonomy.taxeditor.editor.description;\r
\r
import org.apache.log4j.Logger;\r
+import org.eclipse.core.commands.operations.IUndoContext;\r
+import org.eclipse.core.commands.operations.IUndoableOperation;\r
import org.eclipse.core.runtime.Assert;\r
import org.eclipse.jface.action.Action;\r
import org.eclipse.jface.action.IMenuListener;\r
import eu.etaxonomy.cdm.model.description.TaxonDescription;\r
import eu.etaxonomy.taxeditor.ITaxEditorConstants;\r
import eu.etaxonomy.taxeditor.TaxEditorPlugin;\r
-import eu.etaxonomy.taxeditor.actions.ui.description.AddDescriptionElementCompositeAction;\r
+import eu.etaxonomy.taxeditor.controller.EditorController;\r
+import eu.etaxonomy.taxeditor.controller.GlobalController;\r
import eu.etaxonomy.taxeditor.editor.ContextMenu;\r
import eu.etaxonomy.taxeditor.editor.GroupedComposite;\r
import eu.etaxonomy.taxeditor.editor.ParseListener;\r
+import eu.etaxonomy.taxeditor.operations.description.AddElementOperation;\r
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;\r
import eu.etaxonomy.taxeditor.propertysheet.description.TaxonDescriptionPropertySource;\r
\r
.getImage(ITaxEditorConstants.BLACK_SQUARE_ICON); \r
\r
private static final String EMPTY_NAME_PROMPT = "Click to add description label";\r
+\r
+ private TaxonDescription description;\r
+\r
+ private IUndoContext undoContext;\r
\r
- public DescriptionLabelComposite(Composite parent, IManagedForm managedForm, TaxonDescription taxonDescription) {\r
+ public DescriptionLabelComposite(Composite parent, IManagedForm managedForm, TaxonDescription description) {\r
super(parent, managedForm);\r
\r
+ this.description = description;\r
+ \r
+ this.undoContext = EditorController.getUndoContext(taxon);\r
+ \r
createLabelViewer();\r
createBorderSupport();\r
createLineWrapSupport();\r
\r
- setData(taxonDescription);\r
+ setData(description);\r
transform(null);\r
\r
createEmptyViewerPrompt(EMPTY_NAME_PROMPT);\r
setFocus();\r
}\r
\r
+ public TaxonDescription getDescription() {\r
+ return description;\r
+ }\r
+ \r
public void transform(String transformation) {\r
setIsDraggable(false);\r
setFont(DESCRIPTION_LABEL_FONT);\r
\r
private void createMenu() {\r
\r
- final Composite parentComposite = this.getParent();\r
- \r
MenuManager featuresMenu = new MenuManager("Add description element");\r
featuresMenu.setRemoveAllWhenShown(true);\r
featuresMenu.addMenuListener(new IMenuListener() {\r
public void menuAboutToShow(IMenuManager manager) {\r
- for (Feature feature : PreferencesUtil.getPreferredFeatures()) {\r
- Action action = new AddDescriptionElementCompositeAction(\r
- parentComposite, managedForm, feature);\r
- manager.add(action);\r
+ for (final Feature feature : PreferencesUtil.getPreferredFeatures()) {\r
+ \r
+ String text = feature.getLabel();\r
+ manager.add(new Action(text){\r
+ \r
+ public void run() {\r
+ IUndoableOperation operation = new AddElementOperation\r
+ (this.getText(), undoContext, taxon, description, feature);\r
+ GlobalController.executeOperation(operation);\r
+ }\r
+ });\r
}\r
}\r
});\r