org.eclipse.e4.ui.di
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
-Import-Package: javax.inject;version="1.0.0",
+Import-Package: javax.annotation;version="1.0.0";resolution:=optional,
+ javax.inject;version="1.0.0",
org.eclipse.core.databinding.beans,
org.eclipse.core.databinding.observable.list,
org.eclipse.core.databinding.observable.map,
<children xsi:type="menu:HandledMenuItem" xmi:id="_wg0-oDulEeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.commandlabel54" label="%command.label.54" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.editor/icons/deep-delete-16x16-32.png" command="_fKT-wDulEeeOtqC_3qh40A"/>
</menus>
</elements>
+ <elements xsi:type="basic:PartDescriptor" xmi:id="_R7vxEECaEeeL5JDzMOYK6g" elementId="eu.etaxonomy.taxeditor.editor.workingSet.FeatureTreeBuilderViewPart" label="Character Editor" closeable="true" dirtyable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.workingSet.FeatureTreeBuilderViewPart"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="__mwtMDVpEee_b7RlBzTDRw" featurename="commands" parentElementId="xpath:/">
<elements xsi:type="commands:Command" xmi:id="_BjF3ADVqEee_b7RlBzTDRw" elementId="eu.etaxonomy.taxeditor.editor.command.specimeneditor.create_field_unit" commandName="%command.commandname.1"/>
<elements xsi:type="commands:Command" xmi:id="_N0wLsDumEeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.derivative.copySingleReadToClipBoard" commandName="%command.name.COPY_SINGLE_READ_TO_CLIPBOARD"/>
<elements xsi:type="commands:Command" xmi:id="_YPp1wDvREeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.derivate.delete" commandName="Delete"/>
</fragments>
+ <fragments xsi:type="fragment:StringModelFragment" xmi:id="_pZmusEalEeeXMc6kSYO7Xg" featurename="children" parentElementId="eu.etaxonomy.taxeditor.menu.showView">
+ <elements xsi:type="menu:HandledMenuItem" xmi:id="_tvph4EalEeeXMc6kSYO7Xg" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.featuretreeeditor" label="Character Editor" command="_WPjpoDSnEeek0dKsFNy--Q">
+ <parameters xmi:id="_wJkmoEalEeeXMc6kSYO7Xg" elementId="eu.etaxonomy.taxeditor.editor.parameter.0" name="eu.etaxonomy.taxeditor.workbench.commandparameter.partName" value="eu.etaxonomy.taxeditor.editor.workingSet.FeatureTreeBuilderViewPart"/>
+ </elements>
+ </fragments>
</fragment:ModelFragments>
--- /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.editor.workingSet;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+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;
+
+/**
+ * @author pplitzner
+ * @since Jun 2, 2017
+ *
+ */
+public class CharacterDragListener extends FeatureNodeDragListener {
+
+ private TreeViewer structureViewer;
+ private TreeViewer propertyViewer;
+
+ /**
+ * @param propertyViewer
+ */
+ public CharacterDragListener(TreeViewer structureViewer, TreeViewer propertyViewer) {
+ super(propertyViewer);
+ this.structureViewer = structureViewer;
+ this.propertyViewer = propertyViewer;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void dragSetData(DragSourceEvent event) {
+ FeatureNode structure = (FeatureNode) ((IStructuredSelection) structureViewer.getSelection()).getFirstElement();
+ FeatureNode property = (FeatureNode) ((IStructuredSelection) propertyViewer.getSelection()).getFirstElement();
+ FeatureNode[] character = new FeatureNode[2];
+ character[0] = structure;
+ character[1] = property;
+ if (FeatureNodeTransfer.getInstance().isSupportedType(event.dataType)) {
+ event.data = character;
+ }
+ }
+
+}
--- /dev/null
+/**
+* Copyright (C) 2009 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.editor.workingSet;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerDropAdapter;
+import org.eclipse.swt.dnd.TransferData;
+
+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.FeatureNodeTransfer;
+
+/**
+ *
+ * @author pplitzner
+ * @date Jun 1, 2017
+ *
+ */
+public class CharacterDropAdapter extends ViewerDropAdapter {
+
+ protected CharacterDropAdapter(Viewer viewer) {
+ super(viewer);
+ }
+
+ @Override
+ public boolean performDrop(Object data) {
+
+ FeatureNode target = (FeatureNode) getCurrentTarget();
+ int currentLocation = getCurrentLocation();
+ Object[] characterData = (Object[]) data;
+
+ //create new Character
+ if(characterData.length==2){
+ FeatureNode structureNode = (FeatureNode) characterData[0];
+ FeatureNode propertyNode = (FeatureNode) characterData[1];
+ String label = structureNode.getFeature().toString()+" "+propertyNode.getFeature().toString();
+ Character character = Character.NewInstance(structureNode, propertyNode, null, label, label);
+ FeatureNode characterNode = FeatureNode.NewInstance(character);
+
+ if(getViewer().getInput()==null){
+ //create new feature tree
+ FeatureTree featureTree = FeatureTree.NewInstance();
+ getViewer().setInput(featureTree);
+ }
+ if(target==null){
+ FeatureNode root = ((FeatureTree)getViewer().getInput()).getRoot();
+ root.addChild(characterNode);
+ }
+ else{
+ target.addChild(characterNode);
+ }
+ }
+ getViewer().refresh();
+ return true;
+ }
+
+ @Override
+ public boolean validateDrop(Object target, int operation,
+ TransferData transferType) {
+ boolean transferDataIsSupported = FeatureNodeTransfer.getInstance().isSupportedType(transferType);
+ return transferDataIsSupported;
+ }
+
+}
--- /dev/null
+// $Id$
+/**
+* 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.editor.workingSet;
+
+import java.util.UUID;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.inject.Named;
+
+import org.eclipse.e4.ui.di.Focus;
+import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+import eu.etaxonomy.cdm.api.service.IFeatureTreeService;
+import eu.etaxonomy.cdm.model.description.FeatureTree;
+import eu.etaxonomy.taxeditor.featuretree.FeatureNodeTransfer;
+import eu.etaxonomy.taxeditor.featuretree.FeatureTreeContentProvider;
+import eu.etaxonomy.taxeditor.featuretree.FeatureTreeLabelProvider;
+import eu.etaxonomy.taxeditor.featuretree.e4.FeatureTreeEditor;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author pplitzner
+ * @date 24.05.2017
+ *
+ */
+public class FeatureTreeBuilderViewPart {
+
+
+ private TreeViewer treeViewerCharacters;
+ private TreeViewer treeViewerProperties;
+ private TreeViewer treeViewerStructures;
+ private FeatureTreeEditor editor;
+ private final FormToolkit formToolkit = new FormToolkit(Display.getDefault());
+
+ public FeatureTreeBuilderViewPart() {
+ }
+
+ /**
+ * Create contents of the view part.
+ */
+ @PostConstruct
+ public void createControls(Composite parent, @Named(IServiceConstants.ACTIVE_SHELL)Shell shell) {
+ parent.setLayout(new GridLayout(1, false));
+
+ SashForm sashForm = new SashForm(parent, SWT.NONE);
+ sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
+ formToolkit.adapt(sashForm);
+ formToolkit.paintBordersFor(sashForm);
+
+ treeViewerStructures = new TreeViewer(sashForm, SWT.BORDER);
+
+ treeViewerProperties = new TreeViewer(sashForm, SWT.BORDER);
+
+// editor = new FeatureTreeEditor(shell);
+// editor.createControl(sashForm, shell);
+ treeViewerCharacters = new TreeViewer(sashForm, SWT.BORDER);
+ sashForm.setWeights(new int[] {1, 1, 1});
+
+ init();
+ }
+
+ private void init(){
+ int dndOperations = DND.DROP_COPY | DND.DROP_MOVE;
+ Transfer[] transfers = new Transfer[] { FeatureNodeTransfer.getInstance() };
+
+ FeatureTree structureFeatureTree = CdmStore.getService(IFeatureTreeService.class).load(UUID.fromString("546e9c1e-d186-4e3b-838d-7e44586d1b39"));
+ treeViewerStructures.setContentProvider(new FeatureTreeContentProvider());
+ treeViewerStructures.setLabelProvider(new FeatureTreeLabelProvider());
+ treeViewerStructures.setInput(structureFeatureTree);
+
+ FeatureTree propertiesFeatureTree = CdmStore.getService(IFeatureTreeService.class).load(UUID.fromString("07543f00-1572-4ba8-b633-4fdb83fb32dd"));
+ treeViewerProperties.setContentProvider(new FeatureTreeContentProvider());
+ treeViewerProperties.setLabelProvider(new FeatureTreeLabelProvider());
+ treeViewerProperties.addDragSupport(dndOperations, transfers, new CharacterDragListener(treeViewerStructures, treeViewerProperties));
+ treeViewerProperties.setInput(propertiesFeatureTree);
+
+ treeViewerCharacters.setContentProvider(new FeatureTreeContentProvider());
+ treeViewerCharacters.setLabelProvider(new FeatureTreeLabelProvider());
+ treeViewerCharacters.addDropSupport(dndOperations, transfers, new CharacterDropAdapter(treeViewerCharacters));
+ }
+
+ @PreDestroy
+ public void dispose() {
+ }
+
+ @Focus
+ public void setFocus() {
+ }
+
+ public TreeViewer getTreeViewerCharacters() {
+ return treeViewerCharacters;
+ }
+ public TreeViewer getTreeViewerProperties() {
+ return treeViewerProperties;
+ }
+ public TreeViewer getTreeViewerStructures() {
+ return treeViewerStructures;
+ }
+
+}
--- /dev/null
+// $Id$
+/**
+* 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.editor.workingSet;
+
+import java.util.Collections;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+
+import eu.etaxonomy.cdm.model.description.FeatureNode;
+import eu.etaxonomy.cdm.model.description.FeatureTree;
+
+/**
+ * @author pplitzner
+ * @date 24.05.2017
+ *
+ */
+public class StructureContentProvider implements ITreeContentProvider {
+
+ public StructureContentProvider() {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Object[] getElements(Object inputElement) {
+ FeatureTree featureTree = (FeatureTree)inputElement;
+ return Collections.singleton(featureTree.getRoot()).toArray();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Object[] getChildren(Object parentElement) {
+ return ((FeatureNode)parentElement).getChildNodes().toArray();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Object getParent(Object element) {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean hasChildren(Object element) {
+ return ((FeatureNode)element).getChildCount()>0;
+ }
+
+}
--- /dev/null
+// $Id$
+/**
+* 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.editor.workingSet;
+
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+
+import eu.etaxonomy.cdm.model.description.FeatureNode;
+
+/**
+ * @author pplitzner
+ * @date 24.05.2017
+ *
+ */
+public class StructureLabelProvider extends ColumnLabelProvider {
+
+
+ public StructureLabelProvider() {
+ }
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getText(Object element) {
+
+ return ((FeatureNode)element).getFeature().getLabel();
+ }
+}
eu.etaxonomy.taxeditor.editor.definedterm,
eu.etaxonomy.taxeditor.editor.definedterm.input,
eu.etaxonomy.taxeditor.featuretree,
+ eu.etaxonomy.taxeditor.featuretree.e4,
eu.etaxonomy.taxeditor.handler,
eu.etaxonomy.taxeditor.handler.defaultHandler,
eu.etaxonomy.taxeditor.io,
--- /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
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* 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.
*/
import eu.etaxonomy.cdm.model.description.FeatureTree;
/**
- * <p>FeatureTreeLabelProvider class.</p>
*
* @author n.hoffmann
* @created Aug 5, 2010
* @version 1.0
*/
public class FeatureTreeLabelProvider extends LabelProvider {
-
- private Feature feature;
-
+
/** {@inheritDoc} */
@Override
public String getText(Object element) {
if(element instanceof FeatureTree){
return ((FeatureTree) element).getTitleCache();
}else if(element instanceof FeatureNode){
- feature = ((FeatureNode) element).getFeature();
-
- if(feature != null)
- return feature.getTitleCache();
-
+ Feature feature = ((FeatureNode) element).getFeature();
+ if(feature != null) {
+ return feature.getTitleCache();
+ }
+
}
return "No label provided";
}
-
- /**
- * <p>Getter for the field <code>feature</code>.</p>
- *
- * @return a {@link eu.etaxonomy.cdm.model.description.Feature} object.
- */
- public Feature getFeature(){
- return feature;
- }
+
}