3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.taxeditor
.editor
.key
;
13 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
14 import org
.eclipse
.ui
.IEditorPart
;
15 import org
.eclipse
.ui
.PartInitException
;
16 import org
.eclipse
.ui
.forms
.editor
.FormEditor
;
18 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
19 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
20 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKey
;
21 import eu
.etaxonomy
.cdm
.persistence
.hibernate
.CdmDataChangeMap
;
22 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
23 import eu
.etaxonomy
.taxeditor
.editor
.key
.polytomous
.PolytomousKeyGraphEditor
;
24 import eu
.etaxonomy
.taxeditor
.editor
.key
.polytomous
.PolytomousKeyListEditor
;
25 import eu
.etaxonomy
.taxeditor
.model
.IDirtyMarkableSelectionProvider
;
26 import eu
.etaxonomy
.taxeditor
.model
.IPartContentHasDetails
;
30 * @created Mar 30, 2011
33 public class KeyEditor
extends FormEditor
implements IConversationEnabled
,
34 IDirtyMarkableSelectionProvider
, IPartContentHasDetails
{
36 public static final String ID
= "eu.etaxonomy.taxeditor.editor.key";
38 private ConversationHolder conversation
;
40 private boolean dirty
;
45 * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.
49 public void doSave(IProgressMonitor monitor
) {
51 monitor
.beginTask("Saving Editor", 1);
52 getConversationHolder().commit(true);
63 * @see org.eclipse.ui.part.EditorPart#doSaveAs()
66 public void doSaveAs() {
73 * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
76 public boolean isSaveAsAllowed() {
84 * eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update
85 * (eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
88 public void update(CdmDataChangeMap arg0
) {
89 // TODO Auto-generated method stub
96 * eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder
100 public ConversationHolder
getConversationHolder() {
108 * eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider#changed(
112 public void changed(Object element
) {
113 editorDirtyStateChanged();
114 IEditorPart activeEditor
= getActiveEditor();
115 if (activeEditor
instanceof PolytomousKeyListEditor
) {
116 ((PolytomousKeyListEditor
) activeEditor
).changed(element
);
123 * @see org.eclipse.ui.forms.editor.FormEditor#editorDirtyStateChanged()
126 public void editorDirtyStateChanged() {
128 super.editorDirtyStateChanged();
132 protected void handlePropertyChange(int propertyId
) {
133 if (propertyId
== PROP_DIRTY
) {
136 super.handlePropertyChange(propertyId
);
139 private void setDirty(boolean dirty
) {
141 firePropertyChange(PROP_DIRTY
);
147 * @see org.eclipse.ui.forms.editor.FormEditor#isDirty()
150 public boolean isDirty() {
157 * @see org.eclipse.ui.forms.editor.FormEditor#dispose()
160 public void dispose() {
161 conversation
.unregisterForDataStoreChanges(this);
162 conversation
.close();
169 * @see org.eclipse.ui.forms.editor.FormEditor#addPages()
172 protected void addPages() {
173 AbstractIdentificationEditorInput input
= (AbstractIdentificationEditorInput
) getEditorInput();
174 conversation
= input
.getConversationHolder();
175 conversation
.registerForDataStoreChanges(this);
178 addPage(0, new PolytomousKeyListEditor(this), input
);
179 setPageText(0, "List");
180 addPage(1, new PolytomousKeyGraphEditor(this), input
);
181 setPageText(1, "Graph");
182 } catch (PartInitException e
) {
183 EditorUtil
.error(getClass(), e
);
186 PolytomousKey key
= (PolytomousKey
) input
.getKey();
188 setPartName(key
.getTitleCache());