1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.taxeditor.handler.e4;
|
10
|
|
11
|
import java.util.Collection;
|
12
|
|
13
|
import javax.inject.Named;
|
14
|
|
15
|
import org.eclipse.e4.core.contexts.IEclipseContext;
|
16
|
import org.eclipse.e4.core.di.annotations.Execute;
|
17
|
import org.eclipse.e4.ui.model.application.MApplication;
|
18
|
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
19
|
import org.eclipse.e4.ui.services.IServiceConstants;
|
20
|
import org.eclipse.e4.ui.workbench.modeling.EModelService;
|
21
|
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
22
|
import org.eclipse.swt.SWT;
|
23
|
import org.eclipse.swt.widgets.Shell;
|
24
|
import org.eclipse.ui.IPerspectiveRegistry;
|
25
|
import org.eclipse.ui.IWorkbench;
|
26
|
import org.eclipse.ui.IWorkbenchPage;
|
27
|
import org.eclipse.ui.IWorkbenchWindow;
|
28
|
import org.eclipse.ui.PlatformUI;
|
29
|
|
30
|
import eu.etaxonomy.taxeditor.remoting.source.CdmRemoteSource;
|
31
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
32
|
import eu.etaxonomy.taxeditor.ui.dialog.RemotingLoginDialog;
|
33
|
|
34
|
/**
|
35
|
* @author pplitzner
|
36
|
* @date 10.10.2017
|
37
|
*/
|
38
|
public class SwitchUserHandlerE4 {
|
39
|
|
40
|
@Execute
|
41
|
public void execute(@Named(IServiceConstants.ACTIVE_SHELL)Shell shell, EModelService modelService, EPartService partService, MApplication application,
|
42
|
IEclipseContext context) {
|
43
|
Collection<MPart> parts = partService.getParts();
|
44
|
String partId = "eu.etaxonomy.taxeditor.navigation.navigator";
|
45
|
for (MPart part : parts) {
|
46
|
partService.hidePart(part);
|
47
|
|
48
|
}
|
49
|
|
50
|
RemotingLoginDialog loginDialog = new RemotingLoginDialog(shell,
|
51
|
SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
|
52
|
|
53
|
loginDialog.open((CdmRemoteSource) CdmStore.getActiveCdmSource(), false, false);
|
54
|
|
55
|
IWorkbench workbench = PlatformUI.getWorkbench();
|
56
|
IWorkbenchWindow window = workbench
|
57
|
.getActiveWorkbenchWindow();
|
58
|
|
59
|
IPerspectiveRegistry registry = workbench.getPerspectiveRegistry();
|
60
|
IWorkbenchPage page = window.getActivePage();
|
61
|
page.resetPerspective();
|
62
|
}
|
63
|
}
|