eu.etaxonomy.cdm.io.csv.caryophyllales.out,
eu.etaxonomy.cdm.io.csv.redlist.demo,
eu.etaxonomy.cdm.io.csv.redlist.out,
+ eu.etaxonomy.cdm.io.descriptive.owl.out,
eu.etaxonomy.cdm.io.distribution.excelupdate,
eu.etaxonomy.cdm.io.dwca,
eu.etaxonomy.cdm.io.dwca.in,
lblNewLabel_1.setText("Properties");
treeViewerProperties = addFeatureTreeEditor(composite_1);
- initFeatureTreeComposite(treeViewerProperties, new CharacterDragListener(treeViewerStructures.getViewer(), treeViewerProperties.getViewer()), null);
+ initFeatureTreeComposite(treeViewerProperties, null, null);
+ //TODO: fix drag and drop
+// initFeatureTreeComposite(treeViewerProperties, new CharacterDragListener(treeViewerStructures.getViewer(), treeViewerProperties.getViewer()), null);
Composite composite_2 = new Composite(sashForm, SWT.NONE);
formToolkit.adapt(composite_2);
featureTreeEditorComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
featureTreeEditorComposite.getButton_add().setVisible(false);
featureTreeEditorComposite.getButton_remove().setVisible(false);
+ featureTreeEditorComposite.getBtnExportTree().setVisible(false);
return featureTreeEditorComposite;
}
featureTreeEditorComposite.init(featureNodeDragListener, featureNodeDropAdapter, this,
new FeatureTreeChooserListener(featureTreeEditorComposite), new SelectionAdapter() {
}, new SelectionAdapter() {
+ }, new SelectionAdapter() {
});
}
import eu.etaxonomy.cdm.api.service.IFeatureNodeService;
import eu.etaxonomy.cdm.api.service.IFeatureTreeService;
import eu.etaxonomy.cdm.api.service.config.FeatureNodeDeletionConfigurator;
-import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.model.description.Feature;
import eu.etaxonomy.cdm.model.description.FeatureNode;
import eu.etaxonomy.cdm.model.description.FeatureTree;
private Shell shell;
- private FeatureTree featureTree;
-
private FeatureTreeEditorComposite composite;
@Inject
}
/** {@inheritDoc} */
- @PostConstruct
- public void createControl(Composite parent, @Named(IServiceConstants.ACTIVE_SHELL)Shell shell) {
- composite = new FeatureTreeEditorComposite(parent, SWT.NULL);
- composite.init(new FeatureNodeDragListener(composite.getViewer()), new FeatureNodeDropAdapter(this, composite.getViewer()), this, new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- FeatureTree tree = FeatureTreeSelectionDialog.select(shell, conversation, null);
- if(tree!=null){
- setSelectedTree(tree);
- }
- }
- }, new AddButtonListener(), new RemoveSelectionListener());
+ @PostConstruct
+ public void createControl(Composite parent, @Named(IServiceConstants.ACTIVE_SHELL) Shell shell) {
+ composite = new FeatureTreeEditorComposite(parent, SWT.NULL);
+ composite.init(new FeatureNodeDragListener(composite.getViewer()),
+ new FeatureNodeDropAdapter(this, composite.getViewer()), this, new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ FeatureTree tree = FeatureTreeSelectionDialog.select(shell, conversation, null);
+ if (tree != null) {
+ composite.setSelectedTree(tree, FeatureTreeEditor.this);
+ }
+ }
+ }, new AddButtonListener(), new RemoveSelectionListener(), new FeatureTreeExportListener(shell, composite));
composite.getText_title().setEnabled(false);
- }
+ }
public void setDirty(boolean isDirty){
this.dirty.setDirty(isDirty);
return dirty.isDirty();
}
- public void setSelectedTree(FeatureTree featureTree) {
- this.featureTree = HibernateProxyHelper.deproxy(featureTree, FeatureTree.class);
- this.featureTree.setRoot(HibernateProxyHelper.deproxy(featureTree.getRoot(), FeatureNode.class));
- composite.getViewer().setInput(featureTree);
-
- composite.getText_title().setEnabled(true);
- composite.getText_title().removeModifyListener(this);
- composite.getText_title().setText(featureTree.getTitleCache());
- composite.getText_title().addModifyListener(this);
- }
-
public FeatureTree getSelectedFeatureTree(){
- return this.featureTree;
+ return composite.getFeatureTree();
}
/** {@inheritDoc} */
@Override
public void modifyText(ModifyEvent e) {
- featureTree.setTitleCache(composite.getText_title().getText(), true);
+ composite.getFeatureTree().setTitleCache(composite.getText_title().getText(), true);
setDirty(true);
}
// commit the conversation and start a new transaction immediately
conversation.commit(true);
- CdmStore.getService(IFeatureTreeService.class).saveOrUpdate(featureTree);
+ CdmStore.getService(IFeatureTreeService.class).saveOrUpdate(composite.getFeatureTree());
this.setDirty(false);
}
@Override
public List<FeatureTree> getRootEntities() {
List<FeatureTree> root = new ArrayList<>();
- root.add(featureTree);
+ root.add(composite.getFeatureTree());
return root;
}
@Override
public void widgetSelected(SelectionEvent e) {
AvailableFeaturesWizard wizard = new AvailableFeaturesWizard(
- featureTree);
+ composite.getFeatureTree());
WizardDialog dialog = new WizardDialog(shell, wizard);
if (dialog.open() == IStatus.OK) {
composite.getViewer().refresh();
}
}
+
}
private TreeViewer viewer;
private Button button_add;
private Button button_remove;
+ private Button btnExportTree;
public FeatureTreeEditorComposite(Composite parent, int style) {
super(parent, style);
button_remove.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
button_remove.setToolTipText(Messages.FeatureTreeEditorComposite_REMOVE_FEATURE);
button_remove.setImage(ImageResources.getImage(ImageResources.TRASH_ICON));
+
+ btnExportTree = new Button(composite_buttons, SWT.NONE);
+ btnExportTree.setToolTipText("Export feature tree");
+ btnExportTree.setImage(ImageResources.getImage(ImageResources.MOVE_ICON));
}
public void init(DragSourceListener dragSourceListener,
DropTargetListener dropTargetListener, ISelectionChangedListener viewerSelectionChangedListener,
- SelectionListener openFeatureTreeSelectionListener, SelectionListener addButtonSelectionListener, SelectionListener removeButtonSelectionListener) {
+ SelectionListener openFeatureTreeSelectionListener, SelectionListener addButtonSelectionListener, SelectionListener removeButtonSelectionListener, SelectionListener exportButtonSelectionListener) {
viewer.setContentProvider(new FeatureTreeContentProvider());
viewer.setLabelProvider(new FeatureTreeLabelProvider());
button_add.addSelectionListener(addButtonSelectionListener);
button_remove.addSelectionListener(removeButtonSelectionListener);
+ btnExportTree.addSelectionListener(exportButtonSelectionListener);
btnOpenFeatureTree.addSelectionListener(openFeatureTreeSelectionListener);
}
return button_remove;
}
+ /**
+ * @return the btnExportTree
+ */
+ public Button getBtnExportTree() {
+ return btnExportTree;
+ }
+
}
--- /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.e4;
+
+import java.io.File;
+
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.progress.IProgressConstants;
+
+import eu.etaxonomy.cdm.io.descriptive.owl.out.OwlExportConfigurator;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author pplitzner
+ * @since Jul 4, 2017
+ *
+ */
+public class FeatureTreeExportListener extends SelectionAdapter{
+
+ private Shell shell;
+ private FeatureTreeEditorComposite composite;
+
+ public FeatureTreeExportListener(Shell shell, FeatureTreeEditorComposite composite) {
+ super();
+ this.shell = shell;
+ this.composite = composite;
+ }
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if(composite.getFeatureTree()==null){
+ MessagingUtils.informationDialog("Export not possible", "There is no feature tree selected.");
+ return;
+ }
+ DirectoryDialog dialog = new DirectoryDialog(shell);
+ String directoryString = dialog.open();
+ if(directoryString!=null){
+ // create job
+ Job job = CdmStore.getExportManager().createIOServiceJob(OwlExportConfigurator.NewInstance(null, null, composite.getFeatureTree()), new File(directoryString+"/owl.owl"));
+ // configure the job
+ job.setProperty(IProgressConstants.KEEP_PROPERTY, true);
+ job.setUser(true);
+ // schedule job
+ job.schedule();
+ }
+ }
+}