Project

General

Profile

« Previous | Next » 

Revision e4aadd07

Added by Katja Luther over 5 years ago

ref #7903: add possibility to choose order of taxa in cdm light export

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ExportToFileDestinationWizardPage.java
18 18
import java.util.Set;
19 19
import java.util.UUID;
20 20

  
21
import org.eclipse.jface.layout.GridLayoutFactory;
21 22
import org.eclipse.jface.wizard.WizardPage;
22 23
import org.eclipse.swt.SWT;
23 24
import org.eclipse.swt.events.SelectionAdapter;
......
47 48
import eu.etaxonomy.cdm.io.tcsxml.out.TcsXmlExportConfigurator;
48 49
import eu.etaxonomy.cdm.model.taxon.Classification;
49 50
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
51
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDtoByNameComparator;
52
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDtoByRankAndNameComparator;
53
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDtoNaturalComparator;
50 54
import eu.etaxonomy.taxeditor.datasource.CdmDataSourceRepository;
55
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
56
import eu.etaxonomy.taxeditor.preference.NavigatorOrderEnum;
51 57
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
52 58
import eu.etaxonomy.taxeditor.remoting.source.CdmRemoteSourceException;
53 59
import eu.etaxonomy.taxeditor.store.CdmStore;
......
120 126
    private Button checkUseAllClassification;
121 127

  
122 128
    private Button checkExportUnpublished;
129
    Combo orderSelectionCombo;
123 130

  
124 131

  
125 132
	protected ExportToFileDestinationWizardPage(String pageName, String type,
......
304 311
						Button b = (Button) e.widget;
305 312
		                GridData data = (GridData)  classificationSelectionCombo.getLayoutData();
306 313
		                data.exclude = b.getSelection();
307
		                classificationSelectionCombo.setVisible(!data.exclude);
314
		                classificationSelectionCombo.setEnabled(!data.exclude);
308 315

  
309 316
		            	}
310 317
		        	});
......
320 327
			            	   Button b = (Button) e.widget;
321 328
				               GridData data = (GridData)  classificationSelectionCombo.getLayoutData();
322 329
				               data.exclude = b.getSelection();
323
				               classificationSelectionCombo.setVisible(!data.exclude);
330
				               classificationSelectionCombo.setEnabled(!data.exclude);
324 331

  
325 332
			               }
326 333
					  	});
......
333 340
		            	   Button b = (Button) e.widget;
334 341
		                   GridData data = (GridData)  classificationSelectionCombo.getLayoutData();
335 342
		                   data.exclude = b.getSelection();
336
		                   classificationSelectionCombo.setVisible(data.exclude);
343
		                   classificationSelectionCombo.setEnabled(data.exclude);
337 344

  
338 345
		                  }
339 346
				  	});
......
343 350
				selectedClassification = node.getClassification();
344 351
			}
345 352
			createClassificationSelectionCombo(selectNodeOrClassification);
353
			if (outputModelExport){
354
			    Label separator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
355
			    GridData gridDataSep = new GridData();
356
			    gridDataSep = new GridData(GridData.BEGINNING, GridData.CENTER, true, true);
357
			    gridDataSep.horizontalSpan = 2;
358
                separator.setLayoutData(gridDataSep);
359

  
360
                Composite comp = new Composite(composite, SWT.NONE);
361

  
362
                GridData gridData = new GridData();
363
	            gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
364
	            gridData.horizontalSpan = 2;
365
	            comp.setLayoutData(gridData);
366

  
367
	            Label label = new Label(comp, SWT.NONE);
368
                label.setText("Sorting of taxa");
369

  
370
			    orderSelectionCombo = new Combo(comp, SWT.BORDER| SWT.READ_ONLY);
371

  
372
			    GridLayoutFactory.fillDefaults().applyTo(comp);
373
	            for(NavigatorOrderEnum display: NavigatorOrderEnum.values()){
374
	                orderSelectionCombo.add(display.getLabel());
375
	            }
376

  
377
	            int index = 0;
378
	            if (PreferencesUtil.getStringValue(IPreferenceKeys.SORT_NODES) != null){
379
	                NavigatorOrderEnum orderInNavigator = NavigatorOrderEnum.valueOf(PreferencesUtil.getStringValue(IPreferenceKeys.SORT_NODES));
380

  
381
	                for (String itemLabel : orderSelectionCombo.getItems()){
382
	                    if (itemLabel.equalsIgnoreCase(orderInNavigator.getLabel())){
383
	                        orderSelectionCombo.select(index);
384
	                        setComparatorToConfig();
385
	                        break;
386
	                    }
387
	                    index++;
388
	                }
389
	            }
390

  
391
	            orderSelectionCombo.addSelectionListener(new SelectionListener() {
392

  
393
                    @Override
394
                    public void widgetSelected(SelectionEvent e) {
395
                        setComparatorToConfig();
396
                    }
397

  
398
                    @Override
399
                    public void widgetDefaultSelected(SelectionEvent e) {
400
                        // TODO Auto-generated method stub
346 401

  
402
                    }
403
                });
404

  
405
			}
347 406

  
348 407

  
349 408
			if (checkUseSelectedtaxonNode != null){
350 409

  
351 410
				if (checkUseSelectedtaxonNode.getSelection()){
352
					 classificationSelectionCombo.setVisible(false);
353

  
411
					 classificationSelectionCombo.setEnabled(false);
354 412
				}
355 413
			}else{
356
			    classificationSelectionCombo.setVisible(true);
414
			    classificationSelectionCombo.setEnabled(true);
357 415
			    classificationSelectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL,
358 416
                      true, false, 2, 1));
359 417
			}
......
411 469
		setControl(composite);
412 470
	}
413 471

  
472
    protected void setComparatorToConfig() {
473
        if (orderSelectionCombo.getText().equals(NavigatorOrderEnum.NaturalOrder.getLabel())){
474
            ((CdmLightExportConfigurator)configurator).setComparator(new TaxonNodeDtoNaturalComparator());
475
        } else if (orderSelectionCombo.getText().equals(NavigatorOrderEnum.AlphabeticalOrder.getLabel())){
476
            ((CdmLightExportConfigurator)configurator).setComparator(new TaxonNodeDtoByNameComparator());
477
        }else {
478
            ((CdmLightExportConfigurator)configurator).setComparator(new TaxonNodeDtoByRankAndNameComparator());
479
        }
480
    }
481

  
414 482
	protected String generateFilename() {
415 483
		StringBuffer buffer = new StringBuffer();
416 484

  

Also available in: Unified diff