Project

General

Profile

Revision cb53bcb3

IDcb53bcb33c9538a28eab5354dbab66c4451f9a05
Parent 0ac706e3
Child 7f861412

Added by Katja Luther almost 3 years ago

add selection of classification to csvPrintExport

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/CsvNameExportWizard.java
66 66
	            + page.getExportFileName();
67 67

  
68 68
	    final Combo combo = page.getCombo();
69

  
69
	    configurator.setClassificationUUID(page.getSelectedClassificationUUID());
70 70
	    if(CdmStore.getCurrentSessionManager().isRemoting()) {
71 71
	        // create job
72 72
	        Job job = CdmStore.getExportManager().createIOServiceJob(configurator, new File(urlString));
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/CsvPrintExportWizard.java
60 60
				+ page.getExportFileName();
61 61

  
62 62
		final Combo combo = page.getCombo();
63
		final List<Classification> listClassifications = CdmStore.getCurrentApplicationConfiguration().getClassificationService().listClassifications(null, null, null, null);
64
		if(combo != null){
65
		    int selectionIndex = combo.getSelectionIndex();
66
		    HashSet<UUID> set = new HashSet<UUID>();
67
		    if(selectionIndex == -1){
68
		        for(Classification c:listClassifications){
69
		            set.add(c.getUuid());
70
		        }
71
		    }else{
72
		        for(Classification c:listClassifications){
73
		            if(c.getTitleCache().equalsIgnoreCase(combo.getItem(selectionIndex))){
74
		                set.add(c.getUuid());
75
		            }
76
		        }
77

  
78
		        configurator.setHasHeaderLines(true);
79

  
80
		    }
81
		} else{
82
			configurator.setClassificationUUID(listClassifications.get(0).getUuid());
83
		}
63

  
64
	   
65
	    configurator.setClassificationUUID(page.getSelectedClassificationUUID());
66
		
84 67

  
85 68
		if(CdmStore.getCurrentSessionManager().isRemoting()) {
86 69
		    // create job
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ExportToFileDestinationWizardPage.java
12 12

  
13 13
import java.text.SimpleDateFormat;
14 14
import java.util.Calendar;
15
import java.util.Collections;
16
import java.util.Comparator;
15 17
import java.util.List;
18
import java.util.UUID;
16 19

  
17 20
import org.eclipse.jface.wizard.WizardPage;
18 21
import org.eclipse.swt.SWT;
19 22
import org.eclipse.swt.events.SelectionAdapter;
20 23
import org.eclipse.swt.events.SelectionEvent;
24
import org.eclipse.swt.events.SelectionListener;
21 25
import org.eclipse.swt.layout.GridData;
22 26
import org.eclipse.swt.layout.GridLayout;
23 27
import org.eclipse.swt.widgets.Button;
24 28
import org.eclipse.swt.widgets.Combo;
25 29
import org.eclipse.swt.widgets.Composite;
30
import org.eclipse.swt.widgets.Control;
26 31
import org.eclipse.swt.widgets.DirectoryDialog;
27 32
import org.eclipse.swt.widgets.Label;
28 33
import org.eclipse.swt.widgets.Text;
29 34

  
35
import eu.etaxonomy.cdm.api.service.IClassificationService;
30 36
import eu.etaxonomy.cdm.model.taxon.Classification;
31 37
import eu.etaxonomy.taxeditor.datasource.CdmDataSourceRepository;
32 38
import eu.etaxonomy.taxeditor.remoting.source.CdmRemoteSourceException;
......
41 47
 * @created 15.06.2009
42 48
 * @version 1.0
43 49
 */
44
public class ExportToFileDestinationWizardPage extends WizardPage {
50
public class ExportToFileDestinationWizardPage extends WizardPage implements SelectionListener {
45 51

  
46 52
	/** Constant <code>DATE_FORMAT_NOW="yyyyMMddHHmm"</code> */
47 53
	public static final String DATE_FORMAT_NOW = "yyyyMMddHHmm";
......
85 91

  
86 92
	private final String extension;
87 93

  
88
    private Combo comboBox;
94
    private Combo classificationSelectionCombo;
95
    
96
    private List<Classification> classifications;
97
    
98
    private Classification selectedClassification;
89 99

  
90 100
	/**
91 101
	 * @param pageName
......
225 235
		GridLayout gridLayout = new GridLayout();
226 236
		gridLayout.numColumns = 3;
227 237
		composite.setLayout(gridLayout);
238
		if(classifications == null){
239
			classifications = CdmStore.getService(IClassificationService.class).list(null, null, null, null, null);
240
			Collections.sort(classifications, new Comparator<Classification>() {
241

  
242
                @Override
243
                public int compare(Classification o1, Classification o2) {
244
                    return o1.getTitleCache().compareTo(o2.getTitleCache());
245
                }
246
            });
247
			
248
			selectedClassification = classifications.iterator().next();
249
		}
228 250

  
229 251

  
230
		if(csvExport){
252
		if(csvExport || csvPrintExport){
231 253
		    Label comboBoxLabel = new Label(composite, SWT.NONE);
232 254
		    comboBoxLabel.setText("Classification");
233
		    Combo comboBox = addComboBox(composite);
234
		    comboBox.setLayoutData(new GridData(SWT.FILL, SWT.FILL,
255
		   
256
		    createClassificationSelectionCombo(composite);
257
		    classificationSelectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL,
235 258
		                true, false, 2, 1));
236 259
		}
237 260
		
......
326 349
		return text_folder.getText();
327 350
	}
328 351

  
329
	private Combo addComboBox(Composite composite){
352
	private Control createClassificationSelectionCombo(Composite parent){
353
//		classifications = CdmStore.getTaxonTreeService().list(null, null, null, null, null);
330 354

  
331
	    comboBox = new Combo(composite, SWT.DROP_DOWN);
332
	    comboBox.setText("Choose Classification");
355
		Composite classificationSelection = new Composite(parent, SWT.NULL);
356
		classificationSelection.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
333 357

  
334
	    final List<Classification> listClassifications = CdmStore.getCurrentApplicationConfiguration().getClassificationService().listClassifications(null, null, null, null);
358
		GridLayout layout = new GridLayout();
359
		classificationSelection.setLayout(layout);
335 360

  
336
	    for(Classification c : listClassifications){
337
	        comboBox.add(c.getTitleCache());
338
	    }
361
		Label label = new Label(classificationSelection, SWT.NULL);
362
		// TODO not working is not really true but leave it here to remind everyone that this is under construction
363
		label.setText("Select Classification");
364
		classificationSelectionCombo = new Combo(classificationSelection, SWT.BORDER | SWT.READ_ONLY);
365
		classificationSelectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true));
366

  
367
		for(Classification tree : classifications){
368
			classificationSelectionCombo.add(tree.getName().getText(), classifications.indexOf(tree));
369

  
370
		}
339 371

  
340
	    return comboBox;
372
		classificationSelectionCombo.select(classifications.indexOf(selectedClassification));
373

  
374
		// TODO remember last selection
375
		classificationSelectionCombo.addSelectionListener(this);
376

  
377

  
378

  
379
		return classificationSelection;
341 380
	}
342 381

  
343 382
	public Combo getCombo(){
344
	    return comboBox;
383
	    return classificationSelectionCombo;
384
	}
385

  
386
	@Override
387
	public void widgetSelected(SelectionEvent e) {
388
		selectedClassification = classifications.get(classificationSelectionCombo.getSelectionIndex());
389
		
390
	}
391

  
392
	@Override
393
	public void widgetDefaultSelected(SelectionEvent e) {
394
		//not needed here
395
		
396
	}
397

  
398
	public UUID getSelectedClassificationUUID() {
399
		
400
		return selectedClassification.getUuid();
345 401
	}
346 402

  
347 403
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)