summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-07 16:57:51 (EDT)
committerEike Stepper2007-10-07 16:57:51 (EDT)
commitd745180a7a327ad7b30cfd291ecc6d311bbb7751 (patch)
treeb2ed2c53ade23737b2c3dfdd5004c306599b700c
parentdcb7845c8b8b5cdd849f792ac75013d145a4c891 (diff)
downloadcdo-d745180a7a327ad7b30cfd291ecc6d311bbb7751.zip
cdo-d745180a7a327ad7b30cfd291ecc6d311bbb7751.tar.gz
cdo-d745180a7a327ad7b30cfd291ecc6d311bbb7751.tar.bz2
[205668] Provide buddies example
https://bugs.eclipse.org/bugs/show_bug.cgi?id=205668
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/plugin.xml8
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/plugin.xml15
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/BuddiesContentProvider.java45
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/BuddiesItemProvider.java81
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/BuddiesView.java35
-rw-r--r--plugins/org.eclipse.net4j.buddies/plugin.xml8
6 files changed, 192 insertions, 0 deletions
diff --git a/plugins/org.eclipse.net4j.buddies.server/plugin.xml b/plugins/org.eclipse.net4j.buddies.server/plugin.xml
index 1893503..2eee119 100644
--- a/plugins/org.eclipse.net4j.buddies.server/plugin.xml
+++ b/plugins/org.eclipse.net4j.buddies.server/plugin.xml
@@ -17,4 +17,12 @@
<plugin>
+ <extension
+ point="org.eclipse.net4j.util.factories">
+ <factory
+ class="org.eclipse.net4j.buddies.internal.server.protocol.BuddiesServerProtocolFactory"
+ productGroup="org.eclipse.net4j.serverProtocols"
+ type="buddies"/>
+ </extension>
+
</plugin>
diff --git a/plugins/org.eclipse.net4j.buddies.ui/plugin.xml b/plugins/org.eclipse.net4j.buddies.ui/plugin.xml
index 1893503..a7b4d9b 100644
--- a/plugins/org.eclipse.net4j.buddies.ui/plugin.xml
+++ b/plugins/org.eclipse.net4j.buddies.ui/plugin.xml
@@ -17,4 +17,19 @@
<plugin>
+ <extension
+ point="org.eclipse.ui.views">
+ <category
+ id="org.eclipse.net4j"
+ name="Net4j">
+ </category>
+ <view
+ category="org.eclipse.net4j"
+ class="org.eclipse.net4j.buddies.internal.ui.BuddiesView"
+ icon="icons/full/view16/cdo_sessions.gif"
+ id="org.eclipse.net4j.BuddiesView"
+ name="Net4j Buddies">
+ </view>
+ </extension>
+
</plugin>
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/BuddiesContentProvider.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/BuddiesContentProvider.java
new file mode 100644
index 0000000..3f936338
--- /dev/null
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/BuddiesContentProvider.java
@@ -0,0 +1,45 @@
+/***************************************************************************
+ * 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.net4j.buddies.internal.ui;
+
+import org.eclipse.net4j.buddies.IBuddySession;
+import org.eclipse.net4j.util.ui.StructuredContentProvider;
+
+import org.eclipse.internal.net4j.ConnectorFactory;
+
+/**
+ * @author Eike Stepper
+ */
+public class BuddiesContentProvider extends StructuredContentProvider<IBuddySession>
+{
+ public static final String PRODUCT_GROUP = ConnectorFactory.PRODUCT_GROUP;
+
+ public BuddiesContentProvider()
+ {
+ }
+
+ public Object[] getElements(Object inputElement)
+ {
+ return getInput().getElements();
+ }
+
+ @Override
+ protected void connectInput(IBuddySession input)
+ {
+ input.addListener(this);
+ }
+
+ @Override
+ protected void disconnectInput(IBuddySession input)
+ {
+ input.removeListener(this);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/BuddiesItemProvider.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/BuddiesItemProvider.java
new file mode 100644
index 0000000..fe8396c
--- /dev/null
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/BuddiesItemProvider.java
@@ -0,0 +1,81 @@
+/***************************************************************************
+ * 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.net4j.buddies.internal.ui;
+
+import org.eclipse.net4j.util.container.IContainer;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+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.jface.action.IMenuManager;
+import org.eclipse.jface.viewers.ITreeSelection;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @author Eike Stepper
+ */
+public class BuddiesItemProvider extends ContainerItemProvider<IContainer<Object>>
+{
+ public BuddiesItemProvider()
+ {
+ }
+
+ public BuddiesItemProvider(IElementFilter rootElementFilter)
+ {
+ super(rootElementFilter);
+ }
+
+ @Override
+ public Image getImage(Object obj)
+ {
+ if (obj instanceof String)
+ {
+ // return SharedIcons.getImage(SharedIcons.OBJ_ACCEPTOR);
+ }
+
+ return super.getImage(obj);
+ }
+
+ @Override
+ protected void fillContextMenu(IMenuManager manager, ITreeSelection selection)
+ {
+ if (selection.size() == 1)
+ {
+ Object obj = selection.getFirstElement();
+ if (obj instanceof String)
+ {
+ manager.add(new RemoveAction(obj));
+ }
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public class RemoveAction extends LongRunningAction
+ {
+ private Object object;
+
+ public RemoveAction(Object object)
+ {
+ super("Remove", "Remove", ContainerView.getDeleteImageDescriptor());
+ this.object = object;
+ }
+
+ @Override
+ protected void doRun() throws Exception
+ {
+ LifecycleUtil.deactivateNoisy(object);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/BuddiesView.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/BuddiesView.java
new file mode 100644
index 0000000..2a2ec7a
--- /dev/null
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/BuddiesView.java
@@ -0,0 +1,35 @@
+package org.eclipse.net4j.buddies.internal.ui;
+
+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.views.ContainerItemProvider;
+import org.eclipse.net4j.util.ui.views.ContainerView;
+
+import org.eclipse.jface.action.IToolBarManager;
+
+public class BuddiesView extends ContainerView
+{
+ public BuddiesView()
+ {
+ }
+
+ @Override
+ protected IManagedContainer getContainer()
+ {
+ return IPluginContainer.INSTANCE;
+ }
+
+ @Override
+ protected ContainerItemProvider<IContainer<Object>> createContainerItemProvider()
+ {
+ return new BuddiesItemProvider();
+ }
+
+ @Override
+ protected void fillLocalToolBar(IToolBarManager manager)
+ {
+ // manager.add(addConnectorAction);
+ super.fillLocalToolBar(manager);
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.buddies/plugin.xml b/plugins/org.eclipse.net4j.buddies/plugin.xml
index 1893503..c662f1b 100644
--- a/plugins/org.eclipse.net4j.buddies/plugin.xml
+++ b/plugins/org.eclipse.net4j.buddies/plugin.xml
@@ -17,4 +17,12 @@
<plugin>
+ <extension
+ point="org.eclipse.net4j.util.factories">
+ <factory
+ class="org.eclipse.net4j.internal.buddies.protocol.BuddiesClientProtocolFactory"
+ productGroup="org.eclipse.net4j.clientProtocols"
+ type="buddies"/>
+ </extension>
+
</plugin>