TableViewerFocusCellManager focusCellManager = new TableViewerFocusCellManager(viewer, new FocusCellOwnerDrawHighlighter (viewer));
TableViewerEditor.create(viewer, focusCellManager, new ColumnViewerEditorActivationStrategy(viewer), TableViewerEditor.DEFAULT);
-
-// viewer.addSelectionChangedListener(new ISelectionChangedListener() {
-// @Override
-// public void selectionChanged(SelectionChangedEvent event) {
-// IStructuredSelection selection = viewer.getStructuredSelection();
-// Object firstElement = selection.getFirstElement();
-// // do something with it
-// }
-//
-//
-// });
-
-
-
labelProvider = new ChecklistLabelProvider(this);
- // SortedSet<DefinedTermBase> termSet = labelProvider.getNamedAreas(true);
-// terms = new HashMap();
-// for (DefinedTermBase term : termSet){
-// terms.put(term.getUuid(), term);
-// }
-// if (terms == null){
-// MessagingUtils.informationDialog(Messages.ChecklistEditor_NO_AREAS, Messages.ChecklistEditor_NO_AREAS_MESSAGE);
-// this.dispose();
-// return;
-// }
-
viewer.addFilter(filter);
createTable();
viewer.setContentProvider(new ChecklistContentProvider());
viewer.setLabelProvider(this.labelProvider);
-// selectionChangedListener = (event -> selService.setSelection(event.getSelection()));
-// viewer.addSelectionChangedListener(selectionChangedListener);
comparator = new ChecklistEditorComparator();
viewer.setComparator(comparator);
*/
private Text createSearchBar(Composite parent) {
-
-
-// FillLayout fillLayout = new FillLayout();
-//
-// fillLayout.type = SWT.VERTICAL;
-// parent.setLayoutData(fillLayout);
-// Label searchLabel = new Label(parent, SWT.NONE);
-// searchLabel.setText(Messages.ChecklistEditor_SEARCH);
-// GridData gridDataLabel = new GridData();
-// gridDataLabel.horizontalSpan =1;
-// searchLabel.setLayoutData(gridDataLabel);
final Text searchText = new Text(parent, SWT.BORDER | SWT.SEARCH | SWT.ICON_SEARCH | SWT.CANCEL);
GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
searchText.setText(TYPE_FILTER_TEXT);
searchText.setToolTipText(Messages.ChecklistEditor_SEARCH_TOOLTIP);
-
- // Composite buttons = new Composite(parent, SWT.NONE);
- //buttons.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL ));
Button button1 = new Button(parent, SWT.PUSH );
GridData gridData2 = new GridData();
gridData2.horizontalSpan = 1;
}
if (columnIndex == 1 && PreferencesUtil.isShowRankInChecklistEditor()) {
/** uncommented it for now because no rank editing is wanted **/
-// column.setEditingSupport(new RankEditingSupport(viewer, this));
+
}
if ((columnIndex == 1 && !PreferencesUtil.isShowRankInChecklistEditor()) || columnIndex >= 2 ) {
- //read PrefrenceStore to setWidth according to last saved state
-// if(restoreValuesForColumnWidth.get(columnIndex)){
- column.getColumn().setWidth(50);
-// }else{
-// column.getColumn().setWidth(0);
-// }
+ column.getColumn().setWidth(50);
column.setEditingSupport(new DistributionEditingSupportE4(viewer, this, columnIndex));
}
}
}
}
-// return restoreColumnWidth;
+
}
/**
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public void reload(){
- //create new Items for Dropdown menue
- Table table = viewer.getTable();
- table.setRedraw(false);
- Collection<DefinedTermBase> oldTerms = labelProvider.getNamedAreas(false);
-
-// if (PreferencesUtil.isShowIdInVocabularyInChecklistEditor()){
-//
-// } else{
-// terms = (SortedSet<DefinedTermBase>) labelProvider.getTermsOrderedByLabels(labelProvider.getNamedAreas(), CdmStore.getDefaultLanguage());
-// }
- SortedSet<DefinedTermBase> newTerms = labelProvider.getNamedAreas(true);
- //terms = newTerms;
-// toolItem.removeSelectionListener(dropListener);
-//// hideDistributionColumns(oldTerms);
-// createToolbarItems();
-// toolItem.addSelectionListener(dropListener);
-
- //check which terms are deleted and which are new.
- TableColumn[] columns = viewer.getTable().getColumns() ;
- int index = 0;
+ //create new Items for Dropdown menue
+ Table table = viewer.getTable();
+ table.setRedraw(false);
+ Collection<DefinedTermBase> oldTerms = labelProvider.getNamedAreas(false);
+
+ SortedSet<DefinedTermBase> newTerms = labelProvider.getNamedAreas(true);
+
+
+ //check which terms are deleted and which are new.
+ TableColumn[] columns = viewer.getTable().getColumns() ;
+ int index = 0;
for (TableColumn column: columns){
if ((!PreferencesUtil.isShowRankInChecklistEditor() && index > 0) || (index > 1)) {
}
index++;
}
- if (oldTerms != null){
- for (DefinedTermBase oldTerm:oldTerms){
- boolean delete = true;
- for (DefinedTermBase term: newTerms){
- if(oldTerm.getUuid().equals(term.getUuid())){
- delete = false;
- break;
- }
-
- }
- if (delete){
- // viewer.getTable().remove(areaPosition.get(oldTerm.getUuid()));
- areaPosition.remove(oldTerm.getUuid());
- }
- }
- updateColumnIndex();
+ areaPosition.clear();
+ int columnIndex;
+ if (PreferencesUtil.isShowRankInChecklistEditor()){
+ columnIndex = 2;
+ } else{
+ columnIndex = 1;
+ }
+ for (DefinedTermBase term:newTerms){
+ areaPosition.put(term.getUuid(), Integer.valueOf(columnIndex));
+ columnIndex++;
}
+ for (DefinedTermBase term: newTerms){
+ Representation rep = term.getPreferredRepresentation(CdmStore.getDefaultLanguage());
+
+ String termLable = rep.getAbbreviatedLabel();
+ if (termLable == null){
+ termLable = rep.getLabel();
+ }
+ if (PreferencesUtil.isShowIdInVocabularyInChecklistEditor()){
+ if (term.getIdInVocabulary() != null){
+ termLable = term.getIdInVocabulary();
+ }
+ }
+ TableViewerColumn column= addTableViewerColumn(termLable, 200, areaPosition.get(term.getUuid()), term);
+ System.err.println(column.getColumn().getText() + " index: " +areaPosition.get(term.getUuid()) );
- for (DefinedTermBase term:newTerms){
- boolean isNew = true;
-
- Integer position = areaPosition.get(term.getUuid());
- Representation rep = term.getPreferredRepresentation(CdmStore.getDefaultLanguage());
-
- String termLable = rep.getAbbreviatedLabel();
- if (termLable == null){
- termLable = rep.getLabel();
- }
- if (PreferencesUtil.isShowIdInVocabularyInChecklistEditor()){
- if (term.getIdInVocabulary() != null){
- termLable = term.getIdInVocabulary();
- }
- }
-
- if (position == null){
- int count = viewer.getTable().getColumnCount();
- TableViewerColumn column= addTableViewerColumn(termLable, 200, count, term);
- areaPosition.put(term.getUuid(), Integer.valueOf(count));
- }else{
- TableViewerColumn column= addTableViewerColumn(termLable, 200, position, term);
- }
-
-
- }
-
- viewer.setLabelProvider(labelProvider);
+ }
- table.setRedraw(true);
- viewer.refresh();
+ viewer.setLabelProvider(labelProvider);
+ table.setRedraw(true);
+ viewer.refresh();
}
/**