2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.editor
.view
.checklist
.e4
;
12 import java
.util
.ArrayList
;
13 import java
.util
.Arrays
;
14 import java
.util
.Collections
;
15 import java
.util
.HashMap
;
16 import java
.util
.List
;
18 import java
.util
.SortedSet
;
20 import javax
.annotation
.PostConstruct
;
21 import javax
.annotation
.PreDestroy
;
22 import javax
.inject
.Inject
;
24 import org
.apache
.log4j
.Logger
;
25 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
26 import org
.eclipse
.core
.runtime
.IStatus
;
27 import org
.eclipse
.core
.runtime
.Status
;
28 import org
.eclipse
.core
.runtime
.jobs
.Job
;
29 import org
.eclipse
.e4
.ui
.di
.Focus
;
30 import org
.eclipse
.e4
.ui
.di
.Persist
;
31 import org
.eclipse
.e4
.ui
.model
.application
.ui
.MDirtyable
;
32 import org
.eclipse
.e4
.ui
.model
.application
.ui
.basic
.MPart
;
33 import org
.eclipse
.e4
.ui
.workbench
.modeling
.ESelectionService
;
34 import org
.eclipse
.jface
.viewers
.ISelectionChangedListener
;
35 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
36 import org
.eclipse
.jface
.viewers
.SelectionChangedEvent
;
37 import org
.eclipse
.jface
.viewers
.StructuredViewer
;
38 import org
.eclipse
.jface
.viewers
.TableViewer
;
39 import org
.eclipse
.jface
.viewers
.TableViewerColumn
;
40 import org
.eclipse
.swt
.SWT
;
41 import org
.eclipse
.swt
.events
.ModifyListener
;
42 import org
.eclipse
.swt
.events
.SelectionAdapter
;
43 import org
.eclipse
.swt
.events
.SelectionEvent
;
44 import org
.eclipse
.swt
.layout
.GridData
;
45 import org
.eclipse
.swt
.layout
.GridLayout
;
46 import org
.eclipse
.swt
.widgets
.Composite
;
47 import org
.eclipse
.swt
.widgets
.Display
;
48 import org
.eclipse
.swt
.widgets
.Label
;
49 import org
.eclipse
.swt
.widgets
.Menu
;
50 import org
.eclipse
.swt
.widgets
.MenuItem
;
51 import org
.eclipse
.swt
.widgets
.Table
;
52 import org
.eclipse
.swt
.widgets
.TableColumn
;
53 import org
.eclipse
.swt
.widgets
.Text
;
54 import org
.eclipse
.swt
.widgets
.ToolBar
;
55 import org
.eclipse
.swt
.widgets
.ToolItem
;
56 import org
.eclipse
.ui
.IEditorInput
;
57 import org
.eclipse
.ui
.IMemento
;
58 import org
.eclipse
.ui
.progress
.IWorkbenchSiteProgressService
;
60 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
61 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
62 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonNodeService
;
63 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonService
;
64 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
65 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTermBase
;
66 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
67 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
68 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
69 import eu
.etaxonomy
.cdm
.persistence
.hibernate
.CdmDataChangeMap
;
70 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
71 import eu
.etaxonomy
.taxeditor
.editor
.SimpleSelectionProvider
;
72 import eu
.etaxonomy
.taxeditor
.editor
.internal
.TaxeditorEditorPlugin
;
73 import eu
.etaxonomy
.taxeditor
.editor
.l10n
.Messages
;
74 import eu
.etaxonomy
.taxeditor
.editor
.view
.checklist
.ChecklistContentProvider
;
75 import eu
.etaxonomy
.taxeditor
.editor
.view
.checklist
.ChecklistEditorComparator
;
76 import eu
.etaxonomy
.taxeditor
.editor
.view
.checklist
.ChecklistEditorInput
;
77 import eu
.etaxonomy
.taxeditor
.editor
.view
.checklist
.ChecklistLabelProvider
;
78 import eu
.etaxonomy
.taxeditor
.editor
.view
.checklist
.filter
.ChecklistEditorFilter
;
79 import eu
.etaxonomy
.taxeditor
.editor
.view
.checklist
.listener
.ChecklistFocusListener
;
80 import eu
.etaxonomy
.taxeditor
.editor
.view
.checklist
.listener
.ChecklistModifyListener
;
81 import eu
.etaxonomy
.taxeditor
.model
.IContextListener
;
82 import eu
.etaxonomy
.taxeditor
.model
.IDirtyMarkable
;
83 import eu
.etaxonomy
.taxeditor
.model
.IPartContentHasDetails
;
84 import eu
.etaxonomy
.taxeditor
.model
.IPartContentHasFactualData
;
85 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
86 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
87 import eu
.etaxonomy
.taxeditor
.preference
.Resources
;
88 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
95 public class ChecklistEditorE4
implements IPartContentHasFactualData
, IConversationEnabled
,
96 IContextListener
, IDirtyMarkable
, IPartContentHasDetails
{
98 private static final String DISTRIBUTION_EDITOR
= "Distribution Editor";
99 private static final String LOADING_TAXA
= Messages
.ChecklistEditor_LOAD_TAXA
;
100 private static final String UNKNOWN
= Messages
.ChecklistEditor_UNKNOWN
;
101 private static final String ELEMENT_COUNT
= Messages
.ChecklistEditor_ELEMENT_COUNT
;
102 public static final String TYPE_FILTER_TEXT
= "type filter text"; //$NON-NLS-1$
104 private static final Logger logger
= Logger
.getLogger(ChecklistEditorE4
.class);
107 // private class ChecklistJob extends Job {
109 // private List<TaxonNode> taxonNodes;
114 // public ChecklistJob(String title, List<TaxonNode> listTaxonNodes) {
116 // this.taxonNodes = listTaxonNodes;
124 // * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.
125 // * IProgressMonitor)
128 // public IStatus run(final IProgressMonitor monitor) {
130 // logger.debug("Begin of eclipse core runtime Job to Retrieve datasources"); //$NON-NLS-1$
131 // monitor.beginTask(Messages.ChecklistEditor_RETRIEVE_NODES, taxonNodes.size() + 1);
133 // final List<Taxon> taxonList = new ArrayList<Taxon>();
135 // for (TaxonNode taxonNode : taxonNodes) {
136 // HibernateProxyHelper hh = new HibernateProxyHelper();
137 // Taxon taxon = hh.deproxy(taxonNode.getTaxon(), Taxon.class);
138 // taxonList.add(taxon);
141 // Display.getDefault().asyncExec(new Runnable() {
144 // public void run() {
145 // viewer.setInput(taxonList);
148 // monitor.worked(1);
152 // taxonNodes = null;
154 // return Status.OK_STATUS;
160 * <code>ID="eu.etaxonomy.taxeditor.store.datasource"{trunked}</code>
162 public static String ID
= "eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditor"; //$NON-NLS-1$
164 private TableViewer viewer
;
166 private String partNameCache
;
168 //FIXME E4 migrate/delete ater full migration
170 private IWorkbenchSiteProgressService service
;
172 private ITaxonNodeService taxonNodeService
;
174 private ChecklistEditorComparator comparator
;
176 private ChecklistEditorInput checklistEditorInput
;
178 private SimpleSelectionProvider simpleSelectionProvider
;
180 private ConversationHolder conversation
;
182 private Integer countNodes
;
184 private List
<TaxonNode
> selectedTaxonNodes
;
187 private MPart thisPart
;
190 private MDirtyable dirty
;
193 private ESelectionService selService
;
195 private ISelectionChangedListener selectionChangedListener
;
197 private ChecklistEditorFilter filter
;
199 private Menu headerMenu
;
201 private Label statusLabel
;
203 // private final ICdmEntitySession cdmEntitySession;
205 private ChecklistLabelProvider labelProvider
;
207 private SortedSet
<DefinedTermBase
> terms
= null;
208 private ToolItem toolItem
;
209 private ChecklistDropdownSelectionListenerE4 dropListener
;
212 * @return the selectedTaxonNodes
214 public List
<TaxonNode
> getSelectedTaxonNodes() {
215 return selectedTaxonNodes
;
219 * @param selectedTaxonNodes
220 * the selectedTaxonNodes to set
222 public void setSelectedTaxonNodes(List
<TaxonNode
> selectedTaxonNodes
) {
223 this.selectedTaxonNodes
= selectedTaxonNodes
;
227 public ChecklistEditorE4() {
232 public void createPartControl(Composite parent
) {
233 if (!CdmStore
.isActive()){
236 taxonNodeService
= CdmStore
.getService(ITaxonNodeService
.class);
237 viewer
= new TableViewer(parent
, SWT
.MULTI
| SWT
.H_SCROLL
| SWT
.V_SCROLL
| SWT
.FULL_SELECTION
);
239 // viewer.addSelectionChangedListener(new ISelectionChangedListener() {
241 // public void selectionChanged(SelectionChangedEvent event) {
242 // IStructuredSelection selection = viewer.getStructuredSelection();
243 // Object firstElement = selection.getFirstElement();
244 // // do something with it
252 labelProvider
= new ChecklistLabelProvider(this.viewer
);
254 terms
= labelProvider
.getNamedAreas();
256 MessagingUtils
.informationDialog(Messages
.ChecklistEditor_NO_AREAS
, Messages
.ChecklistEditor_NO_AREAS_MESSAGE
);
260 filter
= new ChecklistEditorFilter();
261 createTopComposite(parent
);
267 private void createTopComposite(Composite parent
) {
268 GridLayout gridLayout
= new GridLayout(3, false);
269 gridLayout
.marginWidth
= 0;
270 gridLayout
.marginHeight
= 0;
271 parent
.setLayout(gridLayout
);
273 final Text searchText
= createSearchBar(parent
);
274 createToolbar(parent
);
276 // getSite().setSelectionProvider(viewer);
278 final ModifyListener modifyListener
= new ChecklistModifyListener(viewer
, filter
, searchText
);
280 searchText
.addFocusListener(new ChecklistFocusListener(searchText
, modifyListener
));
281 searchText
.addModifyListener(modifyListener
);
282 createGridDataForViewerLayout();
284 viewer
.addFilter(filter
);
287 viewer
.setContentProvider(new ChecklistContentProvider());
288 viewer
.setLabelProvider(this.labelProvider
);
289 comparator
= new ChecklistEditorComparator();
290 viewer
.setComparator(comparator
);
292 createStatusBar(parent
);
295 private void createGridDataForViewerLayout() {
296 GridData gridData
= new GridData();
297 gridData
.verticalAlignment
= GridData
.FILL
;
298 gridData
.horizontalSpan
= 3;
299 gridData
.grabExcessHorizontalSpace
= true;
300 gridData
.grabExcessVerticalSpace
= true;
301 gridData
.horizontalAlignment
= GridData
.FILL
;
302 viewer
.getControl().setLayoutData(gridData
);
309 private Text
createSearchBar(Composite parent
) {
310 Label searchLabel
= new Label(parent
, SWT
.NONE
);
311 searchLabel
.setText(Messages
.ChecklistEditor_SEARCH
);
312 final Text searchText
= new Text(parent
, SWT
.BORDER
| SWT
.SEARCH
| SWT
.ICON_SEARCH
| SWT
.CANCEL
);
313 searchText
.setLayoutData(new GridData(GridData
.GRAB_HORIZONTAL
| GridData
.HORIZONTAL_ALIGN_FILL
));
314 searchText
.setForeground(EditorUtil
.getColor(Resources
.SEARCH_VIEW_FOREGROUND
));
315 searchText
.setText(TYPE_FILTER_TEXT
);
322 private void createToolbar(Composite parent
) {
323 ToolBar toolBar
= new ToolBar(parent
, SWT
.NONE
);
324 toolItem
= new ToolItem(toolBar
, SWT
.DROP_DOWN
| SWT
.BORDER
);
325 toolItem
.setText(Messages
.ChecklistEditor_DIST_STATUS
);
326 toolItem
.setToolTipText(Messages
.ChecklistEditor_DIST_STATUS_TOOLTIP
);
327 createToolbarItems();
328 toolItem
.addSelectionListener(dropListener
);
332 private void createToolbarItems() {
333 dropListener
= new ChecklistDropdownSelectionListenerE4(toolItem
, this, terms
);
335 for (DefinedTermBase
<DefinedTermBase
> term
: terms
) {
337 dropListener
.add(term
);
342 private void createStatusBar(Composite composite
) {
343 GridData gridData
= new GridData();
344 gridData
.horizontalSpan
= 3;
345 gridData
.grabExcessHorizontalSpace
= true;
346 gridData
.horizontalAlignment
= GridData
.FILL
;
348 statusLabel
= new Label(composite
, SWT
.LEFT
);
349 statusLabel
.setText(ELEMENT_COUNT
+ (countNodes
!= null ? countNodes
: UNKNOWN
));
350 statusLabel
.setLayoutData(gridData
);
353 private void createTable() {
354 Table table
= viewer
.getTable();//new Table(parent, viewer.getTable().getStyle());
355 List
<String
> titles
= new ArrayList
<String
>();
356 List
<Integer
> bounds
= new ArrayList
<Integer
>();
357 if (PreferencesUtil
.isShowRankInChecklistEditor()){
358 Collections
.addAll(titles
, Messages
.ChecklistEditor_TAXON
, Messages
.ChecklistEditor_RANK
);
359 Collections
.addAll(bounds
, 300, 200);
361 Collections
.addAll(titles
, Messages
.ChecklistEditor_TAXON
);
362 Collections
.addAll(bounds
, 300);
366 Map
<Integer
, Boolean
> restoreValuesForColumnWidth
= restoreValuesForColumnWidth(titles
, bounds
);
367 createInitalDistributionColumns(table
, titles
, bounds
, restoreValuesForColumnWidth
);
368 table
.setSortDirection(SWT
.DOWN
);
369 table
.setHeaderVisible(true);
370 table
.setLinesVisible(true);
373 * This method creates initially the distribution columns for a table. It should only be called for creation.<br>
376 *<b>Notice:</b> If you want to add additional columns later please use <b>addTableViewerColumn()</b>
381 * @param restoreValuesForColumnWidth
383 private void createInitalDistributionColumns(Table table
,
384 List
<String
> titles
, List
<Integer
> bounds
, Map
<Integer
, Boolean
> restoreValuesForColumnWidth
) {
385 for (int columnIndex
= 0; columnIndex
< titles
.size(); columnIndex
++) {
386 TableViewerColumn column
= new TableViewerColumn(viewer
, SWT
.NONE
);
387 column
.getColumn().setText(titles
.get(columnIndex
));
388 column
.getColumn().setWidth(bounds
.get(columnIndex
));
389 column
.getColumn().setResizable(true);
390 column
.getColumn().setMoveable(true);
391 column
.getColumn().addSelectionListener(getSelectionAdapter(column
.getColumn(), columnIndex
));
392 if (columnIndex
== 0) {
393 table
.setSortColumn(column
.getColumn());
395 if (columnIndex
== 1 && PreferencesUtil
.isShowRankInChecklistEditor()) {
396 /** uncommented it for now because no rank editing is wanted **/
397 // column.setEditingSupport(new RankEditingSupport(viewer, this));
399 if ((columnIndex
== 1 && !PreferencesUtil
.isShowRankInChecklistEditor()) || columnIndex
>= 2 ) {
400 //read PrefrenceStore to setWidth according to last saved state
401 if(restoreValuesForColumnWidth
.get(columnIndex
)){
402 column
.getColumn().setWidth(50);
404 column
.getColumn().setWidth(50);
406 column
.setEditingSupport(new DistributionEditingSupportE4(viewer
, this, columnIndex
));
412 * This methods loads the last opened distribution columns for the table viewer from the prefrence store.<br>
414 * <b>Notice:</b> It adds also the TitleCache to the titles list for the header of each column.<p>
418 * @return Map<Integer, Boolean>
420 private Map
<Integer
, Boolean
> restoreValuesForColumnWidth(List
<String
> titles
,
421 List
<Integer
> bounds
) {
422 Map
<Integer
, Boolean
> restoreColumnWidth
= new HashMap
<Integer
, Boolean
>();
425 if (PreferencesUtil
.isShowRankInChecklistEditor()){
430 for (DefinedTermBase
<DefinedTermBase
> term
: terms
) {
432 restoreColumnWidth
.put(columnIndex
, PreferencesUtil
.getPreferenceStore().getBoolean(term
.getUuid().toString()));
433 if (PreferencesUtil
.isShowIdInVocabularyInChecklistEditor()){
434 if (term
.getIdInVocabulary() != null){
435 titles
.add(term
.getIdInVocabulary());
437 titles
.add(term
.getTitleCache());
440 titles
.add(term
.getTitleCache());
447 return restoreColumnWidth
;
451 * This method adds new DistributionColumns to an existing table.
458 private TableViewerColumn
addTableViewerColumn(String title
, int bound
, final int colNumber
) {
459 final TableViewerColumn viewerColumn
= new TableViewerColumn(viewer
, SWT
.NONE
);
460 final TableColumn column
= viewerColumn
.getColumn();
461 column
.setText(title
);
462 column
.setWidth(200);
463 viewerColumn
.setEditingSupport(new DistributionEditingSupportE4(viewer
, this, colNumber
));
464 column
.setResizable(true);
465 column
.setMoveable(true);
473 * pull data from database and set input for view
476 private void loadDataInput() {
477 Classification classification
= checklistEditorInput
.getClassification();
478 TaxonNode taxonNode
= checklistEditorInput
.getTaxonNode();
479 if (classification
!= null && taxonNode
== null) {
480 countNodes
= taxonNodeService
.countAllNodesForClassification(classification
);
481 // statusLabel.setText(ELEMENT_COUNT + (countNodes != null ? countNodes : UNKNOWN));
482 // This should not kill the view nor the editor if something goes
484 // TODO: don't load the whole taxonNode Object but rather a small
485 // and simple Solution
486 // FIXME: May be don't open classification which are greater than
488 selectedTaxonNodes
= taxonNodeService
.listAllNodesForClassification(classification
, 0, countNodes
);
489 countNodes
= selectedTaxonNodes
.size();
490 statusLabel
.setText(ELEMENT_COUNT
+ (countNodes
!= null ? countNodes
: UNKNOWN
));
491 viewer
.setInput(checklistEditorInput
.getTaxa());
492 // Job checkListJob = new ChecklistJob(LOADING_TAXA, selectedTaxonNodes);
493 // checkListJob.schedule(Job.LONG);
496 if (taxonNode
!= null) {
497 selectedTaxonNodes
= taxonNodeService
.loadChildNodesOfTaxonNode(taxonNode
, NODE_INIT_STRATEGY
, true, null);
498 countNodes
= selectedTaxonNodes
.size();
499 viewer
.setInput(checklistEditorInput
.getTaxa());
500 statusLabel
.setText(ELEMENT_COUNT
+ (countNodes
!= null ? countNodes
: UNKNOWN
));
501 // Job checkListJob = new ChecklistJob(LOADING_TAXA, selectedTaxonNodes);
502 // checkListJob.schedule(Job.LONG);
503 // getService().schedule(new ChecklistJob(LOADING_TAXA, selectedTaxonNodes), Job.LONG);
509 public void dispose() {
510 // if(checklistEditorInput!=null){
511 // this.checklistEditorInput.getConversation().unregisterForDataStoreChanges(this.checklistEditorInput);
514 if(conversation
!=null){
515 conversation
.unregisterForDataStoreChanges(this);
516 conversation
.unbind();
518 //conversation.close();
524 public void setFocus() {
525 if(viewer
!=null && viewer
.getControl()!=null && !viewer
.getControl().isDisposed())
526 viewer
.getControl().setFocus();
533 // * @see org.eclipse.ui.part.WorkbenchPart#showBusy(boolean)
535 // /** {@inheritDoc} */
537 // public void showBusy(boolean busy) {
538 // super.showBusy(busy);
539 // // viewer.getTable().setEnabled(!busy);
541 // partNameCache = getPartName();
542 // setPartName(String.format(Messages.ChecklistEditor_LOAD_CNT_TAXA, countNodes));
544 // if (partNameCache != null) {
545 // setPartName(partNameCache);
552 * Getter for the field <code>viewer</code>.
555 * @return a {@link org.eclipse.jface.viewers.StructuredViewer} object.
557 public StructuredViewer
getViewer() {
561 public void refresh() {
566 * This method should only be called for adding new Distribution columns and reloading the table.<br>
567 * It will hide the old distribution column and load the newly added columns.<br>
569 * <b>Notice:</b> for data update please use <b>refresh()</b>
572 @SuppressWarnings({ "unchecked", "rawtypes" })
573 public void reload(){
574 //create new Items for Dropdown menue
575 Table table
= viewer
.getTable();
576 table
.setRedraw(false);
577 SortedSet
<DefinedTermBase
> oldTerms
= terms
;
579 // if (PreferencesUtil.isShowIdInVocabularyInChecklistEditor()){
582 // terms = (SortedSet<DefinedTermBase>) labelProvider.getTermsOrderedByLabels(labelProvider.getNamedAreas(), CdmStore.getDefaultLanguage());
584 SortedSet
<DefinedTermBase
> newTerms
= labelProvider
.getNamedAreas();
585 toolItem
.removeSelectionListener(dropListener
);
586 hideDistributionColumns(oldTerms
);
587 createToolbarItems();
588 toolItem
.addSelectionListener(dropListener
);
589 for(DefinedTermBase term
:newTerms
){
590 int count
= viewer
.getTable().getColumnCount();
591 addTableViewerColumn(term
.getTitleCache(), 200, count
);
592 acitivateNewColumnInDropDownMenu(term
);
594 viewer
.setLabelProvider(labelProvider
);
595 // getService().schedule(new ChecklistJob(LOADING_TAXA, selectedTaxonNodes), Job.LONG);
596 table
.setRedraw(true);
600 private void acitivateNewColumnInDropDownMenu(DefinedTermBase term
) {
601 Menu menu
= dropListener
.getMenu();
602 MenuItem
[] items
= menu
.getItems();
603 for(MenuItem item
: items
){
604 if(item
.getText().equalsIgnoreCase(term
.getTitleCache())){
605 item
.setSelection(true);
606 PreferencesUtil
.getPreferenceStore().setValue(term
.getUuid().toString(), true);
611 private void hideDistributionColumns(SortedSet
<DefinedTermBase
> oldTerms
) {
612 TableColumn
[] columns
= viewer
.getTable().getColumns();
613 for(int i
=4; i
<columns
.length
; i
++){
615 columns
[i
].dispose();
616 Menu menu
= dropListener
.getMenu();
617 int itemCount
= menu
.getItemCount();
618 MenuItem item
= menu
.getItem(i
-3);
619 item
.setSelection(false);
621 if(oldTerms
!= null){
622 for(DefinedTermBase term
: oldTerms
){
623 PreferencesUtil
.getPreferenceStore().setValue(term
.getUuid().toString(), false);
630 * Getter for the field <code>service</code>.
633 * @return the service
635 public IWorkbenchSiteProgressService
getService() {
636 return TaxeditorEditorPlugin
.getDefault().getWorkbench().getService(IWorkbenchSiteProgressService
.class);
639 private SelectionAdapter
getSelectionAdapter(final TableColumn column
, final int index
) {
640 SelectionAdapter selectionAdapter
= new SelectionAdapter() {
642 public void widgetSelected(SelectionEvent e
) {
643 comparator
.setColumn(index
);
644 int dir
= viewer
.getTable().getSortDirection();
645 if (viewer
.getTable().getSortColumn() == column
) {
646 dir
= dir
== SWT
.UP ? SWT
.DOWN
: SWT
.UP
;
650 viewer
.getTable().setSortDirection(dir
);
651 viewer
.getTable().setSortColumn(column
);
655 return selectionAdapter
;
659 public void doSave(IProgressMonitor monitor
) {
661 monitor
.beginTask(Messages
.ChecklistEditor_SAVE_EDITOR
, 1);
662 if (!conversation
.isBound()) {
665 this.checklistEditorInput
.merge();
666 //this.checklistEditorInput.merge();
667 conversation
.commit(true);
676 public void init(IEditorInput input
) {
677 if (input
instanceof ChecklistEditorInput
) {
678 checklistEditorInput
= (ChecklistEditorInput
) input
;
679 thisPart
.setLabel(DISTRIBUTION_EDITOR
+": " + checklistEditorInput
.getName());
680 conversation
= checklistEditorInput
.getConversation();
681 conversation
.registerForDataStoreChanges(this);
683 simpleSelectionProvider
= new SimpleSelectionProvider();
685 //propagate selection
686 selectionChangedListener
= (event
-> selService
.setSelection(event
));
687 viewer
.addSelectionChangedListener(selectionChangedListener
);
698 * eu.etaxonomy.taxeditor.model.IContextListener#contextAboutToStop(org.
699 * eclipse.ui.IMemento, org.eclipse.core.runtime.IProgressMonitor)
703 public void contextAboutToStop(IMemento memento
, IProgressMonitor monitor
) {
711 * eu.etaxonomy.taxeditor.model.IContextListener#contextStop(org.eclipse
712 * .ui.IMemento, org.eclipse.core.runtime.IProgressMonitor)
715 public void contextStop(IMemento memento
, IProgressMonitor monitor
) {
716 // IStructuredSelection sel = (IStructuredSelection) this.viewer.getSelection();
717 // if (sel.isEmpty()) {
720 // memento = memento.createChild("tree-selections");
721 // Iterator iter = sel.iterator();
722 // while (iter.hasNext()) {
723 // String nodeName = (String) iter.next();
724 // memento.createChild("selected-nodes", nodeName);
732 * eu.etaxonomy.taxeditor.model.IContextListener#contextStart(org.eclipse
733 * .ui.IMemento, org.eclipse.core.runtime.IProgressMonitor)
736 public void contextStart(IMemento memento
, IProgressMonitor monitor
) {
744 * eu.etaxonomy.taxeditor.model.IContextListener#contextRefresh(org.eclipse
745 * .core.runtime.IProgressMonitor)
748 public void contextRefresh(IProgressMonitor monitor
) {
755 * eu.etaxonomy.taxeditor.model.IContextListener#workbenchShutdown(org.eclipse
756 * .ui.IMemento, org.eclipse.core.runtime.IProgressMonitor)
759 public void workbenchShutdown(IMemento memento
, IProgressMonitor monitor
) {
760 conversation
.clear();
761 conversation
.close();
765 private static final List
<String
> NODE_INIT_STRATEGY
= Arrays
.asList(new String
[] { "descriptions", //$NON-NLS-1$
766 "descriptions.*", "description.state", "feature", "feature.*", "childNodes", "childNodes.taxon", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
767 "childNodes.taxon.name", "taxonNodes", "taxonNodes.*", "taxonNodes.taxon.*", "taxon.*", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
768 "taxon.descriptions", "taxon.sec", "taxon.name.*", "terms", "name.*", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
769 "name.rank.representations", "name.status.type.representations", "stateData.$" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
775 * eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider#changed(
779 public void changed(Object element
) {
780 if (element
!= null) {
781 viewer
.update(element
, null);
787 * @see eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider#forceDirty()
790 public void forceDirty() {
794 public void setDirty(boolean dirty
) {
795 this.dirty
.setDirty(dirty
);
801 * @see org.eclipse.ui.forms.editor.FormEditor#isDirty()
803 public boolean isDirty() {
804 return dirty
.isDirty();
808 * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getCdmEntitySession()
813 // * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
816 // public <T extends CdmBase> Collection<T> getRootEntities() {
817 // // TODO Auto-generated method stub
822 // * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getPropertyPathsMap()
825 // public Map<Object, List<String>> getPropertyPathsMap() {
826 // // TODO Auto-generated method stub
831 * @return the labelProvider
833 public ChecklistLabelProvider
getLabelProvider() {
834 return labelProvider
;
838 * @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
841 public void update(CdmDataChangeMap arg0
) {
842 // TODO Auto-generated method stub
847 * @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
850 public ConversationHolder
getConversationHolder() {