import org.eclipse.swt.dnd.Transfer;\r
import org.eclipse.swt.graphics.Color;\r
import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Event;\r
+import org.eclipse.swt.widgets.Listener;\r
import org.eclipse.ui.forms.widgets.TableWrapData;\r
import org.eclipse.ui.forms.widgets.TableWrapLayout;\r
\r
}\r
\r
public void drop(DropTargetEvent event) {\r
- \r
- if (event.data instanceof Composite) {\r
- Composite composite = (Composite) event.data; \r
- if ( ! composite.getParent().equals(GroupComposite.this)) {\r
- composite.setParent(GroupComposite.this);\r
+ \r
+ if (event.data instanceof GroupedComposite) {\r
+ \r
+ final GroupedComposite composite = (GroupedComposite) event.data;\r
+ if (composite.getDragSource() != null) {\r
+ \r
+ // Make sure composite is not being dropped onto its current parent\r
+ if ( ! composite.getParent().equals(GroupComposite.this)) {\r
+ \r
+ // Change parent at end of drag event\r
+ composite.getDragSource().addListener(DND.DragEnd, new Listener() {\r
+ @Override\r
+ public void handleEvent(Event event) {\r
+ composite.setParent(GroupComposite.this);\r
+ }\r
+ });\r
+ } \r
}\r
}\r
}\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.MenuManager;\r
import org.eclipse.swt.SWT;\r
import org.eclipse.swt.custom.StyledText;\r
import org.eclipse.swt.events.FocusAdapter;\r
\r
@Override\r
public void handleSplitText(String text) {\r
-\r
+ \r
// Create a synonym in a new homotypic group using text as name\r
IUndoContext undoContext = EditorController.getUndoContext(taxon);\r
-// IUndoableOperation operation = new CreateSynonymInNewGroupOperation\r
- setOperation(new CreateSynonymInNewGroupOperation\r
- ("new heterotypic synonym", undoContext, taxon, text)); //$NON-NLS-1$\r
- \r
-// GlobalController.executeOperation(operation);\r
+ IUndoableOperation operation = new CreateSynonymInNewGroupOperation\r
+ ("new heterotypic synonym", undoContext, taxon, text); //$NON-NLS-1$\r
+// setOperation(new CreateSynonymInNewGroupOperation\r
\r
+ GlobalController.executeOperation(operation);\r
// getTextViewer().removeLineBreakListener(this);\r
}\r
\r
});\r
\r
- styledText.addKeyListener(new KeyAdapter(){\r
-\r
- @Override\r
- public void keyReleased(KeyEvent e) {\r
- if (operation != null) {\r
- GlobalController.executeOperation(operation);\r
- operation = null;\r
- }\r
- }\r
- \r
- });\r
+// styledText.addKeyListener(new KeyAdapter(){\r
+//\r
+// @Override\r
+// public void keyReleased(KeyEvent e) {\r
+// if (operation != null) {\r
+// GlobalController.executeOperation(operation);\r
+// operation = null;\r
+// }\r
+// }\r
+// \r
+// });\r
\r
styledText.addFocusListener(new FocusAdapter() {\r
public void focusGained(FocusEvent e) {\r
return nameViewer;\r
}\r
\r
- IUndoableOperation operation;\r
+// IUndoableOperation operation;\r
\r
private Label nonEditableInfo;\r
\r
- protected void setOperation(IUndoableOperation operation) {\r
- this.operation = operation;\r
- }\r
+// protected void setOperation(IUndoableOperation operation) {\r
+// this.operation = operation;\r
+// }\r
\r
public void setText(String text) {\r
Assert.isNotNull(getTextViewer(), \r
import org.eclipse.swt.dnd.Transfer;\r
import org.eclipse.swt.widgets.Composite;\r
import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.Event;\r
+import org.eclipse.swt.widgets.Listener;\r
import org.eclipse.ui.IEditorInput;\r
import org.eclipse.ui.IEditorSite;\r
import org.eclipse.ui.PartInitException;\r
import eu.etaxonomy.taxeditor.controller.GlobalController;\r
import eu.etaxonomy.taxeditor.editor.AbstractTaxonEditor;\r
import eu.etaxonomy.taxeditor.editor.FreeTextElementFactory;\r
+import eu.etaxonomy.taxeditor.editor.GroupComposite;\r
+import eu.etaxonomy.taxeditor.editor.GroupedComposite;\r
import eu.etaxonomy.taxeditor.operations.name.ChangeHomotypicGroupOperation;\r
import eu.etaxonomy.taxeditor.operations.name.ChangeMisappliedNameToSynonymOperation;\r
\r
target.addDropListener(new DropTargetAdapter() {\r
\r
public void drop(DropTargetEvent event) {\r
- \r
- IUndoContext undoContext = EditorController.getUndoContext(getTaxon());\r
- IUndoableOperation operation = null;\r
- \r
- // Synonym being dropped\r
- if(event.data instanceof SynonymComposite){\r
- Synonym synonym = ((SynonymComposite)event.data).getSynonym();\r
- operation = new ChangeHomotypicGroupOperation\r
- ("change type", undoContext, \r
- getTaxon(), synonym, HomotypicalGroup.NewInstance());\r
- }\r
- \r
- // Misapplied name being dropped\r
- if(event.data instanceof MisappliedNameComposite){\r
- Taxon misapplication = ((MisappliedNameComposite)event.data).getMisappliedName();\r
- operation = new ChangeMisappliedNameToSynonymOperation\r
- ("change misapplied name to synonym", undoContext, \r
- getTaxon(), misapplication, HomotypicalGroup.NewInstance()); \r
+ \r
+ if (event.data instanceof GroupedComposite) {\r
+ final GroupedComposite composite = (GroupedComposite) event.data;\r
+ if (composite.getDragSource() != null) {\r
+ \r
+ // Execute operations at end of drag event\r
+ composite.getDragSource().addListener(DND.DragEnd, new Listener() {\r
+ @Override\r
+ public void handleEvent(Event event) {\r
+ IUndoContext undoContext = EditorController.getUndoContext(getTaxon());\r
+ IUndoableOperation operation = null;\r
+ \r
+ // Synonym being dropped\r
+ if(composite instanceof SynonymComposite){\r
+ Synonym synonym = ((SynonymComposite)composite).getSynonym();\r
+ operation = new ChangeHomotypicGroupOperation\r
+ ("change type", undoContext, \r
+ getTaxon(), synonym, HomotypicalGroup.NewInstance());\r
+ }\r
+ \r
+ // Misapplied name being dropped\r
+ if(composite instanceof MisappliedNameComposite){\r
+ Taxon misapplication = ((MisappliedNameComposite)composite).getMisappliedName();\r
+ operation = new ChangeMisappliedNameToSynonymOperation\r
+ ("change misapplied name to synonym", undoContext, \r
+ getTaxon(), misapplication, HomotypicalGroup.NewInstance()); \r
+ }\r
+ \r
+ // Execute operation if it's been init'ed\r
+ if (operation == null) {\r
+ logger.warn("User unsuccessfully tried to drop " + composite.getClass());\r
+ } else {\r
+ GlobalController.executeOperation(operation);\r
+ }\r
+ }\r
+ }); \r
+ }\r
}\r
\r
- // Execute operation if it's been init'ed\r
- if (operation == null) {\r
- logger.warn("User unsuccessfully tried to drop " + event.data.getClass());\r
- } else {\r
- GlobalController.executeOperation(operation);\r
- }\r
+\r
} \r
});\r
\r