import java.text.SimpleDateFormat;
import java.util.Calendar;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.List;
+import java.util.UUID;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
+import eu.etaxonomy.cdm.api.service.IClassificationService;
import eu.etaxonomy.cdm.model.taxon.Classification;
import eu.etaxonomy.taxeditor.datasource.CdmDataSourceRepository;
import eu.etaxonomy.taxeditor.remoting.source.CdmRemoteSourceException;
* @created 15.06.2009
* @version 1.0
*/
-public class ExportToFileDestinationWizardPage extends WizardPage {
+public class ExportToFileDestinationWizardPage extends WizardPage implements SelectionListener {
/** Constant <code>DATE_FORMAT_NOW="yyyyMMddHHmm"</code> */
public static final String DATE_FORMAT_NOW = "yyyyMMddHHmm";
private final String extension;
- private Combo comboBox;
+ private Combo classificationSelectionCombo;
+
+ private List<Classification> classifications;
+
+ private Classification selectedClassification;
/**
* @param pageName
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 3;
composite.setLayout(gridLayout);
+ if(classifications == null){
+ classifications = CdmStore.getService(IClassificationService.class).list(null, null, null, null, null);
+ Collections.sort(classifications, new Comparator<Classification>() {
+
+ @Override
+ public int compare(Classification o1, Classification o2) {
+ return o1.getTitleCache().compareTo(o2.getTitleCache());
+ }
+ });
+
+ selectedClassification = classifications.iterator().next();
+ }
- if(csvExport){
+ if(csvExport || csvPrintExport){
Label comboBoxLabel = new Label(composite, SWT.NONE);
comboBoxLabel.setText("Classification");
- Combo comboBox = addComboBox(composite);
- comboBox.setLayoutData(new GridData(SWT.FILL, SWT.FILL,
+
+ createClassificationSelectionCombo(composite);
+ classificationSelectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL,
true, false, 2, 1));
}
return text_folder.getText();
}
- private Combo addComboBox(Composite composite){
+ private Control createClassificationSelectionCombo(Composite parent){
+// classifications = CdmStore.getTaxonTreeService().list(null, null, null, null, null);
- comboBox = new Combo(composite, SWT.DROP_DOWN);
- comboBox.setText("Choose Classification");
+ Composite classificationSelection = new Composite(parent, SWT.NULL);
+ classificationSelection.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
- final List<Classification> listClassifications = CdmStore.getCurrentApplicationConfiguration().getClassificationService().listClassifications(null, null, null, null);
+ GridLayout layout = new GridLayout();
+ classificationSelection.setLayout(layout);
- for(Classification c : listClassifications){
- comboBox.add(c.getTitleCache());
- }
+ Label label = 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");
+ classificationSelectionCombo = new Combo(classificationSelection, SWT.BORDER | SWT.READ_ONLY);
+ classificationSelectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true));
+
+ for(Classification tree : classifications){
+ classificationSelectionCombo.add(tree.getName().getText(), classifications.indexOf(tree));
+
+ }
- return comboBox;
+ classificationSelectionCombo.select(classifications.indexOf(selectedClassification));
+
+ // TODO remember last selection
+ classificationSelectionCombo.addSelectionListener(this);
+
+
+
+ return classificationSelection;
}
public Combo getCombo(){
- return comboBox;
+ return classificationSelectionCombo;
+ }
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ selectedClassification = classifications.get(classificationSelectionCombo.getSelectionIndex());
+
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ //not needed here
+
+ }
+
+ public UUID getSelectedClassificationUUID() {
+
+ return selectedClassification.getUuid();
}
}