1 |
c949f813
|
n.hoffmann
|
// $Id$
|
2 |
|
|
/**
|
3 |
|
|
* Copyright (C) 2007 EDIT
|
4 |
|
|
* European Distributed Institute of Taxonomy
|
5 |
|
|
* http://www.e-taxonomy.eu
|
6 |
|
|
*
|
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.
|
9 |
|
|
*/
|
10 |
|
|
|
11 |
|
|
package eu.etaxonomy.taxeditor.bulkeditor;
|
12 |
|
|
|
13 |
db5e366d
|
n.hoffmann
|
import org.eclipse.core.commands.operations.IOperationHistory;
|
14 |
|
|
import org.eclipse.core.commands.operations.IUndoContext;
|
15 |
c949f813
|
n.hoffmann
|
import org.eclipse.core.runtime.Assert;
|
16 |
|
|
import org.eclipse.ui.IEditorInput;
|
17 |
|
|
import org.eclipse.ui.IEditorPart;
|
18 |
|
|
import org.eclipse.ui.PartInitException;
|
19 |
|
|
|
20 |
|
|
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
|
21 |
|
|
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
|
22 |
c38375d8
|
n.hoffmann
|
import eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInputType;
|
23 |
74b9f670
|
n.hoffmann
|
import eu.etaxonomy.taxeditor.bulkeditor.internal.TaxeditorBulkeditorPlugin;
|
24 |
c949f813
|
n.hoffmann
|
import eu.etaxonomy.taxeditor.model.AbstractUtility;
|
25 |
|
|
|
26 |
|
|
/**
|
27 |
3be6ef3e
|
n.hoffmann
|
* <p>BulkEditorUtil class.</p>
|
28 |
|
|
*
|
29 |
c949f813
|
n.hoffmann
|
* @author n.hoffmann
|
30 |
|
|
* @created Mar 12, 2010
|
31 |
|
|
* @version 1.0
|
32 |
|
|
*/
|
33 |
|
|
public class BulkEditorUtil extends AbstractUtility{
|
34 |
|
|
|
35 |
|
|
/**
|
36 |
|
|
* Opens a new editor window with the given input
|
37 |
|
|
*
|
38 |
|
|
* @param input
|
39 |
|
|
* @param editorId
|
40 |
|
|
* @return
|
41 |
|
|
* @throws PartInitException
|
42 |
|
|
*/
|
43 |
|
|
private static IEditorPart open(IEditorInput input, String editorId)
|
44 |
|
|
throws PartInitException {
|
45 |
|
|
return getActivePage().openEditor(input, editorId);
|
46 |
|
|
}
|
47 |
|
|
|
48 |
3be6ef3e
|
n.hoffmann
|
/**
|
49 |
|
|
* <p>openEmptyEditor</p>
|
50 |
|
|
*
|
51 |
725cf795
|
n.hoffmann
|
* @param inputType a {@link eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInputTypeValues.BulkEditorInputType} object.
|
52 |
3be6ef3e
|
n.hoffmann
|
* @throws org.eclipse.ui.PartInitException if any.
|
53 |
|
|
*/
|
54 |
c949f813
|
n.hoffmann
|
public static void openEmptyEditor(BulkEditorInputType inputType) throws PartInitException{
|
55 |
|
|
AbstractBulkEditorInput editorInput = AbstractBulkEditorInput.NewInstance(inputType);
|
56 |
|
|
open(editorInput, BulkEditor.ID);
|
57 |
|
|
}
|
58 |
|
|
|
59 |
3be6ef3e
|
n.hoffmann
|
/**
|
60 |
|
|
* <p>openEditor</p>
|
61 |
|
|
*
|
62 |
|
|
* @param entity a {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity} object.
|
63 |
|
|
* @throws org.eclipse.ui.PartInitException if any.
|
64 |
|
|
*/
|
65 |
c949f813
|
n.hoffmann
|
public static void openEditor(IdentifiableEntity entity) throws PartInitException{
|
66 |
|
|
Assert.isNotNull(entity, "Entity must not be null");
|
67 |
|
|
AbstractBulkEditorInput editorInput = AbstractBulkEditorInput.NewInstance(entity);
|
68 |
|
|
open(editorInput, BulkEditor.ID);
|
69 |
|
|
}
|
70 |
74b9f670
|
n.hoffmann
|
|
71 |
3be6ef3e
|
n.hoffmann
|
/**
|
72 |
|
|
* <p>getPluginId</p>
|
73 |
|
|
*
|
74 |
|
|
* @return a {@link java.lang.String} object.
|
75 |
|
|
*/
|
76 |
b9a0d300
|
l.morris
|
public static String getPluginId(){
|
77 |
74b9f670
|
n.hoffmann
|
return TaxeditorBulkeditorPlugin.PLUGIN_ID;
|
78 |
|
|
}
|
79 |
db5e366d
|
n.hoffmann
|
|
80 |
|
|
/**
|
81 |
|
|
* <p>getUndoContext</p>
|
82 |
|
|
*
|
83 |
|
|
* @return a {@link org.eclipse.core.commands.operations.IUndoContext} object.
|
84 |
|
|
*/
|
85 |
|
|
public static IUndoContext getUndoContext(){
|
86 |
|
|
return IOperationHistory.GLOBAL_UNDO_CONTEXT;
|
87 |
|
|
}
|
88 |
c949f813
|
n.hoffmann
|
}
|