summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-02-25 06:46:51 (EST)
committerEike Stepper2007-02-25 06:46:51 (EST)
commit45e23f2a19f4b16014a7ea72aae2c221b42b99c8 (patch)
tree80003a16a5793149cc08e8cc9172d9ca09179a39
parent859e4e780dfbfd9f0c168c7a4a1b55640cfc0b3d (diff)
downloadcdo-45e23f2a19f4b16014a7ea72aae2c221b42b99c8.zip
cdo-45e23f2a19f4b16014a7ea72aae2c221b42b99c8.tar.gz
cdo-45e23f2a19f4b16014a7ea72aae2c221b42b99c8.tar.bz2
Develop CDO2 - http://www.eclipse.org/emft/projects/cdo/#cdo
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsItemProvider.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsView.java62
2 files changed, 50 insertions, 20 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsItemProvider.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsItemProvider.java
index 3ecbcc6..bfb6aa7 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsItemProvider.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsItemProvider.java
@@ -21,6 +21,7 @@ import org.eclipse.emf.cdo.internal.ui.bundle.SharedIcons;
import org.eclipse.net4j.util.event.IEvent;
import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.net4j.util.registry.IRegistry;
import org.eclipse.net4j.util.registry.IRegistryDelta;
import org.eclipse.net4j.util.registry.IRegistryEvent;
import org.eclipse.net4j.util.registry.IRegistryListener;
@@ -125,7 +126,12 @@ public class CDOSessionsItemProvider extends ItemProvider<CDOContainerAdapter> i
@Override
protected void connectInput(CDOContainerAdapter input)
{
- input.getSessionRegistry().addRegistryListener(this);
+ IRegistry<String, CDOSession> registry = input.getSessionRegistry();
+ registry.addRegistryListener(this);
+ for (CDOSession session : registry.values())
+ {
+ session.addListener(this);
+ }
}
@Override
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 c68b29a..312d7d2 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
@@ -1,6 +1,7 @@
package org.eclipse.emf.cdo.internal.ui.views;
import org.eclipse.emf.cdo.CDOConstants;
+import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.container.CDOContainerAdapter;
import org.eclipse.emf.cdo.internal.ui.bundle.CDOUI;
@@ -8,10 +9,12 @@ import org.eclipse.net4j.container.Container;
import org.eclipse.net4j.container.ContainerManager;
import org.eclipse.net4j.transport.ConnectorException;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.SWT;
@@ -30,9 +33,9 @@ public class CDOSessionsView extends StructuredView
private TreeViewer viewer;
- private Action openSessionAction = new OpenSessionAction();
+ private OpenSessionAction openSessionAction = new OpenSessionAction();
- private Action attachAdapterAction = new AttachAdapterAction();
+ private AttachAdapterAction attachAdapterAction = new AttachAdapterAction();
public CDOSessionsView()
{
@@ -58,10 +61,26 @@ public class CDOSessionsView extends StructuredView
}
@Override
+ protected void fillContextMenu(IMenuManager manager)
+ {
+ IStructuredSelection selection = (IStructuredSelection)getCurrentViewer().getSelection();
+ if (selection.size() == 1)
+ {
+ Object element = selection.getFirstElement();
+ if (element instanceof CDOSession)
+ {
+ attachAdapterAction.setSession((CDOSession)element);
+ addContribution(manager, attachAdapterAction);
+ }
+ }
+
+ super.fillContextMenu(manager);
+ }
+
+ @Override
protected void fillLocalPullDown(IMenuManager manager)
{
addContribution(manager, openSessionAction);
- addContribution(manager, attachAdapterAction);
super.fillLocalPullDown(manager);
}
@@ -69,7 +88,6 @@ public class CDOSessionsView extends StructuredView
protected void fillLocalToolBar(IToolBarManager manager)
{
addContribution(manager, openSessionAction);
- addContribution(manager, attachAdapterAction);
super.fillLocalToolBar(manager);
}
@@ -109,6 +127,8 @@ public class CDOSessionsView extends StructuredView
*/
private final class AttachAdapterAction extends Action
{
+ private CDOSession session;
+
public AttachAdapterAction()
{
setText("Attach Adapter");
@@ -117,23 +137,27 @@ public class CDOSessionsView extends StructuredView
ISharedImages.IMG_TOOL_NEW_WIZARD));
}
+ public CDOSession getSession()
+ {
+ return session;
+ }
+
+ public void setSession(CDOSession session)
+ {
+ this.session = session;
+ setEnabled(session != null);
+ }
+
public void run()
{
- InputDialog dialog = new InputDialog(getCurrentViewer().getControl().getShell(), "CDO Sessions",
- "Enter a session description:", null, null);
- if (dialog.open() == InputDialog.OK)
+ try
{
- String description = dialog.getValue();
-
- try
- {
- CDO_ADAPTER.getSession(description);
- }
- catch (ConnectorException ex)
- {
- CDOUI.LOG.error(ex);
- showMessage("Error while creating session for description " + description);
- }
+ session.attach(new ResourceSetImpl());
+ }
+ catch (Exception ex)
+ {
+ CDOUI.LOG.error(ex);
+ showMessage("Error while attaching adapter to session " + session);
}
}
}