Revision 199741f4
Added by Patrick Plitzner almost 6 years ago
eu.etaxonomy.taxeditor.store/fragment.e4xmi | ||
---|---|---|
5 | 5 |
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_xVa1wCXXEeex9MwMOgUeWw" featurename="descriptors" parentElementId="xpath:/"> |
6 | 6 |
<elements xsi:type="basic:PartDescriptor" xmi:id="_2xmxoCXXEeex9MwMOgUeWw" elementId="eu.etaxonomy.taxeditor.view.sessions.SessionsViewPart" label="%view.name.SESSIONS" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/applications-office.png" closeable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.view.sessions.SessionsViewPart"> |
7 | 7 |
<tags>nonRestore</tags> |
8 |
<handlers xmi:id="_gbMXAL-rEeegz7IDD8MJaw" elementId="eu.etaxonomy.taxeditor.view.sessions.InspectSessionHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.view.sessions.InspectSessionHandler" command="_dQ0swL-rEeegz7IDD8MJaw"/> |
|
8 | 9 |
</elements> |
9 | 10 |
<elements xsi:type="basic:PartDescriptor" xmi:id="_J-3UEEqgEeeN-dEYnw7m3g" elementId="eu.etaxonomy.taxeditor.featuretree.e4.FeatureTreeEditor" label="%partdescriptor.label.featureTreeEditor" allowMultiple="true" closeable="true" dirtyable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.featuretree.e4.FeatureTreeEditor"> |
10 | 11 |
<tags>nonRestore</tags> |
... | ... | |
115 | 116 |
<elements xsi:type="commands:Command" xmi:id="_bfjZwK2fEeeykrJkROy5EA" elementId="eu.etaxonomy.taxeditor.store.open.OpenDistributionEditorWizardHandler" commandName="%command.name.11"/> |
116 | 117 |
<elements xsi:type="commands:Command" xmi:id="_KQP_sK2gEeeykrJkROy5EA" elementId="eu.etaxonomy.taxeditor.store.operations.reconnect" commandName="%command.name.RE_CONNECT"/> |
117 | 118 |
<elements xsi:type="commands:Command" xmi:id="_SXZF8K2gEeeykrJkROy5EA" elementId="eu.etaxonomy.taxeditor.store.openPasswordWizzard" commandName="%command.name.10"/> |
119 |
<elements xsi:type="commands:Command" xmi:id="_dQ0swL-rEeegz7IDD8MJaw" elementId="eu.etaxonomy.taxeditor.store.open.InspectSessionsDialog" commandName="Inspect Session"/> |
|
118 | 120 |
</fragments> |
119 | 121 |
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_swGH0GhvEee3K4uKJljEYg" featurename="handlers" parentElementId="xpath:/"> |
120 | 122 |
<elements xsi:type="commands:Handler" xmi:id="_rVEdIGcjEee0qLTtA2ZpVQ" elementId="eu.etaxonomy.taxeditor.featuretree.e4.handler.RemoveFeatureHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.featuretree.e4.handler.RemoveFeatureHandler" command="_fNBtQGcjEee0qLTtA2ZpVQ"/> |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/AbstractUtility.java | ||
---|---|---|
30 | 30 |
import org.apache.commons.lang.StringUtils; |
31 | 31 |
import org.apache.log4j.Logger; |
32 | 32 |
import org.eclipse.core.commands.ExecutionException; |
33 |
import org.eclipse.core.commands.NotEnabledException; |
|
34 |
import org.eclipse.core.commands.NotHandledException; |
|
35 |
import org.eclipse.core.commands.common.NotDefinedException; |
|
36 | 33 |
import org.eclipse.core.commands.operations.AbstractOperation; |
37 | 34 |
import org.eclipse.core.commands.operations.IOperationHistory; |
38 | 35 |
import org.eclipse.core.runtime.IAdaptable; |
... | ... | |
56 | 53 |
import org.eclipse.swt.widgets.Shell; |
57 | 54 |
import org.eclipse.ui.IWorkbench; |
58 | 55 |
import org.eclipse.ui.PlatformUI; |
59 |
import org.eclipse.ui.handlers.IHandlerService; |
|
60 | 56 |
import org.eclipse.ui.ide.undo.WorkspaceUndoUtil; |
61 | 57 |
import org.eclipse.ui.progress.IProgressConstants; |
62 | 58 |
import org.eclipse.ui.progress.IProgressService; |
... | ... | |
669 | 665 |
} |
670 | 666 |
} |
671 | 667 |
|
672 |
|
|
673 |
public static void executeCommand(String commandId, Object source, String pluginId) { |
|
674 |
IHandlerService handlerService = (IHandlerService) AbstractUtility.getService(IHandlerService.class); |
|
675 |
Exception exception = null; |
|
676 |
try { |
|
677 |
handlerService.executeCommand(commandId, null); |
|
678 |
} catch (ExecutionException e) { |
|
679 |
exception = e; |
|
680 |
} catch (NotDefinedException e) { |
|
681 |
exception = e; |
|
682 |
} catch (NotEnabledException e) { |
|
683 |
exception = e; |
|
684 |
} catch (NotHandledException e) { |
|
685 |
exception = e; |
|
686 |
} finally { |
|
687 |
if(exception != null) { |
|
688 |
MessagingUtils.errorDialog("Error executing command", |
|
689 |
source, |
|
690 |
"Could not execute command with id " + commandId , |
|
691 |
pluginId, |
|
692 |
exception, |
|
693 |
true); |
|
694 |
} |
|
695 |
} |
|
696 |
} |
|
697 |
|
|
698 | 668 |
public static Object getElementsFromSelectionChangedEvent(SelectionChangedEvent event) { |
699 | 669 |
IStructuredSelection selection = (IStructuredSelection) event.getSelection(); |
700 | 670 |
Object selectionToSet = selection; |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/sessions/InspectSessionHandler.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2017 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.view.sessions; |
|
10 |
|
|
11 |
import javax.inject.Named; |
|
12 |
|
|
13 |
import org.eclipse.e4.core.di.annotations.Execute; |
|
14 |
import org.eclipse.e4.ui.services.IServiceConstants; |
|
15 |
import org.eclipse.swt.SWT; |
|
16 |
import org.eclipse.swt.widgets.Shell; |
|
17 |
|
|
18 |
/** |
|
19 |
* @author pplitzner |
|
20 |
* @since Nov 2, 2017 |
|
21 |
* |
|
22 |
*/ |
|
23 |
public class InspectSessionHandler { |
|
24 |
|
|
25 |
@Execute |
|
26 |
public void canExecute(@Named(IServiceConstants.ACTIVE_SHELL)Shell shell){ |
|
27 |
InspectSessionsDialog dialog = new InspectSessionsDialog(shell, SWT.NONE); |
|
28 |
dialog.open(); |
|
29 |
} |
|
30 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/sessions/SessionsViewPart.java | ||
---|---|---|
14 | 14 |
import javax.annotation.PostConstruct; |
15 | 15 |
import javax.inject.Inject; |
16 | 16 |
|
17 |
import org.eclipse.core.commands.Command; |
|
18 |
import org.eclipse.core.commands.ParameterizedCommand; |
|
19 |
import org.eclipse.e4.core.commands.ECommandService; |
|
20 |
import org.eclipse.e4.core.commands.EHandlerService; |
|
17 | 21 |
import org.eclipse.swt.SWT; |
18 | 22 |
import org.eclipse.swt.events.SelectionAdapter; |
19 | 23 |
import org.eclipse.swt.events.SelectionEvent; |
... | ... | |
29 | 33 |
import org.eclipse.wb.swt.SWTResourceManager; |
30 | 34 |
|
31 | 35 |
import eu.etaxonomy.cdm.api.cache.CdmCacher; |
32 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
|
33 | 36 |
import eu.etaxonomy.taxeditor.remoting.cache.CdmRemoteCacheManager; |
34 | 37 |
import eu.etaxonomy.taxeditor.session.ICdmEntitySession; |
35 | 38 |
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionManager; |
... | ... | |
61 | 64 |
private Text txtCdmModelOnDisk; |
62 | 65 |
private Text txtDefaultOnDisk; |
63 | 66 |
|
67 |
@Inject |
|
68 |
private ECommandService commandService; |
|
69 |
|
|
70 |
@Inject |
|
71 |
private EHandlerService handlerService; |
|
72 |
|
|
64 | 73 |
@Inject |
65 | 74 |
public SessionsViewPart() { |
66 | 75 |
this.cdmEntitySessionManager = CdmStore.getCurrentSessionManager(); |
... | ... | |
210 | 219 |
btnInspectActiveSession.addSelectionListener(new SelectionAdapter() { |
211 | 220 |
@Override |
212 | 221 |
public void widgetSelected(SelectionEvent e) { |
213 |
AbstractUtility.executeCommand(OPEN_INSPECT_SESSIONS_DIALOG_ID, this, null); |
|
222 |
Command command = commandService.getCommand(OPEN_INSPECT_SESSIONS_DIALOG_ID); |
|
223 |
handlerService.executeHandler(ParameterizedCommand.generateCommand(command, null)); |
|
214 | 224 |
} |
215 | 225 |
}); |
216 | 226 |
btnInspectActiveSession.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1)); |
Also available in: Unified diff
ref #6913 Remove executeCommand() from AbstractUtility