Revision eaff1338
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/MoveDescriptionToOtherTaxonHandlerE4.java | ||
---|---|---|
21 | 21 |
import org.eclipse.jface.viewers.IStructuredSelection; |
22 | 22 |
import org.eclipse.swt.widgets.Display; |
23 | 23 |
import org.eclipse.swt.widgets.Shell; |
24 |
import org.eclipse.ui.PartInitException; |
|
25 | 24 |
|
26 | 25 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
27 | 26 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
... | ... | |
31 | 30 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
32 | 31 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
33 | 32 |
import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor; |
34 |
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput; |
|
35 | 33 |
import eu.etaxonomy.taxeditor.editor.l10n.Messages; |
34 |
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4; |
|
36 | 35 |
import eu.etaxonomy.taxeditor.editor.view.descriptive.e4.FactualDataPartE4; |
37 | 36 |
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.MoveDescriptionToOtherTaxonOperation; |
38 | 37 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
39 | 38 |
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer; |
40 | 39 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
41 | 40 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
42 |
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled; |
|
43 | 41 |
import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog; |
44 | 42 |
import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility; |
45 | 43 |
|
... | ... | |
54 | 52 |
private MoveDescriptionToOtherTaxonOperation operation; |
55 | 53 |
|
56 | 54 |
private UUID newAcceptedTaxonNodeUuid; |
57 |
private MultiPageTaxonEditor editor;
|
|
55 |
private TaxonNameEditorE4 editor;
|
|
58 | 56 |
|
59 | 57 |
@Execute |
60 | 58 |
public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart activePart, |
... | ... | |
64 | 62 |
|
65 | 63 |
FactualDataPartE4 factualDataPart = (FactualDataPartE4) activePart.getObject(); |
66 | 64 |
Object e4WrappedPart = WorkbenchUtility.getE4WrappedPart(factualDataPart.getSelectionProvidingPart()); |
67 |
if(e4WrappedPart instanceof MultiPageTaxonEditor){
|
|
68 |
editor = (MultiPageTaxonEditor) e4WrappedPart;
|
|
65 |
if(e4WrappedPart instanceof TaxonNameEditorE4){
|
|
66 |
editor = (TaxonNameEditorE4) e4WrappedPart;
|
|
69 | 67 |
if (this.editor.isDirty()){ |
70 | 68 |
boolean proceed = MessageDialog.openQuestion(null, |
71 | 69 |
Messages.MoveDescriptionToOtherTaxonHandler_SAVE_CHANGES, Messages.MoveDescriptionToOtherTaxonHandler_SAVE_CHANGES_MESSAGE); |
72 | 70 |
if (proceed) { |
73 |
editor.doSave(AbstractUtility.getMonitor());
|
|
71 |
editor.save(AbstractUtility.getMonitor());
|
|
74 | 72 |
} else { |
75 | 73 |
return; |
76 | 74 |
} |
... | ... | |
90 | 88 |
|
91 | 89 |
// Choose the target taxon |
92 | 90 |
List<UUID> excludeTaxa = new ArrayList<UUID>(); |
93 |
|
|
91 |
|
|
94 | 92 |
excludeTaxa.add(descriptions.get(0).getTaxon().getUuid()); |
95 | 93 |
|
96 | 94 |
//get current taxon node |
97 | 95 |
TaxonNode node = null; |
98 | 96 |
Classification classification = null; |
99 |
MultiPageTaxonEditor taxonEditor = EditorUtil.getActiveMultiPageTaxonEditor(); |
|
100 |
if(taxonEditor!=null){ |
|
101 |
node = ((TaxonEditorInput) taxonEditor.getEditorInput()).getTaxonNode(); |
|
97 |
if(editor!=null){ |
|
98 |
node = editor.getEditorInput().getTaxonNode(); |
|
102 | 99 |
classification = node.getClassification(); |
103 | 100 |
} |
104 | 101 |
TaxonNode newAcceptedTaxonNode = TaxonNodeSelectionDialog.select(shell, |
... | ... | |
121 | 118 |
newAcceptedTaxonNode, |
122 | 119 |
this, |
123 | 120 |
editor, |
124 |
(ICdmEntitySessionEnabled)editor.getEditorInput());
|
|
121 |
editor.getEditorInput()); |
|
125 | 122 |
AbstractUtility.executeOperation(operation); |
126 | 123 |
} |
127 | 124 |
|
... | ... | |
135 | 132 |
|
136 | 133 |
@Override |
137 | 134 |
public void run() { |
138 |
AbstractUtility.close(editor); |
|
139 |
|
|
135 |
//FIXME E4 migrate |
|
136 |
// AbstractUtility.close(editor); |
|
137 |
// |
|
140 | 138 |
try { |
141 |
MultiPageTaxonEditor possibleOpenEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(newAcceptedTaxonNodeUuid); |
|
142 |
if(possibleOpenEditor != null){ |
|
143 |
AbstractUtility.close(possibleOpenEditor); |
|
144 |
} |
|
139 |
// MultiPageTaxonEditor possibleOpenEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(newAcceptedTaxonNodeUuid);
|
|
140 |
// if(possibleOpenEditor != null){
|
|
141 |
// AbstractUtility.close(possibleOpenEditor);
|
|
142 |
// }
|
|
145 | 143 |
EditorUtil.openTaxonNodeE4(newAcceptedTaxonNodeUuid); |
146 |
} catch (PartInitException e) { |
|
147 |
MessagingUtils.error(this.getClass(), e); |
|
148 |
throw new RuntimeException(e); |
|
144 |
// } catch (PartInitException e) {
|
|
145 |
// MessagingUtils.error(this.getClass(), e);
|
|
146 |
// throw new RuntimeException(e);
|
|
149 | 147 |
} catch (Exception e) { |
150 | 148 |
MessagingUtils.warningDialog(Messages.MoveDescriptionToOtherTaxonHandler_CREATE_FAILED, this, e.getMessage()); |
151 | 149 |
} |
Also available in: Unified diff
ref #6595 refactor selection handling to migrated name editor