Project

General

Profile

« Previous | Next » 

Revision 4d7cb09d

Added by Patrick Plitzner about 6 years ago

ref #7011 harmonize creation and showing of MParts

  • also allow authority editor to be opened in multiple parts

View differences:

eu.etaxonomy.taxeditor.editor/fragment.e4xmi
228 228
        <children xsi:type="menu:HandledMenuItem" xmi:id="_Rf4A8KRREeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.polytomouskeylist.delete" label="%command.label.26" command="_uM4zsKO8EeeWePK798pdTw"/>
229 229
      </menus>
230 230
    </elements>
231
    <elements xsi:type="basic:PartDescriptor" xmi:id="_ARZyMKz2EeeBIsZyvYlAaA" elementId="eu.etaxonomy.taxeditor.editor.group.authority.e4.CdmAuthorityEditorE4" label="%editor.name.4" closeable="true" dirtyable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.group.authority.e4.CdmAuthorityEditorE4"/>
231
    <elements xsi:type="basic:PartDescriptor" xmi:id="_ARZyMKz2EeeBIsZyvYlAaA" elementId="eu.etaxonomy.taxeditor.editor.group.authority.e4.CdmAuthorityEditorE4" label="%editor.name.4" allowMultiple="true" closeable="true" dirtyable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.group.authority.e4.CdmAuthorityEditorE4"/>
232 232
    <elements xsi:type="basic:PartDescriptor" xmi:id="_Fa8l4M7XEeex0rHJ7p8Zdw" elementId="eu.etaxonomy.taxeditor.editor.view.workingSet.WorkingSetEditor" label="Working Set Editor" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.editor/icons/ws_icon.gif" tooltip="Working Set Editor" allowMultiple="true" closeable="true" dirtyable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.workingSet.WorkingSetEditor"/>
233 233
    <elements xsi:type="basic:PartDescriptor" xmi:id="_rpaDsNK2EeeWSJT7vW9jsw" elementId="eu.etaxonomy.taxeditor.editor.workingSet.matrix.CharacterMatrixPart" label="Character Matrix" tooltip="Character Matrix" allowMultiple="true" closeable="true" dirtyable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.workingSet.matrix.CharacterMatrixPart">
234 234
      <handlers xmi:id="_d_HUYOPBEeeIH8IplZ0cuA" elementId="eu.etaxonomy.taxeditor.editor.handler.2" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.charactermatrix.handler.ExportCharacterMatrixHandler" command="_YeWagOPBEeeIH8IplZ0cuA"/>
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java
27 27
import org.eclipse.jface.viewers.TreeNode;
28 28
import org.eclipse.swt.widgets.Shell;
29 29
import org.eclipse.ui.IEditorPart;
30
import org.eclipse.ui.PartInitException;
31 30
import org.eclipse.ui.handlers.HandlerUtil;
32 31

  
33 32
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
......
63 62
    private static final String NAME_EDITOR_ID = "eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4";
64 63
    private static boolean isSaving = false;
65 64

  
66
	/**
67
	 * Opens a new {@link DataImportEditor} for the given input
68
	 * @param input a {@link DataImportEditorInput}
69
	 * @throws PartInitException
70
	 */
71
//	public static void open(DataImportEditorInput<?> input)
72
//	        throws PartInitException {
73
//	    if(input instanceof BioCaseEditorInput){
74
//	        open(input, SpecimenImportEditor.ID);
75
//	    }
76
//	    else if(input instanceof GbifImportEditorInput){
77
//	        open(input, GbifImportEditor.ID);
78
//	    }
79
//	}
80

  
81 65
    public static void openWorkingSetEditor(UUID workingSetUuid, EModelService modelService, EPartService partService, MApplication application){
82
        MPart part = partService.createPart("eu.etaxonomy.taxeditor.editor.view.workingSet.WorkingSetEditor");
83
        MPartStack editorAreaPartStack = WorkbenchUtility.getEditorAreaPartStack(application, modelService);
84
        if(editorAreaPartStack!=null){
85
            editorAreaPartStack.getChildren().add(part);
86
        }
87
        part = partService.showPart(part, PartState.ACTIVATE);
66
        String partId = AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_WORKINGSET_WORKINGSETEDITOR;
67
        MPart part = showPart(partId, modelService, partService, application);
88 68
        WorkingSetEditor editor = (WorkingSetEditor) part.getObject();
89 69
        editor.init(workingSetUuid);
90 70
    }
91 71

  
92 72
    public static void openCharacterMatrix(UUID workingSetUuid, EModelService modelService, EPartService partService, MApplication application){
93
        MPart part = partService.createPart(AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_WORKINGSET_MATRIX_CHARACTERMATRIXPART);
94
        MPartStack editorAreaPartStack = WorkbenchUtility.getEditorAreaPartStack(application, modelService);
95
        if(editorAreaPartStack!=null){
96
            editorAreaPartStack.getChildren().add(part);
97
        }
98
        part = partService.showPart(part, PartState.ACTIVATE);
73
        String partId = AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_WORKINGSET_MATRIX_CHARACTERMATRIXPART;
74
        MPart part = showPart(partId, modelService, partService, application);
99 75
        CharacterMatrixPart editor = (CharacterMatrixPart) part.getObject();
100 76
        editor.init(workingSetUuid, true);
101 77
    }
102 78

  
103 79
    public static void openSpecimenEditor(DerivateViewEditorInput input, EModelService modelService, EPartService partService, MApplication application){
104
        MPart part = partService.createPart(AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DERIVATE_DERIVATEVIEW);
80
        String partId = AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DERIVATE_DERIVATEVIEW;
81
        MPart part = showPart(partId, modelService, partService, application);
82
        DerivateView derivateView = (DerivateView) part.getObject();
83
        derivateView.init(input);
84
    }
85

  
86
    public static void openRightsEditor(CdmAuthorityEditorInput input, EModelService modelService, EPartService partService, MApplication application){
87
        String partId = AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_GROUP_AUTHORITY_E4_CDMAUTHORITYEDITORE4;
88
        MPart part = showPart(partId, modelService, partService, application);
89
        CdmAuthorityEditorE4 authorityView = (CdmAuthorityEditorE4) part.getObject();
90
        authorityView.init(input);
91
    }
92

  
93
    private static MPart showPart(String partId, EModelService modelService, EPartService partService, MApplication application){
94
        MPart part = partService.findPart(partId);
95
        if(part==null || modelService.getPartDescriptor(partId).isAllowMultiple()){
96
            part = partService.createPart(partId);
97
        }
105 98
        MPartStack editorAreaPartStack = WorkbenchUtility.getEditorAreaPartStack(application, modelService);
106 99
        if(editorAreaPartStack!=null){
107 100
            editorAreaPartStack.getChildren().add(part);
108 101
        }
109
        part = partService.showPart(part, PartState.ACTIVATE);
110
        DerivateView derivateView = (DerivateView) part.getObject();
111
        derivateView.init(input);
102
        return partService.showPart(part, PartState.ACTIVATE);
112 103
    }
113 104

  
114 105
	public static void openTaxonNodeE4(UUID taxonNodeUuid, EModelService modelService, EPartService partService, MApplication application) {
......
156 147
                break;
157 148
            }
158 149
        }
159
        MPart part = partService.createPart(NAME_EDITOR_ID);
160

  
161
        MPartStack editorAreaPartStack = WorkbenchUtility.getEditorAreaPartStack(application, modelService);
162
        if(editorAreaPartStack!=null){
163
            editorAreaPartStack.getChildren().add(part);
164
        }
165
        part = partService.showPart(part, PartState.ACTIVATE);
166

  
150
        MPart part = showPart(NAME_EDITOR_ID, modelService, partService, application);
167 151
        TaxonNameEditorE4 editor = (TaxonNameEditorE4) part.getObject();
168 152
        editor.init(input);
169 153
    }
170
    public static void openRightsEditor(CdmAuthorityEditorInput input, EModelService modelService, EPartService partService, MApplication application){
171
        MPart part = partService.createPart("eu.etaxonomy.taxeditor.editor.group.authority.e4.CdmAuthorityEditorE4");
172
        MPartStack editorAreaPartStack = WorkbenchUtility.getEditorAreaPartStack(application, modelService);
173
        if(editorAreaPartStack!=null){
174
            editorAreaPartStack.getChildren().add(part);
175
        }
176
        part = partService.showPart(part, PartState.ACTIVATE);
177
        CdmAuthorityEditorE4 authorityView = (CdmAuthorityEditorE4) part.getObject();
178
        authorityView.init(input);
179
    }
180 154

  
181 155
	/**
182 156
	 * An uninitialized taxon is one that hasn't been saved yet. As such, it

Also available in: Unified diff