diff options
author | Eike Stepper | 2009-07-17 13:48:39 +0000 |
---|---|---|
committer | Eike Stepper | 2009-07-17 13:48:39 +0000 |
commit | 88cc9df1f67dab7569370f9e6c658b4b904c8783 (patch) | |
tree | b7d51dfcc0b6bc8b3faa0b6b5d8b0fe561ad9e8f /plugins | |
parent | e25bc71d4a58d6105242bc63c327a068b66eb11c (diff) | |
download | cdo-88cc9df1f67dab7569370f9e6c658b4b904c8783.tar.gz cdo-88cc9df1f67dab7569370f9e6c658b4b904c8783.tar.xz cdo-88cc9df1f67dab7569370f9e6c658b4b904c8783.zip |
[283689] [UI] Provide CollaborationView
https://bugs.eclipse.org/bugs/show_bug.cgi?id=283689
Diffstat (limited to 'plugins')
2 files changed, 79 insertions, 23 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDORemoteSessionsView.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDORemoteSessionsView.java index 30f3b196bd..debbec969b 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDORemoteSessionsView.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDORemoteSessionsView.java @@ -19,6 +19,8 @@ import org.eclipse.net4j.util.event.IListener; import org.eclipse.net4j.util.ui.UIUtil; import org.eclipse.net4j.util.ui.views.ContainerView; +import org.eclipse.jface.dialogs.InputDialog; +import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ISelection; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; @@ -32,6 +34,8 @@ import org.eclipse.ui.IWorkbenchPart; */ public class CDORemoteSessionsView extends ContainerView.Default<CDORemoteSessionManager> { + private static final String TYPE_TEXT_MESSAGE = "org.eclipse.emf.cdo.ui.TextMessage"; + private ISelectionListener selectionListener = new ISelectionListener() { public void selectionChanged(IWorkbenchPart part, ISelection selection) @@ -51,6 +55,12 @@ public class CDORemoteSessionsView extends ContainerView.Default<CDORemoteSessio private IListener containerListener = new CDORemoteSessionManager.EventAdapter() { @Override + protected void onLocalSubscriptionChanged(boolean subscribed) + { + getViewer().getControl().setEnabled(subscribed); + } + + @Override protected void onSubscribed(CDORemoteSession remoteSession) { refreshElement(remoteSession, true); @@ -63,8 +73,30 @@ public class CDORemoteSessionsView extends ContainerView.Default<CDORemoteSessio } @Override - protected void onCustomData(CDORemoteSession remoteSession, String type, byte[] data) + protected void onCustomData(final CDORemoteSession remoteSession, String type, final byte[] data) { + if (TYPE_TEXT_MESSAGE.equals(type)) + { + try + { + getDisplay().asyncExec(new Runnable() + { + public void run() + { + try + { + MessageDialog.openInformation(getShell(), "Message from " + remoteSession, new String(data)); + } + catch (RuntimeException ignore) + { + } + } + }); + } + catch (RuntimeException ignore) + { + } + } } }; @@ -82,8 +114,10 @@ public class CDORemoteSessionsView extends ContainerView.Default<CDORemoteSessio @Override protected Control createUI(Composite parent) { + Control control = super.createUI(parent); + getViewer().getControl().setEnabled(false); getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener(selectionListener); - return super.createUI(parent); + return control; } @Override @@ -93,7 +127,7 @@ public class CDORemoteSessionsView extends ContainerView.Default<CDORemoteSessio } @Override - public Color getElementForeground(Object element) + protected Color getElementForeground(Object element) { if (element instanceof CDORemoteSession) { @@ -106,4 +140,26 @@ public class CDORemoteSessionsView extends ContainerView.Default<CDORemoteSessio return null; } + + @Override + protected void doubleClicked(Object element) + { + if (element instanceof CDORemoteSession) + { + CDORemoteSession remoteSession = (CDORemoteSession)element; + if (remoteSession.isSubscribed()) + { + InputDialog dlg = new InputDialog(getShell(), "Message to " + remoteSession, "Message:", "", null); + if (dlg.open() == InputDialog.OK) + { + String message = dlg.getValue(); + remoteSession.sendCustomData(TYPE_TEXT_MESSAGE, message.getBytes()); + } + + return; + } + } + + super.doubleClicked(element); + } } diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerView.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerView.java index 5445e245b9..f62aea6af5 100644 --- a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerView.java +++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerView.java @@ -283,7 +283,7 @@ public abstract class ContainerView extends ViewPart implements ISelectionProvid /** * @since 3.0 */ - public Color getElementForeground(Object element) + protected Color getElementForeground(Object element) { return null; } @@ -291,7 +291,7 @@ public abstract class ContainerView extends ViewPart implements ISelectionProvid /** * @since 3.0 */ - public Color getElementBackground(Object element) + protected Color getElementBackground(Object element) { return null; } @@ -299,7 +299,7 @@ public abstract class ContainerView extends ViewPart implements ISelectionProvid /** * @since 3.0 */ - public Font getElementFont(Object element) + protected Font getElementFont(Object element) { return null; } @@ -390,7 +390,7 @@ public abstract class ContainerView extends ViewPart implements ISelectionProvid { try { - getSite().getShell().getDisplay().syncExec(new Runnable() + getDisplay().syncExec(new Runnable() { public void run() { @@ -442,6 +442,17 @@ public abstract class ContainerView extends ViewPart implements ISelectionProvid } } + protected Display getDisplay() + { + Display display = viewer.getControl().getDisplay(); + if (display == null) + { + display = UIUtil.getDisplay(); + } + + return display; + } + public void refreshViewer(boolean updateLabels) { refreshElement(null, updateLabels); @@ -523,17 +534,6 @@ public abstract class ContainerView extends ViewPart implements ISelectionProvid } } - protected Display getDisplay() - { - Display display = viewer.getControl().getDisplay(); - if (display == null) - { - display = UIUtil.getDisplay(); - } - - return display; - } - public static ImageDescriptor getAddImageDescriptor() { return SharedIcons.getDescriptor(SharedIcons.TOOL_ADD); @@ -583,6 +583,11 @@ public abstract class ContainerView extends ViewPart implements ISelectionProvid { } + protected IListener getContainerListener() + { + return null; + } + @Override protected CONTAINER getContainer() { @@ -608,10 +613,5 @@ public abstract class ContainerView extends ViewPart implements ISelectionProvid resetInput(); } } - - protected IListener getContainerListener() - { - return null; - } } } |