private void createTable() {
Table table = viewer.getTable();//new Table(parent, viewer.getTable().getStyle());
List<String> titles = new ArrayList<String>();
- Collections.addAll(titles, "Taxon", "Author", "Rank");
List<Integer> bounds = new ArrayList<Integer>();
- Collections.addAll(bounds, 300, 200, 200);
+ if (PreferencesUtil.isShowRankInChecklistEditor()){
+ Collections.addAll(titles, "Taxon", "Rank");
+ Collections.addAll(bounds, 300, 200);
+ } else{
+ Collections.addAll(titles, "Taxon");
+ Collections.addAll(bounds, 300);
+ }
+
+
Map<Integer, Boolean> restoreValuesForColumnWidth = restoreValuesForColumnWidth(titles, bounds);
createInitalDistributionColumns(table, titles, bounds, restoreValuesForColumnWidth);
table.setSortDirection(SWT.DOWN);
* @param restoreValuesForColumnWidth
*/
private void createInitalDistributionColumns(Table table,
- List<String> titles, List<Integer> bounds,
- Map<Integer, Boolean> restoreValuesForColumnWidth) {
+ List<String> titles, List<Integer> bounds, Map<Integer, Boolean> restoreValuesForColumnWidth) {
for (int columnIndex = 0; columnIndex < titles.size(); columnIndex++) {
TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
column.getColumn().setText(titles.get(columnIndex));
if (columnIndex == 0) {
table.setSortColumn(column.getColumn());
}
- if (columnIndex == 2) {
+ if (columnIndex == 1 && PreferencesUtil.isShowRankInChecklistEditor()) {
/** uncommented it for now because no rank editing is wanted **/
// column.setEditingSupport(new RankEditingSupport(viewer, this));
}
- if (columnIndex >= 3) {
+ if ((columnIndex == 1 && !PreferencesUtil.isShowRankInChecklistEditor()) || columnIndex >= 2 ) {
//read PrefrenceStore to setWidth according to last saved state
if(restoreValuesForColumnWidth.get(columnIndex)){
- column.getColumn().setWidth(100);
+ column.getColumn().setWidth(50);
}else{
- column.getColumn().setWidth(100);
+ column.getColumn().setWidth(50);
}
column.setEditingSupport(new DistributionEditingSupport(viewer, this, columnIndex));
}
List<Integer> bounds) {
Map<Integer, Boolean> restoreColumnWidth = new HashMap<Integer, Boolean>();
if (terms != null) {
- int columnIndex = 3;
+ int columnIndex;
+ if (PreferencesUtil.isShowRankInChecklistEditor()){
+ columnIndex = 2;
+ } else{
+ columnIndex = 1;
+ }
for (DefinedTermBase<DefinedTermBase> term : terms) {
if(term != null){
restoreColumnWidth.put(columnIndex, PreferencesUtil.getPreferenceStore().getBoolean(term.getUuid().toString()));
import eu.etaxonomy.cdm.api.service.IDescriptionService;
import eu.etaxonomy.cdm.api.service.ITermService;
+import eu.etaxonomy.cdm.common.CdmUtils;
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
import eu.etaxonomy.cdm.model.common.Language;
/** {@inheritDoc} */
@Override
public String getColumnText(Object element, int columnIndex) {
- descriptionService = CdmStore.getService(IDescriptionService.class);
+ // descriptionService = CdmStore.getService(IDescriptionService.class);
Taxon taxon = (Taxon) element;
//TODO load areas by this list
- List<TaxonDescription> listTaxonDescriptions = descriptionService.listTaxonDescriptions(taxon, null, null, null, null, null, DESC_INIT_STRATEGY);;
+ // List<TaxonDescription> listTaxonDescriptions = descriptionService.listTaxonDescriptions(taxon, null, null, null, null, null, DESC_INIT_STRATEGY);;
+ Set<TaxonDescription> listTaxonDescriptions = taxon.getDescriptions();
NonViralName<?> nonViralName = HibernateProxyHelper.deproxy(taxon.getName(), NonViralName.class);
switch (columnIndex) {
taxonName = (nonViralName != null) ? nonViralName.getNameCache() : null;
return (taxonName != null) ? taxonName : DEFAULT_ENTRY;
- case 1:
- String authorship = null;
- authorship = (nonViralName != null) ? nonViralName.getAuthorshipCache() : null;
- return (authorship != null) ? authorship : DEFAULT_ENTRY;
+ // case 1:
+// String authorship = null;
+// authorship = (nonViralName != null) ? nonViralName.getAuthorshipCache() : null;
+// return (authorship != null) ? authorship : DEFAULT_ENTRY;
// case 2:
// String ref = null;
// if (taxon.getName() != null) {
// ref = (nomenclaturalReference != null) ? nomenclaturalReference.getAbbrevTitleCache() : null;
// }
// return (ref != null) ? ref : DEFAULT_ENTRY;
- case 2:
- String rank = null;
- if (taxon.getName().getRank() != null) {
- rank = taxon.getName().getRank().toString();
+ case 1:
+ if (PreferencesUtil.isShowRankInChecklistEditor()){
+ String rank = null;
+
+ if (taxon.getName().getRank() != null) {
+ rank = taxon.getName().getRank().toString();
+ }
+ return (rank != null) ? rank : DEFAULT_ENTRY;
}
- return (rank != null) ? rank : DEFAULT_ENTRY;
}
- if(columnIndex >2){
+ if(columnIndex >2 || (!PreferencesUtil.isShowRankInChecklistEditor() && columnIndex > 1)){
for (TaxonDescription td : listTaxonDescriptions) {
for (DescriptionElementBase deb : td.getElements()) {
String area = null;
if (distribution.getArea() != null ){
if (PreferencesUtil.isShowIdInVocabularyInChecklistEditor()){
- area = distribution.getArea().getIdInVocabulary();
+ if (distribution.getArea().getIdInVocabulary() != null){
+ area = distribution.getArea().getIdInVocabulary();
+ } else{
+ area = distribution.getArea().getTitleCache();
+ }
}else{
area = distribution.getArea().getTitleCache();
}
if(viewer != null){
TableColumn column = viewer.getTable().getColumn(columnIndex);
if (area.equalsIgnoreCase(column.getText())) {
- return (distribution.getStatus().getTitleCache() != null)?distribution.getStatus().getTitleCache():DEFAULT_ENTRY;
+ if (PreferencesUtil.isShowIdInVocabularyInChecklistEditor()){
+ return (distribution.getStatus().getIdInVocabulary() != null)?distribution.getStatus().getIdInVocabulary():CdmUtils.Nz(distribution.getStatus().getTitleCache());
+ }else{
+ return (distribution.getStatus().getTitleCache() != null)?distribution.getStatus().getTitleCache():DEFAULT_ENTRY;
+ }
}
}
private SortedSet<DefinedTermBase> loadNamedAreas() {
IPreferenceStore preferenceStore = PreferencesUtil.getPreferenceStore();
String values = preferenceStore.getString(PreferencesUtil.DISTRIBUTION_AREA_OCCURENCE_STATUS);
+
if (values != null && values != "") {
String[] split = values.split(",");
List<String> listValue = Arrays.asList(split);
List<DefinedTermBase> termlist = new ArrayList<DefinedTermBase>();
- Set<UUID> uuidList = new HashSet<UUID>();
- UUID uuid;
+ Set<UUID> uuidList = new HashSet<UUID>();
+ UUID uuid;
for(String s : listValue){
uuid = UUID.fromString(s);
uuidList.add(uuid);
}
ITermService service = CdmStore.getService(ITermService.class);
termlist = service.find(uuidList);
-
- return getTermsOrderedByIdInVocabulary(termlist);
+ if (PreferencesUtil.isShowIdInVocabularyInChecklistEditor()){
+ return getTermsOrderedByIdInVocabulary(termlist);
+ } else {
+ return getTermsOrderedByLabels(termlist, CdmStore.getDefaultLanguage());
+ }
}
return null;
}
- public SortedSet<?> getTermsOrderedByLabels(List<DefinedTermBase<?>> listTerm,Language language){
+ public SortedSet<DefinedTermBase> getTermsOrderedByLabels(List<DefinedTermBase> listTerm,Language language){
TermLanguageComparator comp = new TermLanguageComparator();
comp.setCompareLanguage(language);
SortedSet result = new TreeSet(comp);
Taxon taxon = (Taxon) element;
Distribution distributionForColumn = getDistributionForColumn(taxon);
if (distributionForColumn != null) {
- return distributionForColumn.getStatus().getTitleCache();
+ if (PreferencesUtil.isShowIdInVocabularyInChecklistEditor()){
+ if (distributionForColumn.getStatus().getIdInVocabulary() != null){
+ return distributionForColumn.getStatus().getIdInVocabulary();
+ } else{
+ distributionForColumn.getStatus().getTitleCache();
+ }
+ } else{
+ return distributionForColumn.getStatus().getTitleCache();
+ }
}
// return PresenceAbsenceTerms
}
* @return
*/
private Distribution getDistributionForColumn(Taxon taxon) {
- List<TaxonDescription> listTaxonDescriptions = descriptionService.listTaxonDescriptions(taxon, null, null,
- null, null, null, DESC_INIT_STRATEGY);
+// List<TaxonDescription> listTaxonDescriptions = descriptionService.listTaxonDescriptions(taxon, null, null,
+// null, null, null, DESC_INIT_STRATEGY);
+ Set<TaxonDescription> listTaxonDescriptions = taxon.getDescriptions();
TableColumn column = viewer.getTable().getColumn(columnIndex);
for (TaxonDescription td : listTaxonDescriptions) {
for (DescriptionElementBase deb : td.getElements()) {
public void setSearchText(String s) {
// Search must be a substring of the existing value
if(s.contains("*")){
- s=s.replace("*", "");
+ s=s.replace("*", ".*");
}
- this.searchString = "(?i).*" + s + ".*";
+ this.searchString = ".*" + s + ".*";
}
@Override
return true;
}
//Author
- if (nonVirlaName.getAuthorshipCache() != null && nonVirlaName.getAuthorshipCache().matches(searchString)) {
- return true;
- }
- //Reference
- if(reference != null && reference.getAbbrevTitleCache().matches(searchString)){
- return true;
- }
- //Rank
- if (rank != null && rank.matches(searchString)) {
- return true;
- }
+// if (nonVirlaName.getAuthorshipCache() != null && nonVirlaName.getAuthorshipCache().matches(searchString)) {
+// return true;
+// }
+// //Reference
+// if(reference != null && reference.getAbbrevTitleCache().matches(searchString)){
+// return true;
+// }
+// //Rank
+// if (rank != null && rank.matches(searchString)) {
+// return true;
+// }
return false;
}
button_openFeatureTree.setText("Open Distribution Selection Wizard");
final Button showIdInVocabulary = new Button(child, SWT.CHECK);
- boolean isShowIdInVocabulary = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.CHECKLIST_ID_IN_VOCABULARY);
+ boolean isShowIdInVocabulary = PreferencesUtil.isShowIdInVocabularyInChecklistEditor();
showIdInVocabulary.setText("Show Id in Vocabulary instead of full title of the areas");
showIdInVocabulary.setSelection(isShowIdInVocabulary);
showIdInVocabulary.addSelectionListener(new SelectionAdapter(){
@Override
public void widgetSelected(SelectionEvent e) {
boolean isShowIdInVocabulary = showIdInVocabulary.getSelection();
- PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.CHECKLIST_ID_IN_VOCABULARY, isShowIdInVocabulary);
+ PreferencesUtil.setShowIdInVocabularyInChecklistEditor(isShowIdInVocabulary);
}
});
PreferencesUtil.recursiveSetEnabled(button_openFeatureTree, CdmStore.isActive());
+ boolean isShowRank = PreferencesUtil.isShowRankInChecklistEditor();
+ final Button activateRankButton = new Button(child, SWT.CHECK);
+ activateRankButton.setText("Show Rank in Checklist Editor");
+ activateRankButton.setSelection(isShowRank);
+ activateRankButton.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ boolean isShowRank = activateRankButton.getSelection();
+ PreferencesUtil.setShowRankInChecklistEditor(isEditorActivated);
+ }
+ });
+
if(isEditorActivated){
child.setEnabled(true);
public static final String DISTRIBUTION_AREA_OCCURENCE_STATUS_GRAYED = "eu.etaxonomy.taxeditor.checklist.distributionAreaStatusGrayed";
public static final String CHECKLIST_ID_IN_VOCABULARY = "eu.etaxonomy.taxeditor.checklist.checklistIdInVocabulary";
+ public static final String CHECKLIST_SHOW_RANK = "eu.etaxonomy.taxeditor.checklist.checklistShowRank";
public static final String SHOW_ADVANCED_MEDIA_SECTION = "eu.etaxonomy.taxeditor.media.showAdvancedMedia";
public static final String SHOW_SIMPLE_NAME_DETAILS_SECTION = "eu.etaxonomy.taxeditor.name.showSimpleName";
*/
public static final String P2_REPOSITORY_LIST = "eu.etaxonomy.taxeditor.p2.repositories";
+
+
}
getPreferenceStore().setValue(CHECKLIST_ID_IN_VOCABULARY, selection);
}
+ /**
+ * @return
+ */
+ public static boolean isShowRankInChecklistEditor() {
+ return getPreferenceStore().getBoolean(IPreferenceKeys.CHECKLIST_SHOW_RANK);
+ }
+ public static void setShowRankInChecklistEditor(boolean selection) {
+ getPreferenceStore().setValue(CHECKLIST_SHOW_RANK, selection);
+ }
}