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
;
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 org
.apache
.log4j
.Logger
;
21 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
22 import org
.eclipse
.core
.runtime
.IStatus
;
23 import org
.eclipse
.core
.runtime
.Status
;
24 import org
.eclipse
.core
.runtime
.jobs
.Job
;
25 import org
.eclipse
.jface
.viewers
.ISelection
;
26 import org
.eclipse
.jface
.viewers
.StructuredViewer
;
27 import org
.eclipse
.jface
.viewers
.TableViewer
;
28 import org
.eclipse
.jface
.viewers
.TableViewerColumn
;
29 import org
.eclipse
.swt
.SWT
;
30 import org
.eclipse
.swt
.events
.ModifyListener
;
31 import org
.eclipse
.swt
.events
.SelectionAdapter
;
32 import org
.eclipse
.swt
.events
.SelectionEvent
;
33 import org
.eclipse
.swt
.layout
.GridData
;
34 import org
.eclipse
.swt
.layout
.GridLayout
;
35 import org
.eclipse
.swt
.widgets
.Composite
;
36 import org
.eclipse
.swt
.widgets
.Display
;
37 import org
.eclipse
.swt
.widgets
.Label
;
38 import org
.eclipse
.swt
.widgets
.Menu
;
39 import org
.eclipse
.swt
.widgets
.MenuItem
;
40 import org
.eclipse
.swt
.widgets
.Table
;
41 import org
.eclipse
.swt
.widgets
.TableColumn
;
42 import org
.eclipse
.swt
.widgets
.Text
;
43 import org
.eclipse
.swt
.widgets
.ToolBar
;
44 import org
.eclipse
.swt
.widgets
.ToolItem
;
45 import org
.eclipse
.ui
.IEditorInput
;
46 import org
.eclipse
.ui
.IEditorSite
;
47 import org
.eclipse
.ui
.IMemento
;
48 import org
.eclipse
.ui
.ISelectionListener
;
49 import org
.eclipse
.ui
.ISelectionService
;
50 import org
.eclipse
.ui
.IWorkbenchPart
;
51 import org
.eclipse
.ui
.PartInitException
;
52 import org
.eclipse
.ui
.part
.EditorPart
;
53 import org
.eclipse
.ui
.progress
.IWorkbenchSiteProgressService
;
55 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
56 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
57 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonNodeService
;
58 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
59 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTermBase
;
60 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
61 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
62 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
63 import eu
.etaxonomy
.cdm
.persistence
.hibernate
.CdmDataChangeMap
;
64 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
65 import eu
.etaxonomy
.taxeditor
.editor
.SimpleSelectionProvider
;
66 import eu
.etaxonomy
.taxeditor
.editor
.l10n
.Messages
;
67 import eu
.etaxonomy
.taxeditor
.editor
.view
.checklist
.edit
.DistributionEditingSupport
;
68 import eu
.etaxonomy
.taxeditor
.editor
.view
.checklist
.filter
.ChecklistEditorFilter
;
69 import eu
.etaxonomy
.taxeditor
.editor
.view
.checklist
.listener
.ChecklistDropdownSelectionListener
;
70 import eu
.etaxonomy
.taxeditor
.editor
.view
.checklist
.listener
.ChecklistFocusListener
;
71 import eu
.etaxonomy
.taxeditor
.editor
.view
.checklist
.listener
.ChecklistModifyListener
;
72 import eu
.etaxonomy
.taxeditor
.model
.IContextListener
;
73 import eu
.etaxonomy
.taxeditor
.model
.IDirtyMarkable
;
74 import eu
.etaxonomy
.taxeditor
.model
.IPartContentHasDetails
;
75 import eu
.etaxonomy
.taxeditor
.model
.IPartContentHasFactualData
;
76 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
77 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
78 import eu
.etaxonomy
.taxeditor
.preference
.Resources
;
79 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
83 * ChecklistViewPart class.
90 public class ChecklistEditor
extends EditorPart
implements ISelectionListener
, IPartContentHasFactualData
, IConversationEnabled
,
91 IContextListener
, IDirtyMarkable
, IPartContentHasDetails
{
93 private static final String LOADING_TAXA
= Messages
.ChecklistEditor_LOAD_TAXA
;
94 private static final String UNKNOWN
= Messages
.ChecklistEditor_UNKNOWN
;
95 private static final String ELEMENT_COUNT
= Messages
.ChecklistEditor_ELEMENT_COUNT
;
96 public static final String TYPE_FILTER_TEXT
= "type filter text"; //$NON-NLS-1$
98 private static final Logger logger
= Logger
.getLogger(ChecklistEditor
.class);
101 private class ChecklistJob
extends Job
{
103 private List
<TaxonNode
> taxonNodes
;
108 public ChecklistJob(String title
, List
<TaxonNode
> listTaxonNodes
) {
110 this.taxonNodes
= listTaxonNodes
;
118 * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.
122 public IStatus
run(final IProgressMonitor monitor
) {
124 logger
.debug("Begin of eclipse core runtime Job to Retrieve datasources"); //$NON-NLS-1$
125 monitor
.beginTask(Messages
.ChecklistEditor_RETRIEVE_NODES
, taxonNodes
.size() + 1);
127 final List
<Taxon
> taxonList
= new ArrayList
<Taxon
>();
129 for (TaxonNode taxonNode
: taxonNodes
) {
130 HibernateProxyHelper hh
= new HibernateProxyHelper();
131 Taxon taxon
= hh
.deproxy(taxonNode
.getTaxon(), Taxon
.class);
132 taxonList
.add(taxon
);
135 Display
.getDefault().asyncExec(new Runnable() {
139 viewer
.setInput(taxonList
);
148 return Status
.OK_STATUS
;
154 * <code>ID="eu.etaxonomy.taxeditor.store.datasource"{trunked}</code>
156 public static String ID
= "eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditor"; //$NON-NLS-1$
158 private TableViewer viewer
;
160 private String partNameCache
;
162 private IWorkbenchSiteProgressService service
;
164 private ITaxonNodeService taxonNodeService
;
166 private ChecklistEditorComparator comparator
;
168 private ChecklistEditorInput checklistEditorInput
;
170 private SimpleSelectionProvider simpleSelectionProvider
;
172 private ISelectionService selectionService
;
174 private ConversationHolder conversation
;
176 private Integer countNodes
;
178 private List
<TaxonNode
> selectedTaxonNodes
;
180 private boolean dirty
;
182 private ChecklistEditorFilter filter
;
184 private Menu headerMenu
;
186 private Label statusLabel
;
188 // private ICdmEntitySession cdmEntitySession;
190 private ChecklistLabelProvider labelProvider
;
192 private SortedSet
<DefinedTermBase
> terms
= null;
193 private ToolItem toolItem
;
194 private ChecklistDropdownSelectionListener dropListener
;
197 * @return the selectedTaxonNodes
199 public List
<TaxonNode
> getSelectedTaxonNodes() {
200 return selectedTaxonNodes
;
204 * @param selectedTaxonNodes
205 * the selectedTaxonNodes to set
207 public void setSelectedTaxonNodes(List
<TaxonNode
> selectedTaxonNodes
) {
208 this.selectedTaxonNodes
= selectedTaxonNodes
;
213 * Constructor for CdmDataSourceViewPart.
216 public ChecklistEditor() {
217 //cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
223 public void createPartControl(Composite parent
) {
224 service
= getSite().getAdapter(IWorkbenchSiteProgressService
.class);
225 taxonNodeService
= CdmStore
.getService(ITaxonNodeService
.class);
226 selectionService
= getSite().getWorkbenchWindow().getSelectionService();
227 selectionService
.addSelectionListener(this);
228 viewer
= new TableViewer(parent
, SWT
.MULTI
| SWT
.H_SCROLL
| SWT
.V_SCROLL
| SWT
.FULL_SELECTION
);
230 // viewer.addSelectionChangedListener(new ISelectionChangedListener() {
232 // public void selectionChanged(SelectionChangedEvent event) {
233 // IStructuredSelection selection = viewer.getStructuredSelection();
234 // Object firstElement = selection.getFirstElement();
235 // // do something with it
240 labelProvider
= new ChecklistLabelProvider(this.viewer
);
242 terms
= labelProvider
.getNamedAreas(false);
244 MessagingUtils
.informationDialog(Messages
.ChecklistEditor_NO_AREAS
, Messages
.ChecklistEditor_NO_AREAS_MESSAGE
);
248 filter
= new ChecklistEditorFilter();
249 createTopComposite(parent
);
256 private void createTopComposite(Composite parent
) {
257 GridLayout gridLayout
= new GridLayout(3, false);
258 gridLayout
.marginWidth
= 0;
259 gridLayout
.marginHeight
= 0;
260 parent
.setLayout(gridLayout
);
262 final Text searchText
= createSearchBar(parent
);
263 createToolbar(parent
);
265 // getSite().setSelectionProvider(viewer);
267 final ModifyListener modifyListener
= new ChecklistModifyListener(viewer
, filter
, searchText
);
269 searchText
.addFocusListener(new ChecklistFocusListener(searchText
, modifyListener
));
270 searchText
.addModifyListener(modifyListener
);
271 createGridDataForViewerLayout();
273 viewer
.addFilter(filter
);
276 viewer
.setContentProvider(new ChecklistContentProvider());
277 viewer
.setLabelProvider(this.labelProvider
);
278 comparator
= new ChecklistEditorComparator();
279 viewer
.setComparator(comparator
);
281 createStatusBar(parent
);
284 private void createGridDataForViewerLayout() {
285 GridData gridData
= new GridData();
286 gridData
.verticalAlignment
= GridData
.FILL
;
287 gridData
.horizontalSpan
= 3;
288 gridData
.grabExcessHorizontalSpace
= true;
289 gridData
.grabExcessVerticalSpace
= true;
290 gridData
.horizontalAlignment
= GridData
.FILL
;
291 viewer
.getControl().setLayoutData(gridData
);
298 private Text
createSearchBar(Composite parent
) {
299 Label searchLabel
= new Label(parent
, SWT
.NONE
);
300 searchLabel
.setText(Messages
.ChecklistEditor_SEARCH
);
301 final Text searchText
= new Text(parent
, SWT
.BORDER
| SWT
.SEARCH
| SWT
.ICON_SEARCH
| SWT
.CANCEL
);
302 searchText
.setLayoutData(new GridData(GridData
.GRAB_HORIZONTAL
| GridData
.HORIZONTAL_ALIGN_FILL
));
303 searchText
.setForeground(EditorUtil
.getColor(Resources
.SEARCH_VIEW_FOREGROUND
));
304 searchText
.setText(TYPE_FILTER_TEXT
);
311 private void createToolbar(Composite parent
) {
312 ToolBar toolBar
= new ToolBar(parent
, SWT
.NONE
);
313 toolItem
= new ToolItem(toolBar
, SWT
.DROP_DOWN
| SWT
.BORDER
);
314 toolItem
.setText(Messages
.ChecklistEditor_DIST_STATUS
);
315 toolItem
.setToolTipText(Messages
.ChecklistEditor_DIST_STATUS_TOOLTIP
);
316 createToolbarItems();
317 toolItem
.addSelectionListener(dropListener
);
321 private void createToolbarItems() {
322 dropListener
= new ChecklistDropdownSelectionListener(toolItem
, this, terms
);
324 for (DefinedTermBase
<DefinedTermBase
> term
: terms
) {
326 dropListener
.add(term
);
331 private void createStatusBar(Composite composite
) {
332 GridData gridData
= new GridData();
333 gridData
.horizontalSpan
= 3;
334 gridData
.grabExcessHorizontalSpace
= true;
335 gridData
.horizontalAlignment
= GridData
.FILL
;
337 statusLabel
= new Label(composite
, SWT
.LEFT
);
338 statusLabel
.setText(ELEMENT_COUNT
+ (countNodes
!= null ? countNodes
: UNKNOWN
));
339 statusLabel
.setLayoutData(gridData
);
342 private void createTable() {
343 Table table
= viewer
.getTable();//new Table(parent, viewer.getTable().getStyle());
344 List
<String
> titles
= new ArrayList
<String
>();
345 List
<Integer
> bounds
= new ArrayList
<Integer
>();
346 if (PreferencesUtil
.isShowRankInChecklistEditor()){
347 Collections
.addAll(titles
, Messages
.ChecklistEditor_TAXON
, Messages
.ChecklistEditor_RANK
);
348 Collections
.addAll(bounds
, 300, 200);
350 Collections
.addAll(titles
, Messages
.ChecklistEditor_TAXON
);
351 Collections
.addAll(bounds
, 300);
355 Map
<Integer
, Boolean
> restoreValuesForColumnWidth
= restoreValuesForColumnWidth(titles
, bounds
);
356 createInitalDistributionColumns(table
, titles
, bounds
, restoreValuesForColumnWidth
);
357 table
.setSortDirection(SWT
.DOWN
);
358 table
.setHeaderVisible(true);
359 table
.setLinesVisible(true);
362 * This method creates initially the distribution columns for a table. It should only be called for creation.<br>
365 *<b>Notice:</b> If you want to add additional columns later please use <b>addTableViewerColumn()</b>
370 * @param restoreValuesForColumnWidth
372 private void createInitalDistributionColumns(Table table
,
373 List
<String
> titles
, List
<Integer
> bounds
, Map
<Integer
, Boolean
> restoreValuesForColumnWidth
) {
374 for (int columnIndex
= 0; columnIndex
< titles
.size(); columnIndex
++) {
375 TableViewerColumn column
= new TableViewerColumn(viewer
, SWT
.NONE
);
376 column
.getColumn().setText(titles
.get(columnIndex
));
377 column
.getColumn().setWidth(bounds
.get(columnIndex
));
378 column
.getColumn().setResizable(true);
379 column
.getColumn().setMoveable(true);
380 column
.getColumn().addSelectionListener(getSelectionAdapter(column
.getColumn(), columnIndex
));
381 if (columnIndex
== 0) {
382 table
.setSortColumn(column
.getColumn());
384 if (columnIndex
== 1 && PreferencesUtil
.isShowRankInChecklistEditor()) {
385 /** uncommented it for now because no rank editing is wanted **/
386 // column.setEditingSupport(new RankEditingSupport(viewer, this));
388 if ((columnIndex
== 1 && !PreferencesUtil
.isShowRankInChecklistEditor()) || columnIndex
>= 2 ) {
389 //read PrefrenceStore to setWidth according to last saved state
390 if(restoreValuesForColumnWidth
.get(columnIndex
)){
391 column
.getColumn().setWidth(50);
393 column
.getColumn().setWidth(50);
395 column
.setEditingSupport(new DistributionEditingSupport(viewer
, this, columnIndex
));
401 * This methods loads the last opened distribution columns for the table viewer from the prefrence store.<br>
403 * <b>Notice:</b> It adds also the TitleCache to the titles list for the header of each column.<p>
407 * @return Map<Integer, Boolean>
409 private Map
<Integer
, Boolean
> restoreValuesForColumnWidth(List
<String
> titles
,
410 List
<Integer
> bounds
) {
411 Map
<Integer
, Boolean
> restoreColumnWidth
= new HashMap
<Integer
, Boolean
>();
414 if (PreferencesUtil
.isShowRankInChecklistEditor()){
419 for (DefinedTermBase
<DefinedTermBase
> term
: terms
) {
421 restoreColumnWidth
.put(columnIndex
, PreferencesUtil
.getPreferenceStore().getBoolean(term
.getUuid().toString()));
422 if (PreferencesUtil
.isShowIdInVocabularyInChecklistEditor()){
423 if (term
.getIdInVocabulary() != null){
424 titles
.add(term
.getIdInVocabulary());
426 titles
.add(term
.getTitleCache());
429 titles
.add(term
.getTitleCache());
436 return restoreColumnWidth
;
440 * This method adds new DistributionColumns to an existing table.
447 private TableViewerColumn
addTableViewerColumn(String title
, int bound
, final int colNumber
) {
448 final TableViewerColumn viewerColumn
= new TableViewerColumn(viewer
, SWT
.NONE
);
449 final TableColumn column
= viewerColumn
.getColumn();
450 column
.setText(title
);
451 column
.setWidth(200);
452 viewerColumn
.setEditingSupport(new DistributionEditingSupport(viewer
, this, colNumber
));
453 column
.setResizable(true);
454 column
.setMoveable(true);
462 * pull data from database and set input for view
465 private void loadDataInput() {
466 Classification classification
= checklistEditorInput
.getClassification();
467 TaxonNode taxonNode
= checklistEditorInput
.getTaxonNode();
468 if (classification
!= null && taxonNode
== null) {
469 countNodes
= taxonNodeService
.countAllNodesForClassification(classification
);
470 // statusLabel.setText(ELEMENT_COUNT + (countNodes != null ? countNodes : UNKNOWN));
471 // This should not kill the view nor the editor if something goes
473 // TODO: don't load the whole taxonNode Object but rather a small
474 // and simple Solution
475 // FIXME: May be don't open classification which are greater than
477 selectedTaxonNodes
= taxonNodeService
.listAllNodesForClassification(classification
, 0, countNodes
);
478 countNodes
= selectedTaxonNodes
.size();
479 statusLabel
.setText(ELEMENT_COUNT
+ (countNodes
!= null ? countNodes
: UNKNOWN
));
480 getService().schedule(new ChecklistJob(LOADING_TAXA
, selectedTaxonNodes
), Job
.LONG
);
482 if (taxonNode
!= null) {
483 selectedTaxonNodes
= taxonNodeService
.loadChildNodesOfTaxonNode(taxonNode
, NODE_INIT_STRATEGY
, true, null);
484 getService().schedule(new ChecklistJob(LOADING_TAXA
, selectedTaxonNodes
), Job
.LONG
);
485 countNodes
= selectedTaxonNodes
.size();
486 statusLabel
.setText(ELEMENT_COUNT
+ (countNodes
!= null ? countNodes
: UNKNOWN
));
492 public void dispose() {
493 // this.checklistEditorInput.dispose();
496 conversation
.unregisterForDataStoreChanges(this);
497 conversation
.unbind();
499 //conversation.close();
505 public void setFocus() {
507 viewer
.getControl().setFocus();
513 * @see org.eclipse.ui.part.WorkbenchPart#showBusy(boolean)
517 public void showBusy(boolean busy
) {
518 super.showBusy(busy
);
519 // viewer.getTable().setEnabled(!busy);
521 partNameCache
= getPartName();
522 setPartName(String
.format(Messages
.ChecklistEditor_LOAD_CNT_TAXA
, countNodes
));
524 if (partNameCache
!= null) {
525 setPartName(partNameCache
);
532 * Getter for the field <code>viewer</code>.
535 * @return a {@link org.eclipse.jface.viewers.StructuredViewer} object.
537 public StructuredViewer
getViewer() {
541 public void refresh() {
546 * This method should only be called for adding new Distribution columns and reloading the table.<br>
547 * It will hide the old distribution column and load the newly added columns.<br>
549 * <b>Notice:</b> for data update please use <b>refresh()</b>
552 @SuppressWarnings({ "unchecked", "rawtypes" })
553 public void reload(){
554 //create new Items for Dropdown menue
555 Table table
= viewer
.getTable();
556 table
.setRedraw(false);
557 SortedSet
<DefinedTermBase
> oldTerms
= terms
;
559 // if (PreferencesUtil.isShowIdInVocabularyInChecklistEditor()){
562 // terms = (SortedSet<DefinedTermBase>) labelProvider.getTermsOrderedByLabels(labelProvider.getNamedAreas(), CdmStore.getDefaultLanguage());
564 SortedSet
<DefinedTermBase
> newTerms
= labelProvider
.getNamedAreas(true);
565 toolItem
.removeSelectionListener(dropListener
);
566 hideDistributionColumns(oldTerms
);
567 createToolbarItems();
568 toolItem
.addSelectionListener(dropListener
);
569 for(DefinedTermBase term
:newTerms
){
570 int count
= viewer
.getTable().getColumnCount();
571 addTableViewerColumn(term
.getTitleCache(), 200, count
);
572 acitivateNewColumnInDropDownMenu(term
);
574 viewer
.setLabelProvider(labelProvider
);
575 getService().schedule(new ChecklistJob(LOADING_TAXA
, selectedTaxonNodes
), Job
.LONG
);
576 table
.setRedraw(true);
580 private void acitivateNewColumnInDropDownMenu(DefinedTermBase term
) {
581 Menu menu
= dropListener
.getMenu();
582 MenuItem
[] items
= menu
.getItems();
583 for(MenuItem item
: items
){
584 if(item
.getText().equalsIgnoreCase(term
.getTitleCache())){
585 item
.setSelection(true);
586 PreferencesUtil
.getPreferenceStore().setValue(term
.getUuid().toString(), true);
591 private void hideDistributionColumns(SortedSet
<DefinedTermBase
> oldTerms
) {
592 TableColumn
[] columns
= viewer
.getTable().getColumns();
593 for(int i
=4; i
<columns
.length
; i
++){
595 columns
[i
].dispose();
596 Menu menu
= dropListener
.getMenu();
597 int itemCount
= menu
.getItemCount();
598 MenuItem item
= menu
.getItem(i
-3);
599 item
.setSelection(false);
601 if(oldTerms
!= null){
602 for(DefinedTermBase term
: oldTerms
){
603 PreferencesUtil
.getPreferenceStore().setValue(term
.getUuid().toString(), false);
610 * Getter for the field <code>service</code>.
613 * @return the service
615 public IWorkbenchSiteProgressService
getService() {
619 private SelectionAdapter
getSelectionAdapter(final TableColumn column
, final int index
) {
620 SelectionAdapter selectionAdapter
= new SelectionAdapter() {
622 public void widgetSelected(SelectionEvent e
) {
623 comparator
.setColumn(index
);
624 int dir
= viewer
.getTable().getSortDirection();
625 if (viewer
.getTable().getSortColumn() == column
) {
626 dir
= dir
== SWT
.UP ? SWT
.DOWN
: SWT
.UP
;
630 viewer
.getTable().setSortDirection(dir
);
631 viewer
.getTable().setSortColumn(column
);
635 return selectionAdapter
;
639 public void doSave(IProgressMonitor monitor
) {
641 monitor
.beginTask(Messages
.ChecklistEditor_SAVE_EDITOR
, 1);
642 if (!conversation
.isBound()) {
645 CdmStore
.getService(ITaxonNodeService
.class).merge(selectedTaxonNodes
, true);
646 //this.checklistEditorInput.merge();
647 conversation
.commit(true);
657 public void doSaveAs() {
661 public void init(IEditorSite site
, IEditorInput input
) throws PartInitException
{
664 if (input
instanceof ChecklistEditorInput
) {
665 checklistEditorInput
= (ChecklistEditorInput
) input
;
666 setPartName(getPartName() + ": " + checklistEditorInput
.getName()); //$NON-NLS-1$
667 conversation
= checklistEditorInput
.getConversation();
668 conversation
.registerForDataStoreChanges(this);
670 simpleSelectionProvider
= new SimpleSelectionProvider();
671 getSite().setSelectionProvider(simpleSelectionProvider
);
676 public boolean isSaveAsAllowed() {
683 * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.
684 * IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
687 public void selectionChanged(IWorkbenchPart part
, ISelection selection
) {
688 // System.out.println(selection.getClass().getSimpleName());
689 // viewer.setSelection(selection, true);
700 * eu.etaxonomy.taxeditor.model.IContextListener#contextAboutToStop(org.
701 * eclipse.ui.IMemento, org.eclipse.core.runtime.IProgressMonitor)
705 public void contextAboutToStop(IMemento memento
, IProgressMonitor monitor
) {
713 * eu.etaxonomy.taxeditor.model.IContextListener#contextStop(org.eclipse
714 * .ui.IMemento, org.eclipse.core.runtime.IProgressMonitor)
717 public void contextStop(IMemento memento
, IProgressMonitor monitor
) {
718 // IStructuredSelection sel = (IStructuredSelection) this.viewer.getSelection();
719 // if (sel.isEmpty()) {
722 // memento = memento.createChild("tree-selections");
723 // Iterator iter = sel.iterator();
724 // while (iter.hasNext()) {
725 // String nodeName = (String) iter.next();
726 // memento.createChild("selected-nodes", nodeName);
734 * eu.etaxonomy.taxeditor.model.IContextListener#contextStart(org.eclipse
735 * .ui.IMemento, org.eclipse.core.runtime.IProgressMonitor)
738 public void contextStart(IMemento memento
, IProgressMonitor monitor
) {
746 * eu.etaxonomy.taxeditor.model.IContextListener#contextRefresh(org.eclipse
747 * .core.runtime.IProgressMonitor)
750 public void contextRefresh(IProgressMonitor monitor
) {
757 * eu.etaxonomy.taxeditor.model.IContextListener#workbenchShutdown(org.eclipse
758 * .ui.IMemento, org.eclipse.core.runtime.IProgressMonitor)
761 public void workbenchShutdown(IMemento memento
, IProgressMonitor monitor
) {
762 conversation
.clear();
763 conversation
.close();
767 private static final List
<String
> NODE_INIT_STRATEGY
= Arrays
.asList(new String
[] { "descriptions", //$NON-NLS-1$
768 "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$
769 "childNodes.taxon.name", "taxonNodes", "taxonNodes.*", "taxonNodes.taxon.*", "taxon.*", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
770 "taxon.descriptions", "taxon.sec", "taxon.name.*", "terms", "name.*", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
771 "name.rank.representations", "name.status.type.representations", "stateData.$" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
777 * eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider#changed(
781 public void changed(Object element
) {
782 if (element
!= null) {
783 viewer
.update(element
, null);
784 if (element
instanceof Taxon
){
785 checklistEditorInput
.addTaxonToSave((Taxon
)element
);
788 firePropertyChange(PROP_DIRTY
);
793 * @see eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider#forceDirty()
796 public void forceDirty() {
800 public void setDirty(boolean dirty
) {
802 firePropertyChange(PROP_DIRTY
);
808 * @see org.eclipse.ui.forms.editor.FormEditor#isDirty()
811 public boolean isDirty() {
816 * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getCdmEntitySession()
821 // * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
824 // public <T extends CdmBase> Collection<T> getRootEntities() {
825 // // TODO Auto-generated method stub
830 // * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getPropertyPathsMap()
833 // public Map<Object, List<String>> getPropertyPathsMap() {
834 // // TODO Auto-generated method stub
839 * @return the labelProvider
841 public ChecklistLabelProvider
getLabelProvider() {
842 return labelProvider
;
846 * @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
849 public void update(CdmDataChangeMap arg0
) {
850 // TODO Auto-generated method stub
855 * @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
858 public ConversationHolder
getConversationHolder() {