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
.persistence
.hibernate
.CdmDataChangeMap
;
21 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
22 import eu
.etaxonomy
.taxeditor
.editor
.key
.polytomous
.PolytomousKeyGraphEditor
;
23 import eu
.etaxonomy
.taxeditor
.editor
.key
.polytomous
.PolytomousKeyListEditor
;
24 import eu
.etaxonomy
.taxeditor
.model
.IDirtyMarkableSelectionProvider
;
25 import eu
.etaxonomy
.taxeditor
.model
.IPartContentHasDetails
;
29 * @created Mar 30, 2011
32 public class KeyEditor
extends FormEditor
implements IConversationEnabled
,
33 IDirtyMarkableSelectionProvider
, IPartContentHasDetails
{
35 public static final String ID
= "eu.etaxonomy.taxeditor.editor.key";
37 private ConversationHolder conversation
;
39 private AbstractIdentificationEditorInput input
;
41 private boolean dirty
;
46 * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.
50 public void doSave(IProgressMonitor monitor
) {
52 monitor
.beginTask("Saving Editor", 1);
53 getConversationHolder().commit(true);
64 * @see org.eclipse.ui.part.EditorPart#doSaveAs()
67 public void doSaveAs() {
74 * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
77 public boolean isSaveAsAllowed() {
85 * eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update
86 * (eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
89 public void update(CdmDataChangeMap arg0
) {
90 // TODO Auto-generated method stub
97 * eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder
101 public ConversationHolder
getConversationHolder() {
109 * eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider#changed(
113 public void changed(Object element
) {
114 editorDirtyStateChanged();
115 IEditorPart activeEditor
= getActiveEditor();
116 if (activeEditor
instanceof PolytomousKeyListEditor
) {
117 ((PolytomousKeyListEditor
) activeEditor
).changed(element
);
124 * @see org.eclipse.ui.forms.editor.FormEditor#editorDirtyStateChanged()
127 public void editorDirtyStateChanged() {
129 super.editorDirtyStateChanged();
133 protected void handlePropertyChange(int propertyId
) {
134 if (propertyId
== PROP_DIRTY
) {
137 super.handlePropertyChange(propertyId
);
140 private void setDirty(boolean dirty
) {
142 firePropertyChange(PROP_DIRTY
);
148 * @see org.eclipse.ui.forms.editor.FormEditor#isDirty()
151 public boolean isDirty() {
158 * @see org.eclipse.ui.forms.editor.FormEditor#dispose()
161 public void dispose() {
162 conversation
.unregisterForDataStoreChanges(this);
163 conversation
.close();
170 * @see org.eclipse.ui.forms.editor.FormEditor#addPages()
173 protected void addPages() {
174 input
= (AbstractIdentificationEditorInput
) getEditorInput();
175 conversation
= input
.getConversationHolder();
176 conversation
.registerForDataStoreChanges(this);
179 addPage(0, new PolytomousKeyListEditor(), input
);
180 setPageText(0, "List");
181 addPage(1, new PolytomousKeyGraphEditor(), input
);
182 setPageText(1, "Graph");
183 } catch (PartInitException e
) {
184 EditorUtil
.error(getClass(), e
);