import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.progress.IProgressConstants;
+import eu.etaxonomy.cdm.filter.TaxonNodeFilter;
import eu.etaxonomy.cdm.io.cdmLight.CdmLightExportConfigurator;
import eu.etaxonomy.cdm.model.taxon.Classification;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
import eu.etaxonomy.taxeditor.store.CdmStore;
@Override
public void init(IWorkbench workbench, IStructuredSelection selection) {
- configurator = new CdmLightExportConfigurator(null);
+ configurator = new CdmLightExportConfigurator(null);
+ if (selection instanceof TreeSelection && !selection.isEmpty()){
+ TaxonNode node = (TaxonNode)selection.getFirstElement();
+ configurator.setTaxonNodeFilter(TaxonNodeFilter.NewTaxonNodeInstance(node.getUuid()));
+
+ }
+
+
}
for(Classification c:listClassifications){
if(c.getTitleCache().equalsIgnoreCase(combo.getItem(selectionIndex))){
set.add(c.getUuid());
+ if (!page.getCheckUseSelectedTaxonNode()){
+ configurator.setTaxonNodeFilter(TaxonNodeFilter.NewClassificationInstance(c.getUuid()));
+ }
}
}
- configurator.setClassificationUuids(set);
+
}
}
package eu.etaxonomy.taxeditor.io.wizard;
+import java.awt.Checkbox;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
+import org.apache.commons.lang.StringUtils;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Text;
private List<Classification> classifications;
private Classification selectedClassification;
+ private Label classificationLabel;
private ExportConfiguratorBase configurator;
+ private Button checkUseSelectedtaxonNode;
/**
* @param pageName
if(csvExport || csvPrintExport || outputModelExport|| csvNameExport){
// Label comboBoxLabel = new Label(composite, SWT.NONE);
// comboBoxLabel.setText("Classification");
-
- createClassificationSelectionCombo(composite);
- classificationSelectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL,
- true, false, 2, 1));
+
+ if (outputModelExport && !((CdmLightExportConfigurator)configurator).getTaxonNodeFilter().getTaxonNodesFilter().isEmpty()){
+ checkUseSelectedtaxonNode= new Button(composite, SWT.CHECK);
+ checkUseSelectedtaxonNode.setText("Use selected Taxon Node (or whole Classification)");
+ checkUseSelectedtaxonNode.addListener(SWT.Selection, new Listener() {
+ @Override
+ public void handleEvent(Event e) {
+ Button b = (Button) e.widget;
+ GridData data = (GridData) classificationSelectionCombo.getLayoutData();
+ data.exclude = b.getSelection();
+ classificationSelectionCombo.setVisible(!data.exclude);
+ classificationLabel.setVisible(!data.exclude);
+
+ }
+ });
+ }
+
+ createClassificationSelectionCombo(composite);
+ classificationSelectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL,
+ true, false, 2, 1));
+
}
private void createClassificationSelectionCombo(Composite parent){
// classifications = CdmStore.getTaxonTreeService().list(null, null, null, null, null);
-// Composite classificationSelection = new Composite(parent, SWT.NULL);
-// classificationSelection.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
+ Composite classificationSelection = new Composite(parent, SWT.NULL);
+ classificationSelection.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
-// GridLayout layout = new GridLayout();
-// classificationSelection.setLayout(layout);
+ GridLayout layout = new GridLayout();
+ classificationSelection.setLayout(layout);
- Label label = new Label(parent, SWT.NULL);
+ classificationLabel = new Label(classificationSelection, SWT.NULL);
// TODO not working is not really true but leave it here to remind everyone that this is under construction
- label.setText("Select Classification");
+ classificationLabel.setText("Select Classification");
- classificationSelectionCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
+ classificationSelectionCombo = new Combo(classificationSelection, SWT.BORDER | SWT.READ_ONLY);
classificationSelectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true, 2,1));
for(Classification tree : classifications){
return selectedClassification.getUuid();
}
+
+ public boolean getCheckUseSelectedTaxonNode() {
+ return checkUseSelectedtaxonNode.getSelection();
+ }
+
+