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