Project

General

Profile

Revision e4aadd07

IDe4aadd07dfc0c699a5f5ef98304738c14b74744d
Parent 1f351807
Child 6285cec5

Added by Katja Luther almost 2 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/ExcelDistributionUpdateWizard.java
36 36
public class ExcelDistributionUpdateWizard extends AbstractImportWizard<ExcelDistributionUpdateConfigurator> {
37 37
    private ExcelDistributionUpdateConfigurator configurator;
38 38

  
39
    private ImportFromFileAndChooseVocIdWizardOage dataSourcePage;
39
    private ImportFromFileAndChooseVocIdWizardPage dataSourcePage;
40 40

  
41 41
    private static final Logger logger = Logger.getLogger(ExcelDistributionUpdateWizard.class);
42 42

  
......
115 115
    }
116 116

  
117 117
    private void addDataSourcePage(){
118
        dataSourcePage = new ImportFromFileAndChooseVocIdWizardOage("Choose Excel File",
118
        dataSourcePage = new ImportFromFileAndChooseVocIdWizardPage("Choose Excel File",
119 119
                "Please choose an xls file in the Distribution Update format.", new String[]{"*.xlsx", "*.xls", "*.*"});
120 120
        addPage(dataSourcePage);
121 121
    }
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

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ImportFromFileAndChooseVocIdWizardOage.java
1
/**
2
* Copyright (C) 2017 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.io.wizard;
10

  
11
import java.util.List;
12
import java.util.UUID;
13

  
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.events.SelectionAdapter;
16
import org.eclipse.swt.events.SelectionEvent;
17
import org.eclipse.swt.layout.GridData;
18
import org.eclipse.swt.widgets.Combo;
19
import org.eclipse.swt.widgets.Composite;
20
import org.eclipse.swt.widgets.Label;
21

  
22
import eu.etaxonomy.cdm.api.service.IVocabularyService;
23
import eu.etaxonomy.cdm.common.CdmUtils;
24
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
25
import eu.etaxonomy.cdm.model.common.TermType;
26
import eu.etaxonomy.cdm.model.common.TermVocabulary;
27
import eu.etaxonomy.taxeditor.l10n.Messages;
28
import eu.etaxonomy.taxeditor.store.CdmStore;
29

  
30
/**
31
 * @author k.luther
32
 * @date 04.05.2017
33
 *
34
 */
35
public class ImportFromFileAndChooseVocIdWizardOage extends ImportFromFileDataSourceWizardPage {
36

  
37
    private Combo vocabularyCombo;
38
    UUID vocUuid;
39
    String[][] labelAndValues;
40
    /**
41
     * @param title
42
     * @param description
43
     * @param extensions
44
     */
45
    protected ImportFromFileAndChooseVocIdWizardOage(String title, String description, String[] extensions) {
46
        super(title, description, extensions);
47

  
48
    }
49

  
50
    @Override
51
    public void createControl(Composite parent) {
52
        super.createControl(parent);
53
        Composite composite = (Composite)getControl();
54
      //  final Composite composite = new Composite(parent, SWT.NULL);
55
        GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false);
56
        composite.setLayoutData(gridData);
57
        Label label = new Label(composite, SWT.NONE);
58
        label.setText(Messages.ImportFromFileAndChooseVocIdWizardPage_AreaVoc);
59
        label.setToolTipText(Messages.ImportFromFileAndChooseVocIdWizardOage_AreaVoc_toolTip);
60
        vocabularyCombo = new Combo(composite, SWT.DROP_DOWN);
61
        List<TermVocabulary<DefinedTermBase>> vocs = CdmStore.getService(IVocabularyService.class).findByTermType(TermType.NamedArea, null);
62
        for(TermVocabulary voc: vocs){
63
            vocabularyCombo.add(voc.getLabel());
64
        }
65
        getLabelAndValues(vocs);
66
        vocabularyCombo.select(0);
67
        vocabularyCombo.addSelectionListener(new SelectionAdapter(){
68

  
69
            @Override
70
            public void widgetSelected(SelectionEvent e) {
71
                String name = vocabularyCombo.getText();
72

  
73
                for (String[] labelAndValue: labelAndValues){
74
                    if (labelAndValue[0].equals(name)){
75
                        String uuidString = labelAndValue[1];
76
                        vocUuid = UUID.fromString(uuidString);
77
                        setPageComplete(isPageComplete());
78
                    }
79
                }
80

  
81
            }
82

  
83
        });
84
        //setControl(composite);
85
    }
86

  
87
    public UUID getVocUuid() {
88
        return vocUuid;
89
    }
90

  
91
    public void setVocUuid(UUID vocUuid) {
92
        this.vocUuid = vocUuid;
93
    }
94

  
95
    /**
96
     * @return
97
     */
98
    private String[][] getLabelAndValues(List<TermVocabulary<DefinedTermBase>> vocs) {
99

  
100
        labelAndValues = new String[vocs.size()][2];
101
        for (int i = 0; i < vocs.size(); i++) {
102
            labelAndValues[i][0] = vocs.get(i).getLabel();
103
            labelAndValues[i][1] = vocs.get(i).getUuid().toString();
104
        }
105
        return labelAndValues;
106
    }
107

  
108
    @Override
109
    public boolean isPageComplete() {
110
        boolean result = CdmUtils.isNotBlank(text_source.getText()) && vocUuid != null;
111

  
112
        return result;
113
    }
114

  
115
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ImportFromFileAndChooseVocIdWizardPage.java
1
/**
2
* Copyright (C) 2017 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.io.wizard;
10

  
11
import java.util.List;
12
import java.util.UUID;
13

  
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.events.SelectionAdapter;
16
import org.eclipse.swt.events.SelectionEvent;
17
import org.eclipse.swt.layout.GridData;
18
import org.eclipse.swt.widgets.Combo;
19
import org.eclipse.swt.widgets.Composite;
20
import org.eclipse.swt.widgets.Label;
21

  
22
import eu.etaxonomy.cdm.api.service.IVocabularyService;
23
import eu.etaxonomy.cdm.common.CdmUtils;
24
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
25
import eu.etaxonomy.cdm.model.common.TermType;
26
import eu.etaxonomy.cdm.model.common.TermVocabulary;
27
import eu.etaxonomy.taxeditor.l10n.Messages;
28
import eu.etaxonomy.taxeditor.store.CdmStore;
29

  
30
/**
31
 * @author k.luther
32
 * @date 04.05.2017
33
 *
34
 */
35
public class ImportFromFileAndChooseVocIdWizardPage extends ImportFromFileDataSourceWizardPage {
36

  
37
    private Combo vocabularyCombo;
38
    UUID vocUuid;
39
    String[][] labelAndValues;
40
    /**
41
     * @param title
42
     * @param description
43
     * @param extensions
44
     */
45
    protected ImportFromFileAndChooseVocIdWizardPage(String title, String description, String[] extensions) {
46
        super(title, description, extensions);
47

  
48
    }
49

  
50
    @Override
51
    public void createControl(Composite parent) {
52
        super.createControl(parent);
53
        Composite composite = (Composite)getControl();
54
      //  final Composite composite = new Composite(parent, SWT.NULL);
55
        GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false);
56
        composite.setLayoutData(gridData);
57
        Label label = new Label(composite, SWT.NONE);
58
        label.setText(Messages.ImportFromFileAndChooseVocIdWizardPage_AreaVoc);
59
        label.setToolTipText(Messages.ImportFromFileAndChooseVocIdWizardOage_AreaVoc_toolTip);
60
        vocabularyCombo = new Combo(composite, SWT.DROP_DOWN);
61
        List<TermVocabulary<DefinedTermBase>> vocs = CdmStore.getService(IVocabularyService.class).findByTermType(TermType.NamedArea, null);
62
        for(TermVocabulary voc: vocs){
63
            vocabularyCombo.add(voc.getLabel());
64
        }
65
        getLabelAndValues(vocs);
66
        vocabularyCombo.select(0);
67
        vocabularyCombo.addSelectionListener(new SelectionAdapter(){
68

  
69
            @Override
70
            public void widgetSelected(SelectionEvent e) {
71
                String name = vocabularyCombo.getText();
72

  
73
                for (String[] labelAndValue: labelAndValues){
74
                    if (labelAndValue[0].equals(name)){
75
                        String uuidString = labelAndValue[1];
76
                        vocUuid = UUID.fromString(uuidString);
77
                        setPageComplete(isPageComplete());
78
                    }
79
                }
80

  
81
            }
82

  
83
        });
84
        //setControl(composite);
85
    }
86

  
87
    public UUID getVocUuid() {
88
        return vocUuid;
89
    }
90

  
91
    public void setVocUuid(UUID vocUuid) {
92
        this.vocUuid = vocUuid;
93
    }
94

  
95
    /**
96
     * @return
97
     */
98
    private String[][] getLabelAndValues(List<TermVocabulary<DefinedTermBase>> vocs) {
99

  
100
        labelAndValues = new String[vocs.size()][2];
101
        for (int i = 0; i < vocs.size(); i++) {
102
            labelAndValues[i][0] = vocs.get(i).getLabel();
103
            labelAndValues[i][1] = vocs.get(i).getUuid().toString();
104
        }
105
        return labelAndValues;
106
    }
107

  
108
    @Override
109
    public boolean isPageComplete() {
110
        boolean result = CdmUtils.isNotBlank(text_source.getText()) && vocUuid != null;
111

  
112
        return result;
113
    }
114

  
115
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/Messages.java
661 661
    public static String ToggleableText_ToolTip_open;
662 662

  
663 663

  
664
    public static String PublishFlagPreference_description_not_allowed;
665

  
666

  
664 667

  
665 668

  
666 669

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages.properties
372 372
GfBioTerminologyImportPresenter_SEARCH_TOO_SHORT_TITLE=Search phrase too short
373 373

  
374 374
PublishFlagPreference_description=Configure the default settings for the publish flag in new created taxa
375
PublishFlagPreference_description_not_allowed=The configuration of the default settings for the publish flag in new created taxa is not possible in local preferences. If you want to change the configuration, please contact an administrator.
375 376
PublishFlagPreference_do_not_set=Don't set publish flag
376 377
PublishFlagPreference_inherit=Inherit from parent
377 378
PublishFlagPreference_set=Set publish flag
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages_de.properties
372 372
GfBioTerminologyImportPresenter_SEARCH_TOO_SHORT_TITLE=Suchbegriff zu kurz
373 373

  
374 374
PublishFlagPreference_description=Konfiguration des Default Verhaltens beim Setzen des Publish Flags in einem neu erzeugten Taxon.
375
PublishFlagPreference_description_not_allowed=Die Konfiguration des Default Verhaltens beim Setzen des Publish Flags in einem neu erzeugten Taxon kann nur ?ber die Admin Pr?ferenzen ge?ndert werden, da kein lokales ?berschreiben erlaubt ist. Wenn Sie dennoch ?nderungen vornehmen m?chten, wenden Sie sich an einen Administrator.
375 376
PublishFlagPreference_do_not_set=Publish Flag NICHT setzen
376 377
PublishFlagPreference_inherit=Erbe vom Elterntaxon
377 378
PublishFlagPreference_set=Publish Flag setzen
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/PublishFlagLocalPreference.java
1
/**
2
* Copyright (C) 2019 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.preference;
10

  
11
import org.eclipse.swt.SWT;
12
import org.eclipse.swt.custom.CLabel;
13
import org.eclipse.swt.events.SelectionAdapter;
14
import org.eclipse.swt.events.SelectionEvent;
15
import org.eclipse.swt.events.SelectionListener;
16
import org.eclipse.swt.widgets.Button;
17
import org.eclipse.swt.widgets.Combo;
18
import org.eclipse.swt.widgets.Composite;
19
import org.eclipse.swt.widgets.Control;
20

  
21
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
22
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
23
import eu.etaxonomy.taxeditor.l10n.Messages;
24
import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
25

  
26
/**
27
 * @author k.luther
28
 * @since 08.01.2019
29
 *
30
 */
31
public class PublishFlagLocalPreference extends CdmPreferencePage {
32

  
33
    PublishEnum publishBehaviour;
34

  
35
    Combo publishFlagBehaviour;
36
    CdmPreference pref = null;
37

  
38
    protected boolean allowOverride;
39

  
40
   @Override
41
   public void init() {
42
       super.init();
43

  
44

  
45
   }
46
    /**
47
     * {@inheritDoc}
48
     */
49
    @Override
50
    protected Control createContents(Composite parent) {
51
        pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DefaultBehaviourForPublishFlag);
52
        if (pref == null){
53
            pref = CdmPreference.NewTaxEditorInstance(EditorPreferencePredicate.DefaultBehaviourForPublishFlag, EditorPreferencePredicate.DefaultBehaviourForPublishFlag.getDefaultValue().toString());
54
        }
55
        allowOverride = pref.isAllowOverride();
56
        Composite composite = createComposite(parent);
57
        final CLabel description = new CLabel(composite, SWT.NULL);
58
        if (!allowOverride){
59
            description.setText(Messages.PublishFlagPreference_description_not_allowed);
60
            description.setLayoutData(createTextGridData());
61
            return composite;
62
        }
63
        PublishEnum publishFlag = PublishEnum.valueOf(PreferencesUtil.getStringValue(PreferencePredicate.DefaultBehaviourForPublishFlag.getKey(), true));
64

  
65
        description.setText(Messages.PublishFlagPreference_description);
66
        description.setLayoutData(createTextGridData());
67
        publishFlagBehaviour = new Combo(composite, SWT.READ_ONLY);
68

  
69
        publishFlagBehaviour.setFont(parent.getFont());
70
        for(PublishEnum display: PublishEnum.values()){
71
            publishFlagBehaviour.add(display.getLabel());
72
        }
73

  
74
        publishFlagBehaviour.addSelectionListener(new SelectionListener() {
75

  
76
            @Override
77
            public void widgetSelected(SelectionEvent e) {
78
                setApply(true);
79
            }
80

  
81
            @Override
82
            public void widgetDefaultSelected(SelectionEvent e) {
83
                // TODO Auto-generated method stub
84

  
85
            }
86
        });
87
        Button allowOverrideButton = createAllowOverrideButton(composite);
88
        allowOverrideButton.setText(Messages.GeneralPreference_override);
89
        allowOverrideButton.setSelection(allowOverride);
90
        allowOverrideButton.addSelectionListener(new SelectionAdapter(){
91
            @Override
92
            public void widgetSelected(SelectionEvent e) {
93
                allowOverride = allowOverrideButton.getSelection();
94
                setApply(true);
95
                }
96
        });
97

  
98
        int index = 0;
99

  
100

  
101
        for (String itemLabel : publishFlagBehaviour.getItems()){
102
            if (itemLabel.equalsIgnoreCase(publishFlag.getLabel())){
103
                publishFlagBehaviour.select(index);
104
                break;
105
            }
106
            index++;
107
        }
108

  
109
        return composite;
110

  
111
    }
112

  
113

  
114
    @Override
115
    public boolean performOk() {
116
        String text = publishFlagBehaviour.getText();
117
        for (PublishEnum display: PublishEnum.values()){
118
            if (display.getLabel().equals(text)){
119
                text = display.getKey();
120
                break;
121
            }
122
        }
123
        PreferencesUtil.setStringValue(PreferencePredicate.DefaultBehaviourForPublishFlag.getKey(), text);
124
        PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(EditorPreferencePredicate.DefaultBehaviourForPublishFlag.getKey()), allowOverride);
125
        return true;
126
    }
127

  
128

  
129
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)