Project

General

Profile

Revision be02f4f9

IDbe02f4f94259d5ef036e895d59a07dc751d2d32a
Parent 78c4b063
Child 6ec96dc0

Added by Patrick Plitzner about 3 years ago

ref #6595, 6568 Open taxon name editor in editor area

  • migrate taxonomic perspective

View differences:

eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/LifeCycleManager.java
18 18
import org.eclipse.e4.ui.model.application.MApplication;
19 19
import org.eclipse.e4.ui.model.application.ui.MElementContainer;
20 20
import org.eclipse.e4.ui.model.application.ui.MUIElement;
21
import org.eclipse.e4.ui.model.application.ui.advanced.MPlaceholder;
22 21
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
23
import org.eclipse.e4.ui.model.application.ui.basic.MPartStack;
24 22
import org.eclipse.e4.ui.workbench.lifecycle.PostContextCreate;
25 23
import org.eclipse.e4.ui.workbench.lifecycle.PreSave;
26 24
import org.eclipse.e4.ui.workbench.lifecycle.ProcessAdditions;
......
80 78
                parent.getChildren().remove(part);
81 79
            }
82 80
        }
83

  
84
        //FIXME E4 org.eclipse.ui.ediorss will not exist anymore when fully migrated
85
        List<MPlaceholder> uiElements = modelService.findElements(application, "org.eclipse.ui.editorss", MPlaceholder.class, null);
86
        for (MUIElement element : uiElements) {
87
            MElementContainer<MUIElement> parent = element.getParent();
88
            parent.setSelectedElement(null);
89
            parent.getChildren().remove(element);
90
        }
91
        List<MPartStack> additionals = modelService.findElements(application, "additional", MPartStack.class, null);
92
        for (MUIElement additional : additionals) {
93
            MElementContainer<MUIElement> parent = additional.getParent();
94
            parent.setSelectedElement(null);
95
            parent.getChildren().remove(additional);
96
        }
97 81
    }
98 82

  
99 83
    /**
eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/perspective/Default.java
1 1
/**
2
 * 
2
 *
3 3
 */
4 4
package eu.etaxonomy.taxeditor.perspective;
5 5

  
6 6
import org.eclipse.ui.IPageLayout;
7 7
import org.eclipse.ui.IPerspectiveFactory;
8 8
import org.eclipse.ui.IPlaceholderFolderLayout;
9
import org.eclipse.ui.progress.IProgressConstants;
10

  
11
import eu.etaxonomy.taxeditor.view.datasource.CdmDataSourceViewPart;
12 9

  
13 10
/**
14 11
 * @author n.hoffmann
......
17 14
public abstract class Default implements IPerspectiveFactory {
18 15

  
19 16
	protected IPlaceholderFolderLayout folderAdditional;
20
	
17

  
21 18
	public static final String ADDITIONAL = "additional";
22
	
19

  
23 20
	/**
24
	 * 
21
	 *
25 22
	 * @param layout
26 23
	 * @param refId
27 24
	 */
28 25
	public void createAdditionalFolder(IPageLayout layout, String refId) {
29
		folderAdditional = layout.createPlaceholderFolder(ADDITIONAL, IPageLayout.BOTTOM, 0.25f, refId);
30
		
31
		folderAdditional.addPlaceholder(CdmDataSourceViewPart.ID);
32
		folderAdditional.addPlaceholder(IProgressConstants.PROGRESS_VIEW_ID);
33 26
	}
34 27

  
35 28
}
eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/perspective/Taxonomic.java
12 12
import org.eclipse.ui.IFolderLayout;
13 13
import org.eclipse.ui.IPageLayout;
14 14

  
15
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewPart;
16
import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigator;
17
import eu.etaxonomy.taxeditor.navigation.search.SearchResultView;
18
import eu.etaxonomy.taxeditor.view.detail.DetailsViewPart;
19
import eu.etaxonomy.taxeditor.view.supplementaldata.SupplementalDataViewPart;
15
import eu.etaxonomy.taxeditor.store.AppModelId;
20 16

  
21 17
/**
22 18
 * @author n.hoffmann
......
25 21
 */
26 22
public class Taxonomic extends Default {
27 23

  
28
	/* (non-Javadoc)
29
	 * @see org.eclipse.ui.IPerspectiveFactory#createInitialLayout(org.eclipse.ui.IPageLayout)
30
	 */
31 24
	@Override
32 25
	public void createInitialLayout(IPageLayout layout) {
26
	    String details = AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_VIEW_E4_DETAILS_DETAILSPARTE4;
27
	    String supplemental = AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_VIEW_E4_SUPPLEMENTALDATA_SUPPLEMENTALDATAPARTE4;
28
	    String navigator = eu.etaxonomy.taxeditor.navigation.AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_NAVIGATION_NAVIGATOR;
29
	    String nameEditor = eu.etaxonomy.taxeditor.editor.AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_NAME_E4_TAXONNAMEEDITORE4;
30
	    String factual = eu.etaxonomy.taxeditor.editor.AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DESCRIPTIVE_E4_FACTUALDATAPARTE4;
31
	    String searchResults = eu.etaxonomy.taxeditor.navigation.AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_NAVIGATION_SEARCH_E4_SEARCHRESULTVIEWE4;
32

  
33

  
33 34
		IFolderLayout navigationFolder = layout.createFolder("navigation", IPageLayout.LEFT, 0.25f, layout.getEditorArea());
34 35

  
35
		navigationFolder.addView(TaxonNavigator.ID);
36
		navigationFolder.addPlaceholder(SearchResultView.ID + ":*");
36
		navigationFolder.addView(navigator);
37
		navigationFolder.addPlaceholder(searchResults);
38

  
39
		layout.addPlaceholder(nameEditor, IPageLayout.BOTTOM, 0.5f, layout.getEditorArea());
37 40

  
38
		layout.addView(DetailsViewPart.ID, IPageLayout.RIGHT, 0.25f, layout.getEditorArea());
39
		layout.addView(SupplementalDataViewPart.ID, IPageLayout.BOTTOM, 0.25f, DetailsViewPart.ID);
41
		layout.addView(details, IPageLayout.RIGHT, 0.25f, layout.getEditorArea());
42
		layout.addView(supplemental, IPageLayout.BOTTOM, 0.25f, details);
40 43

  
41
		layout.addView(DescriptiveViewPart.ID, IPageLayout.BOTTOM, 0.25f, layout.getEditorArea());
44
		layout.addView(factual, IPageLayout.BOTTOM, 0.25f, layout.getEditorArea());
42 45

  
43 46
		createAdditionalFolder(layout, layout.getEditorArea());
44 47
	}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java
15 15
import org.eclipse.core.commands.ExecutionEvent;
16 16
import org.eclipse.core.commands.operations.IOperationHistory;
17 17
import org.eclipse.core.commands.operations.IUndoContext;
18
import org.eclipse.e4.ui.model.application.MApplication;
18 19
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
20
import org.eclipse.e4.ui.model.application.ui.basic.MPartStack;
21
import org.eclipse.e4.ui.workbench.modeling.EModelService;
19 22
import org.eclipse.e4.ui.workbench.modeling.EPartService;
20 23
import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState;
21 24
import org.eclipse.jface.dialogs.MessageDialog;
......
78 81
	public static void openTaxonNodeE4(UUID taxonNodeUuid) throws Exception {
79 82
	    //FIXME E4 this can probably be removed when fully migrated
80 83
        TaxonEditorInputE4 input = TaxonEditorInputE4.NewInstance(taxonNodeUuid);
81
        openNameEditor_internal(input);
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
	public static void openTaxonNodeE4(UUID taxonNodeUuid, EModelService modelService, EPartService partService, MApplication application) throws Exception {
90
	    TaxonEditorInputE4 input = TaxonEditorInputE4.NewInstance(taxonNodeUuid);
91
	    openNameEditor_internal(input, modelService, partService, application);
92
	}
93

  
94
	public static void openTaxonBaseE4(UUID taxonBaseUuid, EModelService modelService, EPartService partService, MApplication application) {
95
	    TaxonEditorInputE4 input = TaxonEditorInputE4.NewInstanceFromTaxonBase(taxonBaseUuid);
96
	    openNameEditor_internal(input, modelService, partService, application);
82 97
	}
83 98

  
84 99
    public static void openTaxonBaseE4(UUID taxonBaseUuid) {
85 100
        //FIXME E4 this can probably be removed when fully migrated
86 101
        TaxonEditorInputE4 input = TaxonEditorInputE4.NewInstanceFromTaxonBase(taxonBaseUuid);
87
        openNameEditor_internal(input);
102

  
103
        EPartService partService = TaxeditorEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getService(EPartService.class);
104
        EModelService modelService = TaxeditorEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getService(EModelService.class);
105
        openNameEditor_internal(input, modelService, partService, null);
88 106
    }
89 107

  
90
    private static void openNameEditor_internal(TaxonEditorInputE4 input) {
108
    private static void openNameEditor_internal(TaxonEditorInputE4 input, EModelService modelService, EPartService partService, MApplication application) {
91 109
        TaxonBase taxonBase = input.getTaxon();
92 110
        if(taxonBase==null){
93 111
            return;
......
103 121
            }
104 122
        }
105 123

  
106
        EPartService partService = TaxeditorEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getService(EPartService.class);
107 124
        Collection<MPart> parts = partService.getParts();
108 125
        MPart part = null;
109 126
        //check if part is already opened
110 127
        for (MPart mPart : parts) {
111 128
            if(mPart.getObject() instanceof TaxonNameEditorE4
129
                    && ((TaxonNameEditorE4) mPart.getObject()).getTaxon()!=null
112 130
                    && ((TaxonNameEditorE4) mPart.getObject()).getTaxon().equals(input.getTaxon())){
113 131
                part = mPart;
114 132
                break;
......
116 134
        }
117 135
        if(part==null){
118 136
            part = partService.createPart(NAME_EDITOR_ID);
119
            part = partService.showPart(part, PartState.ACTIVATE);
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);
141
            }
142
            partService.showPart(part, PartState.ACTIVATE);
143

  
120 144
            TaxonNameEditorE4 editor = (TaxonNameEditorE4) part.getObject();
121 145
            editor.init(input);
122 146
        }
123
        part = partService.showPart(part, PartState.ACTIVATE);
147
        else{
148
            part = partService.showPart(part, PartState.ACTIVATE);
149
        }
124 150
    }
125 151

  
126 152
	/**
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/NavigationUtil.java
16 16

  
17 17
import org.eclipse.core.commands.operations.IUndoContext;
18 18
import org.eclipse.core.commands.operations.UndoContext;
19
import org.eclipse.e4.ui.model.application.MApplication;
19 20
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
21
import org.eclipse.e4.ui.workbench.modeling.EModelService;
20 22
import org.eclipse.e4.ui.workbench.modeling.EPartService;
21 23
import org.eclipse.jface.wizard.WizardDialog;
22 24
import org.eclipse.swt.widgets.Shell;
......
60 62
	 *
61 63
	 * @param selectedObject a {@link eu.etaxonomy.cdm.model.common.CdmBase} object.
62 64
	 */
63
	public static void openEditor(UuidAndTitleCache uuidAndTitleCache, Shell shell){
65
	public static void openEditor(UuidAndTitleCache uuidAndTitleCache, Shell shell, EModelService modelService, EPartService partService, MApplication application){
64 66
	    Class<?> type = uuidAndTitleCache.getType();
65 67
	    ICdmBase cdmBase = null;
66 68
	    if(type.equals(Classification.class)){
......
79 81
	        MessagingUtils.warningDialog(Messages.NavigationUtil_UNKNOWN_TYPE, NavigationUtil.class, Messages.NavigationUtil_UNKNOWN_TYPE_MESSAGE);
80 82
	    }
81 83
	    if(cdmBase!=null){
82
	    	openEditor(cdmBase, shell);
84
	    	openEditor(cdmBase, shell, modelService, partService, application);
83 85
	    }
84 86
	    else{
85 87
	    	MessagingUtils.warningDialog(Messages.NavigationUtil_NOT_FOUND, NavigationUtil.class, Messages.NavigationUtil_NOT_FOUND_MESSAGE);
86 88
	    }
87 89
	}
88 90

  
89
	public static void openEditor(ICdmBase selectedObject, Shell shell){
91
	public static void openEditor(ICdmBase selectedObject, Shell shell, EModelService modelService, EPartService partService, MApplication application){
90 92
		UUID entityUuid = selectedObject.getUuid();
91 93
		try {
92 94
			if(selectedObject instanceof TaxonNode){
......
100 102
			        dialog.open();
101 103
			    }
102 104
			    else{
103
			        EditorUtil.openTaxonNodeE4(entityUuid);
105
			        EditorUtil.openTaxonNodeE4(entityUuid, modelService, partService, application);
104 106
			    }
105 107
			}
106 108
			else if(selectedObject instanceof TaxonBase){
107
			    EditorUtil.openTaxonBaseE4(entityUuid);
109
			    EditorUtil.openTaxonBaseE4(entityUuid, modelService, partService, application);
108 110
			}
109 111
			else{
110 112
				MessagingUtils.warningDialog(Messages.NavigationUtil_UNSUPPORTED_TYPE, NavigationUtil.class, Messages.NavigationUtil_UNSUPPORTED_TYPE_MESSAGE + selectedObject);
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/TaxonNavigatorE4.java
33 33
import org.eclipse.e4.ui.di.Focus;
34 34
import org.eclipse.e4.ui.di.UIEventTopic;
35 35
import org.eclipse.e4.ui.di.UISynchronize;
36
import org.eclipse.e4.ui.model.application.MApplication;
36 37
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
37 38
import org.eclipse.e4.ui.services.EMenuService;
39
import org.eclipse.e4.ui.workbench.modeling.EModelService;
40
import org.eclipse.e4.ui.workbench.modeling.EPartService;
38 41
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
39 42
import org.eclipse.jface.util.LocalSelectionTransfer;
40 43
import org.eclipse.jface.viewers.ISelection;
......
124 127
    @Inject
125 128
    private MPart thisPart;
126 129

  
130
    @Inject
131
    private MApplication application;
132

  
133
    @Inject
134
    private EModelService modelService;
135

  
136
    @Inject
137
    private EPartService partService;
138

  
127 139
    private boolean linkWithTaxon = false;
128 140

  
129 141
    @Inject
......
150 162
            if(selection instanceof IStructuredSelection){
151 163
                Object firstElement = ((IStructuredSelection) selection).getFirstElement();
152 164
                if(firstElement instanceof ICdmBase){
153
                    NavigationUtil.openEditor((ICdmBase) firstElement, viewer.getControl().getShell());
165
                    NavigationUtil.openEditor((ICdmBase) firstElement, viewer.getControl().getShell(), modelService, partService, application);
154 166
                }
155 167
            }
156 168
        });
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/search/e4/SearchResultViewE4.java
21 21
import org.eclipse.core.runtime.Status;
22 22
import org.eclipse.core.runtime.jobs.Job;
23 23
import org.eclipse.e4.ui.di.Focus;
24
import org.eclipse.e4.ui.model.application.MApplication;
24 25
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
25 26
import org.eclipse.e4.ui.services.EMenuService;
27
import org.eclipse.e4.ui.workbench.modeling.EModelService;
26 28
import org.eclipse.e4.ui.workbench.modeling.EPartService;
27 29
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
28 30
import org.eclipse.jface.viewers.ArrayContentProvider;
......
104 106
    @Inject
105 107
    private ESelectionService selService;
106 108

  
109
    @Inject
110
    private MApplication application;
111

  
112
    @Inject
113
    private EModelService modelService;
114

  
115
    @Inject
116
    private EPartService partService;
117

  
107 118
    private ISelectionChangedListener selectionChangedListener;
108 119

  
109 120
	/** {@inheritDoc} */
......
139 150
			    if(selection instanceof IStructuredSelection){
140 151
			        Object firstElement = ((IStructuredSelection) selection).getFirstElement();
141 152
			        if(firstElement instanceof UuidAndTitleCache){
142
			            NavigationUtil.openEditor((UuidAndTitleCache) firstElement, resultViewer.getControl().getShell());
153
			            NavigationUtil.openEditor((UuidAndTitleCache) firstElement, resultViewer.getControl().getShell(), modelService, partService, application);
143 154
			        }
144 155
			    }
145 156
			}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)