Revision a7d1d751
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java | ||
---|---|---|
16 | 16 |
import org.eclipse.core.commands.ExecutionEvent; |
17 | 17 |
import org.eclipse.core.commands.operations.IOperationHistory; |
18 | 18 |
import org.eclipse.core.commands.operations.IUndoContext; |
19 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
|
20 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
|
21 |
import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState; |
|
19 | 22 |
import org.eclipse.jface.dialogs.MessageDialog; |
20 | 23 |
import org.eclipse.jface.viewers.ISelection; |
21 | 24 |
import org.eclipse.jface.viewers.IStructuredSelection; |
... | ... | |
36 | 39 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
37 | 40 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
38 | 41 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
42 |
import eu.etaxonomy.taxeditor.editor.e4.TaxonEditorInputE4; |
|
39 | 43 |
import eu.etaxonomy.taxeditor.editor.group.authority.CdmAuthorityEditor; |
40 | 44 |
import eu.etaxonomy.taxeditor.editor.group.authority.CdmAuthorityEditorInput; |
41 | 45 |
import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin; |
42 | 46 |
import eu.etaxonomy.taxeditor.editor.key.KeyEditor; |
43 | 47 |
import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyEditorInput; |
44 | 48 |
import eu.etaxonomy.taxeditor.editor.l10n.Messages; |
49 |
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4; |
|
45 | 50 |
import eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditor; |
46 | 51 |
import eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditorInput; |
47 | 52 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
... | ... | |
138 | 143 |
* if any. |
139 | 144 |
*/ |
140 | 145 |
public static void openTaxonNode(UUID taxonNodeUuid) throws Exception { |
141 |
TaxonEditorInput input = TaxonEditorInput.NewInstance(taxonNodeUuid); |
|
142 |
open(input); |
|
146 |
TaxonEditorInput input = TaxonEditorInput.NewInstance(taxonNodeUuid); |
|
147 |
open(input); |
|
148 |
} |
|
149 |
|
|
150 |
public static void openTaxonNodeE4(UUID taxonNodeUuid) throws Exception { |
|
151 |
TaxonEditorInputE4 input = TaxonEditorInputE4.NewInstance(taxonNodeUuid); |
|
152 |
EPartService partService = TaxeditorEditorPlugin.getDefault().getWorkbench().getService(EPartService.class); |
|
153 |
MPart part = partService.createPart("eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4"); |
|
154 |
partService.showPart(part, PartState.ACTIVATE); |
|
155 |
TaxonNameEditorE4 editor = (TaxonNameEditorE4) part.getObject(); |
|
156 |
editor.init(input); |
|
143 | 157 |
} |
144 | 158 |
|
145 |
/** |
|
146 |
* <p> |
|
147 |
* openTaxonBase |
|
148 |
* </p> |
|
149 |
* |
|
150 |
* @param taxonBaseUuid |
|
151 |
* a {@link java.util.UUID} object. |
|
152 |
* @throws org.eclipse.ui.PartInitException |
|
153 |
* if any. |
|
154 |
*/ |
|
155 | 159 |
public static void openTaxonBase(UUID taxonBaseUuid) |
156 | 160 |
throws PartInitException { |
157 | 161 |
TaxonBase taxonBase = CdmStore.getService(ITaxonService.class).find(taxonBaseUuid); |
... | ... | |
172 | 176 |
} |
173 | 177 |
} |
174 | 178 |
|
179 |
public static void openTaxonBaseE4(UUID taxonBaseUuid) throws PartInitException{ |
|
180 |
TaxonBase taxonBase = CdmStore.getService(ITaxonService.class).find(taxonBaseUuid); |
|
181 |
|
|
182 |
if (taxonBase != null && taxonBase.isOrphaned()) { |
|
183 |
if(taxonBase.isInstanceOf(Synonym.class)){ |
|
184 |
MessagingUtils.warningDialog(Messages.EditorUtil_ORPHAN_ACCEPTED_TAXON, TaxonEditorInputE4.class, Messages.EditorUtil_ORPHAN_ACCEPTED_TAXON_MESSAGE); |
|
185 |
return; |
|
186 |
} |
|
187 |
else{ |
|
188 |
MessagingUtils.warningDialog(Messages.EditorUtil_ORPHAN_TAXON, TaxonEditorInputE4.class, Messages.EditorUtil_ORPHAN_TAXON_MESSAGE); |
|
189 |
return; |
|
190 |
} |
|
191 |
} |
|
192 |
TaxonEditorInputE4 input = TaxonEditorInputE4.NewInstanceFromTaxonBase(taxonBaseUuid); |
|
193 |
if(input!=null && input.getTaxonNode()!=null){ |
|
194 |
EPartService partService = TaxeditorEditorPlugin.getDefault().getWorkbench().getService(EPartService.class); |
|
195 |
MPart part = partService.createPart("eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4"); |
|
196 |
partService.showPart(part, PartState.ACTIVATE); |
|
197 |
TaxonNameEditorE4 editor = (TaxonNameEditorE4) part.getObject(); |
|
198 |
editor.init(input); |
|
199 |
} |
|
200 |
} |
|
201 |
|
|
175 | 202 |
/** |
176 | 203 |
* <p> |
177 | 204 |
* findEditorByTaxonNodeUuid |
... | ... | |
350 | 377 |
return true; |
351 | 378 |
} |
352 | 379 |
|
380 |
public static boolean forceUserSaveE4Editor(TaxonNameEditorE4 editor, Shell shell) { |
|
381 |
if (editor.isDirty()) { |
|
382 |
|
|
383 |
boolean doSave = MessageDialog |
|
384 |
.openConfirm(shell, Messages.EditorUtil_COMFIRM_SAVE, |
|
385 |
Messages.EditorUtil_CONFIRM_SAVE_MESSAGE); |
|
386 |
|
|
387 |
if (!doSave) { |
|
388 |
return false; |
|
389 |
} |
|
390 |
|
|
391 |
editor.doSave(AbstractUtility.getMonitor()); |
|
392 |
} |
|
393 |
return true; |
|
394 |
} |
|
395 |
|
|
353 | 396 |
/** |
354 | 397 |
* <p> |
355 | 398 |
* getSelection |
Also available in: Unified diff
ref #6595 migrate concept menu handlers