summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-09-28 05:41:27 (EDT)
committerEike Stepper2007-09-28 05:41:27 (EDT)
commitb136c213f3dbd4f187e62f64c1d9f30e7ab68c8b (patch)
tree6fa514c4261c0e31c85b52ff1787aa78bd561801
parent9b2828b6b8b23cd6e6630fa220c288de1ab598b3 (diff)
downloadcdo-b136c213f3dbd4f187e62f64c1d9f30e7ab68c8b.zip
cdo-b136c213f3dbd4f187e62f64c1d9f30e7ab68c8b.tar.gz
cdo-b136c213f3dbd4f187e62f64c1d9f30e7ab68c8b.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.java55
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java13
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenSessionDialog.java132
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsView.java42
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java8
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java6
6 files changed, 222 insertions, 34 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
new file mode 100644
index 0000000..ffb9488
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenSessionAction.java
@@ -0,0 +1,55 @@
+package org.eclipse.emf.cdo.internal.ui.actions;
+
+import org.eclipse.emf.cdo.CDOSession;
+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;
+
+import org.eclipse.emf.internal.cdo.CDOSessionFactory;
+
+import org.eclipse.net4j.util.container.IPluginContainer;
+import org.eclipse.net4j.util.ui.actions.LongRunningAction;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.ui.IWorkbenchPage;
+
+/**
+ * @author Eike Stepper
+ */
+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;
+ }
+
+ @Override
+ protected void preRun() throws Exception
+ {
+ OpenSessionDialog dialog = new OpenSessionDialog(page);
+ dialog.open();
+ description = dialog.getDescription();
+ if (description == null)
+ {
+ cancel();
+ }
+ }
+
+ @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);
+ if (session == null)
+ {
+ MessageDialog.openError(getShell(), getText(), "Could not open a session to the specified repository.");
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java
index d7dca92..484b1bf 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java
@@ -33,8 +33,17 @@ public abstract class OM
public static final OMPreferences PREFS = BUNDLE.preferences();
- public static final OMPreference<String[]> PREF_HISTORY_SELECT_PACKAGES = PREFS
- .initArray("PREF_HISTORY_SELECT_PACKAGES");
+ public static final OMPreference<String[]> PREF_HISTORY_SELECT_PACKAGES = //
+ PREFS.initArray("PREF_HISTORY_SELECT_PACKAGES");
+
+ public static final OMPreference<String[]> PREF_HISTORY_CONNECTORS = //
+ PREFS.initArray("PREF_HISTORY_CONNECTORS");
+
+ public static final OMPreference<String[]> PREF_HISTORY_REPOSITORIES = //
+ PREFS.initArray("PREF_HISTORY_REPOSITORIES");
+
+ public static final OMPreference<Boolean> PREF_LEGACY_SUPPORT = //
+ PREFS.init("PREF_LEGACY_SUPPORT", true);
/**
* @author Eike Stepper
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenSessionDialog.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenSessionDialog.java
new file mode 100644
index 0000000..ac8f2f5
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenSessionDialog.java
@@ -0,0 +1,132 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.emf.cdo.internal.ui.dialogs;
+
+import org.eclipse.emf.cdo.internal.ui.SharedIcons;
+import org.eclipse.emf.cdo.internal.ui.bundle.OM;
+
+import org.eclipse.net4j.internal.util.collection.PreferenceHistory;
+import org.eclipse.net4j.util.collection.IHistory;
+import org.eclipse.net4j.util.ui.widgets.HistoryText;
+import org.eclipse.net4j.util.ui.widgets.PreferenceButton;
+
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPage;
+
+/**
+ * @author Eike Stepper
+ */
+public class OpenSessionDialog extends TitleAreaDialog
+{
+ public static final String TITLE = "Open Session";
+
+ private IWorkbenchPage page;
+
+ private IHistory<String> connectorHistory = new PreferenceHistory(OM.PREF_HISTORY_CONNECTORS);
+
+ private IHistory<String> repositoryHistory = new PreferenceHistory(OM.PREF_HISTORY_REPOSITORIES);
+
+ private HistoryText connector;
+
+ private Label example;
+
+ private HistoryText repository;
+
+ private String description;
+
+ private PreferenceButton legacy;
+
+ public OpenSessionDialog(IWorkbenchPage page)
+ {
+ super(new Shell(page.getWorkbenchWindow().getShell()));
+ this.page = page;
+ setShellStyle(getShellStyle() | SWT.APPLICATION_MODAL | SWT.MAX | SWT.TITLE | SWT.RESIZE);
+ }
+
+ public IWorkbenchPage getPage()
+ {
+ return page;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ @Override
+ protected void configureShell(Shell newShell)
+ {
+ super.configureShell(newShell);
+ newShell.setText(TITLE);
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent)
+ {
+ Composite composite = new Composite((Composite)super.createDialogArea(parent), SWT.NONE);
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ composite.setLayout(new GridLayout(2, false));
+
+ setTitle(TITLE);
+ setTitleImage(SharedIcons.getImage(SharedIcons.WIZBAN_PACKAGE_MANAGER));
+
+ new Label(composite, SWT.NONE).setText("Server Description:");
+ connector = new HistoryText(composite, SWT.BORDER | SWT.SINGLE, connectorHistory);
+ connector.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
+ new Label(composite, SWT.NONE);
+ example = new Label(composite, SWT.NONE);
+ example.setText("example: tcp://estepper@dev.eclipse.org:2036");
+ example.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
+
+ new Label(composite, SWT.NONE).setText("Repository Name:");
+ repository = new HistoryText(composite, SWT.BORDER | SWT.SINGLE, repositoryHistory);
+ repository.setLayoutData(new GridData(150, SWT.DEFAULT));
+
+ new Label(composite, SWT.NONE).setText("Legacy Support:");
+ legacy = new PreferenceButton(composite, SWT.CHECK, OM.PREF_LEGACY_SUPPORT);
+
+ connector.getCombo().addFocusListener(new FocusListener()
+ {
+ public void focusGained(FocusEvent e)
+ {
+ example.setVisible(true);
+ }
+
+ public void focusLost(FocusEvent e)
+ {
+ example.setVisible(false);
+ }
+ });
+
+ return composite;
+ }
+
+ @Override
+ protected void okPressed()
+ {
+ description = connector.getText() + "/" + repository.getText();
+ if (!legacy.getSelection())
+ {
+ description += "?disableLegacyObjects=true";
+ }
+
+ super.okPressed();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsView.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsView.java
index e3fb0b7..d3eb43d 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsView.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsView.java
@@ -2,34 +2,36 @@ package org.eclipse.emf.cdo.internal.ui.views;
import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.CDOView;
+import org.eclipse.emf.cdo.internal.ui.actions.OpenSessionAction;
import org.eclipse.emf.cdo.internal.ui.editor.CDOEditor;
-import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
import org.eclipse.net4j.util.container.IContainer;
import org.eclipse.net4j.util.container.IManagedContainer;
import org.eclipse.net4j.util.container.IPluginContainer;
-import org.eclipse.net4j.util.ui.actions.LongRunningAction;
import org.eclipse.net4j.util.ui.views.ContainerItemProvider;
import org.eclipse.net4j.util.ui.views.ContainerView;
import org.eclipse.net4j.util.ui.views.IElementFilter;
-import org.eclipse.emf.internal.cdo.CDOSessionFactory;
-
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbenchPage;
public class CDOSessionsView extends ContainerView
{
- private OpenSessionAction openSessionAction2036 = new OpenSessionAction(2036);
-
- private OpenSessionAction openSessionAction2037 = new OpenSessionAction(2037);
+ private OpenSessionAction openSessionAction;
public CDOSessionsView()
{
}
@Override
+ public void createPartControl(Composite parent)
+ {
+ openSessionAction = new OpenSessionAction(getViewSite().getPage());
+ super.createPartControl(parent);
+ }
+
+ @Override
protected IManagedContainer getContainer()
{
return IPluginContainer.INSTANCE;
@@ -50,8 +52,7 @@ public class CDOSessionsView extends ContainerView
@Override
protected void fillLocalToolBar(IToolBarManager manager)
{
- manager.add(openSessionAction2036);
- manager.add(openSessionAction2037);
+ manager.add(openSessionAction);
super.fillLocalToolBar(manager);
}
@@ -71,25 +72,4 @@ public class CDOSessionsView extends ContainerView
super.doubleClicked(object);
}
}
-
- /**
- * @author Eike Stepper
- */
- private static final class OpenSessionAction extends LongRunningAction
- {
- private int port;
-
- private OpenSessionAction(int port)
- {
- super("Open Session " + port, "Open a CDO session on port " + port, getAddImageDescriptor());
- this.port = port;
- }
-
- @Override
- protected void doRun(IProgressMonitor monitor) throws Exception
- {
- IPluginContainer.INSTANCE.getElement(CDOSessionFactory.PRODUCT_GROUP, CDOProtocolConstants.PROTOCOL_NAME,
- "tcp://127.0.0.1:" + port + "/repo1");
- }
- }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java
index 299c835..f84e677 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java
@@ -135,9 +135,15 @@ public final class CDOUtil
return session;
}
+ public static CDOSession openSession(IConnector connector, String repositoryName, boolean disableLegacyObjects)
+ throws ConnectorException
+ {
+ return openSession(connector, repositoryName, disableLegacyObjects, null, null);
+ }
+
public static CDOSession openSession(IConnector connector, String repositoryName) throws ConnectorException
{
- return openSession(connector, repositoryName, false, null, null);
+ return openSession(connector, repositoryName, false);
}
public static CDOSession openSession(IManagedContainer container, String description) throws ConnectorException
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java
index 62f57a9..7c4c112 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java
@@ -39,6 +39,7 @@ public class CDOSessionFactory extends Factory
{
CDOSessionImpl session = new CDOSessionImpl(EPackage.Registry.INSTANCE);
session.setRepositoryName(getRepositoryName(description));
+ session.setDisableLegacyObjects(isDisableLegacyObjects(description));
return session;
}
@@ -49,6 +50,11 @@ public class CDOSessionFactory extends Factory
return path.segment(0);
}
+ public boolean isDisableLegacyObjects(String description)
+ {
+ return description.contains("disableLegacyObjects=true");
+ }
+
public static CDOSession get(IManagedContainer container, String description)
{
return (CDOSession)container.getElement(PRODUCT_GROUP, TYPE, description);