Revision 1cb71588
Added by Patrick Plitzner almost 7 years ago
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditorUtil.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 |
*/ |
... | ... | |
11 | 11 |
|
12 | 12 |
import org.eclipse.core.commands.operations.IOperationHistory; |
13 | 13 |
import org.eclipse.core.commands.operations.IUndoContext; |
14 |
import org.eclipse.core.runtime.Assert; |
|
15 | 14 |
import org.eclipse.ui.IEditorInput; |
16 | 15 |
import org.eclipse.ui.IEditorPart; |
17 | 16 |
import org.eclipse.ui.PartInitException; |
... | ... | |
21 | 20 |
import eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInputType; |
22 | 21 |
import eu.etaxonomy.taxeditor.bulkeditor.internal.TaxeditorBulkeditorPlugin; |
23 | 22 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
23 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
|
24 | 24 |
|
25 | 25 |
/** |
26 | 26 |
* <p>BulkEditorUtil class.</p> |
... | ... | |
30 | 30 |
* @version 1.0 |
31 | 31 |
*/ |
32 | 32 |
public class BulkEditorUtil extends AbstractUtility{ |
33 |
|
|
33 |
|
|
34 | 34 |
/** |
35 | 35 |
* Opens a new editor window with the given input |
36 |
*
|
|
36 |
* |
|
37 | 37 |
* @param input |
38 | 38 |
* @param editorId |
39 |
* @return
|
|
39 |
* @return |
|
40 | 40 |
* @throws PartInitException |
41 | 41 |
*/ |
42 | 42 |
private static IEditorPart open(IEditorInput input, String editorId) |
43 | 43 |
throws PartInitException { |
44 | 44 |
return getActivePage().openEditor(input, editorId); |
45 | 45 |
} |
46 |
|
|
46 |
|
|
47 | 47 |
/** |
48 | 48 |
* <p>openEmptyEditor</p> |
49 | 49 |
* |
... | ... | |
54 | 54 |
AbstractBulkEditorInput editorInput = AbstractBulkEditorInput.NewInstance(inputType); |
55 | 55 |
open(editorInput, BulkEditor.ID); |
56 | 56 |
} |
57 |
|
|
57 |
|
|
58 | 58 |
/** |
59 | 59 |
* <p>openEditor</p> |
60 | 60 |
* |
... | ... | |
62 | 62 |
* @throws org.eclipse.ui.PartInitException if any. |
63 | 63 |
*/ |
64 | 64 |
public static void openEditor(IdentifiableEntity entity) throws PartInitException{ |
65 |
Assert.isNotNull(entity, "Entity must not be null"); |
|
65 |
if(entity==null){ |
|
66 |
MessagingUtils.errorDialog("Entity does not exist", BulkEditorUtil.class, "The entity does not exist in the data base. Maybe it has been deleted.", TaxeditorBulkeditorPlugin.PLUGIN_ID, null, false, false); |
|
67 |
return; |
|
68 |
} |
|
66 | 69 |
AbstractBulkEditorInput editorInput = AbstractBulkEditorInput.NewInstance(entity); |
67 | 70 |
open(editorInput, BulkEditor.ID); |
68 | 71 |
} |
69 |
|
|
72 |
|
|
70 | 73 |
/** |
71 | 74 |
* <p>getPluginId</p> |
72 | 75 |
* |
... | ... | |
75 | 78 |
public static String getPluginId(){ |
76 | 79 |
return TaxeditorBulkeditorPlugin.PLUGIN_ID; |
77 | 80 |
} |
78 |
|
|
81 |
|
|
79 | 82 |
/** |
80 | 83 |
* <p>getUndoContext</p> |
81 | 84 |
* |
Also available in: Unified diff
Fix potential NPE when opening entities that have already been deleted