summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-09-28 07:18:58 (EDT)
committerEike Stepper2007-09-28 07:18:58 (EDT)
commitad06935119a9de82bcc2a64cbbe4217a9d1585b7 (patch)
tree2fbfd38850d23b3d54433d8d3f5db79119ff8f23
parente00c1faac3659bc4ea32882f5146bddd41266603 (diff)
downloadcdo-ad06935119a9de82bcc2a64cbbe4217a9d1585b7.zip
cdo-ad06935119a9de82bcc2a64cbbe4217a9d1585b7.tar.gz
cdo-ad06935119a9de82bcc2a64cbbe4217a9d1585b7.tar.bz2
[204732] Add dialog for "Open Session"
https://bugs.eclipse.org/bugs/show_bug.cgi?id=204732
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenSessionAction.java26
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ChannelInjector.java11
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/actions/LongRunningAction.java21
3 files changed, 47 insertions, 11 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenSessionAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenSessionAction.java
index 0683822..9bb5f93 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenSessionAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenSessionAction.java
@@ -1,6 +1,7 @@
package org.eclipse.emf.cdo.internal.ui.actions;
import org.eclipse.emf.cdo.CDOSession;
+import org.eclipse.emf.cdo.internal.ui.bundle.OM;
import org.eclipse.emf.cdo.internal.ui.dialogs.OpenSessionDialog;
import org.eclipse.emf.cdo.internal.ui.views.CDOSessionsView;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
@@ -19,20 +20,17 @@ import org.eclipse.ui.IWorkbenchPage;
*/
public final class OpenSessionAction extends LongRunningAction
{
- private IWorkbenchPage page;
-
private String description;
public OpenSessionAction(IWorkbenchPage page)
{
- super(OpenSessionDialog.TITLE, "Open a new CDO session", CDOSessionsView.getAddImageDescriptor());
- this.page = page;
+ super(page, OpenSessionDialog.TITLE, "Open a new CDO session", CDOSessionsView.getAddImageDescriptor());
}
@Override
protected void preRun() throws Exception
{
- OpenSessionDialog dialog = new OpenSessionDialog(page);
+ OpenSessionDialog dialog = new OpenSessionDialog(getPage());
if (dialog.open() == OpenSessionDialog.OK)
{
description = dialog.getServerDescription() + "/" + dialog.getRepositoryName();
@@ -50,12 +48,22 @@ public final class OpenSessionAction extends LongRunningAction
@Override
protected void doRun(IProgressMonitor monitor) throws Exception
{
- String productGroup = CDOSessionFactory.PRODUCT_GROUP;
- String type = CDOProtocolConstants.PROTOCOL_NAME;
- CDOSession session = (CDOSession)IPluginContainer.INSTANCE.getElement(productGroup, type, description);
+ CDOSession session = null;
+
+ try
+ {
+ String productGroup = CDOSessionFactory.PRODUCT_GROUP;
+ String type = CDOProtocolConstants.PROTOCOL_NAME;
+ session = (CDOSession)IPluginContainer.INSTANCE.getElement(productGroup, type, description);
+ }
+ catch (RuntimeException ex)
+ {
+ OM.LOG.error(ex);
+ }
+
if (session == null)
{
- MessageDialog.openError(getShell(), getText(), "Could not open a session to the specified repository.");
+ MessageDialog.openError(getShell(), getText(), "Could not open a session on the specified repository.");
}
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ChannelInjector.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ChannelInjector.java
index 8236094..6b6481e 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ChannelInjector.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ChannelInjector.java
@@ -11,6 +11,7 @@
package org.eclipse.emf.internal.cdo.util;
import org.eclipse.net4j.IConnector;
+import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.container.IElementProcessor;
import org.eclipse.net4j.util.container.IManagedContainer;
@@ -45,10 +46,20 @@ public class ChannelInjector implements IElementProcessor
protected IConnector getConnector(IManagedContainer container, String description)
{
+
URI uri = URI.createURI(description);
String factoryType = uri.scheme();
+ if (StringUtil.isEmpty(factoryType))
+ {
+ throw new IllegalArgumentException("Connector type (scheme) missing: " + description);
+ }
String connectorDescription = uri.authority();
+ if (StringUtil.isEmpty(connectorDescription))
+ {
+ throw new IllegalArgumentException("Illegal connector description: " + description);
+ }
+
return (IConnector)container.getElement(ConnectorFactory.PRODUCT_GROUP, factoryType, connectorDescription);
}
}
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/actions/LongRunningAction.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/actions/LongRunningAction.java
index 1870ff3..75f40da 100644
--- a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/actions/LongRunningAction.java
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/actions/LongRunningAction.java
@@ -21,6 +21,7 @@ import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
/**
* @author Eike Stepper
@@ -104,12 +105,28 @@ public abstract class LongRunningAction extends SafeAction
public IWorkbenchPage getPage()
{
- return page;
+ if (page != null)
+ {
+ return page;
+ }
+
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window != null)
+ {
+ return window.getActivePage();
+ }
+
+ return null;
}
public IWorkbenchWindow getWorkbenchWindow()
{
- return page.getWorkbenchWindow();
+ if (page != null)
+ {
+ return page.getWorkbenchWindow();
+ }
+
+ return PlatformUI.getWorkbench().getActiveWorkbenchWindow();
}
public Shell getShell()