Project

General

Profile

Download (2.59 KB) Statistics
| Branch: | Tag: | Revision:
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.eclipse.core.commands.operations.IOperationHistory;
14
import org.eclipse.core.commands.operations.IUndoContext;
15
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
import eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInputType;
23
import eu.etaxonomy.taxeditor.bulkeditor.internal.TaxeditorBulkeditorPlugin;
24
import eu.etaxonomy.taxeditor.model.AbstractUtility;
25

    
26
/**
27
 * <p>BulkEditorUtil class.</p>
28
 *
29
 * @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
	/**
49
	 * <p>openEmptyEditor</p>
50
	 *
51
	 * @param inputType a {@link eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInputTypeValues.BulkEditorInputType} object.
52
	 * @throws org.eclipse.ui.PartInitException if any.
53
	 */
54
	public static void openEmptyEditor(BulkEditorInputType inputType) throws PartInitException{
55
		AbstractBulkEditorInput editorInput = AbstractBulkEditorInput.NewInstance(inputType);
56
		open(editorInput, BulkEditor.ID);
57
	}
58
	
59
	/**
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
	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
	
71
	/**
72
	 * <p>getPluginId</p>
73
	 *
74
	 * @return a {@link java.lang.String} object.
75
	 */
76
	public static String getPluginId(){
77
		return TaxeditorBulkeditorPlugin.PLUGIN_ID;
78
	}
79
	
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
}
(7-7/10)