Revision fbd8e961
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java | ||
---|---|---|
26 | 26 |
import org.eclipse.ui.IEditorPart; |
27 | 27 |
import org.eclipse.ui.handlers.HandlerUtil; |
28 | 28 |
|
29 |
import eu.etaxonomy.cdm.api.service.ITaxonService; |
|
30 | 29 |
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit; |
31 | 30 |
import eu.etaxonomy.cdm.model.occurrence.FieldUnit; |
32 | 31 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
... | ... | |
39 | 38 |
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4; |
40 | 39 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
41 | 40 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
42 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
43 | 41 |
|
44 | 42 |
/** |
45 | 43 |
* Utility for the editor package |
... | ... | |
50 | 48 |
*/ |
51 | 49 |
public class EditorUtil extends AbstractUtility { |
52 | 50 |
|
53 |
private static boolean isSaving = false; |
|
51 |
private static final String NAME_EDITOR_ID = "eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4"; |
|
52 |
private static boolean isSaving = false; |
|
54 | 53 |
|
55 | 54 |
/** |
56 | 55 |
* Opens a new {@link DataImportEditor} for the given input |
... | ... | |
78 | 77 |
*/ |
79 | 78 |
public static void openTaxonNodeE4(UUID taxonNodeUuid) throws Exception { |
80 | 79 |
//FIXME E4 this can probably be removed when fully migrated |
81 |
String editorId = "eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4"; |
|
82 | 80 |
TaxonEditorInputE4 input = TaxonEditorInputE4.NewInstance(taxonNodeUuid); |
81 |
openNameEditor_internal(input); |
|
82 |
} |
|
83 |
|
|
84 |
public static void openTaxonBaseE4(UUID taxonBaseUuid) { |
|
85 |
//FIXME E4 this can probably be removed when fully migrated |
|
86 |
TaxonEditorInputE4 input = TaxonEditorInputE4.NewInstanceFromTaxonBase(taxonBaseUuid); |
|
87 |
openNameEditor_internal(input); |
|
88 |
} |
|
89 |
|
|
90 |
private static void openNameEditor_internal(TaxonEditorInputE4 input) { |
|
91 |
TaxonBase taxonBase = input.getTaxon(); |
|
92 |
|
|
93 |
if (taxonBase != null && taxonBase.isOrphaned()) { |
|
94 |
if(taxonBase.isInstanceOf(Synonym.class)){ |
|
95 |
MessagingUtils.warningDialog(Messages.EditorUtil_ORPHAN_ACCEPTED_TAXON, TaxonEditorInputE4.class, Messages.EditorUtil_ORPHAN_ACCEPTED_TAXON_MESSAGE); |
|
96 |
return; |
|
97 |
} |
|
98 |
else{ |
|
99 |
MessagingUtils.warningDialog(Messages.EditorUtil_ORPHAN_TAXON, TaxonEditorInputE4.class, Messages.EditorUtil_ORPHAN_TAXON_MESSAGE); |
|
100 |
return; |
|
101 |
} |
|
102 |
} |
|
103 |
|
|
83 | 104 |
EPartService partService = TaxeditorEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getService(EPartService.class); |
84 | 105 |
Collection<MPart> parts = partService.getParts(); |
85 | 106 |
MPart part = null; |
... | ... | |
92 | 113 |
} |
93 | 114 |
} |
94 | 115 |
if(part==null){ |
95 |
part = partService.createPart(editorId);
|
|
116 |
part = partService.createPart(NAME_EDITOR_ID);
|
|
96 | 117 |
part = partService.showPart(part, PartState.ACTIVATE); |
97 | 118 |
TaxonNameEditorE4 editor = (TaxonNameEditorE4) part.getObject(); |
98 | 119 |
editor.init(input); |
99 | 120 |
} |
100 | 121 |
part = partService.showPart(part, PartState.ACTIVATE); |
101 |
} |
|
102 |
|
|
103 |
public static void openTaxonBaseE4(UUID taxonBaseUuid) { |
|
104 |
//FIXME E4 this can probably be removed when fully migrated |
|
105 |
TaxonBase taxonBase = CdmStore.getService(ITaxonService.class).find(taxonBaseUuid); |
|
106 |
|
|
107 |
if (taxonBase != null && taxonBase.isOrphaned()) { |
|
108 |
if(taxonBase.isInstanceOf(Synonym.class)){ |
|
109 |
MessagingUtils.warningDialog(Messages.EditorUtil_ORPHAN_ACCEPTED_TAXON, TaxonEditorInputE4.class, Messages.EditorUtil_ORPHAN_ACCEPTED_TAXON_MESSAGE); |
|
110 |
return; |
|
111 |
} |
|
112 |
else{ |
|
113 |
MessagingUtils.warningDialog(Messages.EditorUtil_ORPHAN_TAXON, TaxonEditorInputE4.class, Messages.EditorUtil_ORPHAN_TAXON_MESSAGE); |
|
114 |
return; |
|
115 |
} |
|
116 |
} |
|
117 |
|
|
118 |
TaxonEditorInputE4 input = TaxonEditorInputE4.NewInstanceFromTaxonBase(taxonBaseUuid); |
|
119 |
EPartService partService = TaxeditorEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getService(EPartService.class); |
|
120 |
MPart part = partService.createPart("eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4"); |
|
121 |
part = partService.showPart(part, PartState.ACTIVATE); |
|
122 |
TaxonNameEditorE4 editor = (TaxonNameEditorE4) part.getObject(); |
|
123 |
editor.init(input); |
|
124 |
} |
|
122 |
} |
|
125 | 123 |
|
126 | 124 |
/** |
127 | 125 |
* An uninitialized taxon is one that hasn't been saved yet. As such, it |
... | ... | |
135 | 133 |
TaxonEditorInputE4 input = TaxonEditorInputE4 |
136 | 134 |
.NewEmptyInstance(parentNodeUuid); |
137 | 135 |
EPartService partService = TaxeditorEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getService(EPartService.class); |
138 |
MPart part = partService.createPart("eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4");
|
|
136 |
MPart part = partService.createPart(NAME_EDITOR_ID);
|
|
139 | 137 |
part = partService.showPart(part, PartState.ACTIVATE); |
140 | 138 |
TaxonNameEditorE4 editor = (TaxonNameEditorE4) part.getObject(); |
141 | 139 |
editor.init(input); |
Also available in: Unified diff
ref #6595 Do not open name editor twice for same taxon (fully fixed)