import eu.etaxonomy.taxeditor.l10n.Messages;
import eu.etaxonomy.taxeditor.store.CdmStore;
import eu.etaxonomy.taxeditor.store.StoreUtil;
+import eu.etaxonomy.taxeditor.ui.combo.OriginalSourceTypeComparator;
import eu.etaxonomy.taxeditor.ui.dialog.SuperAreaSelectionWizard;
/**
private Combo comboHigherRank;
private Combo comboLowerRank;
- private Combo comboSourceMode;
+ private Combo comboSourceModeChildParent;
+ private Combo comboSourceModeSubAreaSuperArea;
private CheckboxTableViewer aggregationModeViewer;
Object[] checkedElements;
Map<String, OriginalSourceType> typeMap = new HashMap();
+ Comparator comparator = new Comparator<Rank>(){
+
+ @Override
+ public int compare(Rank o1, Rank o2) {
+ return o2.compareTo(o1);
+ }
+
+ };
+
/**
* @param pageName
*/
public DistributionAggregationWizardPage(DistributionAggregationConfiguration configurator) {
- super("Set Publish Flag Configuration");
+ super("Distribution aggregation configuration");
this.configurator = configurator;
this.setDescription("Configure the aggregation");
comboHigherRank = new Combo(control, SWT.BORDER | SWT.READ_ONLY);
updateHigherRankCombo();
comboHigherRank.addListener(SWT.Selection, this);
+
+
Label lowerRankLabel = new Label(control, SWT.NULL);
lowerRankLabel.setText("Lowest rank");
comboLowerRank = new Combo(control, SWT.BORDER | SWT.READ_ONLY);
public void checkStateChanged( CheckStateChangedEvent event){
Object[] checked =aggregationModeViewer.getCheckedElements();
boolean areachecked = false;
+ boolean toParentChecked = false;
for (int i = 0; i<checked.length;i++){
if (checked[i] instanceof AggregationMode){
if (((AggregationMode)checked[i]).equals(AggregationMode.WithinTaxon)){
areachecked = true;
}
+ if (((AggregationMode)checked[i]).equals(AggregationMode.ToParent)){
+ toParentChecked = true;
+ }
}
}
comboAreaLevel.setEnabled(areachecked);
buttonSuperArea.setEnabled(areachecked);
+ comboSourceModeSubAreaSuperArea.setEnabled(areachecked);
+ comboSourceModeChildParent.setEnabled(toParentChecked);
getWizard().getContainer().updateButtons();
}
});
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);
+
+ sourceModeLabel.setText("Source mode child/parent");
+ sourceModeLabel.setToolTipText("Defines the source mode if aggregation from child to parent taxon is selected.");
+ comboSourceModeChildParent = new Combo(control, SWT.BORDER| SWT.READ_ONLY);
+ comboSourceModeChildParent.setText(Messages.DistributionAggregationConfiguration_AggregationMode);
+ comboSourceModeChildParent.add("None");
+ comboSourceModeChildParent.setData(null);
for (AggregationSourceMode mode :AggregationSourceMode.values()){
- comboSourceMode.add(mode.toString());
- comboSourceMode.setData(mode.toString(), mode);
+ comboSourceModeChildParent.add(mode.toString());
+ comboSourceModeChildParent.setData(mode.toString(), mode);
+
}
- comboSourceMode.addSelectionListener(this);
+ comboSourceModeChildParent.addSelectionListener(this);
+ comboSourceModeChildParent.setEnabled(false);
+ comboSourceModeChildParent.select(0);
+
+ Label sourceModeLabelSuperArea = new Label(control, SWT.NULL);
+ sourceModeLabelSuperArea.setText("Source mode sub area/super area");
+ sourceModeLabelSuperArea.setToolTipText("Defines the source mode if aggregation from sub area to super area is selected.");
+ comboSourceModeSubAreaSuperArea = new Combo(control, SWT.BORDER| SWT.READ_ONLY);
+ comboSourceModeSubAreaSuperArea.setText(Messages.DistributionAggregationConfiguration_AggregationMode);
+ comboSourceModeSubAreaSuperArea.add("None");
+ comboSourceModeSubAreaSuperArea.setData(null);
+ for (AggregationSourceMode mode :AggregationSourceMode.values()){
+ comboSourceModeSubAreaSuperArea.add(mode.toString());
+ comboSourceModeSubAreaSuperArea.setData(mode.toString(), mode);
+ }
+ comboSourceModeSubAreaSuperArea.addSelectionListener(this);
+ comboSourceModeSubAreaSuperArea.setEnabled(false);
+ comboSourceModeSubAreaSuperArea.select(0);
Label sourceTypeLabel = new Label(control, SWT.NULL);
sourceTypeLabel.setText("Source type");
});
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()));
-// typeStrings.sort(new OriginalSourceTypeComparator(null));
+ OriginalSourceType[] typeArray = OriginalSourceType.values();
+ Arrays.sort(typeArray, new OriginalSourceTypeComparator(null));
+ Arrays.stream(typeArray).forEach(p ->typeMap.put(p.getMessage(), p));
+ Arrays.stream(typeArray).forEach(p ->typeStrings.add(p.getMessage()));
+ typeStrings.remove(OriginalSourceType.NomenclaturalReference.getMessage());
sourceTypeViewer.setInput(typeStrings);
sourceTypeViewer.setChecked(OriginalSourceType.PrimaryMediaSource.getMessage(), true);
sourceTypeViewer.setChecked(OriginalSourceType.PrimaryTaxonomicSource.getMessage(), true);
+ sourceTypeViewer.getTable().setEnabled(false);
//aggregation mode
}
comboStatusOrder.addSelectionListener(this);
-
+ comboStatusOrder.select(0);
checkExportUnpublished = new Button(composite, SWT.CHECK);
checkExportUnpublished.setText("Export unpublished taxa");
@Override
public void widgetSelected(SelectionEvent e) {
- if (e.getSource().equals(comboSourceMode)){
- configurator.setToParentSourceMode((AggregationSourceMode)comboSourceMode.getData(comboSourceMode.getText()));
- configurator.setWithinTaxonSourceMode((AggregationSourceMode)comboSourceMode.getData(comboSourceMode.getText()));
+
+ if (e.getSource().equals(comboSourceModeChildParent) || e.getSource().equals(comboSourceModeSubAreaSuperArea)){
+ AggregationSourceMode modeChild = (AggregationSourceMode)comboSourceModeChildParent.getData(comboSourceModeChildParent.getText());
+ AggregationSourceMode modeArea = (AggregationSourceMode)comboSourceModeSubAreaSuperArea.getData(comboSourceModeSubAreaSuperArea.getText());
+ if ((modeChild != null && modeChild.equals(AggregationSourceMode.ALL) || modeChild.equals(AggregationSourceMode.ALL_SAMEVALUE)) ||(modeArea != null && modeArea.equals(AggregationSourceMode.ALL) || modeArea.equals(AggregationSourceMode.ALL_SAMEVALUE))){
+ sourceTypeViewer.getTable().setEnabled(true);
+ }else{
+ sourceTypeViewer.getTable().setEnabled(false);
+ }
+
}
if (e.getSource().equals(comboAreaLevel)){
private void updateHigherRankCombo() {
comboHigherRank.removeAll();
-
+ List<Rank> rankList = new ArrayList<>();
TaxonName name = null;
if (subTreeNode != null){
if (subTreeNode.getTaxon() != null){
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);
+ if (useClassification() || (name != null && name.getRank().isHigher(rank))){
+ rankList.add(rank);
}
-
}
}else{
for (Rank rank: CdmStore.getTermManager().getPreferredTerms(Rank.class)){
- comboHigherRank.add(rank.getLabel());
- comboHigherRank.setData(rank.getLabel(), rank);
+ rankList.add(rank);
}
}
+ rankList.sort(comparator);
+ for (Rank rank: rankList){
+ comboHigherRank.add(rank.getLabel());
+ comboHigherRank.setData(rank.getLabel(), rank);
+ }
+
+
}
private void updateLowerRankCombo() {
comboLowerRank.removeAll();
TaxonName name = null;
+ List<Rank> rankList = new ArrayList<>();
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);
+ rankList.add(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);
+ rankList.add(rank);
}
}
}
-
+ rankList.sort(comparator);
+ for (Rank rank: rankList){
+ comboLowerRank.add(rank.getLabel());
+ comboLowerRank.setData(rank.getLabel(), rank);
+ }
}
return null;
}
- public AggregationSourceMode getSourceMode(){
- if (StringUtils.isNotBlank(comboSourceMode.getText())){
- return (AggregationSourceMode)comboSourceMode.getData(comboSourceMode.getText());
+
+ public AggregationSourceMode getSourceModeChildParent(){
+ if (StringUtils.isNotBlank(comboSourceModeChildParent.getText())){
+ return (AggregationSourceMode)comboSourceModeChildParent.getData(comboSourceModeChildParent.getText());
+ }
+ return null;
+ }
+
+ public AggregationSourceMode getSourceModeSuperAreaSubArea(){
+ if (StringUtils.isNotBlank(comboSourceModeSubAreaSuperArea.getText())){
+ return (AggregationSourceMode)comboSourceModeSubAreaSuperArea.getData(comboSourceModeSubAreaSuperArea.getText());
+
}
return null;
}
return EnumSet.copyOf(list);
}
- public List<AggregationMode> getAggregationMode(){
+ public List<AggregationSourceMode> getAggregationMode(){
- List<AggregationMode> result = new ArrayList<>();
+ List<AggregationSourceMode> result = new ArrayList<>();
for (Object o: aggregationModeViewer.getCheckedElements()){
- if (o instanceof AggregationMode){
- result.add((AggregationMode)o);
+ if (o instanceof AggregationSourceMode){
+ result.add((AggregationSourceMode)o);
}
}
return result;