Revision 56fbcef9
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditorUtil.java | ||
---|---|---|
11 | 11 |
|
12 | 12 |
import org.eclipse.core.commands.operations.IOperationHistory; |
13 | 13 |
import org.eclipse.core.commands.operations.IUndoContext; |
14 |
import org.eclipse.ui.IEditorInput; |
|
15 |
import org.eclipse.ui.IEditorPart; |
|
16 |
import org.eclipse.ui.PartInitException; |
|
17 | 14 |
|
18 |
import eu.etaxonomy.cdm.model.common.IdentifiableEntity; |
|
19 |
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput; |
|
20 |
import eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInputType; |
|
21 | 15 |
import eu.etaxonomy.taxeditor.bulkeditor.internal.TaxeditorBulkeditorPlugin; |
22 | 16 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
23 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
|
24 | 17 |
|
25 | 18 |
/** |
26 | 19 |
* <p>BulkEditorUtil class.</p> |
... | ... | |
31 | 24 |
*/ |
32 | 25 |
public class BulkEditorUtil extends AbstractUtility{ |
33 | 26 |
|
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 |
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 |
} |
|
69 |
AbstractBulkEditorInput editorInput = AbstractBulkEditorInput.NewInstance(entity); |
|
70 |
open(editorInput, BulkEditor.ID); |
|
71 |
} |
|
72 | 27 |
|
73 | 28 |
/** |
74 | 29 |
* <p>getPluginId</p> |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java | ||
---|---|---|
23 | 23 |
import org.eclipse.jface.viewers.IStructuredSelection; |
24 | 24 |
import org.eclipse.jface.viewers.TreeNode; |
25 | 25 |
import org.eclipse.swt.widgets.Shell; |
26 |
import org.eclipse.ui.IEditorInput; |
|
27 | 26 |
import org.eclipse.ui.IEditorPart; |
28 |
import org.eclipse.ui.PartInitException; |
|
29 | 27 |
import org.eclipse.ui.handlers.HandlerUtil; |
30 | 28 |
|
31 | 29 |
import eu.etaxonomy.cdm.api.service.ITaxonService; |
... | ... | |
36 | 34 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
37 | 35 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
38 | 36 |
import eu.etaxonomy.taxeditor.editor.e4.TaxonEditorInputE4; |
39 |
import eu.etaxonomy.taxeditor.editor.group.authority.CdmAuthorityEditor; |
|
40 |
import eu.etaxonomy.taxeditor.editor.group.authority.CdmAuthorityEditorInput; |
|
41 | 37 |
import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin; |
42 |
import eu.etaxonomy.taxeditor.editor.key.KeyEditor; |
|
43 |
import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyEditorInput; |
|
44 | 38 |
import eu.etaxonomy.taxeditor.editor.l10n.Messages; |
45 | 39 |
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4; |
46 |
import eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditor; |
|
47 |
import eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditorInput; |
|
48 | 40 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
49 | 41 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
50 | 42 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
... | ... | |
60 | 52 |
|
61 | 53 |
private static boolean isSaving = false; |
62 | 54 |
|
63 |
/** |
|
64 |
* Opens a new editor window with the given input |
|
65 |
* |
|
66 |
* @param input |
|
67 |
* @param editorId |
|
68 |
* @return |
|
69 |
* @return |
|
70 |
* @throws PartInitException |
|
71 |
*/ |
|
72 |
private static IEditorPart open(final IEditorInput input, |
|
73 |
final String editorId) throws PartInitException { |
|
74 |
IEditorPart editor = getActivePage().openEditor(input, editorId); |
|
75 |
if(input != null && |
|
76 |
editor.getEditorInput() != null && |
|
77 |
input != editor.getEditorInput() && |
|
78 |
input instanceof CdmEntitySessionInput) { |
|
79 |
((CdmEntitySessionInput)input).dispose(); |
|
80 |
} |
|
81 |
return editor; |
|
82 |
} |
|
83 |
|
|
84 |
public static void open(PolytomousKeyEditorInput input) |
|
85 |
throws PartInitException { |
|
86 |
open(input, KeyEditor.ID); |
|
87 |
} |
|
88 |
|
|
89 |
public static void open(CdmAuthorityEditorInput input) |
|
90 |
throws PartInitException { |
|
91 |
open(input, CdmAuthorityEditor.ID); |
|
92 |
} |
|
93 |
|
|
94 |
/** |
|
95 |
* Opens a new ChecklistView for the given input |
|
96 |
* @param input a {@link ChecklistEditorInput} representing the selected checklist |
|
97 |
* @throws PartInitException |
|
98 |
*/ |
|
99 |
public static void open(ChecklistEditorInput input) |
|
100 |
throws PartInitException { |
|
101 |
open(input, ChecklistEditor.ID); |
|
102 |
} |
|
103 |
|
|
104 | 55 |
/** |
105 | 56 |
* Opens a new {@link DataImportEditor} for the given input |
106 | 57 |
* @param input a {@link DataImportEditorInput} |
... | ... | |
281 | 232 |
return TaxeditorEditorPlugin.PLUGIN_ID; |
282 | 233 |
} |
283 | 234 |
|
284 |
public static void openPolytomousKey(UUID polytomousKeyUuid) |
|
285 |
throws Exception { |
|
286 |
PolytomousKeyEditorInput input = PolytomousKeyEditorInput |
|
287 |
.NewInstance(polytomousKeyUuid); |
|
288 |
open(input); |
|
289 |
} |
|
290 |
|
|
291 |
// public static void openPolytomousKeyEditor(UUID polytomousKeyUuid, String name) |
|
292 |
// throws Exception { |
|
293 |
// PolytomousKeyEditorInput input = new PolytomousKeyEditorInput(polytomousKeyUuid, name); |
|
294 |
// open(input); |
|
295 |
// } |
|
296 |
|
|
297 |
public static void openCdmAuthorities(UUID groupUuid) |
|
298 |
throws Exception { |
|
299 |
CdmAuthorityEditorInput input = CdmAuthorityEditorInput.NewInstance(groupUuid); |
|
300 |
open(input); |
|
301 |
} |
|
302 |
|
|
303 | 235 |
/** |
304 | 236 |
* Iterates recursively over all originals having the given specimen as a derivate. |
305 | 237 |
* The first {@link DerivedUnit} with no more originals or the first {@link FieldUnit} is returned |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/group/authority/handler/EditCdmAuthoritiesHandler.java | ||
---|---|---|
66 | 66 |
@Override |
67 | 67 |
public void run() { |
68 | 68 |
try { |
69 |
EditorUtil.openCdmAuthorities(((Group)selectedObject).getUuid()); |
|
69 |
// EditorUtil.openCdmAuthorities(((Group)selectedObject).getUuid());
|
|
70 | 70 |
} catch (Exception e) { |
71 | 71 |
MessagingUtils.warningDialog(Messages.EditCdmAuthoritiesHandler_COULD_NOT_OPEN_AUTHORITIES, EditorUtil.class, e.getMessage()); |
72 | 72 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/e4/handler/OpenRelatedConceptInBulkEditorHandlerE4.java | ||
---|---|---|
1 | 1 |
package eu.etaxonomy.taxeditor.editor.view.concept.e4.handler; |
2 | 2 |
|
3 |
import org.eclipse.ui.PartInitException; |
|
4 |
|
|
5 | 3 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
6 |
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorUtil; |
|
7 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
|
4 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
|
8 | 5 |
|
9 | 6 |
public class OpenRelatedConceptInBulkEditorHandlerE4 extends OpenRelatedConceptHandlerE4{ |
10 | 7 |
/** |
... | ... | |
12 | 9 |
*/ |
13 | 10 |
@Override |
14 | 11 |
protected void openConcept(TaxonBase<?> relatedTaxon) { |
15 |
try { |
|
16 |
BulkEditorUtil.openEditor(relatedTaxon); |
|
17 |
} catch (PartInitException e) { |
|
18 |
MessagingUtils.error(this.getClass(), "Bulk Editor could not be opened for "+relatedTaxon, e); |
|
19 |
} |
|
12 |
EditorUtil.openTaxonBaseE4(relatedTaxon.getUuid()); |
|
20 | 13 |
} |
21 | 14 |
} |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/NavigationUtil.java | ||
---|---|---|
26 | 26 |
import eu.etaxonomy.cdm.api.service.ITaxonNodeService; |
27 | 27 |
import eu.etaxonomy.cdm.api.service.ITaxonService; |
28 | 28 |
import eu.etaxonomy.cdm.model.common.ICdmBase; |
29 |
import eu.etaxonomy.cdm.model.description.PolytomousKey; |
|
30 | 29 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
31 | 30 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
32 | 31 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
... | ... | |
103 | 102 |
else{ |
104 | 103 |
EditorUtil.openTaxonNodeE4(entityUuid); |
105 | 104 |
} |
106 |
}else if(selectedObject instanceof PolytomousKey){ |
|
107 |
EditorUtil.openPolytomousKey(entityUuid); |
|
108 | 105 |
}else{ |
109 | 106 |
MessagingUtils.warningDialog(Messages.NavigationUtil_UNSUPPORTED_TYPE, NavigationUtil.class, Messages.NavigationUtil_UNSUPPORTED_TYPE_MESSAGE + selectedObject); |
110 | 107 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/AbstractUtility.java | ||
---|---|---|
60 | 60 |
import org.eclipse.ui.IViewPart; |
61 | 61 |
import org.eclipse.ui.IViewReference; |
62 | 62 |
import org.eclipse.ui.IWorkbench; |
63 |
import org.eclipse.ui.IWorkbenchPage; |
|
64 | 63 |
import org.eclipse.ui.IWorkbenchWindow; |
65 | 64 |
import org.eclipse.ui.PlatformUI; |
66 | 65 |
import org.eclipse.ui.handlers.IHandlerService; |
... | ... | |
116 | 115 |
return null; |
117 | 116 |
} |
118 | 117 |
|
119 |
public static boolean closeAll() { |
|
120 |
if(getActivePage()!=null){ |
|
121 |
return getActivePage().closeAllEditors(true); |
|
122 |
} |
|
123 |
return false; |
|
124 |
} |
|
125 |
|
|
126 | 118 |
public static Shell getShell() { |
127 | 119 |
|
128 | 120 |
return TaxeditorStorePlugin.getDefault().getWorkbench() |
129 | 121 |
.getActiveWorkbenchWindow().getShell(); |
130 | 122 |
} |
131 | 123 |
|
132 |
public static IWorkbenchPage getActivePage() { |
|
133 |
try{ |
|
134 |
return TaxeditorStorePlugin.getDefault().getWorkbench() |
|
135 |
.getActiveWorkbenchWindow().getActivePage(); |
|
136 |
} catch(NullPointerException npe){ |
|
137 |
return null; |
|
138 |
} |
|
139 |
} |
|
140 |
|
|
141 | 124 |
public static IWorkbench getWorkbench() { |
142 | 125 |
return TaxeditorStorePlugin.getDefault().getWorkbench(); |
143 | 126 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/LoginManager.java | ||
---|---|---|
28 | 28 |
import eu.etaxonomy.cdm.model.common.Group; |
29 | 29 |
import eu.etaxonomy.cdm.model.common.User; |
30 | 30 |
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap; |
31 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
|
32 | 31 |
import eu.etaxonomy.taxeditor.model.IContextListener; |
33 | 32 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
34 | 33 |
|
... | ... | |
62 | 61 |
public boolean authenticate(String username, String password){ |
63 | 62 |
|
64 | 63 |
// close all open editors |
65 |
if(!AbstractUtility.closeAll()){ |
|
66 |
return false; |
|
67 |
} |
|
64 |
//FIXME E4 migrate close all editors after login |
|
65 |
// if(!AbstractUtility.closeAll()){ |
|
66 |
// return false; |
|
67 |
// } |
|
68 | 68 |
|
69 | 69 |
|
70 | 70 |
try{ |
Also available in: Unified diff
ref #6913 Remove getActivePage() method