ref #6190 removing svn property place holder in first line of code - java files
[taxeditor.git] / eu.etaxonomy.taxeditor.bulkeditor / src / main / java / eu / etaxonomy / taxeditor / bulkeditor / BulkEditorUtil.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.bulkeditor;
11
12 import org.eclipse.core.commands.operations.IOperationHistory;
13 import org.eclipse.core.commands.operations.IUndoContext;
14 import org.eclipse.core.runtime.Assert;
15 import org.eclipse.ui.IEditorInput;
16 import org.eclipse.ui.IEditorPart;
17 import org.eclipse.ui.PartInitException;
18
19 import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
20 import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
21 import eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInputType;
22 import eu.etaxonomy.taxeditor.bulkeditor.internal.TaxeditorBulkeditorPlugin;
23 import eu.etaxonomy.taxeditor.model.AbstractUtility;
24
25 /**
26 * <p>BulkEditorUtil class.</p>
27 *
28 * @author n.hoffmann
29 * @created Mar 12, 2010
30 * @version 1.0
31 */
32 public class BulkEditorUtil extends AbstractUtility{
33
34 /**
35 * Opens a new editor window with the given input
36 *
37 * @param input
38 * @param editorId
39 * @return
40 * @throws PartInitException
41 */
42 private static IEditorPart open(IEditorInput input, String editorId)
43 throws PartInitException {
44 return getActivePage().openEditor(input, editorId);
45 }
46
47 /**
48 * <p>openEmptyEditor</p>
49 *
50 * @param inputType a {@link eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInputTypeValues.BulkEditorInputType} object.
51 * @throws org.eclipse.ui.PartInitException if any.
52 */
53 public static void openEmptyEditor(BulkEditorInputType inputType) throws PartInitException{
54 AbstractBulkEditorInput editorInput = AbstractBulkEditorInput.NewInstance(inputType);
55 open(editorInput, BulkEditor.ID);
56 }
57
58 /**
59 * <p>openEditor</p>
60 *
61 * @param entity a {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity} object.
62 * @throws org.eclipse.ui.PartInitException if any.
63 */
64 public static void openEditor(IdentifiableEntity entity) throws PartInitException{
65 Assert.isNotNull(entity, "Entity must not be null");
66 AbstractBulkEditorInput editorInput = AbstractBulkEditorInput.NewInstance(entity);
67 open(editorInput, BulkEditor.ID);
68 }
69
70 /**
71 * <p>getPluginId</p>
72 *
73 * @return a {@link java.lang.String} object.
74 */
75 public static String getPluginId(){
76 return TaxeditorBulkeditorPlugin.PLUGIN_ID;
77 }
78
79 /**
80 * <p>getUndoContext</p>
81 *
82 * @return a {@link org.eclipse.core.commands.operations.IUndoContext} object.
83 */
84 public static IUndoContext getUndoContext(){
85 return IOperationHistory.GLOBAL_UNDO_CONTEXT;
86 }
87 }