Revision 4f25e642
Added by Katja Luther over 5 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/ChecklistEditorE4.java | ||
---|---|---|
17 | 17 |
import java.util.List; |
18 | 18 |
import java.util.Map; |
19 | 19 |
import java.util.SortedSet; |
20 |
import java.util.UUID; |
|
20 | 21 |
|
21 | 22 |
import javax.annotation.PostConstruct; |
22 | 23 |
import javax.annotation.PreDestroy; |
... | ... | |
37 | 38 |
import org.eclipse.jface.viewers.TableViewerColumn; |
38 | 39 |
import org.eclipse.jface.viewers.TableViewerEditor; |
39 | 40 |
import org.eclipse.jface.viewers.TableViewerFocusCellManager; |
41 |
import org.eclipse.jface.wizard.WizardDialog; |
|
40 | 42 |
import org.eclipse.swt.SWT; |
41 | 43 |
import org.eclipse.swt.events.ModifyListener; |
42 | 44 |
import org.eclipse.swt.events.SelectionAdapter; |
... | ... | |
76 | 78 |
import eu.etaxonomy.taxeditor.model.IDirtyMarkable; |
77 | 79 |
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails; |
78 | 80 |
import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData; |
79 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
|
80 | 81 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
81 | 82 |
import eu.etaxonomy.taxeditor.preference.Resources; |
83 |
import eu.etaxonomy.taxeditor.preference.wizard.AvailableDistributionWizard; |
|
82 | 84 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
85 |
import eu.etaxonomy.taxeditor.store.StoreUtil; |
|
83 | 86 |
import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart; |
84 | 87 |
|
85 | 88 |
/** |
... | ... | |
135 | 138 |
|
136 | 139 |
private ChecklistLabelProvider labelProvider; |
137 | 140 |
//TODO: maybe it is better to use a hashMap for better handling of adding and removing terms?? |
138 |
private HashMap<String, DefinedTermBase> terms = null; |
|
139 |
private ToolItem toolItem; |
|
141 |
private Map<UUID, Integer> areaPosition= new HashMap(); |
|
142 |
|
|
143 |
private ToolItem toolItem; |
|
140 | 144 |
private ChecklistDropdownSelectionListenerE4 dropListener; |
141 | 145 |
private Text searchText; |
142 | 146 |
|
143 |
|
|
147 |
public Map<UUID, Integer> getAreaPosition() { |
|
148 |
return areaPosition; |
|
149 |
} |
|
144 | 150 |
/** |
145 | 151 |
* @return the selectedTaxonNodes |
146 | 152 |
*/ |
... | ... | |
190 | 196 |
|
191 | 197 |
|
192 | 198 |
labelProvider = new ChecklistLabelProvider(this.viewer); |
193 |
SortedSet<DefinedTermBase> termSet = labelProvider.getNamedAreas(false);
|
|
194 |
terms = new HashMap(); |
|
195 |
for (DefinedTermBase term : termSet){ |
|
196 |
terms.put(term.getTitleCache(), term);
|
|
197 |
} |
|
198 |
if (terms == null){ |
|
199 |
MessagingUtils.informationDialog(Messages.ChecklistEditor_NO_AREAS, Messages.ChecklistEditor_NO_AREAS_MESSAGE); |
|
200 |
this.dispose(); |
|
201 |
return; |
|
202 |
} |
|
199 |
// SortedSet<DefinedTermBase> termSet = labelProvider.getNamedAreas(true);
|
|
200 |
// terms = new HashMap();
|
|
201 |
// for (DefinedTermBase term : termSet){
|
|
202 |
// terms.put(term.getUuid(), term);
|
|
203 |
// }
|
|
204 |
// if (terms == null){
|
|
205 |
// MessagingUtils.informationDialog(Messages.ChecklistEditor_NO_AREAS, Messages.ChecklistEditor_NO_AREAS_MESSAGE);
|
|
206 |
// this.dispose();
|
|
207 |
// return;
|
|
208 |
// }
|
|
203 | 209 |
|
204 | 210 |
|
205 | 211 |
viewer.addFilter(filter); |
... | ... | |
267 | 273 |
*/ |
268 | 274 |
private void createToolbar(Composite parent) { |
269 | 275 |
ToolBar toolBar = new ToolBar(parent, SWT.NONE); |
270 |
toolItem = new ToolItem(toolBar, SWT.DROP_DOWN | SWT.BORDER); |
|
276 |
// toolItem = new ToolItem(toolBar, SWT.DROP_DOWN | SWT.BORDER); |
|
277 |
toolItem = new ToolItem(toolBar, SWT.BUTTON1); |
|
278 |
|
|
271 | 279 |
toolItem.setText(Messages.ChecklistEditor_DIST_STATUS); |
272 | 280 |
toolItem.setToolTipText(Messages.ChecklistEditor_DIST_STATUS_TOOLTIP); |
273 |
createToolbarItems(); |
|
274 |
toolItem.addSelectionListener(dropListener); |
|
281 |
//createToolbarItems(); |
|
282 |
// toolItem.addSelectionListener(dropListener); |
|
283 |
toolItem.addSelectionListener(new SelectionAdapter() { |
|
284 |
@Override |
|
285 |
public void widgetSelected(SelectionEvent event) { |
|
286 |
AvailableDistributionWizard availableDistributionWizard = new AvailableDistributionWizard(); |
|
287 |
WizardDialog dialog = new WizardDialog(StoreUtil.getShell(), |
|
288 |
availableDistributionWizard); |
|
289 |
|
|
290 |
int open = dialog.open(); |
|
291 |
if(open == 0){ |
|
292 |
reload(); |
|
293 |
} |
|
294 |
} |
|
295 |
}); |
|
275 | 296 |
toolBar.pack(); |
276 | 297 |
} |
277 | 298 |
|
... | ... | |
368 | 389 |
private Map<Integer, Boolean> restoreValuesForColumnWidth(List<String> titles, |
369 | 390 |
List<Integer> bounds) { |
370 | 391 |
Map<Integer, Boolean> restoreColumnWidth = new HashMap<Integer, Boolean>(); |
371 |
if (labelProvider.getNamedAreas(false) != null) {
|
|
392 |
if (labelProvider.getNamedAreas(true) != null) {
|
|
372 | 393 |
int columnIndex; |
373 | 394 |
if (PreferencesUtil.isShowRankInChecklistEditor()){ |
374 | 395 |
columnIndex = 2; |
... | ... | |
378 | 399 |
for (DefinedTermBase<DefinedTermBase> term : getLabelProvider().getNamedAreas(false)) { |
379 | 400 |
if(term != null){ |
380 | 401 |
restoreColumnWidth.put(columnIndex, PreferencesUtil.getPreferenceStore().getBoolean(term.getUuid().toString())); |
402 |
areaPosition.put(term.getUuid(), columnIndex); |
|
381 | 403 |
if (PreferencesUtil.isShowIdInVocabularyInChecklistEditor()){ |
382 | 404 |
if (term.getIdInVocabulary() != null){ |
383 | 405 |
titles.add(term.getIdInVocabulary()); |
... | ... | |
403 | 425 |
* @param colNumber |
404 | 426 |
* @return |
405 | 427 |
*/ |
406 |
private TableViewerColumn addTableViewerColumn(String title, int bound, final int colNumber) { |
|
428 |
private TableViewerColumn addTableViewerColumn(String title, int bound, final int colNumber, DefinedTermBase term) {
|
|
407 | 429 |
|
408 | 430 |
final TableViewerColumn viewerColumn = new TableViewerColumn(viewer, SWT.NONE); |
409 | 431 |
final TableColumn column = viewerColumn.getColumn(); |
410 | 432 |
column.setText(title); |
433 |
String[] UuidAndLable = new String[2]; |
|
434 |
UuidAndLable[0] = term.getUuid().toString(); |
|
435 |
UuidAndLable[1] = title; |
|
436 |
column.setData(UuidAndLable); |
|
411 | 437 |
column.setWidth(200); |
412 | 438 |
viewerColumn.setEditingSupport(new DistributionEditingSupportE4(viewer, this, colNumber)); |
413 | 439 |
column.setResizable(true); |
... | ... | |
533 | 559 |
// } |
534 | 560 |
SortedSet<DefinedTermBase> newTerms = labelProvider.getNamedAreas(true); |
535 | 561 |
//terms = newTerms; |
536 |
toolItem.removeSelectionListener(dropListener); |
|
537 |
// hideDistributionColumns(oldTerms); |
|
538 |
createToolbarItems(); |
|
539 |
toolItem.addSelectionListener(dropListener); |
|
562 |
// toolItem.removeSelectionListener(dropListener);
|
|
563 |
//// hideDistributionColumns(oldTerms);
|
|
564 |
// createToolbarItems();
|
|
565 |
// toolItem.addSelectionListener(dropListener);
|
|
540 | 566 |
|
541 | 567 |
//check which terms are deleted and which are new. |
542 | 568 |
TableColumn[] columns = viewer.getTable().getColumns() ; |
543 | 569 |
int index = 0; |
544 |
for (TableColumn column: columns){ |
|
545 |
if ((!PreferencesUtil.isShowRankInChecklistEditor() && index > 0) || (index > 1)) { |
|
570 |
|
|
571 |
for (TableColumn column: columns){ |
|
572 |
if ((!PreferencesUtil.isShowRankInChecklistEditor() && index > 0) || (index > 1)) { |
|
546 | 573 |
column.dispose(); |
547 | 574 |
} |
548 |
index++; |
|
549 |
} |
|
575 |
index++; |
|
576 |
} |
|
577 |
for (DefinedTermBase oldTerm:oldTerms){ |
|
578 |
boolean delete = true; |
|
579 |
for (DefinedTermBase term: newTerms){ |
|
580 |
if(oldTerm.getUuid().equals(term.getUuid())){ |
|
581 |
delete = false; |
|
582 |
break; |
|
583 |
} |
|
584 |
|
|
585 |
} |
|
586 |
if (delete){ |
|
587 |
// viewer.getTable().remove(areaPosition.get(oldTerm.getUuid())); |
|
588 |
areaPosition.remove(oldTerm.getUuid()); |
|
589 |
|
|
590 |
} |
|
591 |
} |
|
592 |
updateColumnIndex(); |
|
593 |
|
|
594 |
|
|
550 | 595 |
|
551 | 596 |
for (DefinedTermBase term:newTerms){ |
552 | 597 |
boolean isNew = true; |
553 |
for (DefinedTermBase oldTerm: oldTerms){ |
|
554 |
if(oldTerm.getTitleCache().equals(term.getTitleCache())){ |
|
555 |
isNew = false; |
|
556 |
break; |
|
557 |
} |
|
558 | 598 |
|
559 |
} |
|
560 |
if (isNew){ |
|
561 |
terms.put(term.getTitleCache(),term); |
|
599 |
Integer position = areaPosition.get(term.getUuid()); |
|
562 | 600 |
|
563 |
} |
|
564 | 601 |
String termLable = term.getTitleCache();; |
565 | 602 |
if (PreferencesUtil.isShowIdInVocabularyInChecklistEditor()){ |
566 | 603 |
if (term.getIdInVocabulary() != null){ |
567 | 604 |
termLable = term.getIdInVocabulary(); |
568 | 605 |
} |
569 | 606 |
} |
570 |
int count = viewer.getTable().getColumnCount(); |
|
571 |
TableViewerColumn column= addTableViewerColumn(termLable, 200, count); |
|
572 |
acitivateNewColumnInDropDownMenu(term); |
|
573 |
} |
|
574 |
for (DefinedTermBase oldTerm:oldTerms){ |
|
575 |
boolean delete = true; |
|
576 |
for (DefinedTermBase term: newTerms){ |
|
577 |
if(oldTerm.getTitleCache().equals(term.getTitleCache())){ |
|
578 |
delete = false; |
|
579 |
break; |
|
580 |
} |
|
581 | 607 |
|
608 |
if (position == null){ |
|
609 |
int count = viewer.getTable().getColumnCount(); |
|
610 |
TableViewerColumn column= addTableViewerColumn(termLable, 200, count, term); |
|
611 |
areaPosition.put(term.getUuid(), Integer.valueOf(count)); |
|
612 |
}else{ |
|
613 |
TableViewerColumn column= addTableViewerColumn(termLable, 200, position, term); |
|
582 | 614 |
} |
583 |
if (delete){ |
|
584 |
terms.remove(oldTerm); |
|
585 | 615 |
|
586 |
} |
|
587 |
} |
|
616 |
// acitivateNewColumnInDropDownMenu(term); |
|
617 |
} |
|
618 |
|
|
588 | 619 |
|
589 | 620 |
|
590 | 621 |
// for(DefinedTermBase term:terms.values()){ |
... | ... | |
613 | 644 |
viewer.refresh(); |
614 | 645 |
} |
615 | 646 |
|
616 |
private void acitivateNewColumnInDropDownMenu(DefinedTermBase term) { |
|
647 |
/** |
|
648 |
* |
|
649 |
*/ |
|
650 |
private void updateColumnIndex() { |
|
651 |
int columnIndex; |
|
652 |
if (PreferencesUtil.isShowRankInChecklistEditor()){ |
|
653 |
columnIndex = 2; |
|
654 |
} else{ |
|
655 |
columnIndex = 1; |
|
656 |
} |
|
657 |
for (UUID uuid:areaPosition.keySet()){ |
|
658 |
areaPosition.put(uuid, columnIndex); |
|
659 |
columnIndex++; |
|
660 |
} |
|
661 |
|
|
662 |
} |
|
663 |
private void acitivateNewColumnInDropDownMenu(DefinedTermBase term) { |
|
617 | 664 |
Menu menu = dropListener.getMenu(); |
618 | 665 |
MenuItem[] items = menu.getItems(); |
619 | 666 |
for(MenuItem item: items){ |
Also available in: Unified diff
ref #7063: add vocabulary selection for distribution editor and area selection in editor