Project

General

Profile

« Previous | Next » 

Revision 41c668f3

Added by Patrick Plitzner over 6 years ago

ref #6595 code refactoring

View differences:

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;
13 14
import java.util.UUID;
14 15

  
15 16
import org.eclipse.core.commands.ExecutionEvent;
16 17
import org.eclipse.core.commands.operations.IOperationHistory;
17 18
import org.eclipse.core.commands.operations.IUndoContext;
18 19
import org.eclipse.e4.ui.model.application.MApplication;
20
import org.eclipse.e4.ui.model.application.ui.advanced.MArea;
19 21
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
22
import org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainerElement;
20 23
import org.eclipse.e4.ui.model.application.ui.basic.MPartStack;
21 24
import org.eclipse.e4.ui.workbench.modeling.EModelService;
22 25
import org.eclipse.e4.ui.workbench.modeling.EPartService;
......
27 30
import org.eclipse.jface.viewers.TreeNode;
28 31
import org.eclipse.swt.widgets.Shell;
29 32
import org.eclipse.ui.IEditorPart;
33
import org.eclipse.ui.PartInitException;
30 34
import org.eclipse.ui.handlers.HandlerUtil;
31 35

  
32 36
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
......
69 73
//	    }
70 74
//	}
71 75

  
72
	/**
73
	 * Taxon Editors may be opened by supplying a taxon node uuid. Session gets
74
	 * initialised here and is passed to the editor
75
	 *
76
	 * @param taxonNodeUuid
77
	 *            a {@link java.util.UUID} object.
78
	 * @throws java.lang.Exception
79
	 *             if any.
80
	 */
81
	public static void openTaxonNodeE4(UUID taxonNodeUuid) throws Exception {
82
	    //FIXME E4 this can probably be removed when fully migrated
83
        TaxonEditorInputE4 input = TaxonEditorInputE4.NewInstance(taxonNodeUuid);
84

  
85
        EPartService partService = TaxeditorEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getService(EPartService.class);
86
        EModelService modelService = TaxeditorEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getService(EModelService.class);
87
        openNameEditor_internal(input, modelService, partService, null);
88
	}
89 76
	public static void openTaxonNodeE4(UUID taxonNodeUuid, EModelService modelService, EPartService partService, MApplication application) throws Exception {
90 77
	    TaxonEditorInputE4 input = TaxonEditorInputE4.NewInstance(taxonNodeUuid);
91 78
	    openNameEditor_internal(input, modelService, partService, application);
......
134 121
        }
135 122
        if(part==null){
136 123
            part = partService.createPart(NAME_EDITOR_ID);
137
            if(application!=null){
138
                //FIXME E4 hack for opening in e3 editor area
139
                MPartStack partStack = (MPartStack)modelService.find("org.eclipse.e4.primaryDataStack", application);
140
                partStack.getChildren().add(part);
124

  
125
            MPartStack editorAreaPartStack = getEditorAreaPartStack(application, modelService);
126
            if(editorAreaPartStack!=null){
127
                editorAreaPartStack.getChildren().add(part);
141 128
            }
142 129
            partService.showPart(part, PartState.ACTIVATE);
143 130

  
......
149 136
        }
150 137
    }
151 138

  
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

  
152 156
	/**
153 157
	 * An uninitialized taxon is one that hasn't been saved yet. As such, it
154 158
	 * should appear in neither the list of recent names nor in the taxonomic

Also available in: Unified diff