Revision a1880adb
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/e4/handler/RemotingDeletePolytomousKeyHandlerE4.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.taxeditor.navigation.key.polytomous.e4.handler; |
10 | 10 |
|
11 |
import java.util.Collection; |
|
11 | 12 |
import java.util.List; |
12 | 13 |
import java.util.UUID; |
13 | 14 |
|
14 |
import org.eclipse.core.commands.ExecutionEvent; |
|
15 | 15 |
import org.eclipse.core.commands.operations.AbstractOperation; |
16 | 16 |
import org.eclipse.core.runtime.IStatus; |
17 | 17 |
import org.eclipse.core.runtime.Status; |
18 | 18 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
19 | 19 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem; |
20 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
|
20 | 21 |
import org.eclipse.jface.viewers.IStructuredSelection; |
21 | 22 |
import org.eclipse.swt.widgets.Shell; |
22 |
import org.eclipse.ui.IEditorInput; |
|
23 |
import org.eclipse.ui.IEditorReference; |
|
24 |
import org.eclipse.ui.IWorkbenchPage; |
|
25 |
import org.eclipse.ui.PartInitException; |
|
26 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
27 | 23 |
|
28 |
import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyEditorInput;
|
|
24 |
import eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyListEditorE4;
|
|
29 | 25 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
30 | 26 |
import eu.etaxonomy.taxeditor.navigation.key.polytomous.PolytomousKeyViewLabels; |
31 | 27 |
import eu.etaxonomy.taxeditor.navigation.key.polytomous.operation.RemotingDeletePolytomousKeyOperation; |
... | ... | |
63 | 59 |
if(!confirmation) { |
64 | 60 |
return Status.CANCEL_STATUS; |
65 | 61 |
} |
66 |
//FIXME E4 migrate |
|
67 |
// closeObsoleteEditor(event); |
|
62 |
closeObsoleteEditor(partService); |
|
68 | 63 |
return Status.OK_STATUS; |
69 | 64 |
} |
70 | 65 |
|
... | ... | |
80 | 75 |
public void onComplete() { |
81 | 76 |
} |
82 | 77 |
|
83 |
protected boolean closeObsoleteEditor(ExecutionEvent event){ |
|
84 |
boolean result = true; |
|
85 |
IWorkbenchPage activePage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage(); |
|
86 |
|
|
87 |
for (IEditorReference ref : activePage.getEditorReferences()) { |
|
88 |
try { |
|
89 |
IEditorInput input = ref.getEditorInput(); |
|
90 |
if (input instanceof PolytomousKeyEditorInput) { |
|
91 |
UUID uuidForKey = ((PolytomousKeyEditorInput) input).getKey().getUuid(); |
|
92 |
for (UUID keyUuid :keysToDelete) { |
|
93 |
if( uuidForKey.equals(keyUuid)){ |
|
94 |
result &= activePage.closeEditor(ref.getEditor(false), false); |
|
95 |
} |
|
78 |
protected void closeObsoleteEditor(EPartService partService){ |
|
79 |
Collection<MPart> parts = partService.getParts(); |
|
80 |
for (MPart part : parts) { |
|
81 |
if(part.getElementId().equals("eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyListEditorE4")){ |
|
82 |
PolytomousKeyListEditorE4 keyListEditor = (PolytomousKeyListEditorE4) part.getObject(); |
|
83 |
UUID uuidForKey = keyListEditor.getEditorInput().getKey().getUuid(); |
|
84 |
for (UUID keyUuid :keysToDelete) { |
|
85 |
if(uuidForKey.equals(keyUuid)){ |
|
86 |
partService.hidePart(part, true); |
|
96 | 87 |
} |
97 |
|
|
98 | 88 |
} |
99 |
} catch (PartInitException e) { |
|
100 |
continue; |
|
101 | 89 |
} |
102 | 90 |
} |
103 |
return result; |
|
104 | 91 |
} |
105 | 92 |
|
106 | 93 |
/** |
Also available in: Unified diff
ref #6908 Close PK editor when deleting key