}
public Collection<? extends TermDto> getChildTerms(TermVocabularyDto voc) {
- Collection<TermDto> children = vocabularyToChildTermMap.get(voc);
+ Collection<TermDto> children = getVocabularyToChildTermMap().get(voc);
if(children==null){
children = new ArrayList<>(CdmStore.getService(IVocabularyService.class).getCompleteTermHierarchy(voc));
- vocabularyToChildTermMap.put(voc, children);
+ getVocabularyToChildTermMap().put(voc, children);
}
return children;
}
public void removeVocabularyFromCache(TermVocabularyDto voc){
- vocabularyToChildTermMap.remove(voc);
+ getVocabularyToChildTermMap().remove(voc);
+ }
+
+ public Map<TermVocabularyDto, Collection<TermDto>> getVocabularyToChildTermMap() {
+ return vocabularyToChildTermMap;
+ }
+
+ public void setVocabularyToChildTermMap(Map<TermVocabularyDto, Collection<TermDto>> vocabularyToChildTermMap) {
+ this.vocabularyToChildTermMap = vocabularyToChildTermMap;
}
}
*/
public class AvailableDistributionPage extends AbstractTermSelectionWizardPage<TermDto> {
+
+
public AvailableDistributionPage(String pageName) {
super(pageName, TermType.NamedArea);
this.localPref = true;
}
+
@Override
public void createControl(Composite parent) {
setTitle(Messages.AvailableDistributionPage_PAGE_TITLE);
}
+ /**
+ * Grays the tree items corresponding to the given elements.<br>
+ * @param elements
+ */
+ public void setGrayedElements(Object[] elements) {
+ viewer.setGrayedElements(elements);
+ for (Object element: elements) {
+ viewer.reveal(element);
+ }
+ TreeItem[] rootItems = viewer.getTree().getItems();
+ for (TreeItem rootItem : rootItems) {
+ updateItem(rootItem);
+ }
+
+ }
+
@Override
public void widgetSelected(SelectionEvent e) {
ITreeSelection structuredSelection = viewer.getStructuredSelection();
--- /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.combo;
+
+import java.util.Comparator;
+
+import eu.etaxonomy.cdm.model.reference.OriginalSourceBase;
+import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
+
+/**
+ * @author pplitzner, k.luther
+ * @since 04.12.2019
+ */
+/**
+ * Sorts source type combo alphabetically <b>except</b> for PrimaryTaxonomicSource resp.
+ * PrimaryMediaSource which are always on top depending on the IdentifiableSource;
+ * <br>
+ * The last two are always "Other" followed by "Unknown"
+ * @author pplitzner
+ * @date Jan 6, 2017
+ *
+ */
+public class OriginalSourceTypeComparator implements Comparator<OriginalSourceType>{
+
+ private OriginalSourceBase entity;
+
+ public OriginalSourceTypeComparator(OriginalSourceBase entity) {
+ this.entity = entity;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int compare(OriginalSourceType o1, OriginalSourceType o2) {
+ if(o1==null){
+ if(o2==null){
+ return 0;
+ }
+ else{
+ return -1;
+ }
+ }
+ if(o2==null){
+ return 1;
+ }
+ //both are either taxonomic or media
+ else if(o1.equals(OriginalSourceType.PrimaryTaxonomicSource)
+ && o2.equals(OriginalSourceType.PrimaryMediaSource)){
+ if(entity != null && entity.getType().equals(OriginalSourceType.PrimaryMediaSource)){
+ return 1;
+ }
+ else{
+ return -1;
+ }
+ }
+ else if(o2.equals(OriginalSourceType.PrimaryTaxonomicSource)
+ && o1.equals(OriginalSourceType.PrimaryMediaSource)){
+ if(entity != null && entity.getType().equals(OriginalSourceType.PrimaryMediaSource)){
+ return -1;
+ }
+ else{
+ return 1;
+ }
+ }
+ //one is not taxonomic or media
+ else if(o1.equals(OriginalSourceType.PrimaryTaxonomicSource)
+ ||o1.equals(OriginalSourceType.PrimaryMediaSource)){
+ return -1;
+
+ }
+ else if(o2.equals(OriginalSourceType.PrimaryTaxonomicSource)
+ || o2.equals(OriginalSourceType.PrimaryMediaSource)){
+ return 1;
+ }
+ //The last two are always "Other" followed by "Unknown"
+ else if(o1.equals(OriginalSourceType.Other)){
+ if(o2.equals(OriginalSourceType.Unknown)){
+ return -11;
+ }
+ else{
+ return 1;
+ }
+ }
+ if(o2.equals(OriginalSourceType.Other)){
+ return 1;
+ }
+ else{
+ String message1 = o1.getKey();
+ String message2 = o2.getKey();
+ return message1.compareTo(message2);
+ }
+ }
+
+}
\ No newline at end of file
import eu.etaxonomy.cdm.persistence.dto.TermDto;
import eu.etaxonomy.cdm.persistence.dto.TermVocabularyDto;
import eu.etaxonomy.taxeditor.l10n.Messages;
-import eu.etaxonomy.taxeditor.preference.wizard.SuperAreaPage;
+import eu.etaxonomy.taxeditor.ui.dialog.configurator.wizard.SuperAreaPage;
/**
* @author k.luther
import java.util.UUID;
import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.widgets.Display;
import eu.etaxonomy.cdm.api.application.CdmApplicationState;
import eu.etaxonomy.cdm.api.service.description.DistributionAggregationConfiguration;
import eu.etaxonomy.cdm.api.service.longrunningService.ILongRunningTasksService;
+import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor;
import eu.etaxonomy.cdm.filter.TaxonNodeFilter;
import eu.etaxonomy.taxeditor.l10n.Messages;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.operation.IPostMoniteredOperationEnabled;
/**
* @author k.luther
* @since 15.11.2019
*/
-public class DistributionAggregationConfiguratorWizard extends Wizard {
+public class DistributionAggregationConfiguratorWizard extends Wizard implements IPostMoniteredOperationEnabled {
private final DistributionAggregationConfiguration configurator;
private DistributionAggregationWizardPage page;
private ILongRunningTasksService longRunningTaskService;
UUID uuid = longRunningTaskService.invoke(configurator);
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ AbstractUtility.executeMoniteredOperation("Aggregate Distributions",
+ uuid,
+ 1000,
+ false,
+ DistributionAggregationConfiguratorWizard.this,
+ null,
+ true);
+
+ }
+
+ });
return true;
}
}
+ @Override
+ public void postOperation(IRemotingProgressMonitor monitor) {
+ // TODO Auto-generated method stub
+
+ }
+
+
}
super("Set Publish Flag Configuration");
this.configurator = configurator;
- this.setDescription(Messages.SetPublishConfiguration_Description_Configurator);
+ this.setDescription("Configure the aggregation");
}
});
}
checkUseSelectedClassification= new Button(composite, SWT.RADIO);
- checkUseSelectedClassification.setText("Export selected classification");
+ checkUseSelectedClassification.setText("Aggregate selected classification");
checkUseSelectedClassification.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event e) {
control.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, true));
Label higherRankLabel = new Label(control, SWT.NULL);
- higherRankLabel.setText("Higher rank");
+ higherRankLabel.setText("Highest 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");
+ lowerRankLabel.setText("Lowest rank");
comboLowerRank = new Combo(control, SWT.BORDER | SWT.READ_ONLY);
updateLowerRankCombo();
comboLowerRank.addListener(SWT.Selection, this);
public String getText(Object element){
if (element instanceof AggregationMode){
if (((AggregationMode)element).equals(AggregationMode.ToParent)){
- return "from child to parent";
+ return "From child to parent taxon";
}
if (((AggregationMode)element).equals(AggregationMode.WithinTaxon)){
- return "from sub area to super area";
+ return "From sub area to super area";
}
}
return null;
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));
sourceTypeViewer.setInput(typeStrings);
sourceTypeViewer.setChecked(OriginalSourceType.PrimaryMediaSource.getMessage(), true);
sourceTypeViewer.setChecked(OriginalSourceType.PrimaryTaxonomicSource.getMessage(), true);
--- /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.wizard;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import eu.etaxonomy.cdm.api.service.IVocabularyService;
+import eu.etaxonomy.cdm.persistence.dto.TermDto;
+import eu.etaxonomy.cdm.persistence.dto.TermVocabularyDto;
+import eu.etaxonomy.taxeditor.editor.definedterm.TermDtoContentProvider;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author k.luther
+ * @since 03.12.2019
+ */
+public class NamedAreaTermDtoContentProvider extends TermDtoContentProvider {
+
+ @Override
+ public Collection<? extends TermDto> getChildTerms(TermVocabularyDto voc) {
+ Collection<TermDto> children = getVocabularyToChildTermMap().get(voc);
+ if(children==null){
+ children = new ArrayList<>(CdmStore.getService(IVocabularyService.class).getCompleteTermHierarchy(voc));
+ getVocabularyToChildTermMap().put(voc, children);
+ }
+ return children;
+ }
+
+}
* 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.preference.wizard;
+package eu.etaxonomy.taxeditor.ui.dialog.configurator.wizard;
import java.util.ArrayList;
import java.util.Collection;
import eu.etaxonomy.taxeditor.editor.definedterm.DefinedTermSorter;
import eu.etaxonomy.taxeditor.editor.definedterm.TermDtoContentProvider;
import eu.etaxonomy.taxeditor.editor.definedterm.TermDtoLabelProvider;
+import eu.etaxonomy.taxeditor.preference.wizard.AvailableDistributionPage;
+import eu.etaxonomy.taxeditor.preference.wizard.CheckBoxTreeComposite;
import eu.etaxonomy.taxeditor.store.CdmStore;
/**
*/
private void setLevelChecked() {
initialiseVocabularies();
- List<TermDto> areasWithLevel= new ArrayList();
- List<UUID> uuidList = new ArrayList<>();
- getVocabularies().stream().forEach(p -> uuidList.add(p.getUuid()));
- Collection<TermDto> terms = CdmStore.getService(IVocabularyService.class).getTerms(uuidList);
+ List<TermDto> areasChecked= new ArrayList();
+ List<TermDto> areasGrayed = new ArrayList();
+ List<UUID> vocUuidList = new ArrayList<>();
+ getVocabularies().stream().forEach(p -> vocUuidList.add(p.getUuid()));
+ Collection<TermDto> terms = CdmStore.getService(IVocabularyService.class).getNamedAreaTerms(vocUuidList);
for (TermDto term: terms) {
if (term.getLevel() != null && term.getLevel().equals(level)){
- areasWithLevel.add(term);
+ areasChecked.add(term);
+ }else if (term.getLevel() != null && term.getLevel().isHigher(level)){
+ Object[] children = ((TermDtoContentProvider)this.getViewer().getContentProvider()).getChildren(term);
+ boolean checked = false;
+ if (children != null && children.length >0){
+ for (Object o: children){
+ if (o instanceof TermDto){
+ TermDto dto = ((TermDto)o);
+ if (dto.getLevel() != null && dto.getLevel().equals(level)){
+ checked = true;
+ }
+ }
+ }
+ }
+ if (checked){
+ areasGrayed.add(term);
+ }
}
}
treeComposite.getViewer().setInput(getVocabularies());
- treeComposite.setCheckedElements(areasWithLevel.toArray());
+ treeComposite.setCheckedElements(areasChecked.toArray());
+ treeComposite.setGrayedElements(areasGrayed.toArray());
}
@Override
package eu.etaxonomy.taxeditor.ui.section.supplemental;
-import java.util.Comparator;
-
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionListener;
import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
+import eu.etaxonomy.taxeditor.ui.combo.OriginalSourceTypeComparator;
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
}
- /**
- * Sorts source type combo alphabetically <b>except</b> for PrimaryTaxonomicSource resp.
- * PrimaryMediaSource which are always on top depending on the IdentifiableSource;
- * <br>
- * The last two are always "Other" followed by "Unknown"
- * @author pplitzner
- * @date Jan 6, 2017
- *
- */
- private class OriginalSourceTypeComparator implements Comparator<OriginalSourceType>{
-
- private OriginalSourceBase entity;
- public OriginalSourceTypeComparator(OriginalSourceBase entity) {
- this.entity = entity;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int compare(OriginalSourceType o1, OriginalSourceType o2) {
- if(o1==null){
- if(o2==null){
- return 0;
- }
- else{
- return -1;
- }
- }
- if(o2==null){
- return 1;
- }
- //both are either taxonomic or media
- else if(o1.equals(OriginalSourceType.PrimaryTaxonomicSource)
- && o2.equals(OriginalSourceType.PrimaryMediaSource)){
- if(entity.getType().equals(OriginalSourceType.PrimaryMediaSource)){
- return 1;
- }
- else{
- return -1;
- }
- }
- else if(o2.equals(OriginalSourceType.PrimaryTaxonomicSource)
- && o1.equals(OriginalSourceType.PrimaryMediaSource)){
- if(entity.getType().equals(OriginalSourceType.PrimaryMediaSource)){
- return -1;
- }
- else{
- return 1;
- }
- }
- //one is not taxonomic or media
- else if(o1.equals(OriginalSourceType.PrimaryTaxonomicSource)
- ||o1.equals(OriginalSourceType.PrimaryMediaSource)){
- return -1;
-
- }
- else if(o2.equals(OriginalSourceType.PrimaryTaxonomicSource)
- || o2.equals(OriginalSourceType.PrimaryMediaSource)){
- return 1;
- }
- //The last two are always "Other" followed by "Unknown"
- else if(o1.equals(OriginalSourceType.Other)){
- if(o2.equals(OriginalSourceType.Unknown)){
- return -11;
- }
- else{
- return 1;
- }
- }
- if(o2.equals(OriginalSourceType.Other)){
- return 1;
- }
- else{
- String message1 = o1.getKey();
- String message2 = o2.getKey();
- return message1.compareTo(message2);
- }
- }
-
- }
}