Revision b52863af
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.e4.ui.model.application.MApplication; |
|
15 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
|
16 |
import org.eclipse.e4.ui.model.application.ui.basic.MPartStack; |
|
17 |
import org.eclipse.e4.ui.workbench.modeling.EModelService; |
|
18 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
|
19 |
import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState; |
|
14 | 20 |
|
21 |
import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4; |
|
22 |
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput; |
|
15 | 23 |
import eu.etaxonomy.taxeditor.bulkeditor.internal.TaxeditorBulkeditorPlugin; |
16 | 24 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
25 |
import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility; |
|
17 | 26 |
|
18 | 27 |
/** |
19 | 28 |
* <p>BulkEditorUtil class.</p> |
... | ... | |
34 | 43 |
return TaxeditorBulkeditorPlugin.PLUGIN_ID; |
35 | 44 |
} |
36 | 45 |
|
46 |
public static void openBulkEditor(AbstractBulkEditorInput<?> input, |
|
47 |
EModelService modelService, EPartService partService, MApplication application){ |
|
48 |
MPart part = partService.createPart(AppModelId.PARTDESCRIPTOR_BULKEDITOR_EDITOR); |
|
49 |
MPartStack editorAreaPartStack = WorkbenchUtility.getEditorAreaPartStack(application, modelService); |
|
50 |
if(editorAreaPartStack!=null){ |
|
51 |
editorAreaPartStack.getChildren().add(part); |
|
52 |
} |
|
53 |
part = partService.showPart(part, PartState.ACTIVATE); |
|
54 |
BulkEditorE4 bulkEditor = (BulkEditorE4) part.getObject(); |
|
55 |
bulkEditor.init(input); |
|
56 |
} |
|
57 |
|
|
37 | 58 |
/** |
38 | 59 |
* <p>getUndoContext</p> |
39 | 60 |
* |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/OpenBulkEditorHandlerE4.java | ||
---|---|---|
9 | 9 |
package eu.etaxonomy.taxeditor.bulkeditor.e4.handler; |
10 | 10 |
import org.eclipse.core.commands.ParameterizedCommand; |
11 | 11 |
import org.eclipse.e4.core.di.annotations.Execute; |
12 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
|
12 |
import org.eclipse.e4.ui.model.application.MApplication; |
|
13 |
import org.eclipse.e4.ui.workbench.modeling.EModelService; |
|
13 | 14 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
14 |
import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState; |
|
15 | 15 |
|
16 |
import eu.etaxonomy.taxeditor.bulkeditor.AppModelId;
|
|
16 |
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorUtil;
|
|
17 | 17 |
import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorConstants; |
18 |
import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4; |
|
19 | 18 |
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput; |
20 | 19 |
import eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInputType; |
21 | 20 |
|
... | ... | |
28 | 27 |
public class OpenBulkEditorHandlerE4 { |
29 | 28 |
|
30 | 29 |
@Execute |
31 |
public void execute(ParameterizedCommand command, EPartService partService) { |
|
30 |
public void execute(ParameterizedCommand command, EPartService partService, MApplication application, EModelService modelService) {
|
|
32 | 31 |
String inputTypeId = (String) command.getParameterMap().get(IBulkEditorConstants.INPUT_TYPE_PARAMETER_ID); |
33 | 32 |
BulkEditorInputType inputType = BulkEditorInputType.getById(inputTypeId); |
34 |
|
|
35 |
MPart part = partService.createPart(AppModelId.PARTDESCRIPTOR_BULKEDITOR_EDITOR); |
|
36 |
part = partService.showPart(part, PartState.ACTIVATE); |
|
37 |
BulkEditorE4 bulkEditor = (BulkEditorE4) part.getObject(); |
|
38 |
bulkEditor.init(AbstractBulkEditorInput.NewInstance(inputType)); |
|
33 |
AbstractBulkEditorInput input = AbstractBulkEditorInput.NewInstance(inputType); |
|
34 |
BulkEditorUtil.openBulkEditor(input, modelService, partService, application); |
|
39 | 35 |
} |
40 | 36 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/defaultHandler/OpenBulkEditorForIdentifiableEntityE4.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.util.UUID; |
4 | 4 |
|
5 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
|
6 | 5 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
7 |
import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState; |
|
8 | 6 |
import org.eclipse.swt.widgets.Shell; |
9 | 7 |
|
10 | 8 |
import eu.etaxonomy.cdm.model.agent.AgentBase; |
... | ... | |
14 | 12 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
15 | 13 |
import eu.etaxonomy.cdm.model.reference.Reference; |
16 | 14 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
17 |
import eu.etaxonomy.taxeditor.bulkeditor.AppModelId; |
|
18 |
import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4; |
|
15 |
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorUtil; |
|
19 | 16 |
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput; |
20 | 17 |
import eu.etaxonomy.taxeditor.handler.defaultHandler.e4.DefaultOpenHandlerBaseE4; |
21 | 18 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
... | ... | |
35 | 32 |
*/ |
36 | 33 |
@Override |
37 | 34 |
protected void open(IdentifiableEntity entity, Shell shell, EPartService partService) { |
38 |
MPart part = partService.createPart(AppModelId.PARTDESCRIPTOR_BULKEDITOR_EDITOR); |
|
39 |
part = partService.showPart(part, PartState.ACTIVATE); |
|
40 |
BulkEditorE4 bulkEditor = (BulkEditorE4) part.getObject(); |
|
41 |
bulkEditor.init(AbstractBulkEditorInput.NewInstance(entity)); |
|
35 |
AbstractBulkEditorInput input = AbstractBulkEditorInput.NewInstance(entity); |
|
36 |
BulkEditorUtil.openBulkEditor(input, modelService, partService, application); |
|
42 | 37 |
} |
43 | 38 |
|
44 | 39 |
/** |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/defaultHandler/OpenBulkEditorForTaxonNodeHandler.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.util.UUID; |
4 | 4 |
|
5 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
|
6 | 5 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
7 |
import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState; |
|
8 | 6 |
import org.eclipse.swt.widgets.Shell; |
9 | 7 |
|
10 | 8 |
import eu.etaxonomy.cdm.api.service.ITaxonNodeService; |
11 | 9 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
12 |
import eu.etaxonomy.taxeditor.bulkeditor.AppModelId; |
|
13 |
import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4; |
|
10 |
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorUtil; |
|
14 | 11 |
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput; |
15 | 12 |
import eu.etaxonomy.taxeditor.handler.defaultHandler.e4.DefaultOpenHandlerBaseE4; |
16 | 13 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
... | ... | |
24 | 21 |
|
25 | 22 |
@Override |
26 | 23 |
protected void open(TaxonNode entity, Shell shell, EPartService partService) { |
27 |
MPart part = partService.createPart(AppModelId.PARTDESCRIPTOR_BULKEDITOR_EDITOR); |
|
28 |
part = partService.showPart(part, PartState.ACTIVATE); |
|
29 |
BulkEditorE4 bulkEditor = (BulkEditorE4) part.getObject(); |
|
30 |
bulkEditor.init(AbstractBulkEditorInput.NewInstance(entity.getTaxon())); |
|
24 |
AbstractBulkEditorInput input = AbstractBulkEditorInput.NewInstance(entity.getTaxon()); |
|
25 |
BulkEditorUtil.openBulkEditor(input, modelService, partService, application); |
|
31 | 26 |
} |
32 | 27 |
|
33 | 28 |
/** |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java | ||
---|---|---|
10 | 10 |
package eu.etaxonomy.taxeditor.editor; |
11 | 11 |
|
12 | 12 |
import java.util.Collection; |
13 |
import java.util.List; |
|
14 | 13 |
import java.util.UUID; |
15 | 14 |
|
16 | 15 |
import org.eclipse.core.commands.ExecutionEvent; |
17 | 16 |
import org.eclipse.core.commands.operations.IOperationHistory; |
18 | 17 |
import org.eclipse.core.commands.operations.IUndoContext; |
19 | 18 |
import org.eclipse.e4.ui.model.application.MApplication; |
20 |
import org.eclipse.e4.ui.model.application.ui.advanced.MArea; |
|
21 | 19 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
22 |
import org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainerElement; |
|
23 | 20 |
import org.eclipse.e4.ui.model.application.ui.basic.MPartStack; |
24 | 21 |
import org.eclipse.e4.ui.workbench.modeling.EModelService; |
25 | 22 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
... | ... | |
45 | 42 |
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4; |
46 | 43 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
47 | 44 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
45 |
import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility; |
|
48 | 46 |
|
49 | 47 |
/** |
50 | 48 |
* Utility for the editor package |
... | ... | |
122 | 120 |
if(part==null){ |
123 | 121 |
part = partService.createPart(NAME_EDITOR_ID); |
124 | 122 |
|
125 |
MPartStack editorAreaPartStack = getEditorAreaPartStack(application, modelService); |
|
123 |
MPartStack editorAreaPartStack = WorkbenchUtility.getEditorAreaPartStack(application, modelService);
|
|
126 | 124 |
if(editorAreaPartStack!=null){ |
127 | 125 |
editorAreaPartStack.getChildren().add(part); |
128 | 126 |
} |
... | ... | |
136 | 134 |
} |
137 | 135 |
} |
138 | 136 |
|
139 |
public static MPartStack getEditorAreaPartStack(MApplication application, EModelService modelService){ |
|
140 |
//FIXME E4 hack for opening in e3 editor area |
|
141 |
if(application!=null){ |
|
142 |
//FIXME E4 hack for opening in e3 editor area |
|
143 |
List<MArea> elements = modelService.findElements(application, "org.eclipse.ui.editorss", MArea.class, null); |
|
144 |
for (MArea mArea : elements) { |
|
145 |
List<MPartSashContainerElement> children = mArea.getChildren(); |
|
146 |
for (MPartSashContainerElement mPartSashContainerElement : children) { |
|
147 |
if(mPartSashContainerElement instanceof MPartStack){ |
|
148 |
return (MPartStack) mPartSashContainerElement; |
|
149 |
} |
|
150 |
} |
|
151 |
} |
|
152 |
} |
|
153 |
return null; |
|
154 |
} |
|
155 |
|
|
156 | 137 |
/** |
157 | 138 |
* An uninitialized taxon is one that hasn't been saved yet. As such, it |
158 | 139 |
* should appear in neither the list of recent names nor in the taxonomic |
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 | 3 |
import org.eclipse.e4.ui.model.application.MApplication; |
4 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
|
5 | 4 |
import org.eclipse.e4.ui.workbench.modeling.EModelService; |
6 | 5 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
7 |
import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState; |
|
8 | 6 |
|
9 | 7 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
10 |
import eu.etaxonomy.taxeditor.bulkeditor.AppModelId; |
|
11 |
import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4; |
|
8 |
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorUtil; |
|
12 | 9 |
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput; |
13 | 10 |
|
14 | 11 |
public class OpenRelatedConceptInBulkEditorHandlerE4 extends OpenRelatedConceptHandlerE4{ |
... | ... | |
18 | 15 |
@Override |
19 | 16 |
protected void openConcept(TaxonBase<?> relatedTaxon, EModelService modelService, EPartService partService, MApplication application) { |
20 | 17 |
AbstractBulkEditorInput<?> input = AbstractBulkEditorInput.NewInstance(relatedTaxon); |
21 |
MPart part = partService.createPart(AppModelId.PARTDESCRIPTOR_BULKEDITOR_EDITOR); |
|
22 |
part = partService.showPart(part, PartState.ACTIVATE); |
|
23 |
BulkEditorE4 bulkEditor = (BulkEditorE4) part.getObject(); |
|
24 |
bulkEditor.init(input); |
|
18 |
BulkEditorUtil.openBulkEditor(input, modelService, partService, application); |
|
25 | 19 |
} |
26 | 20 |
} |
eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/WorkbenchUtility.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.taxeditor.workbench; |
10 | 10 |
|
11 |
import java.util.List; |
|
12 |
|
|
13 |
import org.eclipse.e4.ui.model.application.MApplication; |
|
14 |
import org.eclipse.e4.ui.model.application.ui.advanced.MArea; |
|
11 | 15 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
16 |
import org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainerElement; |
|
17 |
import org.eclipse.e4.ui.model.application.ui.basic.MPartStack; |
|
18 |
import org.eclipse.e4.ui.workbench.modeling.EModelService; |
|
12 | 19 |
|
13 | 20 |
import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart; |
14 | 21 |
import eu.etaxonomy.taxeditor.workbench.part.ISelectionElementEditingPart; |
... | ... | |
48 | 55 |
} |
49 | 56 |
return null; |
50 | 57 |
} |
58 |
|
|
59 |
public static MPartStack getEditorAreaPartStack(MApplication application, EModelService modelService){ |
|
60 |
//FIXME E4 hack for opening in e3 editor area |
|
61 |
if(application!=null){ |
|
62 |
//FIXME E4 hack for opening in e3 editor area |
|
63 |
List<MArea> elements = modelService.findElements(application, "org.eclipse.ui.editorss", MArea.class, null); |
|
64 |
for (MArea mArea : elements) { |
|
65 |
List<MPartSashContainerElement> children = mArea.getChildren(); |
|
66 |
for (MPartSashContainerElement mPartSashContainerElement : children) { |
|
67 |
if(mPartSashContainerElement instanceof MPartStack){ |
|
68 |
return (MPartStack) mPartSashContainerElement; |
|
69 |
} |
|
70 |
} |
|
71 |
} |
|
72 |
} |
|
73 |
return null; |
|
74 |
} |
|
51 | 75 |
} |
Also available in: Unified diff
ref #6925 Open bulk editor in editor area