--- /dev/null
+/**
+* Copyright (C) 2019 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.navigation.navigator.e4.handler;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.inject.Named;
+
+import org.eclipse.core.commands.operations.AbstractOperation;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.e4.core.di.annotations.CanExecute;
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
+import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+
+import eu.etaxonomy.cdm.api.service.description.DescriptionAggregationConfigurationBase.AggregationMode;
+import eu.etaxonomy.cdm.api.service.description.DistributionAggregationConfiguration;
+import eu.etaxonomy.cdm.filter.TaxonNodeFilter;
+import eu.etaxonomy.cdm.model.taxon.Classification;
+import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
+import eu.etaxonomy.taxeditor.editor.EditorUtil;
+import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
+import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigatorLabels;
+import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4;
+import eu.etaxonomy.taxeditor.ui.dialog.configurator.DistributionAggregationConfiguratorWizard;
+import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart;
+
+/**
+ * @author k.luther
+ * @since 15.11.2019
+ */
+public class AggregateDistributionForSubTreeHandler extends RemotingCdmHandlerE4 {
+
+
+
+ private TaxonNodeDto taxonNode;
+ private DistributionAggregationConfiguration configurator;
+ private static final String NO = Messages.NO;
+ private static final String CANCEL = Messages.RemotingMoveTaxonNodeHandler_CANCEL;
+ private static final String YES = Messages.YES;
+
+ /**
+ * @param label
+ */
+ public AggregateDistributionForSubTreeHandler() {
+ super("");
+
+ }
+
+
+ @Override
+ public IStatus allowOperations(IStructuredSelection selection, Shell shell, MPart activePart,
+ MHandledMenuItem menuItem) {
+ // check that only a single taxon tree node has been selected
+ if(selection.size() > 1) { }
+
+ // check for no taxon tree node selected
+ if(selection.size() == 0) {
+ return new Status(IStatus.ERROR,
+ "unknown", //$NON-NLS-1$
+ TaxonNavigatorLabels.NO_TAXON_SELECTION_MESSAGE);
+ }
+
+ // check that selected object is a taxon node
+ Object obj = selection.iterator().next();
+ if(obj instanceof TaxonNodeDto) {
+ taxonNode = (TaxonNodeDto)obj;
+ } else if(obj instanceof Classification){
+ taxonNode = new TaxonNodeDto(((Classification)obj).getRootNode());
+ }else{
+ return new Status(IStatus.ERROR,
+ "unknown", //$NON-NLS-1$
+ TaxonNavigatorLabels.SELECTED_OBJECT_NOT_TREE_NODE_MESSAGE);
+ }
+ Collection<IE4SavablePart> dirtyParts = EditorUtil.checkForTaxonChanges(null, partService);
+
+ if (dirtyParts != null && !dirtyParts.isEmpty()){
+ String[] buttonLables = {YES, NO,CANCEL};
+ MessageDialog dialog = new MessageDialog(null, Messages.SetPublishFlagForSubtreeHandlerE4_UnsavedChanges, null, Messages.SetPublishFlagForSubtreeHandlerE4_UnsavedChangesQuestion, MessageDialog.QUESTION_WITH_CANCEL, buttonLables, 0);
+ dialog.open();
+ int returnCode = dialog.getReturnCode();
+ boolean proceed = false;
+ if (returnCode == 0){
+ proceed = true;
+ }else if (returnCode == 2){
+ return Status.CANCEL_STATUS;
+ }
+
+ Iterator<IE4SavablePart> partIterator = dirtyParts.iterator();
+ while( partIterator.hasNext() ){
+ IE4SavablePart part = partIterator.next();
+ if (proceed) {
+ if (part != null){
+ part.save(new NullProgressMonitor());
+ }
+ }
+ }
+ }
+
+
+ configurator = DistributionAggregationConfiguration.NewInstance(AggregationMode.byAreasAndRanks(), null, TaxonNodeFilter.NewSubtreeInstance(taxonNode.getUuid()), null);
+ DistributionAggregationConfiguratorWizard wizard = new DistributionAggregationConfiguratorWizard(configurator);
+
+ WizardDialog dialog = new WizardDialog(shell, wizard);
+
+ if (dialog.open() == Window.OK) {
+ return Status.OK_STATUS;
+ }else{
+ return Status.CANCEL_STATUS;
+ }
+ }
+
+ @Override
+ public AbstractOperation prepareOperation(IStructuredSelection selection, Shell shell, MPart activePart,
+ MHandledMenuItem menuItem) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void onComplete() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected Object getTrigger() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @CanExecute
+ private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection, MHandledMenuItem menuItem){
+ boolean canExecute = false;
+ canExecute = selection.size()==1
+ && selection.getFirstElement() instanceof TaxonNodeDto;
+ menuItem.setVisible(canExecute);
+ return canExecute;
+ }
+
+}
--- /dev/null
+/**
+* Copyright (C) 2019 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.ui.dialog.configurator;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.lang.StringUtils;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.wizard.WizardDialog;
+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.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+
+import eu.etaxonomy.cdm.api.application.CdmApplicationState;
+import eu.etaxonomy.cdm.api.service.IClassificationService;
+import eu.etaxonomy.cdm.api.service.ITermTreeService;
+import eu.etaxonomy.cdm.api.service.description.DescriptionAggregationConfigurationBase.AggregationMode;
+import eu.etaxonomy.cdm.api.service.description.DescriptionAggregationConfigurationBase.SourceMode;
+import eu.etaxonomy.cdm.api.service.description.DistributionAggregationConfiguration;
+import eu.etaxonomy.cdm.filter.LogicFilter;
+import eu.etaxonomy.cdm.model.name.Rank;
+import eu.etaxonomy.cdm.model.name.TaxonName;
+import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
+import eu.etaxonomy.cdm.model.taxon.Classification;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.cdm.model.term.TermTree;
+import eu.etaxonomy.cdm.model.term.TermType;
+import eu.etaxonomy.taxeditor.l10n.Messages;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+import eu.etaxonomy.taxeditor.store.StoreUtil;
+import eu.etaxonomy.taxeditor.ui.dialog.SuperAreaSelectionWizard;
+
+/**
+ * @author k.luther
+ * @since 15.11.2019
+ */
+public class DistributionAggregationWizardPage extends WizardPage implements Listener, SelectionListener{
+
+ private DistributionAggregationConfiguration configurator;
+
+ private Combo comboHigherRank;
+ private Combo comboLowerRank;
+
+ private Combo comboSourceMode;
+
+ private Combo comboAggregationMode;
+
+ private Button btnSelectSuperAreas;
+ private Combo comboStatusOrder;
+
+
+ private Combo comboClassificationSelection;
+ private List<Classification> classifications;
+ private Classification selectedClassification;
+
+
+
+ private Button checkUseSelectedTaxonNode;
+ private Button checkUseSelectedClassification;
+ private Button checkUseSelectedSubtree;
+
+
+ private Button checkExportUnpublished;
+
+ private TaxonNode subTreeNode;
+ private CheckboxTableViewer sourceTypeViewer;
+ Object[] checkedElements;
+ Map<String, OriginalSourceType> typeMap = new HashMap();
+
+
+ /**
+ * @param pageName
+ */
+ public DistributionAggregationWizardPage(DistributionAggregationConfiguration configurator) {
+ super("Set Publish Flag Configuration");
+ this.configurator = configurator;
+
+ this.setDescription(Messages.SetPublishConfiguration_Description_Configurator);
+
+ }
+
+
+ @Override
+ public void createControl(Composite parent) {
+ final Composite composite = new Composite(parent, SWT.NULL);
+ checkExportUnpublished = new Button(composite, SWT.CHECK);
+ checkExportUnpublished.setText("Export unpublished taxa");
+ GridData gridDataCheckUnpublished = new GridData(GridData.FILL_HORIZONTAL);
+ gridDataCheckUnpublished.horizontalSpan = 2;
+
+
+ Label separator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.horizontalSpan = 2;
+ gridData.verticalIndent = 5;
+ separator.setLayoutData(gridData);
+
+ String taxonStr = "";
+ int count = configurator.getTaxonNodeFilter().getSubtreeFilter().size();
+ // TaxonNode node = null;
+ for (LogicFilter<TaxonNode> filter: configurator.getTaxonNodeFilter().getSubtreeFilter()){
+ subTreeNode = CdmApplicationState.getCurrentAppConfig().getTaxonNodeService().load(filter.getUuid());
+ count--;
+ if (subTreeNode.hasTaxon()){
+ taxonStr += subTreeNode.getTaxon().getName().getTitleCache();
+ if (count>0){
+ taxonStr += ", ";
+ }
+ }
+ }
+ if (StringUtils.isNotBlank(taxonStr)){
+ checkUseSelectedTaxonNode= new Button(composite, SWT.RADIO);
+ checkUseSelectedTaxonNode.setText("Aggregation only for ("+ taxonStr+")");
+ checkUseSelectedTaxonNode.addListener(SWT.Selection, new Listener() {
+ @Override
+ public void handleEvent(Event e) {
+ Button b = (Button) e.widget;
+ GridData data = (GridData) comboClassificationSelection.getLayoutData();
+ data.exclude = b.getSelection();
+ comboClassificationSelection.setEnabled(!data.exclude);
+ updateHigherRankCombo();
+ }
+
+
+ });
+
+ checkUseSelectedSubtree= new Button(composite, SWT.RADIO);
+ checkUseSelectedSubtree.setText("Aggregation for selected subtree(s) ("+ taxonStr+")");
+ checkUseSelectedSubtree.addListener(SWT.Selection, new Listener() {
+ @Override
+ public void handleEvent(Event e) {
+ Button b = (Button) e.widget;
+ GridData data = (GridData) comboClassificationSelection.getLayoutData();
+ data.exclude = b.getSelection();
+ comboClassificationSelection.setEnabled(!data.exclude);
+
+ updateHigherRankCombo();
+ }
+ });
+
+ }
+
+
+ checkUseSelectedClassification= new Button(composite, SWT.RADIO);
+ checkUseSelectedClassification.setText("Export selected classification");
+ checkUseSelectedClassification.addListener(SWT.Selection, new Listener() {
+ @Override
+ public void handleEvent(Event e) {
+ Button b = (Button) e.widget;
+ GridData data = (GridData) comboClassificationSelection.getLayoutData();
+ data.exclude = b.getSelection();
+ comboClassificationSelection.setEnabled(data.exclude);
+ updateHigherRankCombo();
+ }
+ });
+
+
+ GridLayoutFactory.fillDefaults();
+
+ if (subTreeNode!= null){
+ selectedClassification = subTreeNode.getClassification();
+ }
+ GridData gridDataClassificationCombo = new GridData();
+ gridDataClassificationCombo = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
+ gridDataClassificationCombo.horizontalIndent = 5;
+// classificationSelection.setLayoutData(gridData);
+
+ comboClassificationSelection = new Combo(composite, SWT.BORDER| SWT.READ_ONLY);
+ comboClassificationSelection.setLayoutData(gridDataClassificationCombo);
+ 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) {
+ if (o1.equals(o2)){
+ return 0;
+ }
+ int result = o1.getTitleCache().compareTo(o2.getTitleCache());
+ if (result == 0){
+ return o1.getUuid().compareTo(o2.getUuid());
+ }
+ return result;
+ }
+ });
+ for(Classification tree : classifications){
+ comboClassificationSelection.add(tree.getName().getText(), classifications.indexOf(tree));
+
+ }
+
+ comboClassificationSelection.select(classifications.indexOf(selectedClassification));
+
+ // TODO remember last selection
+ comboClassificationSelection.addSelectionListener(this);
+
+ if (StringUtils.isNotBlank(taxonStr)){
+ checkUseSelectedTaxonNode.setSelection(true);
+ comboClassificationSelection.setEnabled(false);
+ }else{
+ checkUseSelectedClassification.setSelection(true);
+ }
+ separator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
+ gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.horizontalSpan = 2;
+ gridData.verticalIndent = 5;
+ separator.setLayoutData(gridData);
+
+/*
+ *
+
+ TaxonNodeFilter parameter
+ subtrees (TaxonNode) - if started from navigator by taxon node kontext menu, this should be prefilled
+ upperRank and lower rank, both are optional, but upperRank should not show ranks above the rank of the selected taxonnode (if any selected)
+ includeUnpublished (not yet fully implemented but definetely needed)
+ taxonNodes: if we want to allow to update single taxonNodes (without subtree) we can use this, maybe the UI can have a checkbox "on subtree/on taxon only" to switch between subtrees/taxonNodes
+
+
+ statusOrder: this is a link on all TermTree in the DB, which can be created with TaxEditor now. If empty the default ordering of the vocabulary for PresenceAbsenceTerm is taken, so if you want you can also add this vocabulary to the selection list
+
+ SourceMode: List of the available enum of same name, a human readable version is still missing
+
+ aggregatingSourceTypes: source types to use for aggregation, by default it is the both PrimaryXXX
+
+ */
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = 1;
+
+ composite.setLayout(gridLayout);
+ final Composite control = new Composite(composite, SWT.NULL);
+ GridLayout gridLayoutControl = new GridLayout();
+ gridLayoutControl.numColumns = 2;
+ control.setLayout(gridLayoutControl);
+ control.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, true));
+
+ Label higherRankLabel = new Label(control, SWT.NULL);
+ higherRankLabel.setText("Higher rank");
+ comboHigherRank = new Combo(control, SWT.BORDER | SWT.READ_ONLY);
+ updateHigherRankCombo();
+ comboHigherRank.addListener(SWT.Selection, this);
+ Label lowerRankLabel = new Label(control, SWT.NULL);
+ lowerRankLabel.setText("Lower rank");
+ comboLowerRank = new Combo(control, SWT.BORDER | SWT.READ_ONLY);
+ updateLowerRankCombo();
+ comboLowerRank.addListener(SWT.Selection, this);
+
+ Label sourceModeLabel = new Label(control, SWT.NULL);
+ sourceModeLabel.setText("Source mode");
+ comboSourceMode = new Combo(control, SWT.BORDER| SWT.READ_ONLY);
+ comboSourceMode.setText(Messages.DistributionAggregationConfiguration_AggregationMode);
+ for (SourceMode mode :SourceMode.values()){
+ comboSourceMode.add(mode.toString());
+ comboSourceMode.setData(mode.toString(), mode);
+ }
+
+ comboSourceMode.addSelectionListener(this);
+
+ Label aggregationModeLabel = new Label(control, SWT.NULL);
+ aggregationModeLabel.setText("Aggregation mode");
+ comboAggregationMode = new Combo(control, SWT.BORDER| SWT.READ_ONLY);
+ comboAggregationMode.setText(Messages.DistributionAggregationConfiguration_AggregationMode);
+// for (AggregationMode mode: AggregationMode.values()){
+// comboAggregationMode.add(mode.toString());
+// comboAggregationMode.setData(mode.toString(), mode);
+// }
+ comboAggregationMode.add("ranks");
+ comboAggregationMode.setData("ranks", AggregationMode.byRanks());
+
+ comboAggregationMode.add("areas and ranks");
+ comboAggregationMode.setData("areas and ranks", AggregationMode.byAreasAndRanks());
+
+ comboAggregationMode.add("areas");
+ comboAggregationMode.setData("areas", AggregationMode.byAreas());
+
+
+ comboAggregationMode.addSelectionListener(this);
+
+ Label sourceTypeLabel = new Label(control, SWT.NULL);
+ sourceTypeLabel.setText("Source type");
+
+ sourceTypeViewer = CheckboxTableViewer.newCheckList(control, SWT.BORDER | SWT.SINGLE);
+ sourceTypeViewer.setContentProvider(new ArrayContentProvider());
+
+
+ sourceTypeViewer.addCheckStateListener(new ICheckStateListener(){
+ @Override
+ public void checkStateChanged( CheckStateChangedEvent event){
+ checkedElements=sourceTypeViewer.getCheckedElements();
+ getWizard().getContainer().updateButtons();
+ }
+ });
+
+ List<String> typeStrings = new ArrayList<>();
+ Arrays.stream(OriginalSourceType.values()).forEach(p ->typeMap.put(p.getMessage(), p));
+ Arrays.stream(OriginalSourceType.values()).forEach(p ->typeStrings.add(p.getMessage()));
+ sourceTypeViewer.setInput(typeStrings);
+ sourceTypeViewer.setChecked(OriginalSourceType.PrimaryMediaSource.getMessage(), true);
+ sourceTypeViewer.setChecked(OriginalSourceType.PrimaryTaxonomicSource.getMessage(), true);
+
+ //aggregation mode
+
+
+
+ Label selectStatusLabel = new Label(control, SWT.NULL);
+ selectStatusLabel.setText("Status order");
+ comboStatusOrder = new Combo(control, SWT.PUSH );
+
+ for (TermTree tree: CdmStore.getService(ITermTreeService.class).list(TermType.PresenceAbsenceTerm, null, 0, null,null)){
+ comboStatusOrder.add(tree.getTitleCache());
+ comboStatusOrder.setData(tree.getTitleCache(), tree);
+ }
+ comboStatusOrder.setText(Messages.DistributionAggregationConfiguration_StatusOrder);
+ comboStatusOrder.addSelectionListener(this);
+
+ Button buttonSuperArea = new Button(control, SWT.PUSH );
+ GridData gridData2 = new GridData();
+ gridData2.horizontalSpan = 1;
+ gridData2.horizontalAlignment = SWT.RIGHT;
+
+ buttonSuperArea.setLayoutData(gridData2);
+
+
+ buttonSuperArea.setText("Select Super Areas");
+// buttonSuperArea.setToolTipText(Messages.ChecklistEditor_DIST_STATUS_TOOLTIP);
+ buttonSuperArea.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ SuperAreaSelectionWizard availableDistributionWizard = new SuperAreaSelectionWizard(configurator);
+ WizardDialog dialog = new WizardDialog(StoreUtil.getShell(),
+ availableDistributionWizard);
+
+ int open = dialog.open();
+
+ }
+ });
+
+ GridLayoutFactory.fillDefaults();
+
+
+
+ setControl(composite);
+
+ }
+
+
+
+
+
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (e.getSource().equals(comboSourceMode)){
+
+ configurator.setToParentSourceMode((SourceMode)comboSourceMode.getData(comboSourceMode.getText()));
+ configurator.setWithinTaxonSourceMode((SourceMode)comboSourceMode.getData(comboSourceMode.getText()));
+ }
+
+
+ }
+
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ @Override
+ public void handleEvent(Event event) {
+ if (event.widget.equals(comboHigherRank)){
+ updateLowerRankCombo();
+ }
+ if (event.widget.equals(selectedClassification)){
+ updateHigherRankCombo();
+ updateLowerRankCombo();
+ }
+ if (event.widget.equals(this.checkUseSelectedClassification)){
+ updateHigherRankCombo();
+ updateLowerRankCombo();
+ }
+ if (event.widget.equals(this.checkUseSelectedSubtree)){
+ updateHigherRankCombo();
+ updateLowerRankCombo();
+ }
+ if (event.widget.equals(this.checkUseSelectedTaxonNode)){
+ updateHigherRankCombo();
+ updateLowerRankCombo();
+ }
+
+ }
+
+ private void updateHigherRankCombo() {
+ comboHigherRank.removeAll();
+
+ TaxonName name = null;
+ if (subTreeNode != null){
+ if (subTreeNode.getTaxon() != null){
+ name = subTreeNode.getTaxon().getName();
+ }
+ }
+ comboHigherRank.add("");
+ if (name != null){
+ for (Rank rank: CdmStore.getTermManager().getPreferredTerms(Rank.class)){
+ if (useClassification()){
+ comboHigherRank.add(rank.getLabel());
+ comboHigherRank.setData(rank.getLabel(), rank);
+ }else if (name != null && name.getRank().isHigher(rank)){
+ comboHigherRank.add(rank.getLabel());
+ comboHigherRank.setData(rank.getLabel(), rank);
+ }
+
+ }
+ }else{
+ for (Rank rank: CdmStore.getTermManager().getPreferredTerms(Rank.class)){
+ comboHigherRank.add(rank.getLabel());
+ comboHigherRank.setData(rank.getLabel(), rank);
+ }
+ }
+
+ }
+
+
+ private void updateLowerRankCombo() {
+ comboLowerRank.removeAll();
+ TaxonName name = null;
+ if (subTreeNode != null){
+ if (subTreeNode.getTaxon() != null){
+ name = subTreeNode.getTaxon().getName();
+ }
+ }
+ comboLowerRank.add("");
+ for (Rank rank: CdmStore.getTermManager().getPreferredTerms(Rank.class)){
+ if (subTreeNode == null && (comboHigherRank.getText() == null || (comboHigherRank.getData(comboHigherRank.getText()) != null && ((Rank)comboHigherRank.getData(comboHigherRank.getText())).isHigher(rank)))){
+ comboLowerRank.add(rank.getLabel());
+ comboLowerRank.setData(rank.getLabel(), rank);
+ }else if (name == null || name.getRank().isHigher(rank)) {
+ if(StringUtils.isBlank(comboHigherRank.getText()) || comboHigherRank.getData(comboHigherRank.getText()) != null && ((Rank)comboHigherRank.getData(comboHigherRank.getText())).isHigher(rank)){
+ // the rank is lower than higher rank and lower than the rank of the subtree name
+ comboLowerRank.add(rank.getLabel());
+ comboLowerRank.setData(rank.getLabel(), rank);
+ }
+ }
+ }
+
+
+ }
+
+ public Rank getHigherRank(){
+ if (StringUtils.isNotBlank(comboHigherRank.getText())){
+ return (Rank)comboHigherRank.getData(comboHigherRank.getText());
+ }
+ return null;
+ }
+
+ public Rank getLowerRank(){
+ if (StringUtils.isNotBlank(comboLowerRank.getText())){
+ return (Rank)comboLowerRank.getData(comboLowerRank.getText());
+ }
+ return null;
+ }
+
+ public SourceMode getSourceMode(){
+ if (StringUtils.isNotBlank(comboSourceMode.getText())){
+ return (SourceMode)comboSourceMode.getData(comboSourceMode.getText());
+ }
+ return null;
+ }
+
+ public TermTree getStatusOrder(){
+ if (StringUtils.isNotBlank(comboStatusOrder.getText())){
+ return (TermTree)comboStatusOrder.getData(comboStatusOrder.getText());
+ }
+ return null;
+ }
+
+ public boolean useClassification(){
+ return checkUseSelectedClassification.getSelection();
+ }
+
+ public boolean useSubtree(){
+ return checkUseSelectedSubtree.getSelection();
+ }
+
+ public boolean useTaxonNode(){
+ return checkUseSelectedTaxonNode.getSelection();
+ }
+
+ public boolean useUnpublishedData(){
+ return checkExportUnpublished.getSelection();
+ }
+
+ public EnumSet<OriginalSourceType> getSourceTypes(){
+ List<OriginalSourceType> list = new ArrayList<>();
+ for (Object o: sourceTypeViewer.getCheckedElements()){
+ String string = null;
+ if (o instanceof String){
+ string = (String)o;
+ }
+ if (string != null){
+ list.add(typeMap.get(string));
+ }
+ }
+
+ return EnumSet.copyOf(list);
+ }
+
+ public List<AggregationMode> getAggregationMode(){
+ return (List<AggregationMode>) comboAggregationMode.getData(comboAggregationMode.getText());
+ }
+
+
+ public Classification getSelectedClassification() {
+ return selectedClassification;
+ }
+
+
+ public TaxonNode getSubTreeNode() {
+ return subTreeNode;
+ }
+}