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
.ISelectionChangedListener
;
27 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
28 import org
.eclipse
.jface
.viewers
.SelectionChangedEvent
;
29 import org
.eclipse
.jface
.viewers
.StructuredViewer
;
30 import org
.eclipse
.jface
.viewers
.TableViewer
;
31 import org
.eclipse
.jface
.viewers
.TableViewerColumn
;
32 import org
.eclipse
.swt
.SWT
;
33 import org
.eclipse
.swt
.events
.ModifyListener
;
34 import org
.eclipse
.swt
.events
.SelectionAdapter
;
35 import org
.eclipse
.swt
.events
.SelectionEvent
;
36 import org
.eclipse
.swt
.events
.SelectionListener
;
37 import org
.eclipse
.swt
.layout
.GridData
;
38 import org
.eclipse
.swt
.layout
.GridLayout
;
39 import org
.eclipse
.swt
.widgets
.Composite
;
40 import org
.eclipse
.swt
.widgets
.Display
;
41 import org
.eclipse
.swt
.widgets
.Label
;
42 import org
.eclipse
.swt
.widgets
.Menu
;
43 import org
.eclipse
.swt
.widgets
.MenuItem
;
44 import org
.eclipse
.swt
.widgets
.Table
;
45 import org
.eclipse
.swt
.widgets
.TableColumn
;
46 import org
.eclipse
.swt
.widgets
.Text
;
47 import org
.eclipse
.swt
.widgets
.ToolBar
;
48 import org
.eclipse
.swt
.widgets
.ToolItem
;
49 import org
.eclipse
.ui
.IEditorInput
;
50 import org
.eclipse
.ui
.IEditorSite
;
51 import org
.eclipse
.ui
.IMemento
;
52 import org
.eclipse
.ui
.ISelectionListener
;
53 import org
.eclipse
.ui
.ISelectionService
;
54 import org
.eclipse
.ui
.IWorkbenchPart
;
55 import org
.eclipse
.ui
.PartInitException
;
56 import org
.eclipse
.ui
.part
.EditorPart
;
57 import org
.eclipse
.ui
.progress
.IWorkbenchSiteProgressService
;
59 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
60 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
61 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonNodeService
;
62 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
63 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTermBase
;
64 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
65 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
66 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
67 import eu
.etaxonomy
.cdm
.persistence
.hibernate
.CdmDataChangeMap
;
68 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
69 import eu
.etaxonomy
.taxeditor
.editor
.SimpleSelectionProvider
;
70 import eu
.etaxonomy
.taxeditor
.editor
.l10n
.Messages
;
71 import eu
.etaxonomy
.taxeditor
.editor
.view
.checklist
.edit
.DistributionEditingSupport
;
72 import eu
.etaxonomy
.taxeditor
.editor
.view
.checklist
.filter
.ChecklistEditorFilter
;
73 import eu
.etaxonomy
.taxeditor
.editor
.view
.checklist
.listener
.ChecklistDropdownSelectionListener
;
74 import eu
.etaxonomy
.taxeditor
.editor
.view
.checklist
.listener
.ChecklistFocusListener
;
75 import eu
.etaxonomy
.taxeditor
.editor
.view
.checklist
.listener
.ChecklistModifyListener
;
76 import eu
.etaxonomy
.taxeditor
.model
.IContextListener
;
77 import eu
.etaxonomy
.taxeditor
.model
.IDirtyMarkable
;
78 import eu
.etaxonomy
.taxeditor
.model
.IPartContentHasDetails
;
79 import eu
.etaxonomy
.taxeditor
.model
.IPartContentHasFactualData
;
80 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
81 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
82 import eu
.etaxonomy
.taxeditor
.preference
.Resources
;
83 import eu
.etaxonomy
.taxeditor
.session
.ICdmEntitySession
;
84 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
88 * ChecklistViewPart class.
95 public class ChecklistEditor
extends EditorPart
implements ISelectionListener
, IPartContentHasFactualData
, IConversationEnabled
,
96 IContextListener
, IDirtyMarkable
, IPartContentHasDetails
{
98 private static final String LOADING_TAXA
= Messages
.ChecklistEditor_LOAD_TAXA
;
99 private static final String UNKNOWN
= Messages
.ChecklistEditor_UNKNOWN
;
100 private static final String ELEMENT_COUNT
= Messages
.ChecklistEditor_ELEMENT_COUNT
;
101 public static final String TYPE_FILTER_TEXT
= "type filter text"; //$NON-NLS-1$
103 private static final Logger logger
= Logger
.getLogger(ChecklistEditor
.class);
106 private class ChecklistJob
extends Job
{
108 private List
<TaxonNode
> taxonNodes
;
113 public ChecklistJob(String title
, List
<TaxonNode
> listTaxonNodes
) {
115 this.taxonNodes
= listTaxonNodes
;
123 * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.
127 public IStatus
run(final IProgressMonitor monitor
) {
129 logger
.debug("Begin of eclipse core runtime Job to Retrieve datasources"); //$NON-NLS-1$
130 monitor
.beginTask(Messages
.ChecklistEditor_RETRIEVE_NODES
, taxonNodes
.size() + 1);
132 final List
<Taxon
> taxonList
= new ArrayList
<Taxon
>();
134 for (TaxonNode taxonNode
: taxonNodes
) {
135 HibernateProxyHelper hh
= new HibernateProxyHelper();
136 Taxon taxon
= hh
.deproxy(taxonNode
.getTaxon(), Taxon
.class);
137 taxonList
.add(taxon
);
140 Display
.getDefault().asyncExec(new Runnable() {
144 viewer
.setInput(taxonList
);
153 return Status
.OK_STATUS
;
159 * <code>ID="eu.etaxonomy.taxeditor.store.datasource"{trunked}</code>
161 public static String ID
= "eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditor"; //$NON-NLS-1$
163 private TableViewer viewer
;
165 private String partNameCache
;
167 private IWorkbenchSiteProgressService service
;
169 private ITaxonNodeService taxonNodeService
;
171 private ChecklistEditorComparator comparator
;
173 private ChecklistEditorInput checklistEditorInput
;
175 private SimpleSelectionProvider simpleSelectionProvider
;
177 private ISelectionService selectionService
;
179 private ConversationHolder conversation
;
181 private Integer countNodes
;
183 private List
<TaxonNode
> selectedTaxonNodes
;
185 private boolean dirty
;
187 private ChecklistEditorFilter filter
;
189 private Menu headerMenu
;
191 private Label statusLabel
;
193 private ICdmEntitySession cdmEntitySession
;
195 private ChecklistLabelProvider labelProvider
;
197 private SortedSet
<DefinedTermBase
> terms
= null;
198 private ToolItem toolItem
;
199 private ChecklistDropdownSelectionListener dropListener
;
202 * @return the selectedTaxonNodes
204 public List
<TaxonNode
> getSelectedTaxonNodes() {
205 return selectedTaxonNodes
;
209 * @param selectedTaxonNodes
210 * the selectedTaxonNodes to set
212 public void setSelectedTaxonNodes(List
<TaxonNode
> selectedTaxonNodes
) {
213 this.selectedTaxonNodes
= selectedTaxonNodes
;
218 * Constructor for CdmDataSourceViewPart.
221 public ChecklistEditor() {
222 //cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
228 public void createPartControl(Composite parent
) {
229 service
= (IWorkbenchSiteProgressService
) getSite().getAdapter(IWorkbenchSiteProgressService
.class);
230 taxonNodeService
= CdmStore
.getService(ITaxonNodeService
.class);
231 selectionService
= getSite().getWorkbenchWindow().getSelectionService();
232 selectionService
.addSelectionListener(this);
233 viewer
= new TableViewer(parent
, SWT
.MULTI
| SWT
.H_SCROLL
| SWT
.V_SCROLL
| SWT
.FULL_SELECTION
);
235 // viewer.addSelectionChangedListener(new ISelectionChangedListener() {
237 // public void selectionChanged(SelectionChangedEvent event) {
238 // IStructuredSelection selection = viewer.getStructuredSelection();
239 // Object firstElement = selection.getFirstElement();
240 // // do something with it
245 labelProvider
= new ChecklistLabelProvider(this.viewer
);
247 terms
= labelProvider
.getNamedAreas();
249 MessagingUtils
.informationDialog(Messages
.ChecklistEditor_NO_AREAS
, Messages
.ChecklistEditor_NO_AREAS_MESSAGE
);
253 filter
= new ChecklistEditorFilter();
254 createTopComposite(parent
);
261 private void createTopComposite(Composite parent
) {
262 GridLayout gridLayout
= new GridLayout(3, false);
263 gridLayout
.marginWidth
= 0;
264 gridLayout
.marginHeight
= 0;
265 parent
.setLayout(gridLayout
);
267 final Text searchText
= createSearchBar(parent
);
268 createToolbar(parent
);
270 // getSite().setSelectionProvider(viewer);
272 final ModifyListener modifyListener
= new ChecklistModifyListener(viewer
, filter
, searchText
);
274 searchText
.addFocusListener(new ChecklistFocusListener(searchText
, modifyListener
));
275 searchText
.addModifyListener(modifyListener
);
276 createGridDataForViewerLayout();
278 viewer
.addFilter(filter
);
281 viewer
.setContentProvider(new ChecklistContentProvider());
282 viewer
.setLabelProvider(this.labelProvider
);
283 comparator
= new ChecklistEditorComparator();
284 viewer
.setComparator(comparator
);
286 createStatusBar(parent
);
289 private void createGridDataForViewerLayout() {
290 GridData gridData
= new GridData();
291 gridData
.verticalAlignment
= GridData
.FILL
;
292 gridData
.horizontalSpan
= 3;
293 gridData
.grabExcessHorizontalSpace
= true;
294 gridData
.grabExcessVerticalSpace
= true;
295 gridData
.horizontalAlignment
= GridData
.FILL
;
296 viewer
.getControl().setLayoutData(gridData
);
303 private Text
createSearchBar(Composite parent
) {
304 Label searchLabel
= new Label(parent
, SWT
.NONE
);
305 searchLabel
.setText(Messages
.ChecklistEditor_SEARCH
);
306 final Text searchText
= new Text(parent
, SWT
.BORDER
| SWT
.SEARCH
| SWT
.ICON_SEARCH
| SWT
.CANCEL
);
307 searchText
.setLayoutData(new GridData(GridData
.GRAB_HORIZONTAL
| GridData
.HORIZONTAL_ALIGN_FILL
));
308 searchText
.setForeground(EditorUtil
.getColor(Resources
.SEARCH_VIEW_FOREGROUND
));
309 searchText
.setText(TYPE_FILTER_TEXT
);
316 private void createToolbar(Composite parent
) {
317 ToolBar toolBar
= new ToolBar(parent
, SWT
.NONE
);
318 toolItem
= new ToolItem(toolBar
, SWT
.DROP_DOWN
| SWT
.BORDER
);
319 toolItem
.setText(Messages
.ChecklistEditor_DIST_STATUS
);
320 toolItem
.setToolTipText(Messages
.ChecklistEditor_DIST_STATUS_TOOLTIP
);
321 createToolbarItems();
322 toolItem
.addSelectionListener(dropListener
);
326 private void createToolbarItems() {
327 dropListener
= new ChecklistDropdownSelectionListener(toolItem
, this, terms
);
329 for (DefinedTermBase
<DefinedTermBase
> term
: terms
) {
331 dropListener
.add(term
);
336 private void createStatusBar(Composite composite
) {
337 GridData gridData
= new GridData();
338 gridData
.horizontalSpan
= 3;
339 gridData
.grabExcessHorizontalSpace
= true;
340 gridData
.horizontalAlignment
= GridData
.FILL
;
342 statusLabel
= new Label(composite
, SWT
.LEFT
);
343 statusLabel
.setText(ELEMENT_COUNT
+ (countNodes
!= null ? countNodes
: UNKNOWN
));
344 statusLabel
.setLayoutData(gridData
);
347 private void createTable() {
348 Table table
= viewer
.getTable();//new Table(parent, viewer.getTable().getStyle());
349 List
<String
> titles
= new ArrayList
<String
>();
350 List
<Integer
> bounds
= new ArrayList
<Integer
>();
351 if (PreferencesUtil
.isShowRankInChecklistEditor()){
352 Collections
.addAll(titles
, Messages
.ChecklistEditor_TAXON
, Messages
.ChecklistEditor_RANK
);
353 Collections
.addAll(bounds
, 300, 200);
355 Collections
.addAll(titles
, Messages
.ChecklistEditor_TAXON
);
356 Collections
.addAll(bounds
, 300);
360 Map
<Integer
, Boolean
> restoreValuesForColumnWidth
= restoreValuesForColumnWidth(titles
, bounds
);
361 createInitalDistributionColumns(table
, titles
, bounds
, restoreValuesForColumnWidth
);
362 table
.setSortDirection(SWT
.DOWN
);
363 table
.setHeaderVisible(true);
364 table
.setLinesVisible(true);
367 * This method creates initially the distribution columns for a table. It should only be called for creation.<br>
370 *<b>Notice:</b> If you want to add additional columns later please use <b>addTableViewerColumn()</b>
375 * @param restoreValuesForColumnWidth
377 private void createInitalDistributionColumns(Table table
,
378 List
<String
> titles
, List
<Integer
> bounds
, Map
<Integer
, Boolean
> restoreValuesForColumnWidth
) {
379 for (int columnIndex
= 0; columnIndex
< titles
.size(); columnIndex
++) {
380 TableViewerColumn column
= new TableViewerColumn(viewer
, SWT
.NONE
);
381 column
.getColumn().setText(titles
.get(columnIndex
));
382 column
.getColumn().setWidth(bounds
.get(columnIndex
));
383 column
.getColumn().setResizable(true);
384 column
.getColumn().setMoveable(true);
385 column
.getColumn().addSelectionListener(getSelectionAdapter(column
.getColumn(), columnIndex
));
386 if (columnIndex
== 0) {
387 table
.setSortColumn(column
.getColumn());
389 if (columnIndex
== 1 && PreferencesUtil
.isShowRankInChecklistEditor()) {
390 /** uncommented it for now because no rank editing is wanted **/
391 // column.setEditingSupport(new RankEditingSupport(viewer, this));
393 if ((columnIndex
== 1 && !PreferencesUtil
.isShowRankInChecklistEditor()) || columnIndex
>= 2 ) {
394 //read PrefrenceStore to setWidth according to last saved state
395 if(restoreValuesForColumnWidth
.get(columnIndex
)){
396 column
.getColumn().setWidth(50);
398 column
.getColumn().setWidth(50);
400 column
.setEditingSupport(new DistributionEditingSupport(viewer
, this, columnIndex
));
406 * This methods loads the last opened distribution columns for the table viewer from the prefrence store.<br>
408 * <b>Notice:</b> It adds also the TitleCache to the titles list for the header of each column.<p>
412 * @return Map<Integer, Boolean>
414 private Map
<Integer
, Boolean
> restoreValuesForColumnWidth(List
<String
> titles
,
415 List
<Integer
> bounds
) {
416 Map
<Integer
, Boolean
> restoreColumnWidth
= new HashMap
<Integer
, Boolean
>();
419 if (PreferencesUtil
.isShowRankInChecklistEditor()){
424 for (DefinedTermBase
<DefinedTermBase
> term
: terms
) {
426 restoreColumnWidth
.put(columnIndex
, PreferencesUtil
.getPreferenceStore().getBoolean(term
.getUuid().toString()));
427 if (PreferencesUtil
.isShowIdInVocabularyInChecklistEditor()){
428 if (term
.getIdInVocabulary() != null){
429 titles
.add(term
.getIdInVocabulary());
431 titles
.add(term
.getTitleCache());
434 titles
.add(term
.getTitleCache());
441 return restoreColumnWidth
;
445 * This method adds new DistributionColumns to an existing table.
452 private TableViewerColumn
addTableViewerColumn(String title
, int bound
, final int colNumber
) {
453 final TableViewerColumn viewerColumn
= new TableViewerColumn(viewer
, SWT
.NONE
);
454 final TableColumn column
= viewerColumn
.getColumn();
455 column
.setText(title
);
456 column
.setWidth(200);
457 viewerColumn
.setEditingSupport(new DistributionEditingSupport(viewer
, this, colNumber
));
458 column
.setResizable(true);
459 column
.setMoveable(true);
467 * pull data from database and set input for view
470 private void loadDataInput() {
471 Classification classification
= checklistEditorInput
.getClassification();
472 TaxonNode taxonNode
= checklistEditorInput
.getTaxonNode();
473 if (classification
!= null && taxonNode
== null) {
474 countNodes
= taxonNodeService
.countAllNodesForClassification(classification
);
475 // statusLabel.setText(ELEMENT_COUNT + (countNodes != null ? countNodes : UNKNOWN));
476 // This should not kill the view nor the editor if something goes
478 // TODO: don't load the whole taxonNode Object but rather a small
479 // and simple Solution
480 // FIXME: May be don't open classification which are greater than
482 selectedTaxonNodes
= taxonNodeService
.listAllNodesForClassification(classification
, 0, countNodes
);
483 countNodes
= selectedTaxonNodes
.size();
484 statusLabel
.setText(ELEMENT_COUNT
+ (countNodes
!= null ? countNodes
: UNKNOWN
));
485 getService().schedule(new ChecklistJob(LOADING_TAXA
, selectedTaxonNodes
), Job
.LONG
);
487 if (taxonNode
!= null) {
488 selectedTaxonNodes
= taxonNodeService
.loadChildNodesOfTaxonNode(taxonNode
, NODE_INIT_STRATEGY
, true, null);
489 getService().schedule(new ChecklistJob(LOADING_TAXA
, selectedTaxonNodes
), Job
.LONG
);
490 countNodes
= selectedTaxonNodes
.size();
491 statusLabel
.setText(ELEMENT_COUNT
+ (countNodes
!= null ? countNodes
: UNKNOWN
));
497 public void dispose() {
498 // this.checklistEditorInput.dispose();
501 conversation
.unregisterForDataStoreChanges(this);
502 conversation
.unbind();
504 //conversation.close();
510 public void setFocus() {
512 viewer
.getControl().setFocus();
518 * @see org.eclipse.ui.part.WorkbenchPart#showBusy(boolean)
522 public void showBusy(boolean busy
) {
523 super.showBusy(busy
);
524 // viewer.getTable().setEnabled(!busy);
526 partNameCache
= getPartName();
527 setPartName(String
.format(Messages
.ChecklistEditor_LOAD_CNT_TAXA
, countNodes
));
529 if (partNameCache
!= null) {
530 setPartName(partNameCache
);
537 * Getter for the field <code>viewer</code>.
540 * @return a {@link org.eclipse.jface.viewers.StructuredViewer} object.
542 public StructuredViewer
getViewer() {
546 public void refresh() {
551 * This method should only be called for adding new Distribution columns and reloading the table.<br>
552 * It will hide the old distribution column and load the newly added columns.<br>
554 * <b>Notice:</b> for data update please use <b>refresh()</b>
557 @SuppressWarnings({ "unchecked", "rawtypes" })
558 public void reload(){
559 //create new Items for Dropdown menue
560 Table table
= viewer
.getTable();
561 table
.setRedraw(false);
562 SortedSet
<DefinedTermBase
> oldTerms
= terms
;
564 // if (PreferencesUtil.isShowIdInVocabularyInChecklistEditor()){
567 // terms = (SortedSet<DefinedTermBase>) labelProvider.getTermsOrderedByLabels(labelProvider.getNamedAreas(), CdmStore.getDefaultLanguage());
569 SortedSet
<DefinedTermBase
> newTerms
= labelProvider
.getNamedAreas();
570 toolItem
.removeSelectionListener(dropListener
);
571 hideDistributionColumns(oldTerms
);
572 createToolbarItems();
573 toolItem
.addSelectionListener(dropListener
);
574 for(DefinedTermBase term
:newTerms
){
575 int count
= viewer
.getTable().getColumnCount();
576 addTableViewerColumn(term
.getTitleCache(), 200, count
);
577 acitivateNewColumnInDropDownMenu(term
);
579 viewer
.setLabelProvider(labelProvider
);
580 getService().schedule(new ChecklistJob(LOADING_TAXA
, selectedTaxonNodes
), Job
.LONG
);
581 table
.setRedraw(true);
585 private void acitivateNewColumnInDropDownMenu(DefinedTermBase term
) {
586 Menu menu
= dropListener
.getMenu();
587 MenuItem
[] items
= menu
.getItems();
588 for(MenuItem item
: items
){
589 if(item
.getText().equalsIgnoreCase(term
.getTitleCache())){
590 item
.setSelection(true);
591 PreferencesUtil
.getPreferenceStore().setValue(term
.getUuid().toString(), true);
596 private void hideDistributionColumns(SortedSet
<DefinedTermBase
> oldTerms
) {
597 TableColumn
[] columns
= viewer
.getTable().getColumns();
598 for(int i
=4; i
<columns
.length
; i
++){
600 columns
[i
].dispose();
601 Menu menu
= dropListener
.getMenu();
602 int itemCount
= menu
.getItemCount();
603 MenuItem item
= menu
.getItem(i
-3);
604 item
.setSelection(false);
606 if(oldTerms
!= null){
607 for(DefinedTermBase term
: oldTerms
){
608 PreferencesUtil
.getPreferenceStore().setValue(term
.getUuid().toString(), false);
615 * Getter for the field <code>service</code>.
618 * @return the service
620 public IWorkbenchSiteProgressService
getService() {
624 private SelectionAdapter
getSelectionAdapter(final TableColumn column
, final int index
) {
625 SelectionAdapter selectionAdapter
= new SelectionAdapter() {
627 public void widgetSelected(SelectionEvent e
) {
628 comparator
.setColumn(index
);
629 int dir
= viewer
.getTable().getSortDirection();
630 if (viewer
.getTable().getSortColumn() == column
) {
631 dir
= dir
== SWT
.UP ? SWT
.DOWN
: SWT
.UP
;
635 viewer
.getTable().setSortDirection(dir
);
636 viewer
.getTable().setSortColumn(column
);
640 return selectionAdapter
;
644 public void doSave(IProgressMonitor monitor
) {
646 monitor
.beginTask(Messages
.ChecklistEditor_SAVE_EDITOR
, 1);
647 if (!conversation
.isBound()) {
650 CdmStore
.getService(ITaxonNodeService
.class).merge(selectedTaxonNodes
, true);
651 //this.checklistEditorInput.merge();
652 conversation
.commit(true);
662 public void doSaveAs() {
666 public void init(IEditorSite site
, IEditorInput input
) throws PartInitException
{
669 if (input
instanceof ChecklistEditorInput
) {
670 checklistEditorInput
= (ChecklistEditorInput
) input
;
671 setPartName(getPartName() + ": " + checklistEditorInput
.getName()); //$NON-NLS-1$
672 conversation
= checklistEditorInput
.getConversation();
673 conversation
.registerForDataStoreChanges(this);
675 simpleSelectionProvider
= new SimpleSelectionProvider();
676 getSite().setSelectionProvider(simpleSelectionProvider
);
681 public boolean isSaveAsAllowed() {
688 * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.
689 * IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
692 public void selectionChanged(IWorkbenchPart part
, ISelection selection
) {
693 // System.out.println(selection.getClass().getSimpleName());
694 // viewer.setSelection(selection, true);
705 * eu.etaxonomy.taxeditor.model.IContextListener#contextAboutToStop(org.
706 * eclipse.ui.IMemento, org.eclipse.core.runtime.IProgressMonitor)
710 public void contextAboutToStop(IMemento memento
, IProgressMonitor monitor
) {
718 * eu.etaxonomy.taxeditor.model.IContextListener#contextStop(org.eclipse
719 * .ui.IMemento, org.eclipse.core.runtime.IProgressMonitor)
722 public void contextStop(IMemento memento
, IProgressMonitor monitor
) {
723 // IStructuredSelection sel = (IStructuredSelection) this.viewer.getSelection();
724 // if (sel.isEmpty()) {
727 // memento = memento.createChild("tree-selections");
728 // Iterator iter = sel.iterator();
729 // while (iter.hasNext()) {
730 // String nodeName = (String) iter.next();
731 // memento.createChild("selected-nodes", nodeName);
739 * eu.etaxonomy.taxeditor.model.IContextListener#contextStart(org.eclipse
740 * .ui.IMemento, org.eclipse.core.runtime.IProgressMonitor)
743 public void contextStart(IMemento memento
, IProgressMonitor monitor
) {
751 * eu.etaxonomy.taxeditor.model.IContextListener#contextRefresh(org.eclipse
752 * .core.runtime.IProgressMonitor)
755 public void contextRefresh(IProgressMonitor monitor
) {
762 * eu.etaxonomy.taxeditor.model.IContextListener#workbenchShutdown(org.eclipse
763 * .ui.IMemento, org.eclipse.core.runtime.IProgressMonitor)
766 public void workbenchShutdown(IMemento memento
, IProgressMonitor monitor
) {
767 conversation
.clear();
768 conversation
.close();
772 private static final List
<String
> NODE_INIT_STRATEGY
= Arrays
.asList(new String
[] { "descriptions", //$NON-NLS-1$
773 "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$
774 "childNodes.taxon.name", "taxonNodes", "taxonNodes.*", "taxonNodes.taxon.*", "taxon.*", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
775 "taxon.descriptions", "taxon.sec", "taxon.name.*", "terms", "name.*", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
776 "name.rank.representations", "name.status.type.representations", "stateData.$" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
782 * eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider#changed(
786 public void changed(Object element
) {
787 if (element
!= null) {
788 viewer
.update(element
, null);
790 firePropertyChange(PROP_DIRTY
);
795 * @see eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider#forceDirty()
798 public void forceDirty() {
802 public void setDirty(boolean dirty
) {
804 firePropertyChange(PROP_DIRTY
);
810 * @see org.eclipse.ui.forms.editor.FormEditor#isDirty()
813 public boolean isDirty() {
818 * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getCdmEntitySession()
823 // * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
826 // public <T extends CdmBase> Collection<T> getRootEntities() {
827 // // TODO Auto-generated method stub
832 // * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getPropertyPathsMap()
835 // public Map<Object, List<String>> getPropertyPathsMap() {
836 // // TODO Auto-generated method stub
841 * @return the labelProvider
843 public ChecklistLabelProvider
getLabelProvider() {
844 return labelProvider
;
848 * @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
851 public void update(CdmDataChangeMap arg0
) {
852 // TODO Auto-generated method stub
857 * @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
860 public ConversationHolder
getConversationHolder() {