import org.eclipse.swt.dnd.DragSourceEvent;
import eu.etaxonomy.cdm.model.description.FeatureNode;
-import eu.etaxonomy.taxeditor.featuretree.FeatureNodeDragListener;
import eu.etaxonomy.taxeditor.featuretree.FeatureNodeTransfer;
+import eu.etaxonomy.taxeditor.featuretree.e4.FeatureNodeDragListener;
/**
* @author pplitzner
import eu.etaxonomy.cdm.model.description.Character;
import eu.etaxonomy.cdm.model.description.FeatureNode;
import eu.etaxonomy.cdm.model.description.FeatureTree;
-import eu.etaxonomy.taxeditor.featuretree.FeatureNodeDragListener;
-import eu.etaxonomy.taxeditor.featuretree.FeatureNodeDropAdapter;
+import eu.etaxonomy.taxeditor.featuretree.e4.FeatureNodeDragListener;
+import eu.etaxonomy.taxeditor.featuretree.e4.FeatureNodeDropAdapter;
import eu.etaxonomy.taxeditor.featuretree.e4.FeatureTreeEditorComposite;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
composite_3.setLayout(new GridLayout(1, false));
characterTreeEditorComposite = addFeatureTreeEditor(composite_3);
- initFeatureTreeComposite(characterTreeEditorComposite, new FeatureNodeDragListener(characterTreeEditorComposite.getViewer()), new FeatureNodeDropAdapter(characterTreeEditorComposite.getViewer()));
+ initFeatureTreeComposite(characterTreeEditorComposite, new FeatureNodeDragListener(characterTreeEditorComposite.getViewer()), new FeatureNodeDropAdapter(dirty, characterTreeEditorComposite.getViewer()));
characterTreeEditorComposite.getLabel_title().setText("Characters");
sashForm.setWeights(new int[] {3, 3, 1, 3});
+++ /dev/null
-/**
-* Copyright (C) 2017 EDIT
-* European Distributed Institute of Taxonomy
-* http://www.e-taxonomy.eu
-*
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
-package eu.etaxonomy.taxeditor.featuretree;
-
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DragSourceAdapter;
-import org.eclipse.swt.dnd.DragSourceEvent;
-
-import eu.etaxonomy.cdm.model.description.FeatureNode;
-
-/**
- * @author pplitzner
- * @since Jun 2, 2017
- *
- */
-public class FeatureNodeDragListener extends DragSourceAdapter {
-
- private final TreeViewer viewer;
-
- public FeatureNodeDragListener(TreeViewer viewer) {
- this.viewer = viewer;
- }
-
- /**
- * Method declared on DragSourceListener
- */
- @Override
- public void dragFinished(DragSourceEvent event) {
- if (!event.doit) {
- return;
- }
- if (event.detail == DND.DROP_MOVE) {
- viewer.refresh();
- }
- }
-
- /**
- * Method declared on DragSourceListener
- */
- @Override
- public void dragSetData(DragSourceEvent event) {
- IStructuredSelection selection = (IStructuredSelection) viewer
- .getSelection();
- FeatureNode[] featureNodes = (FeatureNode[]) selection.toList()
- .toArray(new FeatureNode[selection.size()]);
- if (FeatureNodeTransfer.getInstance().isSupportedType(
- event.dataType)) {
- event.data = featureNodes;
- }
- }
-
- /**
- * Method declared on DragSourceListener
- */
- @Override
- public void dragStart(DragSourceEvent event) {
- event.doit = !viewer.getSelection().isEmpty();
- }
-
-}
+++ /dev/null
-/**
-* Copyright (C) 2017 EDIT
-* European Distributed Institute of Taxonomy
-* http://www.e-taxonomy.eu
-*
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
-package eu.etaxonomy.taxeditor.featuretree;
-
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerDropAdapter;
-import org.eclipse.swt.dnd.TransferData;
-
-import eu.etaxonomy.cdm.model.description.FeatureNode;
-import eu.etaxonomy.cdm.model.description.FeatureTree;
-import eu.etaxonomy.taxeditor.model.MessagingUtils;
-
-/**
- * @author pplitzner
- * @since Jun 2, 2017
- *
- */
-public class FeatureNodeDropAdapter extends ViewerDropAdapter {
-
- public FeatureNodeDropAdapter(Viewer viewer) {
- super(viewer);
- }
-
- @Override
- public boolean performDrop(Object data) {
- FeatureNode target = (FeatureNode) getCurrentTarget();
- int position = 0;
-
- if (target != null) {
- int location = getCurrentLocation();
- FeatureNode parent = target.getParent();
- if (location == LOCATION_BEFORE) {
- position = Math.max(0, parent.getIndex(target) - 1);
- target = parent;
- }
-
- if (location == LOCATION_AFTER) {
- position = parent.getIndex(target);
- target = parent;
- }
- }
-
- // set target to root node if there is no target specified
- if (target == null) {
- FeatureTree featureTree = (FeatureTree) getViewer().getInput();
- target = featureTree.getRoot();
- }
-
- Object[] droppedObjects = (Object[]) data;
- TreeViewer viewer = (TreeViewer) getViewer();
-
- // cannot drop a feature node onto itself
- for (Object droppedObject : droppedObjects) {
- if (droppedObject == null) {
- MessagingUtils.warningDialog(
- "Operation not supported yet",
- this,
- "We are currently unable to change the order of freshly created "
- + "feature trees nodes. Please close and reopen the dialog to change the order of features.");
- return false;
- }
- if (droppedObject.equals(target)) {
- return false;
- }
- }
- for (Object droppedObject : droppedObjects) {
- FeatureNode droppedNode = (FeatureNode) droppedObject;
- target.addChild(droppedNode, position);
- viewer.add(target, droppedNode);
- viewer.reveal(droppedNode);
- }
- return true;
- }
-
- @Override
- public boolean validateDrop(Object target, int operation,
- TransferData transferData) {
- return FeatureNodeTransfer.getInstance().isSupportedType(
- transferData);
- }
-
-}
\ No newline at end of file
import eu.etaxonomy.cdm.model.description.FeatureNode;
import eu.etaxonomy.taxeditor.featuretree.FeatureNodeTransfer;
-class FeatureNodeDragListener extends DragSourceAdapter {
+public class FeatureNodeDragListener extends DragSourceAdapter {
private final TreeViewer viewer;
*/
package eu.etaxonomy.taxeditor.featuretree.e4;
+import org.eclipse.e4.ui.model.application.ui.MDirtyable;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerDropAdapter;
import eu.etaxonomy.taxeditor.featuretree.FeatureNodeTransfer;
import eu.etaxonomy.taxeditor.store.CdmStore;
-class FeatureNodeDropAdapter extends ViewerDropAdapter {
+public class FeatureNodeDropAdapter extends ViewerDropAdapter {
- private final FeatureTreeEditor featureTreeEditor;
+ private final MDirtyable dirtyable;
- protected FeatureNodeDropAdapter(FeatureTreeEditor featureTreeEditor, Viewer viewer) {
+ public FeatureNodeDropAdapter(MDirtyable dirtyable, Viewer viewer) {
super(viewer);
- this.featureTreeEditor = featureTreeEditor;
+ this.dirtyable = dirtyable;
}
@Override
viewer.refresh();
viewer.reveal(droppedNode);
}
- this.featureTreeEditor.setDirty(true);
+ this.dirtyable.setDirty(true);
return true;
}
}
composite = new FeatureTreeEditorComposite(parent, SWT.NULL);
composite.init(new FeatureNodeDragListener(composite.getViewer()),
- new FeatureNodeDropAdapter(this, composite.getViewer()), this, new SelectionAdapter() {
+ new FeatureNodeDropAdapter(dirty, composite.getViewer()), this, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if(isDirty()){