diff --git a/eclipse/META-INF/MANIFEST.MF b/eclipse/META-INF/MANIFEST.MF index 964becbc8e..1c6fdd5d98 100644 --- a/eclipse/META-INF/MANIFEST.MF +++ b/eclipse/META-INF/MANIFEST.MF @@ -20,7 +20,18 @@ Require-Bundle: org.eclipse.ui, org.eclipse.equinox.security, org.junit;resolution:=optional, org.eclipse.jdt.launching;resolution:=optional, - saros.core + org.eclipse.e4.ui.model.workbench, + org.eclipse.e4.ui.di, + org.eclipse.osgi, + org.eclipse.e4.ui.services, + org.eclipse.e4.core.di.annotations, + saros.core, + org.eclipse.osgi.services, + org.eclipse.e4.ui.workbench, + org.eclipse.equinox.ds, + org.eclipse.equinox.event, + org.eclipse.equinox.util, + org.eclipse.e4.ui.workbench.addons.swt Bundle-ActivationPolicy: lazy Export-Package: saros; uses:="org.eclipse.core.runtime, @@ -129,4 +140,6 @@ Export-Package: saros; saros.util;uses:="org.eclipse.core.resources,org.jivesoftware.smack.packet" Bundle-Vendor: Saros Project Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Import-Package: org.eclipse.core.filesystem \ No newline at end of file +Import-Package: javax.annotation;version="1.2.0", + javax.inject, + org.eclipse.core.filesystem diff --git a/eclipse/build.gradle.kts b/eclipse/build.gradle.kts index 2ddf6d5b04..407eeedb82 100644 --- a/eclipse/build.gradle.kts +++ b/eclipse/build.gradle.kts @@ -45,6 +45,9 @@ dependencies { // This is a workaround for https://github.com/saros-project/saros/issues/1114 implementation("org.eclipse.platform:org.eclipse.ui.ide:3.17.200") implementation("org.eclipse.platform:org.eclipse.ui.workbench:3.120.0") + // This is a workaround for an Issues, same as https://github.com/saros-project/saros/issues/1114 + implementation("org.eclipse.platform:org.eclipse.e4.ui.services:1.3.700") + implementation("javax.inject:javax.inject:1") testImplementation(project(path = ":saros.core", configuration = "testing")) } diff --git a/eclipse/fragment.e4xmi b/eclipse/fragment.e4xmi new file mode 100644 index 0000000000..6c5565c79e --- /dev/null +++ b/eclipse/fragment.e4xmi @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/eclipse/plugin.xml b/eclipse/plugin.xml index 28d01713c5..2c14cf2eff 100644 --- a/eclipse/plugin.xml +++ b/eclipse/plugin.xml @@ -2,6 +2,12 @@ + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1088,6 +707,20 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/eclipse/src/saros/Saros.java b/eclipse/src/saros/Saros.java index 9d9edc6ab5..b7adbb1e29 100644 --- a/eclipse/src/saros/Saros.java +++ b/eclipse/src/saros/Saros.java @@ -3,6 +3,7 @@ import java.io.File; import java.io.InputStream; import java.util.concurrent.atomic.AtomicBoolean; +import javax.inject.Inject; import org.apache.log4j.Logger; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.core.config.ConfigurationSource; @@ -11,12 +12,16 @@ import org.apache.logging.log4j.status.StatusLogger; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.preferences.ConfigurationScope; +import org.eclipse.e4.core.di.annotations.Optional; +import org.eclipse.e4.ui.di.UIEventTopic; +import org.eclipse.e4.ui.workbench.UIEvents; import org.eclipse.swt.SWTException; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchListener; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; +import org.osgi.service.event.Event; import org.osgi.service.prefs.BackingStoreException; import org.osgi.service.prefs.Preferences; import saros.annotations.Component; @@ -130,10 +135,17 @@ public void start(BundleContext context) throws Exception { isLifecycleStarted = true; - getWorkbench().addWorkbenchListener(workbenchShutdownListener); isInitialized = true; } + @Inject + @Optional + public void applicationStarted( + @UIEventTopic(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE) Event event, Saros saros) { + + saros.getWorkbench().addWorkbenchListener(saros.workbenchShutdownListener); + } + @Override public void stop(BundleContext context) throws Exception { diff --git a/eclipse/src/saros/ui/command_handlers/AddContactHandler.java b/eclipse/src/saros/ui/command_handlers/AddContactHandler.java index f7b27fed3c..5b8e5f5fbf 100644 --- a/eclipse/src/saros/ui/command_handlers/AddContactHandler.java +++ b/eclipse/src/saros/ui/command_handlers/AddContactHandler.java @@ -1,15 +1,27 @@ package saros.ui.command_handlers; -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; +import org.eclipse.e4.core.di.annotations.CanExecute; +import org.eclipse.e4.core.di.annotations.Execute; +import saros.SarosPluginContext; +import saros.communication.connection.ConnectionHandler; +import saros.repackaged.picocontainer.annotations.Inject; import saros.ui.util.WizardUtils; -public class AddContactHandler extends AbstractHandler { +public class AddContactHandler { + @Inject private ConnectionHandler connectionHandler; - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { + public AddContactHandler() { + SarosPluginContext.initComponent(this); + } + + @Execute + public Object execute() { WizardUtils.openAddContactWizard(); return null; } + + @CanExecute + public boolean canExecute() { + return connectionHandler.isConnected(); + } } diff --git a/eclipse/src/saros/ui/command_handlers/AddXMPPAccountHandler.java b/eclipse/src/saros/ui/command_handlers/AddXMPPAccountHandler.java index 62f228759b..95bc54946b 100644 --- a/eclipse/src/saros/ui/command_handlers/AddXMPPAccountHandler.java +++ b/eclipse/src/saros/ui/command_handlers/AddXMPPAccountHandler.java @@ -1,14 +1,12 @@ package saros.ui.command_handlers; -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; +import org.eclipse.e4.core.di.annotations.Execute; import saros.ui.util.WizardUtils; -public class AddXMPPAccountHandler extends AbstractHandler { +public class AddXMPPAccountHandler { - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { + @Execute + public Object execute() { WizardUtils.openAddXMPPAccountWizard(); return null; } diff --git a/eclipse/src/saros/ui/command_handlers/CreateXMPPAccountHandler.java b/eclipse/src/saros/ui/command_handlers/CreateXMPPAccountHandler.java index eee81f8206..921315e176 100644 --- a/eclipse/src/saros/ui/command_handlers/CreateXMPPAccountHandler.java +++ b/eclipse/src/saros/ui/command_handlers/CreateXMPPAccountHandler.java @@ -1,14 +1,12 @@ package saros.ui.command_handlers; -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; +import org.eclipse.e4.core.di.annotations.Execute; import saros.ui.util.WizardUtils; -public class CreateXMPPAccountHandler extends AbstractHandler { +public class CreateXMPPAccountHandler { - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { + @Execute + public Object execute() { WizardUtils.openCreateXMPPAccountWizard(true); diff --git a/eclipse/src/saros/ui/command_handlers/GettingStartedHandler.java b/eclipse/src/saros/ui/command_handlers/GettingStartedHandler.java index 9dc9a9cc1b..6d24ed9017 100644 --- a/eclipse/src/saros/ui/command_handlers/GettingStartedHandler.java +++ b/eclipse/src/saros/ui/command_handlers/GettingStartedHandler.java @@ -1,18 +1,14 @@ package saros.ui.command_handlers; -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; +import org.eclipse.e4.core.di.annotations.Execute; import saros.ui.util.SWTUtils; -public class GettingStartedHandler extends AbstractHandler { +public class GettingStartedHandler { - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { + @Execute + public void execute() { SWTUtils.openInternalBrowser( "https://www.saros-project.org/documentation/getting-started.html", "Welcome to Saros"); - - return null; } } diff --git a/eclipse/src/saros/ui/command_handlers/OpenSarosPreferencesHandler.java b/eclipse/src/saros/ui/command_handlers/OpenSarosPreferencesHandler.java index 1ff118f79d..114b557020 100644 --- a/eclipse/src/saros/ui/command_handlers/OpenSarosPreferencesHandler.java +++ b/eclipse/src/saros/ui/command_handlers/OpenSarosPreferencesHandler.java @@ -1,19 +1,16 @@ package saros.ui.command_handlers; -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; +import org.eclipse.e4.core.di.annotations.Execute; import org.eclipse.jface.preference.PreferenceDialog; import org.eclipse.ui.dialogs.PreferencesUtil; -public class OpenSarosPreferencesHandler extends AbstractHandler { +public class OpenSarosPreferencesHandler { - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { + @Execute + public Object execute() { PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn(null, "saros.preferences", null, null); if (pref != null) pref.open(); - return null; } } diff --git a/eclipse/src/saros/ui/command_handlers/SessionAddContactsHandler.java b/eclipse/src/saros/ui/command_handlers/SessionAddContactsHandler.java index 0b62b50e27..230cdb82c7 100644 --- a/eclipse/src/saros/ui/command_handlers/SessionAddContactsHandler.java +++ b/eclipse/src/saros/ui/command_handlers/SessionAddContactsHandler.java @@ -1,10 +1,13 @@ package saros.ui.command_handlers; -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; +import org.eclipse.e4.core.di.annotations.CanExecute; +import org.eclipse.e4.core.di.annotations.Execute; +import saros.SarosPluginContext; +import saros.communication.connection.ConnectionHandler; import saros.net.xmpp.JID; +import saros.repackaged.picocontainer.annotations.Inject; import saros.session.ISarosSession; +import saros.session.ISarosSessionManager; import saros.ui.util.WizardUtils; import saros.ui.wizards.AddResourcesToSessionWizard; @@ -12,11 +15,22 @@ * Handles the addition of {@link JID}s that must explicitly be selected in the opening {@link * AddResourcesToSessionWizard} to the running {@link ISarosSession}. */ -public class SessionAddContactsHandler extends AbstractHandler { +public class SessionAddContactsHandler { + @Inject private ConnectionHandler connectionHandler; + @Inject private ISarosSessionManager sessionManager; - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { + public SessionAddContactsHandler() { + SarosPluginContext.initComponent(this); + } + + @Execute + public Object execute() { WizardUtils.openAddContactsToSessionWizard(); return null; } + + @CanExecute + public boolean canExecute() { + return connectionHandler.isConnected() && sessionManager.getSession() != null; + } } diff --git a/eclipse/src/saros/ui/command_handlers/SessionAddResourcesHandler.java b/eclipse/src/saros/ui/command_handlers/SessionAddResourcesHandler.java index 81f60f2564..18c0dac8f9 100644 --- a/eclipse/src/saros/ui/command_handlers/SessionAddResourcesHandler.java +++ b/eclipse/src/saros/ui/command_handlers/SessionAddResourcesHandler.java @@ -1,10 +1,13 @@ package saros.ui.command_handlers; -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.resources.IResource; +import org.eclipse.e4.core.di.annotations.CanExecute; +import org.eclipse.e4.core.di.annotations.Execute; +import saros.SarosPluginContext; +import saros.communication.connection.ConnectionHandler; +import saros.repackaged.picocontainer.annotations.Inject; import saros.session.ISarosSession; +import saros.session.ISarosSessionManager; import saros.ui.util.WizardUtils; import saros.ui.wizards.AddResourcesToSessionWizard; @@ -15,11 +18,23 @@ *

This class is used to define the behavior of the saros menu entry to add reference points to a * running session. */ -public class SessionAddResourcesHandler extends AbstractHandler { +public class SessionAddResourcesHandler { + @Inject private ConnectionHandler connectionHandler; + @Inject private ISarosSessionManager sessionManager; - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { + public SessionAddResourcesHandler() { + SarosPluginContext.initComponent(this); + } + + @Execute + public Object execute() { WizardUtils.openAddResourcesToSessionWizard(null); return null; } + + @CanExecute + public boolean canExecute() { + final ISarosSession session = sessionManager.getSession(); + return connectionHandler.isConnected() && session != null && session.hasWriteAccess(); + } } diff --git a/eclipse/src/saros/ui/command_handlers/SessionAddSelectedContactsHandler.java b/eclipse/src/saros/ui/command_handlers/SessionAddSelectedContactsHandler.java index 3c1335fb0c..ef64dd9d5d 100644 --- a/eclipse/src/saros/ui/command_handlers/SessionAddSelectedContactsHandler.java +++ b/eclipse/src/saros/ui/command_handlers/SessionAddSelectedContactsHandler.java @@ -1,23 +1,53 @@ package saros.ui.command_handlers; import java.util.List; -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; +import javax.inject.Named; +import org.eclipse.e4.core.di.annotations.CanExecute; +import org.eclipse.e4.core.di.annotations.Execute; +import org.eclipse.e4.core.di.annotations.Optional; +import org.eclipse.e4.ui.services.IServiceConstants; +import org.eclipse.jface.viewers.ISelection; +import saros.SarosPluginContext; +import saros.communication.connection.ConnectionHandler; import saros.net.xmpp.JID; +import saros.repackaged.picocontainer.annotations.Inject; import saros.session.ISarosSession; +import saros.session.ISarosSessionManager; import saros.ui.util.CollaborationUtils; -import saros.ui.util.selection.retriever.SelectionRetrieverFactory; +import saros.ui.util.selection.SelectionUtils; /** Handles the addition of selected {@link JID}s to the running {@link ISarosSession}. */ -public class SessionAddSelectedContactsHandler extends AbstractHandler { +public class SessionAddSelectedContactsHandler { - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { + @Inject private ConnectionHandler connectionHandler; + @Inject private ISarosSessionManager sessionManager; - List jids = SelectionRetrieverFactory.getSelectionRetriever(JID.class).getSelection(); + public SessionAddSelectedContactsHandler() { + SarosPluginContext.initComponent(this); + } + + @Execute + public Object execute(@Named(IServiceConstants.ACTIVE_SELECTION) @Optional ISelection selection) { + + List jids = SelectionUtils.getAdaptableObjects(selection, JID.class); CollaborationUtils.addContactsToSession(jids); return null; } + + @CanExecute + public boolean canExecute( + @Named(IServiceConstants.ACTIVE_SELECTION) @Optional ISelection selection) { + final ISarosSession session = sessionManager.getSession(); + if (!(connectionHandler.isConnected() && session != null && session.hasWriteAccess())) { + return false; + } + List jids = SelectionUtils.getAdaptableObjects(selection, JID.class); + for (JID jid : jids) { + if (session.getUsers().stream().anyMatch(u -> u.getJID().equals(jid))) { + return false; + } + } + return true; + } } diff --git a/eclipse/src/saros/ui/command_handlers/SessionAddSelectedResourcesHandler.java b/eclipse/src/saros/ui/command_handlers/SessionAddSelectedResourcesHandler.java index 391f7c3556..c14e8ac7b4 100644 --- a/eclipse/src/saros/ui/command_handlers/SessionAddSelectedResourcesHandler.java +++ b/eclipse/src/saros/ui/command_handlers/SessionAddSelectedResourcesHandler.java @@ -2,13 +2,23 @@ import java.util.HashSet; import java.util.List; -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; +import java.util.Set; +import javax.inject.Named; import org.eclipse.core.resources.IResource; +import org.eclipse.e4.core.di.annotations.CanExecute; +import org.eclipse.e4.core.di.annotations.Execute; +import org.eclipse.e4.core.di.annotations.Optional; +import org.eclipse.e4.ui.services.IServiceConstants; +import org.eclipse.jface.viewers.ISelection; +import saros.SarosPluginContext; +import saros.communication.connection.ConnectionHandler; +import saros.filesystem.IReferencePoint; +import saros.filesystem.ResourceConverter; +import saros.repackaged.picocontainer.annotations.Inject; import saros.session.ISarosSession; +import saros.session.ISarosSessionManager; import saros.ui.util.WizardUtils; -import saros.ui.util.selection.retriever.SelectionRetrieverFactory; +import saros.ui.util.selection.SelectionUtils; /** * Handles the addition of selected {@link IResource}s to the running {@link ISarosSession}. @@ -19,16 +29,44 @@ *

This class is used to define the behavior of the package explorer context menu entry to add * reference points to a running session. */ -public class SessionAddSelectedResourcesHandler extends AbstractHandler { +public class SessionAddSelectedResourcesHandler { + @Inject private ConnectionHandler connectionHandler; + @Inject private ISarosSessionManager sessionManager; - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { + public SessionAddSelectedResourcesHandler() { + SarosPluginContext.initComponent(this); + } + + @Execute + public Object execute(@Named(IServiceConstants.ACTIVE_SELECTION) @Optional ISelection selection) { List selectedResources = - SelectionRetrieverFactory.getSelectionRetriever(IResource.class).getSelection(); + SelectionUtils.getAdaptableObjects(selection, IResource.class); WizardUtils.openAddResourcesToSessionWizard(new HashSet<>(selectedResources)); return null; } + + @CanExecute + public boolean canExecute( + @Named(IServiceConstants.ACTIVE_SELECTION) @Optional ISelection selection) { + List resources = SelectionUtils.getAdaptableObjects(selection, IResource.class); + if (!(resources.size() > 0)) { + return false; + } + final ISarosSession session = sessionManager.getSession(); + if (!(connectionHandler.isConnected() && session != null && session.hasWriteAccess())) { + return false; + } + Set sharedReferencePoints = session.getReferencePoints(); + for (IResource resource : resources) { + saros.filesystem.IResource wrappedResource = + ResourceConverter.convertToResource(sharedReferencePoints, resource); + if (session.isShared(wrappedResource)) { + return false; + } + } + return true; + } } diff --git a/eclipse/src/saros/ui/command_handlers/SessionLeaveHandler.java b/eclipse/src/saros/ui/command_handlers/SessionLeaveHandler.java index a0942cee0c..0416ea9389 100644 --- a/eclipse/src/saros/ui/command_handlers/SessionLeaveHandler.java +++ b/eclipse/src/saros/ui/command_handlers/SessionLeaveHandler.java @@ -1,15 +1,29 @@ package saros.ui.command_handlers; -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; +import org.eclipse.e4.core.di.annotations.CanExecute; +import org.eclipse.e4.core.di.annotations.Execute; +import saros.SarosPluginContext; +import saros.communication.connection.ConnectionHandler; +import saros.repackaged.picocontainer.annotations.Inject; +import saros.session.ISarosSessionManager; import saros.ui.util.CollaborationUtils; -public class SessionLeaveHandler extends AbstractHandler { +public class SessionLeaveHandler { + @Inject private ConnectionHandler connectionHandler; + @Inject private ISarosSessionManager sessionManager; - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { + public SessionLeaveHandler() { + SarosPluginContext.initComponent(this); + } + + @Execute + public Object execute() { CollaborationUtils.leaveSession(); return null; } + + @CanExecute + public boolean canExecute() { + return connectionHandler.isConnected() && sessionManager.getSession() != null; + } } diff --git a/eclipse/src/saros/ui/command_handlers/ShareResourcesHandler.java b/eclipse/src/saros/ui/command_handlers/ShareResourcesHandler.java index 3220ba4292..50a36abb0c 100644 --- a/eclipse/src/saros/ui/command_handlers/ShareResourcesHandler.java +++ b/eclipse/src/saros/ui/command_handlers/ShareResourcesHandler.java @@ -1,12 +1,19 @@ package saros.ui.command_handlers; -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; +import javax.inject.Named; import org.eclipse.core.resources.IResource; +import org.eclipse.e4.core.di.annotations.CanExecute; +import org.eclipse.e4.core.di.annotations.Execute; +import org.eclipse.e4.core.di.annotations.Optional; +import org.eclipse.e4.ui.services.IServiceConstants; +import org.eclipse.jface.viewers.ISelection; +import saros.SarosPluginContext; +import saros.communication.connection.ConnectionHandler; +import saros.repackaged.picocontainer.annotations.Inject; +import saros.session.ISarosSessionManager; import saros.ui.menu_contributions.StartSessionWithProjects; import saros.ui.util.WizardUtils; -import saros.ui.util.selection.retriever.SelectionRetrieverFactory; +import saros.ui.util.selection.SelectionUtils; /** * @JTourBusStop 1, Invitation Process: @@ -35,12 +42,24 @@ * *

Notice that this is done via the {@link saros.ui.wizards.StartSessionWizard}. */ -public class ShareResourcesHandler extends AbstractHandler { +public class ShareResourcesHandler { - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { + @Inject private ConnectionHandler connectionHandler; + @Inject private ISarosSessionManager sessionManager; + + public ShareResourcesHandler() { + SarosPluginContext.initComponent(this); + } + + @Execute + public Object execute(@Named(IServiceConstants.ACTIVE_SELECTION) @Optional ISelection selection) { WizardUtils.openStartSessionWizard( - SelectionRetrieverFactory.getSelectionRetriever(IResource.class).getSelection()); + SelectionUtils.getAdaptableObjects(selection, IResource.class)); return null; } + + @CanExecute + public boolean canExecute() { + return connectionHandler.isConnected() && sessionManager.getSession() == null; + } } diff --git a/eclipse/src/saros/ui/command_handlers/StartSarosConfigurationHandler.java b/eclipse/src/saros/ui/command_handlers/StartSarosConfigurationHandler.java index df54518659..37c730bdb1 100644 --- a/eclipse/src/saros/ui/command_handlers/StartSarosConfigurationHandler.java +++ b/eclipse/src/saros/ui/command_handlers/StartSarosConfigurationHandler.java @@ -1,14 +1,12 @@ package saros.ui.command_handlers; -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; +import org.eclipse.e4.core.di.annotations.Execute; import saros.ui.util.WizardUtils; -public class StartSarosConfigurationHandler extends AbstractHandler { +public class StartSarosConfigurationHandler { - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { + @Execute + public Object execute() { WizardUtils.openSarosConfigurationWizard(); return null; } diff --git a/eclipse/src/saros/ui/util/SWTUtils.java b/eclipse/src/saros/ui/util/SWTUtils.java index c92eeb658b..b6de3ec798 100644 --- a/eclipse/src/saros/ui/util/SWTUtils.java +++ b/eclipse/src/saros/ui/util/SWTUtils.java @@ -21,6 +21,8 @@ public class SWTUtils { private static final Logger log = Logger.getLogger(SWTUtils.class); + private static Display display; + private static class CallableResult { private T result; private Exception exception; @@ -187,7 +189,21 @@ public static void runSafeSWTSync(final Logger log, final Runnable runnable) { * @return the display of the current workbench */ public static Display getDisplay() { - return PlatformUI.getWorkbench().getDisplay(); + /** + * This is a temporary solution. Migrating the UI from Eclipse3 to Eclipse4 caused an earlier + * initialization of Saros and its context. Calling PlatformUI.getWorkbench.getDisplay() can not + * be used, since the Workbench wont be created at that point, when this function is first + * called. Continuing the migration it would be best to find an other solution by replacing all + * calls to this function and keeping track of the display another way or find an equivalent to + * PlatformUI.getWorkbench.getDisplay() working in E4. + */ + if (display == null) { + display = Display.getCurrent(); + if (display == null) { + display = Display.getDefault(); + } + } + return display; } /** diff --git a/stf/build.gradle.kts b/stf/build.gradle.kts index efc7af91a5..460c972942 100644 --- a/stf/build.gradle.kts +++ b/stf/build.gradle.kts @@ -33,6 +33,9 @@ dependencies { // This is a workaround for https://github.com/saros-project/saros/issues/1114 implementation("org.eclipse.platform:org.eclipse.ui.ide:3.17.200") implementation("org.eclipse.platform:org.eclipse.ui.workbench:3.120.0") + // This is a workaround for an Issues, same as https://github.com/saros-project/saros/issues/1114 + implementation("org.eclipse.platform:org.eclipse.e4.ui.services:1.3.700") + implementation("javax.inject:javax.inject:1") compile(project(path = ":saros.eclipse", configuration = "testing")) releaseDep(fileTree("libs"))