Project

General

Profile

Revision 860316c8

ID860316c85796120e3c72dbef3a6b44c98bf1f07f
Parent 24b8f2f1
Child 2b7bbafc

Added by Patrick Plitzner about 3 years ago

ref #6595 removed e3 name editor classes (unstable navigator plugin)

View differences:

eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/perspective/ChecklistPerspective.java
1 1
/**
2 2
 * Copyright (C) 2007 EDIT
3
 * European Distributed Institute of Taxonomy 
3
 * European Distributed Institute of Taxonomy
4 4
 * http://www.e-taxonomy.eu
5
 * 
5
 *
6 6
 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
 * See LICENSE.TXT at the top of this package for the full license terms.
8 8
 */
......
13 13
import org.eclipse.ui.IPageLayout;
14 14

  
15 15
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewPart;
16
import eu.etaxonomy.taxeditor.editor.view.media.MediaViewPart;
17 16
import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigator;
18 17
import eu.etaxonomy.taxeditor.navigation.search.SearchResultView;
19 18
import eu.etaxonomy.taxeditor.view.datasource.CdmDataSourceViewPart;
20 19
import eu.etaxonomy.taxeditor.view.detail.DetailsViewPart;
21
import eu.etaxonomy.taxeditor.editor.view.concept.ConceptViewPart;
22 20

  
23 21
/**
24 22
 * @author a.oppermann
......
29 27

  
30 28
	/*
31 29
	 * (non-Javadoc)
32
	 * 
30
	 *
33 31
	 * @see
34 32
	 * org.eclipse.ui.IPerspectiveFactory#createInitialLayout(org.eclipse.ui
35 33
	 * .IPageLayout)
......
46 44
		IFolderLayout folder = layout.createFolder("Folder", IPageLayout.BOTTOM, 0.6f, layout.getEditorArea());
47 45
		folder.addView(DescriptiveViewPart.ID);
48 46
		folder.addView(DetailsViewPart.ID);
49
		folder.addView(ConceptViewPart.ID);
50 47
//		folder.addView(MediaViewPart.ID);
51 48

  
52 49
//		createAdditionalFolder(layout, layout.getEditorArea());
eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/perspective/Taxonomic.java
1 1
/**
2 2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
3
* European Distributed Institute of Taxonomy
4 4
* http://www.e-taxonomy.eu
5
* 
5
*
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
......
13 13
import org.eclipse.ui.IPageLayout;
14 14

  
15 15
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewPart;
16
import eu.etaxonomy.taxeditor.editor.view.media.MediaViewPart;
17 16
import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigator;
18 17
import eu.etaxonomy.taxeditor.navigation.search.SearchResultView;
19 18
import eu.etaxonomy.taxeditor.view.detail.DetailsViewPart;
......
32 31
	@Override
33 32
	public void createInitialLayout(IPageLayout layout) {
34 33
		IFolderLayout navigationFolder = layout.createFolder("navigation", IPageLayout.LEFT, 0.25f, layout.getEditorArea());
35
		
34

  
36 35
		navigationFolder.addView(TaxonNavigator.ID);
37 36
		navigationFolder.addPlaceholder(SearchResultView.ID + ":*");
38
		
37

  
39 38
		layout.addView(DetailsViewPart.ID, IPageLayout.RIGHT, 0.25f, layout.getEditorArea());
40 39
		layout.addView(SupplementalDataViewPart.ID, IPageLayout.BOTTOM, 0.25f, DetailsViewPart.ID);
41
		
40

  
42 41
		layout.addView(DescriptiveViewPart.ID, IPageLayout.BOTTOM, 0.25f, layout.getEditorArea());
43
		layout.addView(MediaViewPart.ID, IPageLayout.RIGHT, 0.25f, DescriptiveViewPart.ID);
44
		
42

  
45 43
		createAdditionalFolder(layout, layout.getEditorArea());
46 44
	}
47 45
}
eu.etaxonomy.taxeditor.editor/META-INF/MANIFEST.MF
12 12
 eu.etaxonomy.taxeditor.editor.handler.defaultHandler,
13 13
 eu.etaxonomy.taxeditor.editor.internal,
14 14
 eu.etaxonomy.taxeditor.editor.key.polytomous,
15
 eu.etaxonomy.taxeditor.editor.name,
16 15
 eu.etaxonomy.taxeditor.editor.name.handler,
17 16
 eu.etaxonomy.taxeditor.editor.name.operation,
18 17
 eu.etaxonomy.taxeditor.editor.view.concept,
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorStateManager.java
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
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.
8
*/
9

  
10
package eu.etaxonomy.taxeditor.editor;
11

  
12
import java.util.HashSet;
13
import java.util.Set;
14
import java.util.UUID;
15

  
16
import org.eclipse.core.runtime.IProgressMonitor;
17
import org.eclipse.ui.IEditorInput;
18
import org.eclipse.ui.IEditorPart;
19
import org.eclipse.ui.IMemento;
20
import org.eclipse.ui.IPersistable;
21
import org.eclipse.ui.PartInitException;
22

  
23
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
24
import eu.etaxonomy.taxeditor.editor.view.concept.ConceptViewPart;
25
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewPart;
26
import eu.etaxonomy.taxeditor.editor.view.media.MediaViewPart;
27
import eu.etaxonomy.taxeditor.model.ContextListenerAdapter;
28
import eu.etaxonomy.taxeditor.model.MessagingUtils;
29
import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;
30

  
31
/**
32
 * <p>EditorStateManager class.</p>
33
 *
34
 * @author n.hoffmann
35
 * @created Sep 30, 2010
36
 * @version 1.0
37
 */
38
public class EditorStateManager extends ContextListenerAdapter {
39

  
40
	private static final String EDITORS = "editors"; //$NON-NLS-1$
41

  
42
	private static final String EDITOR = "editor"; //$NON-NLS-1$
43

  
44
	private TaxonEditorInputFactory inputFactory;
45

  
46
	/**
47
	 * <p>Constructor for EditorStateManager.</p>
48
	 */
49
	public EditorStateManager() {
50
		inputFactory = new TaxonEditorInputFactory();
51
	}
52

  
53
	/* (non-Javadoc)
54
	 * @see eu.etaxonomy.taxeditor.model.IContextListener#contextAboutToStop(org.eclipse.ui.IMemento, org.eclipse.core.runtime.IProgressMonitor)
55
	 */
56
	/** {@inheritDoc} */
57
	@Override
58
	public void contextAboutToStop(IMemento memento, IProgressMonitor monitor) {
59
		saveEditorState(memento);
60
	}
61

  
62
	/* (non-Javadoc)
63
	 * @see eu.etaxonomy.taxeditor.model.ContextListenerAdapter#contextStop(org.eclipse.ui.IMemento, org.eclipse.core.runtime.IProgressMonitor)
64
	 */
65
	/** {@inheritDoc} */
66
	@Override
67
	public void contextStop(IMemento memento, IProgressMonitor monitor) {
68
		EditorUtil.closeAll();
69
		resetConstantViews();
70
	}
71

  
72
	/**
73
	 *
74
	 */
75
	private void resetConstantViews() {
76
		AbstractCdmEditorViewPart descriptiveView = (AbstractCdmEditorViewPart) EditorUtil.getView(DescriptiveViewPart.ID, false);
77
		AbstractCdmEditorViewPart mediaView = (AbstractCdmEditorViewPart) EditorUtil.getView(MediaViewPart.ID, false);
78
		AbstractCdmEditorViewPart conceptView = (AbstractCdmEditorViewPart) EditorUtil.getView(ConceptViewPart.ID, false);
79

  
80
		if(descriptiveView != null){
81
			descriptiveView.showEmptyPage();
82
		}
83
		if(mediaView != null){
84
			mediaView.showEmptyPage();
85
		}
86
		if(conceptView != null){
87
			conceptView.showEmptyPage();
88
		}
89
	}
90

  
91
	/* (non-Javadoc)
92
	 * @see eu.etaxonomy.taxeditor.model.IContextListener#contextStart(org.eclipse.ui.IMemento, org.eclipse.core.runtime.IProgressMonitor)
93
	 */
94
	/** {@inheritDoc} */
95
	@Override
96
	public void contextStart(IMemento memento, IProgressMonitor monitor) {
97
		restoreEditors(memento, monitor);
98
	}
99

  
100
	/* (non-Javadoc)
101
	 * @see eu.etaxonomy.taxeditor.model.ContextListenerAdapter#contextRefresh(org.eclipse.core.runtime.IProgressMonitor)
102
	 */
103
	@Override
104
	public void contextRefresh(IProgressMonitor monitor) {
105
		refreshEditors(monitor);
106
	}
107

  
108
	/* (non-Javadoc)
109
	 * @see eu.etaxonomy.taxeditor.model.ContextListenerAdapter#workbenchShutdown(org.eclipse.ui.IMemento, org.eclipse.core.runtime.IProgressMonitor)
110
	 */
111
	/** {@inheritDoc} */
112
	@Override
113
	public void workbenchShutdown(IMemento memento, IProgressMonitor monitor) {
114
		saveEditorState(memento);
115
	}
116

  
117
	/**
118
	 * Reads taxon node UUIDs from the given memento and tries to open an editor
119
	 * for each of the found UUIDs.
120
	 *
121
	 * @param memento
122
	 */
123
	private void restoreEditors(final IMemento memento, IProgressMonitor monitor){
124
		if(memento == null){
125
			return;
126
		}
127

  
128
		IProgressMonitor subProgressMonitor = EditorUtil.getSubProgressMonitor(monitor, 1);
129

  
130
		IMemento editorMementos = memento.getChild(EDITORS);
131
		IMemento[] editorInputs = editorMementos.getChildren(EDITOR);
132

  
133
		String taskName = Messages.EditorStateManager_RESTORE_EDITORS;
134
        subProgressMonitor.beginTask(taskName, 1 + editorInputs.length * 2);
135
		subProgressMonitor.subTask(taskName);
136
		subProgressMonitor.worked(1);
137

  
138
		for(IMemento editorInput : editorInputs){
139
			TaxonEditorInput input = (TaxonEditorInput) inputFactory.createElement(editorInput);
140
			subProgressMonitor.worked(1);
141
			if(!subProgressMonitor.isCanceled() && input != null){
142
				try {
143
					EditorUtil.open(input);
144
				} catch (PartInitException e) {
145
					MessagingUtils.error(getClass(), Messages.EditorStateManager_ERROR_OPEN_WINDOW, e);
146
				}
147
			}
148
			subProgressMonitor.worked(1);
149
		}
150
		subProgressMonitor.done();
151
	}
152

  
153
	/**
154
	 * @param monitor
155
	 */
156
	private void refreshEditors(IProgressMonitor monitor) {
157
		IProgressMonitor subProgressMonitor = EditorUtil.getSubProgressMonitor(monitor, 1);
158

  
159
		Set<IEditorPart> openEditors = EditorUtil.getOpenEditors();
160

  
161

  
162
		subProgressMonitor.beginTask(Messages.EditorStateManager_REFRESH_EDITOR, openEditors.size() * 2);
163

  
164
		Set<UUID> uuids = new HashSet<UUID>();
165

  
166
		for(IEditorPart editor : openEditors){
167
			if(editor instanceof MultiPageTaxonEditor){
168
				try {
169
					uuids.add(((TaxonEditorInput) editor.getEditorInput()).getTaxonNode().getUuid());
170

  
171
//					((MultiPageTaxonEditor) editor).close(false);
172
					EditorUtil.close((MultiPageTaxonEditor)editor);
173
					subProgressMonitor.worked(1);
174
				} catch (Exception e) {
175
					// TODO Auto-generated catch block
176
					e.printStackTrace();
177
				}
178
			}
179
		}
180

  
181
		for(UUID uuid : uuids){
182
			try {
183
				EditorUtil.openTaxonNodeE4(uuid);
184
			} catch (Exception e) {
185
				// TODO Auto-generated catch block
186
				e.printStackTrace();
187
			}
188
			subProgressMonitor.worked(1);
189
		}
190

  
191
		subProgressMonitor.done();
192
	}
193

  
194
	/**
195
	 * Saves the UUIDs
196
	 *
197
	 * @param memento
198
	 */
199
	private void saveEditorState(IMemento memento){
200
		if(memento == null){
201
			return;
202
		}
203

  
204
		Set<IEditorPart> editors = EditorUtil.getOpenEditors();
205

  
206
		IMemento editorMementos = memento.createChild(EDITORS);
207

  
208
		for(IEditorPart editor : editors){
209
			IEditorInput input = editor.getEditorInput();
210
			if(input instanceof IPersistable){
211
				IMemento editorMemento = editorMementos.createChild(EDITOR);
212
				((IPersistable) input).saveState(editorMemento);
213
			}
214
		}
215
	}
216
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java
9 9

  
10 10
package eu.etaxonomy.taxeditor.editor;
11 11

  
12
import java.util.HashSet;
13
import java.util.Set;
14 12
import java.util.UUID;
15 13

  
16 14
import org.eclipse.core.commands.ExecutionEvent;
......
85 83
		return editor;
86 84
	}
87 85

  
88
	/**
89
	 * Opens a new editor window with the given TaxonEditorInput
90
	 *
91
	 * @param input
92
	 *            a {@link eu.etaxonomy.taxeditor.editor.TaxonEditorInput}
93
	 *            object.
94
	 * @throws org.eclipse.ui.PartInitException
95
	 *             if any.
96
	 */
97
	public static void open(TaxonEditorInput input) throws PartInitException {
98
		open(input, MultiPageTaxonEditor.ID);
99
	}
100

  
101 86
	public static void open(PolytomousKeyEditorInput input)
102 87
			throws PartInitException {
103 88
		open(input, KeyEditor.ID);
......
236 221
	}
237 222

  
238 223
	/**
239
	 * Returns a set of all currently open <code>MultiPageTaxonEditor</code>s.
240
	 *
241
	 * @return a {@link java.util.Set} object.
242
	 */
243
	public static Set<IEditorPart> getOpenEditors() {
244
		Set<IEditorPart> taxonEditors = new HashSet<IEditorPart>();
245

  
246
		if (getActivePage() != null) {
247
			for (IEditorReference reference : getActivePage()
248
					.getEditorReferences()) {
249
				IEditorPart editor = reference.getEditor(false);
250
				if (editor instanceof MultiPageTaxonEditor) {
251
					taxonEditors.add(editor);
252
				}
253
			}
254
		}
255

  
256
		return taxonEditors;
257
	}
258

  
259
	/**
260
	 * Returns the currently active taxon editor
261
	 *
262
	 * @return the taxon editor that has focus
263
	 */
264
	public static MultiPageTaxonEditor getActiveMultiPageTaxonEditor() {
265
		Object editorPart = getActiveE4Editor();
266
		if (editorPart != null && editorPart instanceof MultiPageTaxonEditor) {
267
			MultiPageTaxonEditor editor = (MultiPageTaxonEditor) editorPart;
268
			editor.getConversationHolder().bind();
269
			return editor;
270
		}
271
		return null;
272
	}
273

  
274
	/**
275
	 * <p>
276
	 * getActiveEditorPage
277
	 * </p>
278
	 *
279
	 * @param page
280
	 *            a {@link eu.etaxonomy.taxeditor.editor.Page} object.
281
	 * @return a {@link org.eclipse.ui.IEditorPart} object.
282
	 */
283
	public static IEditorPart getActiveEditorPage(Page page) {
284
		MultiPageTaxonEditor editor = getActiveMultiPageTaxonEditor();
285

  
286
		return editor != null ? editor.getPage(page) : null;
287
	}
288

  
289
	/**
290
	 * Returns the selection of the currently active taxon editor
291
	 *
292
	 * @return a {@link org.eclipse.jface.viewers.ISelection} object.
293
	 */
294
	public static ISelection getCurrentSelection() {
295
		if (getActiveMultiPageTaxonEditor() == null) {
296
			return null;
297
		} else {
298
			return getActiveMultiPageTaxonEditor().getSite()
299
					.getSelectionProvider().getSelection();
300
		}
301
	}
302

  
303
	/**
304
	 * <p>
305
	 * getUndoContext
306
	 * </p>
307
	 *
308
	 * @param editor
309
	 *            a {@link eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor}
310
	 *            object.
311
	 * @return a {@link org.eclipse.core.commands.operations.IUndoContext}
312
	 *         object.
313
	 */
314
	public static IUndoContext getUndoContext(MultiPageTaxonEditor editor) {
315
		return editor.getUndoContext();
316
	}
317

  
318
	/**
319 224
	 * <p>
320 225
	 * getUndoContext
321 226
	 * </p>
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/IDropTargetable.java
1
/**
2
 * 
3
 */
4
package eu.etaxonomy.taxeditor.editor;
5

  
6
import org.eclipse.swt.widgets.Composite;
7

  
8
import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
9
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
10

  
11
/**
12
 * <p>IDropTargetable interface.</p>
13
 *
14
 * @author n.hoffmann
15
 * @version $Id: $
16
 */
17
public interface IDropTargetable extends IPostOperationEnabled {
18

  
19
	/**
20
	 * <p>getControl</p>
21
	 *
22
	 * @return a {@link org.eclipse.swt.widgets.Composite} object.
23
	 */
24
	public Composite getControl();
25
	
26
	/**
27
	 * <p>getNameEditor</p>
28
	 *
29
	 * @return a {@link eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor} object.
30
	 */
31
	public TaxonNameEditor getEditor();
32

  
33
	/**
34
	 * <p>dragEntered</p>
35
	 */
36
	public void dragEntered();
37

  
38
	/**
39
	 * <p>dragLeft</p>
40
	 */
41
	public void dragLeft();
42
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/IMultiPageTaxonEditorPage.java
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
4
* http://www.e-taxonomy.eu
5
* 
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.
8
*/
9

  
10
package eu.etaxonomy.taxeditor.editor;
11

  
12
import org.eclipse.ui.IEditorPart;
13

  
14
/**
15
 * <p>IMultiPageTaxonEditorPage interface.</p>
16
 *
17
 * @author n.hoffmann
18
 * @created Jan 5, 2010
19
 * @version 1.0
20
 */
21
public interface IMultiPageTaxonEditorPage extends IEditorPart {
22

  
23
	/**
24
	 * Redraws this editor
25
	 * return true on success
26
	 *
27
	 * @return a boolean.
28
	 */
29
	public boolean redraw();
30
	
31
	/**
32
	 * Redraws the editor controls
33
	 *
34
	 * @param focus if set to true the focus is set on the editor
35
	 * @return true on success
36
	 */
37
	public boolean redraw(boolean focus);
38
	
39
	/**
40
	 * Whether the editor page is currently redrawing
41
	 *
42
	 * @return a boolean.
43
	 */
44
	public boolean isRedrawing();
45

  
46
	/**
47
	 * Sets the editor page into enabled or disabled state depending on the 
48
	 * value of the supplied parameter <code>enabled</code>.
49
	 * 
50
	 * @param enabled
51
	 */
52
	public void setEnabled(boolean enabled);
53

  
54
	/**
55
	 * Sets the editor page into disabled state and changes the 
56
	 * appearance accordingly. 
57
	 */
58
	void setDisabled();
59
	
60
	/**
61
	 * Sets the editor page into disabled state and changes the 
62
	 * appearance in order to indicate that an error has occurred.  
63
	 */
64
	public void setOnError();
65
	
66
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/MultiPageTaxonEditor.java
1
/**
2
 * Copyright (C) 2007 EDIT
3
 * European Distributed Institute of Taxonomy
4
 * http://www.e-taxonomy.eu
5
 *
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.
8
 */
9

  
10
package eu.etaxonomy.taxeditor.editor;
11

  
12
import java.util.ArrayList;
13
import java.util.List;
14
import java.util.UUID;
15

  
16
import org.eclipse.core.commands.operations.IUndoContext;
17
import org.eclipse.core.commands.operations.UndoContext;
18
import org.eclipse.core.runtime.IProgressMonitor;
19
import org.eclipse.jface.dialogs.MessageDialog;
20
import org.eclipse.ui.IEditorInput;
21
import org.eclipse.ui.IEditorPart;
22
import org.eclipse.ui.IEditorSite;
23
import org.eclipse.ui.PartInitException;
24
import org.eclipse.ui.forms.editor.FormEditor;
25

  
26
import eu.etaxonomy.cdm.api.application.CdmApplicationState;
27
import eu.etaxonomy.cdm.api.application.CdmChangeEvent;
28
import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action;
29
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
30
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
31
import eu.etaxonomy.cdm.model.common.CdmBase;
32
import eu.etaxonomy.cdm.model.name.TaxonName;
33
import eu.etaxonomy.cdm.model.taxon.Taxon;
34
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
35
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
36
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
37
import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;
38
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
39
import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
40
import eu.etaxonomy.taxeditor.editor.name.container.AbstractGroupedContainer;
41
import eu.etaxonomy.taxeditor.model.AbstractUtility;
42
import eu.etaxonomy.taxeditor.model.DataChangeBridge;
43
import eu.etaxonomy.taxeditor.model.IDataChangeBehavior;
44
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
45
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
46
import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData;
47
import eu.etaxonomy.taxeditor.model.IPartContentHasMedia;
48
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
49
import eu.etaxonomy.taxeditor.model.MessagingUtils;
50
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
51

  
52
/**
53
 *
54
 * Generates the tabbed editor with <code>TaxonNameEditor</code> on top and tabs
55
 * for "Descriptions", "Concepts", "Geography", etc.
56
 *
57
 * @author p.ciardelli
58
 * @author n.hoffmann
59
 * @created 15.05.2008
60
 * @version 1.0
61
 */
62
public class MultiPageTaxonEditor extends FormEditor
63
        implements IPartContentHasFactualData, IConversationEnabled, IPostOperationEnabled, IDirtyMarkable,
64
        IPartContentHasDetails, IPartContentHasSupplementalData, ISecuredEditor, IPartContentHasMedia, ITaxonEditor {
65

  
66
    /** Constant <code>ID="eu.etaxonomy.taxeditor.editor.taxon"{trunked}</code> */
67
    public static final String ID = "eu.etaxonomy.taxeditor.editor.taxon"; //$NON-NLS-1$
68

  
69
    private boolean dirty;
70

  
71
    private ConversationHolder conversation;
72
    private IDataChangeBehavior dataChangeBehavior;
73
    private IUndoContext undoContext;
74

  
75
    private TaxonEditorInput input;
76

  
77
    /**
78
     * <p>
79
     * Constructor for MultiPageTaxonEditor.
80
     * </p>
81
     */
82
    public MultiPageTaxonEditor() {
83
        super();
84
        undoContext = new UndoContext();
85

  
86
    }
87

  
88
    /** {@inheritDoc} */
89
    @Override
90
    public void dispose() {
91
        input.dispose();
92
        conversation.unregisterForDataStoreChanges(this);
93
        conversation.close();
94
        super.dispose();
95
    }
96

  
97
    /*
98
     * (non-Javadoc)
99
     *
100
     * @see org.eclipse.ui.forms.editor.FormEditor#addPages()
101
     */
102
    /** {@inheritDoc} */
103
    @Override
104
    protected void addPages() {
105
        input = (TaxonEditorInput) getEditorInput();
106
        conversation = input.getConversationHolder();
107
        conversation.registerForDataStoreChanges(this);
108

  
109
        try {
110
            addPage(Page.NAME.getIndex(), new TaxonNameEditor(this),
111
                    getEditorInput());
112
            // setPageText(Page.NAME.getIndex(), Page.NAME.getTitle());
113

  
114
            // TODO lazy create
115
            // addPage(Page.DESCRIPTIVE.getIndex(), new
116
            // TaxonDescriptionTreeEditor(this), getEditorInput());
117
            // setPageText(Page.DESCRIPTIVE.getIndex(),
118
            // Page.DESCRIPTIVE.getTitle());
119

  
120
            // EditorUtil.showPropertySheet();
121

  
122
        } catch (PartInitException e) {
123
            MessagingUtils.error(getClass(), e);
124
        }
125
    }
126

  
127
    /**
128
     * {@inheritDoc}
129
     */
130
    @Override
131
    protected void pageChange(int newPageIndex) {
132
        if(getCurrentPage()==-1){
133
            return;
134
        }
135
        super.pageChange(newPageIndex);
136
    }
137

  
138
    /** {@inheritDoc} */
139
    @Override
140
    public void doSave(IProgressMonitor monitor) {
141
        monitor.beginTask(Messages.MultiPageTaxonEditor_SAVING_EDITOR, 4);
142
        try {
143
            if (!conversation.isBound()) {
144
                conversation.bind();
145
            }
146
            monitor.worked(1);
147

  
148
            for (IEditorPart editorPage : getPages()) {
149
                if (editorPage instanceof TaxonNameEditor) {
150
                    if (((TaxonNameEditor) editorPage).checkForEmptyNames()) {
151
                        MessageDialog.openWarning(AbstractUtility.getShell(), Messages.MultiPageTaxonEditor_NO_NAME_SPECIFIED,
152
                                Messages.MultiPageTaxonEditor_NO_NAME_SPECIFIED_MESSAGE);
153
                        return;
154
                    }
155
                }
156

  
157
                editorPage.doSave(monitor);
158
                monitor.worked(1);
159
            }
160

  
161
            // commit the conversation and start a new transaction immediately
162

  
163
            input.merge();
164

  
165
            conversation.commit(true);
166
            CdmApplicationState.getCurrentDataChangeService()
167
            .fireChangeEvent(new CdmChangeEvent(Action.Update, input.getTaxonNode() , MultiPageTaxonEditor.class), true);
168
            monitor.worked(1);
169

  
170
            this.setDirty(false);
171
            monitor.worked(1);
172
        } catch (Exception e) {
173
            setFocus();
174
            MessagingUtils.operationDialog(this, e, TaxeditorEditorPlugin.PLUGIN_ID,Messages.MultiPageTaxonEditor_SAVING_TAXON, Messages.MultiPageTaxonEditor_SAVING_TAXON_MESSAGE);
175
            disableEditor(true);
176
        } finally {
177
            monitor.done();
178
        }
179
    }
180

  
181
    private void disableEditor(boolean isOnError) {
182
        for (IMultiPageTaxonEditorPage editorPage : getPages()) {
183
            if(isOnError){
184
                editorPage.setOnError();
185
            }else {
186
                editorPage.setDisabled();
187
            }
188
        }
189

  
190
        conversation.unregisterForDataStoreChanges(this);
191
        conversation.close();
192
        setDirty(false);
193
    }
194

  
195
    private void setDirty(boolean dirty) {
196
        this.dirty = dirty;
197
        firePropertyChange(PROP_DIRTY);
198
    }
199

  
200
    /*
201
     * (non-Javadoc)
202
     *
203
     * @see org.eclipse.ui.part.MultiPageEditorPart#isDirty()
204
     */
205
    /**
206
     * <p>
207
     * isDirty
208
     * </p>
209
     *
210
     * @return a boolean.
211
     */
212
    @Override
213
    public boolean isDirty() {
214
        return dirty;
215
    }
216

  
217
    /*
218
     * (non-Javadoc)
219
     *
220
     * @see org.eclipse.ui.forms.editor.FormEditor#editorDirtyStateChanged()
221
     */
222
    /** {@inheritDoc} */
223
    @Override
224
    public void editorDirtyStateChanged() {
225
        dirty = true;
226
        super.editorDirtyStateChanged();
227
    }
228

  
229
    /**
230
     * {@inheritDoc}
231
     *
232
     * Checks whether nested editors are calling
233
     * <code>firePropertyChange(PROP_DIRTY)</code> to signal an edit has taken
234
     * place before passing property change along to
235
     * <code>super.handlePropertyChange(int propertyId)</code>.
236
     */
237
    /*
238
     * (non-Javadoc)
239
     *
240
     * @see org.eclipse.ui.part.MultiPageEditorPart#handlePropertyChange(int)
241
     */
242
    @Override
243
    protected void handlePropertyChange(int propertyId) {
244
        if (propertyId == PROP_DIRTY) {
245
            setDirty(true);
246
        }
247
        super.handlePropertyChange(propertyId);
248
    }
249

  
250
    /** {@inheritDoc} */
251
    @Override
252
    public void doSaveAs() {
253
    }
254

  
255
    /** {@inheritDoc} */
256
    @Override
257
    public boolean isSaveAsAllowed() {
258
        return false;
259
    }
260

  
261
    /** {@inheritDoc} */
262
    @Override
263
    public void init(IEditorSite site, IEditorInput input)
264
            throws PartInitException {
265

  
266
        if (!(input instanceof TaxonEditorInput)) {
267
            throw new PartInitException(
268
                    Messages.MultiPageTaxonEditor_INVALID_INPUT);
269
        }
270

  
271
        this.input = (TaxonEditorInput) input;
272

  
273

  
274
        // try {
275
        // // Listen for name changes,
276
        // // change tab for this taxon editor accordingly
277
        // getTaxon().addPropertyChangeListener("name",
278
        // new PropertyChangeListener() {
279
        // public void propertyChange(PropertyChangeEvent e) {
280
        // setPartName();
281
        // }
282
        // });
283
        // } catch (NullPointerException e) {
284
        // EditorUtil.warn(getClass(),
285
        // "Caught an NPE while initing an editor. This is most " +
286
        // "likely due to the unsuccesful attempt to restore the former " +
287
        // "state of the application. We ignore this because the workbench " +
288
        // "will simply be reset.");
289
        // }
290
        setPartName();
291

  
292
        super.init(site, input);
293
    }
294

  
295
    /**
296
     * Calls <code>MultiPageEditorPart.setPartName(String partName)</code> with
297
     * text appropriate to the state of the taxon: any taxon that has been saved
298
     * will by necessity have a name to display; a new taxon should display
299
     * "New taxon" in the editor tab.
300
     */
301
    protected void setPartName() {
302

  
303
        String partName = null;
304
        TaxonName name = getTaxon().getName();
305

  
306
        if (name != null) {
307
            partName = name.getTitleCache();
308
        }
309

  
310
        if (partName == null || partName.equals("")) { //$NON-NLS-1$
311
            partName = (Messages.MultiPageTaxonEditor_NEW_TAXON);
312
        }
313

  
314
        setPartName(partName);
315
    }
316

  
317
    /**
318
     * {@inheritDoc}
319
     *
320
     * Editor pages call this in their postOperation to notify the
321
     * MultiPageTaxonEditor of unsaved changes
322
     */
323
    @Override
324
    public void changed(Object element) {
325
        // setDirty(true);
326
        // if the attribute is null then do not set the dirty flag -> hotfix for the problem that for tasks done in service methods the changes are saved automatically
327
        if (element != null){
328
            dirty = true;
329
            super.editorDirtyStateChanged();
330
        }
331

  
332
        if (element instanceof TaxonBase) {
333
            TaxonNameEditor page = (TaxonNameEditor) getPage(Page.NAME);
334
            AbstractGroupedContainer container = page.getContainer((TaxonBase) element);
335
            if (container != null) {
336
                container.refresh();
337
            }
338
        }
339
        if (element instanceof TaxonRelationship) {
340
            TaxonNameEditor page = (TaxonNameEditor) getPage(Page.NAME);
341
            AbstractGroupedContainer container = page.getContainer(((TaxonRelationship) element).getFromTaxon());
342
            if (container != null) {
343
                container.refresh();
344
            }
345
        }
346
        //refresh part title
347
        //TODO: refresh taxon node in taxon navigator
348
        setPartName();
349
    }
350

  
351
    /* (non-Javadoc)
352
     * @see eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider#forceDirty()
353
     */
354
    @Override
355
    public void forceDirty() {
356
        changed(null);
357
    }
358

  
359
    /**
360
     * The accepted taxon that is the input for this editor
361
     *
362
     * @return the accepted taxon
363
     */
364
    @Override
365
    public Taxon getTaxon() {
366
        return input.getTaxon();
367
    }
368

  
369
    /*
370
     * (non-Javadoc)
371
     *
372
     * @see
373
     * eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder
374
     * ()
375
     */
376
    /**
377
     * <p>
378
     * getConversationHolder
379
     * </p>
380
     *
381
     * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
382
     *         object.
383
     */
384
    @Override
385
    public ConversationHolder getConversationHolder() {
386
        return conversation;
387
    }
388

  
389
    /**
390
     * <p>
391
     * setConversationHolder
392
     * </p>
393
     *
394
     * @param conversation
395
     *            a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
396
     *            object.
397
     */
398
    public void setConversationHolder(ConversationHolder conversation) {
399
        this.conversation = conversation;
400
    }
401

  
402
    /**
403
     * <p>
404
     * Getter for the field <code>undoContext</code>.
405
     * </p>
406
     *
407
     * @return a {@link org.eclipse.core.commands.operations.IUndoContext}
408
     *         object.
409
     */
410
    public IUndoContext getUndoContext() {
411
        return undoContext;
412
    }
413

  
414
    /**
415
     * <p>
416
     * Setter for the field <code>undoContext</code>.
417
     * </p>
418
     *
419
     * @param undoContext
420
     *            a {@link org.eclipse.core.commands.operations.IUndoContext}
421
     *            object.
422
     */
423
    public void setUndoContext(IUndoContext undoContext) {
424
        this.undoContext = undoContext;
425
    }
426

  
427
    /** {@inheritDoc} */
428
    @Override
429
    public void setFocus() {
430
        // logger.warn("Setting focus to editor");
431
        // bind the conversation
432
        getConversationHolder().bind();
433
        input.bind();
434
        // pass focus to the active editor page
435
        getActiveEditor().setFocus();
436
    }
437

  
438
    /*
439
     * (non-Javadoc)
440
     *
441
     * @see
442
     * eu.etaxonomy.cdm.persistence.hibernate.ICdmPostCrudObserver#update(eu
443
     * .etaxonomy.cdm.persistence.hibernate.CdmCrudEvent)
444
     */
445
    /** {@inheritDoc} */
446
    @Override
447
    public void update(CdmDataChangeMap events) {
448
        if (dataChangeBehavior == null) {
449
            dataChangeBehavior = new MultiPageTaxonEditorDataChangeBehaviour(this);
450
        }
451

  
452
        DataChangeBridge.handleDataChange(events, dataChangeBehavior);
453
    }
454

  
455
    /*
456
     * (non-Javadoc)
457
     *
458
     * @see
459
     * eu.etaxonomy.taxeditor.store.operations.IPostOperationEnabled#postOperation
460
     * ()
461
     */
462
    /** {@inheritDoc} */
463
    @Override
464
    public boolean postOperation(CdmBase objectAffectedByOperation) {
465
    		setDirty(true);
466

  
467
        for (IEditorPart editor : this.getPages()) {
468
            if (editor instanceof IPostOperationEnabled) {
469
                ((IPostOperationEnabled) editor).postOperation(objectAffectedByOperation);
470
            } else {
471
                MessagingUtils.warn(getClass(), Messages.MultiPageTaxonEditor_POST_OP_NOT_ENABLED + editor);
472
            }
473
        }
474
        MessagingUtils.warn(getClass(), Messages.MultiPageTaxonEditor_POST_OP_CALLED);
475

  
476
        return false;
477
    }
478

  
479
    /**
480
     * Returns an <code>IEditorPart</code> implementation by type
481
     *
482
     * @param page
483
     *            the page type
484
     * @return a {@link eu.etaxonomy.taxeditor.editor.IMultiPageTaxonEditorPage}
485
     *         object.
486
     */
487
    public IMultiPageTaxonEditorPage getPage(Page page) {
488
        for (IEditorPart editor : this.getPages()) {
489
            if (editor.getClass().equals(page.getClazz())) {
490
                return (IMultiPageTaxonEditorPage) editor;
491
            }
492
        }
493
        return null;
494
    }
495

  
496
    /**
497
     * Return a list of <code>AbstractTaxonEditor</code>s registered with this
498
     * <code>MultiPageTaxonEditor</code>.
499
     *
500
     * @return a {@link java.util.List} object.
501
     */
502
    public List<IMultiPageTaxonEditorPage> getPages() {
503
        ArrayList<IMultiPageTaxonEditorPage> editors = new ArrayList<IMultiPageTaxonEditorPage>();
504
        for (int i = 0; i < this.getPageCount(); i++) {
505

  
506
            editors.add((IMultiPageTaxonEditorPage) this.getEditor(i));
507
        }
508
        return editors;
509
    }
510

  
511
    /**
512
     * Refreshes a certain page of the MultipageTaxonEditor
513
     *
514
     * @param page
515
     *            a {@link eu.etaxonomy.taxeditor.editor.Page} object.
516
     * @return a boolean.
517
     */
518
    public boolean redraw(Page page) {
519
        return redraw(page, true);
520
    }
521

  
522
    /**
523
     * Refreshes a certain page of the MultipageTaxonEditor and sets focus to
524
     * that page
525
     *
526
     * @param page
527
     *            a {@link eu.etaxonomy.taxeditor.editor.Page} object.
528
     * @param focus
529
     *            a boolean.
530
     * @return a boolean.
531
     */
532
    public boolean redraw(Page page, boolean focus) {
533
        IMultiPageTaxonEditorPage editorPage = getPage(page);
534
        return editorPage != null && editorPage.redraw(focus);
535
    }
536

  
537
    /**
538
     * <p>
539
     * onComplete
540
     * </p>
541
     *
542
     * @return a boolean.
543
     */
544
    @Override
545
    public boolean onComplete() {
546
        return false;
547
    }
548

  
549
    /**
550
     * Reloads the data for this
551
     */
552
    public void reload() {
553
        if (isDirty()) {
554
            MessagingUtils.warningDialog(Messages.MultiPageTaxonEditor_UNSAVED_DATA, getClass(), Messages.MultiPageTaxonEditor_UNSAVED_DATA_MESSAGE);
555
        } else {
556
            TaxonEditorInput input = (TaxonEditorInput) getEditorInput();
557

  
558
            UUID uuid = input.getTaxonNode().getUuid();
559

  
560
            conversation.clear();
561

  
562
            try {
563
                TaxonEditorInput newInput = TaxonEditorInput.NewInstance(uuid);
564
                setInput(newInput);
565
                for (IMultiPageTaxonEditorPage editorPart : getPages()) {
566
                    editorPart.redraw();
567
                }
568
            } catch (Exception e) {
569
                MessagingUtils.messageDialog(Messages.MultiPageTaxonEditor_REFRESH_ERROR, getClass(), Messages.MultiPageTaxonEditor_REFRESH_ERROR_MESSAGE, e);
570
            }
571
        }
572
    }
573

  
574
    @Override
575
    public String toString() {
576
        return String.format("%s[%s]", this.getClass().getSimpleName(), getEditorInput()); //$NON-NLS-1$
577
    }
578

  
579
    @Override
580
    public boolean permissionsSatisfied() {
581
        IEditorPart activeEditor = getActiveEditor();
582
        if(activeEditor != null && ISecuredEditor.class.isAssignableFrom(activeEditor.getClass())){
583
            return ((ISecuredEditor)activeEditor).permissionsSatisfied();
584
        }
585
        return true;
586
    }
587

  
588
    /* (non-Javadoc)
589
     * @see eu.etaxonomy.taxeditor.model.IPartContentHasMedia#canAttachMedia()
590
     */
591
    @Override
592
    public boolean canAttachMedia() {
593
        return true;
594
    }
595

  
596
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/MultiPageTaxonEditorAdapterFactory.java
1
/**
2
 * 
3
 */
4
package eu.etaxonomy.taxeditor.editor;
5

  
6
import org.eclipse.core.runtime.IAdapterFactory;
7

  
8
/**
9
 * TODO remove this class
10
 *
11
 * @author n.hoffmann
12
 * @version $Id: $
13
 */
14
public class MultiPageTaxonEditorAdapterFactory implements IAdapterFactory {
15

  
16
	/* (non-Javadoc)
17
	 * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
18
	 */
19
	/** {@inheritDoc} */
20
	public Object getAdapter(Object adaptableObject, Class adapterType) {
21
		
22
//		if((adaptableObject instanceof MultiPageTaxonEditor)  && adapterType.equals(DuplicateArbitrator.class)){
23
//			return null;// new DuplicateArbitrator((MultiPageTaxonEditor) adaptableObject);
24
//		}
25
		
26
		return null;
27
	}
28

  
29
	/* (non-Javadoc)
30
	 * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
31
	 */
32
	/**
33
	 * <p>getAdapterList</p>
34
	 *
35
	 * @return an array of {@link java.lang.Class} objects.
36
	 */
37
	public Class[] getAdapterList() {
38
		return new Class[]{
39
//				DuplicateArbitrator.class
40
		};
41
	}
42

  
43
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/MultiPageTaxonEditorDataChangeBehaviour.java
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
4
* http://www.e-taxonomy.eu
5
* 
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.
8
*/
9

  
10
package eu.etaxonomy.taxeditor.editor;
11

  
12
import java.util.Vector;
13

  
14
import org.apache.log4j.Logger;
15

  
16
import eu.etaxonomy.cdm.model.name.TaxonName;
17
import eu.etaxonomy.cdm.model.taxon.Synonym;
18
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
19
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeEvent;
20
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeEvent.EventType;
21
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
22
import eu.etaxonomy.taxeditor.model.AbstractDataChangeBehaviour;
23
import eu.etaxonomy.taxeditor.model.IDataChangeBehavior;
24

  
25
/**
26
 * Implementation if {@link eu.etaxonomy.taxeditor.store.model.IDataChangeBehaviour}
27
 * for the {@link eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor}.
28
 *
29
 * TODO make this class a bean and thus configurable by Spring
30
 *
31
 * @author n.hoffmann
32
 * @created 01.04.2009
33
 * @version 1.0
34
 */
35
public class MultiPageTaxonEditorDataChangeBehaviour extends AbstractDataChangeBehaviour implements
36
		IDataChangeBehavior {
37
	private static final Logger logger = Logger
38
			.getLogger(MultiPageTaxonEditorDataChangeBehaviour.class);
39

  
40
	private MultiPageTaxonEditor source;
41

  
42
	private TaxonEditorInput input;
43
	
44
	/**
45
	 * <p>Constructor for MultiPageTaxonEditorDataChangeBehaviour.</p>
46
	 *
47
	 * @param multiPageTaxonEditor a {@link eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor} object.
48
	 */
49
	public MultiPageTaxonEditorDataChangeBehaviour(
50
			MultiPageTaxonEditor multiPageTaxonEditor) {
51
		source = multiPageTaxonEditor;
52
	}
53

  
54
	/* (non-Javadoc)
55
	 * @see eu.etaxonomy.taxeditor.store.model.IDataChangeBehavior#reactOnDataChange()
56
	 */
57
	/** {@inheritDoc} */
58
	public void reactOnDataChange(CdmDataChangeMap changeEvents) {
59
		input = (TaxonEditorInput) source.getEditorInput();
60
		
61
		// I don't know when this happens but ...
62
		if(input.getTaxon() == null)
63
			return;
64
		
65
		if(changeEvents.sizeByEventType(EventType.UPDATE) > 0){
66
			reactOnUpdate(changeEvents.getEvents(EventType.UPDATE));
67
		}
68
		if(changeEvents.sizeByEventType(EventType.INSERT) > 0){
69
			reactOnInsert(changeEvents.getEvents(EventType.INSERT));
70
		}
71
		if(changeEvents.sizeByEventType(EventType.DELETE) > 0){
72
			reactOnDelete(changeEvents.getEvents(EventType.DELETE));
73
		}
74
	}
75
	
76
	
77
	/** {@inheritDoc} */
78
	//we do not really need this anymore as closing the editors is 
79
	//now run before the delete operation in DeleteHandler
80
	@Override
81
	public void reactOnDelete(Vector<CdmDataChangeEvent> events){
82
		for(CdmDataChangeEvent event : events){
83
			// close open editors
84
			if((event.getEntity() instanceof TaxonNode) 
85
					&& input.getTaxonNode().equals(event.getEntity())){
86
				//EditorUtil.close(source);
87
				logger.debug("Closing open editor for deleted taxon."); //$NON-NLS-1$
88
			}
89
		}
90
	}
91
	
92
	/** {@inheritDoc} */
93
	@Override
94
	public void reactOnUpdate(Vector<CdmDataChangeEvent> events){
95

  
96
		for(CdmDataChangeEvent event : events){
97
			
98
			// update editor title
99
			if(event.getEntity() instanceof TaxonName){
100
				if(input.getTaxon().getName().equals(event.getEntity())){
101
					// set the name of the editor window
102
					source.setPartName();
103
					logger.debug("Updating title of taxons editor."); //$NON-NLS-1$
104
				}
105
			}
106
			// TODO other stuff to happen
107
			
108
		}
109
	}
110
	
111
	/** {@inheritDoc} */
112
	@Override
113
	public void reactOnInsert(Vector<CdmDataChangeEvent> events){
114
		boolean doRedraw = false;
115
		for(CdmDataChangeEvent event : events){
116
			// refresh on synonym changes
117
			if(input.getTaxon().hasSynonyms() && event.getEntity() instanceof Synonym){
118
				Synonym synonym = (Synonym) event.getEntity();
119
				
120
				if(synonym.isSynonymOf(input.getTaxon())){
121
					doRedraw = true;
122
					break;
123
				}
124
			}
125
		}
126
//		if(doRedraw)
127
//			source.redraw(Page.NAME);
128
	}
129
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/Page.java
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
4
* http://www.e-taxonomy.eu
5
* 
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.
8
*/
9

  
10
package eu.etaxonomy.taxeditor.editor;
11

  
12
import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
13

  
14
/**
15
 * <p>Page class.</p>
16
 *
17
 * @author n.hoffmann
18
 * @created 30.04.2009
19
 * @version 1.0
20
 */
21
public enum Page {
22
	NAME ("Name", TaxonNameEditor.class, 0); //$NON-NLS-1$
23
	
24
	private String title;
25
	private Class<?> clazz;
26
	private int index;
27
	
28
	Page(String title, Class<?> clazz, int index){
29
		this.title = title;
30
		this.clazz = clazz;
31
		this.index = index;
32
	}
33
	
34
	/**
35
	 * <p>Getter for the field <code>title</code>.</p>
36
	 *
37
	 * @return a {@link java.lang.String} object.
38
	 */
39
	public String getTitle(){
40
		return this.title;
41
	}
42
	
43
	/**
44
	 * <p>Getter for the field <code>clazz</code>.</p>
45
	 *
46
	 * @return a {@link java.lang.Class} object.
47
	 */
48
	public Class<?> getClazz(){
49
		return this.clazz;
50
	}
51
	
52
	/**
53
	 * <p>Getter for the field <code>index</code>.</p>
54
	 *
55
	 * @return a int.
56
	 */
57
	public int getIndex(){
58
		return this.index;
59
	}
60
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/SaveAllHandler.java
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
4
* http://www.e-taxonomy.eu
5
* 
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.
8
*/
9

  
10
package eu.etaxonomy.taxeditor.editor.handler;
11

  
12
import org.apache.log4j.Logger;
13
import org.eclipse.core.commands.AbstractHandler;
14
import org.eclipse.core.commands.ExecutionEvent;
15
import org.eclipse.core.commands.ExecutionException;
16
import org.eclipse.core.commands.IHandler;
17
import org.eclipse.ui.IEditorPart;
18

  
19
import eu.etaxonomy.taxeditor.editor.EditorUtil;
20

  
21
/**
22
 * <p>SaveAllHandler class.</p>
23
 *
24
 * @author n.hoffmann
25
 * @created 06.02.2009
26
 * @version 1.0
27
 */
28
public class SaveAllHandler extends AbstractHandler implements IHandler {
29
	private static final Logger logger = Logger.getLogger(SaveAllHandler.class);
30

  
31
	/* (non-Javadoc)
32
	 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
33
	 */
34
	/** {@inheritDoc} */
35
	public Object execute(ExecutionEvent event) throws ExecutionException {
36
		logger.debug("Handler called: " + this.getClass().getCanonicalName()); //$NON-NLS-1$
37
		
38
		// TODO what is this for?
39
		EditorUtil.setSaving(true);
40
		
41
		for (IEditorPart editor : EditorUtil.getOpenEditors()) {
42
			if (editor.isDirty()) {
43
				editor.doSave(EditorUtil.getMonitor());
44
			}
45
		}
46
		
47
		EditorUtil.setSaving(false);
48
		// TODO: delete undoHistory
49
		return null;
50
	}
51
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/SaveTaxonHandler.java
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
4
* http://www.e-taxonomy.eu
5
* 
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.
8
*/
9

  
10
package eu.etaxonomy.taxeditor.editor.handler;
11

  
12
import org.apache.log4j.Logger;
13
import org.eclipse.core.commands.AbstractHandler;
14
import org.eclipse.core.commands.ExecutionEvent;
15
import org.eclipse.core.commands.ExecutionException;
16

  
17
import eu.etaxonomy.taxeditor.editor.EditorUtil;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)