Revision fecf5fd5
Added by Katja Luther over 5 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/ChecklistEditorE4.java | ||
---|---|---|
197 | 197 |
TableViewerFocusCellManager focusCellManager = new TableViewerFocusCellManager(viewer, new FocusCellOwnerDrawHighlighter (viewer)); |
198 | 198 |
TableViewerEditor.create(viewer, focusCellManager, new ColumnViewerEditorActivationStrategy(viewer), TableViewerEditor.DEFAULT); |
199 | 199 |
|
200 |
|
|
201 |
// viewer.addSelectionChangedListener(new ISelectionChangedListener() { |
|
202 |
// @Override |
|
203 |
// public void selectionChanged(SelectionChangedEvent event) { |
|
204 |
// IStructuredSelection selection = viewer.getStructuredSelection(); |
|
205 |
// Object firstElement = selection.getFirstElement(); |
|
206 |
// // do something with it |
|
207 |
// } |
|
208 |
// |
|
209 |
// |
|
210 |
// }); |
|
211 |
|
|
212 |
|
|
213 |
|
|
214 | 200 |
labelProvider = new ChecklistLabelProvider(this); |
215 |
// SortedSet<DefinedTermBase> termSet = labelProvider.getNamedAreas(true); |
|
216 |
// terms = new HashMap(); |
|
217 |
// for (DefinedTermBase term : termSet){ |
|
218 |
// terms.put(term.getUuid(), term); |
|
219 |
// } |
|
220 |
// if (terms == null){ |
|
221 |
// MessagingUtils.informationDialog(Messages.ChecklistEditor_NO_AREAS, Messages.ChecklistEditor_NO_AREAS_MESSAGE); |
|
222 |
// this.dispose(); |
|
223 |
// return; |
|
224 |
// } |
|
225 |
|
|
226 | 201 |
|
227 | 202 |
viewer.addFilter(filter); |
228 | 203 |
createTable(); |
229 | 204 |
|
230 | 205 |
viewer.setContentProvider(new ChecklistContentProvider()); |
231 | 206 |
viewer.setLabelProvider(this.labelProvider); |
232 |
// selectionChangedListener = (event -> selService.setSelection(event.getSelection())); |
|
233 |
// viewer.addSelectionChangedListener(selectionChangedListener); |
|
234 | 207 |
|
235 | 208 |
comparator = new ChecklistEditorComparator(); |
236 | 209 |
viewer.setComparator(comparator); |
... | ... | |
290 | 263 |
*/ |
291 | 264 |
private Text createSearchBar(Composite parent) { |
292 | 265 |
|
293 |
|
|
294 |
|
|
295 |
// FillLayout fillLayout = new FillLayout(); |
|
296 |
// |
|
297 |
// fillLayout.type = SWT.VERTICAL; |
|
298 |
// parent.setLayoutData(fillLayout); |
|
299 |
// Label searchLabel = new Label(parent, SWT.NONE); |
|
300 |
// searchLabel.setText(Messages.ChecklistEditor_SEARCH); |
|
301 |
// GridData gridDataLabel = new GridData(); |
|
302 |
// gridDataLabel.horizontalSpan =1; |
|
303 |
// searchLabel.setLayoutData(gridDataLabel); |
|
304 | 266 |
final Text searchText = new Text(parent, SWT.BORDER | SWT.SEARCH | SWT.ICON_SEARCH | SWT.CANCEL); |
305 | 267 |
GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL); |
306 | 268 |
|
... | ... | |
309 | 271 |
searchText.setText(TYPE_FILTER_TEXT); |
310 | 272 |
searchText.setToolTipText(Messages.ChecklistEditor_SEARCH_TOOLTIP); |
311 | 273 |
|
312 |
|
|
313 |
// Composite buttons = new Composite(parent, SWT.NONE); |
|
314 |
//buttons.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL )); |
|
315 | 274 |
Button button1 = new Button(parent, SWT.PUSH ); |
316 | 275 |
GridData gridData2 = new GridData(); |
317 | 276 |
gridData2.horizontalSpan = 1; |
... | ... | |
479 | 438 |
} |
480 | 439 |
if (columnIndex == 1 && PreferencesUtil.isShowRankInChecklistEditor()) { |
481 | 440 |
/** uncommented it for now because no rank editing is wanted **/ |
482 |
// column.setEditingSupport(new RankEditingSupport(viewer, this)); |
|
441 |
|
|
483 | 442 |
} |
484 | 443 |
if ((columnIndex == 1 && !PreferencesUtil.isShowRankInChecklistEditor()) || columnIndex >= 2 ) { |
485 |
//read PrefrenceStore to setWidth according to last saved state |
|
486 |
// if(restoreValuesForColumnWidth.get(columnIndex)){ |
|
487 |
column.getColumn().setWidth(50); |
|
488 |
// }else{ |
|
489 |
// column.getColumn().setWidth(0); |
|
490 |
// } |
|
444 |
column.getColumn().setWidth(50); |
|
491 | 445 |
column.setEditingSupport(new DistributionEditingSupportE4(viewer, this, columnIndex)); |
492 | 446 |
|
493 | 447 |
} |
... | ... | |
548 | 502 |
} |
549 | 503 |
} |
550 | 504 |
} |
551 |
// return restoreColumnWidth; |
|
505 |
|
|
552 | 506 |
} |
553 | 507 |
|
554 | 508 |
/** |
... | ... | |
681 | 635 |
*/ |
682 | 636 |
@SuppressWarnings({ "unchecked", "rawtypes" }) |
683 | 637 |
public void reload(){ |
684 |
//create new Items for Dropdown menue |
|
685 |
Table table = viewer.getTable(); |
|
686 |
table.setRedraw(false); |
|
687 |
Collection<DefinedTermBase> oldTerms = labelProvider.getNamedAreas(false); |
|
688 |
|
|
689 |
// if (PreferencesUtil.isShowIdInVocabularyInChecklistEditor()){ |
|
690 |
// |
|
691 |
// } else{ |
|
692 |
// terms = (SortedSet<DefinedTermBase>) labelProvider.getTermsOrderedByLabels(labelProvider.getNamedAreas(), CdmStore.getDefaultLanguage()); |
|
693 |
// } |
|
694 |
SortedSet<DefinedTermBase> newTerms = labelProvider.getNamedAreas(true); |
|
695 |
//terms = newTerms; |
|
696 |
// toolItem.removeSelectionListener(dropListener); |
|
697 |
//// hideDistributionColumns(oldTerms); |
|
698 |
// createToolbarItems(); |
|
699 |
// toolItem.addSelectionListener(dropListener); |
|
700 |
|
|
701 |
//check which terms are deleted and which are new. |
|
702 |
TableColumn[] columns = viewer.getTable().getColumns() ; |
|
703 |
int index = 0; |
|
638 |
//create new Items for Dropdown menue |
|
639 |
Table table = viewer.getTable(); |
|
640 |
table.setRedraw(false); |
|
641 |
Collection<DefinedTermBase> oldTerms = labelProvider.getNamedAreas(false); |
|
642 |
|
|
643 |
SortedSet<DefinedTermBase> newTerms = labelProvider.getNamedAreas(true); |
|
644 |
|
|
645 |
|
|
646 |
//check which terms are deleted and which are new. |
|
647 |
TableColumn[] columns = viewer.getTable().getColumns() ; |
|
648 |
int index = 0; |
|
704 | 649 |
|
705 | 650 |
for (TableColumn column: columns){ |
706 | 651 |
if ((!PreferencesUtil.isShowRankInChecklistEditor() && index > 0) || (index > 1)) { |
... | ... | |
708 | 653 |
} |
709 | 654 |
index++; |
710 | 655 |
} |
711 |
if (oldTerms != null){ |
|
712 |
for (DefinedTermBase oldTerm:oldTerms){ |
|
713 |
boolean delete = true; |
|
714 |
for (DefinedTermBase term: newTerms){ |
|
715 |
if(oldTerm.getUuid().equals(term.getUuid())){ |
|
716 |
delete = false; |
|
717 |
break; |
|
718 |
} |
|
719 |
|
|
720 |
} |
|
721 |
if (delete){ |
|
722 |
// viewer.getTable().remove(areaPosition.get(oldTerm.getUuid())); |
|
723 |
areaPosition.remove(oldTerm.getUuid()); |
|
724 | 656 |
|
725 |
} |
|
726 |
} |
|
727 |
updateColumnIndex(); |
|
657 |
areaPosition.clear(); |
|
658 |
int columnIndex; |
|
659 |
if (PreferencesUtil.isShowRankInChecklistEditor()){ |
|
660 |
columnIndex = 2; |
|
661 |
} else{ |
|
662 |
columnIndex = 1; |
|
663 |
} |
|
664 |
for (DefinedTermBase term:newTerms){ |
|
665 |
areaPosition.put(term.getUuid(), Integer.valueOf(columnIndex)); |
|
666 |
columnIndex++; |
|
728 | 667 |
} |
729 | 668 |
|
669 |
for (DefinedTermBase term: newTerms){ |
|
670 |
Representation rep = term.getPreferredRepresentation(CdmStore.getDefaultLanguage()); |
|
671 |
|
|
672 |
String termLable = rep.getAbbreviatedLabel(); |
|
673 |
if (termLable == null){ |
|
674 |
termLable = rep.getLabel(); |
|
675 |
} |
|
676 |
if (PreferencesUtil.isShowIdInVocabularyInChecklistEditor()){ |
|
677 |
if (term.getIdInVocabulary() != null){ |
|
678 |
termLable = term.getIdInVocabulary(); |
|
679 |
} |
|
680 |
} |
|
681 |
TableViewerColumn column= addTableViewerColumn(termLable, 200, areaPosition.get(term.getUuid()), term); |
|
682 |
System.err.println(column.getColumn().getText() + " index: " +areaPosition.get(term.getUuid()) ); |
|
730 | 683 |
|
731 |
for (DefinedTermBase term:newTerms){ |
|
732 |
boolean isNew = true; |
|
733 |
|
|
734 |
Integer position = areaPosition.get(term.getUuid()); |
|
735 |
Representation rep = term.getPreferredRepresentation(CdmStore.getDefaultLanguage()); |
|
736 |
|
|
737 |
String termLable = rep.getAbbreviatedLabel(); |
|
738 |
if (termLable == null){ |
|
739 |
termLable = rep.getLabel(); |
|
740 |
} |
|
741 |
if (PreferencesUtil.isShowIdInVocabularyInChecklistEditor()){ |
|
742 |
if (term.getIdInVocabulary() != null){ |
|
743 |
termLable = term.getIdInVocabulary(); |
|
744 |
} |
|
745 |
} |
|
746 |
|
|
747 |
if (position == null){ |
|
748 |
int count = viewer.getTable().getColumnCount(); |
|
749 |
TableViewerColumn column= addTableViewerColumn(termLable, 200, count, term); |
|
750 |
areaPosition.put(term.getUuid(), Integer.valueOf(count)); |
|
751 |
}else{ |
|
752 |
TableViewerColumn column= addTableViewerColumn(termLable, 200, position, term); |
|
753 |
} |
|
754 |
|
|
755 |
|
|
756 |
} |
|
757 |
|
|
758 |
viewer.setLabelProvider(labelProvider); |
|
684 |
} |
|
759 | 685 |
|
760 |
table.setRedraw(true); |
|
761 |
viewer.refresh(); |
|
686 |
viewer.setLabelProvider(labelProvider); |
|
687 |
table.setRedraw(true); |
|
688 |
viewer.refresh(); |
|
762 | 689 |
} |
763 | 690 |
|
764 | 691 |
/** |
Also available in: Unified diff
ref #7911: fix wrong order index of columns in distribution editor when changing areas