import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
private Combo comboSourceMode;
- private Combo comboAggregationMode;
+ private CheckboxTableViewer aggregationModeViewer;
private Button btnSelectSuperAreas;
+ private Button buttonSuperArea;
private Combo comboStatusOrder;
@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();
}else{
checkUseSelectedClassification.setSelection(true);
}
- separator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
- gridData = new GridData(GridData.FILL_HORIZONTAL);
+ 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);
+
+
/*
*
updateLowerRankCombo();
comboLowerRank.addListener(SWT.Selection, this);
+
+
+ separator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
+ gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.horizontalSpan = 2;
+ gridData.verticalIndent = 5;
+ separator.setLayoutData(gridData);
+
+ Label aggregationModeLabel = new Label(control, SWT.NULL);
+ aggregationModeLabel.setText("Aggregation mode");
+ aggregationModeLabel.setToolTipText("Selecting none would delete all existing aggregated distributions");
+ aggregationModeViewer = CheckboxTableViewer.newCheckList(control, SWT.BORDER | SWT.SINGLE);
+ aggregationModeViewer.setContentProvider(new ArrayContentProvider());
+ aggregationModeViewer.setLabelProvider(new LabelProvider(){
+ @Override
+ public String getText(Object element){
+ if (element instanceof AggregationMode){
+ if (((AggregationMode)element).equals(AggregationMode.ToParent)){
+ return "from child to parent";
+ }
+ if (((AggregationMode)element).equals(AggregationMode.WithinTaxon)){
+ return "from sub area to super area";
+ }
+ }
+ return null;
+ }
+
+ });
+ List<AggregationMode> aggregationModeList = new ArrayList<>();
+ for (AggregationMode mode: AggregationMode.values()){
+ aggregationModeList.add(mode);
+ }
+
+ aggregationModeViewer.setInput(aggregationModeList);
+
+ aggregationModeViewer.addCheckStateListener(new ICheckStateListener(){
+ @Override
+ public void checkStateChanged( CheckStateChangedEvent event){
+ Object[] checked =aggregationModeViewer.getCheckedElements();
+ boolean areachecked = false;
+ for (int i = 0; i<checked.length;i++){
+ if (checked[i] instanceof AggregationMode){
+ if (((AggregationMode)checked[i]).equals(AggregationMode.WithinTaxon)){
+ areachecked = true;
+ }
+ }
+ }
+ buttonSuperArea.setEnabled(areachecked);
+ getWizard().getContainer().updateButtons();
+ }
+ });
+
+
+ buttonSuperArea = new Button(control, SWT.PUSH );
+ GridData gridData2 = new GridData();
+ gridData2.horizontalSpan = 2;
+ gridData2.horizontalAlignment = SWT.LEFT;
+
+ buttonSuperArea.setLayoutData(gridData2);
+
+ buttonSuperArea.setEnabled(false);
+ 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();
+
+ }
+ });
+
+
+
+
Label sourceModeLabel = new Label(control, SWT.NULL);
sourceModeLabel.setText("Source mode");
comboSourceMode = new Combo(control, SWT.BORDER| SWT.READ_ONLY);
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");
Label selectStatusLabel = new Label(control, SWT.NULL);
selectStatusLabel.setText("Status order");
comboStatusOrder = new Combo(control, SWT.PUSH );
-
+ comboStatusOrder.add("Default - by vocabulary");
+ comboStatusOrder.setData("Default - by vocabulary", null);
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);
+ comboStatusOrder.addSelectionListener(this);
- int open = dialog.open();
- }
- });
+ checkExportUnpublished = new Button(composite, SWT.CHECK);
+ checkExportUnpublished.setText("Export unpublished taxa");
GridLayoutFactory.fillDefaults();
}
public List<AggregationMode> getAggregationMode(){
- return (List<AggregationMode>) comboAggregationMode.getData(comboAggregationMode.getText());
+
+ List<AggregationMode> result = new ArrayList<>();
+ for (Object o: aggregationModeViewer.getCheckedElements()){
+ if (o instanceof AggregationMode){
+ result.add((AggregationMode)o);
+ }
+ }
+ return result;
}