Project

General

Profile

Revision f13a970a

IDf13a970a6f10f19bfba2e96ff735cb9334d4037e
Parent ae6dd647
Child a9e74373

Added by Patrick Plitzner over 2 years ago

ref #6596 Refactored selection handling to support e3 and e4 parts

View differences:

eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/referencingobjects/ReferencingObjectsView.java
20 20
import org.eclipse.core.runtime.IProgressMonitor;
21 21
import org.eclipse.core.runtime.IStatus;
22 22
import org.eclipse.core.runtime.Status;
23
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
24
import org.eclipse.core.runtime.jobs.IJobChangeListener;
25 23
import org.eclipse.core.runtime.jobs.Job;
26
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
27 24
import org.eclipse.jface.action.MenuManager;
28 25
import org.eclipse.jface.viewers.CellEditor;
29 26
import org.eclipse.jface.viewers.ICellModifier;
......
41 38
import org.eclipse.swt.widgets.Display;
42 39
import org.eclipse.swt.widgets.Menu;
43 40
import org.eclipse.swt.widgets.Table;
44
import org.eclipse.ui.IActionBars;
45 41
import org.eclipse.ui.IWorkbenchPart;
46 42
import org.springframework.remoting.RemoteAccessException;
47 43

  
......
80 76
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
81 77
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
82 78
import eu.etaxonomy.taxeditor.model.DescriptionHelper;
83
import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
84
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
85 79
import eu.etaxonomy.taxeditor.store.CdmStore;
86 80
import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart;
87 81

  
......
109 103

  
110 104
	public ReferencingObjectsView() {
111 105
	  // cdmEntitySession = CdmStore.getCurrentSessionManager().getNullSession();
112
	    
106

  
113 107
		//cdmEntitySession = CdmStore.getCurrentSessionManager().bindNullSession();
114 108
	}
115 109

  
......
123 117
		createColumns(viewer);
124 118
		viewer.setContentProvider(new ReferencingObjectsContentProvider());
125 119
		viewer.setLabelProvider(new ReferencingObjectsLabelProvider());
126
		
120

  
127 121
		viewer.setCellModifier(new ICellModifier() {
128 122
            @Override
129 123
            public void modify(Object element, String property, Object value) {
......
197 191
	    if (actualUuid == entityUUID){
198 192
	        return ;
199 193
	    }
200
	    
194

  
201 195
	    if(actualMonitor!=null && !actualMonitor.isCanceled()){
202 196
//	        boolean success = false;
203 197
//	        //wait for cancel to be done
......
257 251
	                    return Status.CANCEL_STATUS;
258 252
	                }
259 253
	                monitor.worked(80);
260
                    
254

  
261 255
	                updateView();
262 256
//	                if(previousCdmEntitySession != null) {
263 257
//	                    previousCdmEntitySession.bind();
264 258
//	                }else{
265
//	                	CdmStore.getCurrentSessionManager().bind(null); 
259
//	                	CdmStore.getCurrentSessionManager().bind(null);
266 260
//	                }
267 261
	               // actualUuid = entityUUID;
268 262
				}
269 263
				monitor.done();
270 264
				actualMonitor = null;
271
				
265

  
272 266
				return Status.OK_STATUS;
273 267

  
274 268

  
......
388 382
	    Display.getDefault().asyncExec(new Runnable() {
389 383
            @Override
390 384
            public void run() {
391
            	
385

  
392 386
        		if (viewer != null && !viewer.getControl().isDisposed()){
393 387
        			try{
394 388
        				viewer.setInput(referencingObjects);
......
418 412
                } else {
419 413
                    setContentDescription(description);
420 414
                }
421
        	    
415

  
422 416
            }
423 417

  
424 418
         });
......
439 433

  
440 434
	/** {@inheritDoc} */
441 435
	@Override
442
	public void showViewer(IWorkbenchPart part, IStructuredSelection selection) {
436
	public void showViewer(Object part, IStructuredSelection selection) {
443 437
	//	this.part = part;
444 438

  
445 439
		Object firstElement = selection.getFirstElement();
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java
258 258
	 * @return the taxon editor that has focus
259 259
	 */
260 260
	public static MultiPageTaxonEditor getActiveMultiPageTaxonEditor() {
261
		IEditorPart editorPart = getActiveEditor();
261
		Object editorPart = getActiveE4Editor();
262 262
		if (editorPart != null && editorPart instanceof MultiPageTaxonEditor) {
263 263
			MultiPageTaxonEditor editor = (MultiPageTaxonEditor) editorPart;
264 264
			editor.getConversationHolder().bind();
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/group/authority/handler/EditCdmAuthoritiesHandler.java
44 44
	 */
45 45
	@Override
46 46
	public Object execute(ExecutionEvent event) throws ExecutionException {
47
		BulkEditor editor = (BulkEditor) EditorUtil.getActiveEditor();
47
		BulkEditor editor = (BulkEditor) EditorUtil.getActiveE4Editor();
48 48

  
49 49
		ISelection selection = editor.getSite().getSelectionProvider().getSelection();
50 50
		if(selection instanceof LineSelection){
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/TaxonNameEditor.java
857 857
	 * @return a boolean.
858 858
	 */
859 859
	public boolean isActive() {
860
		IWorkbenchPart activePart = AbstractUtility.getActivePart();
861
		return editor.equals(activePart);
860
		return editor.equals(AbstractUtility.getActiveE4Part());
862 861
	}
863 862

  
864 863
	/**
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/handler/OpenDistributionHandler.java
36 36
    public Object execute(ExecutionEvent event) throws ExecutionException {
37 37

  
38 38
        ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
39
        ChecklistEditor editor = (ChecklistEditor) EditorUtil.getActiveEditor();
39
        ChecklistEditor editor = (ChecklistEditor) EditorUtil.getActiveE4Editor();
40 40

  
41 41
        if (currentSelection instanceof IStructuredSelection) {
42 42

  
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/ConceptViewPart.java
59 59
		if(part == this){
60 60
		    return;
61 61
		}
62
		if(AbstractUtility.getActiveEditor() == null){
62
		if(AbstractUtility.getActiveE4Editor() == null){
63 63
			showEmptyPage();
64 64
			return;
65 65
		}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/graph/ConceptGraphView.java
45 45
//			return;
46 46
//		}
47 47

  
48
		if(EditorUtil.getActiveEditor() == null){
48
		if(EditorUtil.getActiveE4Editor() == null){
49 49
			showEmptyPage();
50 50
			return;
51 51
		}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/handler/CreateConceptRelationHandler.java
18 18
import org.eclipse.jface.viewers.ISelection;
19 19
import org.eclipse.jface.viewers.IStructuredSelection;
20 20
import org.eclipse.swt.widgets.Event;
21
import org.eclipse.ui.IEditorPart;
22 21
import org.eclipse.ui.IWorkbenchPart;
23 22
import org.eclipse.ui.handlers.HandlerUtil;
24 23

  
......
48 47
	    IUndoContext undoContext = null;
49 48
	    ConversationHolder conversationHolder = null;
50 49
	    Taxon taxon = null;
51
		IEditorPart activeEditor = AbstractUtility.getActiveEditor();
50
		Object activeEditor = AbstractUtility.getActiveE4Editor();
52 51
		if(activeEditor instanceof MultiPageTaxonEditor){
53 52
		    MultiPageTaxonEditor taxonEditor = (MultiPageTaxonEditor)activeEditor;
54 53
		    taxon = taxonEditor.getTaxon();
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/handler/OpenRelatedConceptHandler.java
14 14
import org.eclipse.core.commands.ExecutionException;
15 15
import org.eclipse.jface.viewers.ISelection;
16 16
import org.eclipse.jface.viewers.IStructuredSelection;
17
import org.eclipse.ui.IEditorPart;
18 17
import org.eclipse.ui.PartInitException;
19 18
import org.eclipse.ui.handlers.HandlerUtil;
20 19

  
......
46 45
            Object selectedElement = structuredSelection.getFirstElement();
47 46

  
48 47
            if(selectedElement instanceof TaxonRelationship){
49
                IEditorPart activeEditor = AbstractUtility.getActiveEditor();
48
                Object activeEditor = AbstractUtility.getActiveE4Editor();
50 49
                if(activeEditor instanceof MultiPageTaxonEditor){
51 50
                    relatedTaxon = getRelatedTaxon((TaxonRelationship) selectedElement, ((MultiPageTaxonEditor) activeEditor).getTaxon());
52 51
                }
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptiveViewPart.java
153 153
	/** {@inheritDoc} */
154 154
	@Override
155 155
    protected void selectionChanged_internal(IWorkbenchPart part, ISelection selection) {
156
		if(AbstractUtility.getActiveEditor() == null){
156
		if(AbstractUtility.getActiveE4Editor() == null){
157 157
			showEmptyPage();
158 158
			return;
159 159
		}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/DescriptionsMenuPropertyTester.java
160 160
	}
161 161

  
162 162
	private boolean isTaxonEditor() {
163
	    if(AbstractUtility.getActiveEditor() instanceof MultiPageTaxonEditor){
163
	    if(AbstractUtility.getActiveE4Editor() instanceof MultiPageTaxonEditor){
164 164
	        return true;
165 165
	    }
166 166
	    return false;
167 167
	}
168 168

  
169 169
	private boolean isBulkEditor() {
170
	    if(AbstractUtility.getActiveEditor() instanceof BulkEditor){
170
	    if(AbstractUtility.getActiveE4Editor() instanceof BulkEditor){
171 171
	        return true;
172 172
	    }
173 173
	    return false;
174 174
	}
175 175

  
176 176
	private boolean isDerivateEditor() {
177
	    if(AbstractUtility.getActiveEditor() instanceof DerivateView){
177
	    if(AbstractUtility.getActiveE4Editor() instanceof DerivateView){
178 178
	        return true;
179 179
	    }
180 180
	    return false;
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/DynamicFeatureMenu.java
28 28
import eu.etaxonomy.cdm.model.description.Feature;
29 29
import eu.etaxonomy.cdm.model.description.FeatureNode;
30 30
import eu.etaxonomy.cdm.model.description.FeatureTree;
31
import eu.etaxonomy.taxeditor.editor.EditorUtil;
31
import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;
32 32
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewPart;
33 33
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateDescriptionElementOperation;
34 34
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
......
47 47
 */
48 48
public class DynamicFeatureMenu extends CompoundContributionItem {
49 49

  
50
	private final ISelectionService selectionService = EditorUtil.getActivePart()
51
			.getSite().getWorkbenchWindow().getSelectionService();
52
	private final IHandlerService handlerService = (IHandlerService) EditorUtil
53
			.getService(IHandlerService.class);
50
	private final ISelectionService selectionService = TaxeditorEditorPlugin.getDefault().getWorkbench().getService(ISelectionService.class);
51
	private final IHandlerService handlerService = TaxeditorEditorPlugin.getDefault().getWorkbench().getService(IHandlerService.class);
54 52

  
55 53
	/*
56 54
	 * (non-Javadoc)
......
105 103
	private void createMenuItem(Menu menu, final Feature feature) {
106 104
		MenuItem menuItem = new MenuItem(menu, -1);
107 105
		final Feature deproxiedFeature = HibernateProxyHelper.deproxy(feature, Feature.class);
108
				
106

  
109 107
		String label = deproxiedFeature.getLabel(PreferencesUtil.getGlobalLanguage());
110 108
		if (label == null){
111 109
			menuItem.setText(deproxiedFeature.getLabel());
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/MediaViewPart.java
92 92
	    if(part==this){
93 93
	        return;
94 94
	    }
95
		if(AbstractUtility.getActiveEditor() == null){
95
		if(AbstractUtility.getActiveE4Editor() == null){
96 96
			showEmptyPage();
97 97
			return;
98 98
		}
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/handler/AbstractAlignmentEditorHandler.java
12 12
import org.eclipse.core.commands.AbstractHandler;
13 13
import org.eclipse.core.commands.ExecutionEvent;
14 14
import org.eclipse.core.commands.ExecutionException;
15
import org.eclipse.ui.IEditorPart;
16 15

  
17 16
import eu.etaxonomy.taxeditor.model.AbstractUtility;
18 17
import eu.etaxonomy.taxeditor.molecular.editor.AlignmentEditor;
......
29 28
 */
30 29
public abstract class AbstractAlignmentEditorHandler extends AbstractHandler {
31 30
	public static AlignmentEditor getActiveAlignmentEditor() {
32
        IEditorPart activeEditor = AbstractUtility.getActiveEditor();
31
	    Object activeEditor = AbstractUtility.getActiveE4Editor();
33 32
        if (activeEditor instanceof AlignmentEditor) {
34 33
            return (AlignmentEditor)activeEditor;
35 34
        }
......
37 36
        	return null;
38 37
        }
39 38
	}
40
	
41
	
39

  
40

  
42 41
    @Override
43 42
    public Object execute(ExecutionEvent event) throws ExecutionException {
44 43
    	AlignmentEditor editor = getActiveAlignmentEditor();
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/handler/AbstractPherogramComponentHandler.java
9 9
package eu.etaxonomy.taxeditor.molecular.handler;
10 10

  
11 11

  
12
import info.bioinfweb.libralign.alignmentarea.AlignmentArea;
13
import info.bioinfweb.libralign.dataarea.implementations.pherogram.PherogramArea;
14
import info.bioinfweb.libralign.pherogram.PherogramComponent;
15

  
16 12
import java.util.Iterator;
17 13

  
18 14
import org.eclipse.core.commands.AbstractHandler;
19 15
import org.eclipse.core.commands.ExecutionEvent;
20 16
import org.eclipse.core.commands.ExecutionException;
21
import org.eclipse.ui.IWorkbenchPart;
22 17

  
23 18
import eu.etaxonomy.taxeditor.model.AbstractUtility;
24 19
import eu.etaxonomy.taxeditor.molecular.editor.AlignmentEditor;
25 20
import eu.etaxonomy.taxeditor.molecular.editor.PherogramViewPart;
21
import info.bioinfweb.libralign.alignmentarea.AlignmentArea;
22
import info.bioinfweb.libralign.dataarea.implementations.pherogram.PherogramArea;
23
import info.bioinfweb.libralign.pherogram.PherogramComponent;
26 24

  
27 25

  
28 26

  
......
36 34
public abstract class AbstractPherogramComponentHandler extends AbstractHandler {
37 35
    @Override
38 36
    public Object execute(ExecutionEvent event) throws ExecutionException {
39
        IWorkbenchPart activePart = AbstractUtility.getActivePart();
37
        Object activePart = AbstractUtility.getActiveE4Part();
40 38

  
41 39
        if (activePart instanceof AlignmentEditor) {
42 40
            AlignmentEditor editor = (AlignmentEditor)activePart;
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/handler/LoadPherogramHandler.java
17 17
import org.eclipse.core.commands.ExecutionEvent;
18 18
import org.eclipse.core.commands.ExecutionException;
19 19
import org.eclipse.swt.widgets.FileDialog;
20
import org.eclipse.ui.IEditorPart;
21 20

  
22 21
import eu.etaxonomy.taxeditor.model.AbstractUtility;
23 22
import eu.etaxonomy.taxeditor.model.MessagingUtils;
......
36 35
public class LoadPherogramHandler extends AbstractHandler {
37 36
	//TODO Change so that also URIs which do not point to files can be specified.
38 37

  
39
	/* (non-Javadoc)
40
     * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
41
     */
42 38
    @Override
43 39
    public Object execute(ExecutionEvent event) throws ExecutionException {
44
        IEditorPart activeEditor = AbstractUtility.getActiveEditor();
40
        Object activeEditor = AbstractUtility.getActiveE4Editor();
45 41
        if (activeEditor instanceof AlignmentEditor) {
46 42
            AlignmentEditor alignmentEditor = (AlignmentEditor)activeEditor;
47 43

  
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/handler/ToggleInsertOverwriteHandler.java
15 15
import org.eclipse.core.commands.ExecutionEvent;
16 16
import org.eclipse.core.commands.ExecutionException;
17 17
import org.eclipse.jface.resource.ImageDescriptor;
18
import org.eclipse.ui.IEditorPart;
19 18
import org.eclipse.ui.PlatformUI;
20 19
import org.eclipse.ui.commands.ICommandService;
21 20
import org.eclipse.ui.commands.IElementUpdater;
......
50 49

  
51 50
	@Override
52 51
	public void updateElement(UIElement element, @SuppressWarnings("rawtypes") Map parameters) {
53
        IEditorPart activeEditor = AbstractUtility.getActiveEditor();
52
	    Object activeEditor = AbstractUtility.getActiveE4Editor();
54 53
		if (activeEditor instanceof AlignmentEditor) {
55 54
			if (((AlignmentEditor)activeEditor).isInsertMode()) {
56 55
			    element.setIcon(INSERT_DESCRIPTOR);
......
62 61
				element.setText("OVR"); //$NON-NLS-1$
63 62
				element.setTooltip(Messages.ToggleInsertOverwriteHandler_SWITCH_INSERTION);
64 63
			}
65
            ((ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class)).refreshElements(
64
            PlatformUI.getWorkbench().getService(ICommandService.class).refreshElements(
66 65
                    ToggleLeftRightInsertionHandler.COMMAND_ID, null);
67 66
		}
68 67
	}
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/handler/ToggleLeftRightInsertionHandler.java
14 14
import org.eclipse.core.commands.ExecutionEvent;
15 15
import org.eclipse.core.commands.ExecutionException;
16 16
import org.eclipse.jface.resource.ImageDescriptor;
17
import org.eclipse.ui.IEditorPart;
18 17
import org.eclipse.ui.commands.IElementUpdater;
19 18
import org.eclipse.ui.menus.UIElement;
20 19

  
......
53 52

  
54 53
    @Override
55 54
    public void updateElement(UIElement element, @SuppressWarnings("rawtypes") Map parameters) {
56
        IEditorPart activeEditor = AbstractUtility.getActiveEditor();
55
        Object activeEditor = AbstractUtility.getActiveE4Editor();
57 56
        if (activeEditor instanceof AlignmentEditor) {
58 57
            setBaseEnabled(((AlignmentEditor)activeEditor).isInsertMode());
59 58
            if (((AlignmentEditor)activeEditor).isInsertLeftInPherogram()) {
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/MoveFactualDataHandler.java
12 12
import org.eclipse.jface.viewers.ISelection;
13 13
import org.eclipse.jface.viewers.TreeSelection;
14 14
import org.eclipse.swt.widgets.Display;
15
import org.eclipse.ui.IWorkbenchPart;
16 15
import org.eclipse.ui.PartInitException;
17 16
import org.eclipse.ui.handlers.HandlerUtil;
18 17

  
......
40 39
    @Override
41 40
    public Object execute(ExecutionEvent event) throws ExecutionException {
42 41
        ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
43
        IWorkbenchPart activePart = AbstractUtility.getActivePart();
42
        Object activePart = AbstractUtility.getActiveE4Part();
44 43
        TaxonNavigator navigator = null;
45 44
        if(activePart instanceof TaxonNavigator){
46 45
            navigator = (TaxonNavigator)activePart;
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/AbstractUtility.java
9 9

  
10 10
package eu.etaxonomy.taxeditor.model;
11 11

  
12
import java.lang.reflect.Field;
12 13
import java.lang.reflect.InvocationTargetException;
13 14
import java.util.ArrayList;
14 15
import java.util.Collection;
......
34 35
import org.eclipse.core.runtime.SubProgressMonitor;
35 36
import org.eclipse.core.runtime.jobs.ISchedulingRule;
36 37
import org.eclipse.core.runtime.jobs.Job;
38
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
37 39
import org.eclipse.jface.action.IStatusLineManager;
38 40
import org.eclipse.jface.operation.IRunnableWithProgress;
39 41
import org.eclipse.jface.resource.ColorRegistry;
......
53 55
import org.eclipse.ui.PlatformUI;
54 56
import org.eclipse.ui.handlers.IHandlerService;
55 57
import org.eclipse.ui.ide.undo.WorkspaceUndoUtil;
58
import org.eclipse.ui.internal.E4PartWrapper;
56 59
import org.eclipse.ui.part.EditorPart;
57 60
import org.eclipse.ui.progress.IProgressConstants;
58 61
import org.eclipse.ui.progress.IProgressService;
......
77 80
import eu.etaxonomy.taxeditor.view.supplementaldata.SupplementalDataViewPart;
78 81

  
79 82
/**
80
 * <p>
81
 * Abstract AbstractUtility class.
82
 * </p>
83 83
 *
84 84
 * @author n.hoffmann
85 85
 * @created 11.05.2009
......
93 93
    protected static IStatusLineManager statusLineManager;
94 94

  
95 95

  
96
    /**
97
     * <p>
98
     * closeAll
99
     * </p>
100
     *
101
     * @return a boolean.
102
     */
103 96
    public static boolean closeAll() {
104 97
        if(getActivePage()!=null){
105 98
            return getActivePage().closeAllEditors(true);
......
118 111
        return getActivePage() != null ? getActivePage().closeEditor(editor, true):false;
119 112
    }
120 113

  
121
    /**
122
     * <p>
123
     * getShell
124
     * </p>
125
     *
126
     * @return a {@link org.eclipse.swt.widgets.Shell} object.
127
     */
128 114
    public static Shell getShell() {
129 115

  
130 116
        return TaxeditorStorePlugin.getDefault().getWorkbench()
131 117
                .getActiveWorkbenchWindow().getShell();
132 118
    }
133 119

  
134
    /**
135
     * <p>
136
     * getActivePage
137
     * </p>
138
     *
139
     * @return a {@link org.eclipse.ui.IWorkbenchPage} object.
140
     */
141 120
    public static IWorkbenchPage getActivePage() {
142 121
        try{
143 122
            return TaxeditorStorePlugin.getDefault().getWorkbench()
......
147 126
        }
148 127
    }
149 128

  
150
    /**
151
     * <p>
152
     * getActivePart
153
     * </p>
154
     *
155
     * @return a {@link org.eclipse.ui.IWorkbenchPart} object.
156
     */
157
    public static IWorkbenchPart getActivePart() {
158
        return getActivePage() != null ? getActivePage().getActivePart() : null;
129
    public static IWorkbenchPart getActiveWorkbenchPart() {
130
        IWorkbenchPage activePage = getActivePage();
131
        if(activePage!=null){
132
            IWorkbenchPart activePart = activePage.getActivePart();
133
            if(activePart!=null){
134
                return activePart;
135
            }
136
        }
137
        return null;
138
    }
139

  
140
    public static Object getActiveE4Part() {
141
        IWorkbenchPage activePage = getActivePage();
142
        if(activePage!=null){
143
            IWorkbenchPart activePart = activePage.getActivePart();
144
            Object e4WrappedPart = getE4WrappedPart(activePart);
145
            return e4WrappedPart!=null?e4WrappedPart:activePart;
146
        }
147
        return null;
148
    }
149

  
150
    public static Object getE4WrappedPart(Object activePart){
151
        if(activePart instanceof E4PartWrapper){
152
            //FIXME can be removed when E4 migration is complete
153
            try {
154
                Field field = activePart.getClass().getDeclaredField("wrappedPart");
155
                field.setAccessible(true);
156
                Object object = field.get(activePart);
157
                if(object instanceof MPart){
158
                    return ((MPart) object).getObject();
159
                }
160
            } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
161
                e.printStackTrace();
162
            }
163
        }
164
        return null;
159 165
    }
160 166

  
161 167
    public static IWorkbench getWorkbench() {
162 168
        return TaxeditorStorePlugin.getDefault().getWorkbench();
163 169
    }
164 170

  
165
    /**
166
     * <p>
167
     * getWorkbenchWindow
168
     * </p>
169
     *
170
     * @return a {@link org.eclipse.jface.window.ApplicationWindow} object.
171
     */
172 171
    public static IWorkbenchWindow getWorkbenchWindow() {
173 172
        if (getWorkbench().getWorkbenchWindowCount() > 1) {
174 173
            throw new IllegalStateException("More than one workbench window");
......
176 175
        return getWorkbench().getWorkbenchWindows()[0];
177 176
    }
178 177

  
179
    /**
180
     * <p>
181
     * showView
182
     * </p>
183
     *
184
     * @param id
185
     *            a {@link java.lang.String} object.
186
     * @return a {@link org.eclipse.ui.IViewPart} object.
187
     */
188 178
    public static IViewPart showView(String id) {
189 179
        try {
190 180
            return PlatformUI.getWorkbench().getActiveWorkbenchWindow()
......
196 186
        }
197 187
    }
198 188

  
199
    /**
200
     * <p>
201
     * hideView
202
     * </p>
203
     *
204
     * @param view
205
     *            a {@link org.eclipse.ui.IViewPart} object.
206
     */
207 189
    public static void hideView(IViewPart view) {
208 190
        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
209 191
        .hideView(view);
210 192
    }
211 193

  
212
    /**
213
     * <p>
214
     * getView
215
     * </p>
216
     *
217
     * @param id
218
     *            a {@link java.lang.String} object.
219
     * @param restore
220
     *            a boolean.
221
     * @return a {@link org.eclipse.ui.IViewPart} object.
222
     */
223 194
    public static IViewPart getView(String id, boolean restore) {
224 195
    	IWorkbench workbench = PlatformUI.getWorkbench();
225 196
        IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
......
240 211
        return null;
241 212
    }
242 213

  
243
    /**
244
     * <p>
245
     * getService
246
     * </p>
247
     *
248
     * @param api
249
     *            a {@link java.lang.Class} object.
250
     * @return a {@link java.lang.Object} object.
251
     */
252 214
    public static Object getService(Class api) {
253 215
        return TaxeditorStorePlugin.getDefault().getWorkbench().getService(api);
254 216
    }
255 217

  
256
    /**
257
     * <p>
258
     * getCurrentTheme
259
     * </p>
260
     *
261
     * @return a {@link org.eclipse.ui.themes.ITheme} object.
262
     */
263 218
    public static ITheme getCurrentTheme() {
264 219
        IThemeManager themeManager = TaxeditorStorePlugin.getDefault()
265 220
                .getWorkbench().getThemeManager();
......
277 232
        return getCurrentTheme().getFontRegistry();
278 233
    }
279 234

  
280
    /**
281
     * <p>
282
     * getFont
283
     * </p>
284
     *
285
     * @param symbolicName
286
     *            a {@link java.lang.String} object.
287
     * @return a {@link org.eclipse.swt.graphics.Font} object.
288
     */
289 235
    public static Font getFont(String symbolicName) {
290 236
        return getFontRegistry().get(symbolicName);
291 237
    }
......
301 247
        return getCurrentTheme().getColorRegistry();
302 248
    }
303 249

  
304
    /**
305
     * <p>
306
     * getColor
307
     * </p>
308
     *
309
     * @param symbolicName
310
     *            a {@link java.lang.String} object.
311
     * @return a {@link org.eclipse.swt.graphics.Color} object.
312
     */
313 250
    public static Color getColor(String symbolicName) {
314 251
        return getColorRegistry().get(symbolicName);
315 252
    }
316 253

  
317
    /**
318
     * <p>
319
     * executeOperation
320
     * </p>
321
     *
322
     * @param operation
323
     *            a
324
     *            {@link eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation}
325
     *            object.
326
     * @return a {@link org.eclipse.core.runtime.IStatus} object.
327
     */
328 254
    public static IStatus executeOperation(final AbstractPostOperation operation) {
329 255
        if (getOperationHistory() == null) {
330 256
            throw new IllegalArgumentException(
......
508 434
        return Status.OK_STATUS;
509 435
    }
510 436

  
511

  
512
    /**
513
     * <p>
514
     * getOperationHistory
515
     * </p>
516
     *
517
     * @return a {@link org.eclipse.core.commands.operations.IOperationHistory}
518
     *         object.
519
     */
520 437
    public static IOperationHistory getOperationHistory() {
521 438
        return getWorkbench().getOperationSupport().getOperationHistory();
522 439
    }
523 440

  
524
    /**
525
     * <p>
526
     * setStatusLine
527
     * </p>
528
     *
529
     * @param message
530
     *            a {@link java.lang.String} object.
531
     */
532 441
    public static void setStatusLine(final String message) {
533 442
        Display.getDefault().asyncExec(new Runnable() {
534 443

  
......
541 450

  
542 451
    }
543 452

  
544
    /**
545
     * <p>
546
     * getMonitor
547
     * </p>
548
     *
549
     * @return a {@link org.eclipse.core.runtime.IProgressMonitor} object.
550
     */
551 453
    public static IProgressMonitor getMonitor() {
552 454
        statusLineManager.setCancelEnabled(false);
553 455
        return statusLineManager.getProgressMonitor();
......
636 538
        getProgressService().busyCursorWhile(runnable);
637 539
    }
638 540

  
639
    /**
640
     * <p>
641
     * runInUI
642
     * </p>
643
     *
644
     * @see {@link IProgressService#runInUI(org.eclipse.jface.operation.IRunnableContext, IRunnableWithProgress, ISchedulingRule)}
645
     * @param runnable
646
     *            a {@link org.eclipse.jface.operation.IRunnableWithProgress}
647
     *            object.
648
     * @param rule
649
     *            a {@link org.eclipse.core.runtime.jobs.ISchedulingRule}
650
     *            object.
651
     * @throws java.lang.reflect.InvocationTargetException
652
     *             if any.
653
     * @throws java.lang.InterruptedException
654
     *             if any.
655
     */
656 541
    public static void runInUI(IRunnableWithProgress runnable,
657 542
            ISchedulingRule rule) throws InvocationTargetException,
658 543
            InterruptedException {
659 544
        getProgressService().runInUI(getWorkbenchWindow(), runnable, rule);
660 545
    }
661 546

  
662
    /**
663
     * <p>
664
     * run
665
     * </p>
666
     *
667
     * @param fork
668
     *            a boolean.
669
     * @param cancelable
670
     *            a boolean.
671
     * @param runnable
672
     *            a {@link org.eclipse.jface.operation.IRunnableWithProgress}
673
     *            object.
674
     * @throws java.lang.reflect.InvocationTargetException
675
     *             if any.
676
     * @throws java.lang.InterruptedException
677
     *             if any.
678
     */
679 547
    public static void run(boolean fork, boolean cancelable,
680 548
            IRunnableWithProgress runnable) throws InvocationTargetException,
681 549
            InterruptedException {
682 550
        getProgressService().run(fork, cancelable, runnable);
683 551
    }
684 552

  
685
    /**
686
     * <p>
687
     * getProgressService
688
     * </p>
689
     *
690
     * @return a {@link org.eclipse.ui.progress.IProgressService} object.
691
     */
692 553
    public static IProgressService getProgressService() {
693 554
        IWorkbench workbench = PlatformUI.getWorkbench();
694 555
        return workbench.getProgressService();
695 556
    }
696 557

  
697
    /**
698
     * <p>
699
     * getProgressService2
700
     * </p>
701
     *
702
     * @return a {@link org.eclipse.ui.progress.IWorkbenchSiteProgressService}
703
     *         object.
704
     */
705 558
    public static IWorkbenchSiteProgressService getProgressService2() {
706 559
        return (IWorkbenchSiteProgressService) getService(IWorkbenchSiteProgressService.class);
707 560
    }
708 561

  
709
    /**
710
     * <p>
711
     * getPluginId
712
     * </p>
713
     *
714
     * @return a {@link java.lang.String} object.
715
     */
716 562
    public static String getPluginId() {
717 563
        return "eu.taxeditor";
718 564
    }
719 565

  
720
    /**
721
     * <p>
722
     * getActiveEditor
723
     * </p>
724
     *
725
     * @return a {@link org.eclipse.ui.IEditorPart} object.
726
     */
727 566
    public static IEditorPart getActiveEditor() {
728 567
        return getActivePage() != null ? getActivePage().getActiveEditor()
729 568
                : null;
730 569
    }
731 570

  
732
    /**
733
     * <p>
734
     * getDetailsView
735
     * </p>
736
     *
737
     * @return a {@link eu.etaxonomy.taxeditor.view.detail.DetailsViewPart}
738
     *         object.
739
     */
571
    public static Object getActiveE4Editor() {
572
        if(getActivePage()!=null){
573
            IEditorPart activeEditor = getActivePage().getActiveEditor();
574
            Object wrappedPart = getE4WrappedPart(getActivePage().getActivePart());
575
            return wrappedPart!=null?wrappedPart:activeEditor;
576
        }
577
        return null;
578
    }
579

  
740 580
    public static DetailsViewPart getDetailsView() {
741 581
        return (DetailsViewPart) getView(DetailsViewPart.ID, false);
742 582
    }
743 583

  
744
    /**
745
     * <p>
746
     * refreshDetailsViewer
747
     * </p>
748
     */
749 584
    public static void refreshDetailsViewer() {
750 585
        if (getDetailsView() != null) {
751 586
            ((AbstractCdmDataViewer) getDetailsView().getViewer()).refresh();
752 587
        }
753 588
    }
754 589

  
755
    /**
756
     * <p>
757
     * reflowDetailsViewer
758
     * </p>
759
     */
760 590
    public static void reflowDetailsViewer() {
761 591
        if (getDetailsView() != null) {
762 592
            ((AbstractCdmDataViewer) getDetailsView().getViewer()).reflow();
......
870 700
        private final T term;
871 701
        private final TreeSet<TermNode<T>> children;
872 702

  
873
        /**
874
         * @param term
875
         * @param children
876
         */
877 703
        public TermNode(T term) {
878 704
            super();
879 705
            this.term = term;
......
884 710
            this.children.add(child);
885 711
        }
886 712

  
887
        /**
888
         * @return the children
889
         */
890 713
        public TreeSet<TermNode<T>> getChildren() {
891 714
            return children;
892 715
        }
893 716

  
894
        /**
895
         * @return the term
896
         */
897 717
        public T getTerm() {
898 718
            return term;
899 719
        }
900 720

  
901
        /* (non-Javadoc)
902
         * @see java.lang.Object#hashCode()
903
         */
904 721
        @Override
905 722
        public int hashCode() {
906 723
            final int prime = 31;
......
909 726
            return result;
910 727
        }
911 728

  
912
        /* (non-Javadoc)
913
         * @see java.lang.Object#equals(java.lang.Object)
914
         */
915 729
        @Override
916 730
        public boolean equals(Object obj) {
917 731
            if (this == obj) {
......
934 748
            return true;
935 749
        }
936 750

  
937
        /* (non-Javadoc)
938
         * @see java.lang.Comparable#compareTo(java.lang.Object)
939
         */
940 751
        @Override
941 752
        public int compareTo(TermNode<T> that) {
942 753
            return this.term.getMessage().compareTo(that.term.getMessage());
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractFormSection.java
25 25
import org.eclipse.swt.widgets.Display;
26 26
import org.eclipse.swt.widgets.TypedListener;
27 27
import org.eclipse.swt.widgets.Widget;
28
import org.eclipse.ui.IEditorPart;
29 28
import org.eclipse.ui.forms.events.ExpansionEvent;
30 29
import org.eclipse.ui.forms.events.IExpansionListener;
31 30
import org.eclipse.ui.forms.widgets.Section;
......
574 573
	 */
575 574
	@Override
576 575
    public ConversationHolder getConversationHolder() {
577
	    if(AbstractUtility.getActivePart() instanceof IConversationEnabled){
578
            return ((IConversationEnabled) AbstractUtility.getActivePart()).getConversationHolder();
576
	    if(AbstractUtility.getActiveE4Part() instanceof IConversationEnabled){
577
            return ((IConversationEnabled) AbstractUtility.getActiveE4Part()).getConversationHolder();
579 578
        }
580 579
	    if(getParentElement() instanceof RootElement || getParentElement() == null){
581 580

  
582
	        IEditorPart activeEditor = AbstractUtility.getActiveEditor();
581
	        Object activeEditor = AbstractUtility.getActiveE4Editor();
583 582
	        if(activeEditor instanceof IConversationEnabled){
584
	            ConversationHolder conversation = ((IConversationEnabled) AbstractUtility.getActiveEditor()).getConversationHolder();
583
	            ConversationHolder conversation = ((IConversationEnabled) AbstractUtility.getActiveE4Editor()).getConversationHolder();
585 584
	            return conversation;
586 585
	        }
587 586
	    }else if(getParentElement() instanceof IConversationEnabled){
......
599 598
    public void update(CdmDataChangeMap changeEvents) {
600 599

  
601 600
	}
602
	
601

  
603 602
    private class ExpandListener implements IExpansionListener{
604 603
		@Override
605 604
		public void expansionStateChanging(ExpansionEvent e) {
......
617 616
	private void addExpandListener() {
618 617
		PreferencesUtil.getPreferenceStore().setDefault(getPrefKey(), isExpanded());
619 618
		setExpanded(PreferencesUtil.getPreferenceStore().getBoolean(getPrefKey()));
620
		addExpansionListener(new ExpandListener());		
619
		addExpansionListener(new ExpandListener());
621 620
	}
622 621

  
623 622
	private String getPrefKey() {
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CommandHandlerButton.java
22 22

  
23 23
import eu.etaxonomy.taxeditor.store.CdmStore;
24 24
import eu.etaxonomy.taxeditor.store.LoginManager;
25
import eu.etaxonomy.taxeditor.store.StoreUtil;
25
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
26 26

  
27 27
/**
28 28
 * A Button which executes a <code>IHandler</code> managed through a
29 29
 * <code>org.eclipse.ui.handlers</code> extension point
30
 * 
30
 *
31 31
 * see http://wiki.eclipse.org/Platform_Command_Framework#Commands
32
 * 
32
 *
33 33
 * @author a.kohlbecker
34
 * 
34
 *
35 35
 */
36 36
public class CommandHandlerButton extends Composite implements Observer {
37
	
37

  
38 38
	String commandId;
39 39
	Button button;
40 40

  
......
46 46
	public CommandHandlerButton(Composite parent, int style, String commandId)  {
47 47
		super(parent, SWT.NONE);
48 48
		this.commandId = commandId;
49
		
49

  
50 50
		setLayout(new GridLayout());
51 51
		setLayoutData(new GridData());
52
	
52

  
53 53
		button = new Button(this, style);
54 54
		button.addSelectionListener(new SelectionAdapter() {
55 55
			@Override
56 56
			public void widgetSelected(SelectionEvent se) {
57 57
				// you can execute a command directly ... but to get the proper environment it's better to execute it through the IHandlerService:
58
				IHandlerService handlerService =  (IHandlerService) StoreUtil.getActivePart().getSite().getService(IHandlerService.class);
58
				IHandlerService handlerService =  TaxeditorStorePlugin.getDefault().getWorkbench().getService(IHandlerService.class);
59 59
				try {
60 60
					handlerService.executeCommand(CommandHandlerButton.this.commandId, null);
61 61
				} catch (ExecutionException e) {
......
72 72
					e.printStackTrace();
73 73
				}
74 74
			}
75
			
75

  
76 76
		});
77 77
		updateButtonEnabledState();
78
		
78

  
79 79
		CdmStore.getLoginManager().addObserver(this);
80 80
        addDisposeListener(new DisposeListener() {
81 81
			@Override
......
94 94
		if(o instanceof LoginManager){
95 95
			updateButtonEnabledState();
96 96
		}
97
		
97

  
98 98
	}
99 99

  
100 100
	private void updateButtonEnabledState() {
101
		ICommandService commandService =  (ICommandService) StoreUtil.getActivePart().getSite().getService(ICommandService.class);
101
		ICommandService commandService =  TaxeditorStorePlugin.getDefault().getWorkbench().getService(ICommandService.class);
102 102
		Command command = commandService.getCommand(commandId);
103 103
		if(!button.isDisposed()){
104
			button.setEnabled(command != null && command.isEnabled());			
104
			button.setEnabled(command != null && command.isEnabled());
105 105
		}
106 106
	}
107 107

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/AbstractCdmEditorViewPart.java
92 92
            Display.getCurrent().asyncExec(delaySelection);
93 93
        }
94 94
    }
95
    
96
    
95

  
96

  
97 97

  
98 98
    /** {@inheritDoc} */
99 99
    @Override
......
127 127
    /** {@inheritDoc} */
128 128
    @Override
129 129
    public void changed(Object object) {
130
        if (part instanceof AbstractCdmViewPart) {
131
            ((AbstractCdmViewPart) part).changed(object);
132
        } else {
130
        if(part instanceof IDirtyMarkable){
131
            ((IDirtyMarkable) part).changed(object);
132
        }
133
        else {
133 134
            IEditorPart editor = getEditor();
134 135
            if (editor != null && editor instanceof IDirtyMarkable) {
135 136
                ((IDirtyMarkable) editor).changed(object);
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/AbstractCdmViewPart.java
23 23
import org.eclipse.swt.widgets.Label;
24 24
import org.eclipse.ui.ISelectionListener;
25 25
import org.eclipse.ui.ISelectionService;
26
import org.eclipse.ui.IWorkbenchPart;
27 26
import org.eclipse.ui.part.PageBook;
28 27
import org.eclipse.ui.part.ViewPart;
29 28

  
......
50 49

  
51 50
    public static IStructuredSelection EMPTY_SELECTION = new StructuredSelection();
52 51

  
53
    protected IWorkbenchPart part;
52
    protected Object part;
54 53

  
55 54
    private PageBook pageBook;
56 55

  
......
75 74
        setInitialSelection();
76 75
    }
77 76

  
78
    /**
79
     *
80
     */
81 77
    private void setInitialSelection() {
82
        selectionChanged(AbstractUtility.getActivePart(), getInitialSelection());
78
        selectionChanged(AbstractUtility.getActiveWorkbenchPart(), getInitialSelection());
83 79
    }
84 80

  
85 81
    /**
......
105 101
     * @param part a {@link org.eclipse.ui.IWorkbenchPart} object.
106 102
     * @param selection a {@link org.eclipse.jface.viewers.ISelection} object.
107 103
     */
108
    public void showViewer(IWorkbenchPart part, IStructuredSelection selection){
104
    public void showViewer(Object part, IStructuredSelection selection){
109 105
        this.part = part;
110 106

  
111 107
        Object element = selection.getFirstElement();
......
224 220
        // TODO Auto-generated method stub
225 221
        return null;
226 222
    }
227
    
223

  
228 224
	protected String createPartTitle(Object selectedObject){
229 225
	    if(selectedObject!=null){
230 226
	        return getViewName()+": "+selectedObject; //$NON-NLS-1$
231 227
	    }
232 228
        return getViewName();
233 229
	}
234
	
230

  
235 231
    protected abstract String getViewName();
236 232
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/dataimport/DataImportEditorContextMenu.java
6 6

  
7 7
import org.apache.http.client.ClientProtocolException;
8 8
import org.apache.log4j.Logger;
9
import org.eclipse.core.runtime.IProgressMonitor;
10
import org.eclipse.core.runtime.IStatus;
11
import org.eclipse.core.runtime.Status;
12
import org.eclipse.core.runtime.jobs.Job;
13 9
import org.eclipse.jface.action.ContributionItem;
14 10
import org.eclipse.jface.action.IContributionItem;
15 11
import org.eclipse.jface.viewers.ISelection;
......
19 15
import org.eclipse.swt.widgets.Listener;
20 16
import org.eclipse.swt.widgets.Menu;
21 17
import org.eclipse.swt.widgets.MenuItem;
22
import org.eclipse.ui.IEditorPart;
23 18
import org.eclipse.ui.IWorkbenchWindow;
24 19
import org.eclipse.ui.PlatformUI;
25 20
import org.eclipse.ui.actions.CompoundContributionItem;
26 21

  
27 22
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
28
import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery;
29 23
import eu.etaxonomy.cdm.ext.occurrence.gbif.DataSetResponse;
30 24
import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifDataSetProtocol;
31 25
import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifQueryServiceWrapper;
......
48 42
                    @Override
49 43
                    public void fill(Menu menu, int index) {
50 44
                        final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
51
                        final IEditorPart activeEditor = AbstractUtility.getActiveEditor();
45
                        final Object activeEditor = AbstractUtility.getActiveE4Editor();
52 46
                        final ISelection selection = window.getActivePage().getSelection();
53 47
                        if(selection instanceof StructuredSelection){
54 48
                            final StructuredSelection structuredSelection = (StructuredSelection)selection;
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewPart.java
9 9

  
10 10
package eu.etaxonomy.taxeditor.view.detail;
11 11

  
12
import java.util.Collection;
13

  
12 14
import org.eclipse.core.runtime.IProgressMonitor;
15
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
16
import org.eclipse.e4.ui.workbench.modeling.EPartService;
13 17
import org.eclipse.jface.viewers.ISelection;
14 18
import org.eclipse.jface.viewers.IStructuredSelection;
15 19
import org.eclipse.jface.viewers.TreeNode;
......
30 34
import eu.etaxonomy.taxeditor.model.IContextListener;
31 35
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
32 36
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
37
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
33 38
import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;
34 39

  
35 40
/**
......
46 51

  
47 52
	private DetailsViewer viewer;
48 53

  
54
	//FIXME E4: this can be removed when working with E4 event system
55
	private Object selectionProvidingPart;
56

  
49 57
	/** {@inheritDoc} */
50 58
	@Override
51 59
	public void createViewer(Composite parent) {
......
55 63
	}
56 64

  
57 65
	@Override
58
    protected void selectionChanged_internal(IWorkbenchPart part, ISelection selection){
59
	    if(AbstractUtility.getActiveEditor() == null && !(AbstractUtility.getActivePart() instanceof IConversationEnabled)){
66
    protected void selectionChanged_internal(IWorkbenchPart workbenchPart, ISelection selection){
67
	    Object part = workbenchPart;
68
	    Object wrappedPart = AbstractUtility.getE4WrappedPart(part);
69
	    if(wrappedPart!=null){
70
	        part = wrappedPart;
71
	    }
72
	    if(AbstractUtility.getActiveE4Editor() == null && !(AbstractUtility.getActiveE4Part() instanceof IConversationEnabled)){
60 73
            showEmptyPage();
61 74
            return;
62 75
        }
63 76

  
64
	    if(AbstractUtility.getActiveEditor() == null &&
65
	            selection instanceof IStructuredSelection && ((IStructuredSelection) selection).getFirstElement() !=null){
66
	        //special case where the details view still open with details about the closed object #5495
67
	        showEmptyPage();
77
	    //special case where the details view still open with details about the closed object #5495
78
	    try{
79
	        boolean isSelectionProvidingPartStillActive = false;
80
	        if(selectionProvidingPart!=null){
81
	            EPartService partService = TaxeditorStorePlugin.getDefault().getWorkbench().getService(EPartService.class);
82
	            Collection<MPart> parts = partService.getParts();
83
	            for (MPart mPart : parts) {
84
	                if(selectionProvidingPart.equals(mPart.getObject())){
85
	                    isSelectionProvidingPartStillActive = true;
86
	                    break;
87
	                }
88
	            }
89
	            if(!isSelectionProvidingPartStillActive &&
90
	                    selection instanceof IStructuredSelection && ((IStructuredSelection) selection).getFirstElement() !=null){
91
	                showEmptyPage();
92
	                return;
93
	            }
94
	        }
95
	    }catch(IllegalStateException e){
96
	        //nothing
97
	    }
98

  
99
	    if(part == this){
68 100
	        return;
69 101
	    }
70
        if(part == this){
71
            return;
72
        }
73 102

  
74 103
        if(!(selection instanceof IStructuredSelection)){
75 104
            return;
......
92 121
                    return;
93 122
                }
94 123
            }
124
            selectionProvidingPart = part;
95 125
            showViewer(part, structuredSelection);
96 126
        }else{
97 127
            showEmptyPage();
......
122 152

  
123 153
	@Override
124 154
	public void showEmptyPage() {
155
	    selectionProvidingPart = null;
125 156
	    viewer.setSelection(null);
126 157
	    super.showEmptyPage();
127 158
	}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewer.java
573 573

  
574 574
        DerivedUnitGeneralDetailSection derivedUnitGeneralDetailSection = formFactory.createDerivedUnitGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
575 575
        //TODO for DerivateEditor do not use facade anymore to avoid this special case handling #4539
576
        if(!(AbstractUtility.getActivePart() instanceof IDerivedUnitFacadePart)){
576
        if(!(AbstractUtility.getActiveE4Part() instanceof IDerivedUnitFacadePart)){
577 577
            derivedUnitGeneralDetailSection.setShowOnlyDerivedUnitData(true);
578 578
        }
579 579
        addPart(derivedUnitGeneralDetailSection);
......
584 584
        addPart(derivedUnitBaseDetailSection);
585 585

  
586 586
        //for editors working with facades
587
        if(AbstractUtility.getActivePart() instanceof IDerivedUnitFacadePart){
587
        if(AbstractUtility.getActiveE4Part() instanceof IDerivedUnitFacadePart){
588 588
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
589 589
            GatheringEventDetailSection gatheringEventDetailSection = formFactory.createGatheringEventDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
590 590
            addPart(gatheringEventDetailSection);
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/supplementaldata/SupplementalDataViewPart.java
55 55
	/** {@inheritDoc} */
56 56
	@Override
57 57
	protected void selectionChanged_internal(IWorkbenchPart part, ISelection selection) {
58
		if(AbstractUtility.getActiveEditor() == null){
58
		if(AbstractUtility.getActiveE4Editor() == null){
59 59
			showEmptyPage();
60 60
			return;
61 61
		}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)