summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-04-07 11:55:36 (EDT)
committerEike Stepper2007-04-07 11:55:36 (EDT)
commitb5a02444dba63d8920e5ef8c8ca5f5138545d51c (patch)
treed8c6f7b526bb8483189809028890bcd6145049b7
parent19268a2ee5d3194500b4ab71b73d2d213ecc4406 (diff)
downloadcdo-b5a02444dba63d8920e5ef8c8ca5f5138545d51c.zip
cdo-b5a02444dba63d8920e5ef8c8ca5f5138545d51c.tar.gz
cdo-b5a02444dba63d8920e5ef8c8ca5f5138545d51c.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF10
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/CDOUI.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditorInput.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java62
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsItemProvider.java144
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsView.java244
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewEditorWizard.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewEditorWizardPage.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewSessionWizard.java2
-rw-r--r--plugins/org.eclipse.net4j.tcp/plugin.xml10
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ClientTestProtocolFactory.java34
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ServerTestProtocolFactory.java (renamed from plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestProtocolFactory.java)4
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPTransportTest.java10
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestProtocol.java2
-rw-r--r--plugins/org.eclipse.net4j.ui/META-INF/MANIFEST.MF7
-rw-r--r--plugins/org.eclipse.net4j.ui/icons/full/etool16/add.gifbin0 -> 318 bytes
-rw-r--r--plugins/org.eclipse.net4j.ui/icons/full/etool16/add_acceptor.gifbin0 -> 381 bytes
-rw-r--r--plugins/org.eclipse.net4j.ui/icons/full/etool16/add_connector.gifbin0 -> 223 bytes
-rw-r--r--plugins/org.eclipse.net4j.ui/icons/full/view16/acceptors.gifbin0 -> 376 bytes
-rw-r--r--plugins/org.eclipse.net4j.ui/icons/full/view16/connectors.gifbin0 -> 202 bytes
-rw-r--r--plugins/org.eclipse.net4j.ui/icons/plus.gifbin0 -> 171 bytes
-rw-r--r--plugins/org.eclipse.net4j.ui/plugin.xml15
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/ContainerItemProvider.java339
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/ContainerNameSorter.java (renamed from plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/Net4jExplorerNameSorter.java)4
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/ContainerView.java175
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/IElementFilter.java19
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/ItemProvider.java (renamed from plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/ItemProvider.java)47
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/ManagedContainerItemProvider.java173
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/SafeAction.java46
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/StructuredView.java (renamed from plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/StructuredView.java)3
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/bundle/SharedIcons.java58
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/AcceptorsItemProvider.java179
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/AcceptorsView.java53
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/AdaptersItemProvider.java77
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/ConnectorsItemProvider.java116
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/ConnectorsView.java53
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/FactoriesItemProvider.java147
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/ItemProvider.java161
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/Net4jExplorerView.java230
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/Net4jItemProvider.java69
-rw-r--r--plugins/org.eclipse.net4j/plugin.xml1
-rw-r--r--plugins/org.eclipse.net4j/schema/elementProcessors.exsd105
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/Net4j.java1
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/PluginTransportContainer.java76
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferFactory.java4
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferPool.java3
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/Channel.java3
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/Connector.java39
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/TransportContainer.java22
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/concurrent/NamedExecutorService.java137
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/container/LifecycleEventConverter.java16
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/container/ManagedContainer.java55
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/container/PluginElementProcessorList.java132
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/registry/Registry.java3
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java3
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ConnectorException.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/IPluginTransportContainer.java21
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ITransportContainer.java18
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/container/IManagedContainer.java5
60 files changed, 1775 insertions, 1382 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF
index d47873b..64c7b94 100644
--- a/plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF
@@ -6,10 +6,10 @@ Bundle-Version: 0.8.0.qualifier
Bundle-Activator: org.eclipse.emf.cdo.internal.ui.bundle.CDOUI$Activator
Bundle-Vendor: %providerName
Require-Bundle: org.eclipse.core.runtime,
- org.eclipse.ui,
- org.eclipse.emf.cdo.container,
- org.eclipse.emf.edit.ui;visibility:=reexport,
- org.eclipse.ui.ide;visibility:=reexport,
org.eclipse.core.resources,
- org.eclipse.emf.ecore.edit
+ org.eclipse.ui.ide;visibility:=reexport,
+ org.eclipse.net4j.ui;visibility:=reexport,
+ org.eclipse.emf.edit.ui;visibility:=reexport,
+ org.eclipse.emf.ecore.edit;visibility:=reexport,
+ org.eclipse.emf.cdo;visibility:=reexport
Eclipse-LazyStart: true
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/CDOUI.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/CDOUI.java
index b3769a4..776bcf6 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/CDOUI.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/CDOUI.java
@@ -10,6 +10,13 @@
**************************************************************************/
package org.eclipse.emf.cdo.internal.ui.bundle;
+import org.eclipse.net4j.util.om.OMBundle;
+import org.eclipse.net4j.util.om.OMLogger;
+import org.eclipse.net4j.util.om.OMPlatform;
+import org.eclipse.net4j.util.om.OMTracer;
+
+import org.eclipse.internal.net4j.util.om.OSGiActivator;
+
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
index 0fb088e..8f514aa 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
@@ -6,6 +6,10 @@
*/
package org.eclipse.emf.cdo.internal.ui.editor;
+import org.eclipse.emf.cdo.CDOAdapter;
+import org.eclipse.emf.cdo.CDOSession;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
import org.eclipse.emf.common.command.BasicCommandStack;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditorInput.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditorInput.java
index 796ca29..607d0fc 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditorInput.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditorInput.java
@@ -10,6 +10,7 @@
**************************************************************************/
package org.eclipse.emf.cdo.internal.ui.editor;
+import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.internal.ui.bundle.SharedIcons;
import org.eclipse.jface.resource.ImageDescriptor;
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java
new file mode 100644
index 0000000..e7db888
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java
@@ -0,0 +1,62 @@
+/***************************************************************************
+ * Copyright (c) 2004, 2005, 2006 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.views;
+
+import org.eclipse.emf.cdo.CDOAdapter;
+import org.eclipse.emf.cdo.CDOSession;
+import org.eclipse.emf.cdo.internal.ui.bundle.SharedIcons;
+
+import org.eclipse.net4j.internal.ui.ContainerItemProvider;
+import org.eclipse.net4j.internal.ui.IElementFilter;
+
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDOItemProvider extends ContainerItemProvider
+{
+ public CDOItemProvider()
+ {
+ }
+
+ public CDOItemProvider(IElementFilter rootElementFilter)
+ {
+ super(rootElementFilter);
+ }
+
+ @Override
+ public Image getImage(Object obj)
+ {
+ if (obj instanceof CDOSession)
+ {
+ return SharedIcons.getImage(SharedIcons.OBJ_SESSION);
+ }
+
+ if (obj instanceof CDOAdapter)
+ {
+ CDOAdapter adapter = (CDOAdapter)obj;
+ if (adapter.isHistorical())
+ {
+ return SharedIcons.getImage(SharedIcons.OBJ_EDITOR_HISTORICAL);
+ }
+
+ if (adapter.isReadOnly())
+ {
+ return SharedIcons.getImage(SharedIcons.OBJ_EDITOR_READONLY);
+ }
+
+ return SharedIcons.getImage(SharedIcons.OBJ_EDITOR);
+ }
+
+ return super.getImage(obj);
+ }
+}
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
deleted file mode 100644
index 1123ef6..0000000
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsItemProvider.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/***************************************************************************
- * 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.views;
-
-import org.eclipse.emf.cdo.internal.ui.bundle.SharedIcons;
-
-import org.eclipse.swt.graphics.Image;
-
-import java.text.MessageFormat;
-import java.util.Collection;
-
-public class CDOSessionsItemProvider extends ItemProvider<CDOContainerAdapter> implements IRegistryListener, IListener
-{
- public CDOSessionsItemProvider()
- {
- }
-
- public Object getParent(Object child)
- {
- if (child instanceof CDOSession)
- {
- return getInput();
- }
-
- if (child instanceof CDOAdapter)
- {
- CDOAdapter adapter = (CDOAdapter)child;
- return adapter.getSession();
- }
-
- return null;
- }
-
- public Object[] getChildren(Object parent)
- {
- if (parent == getInput())
- {
- Collection values = getInput().getSessionRegistry().values();
- return values.toArray(new Object[values.size()]);
- }
-
- if (parent instanceof CDOSession)
- {
- CDOSession session = (CDOSession)parent;
- return session.getAdapters();
- }
-
- return NO_CHILDREN;
- }
-
- public void notifyRegistryEvent(IRegistryEvent event)
- {
- IRegistryDelta[] deltas = event.getDeltas();
- for (IRegistryDelta delta : deltas)
- {
- Object element = delta.getElement();
- if (element instanceof CDOSession)
- {
- CDOSession session = (CDOSession)element;
- switch (delta.getKind())
- {
- case REGISTERED:
- session.addListener(this);
- break;
- case DEREGISTERED:
- session.removeListener(this);
- break;
- }
- }
- }
-
- refreshViewer(false);
- }
-
- public void notifyEvent(IEvent event)
- {
- refreshViewer(false);
- }
-
- @Override
- public String getText(Object obj)
- {
- if (obj instanceof CDOSession)
- {
- CDOSession session = (CDOSession)obj;
- String description = CDOContainerAdapterImpl.getDescription(session);
- return MessageFormat.format("[{0}] {1}", session.getSessionID(), description);
- }
-
- return super.getText(obj);
- }
-
- @Override
- public Image getImage(Object obj)
- {
- if (obj instanceof CDOSession)
- {
- return SharedIcons.getImage(SharedIcons.OBJ_SESSION);
- }
-
- if (obj instanceof CDOAdapter)
- {
- CDOAdapter adapter = (CDOAdapter)obj;
- if (adapter.isHistorical())
- {
- return SharedIcons.getImage(SharedIcons.OBJ_EDITOR_HISTORICAL);
- }
-
- if (adapter.isReadOnly())
- {
- return SharedIcons.getImage(SharedIcons.OBJ_EDITOR_READONLY);
- }
-
- return SharedIcons.getImage(SharedIcons.OBJ_EDITOR);
- }
-
- return null;
- }
-
- @Override
- protected void connectInput(CDOContainerAdapter input)
- {
- IRegistry<String, CDOSession> registry = input.getSessionRegistry();
- registry.addRegistryListener(this);
- for (CDOSession session : registry.values())
- {
- session.addListener(this);
- }
- }
-
- @Override
- protected void disconnectInput(CDOContainerAdapter input)
- {
- input.getSessionRegistry().removeRegistryListener(this);
- }
-} \ No newline at end of file
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 e8fce8f..60b7df7 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,246 +1,58 @@
package org.eclipse.emf.cdo.internal.ui.views;
-import org.eclipse.emf.cdo.internal.ui.bundle.CDOUI;
-import org.eclipse.emf.cdo.internal.ui.bundle.SharedIcons;
+import org.eclipse.emf.cdo.CDOSession;
+import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.net4j.internal.ui.ContainerItemProvider;
+import org.eclipse.net4j.internal.ui.ContainerView;
+import org.eclipse.net4j.internal.ui.IElementFilter;
+import org.eclipse.net4j.internal.ui.SafeAction;
+import org.eclipse.net4j.transport.IPluginTransportContainer;
+import org.eclipse.net4j.transport.ITransportContainer;
+
+import org.eclipse.emf.internal.cdo.CDOSessionFactory;
-import org.eclipse.core.internal.resources.Container;
import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-public class CDOSessionsView extends StructuredView
+public class CDOSessionsView extends ContainerView
{
- private static final Container CONTAINER = ContainerManager.INSTANCE.getContainer();
-
- private static final CDOContainerAdapter CDO_ADAPTER = (CDOContainerAdapter)CONTAINER.getAdapter(CDOConstants.TYPE);
-
- private static final ItemProvider ITEM_PROVIDER = new CDOSessionsItemProvider();
-
- private TreeViewer viewer;
-
- private OpenSessionAction openSessionAction = new OpenSessionAction();
-
- private OpenEditorAction openEditorAction = new OpenEditorAction();
-
- private OpenEditorAction openEditorReadOnlyAction = new OpenEditorReadOnlyAction();
-
- private OpenEditorAction openEditorHistoricalAction = new OpenEditorHistoricalAction();
-
- public CDOSessionsView()
+ private Action openSessionAction = new SafeAction("Open Session", "Open a CDO session", getAddImageDescriptor())
{
- }
+ @Override
+ protected void doRun() throws Exception
+ {
+ IPluginTransportContainer.INSTANCE.getElement(CDOSessionFactory.SESSION_GROUP,
+ CDOProtocolConstants.PROTOCOL_NAME, "tcp://127.0.0.1:2036/repo1");
+ }
+ };
- @Override
- protected void doCreatePartControl(Composite parent)
+ public CDOSessionsView()
{
- viewer = new TreeViewer(parent, (SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL));
- viewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
-
- viewer.setContentProvider(ITEM_PROVIDER);
- viewer.setLabelProvider(ITEM_PROVIDER);
- viewer.setSorter(new NameSorter());
- viewer.setInput(CDO_ADAPTER);
-
- getSite().setSelectionProvider(viewer);
}
@Override
- protected StructuredViewer getCurrentViewer()
+ protected ITransportContainer getContainer()
{
- return viewer;
+ return IPluginTransportContainer.INSTANCE;
}
@Override
- protected void fillContextMenu(IMenuManager manager)
+ protected ContainerItemProvider createContainerItemProvider()
{
- IStructuredSelection selection = (IStructuredSelection)getCurrentViewer().getSelection();
- if (selection.size() == 1)
+ return new CDOItemProvider(new IElementFilter()
{
- Object element = selection.getFirstElement();
- if (element instanceof CDOSession)
+ public boolean filter(Object element)
{
- openEditorAction.setSession((CDOSession)element);
- addContribution(manager, openEditorAction);
-
- openEditorReadOnlyAction.setSession((CDOSession)element);
- addContribution(manager, openEditorReadOnlyAction);
-
- openEditorHistoricalAction.setSession((CDOSession)element);
- addContribution(manager, openEditorHistoricalAction);
+ return element instanceof CDOSession;
}
- }
-
- super.fillContextMenu(manager);
- }
-
- @Override
- protected void fillLocalPullDown(IMenuManager manager)
- {
- addContribution(manager, openSessionAction);
- super.fillLocalPullDown(manager);
+ });
}
@Override
protected void fillLocalToolBar(IToolBarManager manager)
{
- addContribution(manager, openSessionAction);
+ manager.add(openSessionAction);
super.fillLocalToolBar(manager);
}
-
- @Override
- protected void onDoubleClick(Object selectedElement)
- {
- if (selectedElement instanceof CDOSession && !viewer.isExpandable(selectedElement))
- {
- openEditorAction.setSession((CDOSession)selectedElement);
- openEditorAction.run();
- }
-
- super.onDoubleClick(selectedElement);
- }
-
- private static final class NameSorter extends ViewerSorter
- {
- }
-
- /**
- * @author Eike Stepper
- */
- private final class OpenSessionAction extends Action
- {
- public OpenSessionAction()
- {
- setText("Open Session");
- setToolTipText("Open a CDO session");
- setImageDescriptor(SharedIcons.getDescriptor(SharedIcons.ETOOL_OPEN_SESSION));
- }
-
- public void run()
- {
- String description = showInputDialog("Enter a session description");
- if (description != null)
- {
- try
- {
- CDO_ADAPTER.getSession(description);
- }
- catch (ConnectorException ex)
- {
- CDOUI.LOG.error(ex);
- showMessage("Error while creating session for description " + description);
- }
- }
- }
- }
-
- /**
- * @author Eike Stepper
- */
- private class OpenEditorAction extends Action
- {
- private CDOSession session;
-
- public OpenEditorAction()
- {
- this("Open Editor", "Open a CDO editor", SharedIcons.ETOOL_OPEN_EDITOR);
- }
-
- protected OpenEditorAction(String text, String tooltip, String iconKey)
- {
- setText(text);
- setToolTipText(tooltip);
- setImageDescriptor(SharedIcons.getDescriptor(iconKey));
- }
-
- public CDOSession getSession()
- {
- return session;
- }
-
- public void setSession(CDOSession session)
- {
- this.session = session;
- setEnabled(session != null);
- }
-
- public void run()
- {
- try
- {
- openEditor(session);
- }
- catch (Exception ex)
- {
- CDOUI.LOG.error(ex);
- showMessage("Error while opening editor on session " + session);
- }
- }
-
- protected void openEditor(CDOSession session)
- {
- session.attach(new ResourceSetImpl());
- }
- }
-
- /**
- * @author Eike Stepper
- */
- private class OpenEditorReadOnlyAction extends OpenEditorAction
- {
- public OpenEditorReadOnlyAction()
- {
- super("Open Editor in Read Only Mode", "Open a CDO editor in read only mode", null);
- }
-
- @Override
- protected void openEditor(CDOSession session)
- {
- session.attach(new ResourceSetImpl(), true);
- }
- }
-
- /**
- * @author Eike Stepper
- */
- private class OpenEditorHistoricalAction extends OpenEditorAction
- {
- public OpenEditorHistoricalAction()
- {
- super("Open Editor in Historical Mode", "Open a CDO editor in historical mode", null);
- }
-
- @Override
- protected void openEditor(CDOSession session)
- {
- DateFormat formatter = SimpleDateFormat.getInstance();
- String value = formatter.format(new Date());
- String str = showInputDialog("Enter a date", value);
- if (str != null)
- {
- try
- {
- Date date = formatter.parse(str);
- session.attach(new ResourceSetImpl(), date.getTime());
- }
- catch (ParseException ex)
- {
- CDOUI.LOG.error(ex);
- }
- }
- }
- }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewEditorWizard.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewEditorWizard.java
index cfe767c..ba39094 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewEditorWizard.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewEditorWizard.java
@@ -1,5 +1,9 @@
package org.eclipse.emf.cdo.internal.ui.wizards;
+import org.eclipse.emf.cdo.CDOSession;
+
+import org.eclipse.net4j.transport.ConnectorException;
+
import org.eclipse.core.internal.resources.Container;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.MessageDialog;
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewEditorWizardPage.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewEditorWizardPage.java
index ebf3ef7..66a05a5 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewEditorWizardPage.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewEditorWizardPage.java
@@ -1,5 +1,7 @@
package org.eclipse.emf.cdo.internal.ui.wizards;
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.internal.ui.bundle.SharedIcons;
import org.eclipse.emf.common.util.EList;
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewSessionWizard.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewSessionWizard.java
index 08886b0..3f9df35 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewSessionWizard.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/wizards/NewSessionWizard.java
@@ -1,5 +1,7 @@
package org.eclipse.emf.cdo.internal.ui.wizards;
+import org.eclipse.net4j.transport.ConnectorException;
+
import org.eclipse.core.internal.resources.Container;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.MessageDialog;
diff --git a/plugins/org.eclipse.net4j.tcp/plugin.xml b/plugins/org.eclipse.net4j.tcp/plugin.xml
index c57536b..774c703 100644
--- a/plugins/org.eclipse.net4j.tcp/plugin.xml
+++ b/plugins/org.eclipse.net4j.tcp/plugin.xml
@@ -13,6 +13,16 @@
class="org.eclipse.net4j.internal.tcp.TCPConnectorFactory"
productGroup="org.eclipse.net4j.connectors"
type="tcp"/>
+ <factory
+ class="org.eclipse.net4j.internal.tcp.TCPSelectorFactory"
+ productGroup="org.eclipse.net4j.selectors"
+ type="tcp"/>
+ </extension>
+ <extension
+ point="org.eclipse.net4j.elementProcessors">
+ <elementProcessor
+ class="org.eclipse.net4j.internal.tcp.TCPSelectorInjector">
+ </elementProcessor>
</extension>
</plugin>
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ClientTestProtocolFactory.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ClientTestProtocolFactory.java
new file mode 100644
index 0000000..a9db577
--- /dev/null
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ClientTestProtocolFactory.java
@@ -0,0 +1,34 @@
+/***************************************************************************
+ * 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.tests;
+
+import org.eclipse.net4j.transport.IProtocol;
+import org.eclipse.net4j.util.factory.ProductCreationException;
+
+import org.eclipse.internal.net4j.transport.ClientProtocolFactory;
+
+/**
+ * @author Eike Stepper
+ */
+public class ClientTestProtocolFactory extends ClientProtocolFactory
+{
+ public static final String TYPE = ServerTestProtocolFactory.TYPE;
+
+ public ClientTestProtocolFactory()
+ {
+ super(TYPE);
+ }
+
+ public IProtocol create(String description) throws ProductCreationException
+ {
+ return null;
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestProtocolFactory.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ServerTestProtocolFactory.java
index 0637646..847a87f 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestProtocolFactory.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ServerTestProtocolFactory.java
@@ -19,13 +19,13 @@ import java.util.concurrent.CountDownLatch;
/**
* @author Eike Stepper
*/
-public class TestProtocolFactory extends ServerProtocolFactory<TestProtocol>
+public class ServerTestProtocolFactory extends ServerProtocolFactory<TestProtocol>
{
public static final String TYPE = "test.protocol";
private CountDownLatch counter;
- public TestProtocolFactory(CountDownLatch counter)
+ public ServerTestProtocolFactory(CountDownLatch counter)
{
super(TYPE);
this.counter = counter;
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPTransportTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPTransportTest.java
index 1fc924e..f4545f2 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPTransportTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPTransportTest.java
@@ -66,7 +66,7 @@ public class TCPTransportTest extends AbstractTransportTest
IBuffer buffer = provideBuffer();
ByteBuffer byteBuffer = buffer.startPutting(channel.getChannelIndex());
byteBuffer.putInt(1970);
- channel.handleBuffer(buffer);
+ channel.sendBuffer(buffer);
}
}
@@ -74,16 +74,18 @@ public class TCPTransportTest extends AbstractTransportTest
{
final int COUNT = 3;
final CountDownLatch counter = new CountDownLatch(COUNT);
- container.registerFactory(new TestProtocolFactory(counter));
+ container.registerFactory(new ServerTestProtocolFactory(counter));
+ container.registerFactory(new ClientTestProtocolFactory());
startTransport();
- IChannel channel = getConnector().openChannel(TestProtocolFactory.TYPE);
+ IChannel channel = getConnector().openChannel(ServerTestProtocolFactory.TYPE);
for (int i = 0; i < COUNT; i++)
{
IBuffer buffer = provideBuffer();
ByteBuffer byteBuffer = buffer.startPutting(channel.getChannelIndex());
byteBuffer.putInt(1970);
- channel.handleBuffer(buffer);
+ channel.sendBuffer(buffer);
+ Thread.sleep(500000);
}
assertTrue(counter.await(2, TimeUnit.SECONDS));
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestProtocol.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestProtocol.java
index ae1e624..98ee2aa 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestProtocol.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestProtocol.java
@@ -20,7 +20,7 @@ public final class TestProtocol extends Protocol
public String getType()
{
- return TestProtocolFactory.TYPE;
+ return ServerTestProtocolFactory.TYPE;
}
public void handleBuffer(IBuffer buffer)
diff --git a/plugins/org.eclipse.net4j.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j.ui/META-INF/MANIFEST.MF
index b9ef680..5d39969 100644
--- a/plugins/org.eclipse.net4j.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.net4j.ui/META-INF/MANIFEST.MF
@@ -6,6 +6,9 @@ Bundle-Version: 0.8.0.qualifier
Bundle-Activator: org.eclipse.net4j.internal.ui.bundle.Net4jUI$Activator
Bundle-Vendor: %providerName
Require-Bundle: org.eclipse.core.runtime,
- org.eclipse.ui,
- org.eclipse.net4j
+ org.eclipse.ui;visibility:=reexport,
+ org.eclipse.net4j;visibility:=reexport
Eclipse-LazyStart: true
+Export-Package: org.eclipse.net4j.internal.ui,
+ org.eclipse.net4j.internal.ui.bundle,
+ org.eclipse.net4j.internal.ui.views
diff --git a/plugins/org.eclipse.net4j.ui/icons/full/etool16/add.gif b/plugins/org.eclipse.net4j.ui/icons/full/etool16/add.gif
new file mode 100644
index 0000000..252d7eb
--- /dev/null
+++ b/plugins/org.eclipse.net4j.ui/icons/full/etool16/add.gif
Binary files differ
diff --git a/plugins/org.eclipse.net4j.ui/icons/full/etool16/add_acceptor.gif b/plugins/org.eclipse.net4j.ui/icons/full/etool16/add_acceptor.gif
new file mode 100644
index 0000000..5af19b1
--- /dev/null
+++ b/plugins/org.eclipse.net4j.ui/icons/full/etool16/add_acceptor.gif
Binary files differ
diff --git a/plugins/org.eclipse.net4j.ui/icons/full/etool16/add_connector.gif b/plugins/org.eclipse.net4j.ui/icons/full/etool16/add_connector.gif
new file mode 100644
index 0000000..8fbb69b
--- /dev/null
+++ b/plugins/org.eclipse.net4j.ui/icons/full/etool16/add_connector.gif
Binary files differ
diff --git a/plugins/org.eclipse.net4j.ui/icons/full/view16/acceptors.gif b/plugins/org.eclipse.net4j.ui/icons/full/view16/acceptors.gif
new file mode 100644
index 0000000..a830867
--- /dev/null
+++ b/plugins/org.eclipse.net4j.ui/icons/full/view16/acceptors.gif
Binary files differ
diff --git a/plugins/org.eclipse.net4j.ui/icons/full/view16/connectors.gif b/plugins/org.eclipse.net4j.ui/icons/full/view16/connectors.gif
new file mode 100644
index 0000000..3b3ad7c
--- /dev/null
+++ b/plugins/org.eclipse.net4j.ui/icons/full/view16/connectors.gif
Binary files differ
diff --git a/plugins/org.eclipse.net4j.ui/icons/plus.gif b/plugins/org.eclipse.net4j.ui/icons/plus.gif
new file mode 100644
index 0000000..571b553
--- /dev/null
+++ b/plugins/org.eclipse.net4j.ui/icons/plus.gif
Binary files differ
diff --git a/plugins/org.eclipse.net4j.ui/plugin.xml b/plugins/org.eclipse.net4j.ui/plugin.xml
index aaad7a3..5d1581d 100644
--- a/plugins/org.eclipse.net4j.ui/plugin.xml
+++ b/plugins/org.eclipse.net4j.ui/plugin.xml
@@ -11,10 +11,17 @@
</category>
<view
category="org.eclipse.net4j.ui"
- class="org.eclipse.net4j.internal.ui.views.Net4jExplorerView"
- icon="icons/sample.gif"
- id="org.eclipse.net4j.internal.ui.views.Net4jExplorerView"
- name="Net4j Explorer">
+ class="org.eclipse.net4j.internal.ui.views.AcceptorsView"
+ icon="icons/full/view16/acceptors.gif"
+ id="org.eclipse.net4j.internal.ui.views.AcceptorsView"
+ name="Acceptors">
+ </view>
+ <view
+ category="org.eclipse.net4j.ui"
+ class="org.eclipse.net4j.internal.ui.views.ConnectorsView"
+ icon="icons/full/view16/connectors.gif"
+ id="org.eclipse.net4j.internal.ui.views.ConnectorsView"
+ name="Connectors">
</view>
</extension>
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/ContainerItemProvider.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/ContainerItemProvider.java
new file mode 100644
index 0000000..115ffe4
--- /dev/null
+++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/ContainerItemProvider.java
@@ -0,0 +1,339 @@
+/***************************************************************************
+ * Copyright (c) 2004, 2005, 2006 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.internal.ui;
+
+import org.eclipse.net4j.util.container.IContainer;
+import org.eclipse.net4j.util.event.IListener;
+
+import org.eclipse.internal.net4j.util.container.ContainerEventAdapter;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public class ContainerItemProvider<CONTAINER extends IContainer> extends ItemProvider<CONTAINER>
+{
+ private Map<Object, Node> nodes = new HashMap();
+
+ private ContainerNode root;
+
+ private IElementFilter rootElementFilter;
+
+ public ContainerItemProvider()
+ {
+ }
+
+ public ContainerItemProvider(IElementFilter rootElementFilter)
+ {
+ this.rootElementFilter = rootElementFilter;
+ }
+
+ public IElementFilter getRootElementFilter()
+ {
+ return rootElementFilter;
+ }
+
+ @Override
+ public boolean hasChildren(Object element)
+ {
+ Node node = getNode(element);
+ return !node.getChildren().isEmpty();
+ }
+
+ public Object[] getChildren(Object element)
+ {
+ Node node = getNode(element);
+ List<Node> children = node.getChildren();
+ Object[] elements = new Object[children.size()];
+ for (int i = 0; i < elements.length; i++)
+ {
+ elements[i] = children.get(i).getElement();
+ }
+
+ return elements;
+ }
+
+ public Object getParent(Object element)
+ {
+ Node node = getNode(element);
+ Node parentNode = node.getParent();
+ return parentNode == null ? null : parentNode.getElement();
+ }
+
+ @Override
+ protected void connectInput(CONTAINER input)
+ {
+ root = (ContainerNode)createNode(null, input);
+ nodes.put(input, root);
+ }
+
+ @Override
+ protected void disconnectInput(CONTAINER input)
+ {
+ root.dispose();
+ root = null;
+ nodes.clear();
+ }
+
+ protected ContainerNode getRoot()
+ {
+ return root;
+ }
+
+ protected Map<Object, Node> getNodes()
+ {
+ return nodes;
+ }
+
+ protected Node getNode(Object element)
+ {
+ if (element == getInput())
+ {
+ return root;
+ }
+
+ Node node = nodes.get(element);
+ if (node == null)
+ {
+ throw new IllegalStateException("No node for " + element);
+ }
+
+ return node;
+ }
+
+ protected Node createNode(Node parent, Object element)
+ {
+ if (element instanceof IContainer)
+ {
+ return new ContainerNode(parent, (IContainer)element);
+ }
+
+ return new LeafNode(parent, element);
+ }
+
+ protected boolean filterRootElement(Object element)
+ {
+ if (rootElementFilter != null)
+ {
+ return rootElementFilter.filter(element);
+ }
+
+ return true;
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public interface Node
+ {
+ public void dispose();
+
+ public Object getElement();
+
+ public Node getParent();
+
+ public List<Node> getChildren();
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public abstract class AbstractNode implements Node
+ {
+ private Node parent;
+
+ private List<Node> children;
+
+ public AbstractNode(Node parent)
+ {
+ this.parent = parent;
+ }
+
+ public void dispose()
+ {
+ parent = null;
+ if (children != null)
+ {
+ for (Node child : children)
+ {
+ child.dispose();
+ }
+
+ children.clear();
+ children = null;
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ return getElement().toString();
+ }
+
+ public final Node getParent()
+ {
+ return parent;
+ }
+
+ public final List<Node> getChildren()
+ {
+ if (children == null)
+ {
+ children = createChildren();
+ }
+
+ return children;
+ }
+
+ protected abstract List<Node> createChildren();
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public class ContainerNode extends AbstractNode
+ {
+ private IContainer container;
+
+ private IListener containerListener = new ContainerEventAdapter()
+ {
+ @Override
+ protected void onAdded(IContainer container, Object element)
+ {
+ if (container == ContainerNode.this.container)
+ {
+ elementAdded(element);
+ }
+ }
+
+ @Override
+ protected void onRemoved(IContainer container, Object element)
+ {
+ if (container == ContainerNode.this.container)
+ {
+ elementRemoved(element);
+ }
+ }
+ };
+
+ public ContainerNode(Node parent, IContainer container)
+ {
+ super(parent);
+ this.container = container;
+ }
+
+ public void dispose()
+ {
+ container.removeListener(containerListener);
+ container = null;
+ super.dispose();
+ }
+
+ public IContainer getContainer()
+ {
+ return container;
+ }
+
+ public Object getElement()
+ {
+ return container;
+ }
+
+ @Override
+ protected List<Node> createChildren()
+ {
+ Object[] elements = container.getElements();
+ List<Node> children = new ArrayList(elements.length);
+ for (int i = 0; i < elements.length; i++)
+ {
+ Object element = elements[i];
+ addChild(children, element);
+ }
+
+ container.addListener(containerListener);
+ return children;
+ }
+
+ protected Node addChild(List<Node> children, Object element)
+ {
+ if (this != root || filterRootElement(element))
+ {
+ Node node = createNode(this, element);
+ nodes.put(element, node);
+ children.add(node);
+ return node;
+ }
+
+ return null;
+ }
+
+ protected void elementAdded(final Object element)
+ {
+ if (addChild(getChildren(), element) != null)
+ {
+ refreshElement(getElement(), false);
+ }
+ }
+
+ protected void elementRemoved(Object element)
+ {
+ Node node = nodes.remove(element);
+ if (node != null)
+ {
+ getChildren().remove(node);
+ node.dispose();
+ refreshElement(getElement(), false);
+ }
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public class LeafNode implements Node
+ {
+ private Node parent;
+
+ private Object element;
+
+ public LeafNode(Node parent, Object element)
+ {
+ this.parent = parent;
+ this.element = element;
+ }
+
+ public void dispose()
+ {
+ parent = null;
+ element = null;
+ }
+
+ public Node getParent()
+ {
+ return parent;
+ }
+
+ public Object getElement()
+ {
+ return element;
+ }
+
+ public List<Node> getChildren()
+ {
+ return Collections.EMPTY_LIST;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/Net4jExplorerNameSorter.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/ContainerNameSorter.java
index 881ab72..06892e8 100644
--- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/Net4jExplorerNameSorter.java
+++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/ContainerNameSorter.java
@@ -8,10 +8,10 @@
* Contributors:
* Eike Stepper - initial API and implementation
**************************************************************************/
-package org.eclipse.net4j.internal.ui.views;
+package org.eclipse.net4j.internal.ui;
import org.eclipse.jface.viewers.ViewerSorter;
-public class Net4jExplorerNameSorter extends ViewerSorter
+public class ContainerNameSorter extends ViewerSorter
{
} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/ContainerView.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/ContainerView.java
new file mode 100644
index 0000000..70e1ae8
--- /dev/null
+++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/ContainerView.java
@@ -0,0 +1,175 @@
+package org.eclipse.net4j.internal.ui;
+
+import org.eclipse.net4j.internal.ui.bundle.SharedIcons;
+import org.eclipse.net4j.transport.ITransportContainer;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.part.ViewPart;
+
+public abstract class ContainerView extends ViewPart
+{
+ private ContainerItemProvider itemProvider;
+
+ private TreeViewer viewer;
+
+ private Action doubleClickAction = new Action()
+ {
+ public void run()
+ {
+ ISelection selection = viewer.getSelection();
+ Object obj = ((IStructuredSelection)selection).getFirstElement();
+ showMessage("Double-click detected on " + obj.toString());
+ }
+ };
+
+ public ContainerView()
+ {
+ }
+
+ public void setFocus()
+ {
+ viewer.getControl().setFocus();
+ }
+
+ public void createPartControl(Composite parent)
+ {
+ itemProvider = createContainerItemProvider();
+ viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+ viewer.setContentProvider(itemProvider);
+ viewer.setLabelProvider(itemProvider);
+ viewer.setSorter(new ContainerNameSorter());
+ viewer.setInput(getContainer());
+
+ hookContextMenu();
+ hookDoubleClickAction();
+ contributeToActionBars();
+ }
+
+ protected ContainerItemProvider createContainerItemProvider()
+ {
+ return new ContainerItemProvider(getRootElementFilter())
+ {
+ @Override
+ public Image getImage(Object obj)
+ {
+ Image image = getElementImage(obj);
+ if (image == null)
+ {
+ image = super.getImage(obj);
+ }
+
+ return image;
+ }
+
+ @Override
+ public String getText(Object obj)
+ {
+ String text = getElementText(obj);
+ if (text == null)
+ {
+ text = super.getText(obj);
+ }
+
+ return text;
+ }
+ };
+ }
+
+ protected String getElementText(Object element)
+ {
+ return null;
+ }
+
+ protected Image getElementImage(Object element)
+ {
+ return null;
+ }
+
+ protected IElementFilter getRootElementFilter()
+ {
+ return null;
+ }
+
+ protected abstract ITransportContainer getContainer();
+
+ protected void hookContextMenu()
+ {
+ MenuManager menuMgr = new MenuManager("#PopupMenu");
+ menuMgr.setRemoveAllWhenShown(true);
+ menuMgr.addMenuListener(new IMenuListener()
+ {
+ public void menuAboutToShow(IMenuManager manager)
+ {
+ ContainerView.this.fillContextMenu(manager);
+ }
+ });
+
+ Menu menu = menuMgr.createContextMenu(viewer.getControl());
+ viewer.getControl().setMenu(menu);
+ getSite().registerContextMenu(menuMgr, viewer);
+ }
+
+ protected void contributeToActionBars()
+ {
+ IActionBars bars = getViewSite().getActionBars();
+ fillLocalPullDown(bars.getMenuManager());
+ fillLocalToolBar(bars.getToolBarManager());
+ }
+
+ protected void fillLocalPullDown(IMenuManager manager)
+ {
+ }
+
+ protected void fillContextMenu(IMenuManager manager)
+ {
+ manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ }
+
+ protected void fillLocalToolBar(IToolBarManager manager)
+ {
+ }
+
+ protected void hookDoubleClickAction()
+ {
+ viewer.addDoubleClickListener(new IDoubleClickListener()
+ {
+ public void doubleClick(DoubleClickEvent event)
+ {
+ doubleClickAction.run();
+ }
+ });
+ }
+
+ protected void showMessage(String message)
+ {
+ MessageDialog.openInformation(viewer.getControl().getShell(), getTitle(), message);
+ }
+
+ public static ImageDescriptor getAddImageDescriptor()
+ {
+ return SharedIcons.getDescriptor(SharedIcons.ETOOL_ADD);
+ }
+
+ public static ImageDescriptor getDeleteImageDescriptor()
+ {
+ return SharedIcons.getDescriptor(SharedIcons.ETOOL_DELETE);
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/IElementFilter.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/IElementFilter.java
new file mode 100644
index 0000000..6117a5f
--- /dev/null
+++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/IElementFilter.java
@@ -0,0 +1,19 @@
+/***************************************************************************
+ * Copyright (c) 2004, 2005, 2006 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.internal.ui;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IElementFilter
+{
+ public boolean filter(Object element);
+}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/ItemProvider.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/ItemProvider.java
index 359ddb5..044cb19 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/ItemProvider.java
+++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/ItemProvider.java
@@ -8,7 +8,7 @@
* Contributors:
* Eike Stepper - initial API and implementation
**************************************************************************/
-package org.eclipse.emf.cdo.internal.ui.views;
+package org.eclipse.net4j.internal.ui;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
@@ -57,20 +57,21 @@ public abstract class ItemProvider<INPUT> extends LabelProvider implements IStru
if (viewer instanceof StructuredViewer)
{
this.viewer = (StructuredViewer)viewer;
-
- if (input != null)
- {
- disconnectInput(input);
- }
-
- try
- {
- input = (INPUT)newInput;
- connectInput(input);
- }
- catch (Exception ex)
+ if (newInput != input)
{
- input = null;
+ if (input != null)
+ {
+ disconnectInput(input);
+ }
+ try
+ {
+ input = (INPUT)newInput;
+ connectInput(input);
+ }
+ catch (Exception ex)
+ {
+ input = null;
+ }
}
}
}
@@ -111,13 +112,13 @@ public abstract class ItemProvider<INPUT> extends LabelProvider implements IStru
protected void refreshElement(final Object element, final boolean updateLabels)
{
- if (isViewerActive())
+ try
{
getDisplay().asyncExec(new Runnable()
{
public void run()
{
- if (isViewerActive())
+ try
{
if (element != null)
{
@@ -128,12 +129,19 @@ public abstract class ItemProvider<INPUT> extends LabelProvider implements IStru
viewer.refresh(updateLabels);
}
}
+ catch (Exception ignore)
+ {
+ ignore.printStackTrace();
+ }
}
});
}
+ catch (Exception ignore)
+ {
+ }
}
- private Display getDisplay()
+ protected Display getDisplay()
{
Display display = viewer.getControl().getDisplay();
if (display == null)
@@ -153,9 +161,4 @@ public abstract class ItemProvider<INPUT> extends LabelProvider implements IStru
return display;
}
-
- private boolean isViewerActive()
- {
- return viewer != null && viewer.getControl() != null && !viewer.getControl().isDisposed();
- }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/ManagedContainerItemProvider.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/ManagedContainerItemProvider.java
new file mode 100644
index 0000000..2293c42
--- /dev/null
+++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/ManagedContainerItemProvider.java
@@ -0,0 +1,173 @@
+/***************************************************************************
+ * Copyright (c) 2004, 2005, 2006 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.internal.ui;
+
+import org.eclipse.net4j.util.container.IManagedContainer;
+
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+@Deprecated
+public class ManagedContainerItemProvider<CONTAINER extends IManagedContainer> extends ContainerItemProvider<CONTAINER>
+{
+ private boolean showProductGroups = true;
+
+ private boolean showFactoryTypes = false;
+
+ public ManagedContainerItemProvider()
+ {
+ }
+
+ public boolean isShowProductGroups()
+ {
+ return showProductGroups;
+ }
+
+ public void setShowProductGroups(boolean showProductGroups)
+ {
+ this.showProductGroups = showProductGroups;
+ }
+
+ public boolean isShowFactoryTypes()
+ {
+ return showFactoryTypes;
+ }
+
+ public void setShowFactoryTypes(boolean showFactoryTypes)
+ {
+ this.showFactoryTypes = showFactoryTypes;
+ }
+
+ @Override
+ protected Node createNode(Node parent, Object element)
+ {
+ if (element instanceof IManagedContainer)
+ {
+ return new ManagedContainerNode(parent, (IManagedContainer)element);
+ }
+
+ return super.createNode(parent, element);
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public class ManagedContainerNode extends ContainerNode
+ {
+ public ManagedContainerNode(Node parent, IManagedContainer container)
+ {
+ super(parent, container);
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public class ProductGroupNode extends AbstractNode
+ {
+ private String productGroup;
+
+ public ProductGroupNode(ContainerNode parent, String productGroup)
+ {
+ super(parent);
+ this.productGroup = productGroup;
+ }
+
+ public String getProductGroup()
+ {
+ return productGroup;
+ }
+
+ public IManagedContainer getContainer()
+ {
+ ContainerNode parent = (ContainerNode)getParent();
+ return (IManagedContainer)parent.getContainer();
+ }
+
+ public Object getElement()
+ {
+ return this;
+ }
+
+ @Override
+ protected List<Node> createChildren()
+ {
+ return null;
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public class FactoryTypeNode extends AbstractNode
+ {
+ private String factoryType;
+
+ public FactoryTypeNode(ProductGroupNode parent, String factoryType)
+ {
+ super(parent);
+ this.factoryType = factoryType;
+ }
+
+ public ProductGroupNode getProductGroupNode()
+ {
+ return (ProductGroupNode)getParent();
+ }
+
+ public String getFactoryType()
+ {
+ return factoryType;
+ }
+
+ public IManagedContainer getContainer()
+ {
+ return getProductGroupNode().getContainer();
+ }
+
+ public Object getElement()
+ {
+ return this;
+ }
+
+ @Override
+ protected List<Node> createChildren()
+ {
+ return null;
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public class ProductGroupFactoryTypeNode extends ProductGroupNode
+ {
+ private String factoryType;
+
+ public ProductGroupFactoryTypeNode(ContainerNode parent, String productGroup, String factoryType)
+ {
+ super(parent, productGroup);
+ this.factoryType = factoryType;
+ }
+
+ public String getFactoryType()
+ {
+ return factoryType;
+ }
+
+ @Override
+ protected List<Node> createChildren()
+ {
+ return null;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/SafeAction.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/SafeAction.java
new file mode 100644
index 0000000..4591bd8
--- /dev/null
+++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/SafeAction.java
@@ -0,0 +1,46 @@
+package org.eclipse.net4j.internal.ui;
+
+import org.eclipse.net4j.internal.ui.bundle.Net4jUI;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class SafeAction extends Action
+{
+ public SafeAction()
+ {
+ }
+
+ public SafeAction(String text, String toolTipText, ImageDescriptor image)
+ {
+ super(text, image);
+ setToolTipText(toolTipText);
+ }
+
+ public SafeAction(String text, int style)
+ {
+ super(text, style);
+ }
+
+ public SafeAction(String text)
+ {
+ super(text);
+ }
+
+ public void run()
+ {
+ try
+ {
+ doRun();
+ }
+ catch (Exception ex)
+ {
+ Net4jUI.LOG.error(ex);
+ }
+ }
+
+ protected abstract void doRun() throws Exception;
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/StructuredView.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/StructuredView.java
index 9aa254b..7cb77c0 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/StructuredView.java
+++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/StructuredView.java
@@ -1,4 +1,4 @@
-package org.eclipse.emf.cdo.internal.ui.views;
+package org.eclipse.net4j.internal.ui;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IContributionItem;
@@ -22,6 +22,7 @@ import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.part.ViewPart;
+@Deprecated
public abstract class StructuredView extends ViewPart
{
public StructuredView()
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/bundle/SharedIcons.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/bundle/SharedIcons.java
index 695a1af..c52a789 100644
--- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/bundle/SharedIcons.java
+++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/bundle/SharedIcons.java
@@ -23,36 +23,61 @@ public class SharedIcons
{
private static final ImageRegistry REGISTRY = new ImageRegistry(getDisplay());
- private static final String OBJ = "icons/full/obj16/";
+ private static final String ETOOL = "etool16/";
- public static final ImageDescriptor OBJ_ACCEPTOR = getDescriptor(OBJ + "acceptor.gif");
+ private static final String OBJ = "obj16/";
- public static final ImageDescriptor OBJ_ADAPTER = getDescriptor(OBJ + "adapter.gif");
+ public static final String OBJ_ACCEPTOR = OBJ + "acceptor";
- public static final ImageDescriptor OBJ_CHANNEL = getDescriptor(OBJ + "channel.gif");
+ public static final String OBJ_ADAPTER = OBJ + "adapter";
- public static final ImageDescriptor OBJ_CONNECTOR = getDescriptor(OBJ + "connector.gif");
+ public static final String OBJ_CHANNEL = OBJ + "channel";
- public static final ImageDescriptor OBJ_FACTORY = getDescriptor(OBJ + "factory.gif");
+ public static final String OBJ_CONNECTOR = OBJ + "connector";
- public static final ImageDescriptor OBJ_FOLDER = getDescriptor(OBJ + "folder.gif");
+ public static final String OBJ_FACTORY = OBJ + "factory";
+
+ public static final String OBJ_FOLDER = OBJ + "folder";
+
+ public static final String ETOOL_ADD_ACCEPTOR = ETOOL + "add_acceptor";
+
+ public static final String ETOOL_ADD_CONNECTOR = ETOOL + "add_connector";
+
+ public static final String ETOOL_ADD = ETOOL + "add";
+
+ public static final String ETOOL_DELETE = ETOOL + "delete";
public static Image getImage(String key)
{
- ImageDescriptor descriptor = getDescriptor(key);
- return descriptor.createImage();
+ key = mangleKey(key);
+ Image image = REGISTRY.get(key);
+ if (image == null)
+ {
+ createDescriptor(key);
+ image = REGISTRY.get(key);
+ }
+
+ return image;
}
public static ImageDescriptor getDescriptor(String key)
{
+ key = mangleKey(key);
ImageDescriptor descriptor = REGISTRY.getDescriptor(key);
if (descriptor == null)
{
- descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(Net4jUI.BUNDLE_ID, key);
- if (descriptor != null)
- {
- REGISTRY.put(key, descriptor);
- }
+ descriptor = createDescriptor(key);
+ }
+
+ return descriptor;
+ }
+
+ private static ImageDescriptor createDescriptor(String key)
+ {
+ ImageDescriptor descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(Net4jUI.BUNDLE_ID, key);
+ if (descriptor != null)
+ {
+ REGISTRY.put(key, descriptor);
}
return descriptor;
@@ -73,4 +98,9 @@ public class SharedIcons
return display;
}
+
+ private static String mangleKey(String key)
+ {
+ return "icons/full/" + key + ".gif";
+ }
}
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/AcceptorsItemProvider.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/AcceptorsItemProvider.java
deleted file mode 100644
index e4a0fde..0000000
--- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/AcceptorsItemProvider.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/***************************************************************************
- * 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.internal.ui.views;
-
-import org.eclipse.net4j.internal.ui.bundle.SharedIcons;
-import org.eclipse.net4j.transport.IAcceptor;
-import org.eclipse.net4j.transport.IBufferHandler;
-import org.eclipse.net4j.transport.IChannel;
-import org.eclipse.net4j.transport.IConnector;
-import org.eclipse.net4j.transport.IProtocol;
-import org.eclipse.net4j.util.event.IEvent;
-import org.eclipse.net4j.util.event.IListener;
-import org.eclipse.net4j.util.registry.IRegistryEvent;
-
-import org.eclipse.swt.graphics.Image;
-
-import java.text.MessageFormat;
-import java.util.Collection;
-
-public class AcceptorsItemProvider extends ItemProvider<Container> implements IRegistryListener, IListener
-{
- public AcceptorsItemProvider()
- {
- }
-
- public Object getParent(Object child)
- {
- if (child instanceof IAcceptor)
- {
- return getInput();
- }
-
- if (child instanceof IConnector)
- {
- IConnector connector = (IConnector)child;
- Collection<IAcceptor> acceptors = getInput().getAcceptorRegistry().values();
- for (IAcceptor acceptor : acceptors)
- {
- IConnector[] connectors = acceptor.getAcceptedConnectors();
- for (IConnector c : connectors)
- {
- if (c == connector)
- {
- return acceptor;
- }
- }
- }
- }
-
- if (child instanceof IChannel)
- {
- return ((IChannel)child).getConnector();
- }
-
- return null;
- }
-
- public Object[] getChildren(Object parent)
- {
- if (parent == getInput())
- {
- Collection values = getInput().getAcceptorRegistry().values();
- return values.toArray(new Object[values.size()]);
- }
-
- if (parent instanceof IAcceptor)
- {
- IAcceptor acceptor = (IAcceptor)parent;
- return acceptor.getAcceptedConnectors();
- }
-
- if (parent instanceof IConnector)
- {
- return ((IConnector)parent).getChannels();
- }
-
- return NO_CHILDREN;
- }
-
- public void notifyRegistryEvent(IRegistryEvent event)
- {
- refreshViewer(false);
-
- IRegistryDelta[] deltas = event.getDeltas();
- for (IRegistryDelta delta : deltas)
- {
- if (delta.getElement() instanceof IAcceptor)
- {
- IAcceptor acceptor = (IAcceptor)delta.getElement();
- switch (delta.getKind())
- {
- case REGISTERED:
- acceptor.addListener(this);
- break;
-
- case DEREGISTERED:
- acceptor.removeListener(this);
- break;
- }
- }
- }
- }
-
- public void notifyEvent(IEvent event)
- {
- refreshViewer(false);
- }
-
- @Override
- public String getText(Object obj)
- {
- if (obj instanceof IAcceptor)
- {
- IAcceptor acceptor = (IAcceptor)obj;
- return acceptor.getDescription();
- }
-
- if (obj instanceof IConnector)
- {
- IConnector connector = (IConnector)obj;
- return connector.getDescription();
- }
-
- if (obj instanceof IChannel)
- {
- IChannel channel = (IChannel)obj;
- IBufferHandler receiveHandler = channel.getReceiveHandler();
- Object str = receiveHandler instanceof IProtocol ? ((IProtocol)receiveHandler).getProtocolID() : receiveHandler;
- return MessageFormat.format("[{0}] {1}", channel.getChannelIndex(), str);
- }
-
- return super.getText(obj);
- }
-
- @Override
- public Image getImage(Object obj)
- {
- if (obj instanceof IAcceptor)
- {
- return SharedIcons.OBJ_ACCEPTOR.createImage();
- }
-
- if (obj instanceof IConnector)
- {
- return SharedIcons.OBJ_CONNECTOR.createImage();
- }
-
- if (obj instanceof IChannel)
- {
- return SharedIcons.OBJ_CHANNEL.createImage();
- }
-
- return null;
- }
-
- @Override
- protected void connectInput(Container input)
- {
- input.getAcceptorRegistry().addRegistryListener(this);
- input.getConnectorRegistry().addRegistryListener(this);
- input.getChannelRegistry().addRegistryListener(this);
- }
-
- @Override
- protected void disconnectInput(Container input)
- {
- input.getAcceptorRegistry().removeRegistryListener(this);
- input.getConnectorRegistry().removeRegistryListener(this);
- input.getChannelRegistry().removeRegistryListener(this);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/AcceptorsView.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/AcceptorsView.java
new file mode 100644
index 0000000..754c991
--- /dev/null
+++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/AcceptorsView.java
@@ -0,0 +1,53 @@
+package org.eclipse.net4j.internal.ui.views;
+
+import org.eclipse.net4j.internal.ui.ContainerItemProvider;
+import org.eclipse.net4j.internal.ui.ContainerView;
+import org.eclipse.net4j.internal.ui.IElementFilter;
+import org.eclipse.net4j.internal.ui.SafeAction;
+import org.eclipse.net4j.transport.IAcceptor;
+import org.eclipse.net4j.transport.IPluginTransportContainer;
+import org.eclipse.net4j.transport.ITransportContainer;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IToolBarManager;
+
+public class AcceptorsView extends ContainerView
+{
+ private Action addAcceptorAction = new SafeAction("Add Acceptor", "Add an acceptor", getAddImageDescriptor())
+ {
+ @Override
+ protected void doRun() throws Exception
+ {
+ IPluginTransportContainer.INSTANCE.getAcceptor("tcp", "0.0.0.0:2036");
+ }
+ };
+
+ public AcceptorsView()
+ {
+ }
+
+ @Override
+ protected ITransportContainer getContainer()
+ {
+ return IPluginTransportContainer.INSTANCE;
+ }
+
+ @Override
+ protected ContainerItemProvider createContainerItemProvider()
+ {
+ return new Net4jItemProvider(new IElementFilter()
+ {
+ public boolean filter(Object element)
+ {
+ return element instanceof IAcceptor;
+ }
+ });
+ }
+
+ @Override
+ protected void fillLocalToolBar(IToolBarManager manager)
+ {
+ manager.add(addAcceptorAction);
+ super.fillLocalToolBar(manager);
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/AdaptersItemProvider.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/AdaptersItemProvider.java
deleted file mode 100644
index 6097e77..0000000
--- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/AdaptersItemProvider.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/***************************************************************************
- * 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.internal.ui.views;
-
-import org.eclipse.net4j.internal.ui.bundle.SharedIcons;
-import org.eclipse.net4j.util.registry.IRegistryEvent;
-
-import org.eclipse.swt.graphics.Image;
-
-import java.text.MessageFormat;
-import java.util.Collection;
-
-public class AdaptersItemProvider extends ItemProvider<Container> implements IRegistryListener
-{
- public AdaptersItemProvider()
- {
- }
-
- public Object getParent(Object child)
- {
- if (child instanceof ContainerAdapterFactory)
- {
- return getInput();
- }
-
- return null;
- }
-
- public Object[] getChildren(Object parent)
- {
- if (parent == getInput())
- {
- Collection values = getInput().getAdapterFactoryRegistry().values();
- return values.toArray(new Object[values.size()]);
- }
-
- return NO_CHILDREN;
- }
-
- public void notifyRegistryEvent(IRegistryEvent event)
- {
- refreshViewer(false);
- }
-
- @Override
- public String getText(Object obj)
- {
- ContainerAdapterFactory factory = (ContainerAdapterFactory)obj;
- return MessageFormat.format("{0} ({1})", factory.getType(), factory.getClass().getName());
- }
-
- @Override
- public Image getImage(Object obj)
- {
- return SharedIcons.OBJ_ADAPTER.createImage();
- }
-
- @Override
- protected void connectInput(Container input)
- {
- input.getAdapterFactoryRegistry().addRegistryListener(this);
- }
-
- @Override
- protected void disconnectInput(Container input)
- {
- input.getAdapterFactoryRegistry().removeRegistryListener(this);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/ConnectorsItemProvider.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/ConnectorsItemProvider.java
deleted file mode 100644
index b7ab5f1..0000000
--- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/ConnectorsItemProvider.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/***************************************************************************
- * 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.internal.ui.views;
-
-import org.eclipse.net4j.internal.ui.bundle.SharedIcons;
-import org.eclipse.net4j.transport.IBufferHandler;
-import org.eclipse.net4j.transport.IChannel;
-import org.eclipse.net4j.transport.IConnector;
-import org.eclipse.net4j.transport.IProtocol;
-import org.eclipse.net4j.util.registry.IRegistryEvent;
-
-import org.eclipse.swt.graphics.Image;
-
-import java.text.MessageFormat;
-import java.util.Collection;
-
-public class ConnectorsItemProvider extends ItemProvider<Container> implements IRegistryListener
-{
- public ConnectorsItemProvider()
- {
- }
-
- public Object getParent(Object child)
- {
- if (child instanceof IConnector)
- {
- return getInput();
- }
-
- if (child instanceof IChannel)
- {
- return ((IChannel)child).getConnector();
- }
-
- return null;
- }
-
- public Object[] getChildren(Object parent)
- {
- if (parent == getInput())
- {
- Collection values = getInput().getConnectorRegistry().values();
- return values.toArray(new Object[values.size()]);
- }
-
- if (parent instanceof IConnector)
- {
- return ((IConnector)parent).getChannels();
- }
-
- return NO_CHILDREN;
- }
-
- public void notifyRegistryEvent(IRegistryEvent event)
- {
- refreshViewer(false);
- }
-
- @Override
- public String getText(Object obj)
- {
- if (obj instanceof IConnector)
- {
- IConnector connector = (IConnector)obj;
- return connector.getDescription();
- }
-
- if (obj instanceof IChannel)
- {
- IChannel channel = (IChannel)obj;
- IBufferHandler receiveHandler = channel.getReceiveHandler();
- Object str = receiveHandler instanceof IProtocol ? ((IProtocol)receiveHandler).getProtocolID() : receiveHandler;
- return MessageFormat.format("[{0}] {1}", channel.getChannelIndex(), str);
- }
-
- return super.getText(obj);
- }
-
- @Override
- public Image getImage(Object obj)
- {
- if (obj instanceof IConnector)
- {
- return SharedIcons.OBJ_CONNECTOR.createImage();
- }
-
- if (obj instanceof IChannel)
- {
- return SharedIcons.OBJ_CHANNEL.createImage();
- }
-
- return null;
- }
-
- @Override
- protected void connectInput(Container input)
- {
- input.getConnectorRegistry().addRegistryListener(this);
- input.getChannelRegistry().addRegistryListener(this);
- }
-
- @Override
- protected void disconnectInput(Container input)
- {
- input.getConnectorRegistry().removeRegistryListener(this);
- input.getChannelRegistry().removeRegistryListener(this);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/ConnectorsView.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/ConnectorsView.java
new file mode 100644
index 0000000..3d42d7f
--- /dev/null
+++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/ConnectorsView.java
@@ -0,0 +1,53 @@
+package org.eclipse.net4j.internal.ui.views;
+
+import org.eclipse.net4j.internal.ui.ContainerItemProvider;
+import org.eclipse.net4j.internal.ui.ContainerView;
+import org.eclipse.net4j.internal.ui.IElementFilter;
+import org.eclipse.net4j.internal.ui.SafeAction;
+import org.eclipse.net4j.transport.IConnector;
+import org.eclipse.net4j.transport.IPluginTransportContainer;
+import org.eclipse.net4j.transport.ITransportContainer;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IToolBarManager;
+
+public class ConnectorsView extends ContainerView
+{
+ private Action addConnectorAction = new SafeAction("Add Connector", "Add a connector", getAddImageDescriptor())
+ {
+ @Override
+ protected void doRun() throws Exception
+ {
+ IPluginTransportContainer.INSTANCE.getConnector("tcp", "127.0.0.1:2036");
+ }
+ };
+
+ public ConnectorsView()
+ {
+ }
+
+ @Override
+ protected ITransportContainer getContainer()
+ {
+ return IPluginTransportContainer.INSTANCE;
+ }
+
+ @Override
+ protected ContainerItemProvider createContainerItemProvider()
+ {
+ return new Net4jItemProvider(new IElementFilter()
+ {
+ public boolean filter(Object element)
+ {
+ return element instanceof IConnector;
+ }
+ });
+ }
+
+ @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.ui/src/org/eclipse/net4j/internal/ui/views/FactoriesItemProvider.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/FactoriesItemProvider.java
deleted file mode 100644
index 3d6757e..0000000
--- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/FactoriesItemProvider.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/***************************************************************************
- * 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.internal.ui.views;
-
-import org.eclipse.net4j.internal.ui.bundle.SharedIcons;
-import org.eclipse.net4j.util.registry.IRegistry;
-import org.eclipse.net4j.util.registry.IRegistryEvent;
-
-import org.eclipse.swt.graphics.Image;
-
-import java.text.MessageFormat;
-import java.util.Collection;
-
-public class FactoriesItemProvider extends ItemProvider<Container> implements IRegistryListener
-{
- private IRegistry[] registries = new IRegistry[3];
-
- public FactoriesItemProvider()
- {
- }
-
- public Object getParent(Object child)
- {
- if (child instanceof IRegistry)
- {
- return getInput();
- }
-
- if (child instanceof IAcceptorFactory)
- {
- return registries[1];
- }
-
- if (child instanceof IConnectorFactory)
- {
- return registries[2];
- }
-
- if (child instanceof IProtocolFactory)
- {
- return registries[3];
- }
-
- return null;
- }
-
- public Object[] getChildren(Object parent)
- {
- if (parent == getInput())
- {
- return registries;
- }
-
- if (parent instanceof IRegistry)
- {
- Collection values = ((IRegistry)parent).values();
- return values.toArray(new Object[values.size()]);
- }
-
- return NO_CHILDREN;
- }
-
- public void notifyRegistryEvent(IRegistryEvent event)
- {
- refreshViewer(false);
- }
-
- @Override
- public String getText(Object obj)
- {
- if (obj == getInput().getAcceptorFactoryRegistry())
- {
- return "Acceptor Factories";
- }
-
- if (obj == getInput().getConnectorFactoryRegistry())
- {
- return "Connector Factories";
- }
-
- if (obj == getInput().getProtocolFactoryRegistry())
- {
- return "Protocol Factories";
- }
-
- if (obj instanceof IAcceptorFactory)
- {
- IAcceptorFactory factory = (IAcceptorFactory)obj;
- return MessageFormat.format("{0} = {1}", factory.getType(), factory.getClass().getName());
- }
-
- if (obj instanceof IConnectorFactory)
- {
- IConnectorFactory factory = (IConnectorFactory)obj;
- return MessageFormat.format("{0} = {1}", factory.getType(), factory.getClass().getName());
- }
-
- if (obj instanceof IProtocolFactory)
- {
- IProtocolFactory factory = (IProtocolFactory)obj;
- return MessageFormat.format("{0} {1} = {2}", factory.getProtocolID(), factory.getLocations(), factory.getClass()
- .getName());
- }
-
- return super.getText(obj);
- }
-
- @Override
- public Image getImage(Object obj)
- {
- if (obj instanceof IRegistry)
- {
- return SharedIcons.OBJ_FOLDER.createImage();
- }
-
- return SharedIcons.OBJ_FACTORY.createImage();
- }
-
- @Override
- protected void connectInput(Container input)
- {
- registries[0] = input.getAcceptorFactoryRegistry();
- registries[0].addRegistryListener(this);
- registries[1] = input.getConnectorFactoryRegistry();
- registries[1].addRegistryListener(this);
- registries[2] = input.getProtocolFactoryRegistry();
- registries[2].addRegistryListener(this);
- }
-
- @Override
- protected void disconnectInput(Container input)
- {
- for (int i = 0; i < registries.length; i++)
- {
- registries[i].removeRegistryListener(this);
- registries[i] = null;
- }
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/ItemProvider.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/ItemProvider.java
deleted file mode 100644
index 819bb9c..0000000
--- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/ItemProvider.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/***************************************************************************
- * 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.internal.ui.views;
-
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
-
-public abstract class ItemProvider<INPUT> extends LabelProvider implements IStructuredContentProvider,
- ITreeContentProvider
-{
- protected static final Object[] NO_CHILDREN = new Object[0];
-
- private StructuredViewer viewer;
-
- private INPUT input;
-
- public ItemProvider()
- {
- }
-
- public void dispose()
- {
- if (input != null)
- {
- disconnectInput(input);
- input = null;
- }
- }
-
- public StructuredViewer getViewer()
- {
- return viewer;
- }
-
- public INPUT getInput()
- {
- return input;
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
- {
- if (viewer instanceof StructuredViewer)
- {
- this.viewer = (StructuredViewer)viewer;
-
- if (input != null)
- {
- disconnectInput(input);
- }
-
- try
- {
- input = (INPUT)newInput;
- connectInput(input);
- }
- catch (Exception ex)
- {
- input = null;
- }
- }
- }
-
- public Object[] getElements(Object parent)
- {
- return getChildren(parent);
- }
-
- public boolean hasChildren(Object parent)
- {
- return getChildren(parent).length != 0;
- }
-
- public String getText(Object obj)
- {
- return obj.toString();
- }
-
- public Image getImage(Object obj)
- {
- String imageKey = ISharedImages.IMG_OBJ_ELEMENT;
- return PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
- }
-
- protected void connectInput(INPUT input)
- {
- }
-
- protected void disconnectInput(INPUT input)
- {
- }
-
- protected void refreshViewer(boolean updateLabels)
- {
- refreshElement(null, updateLabels);
- }
-
- protected void refreshElement(final Object element, final boolean updateLabels)
- {
- if (isViewerActive())
- {
- getDisplay().asyncExec(new Runnable()
- {
- public void run()
- {
- if (isViewerActive())
- {
- if (element != null)
- {
- viewer.refresh(element, updateLabels);
- }
- else
- {
- viewer.refresh(updateLabels);
- }
- }
- }
- });
- }
- }
-
- private Display getDisplay()
- {
- Display display = viewer.getControl().getDisplay();
- if (display == null)
- {
- display = Display.getCurrent();
- }
-
- if (display == null)
- {
- display = Display.getDefault();
- }
-
- if (display == null)
- {
- throw new IllegalStateException("display == null");
- }
-
- return display;
- }
-
- private boolean isViewerActive()
- {
- return viewer != null && viewer.getControl() != null && !viewer.getControl().isDisposed();
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/Net4jExplorerView.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/Net4jExplorerView.java
deleted file mode 100644
index 4d86bd9..0000000
--- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/Net4jExplorerView.java
+++ /dev/null
@@ -1,230 +0,0 @@
-package org.eclipse.net4j.internal.ui.views;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.TabFolder;
-import org.eclipse.swt.widgets.TabItem;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.ViewPart;
-
-public class Net4jExplorerView extends ViewPart
-{
- private static final String[] TAB_LABELS = { "Connectors", "Acceptors", "Factories", "Adapters" };
-
- private static final boolean[] WITH_TREE = { true, true, true, false };
-
- private static final ItemProvider[] ITEM_PROVIDERS = { new ConnectorsItemProvider(), new AcceptorsItemProvider(),
- new FactoriesItemProvider(), new AdaptersItemProvider() };
-
- private TabFolder tabFolder;
-
- private Control[] tabControls = new Control[TAB_LABELS.length];
-
- private StructuredViewer[] viewers = new StructuredViewer[TAB_LABELS.length];
-
- // private DrillDownAdapter drillDownAdapter;
-
- private Action addConnectorAction;
-
- private Action addAcceptorAction;
-
- private Action doubleClickAction;
-
- public Net4jExplorerView()
- {
- }
-
- public void createPartControl(Composite parent)
- {
- tabFolder = new TabFolder(parent, SWT.NULL);
- for (int i = 0; i < TAB_LABELS.length; i++)
- {
- tabControls[0] = createTabControl(tabFolder, i, TAB_LABELS[i]);
- }
-
- makeActions();
- hookContextMenu();
- hookDoubleClickAction();
- contributeToActionBars();
- }
-
- private Control createTabControl(TabFolder parent, int index, String label)
- {
- viewers[index] = createViewer(parent, index);
- Control control = viewers[index].getControl();
- control.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- final TabItem factoryTab = new TabItem(tabFolder, SWT.NULL);
- factoryTab.setText(label);
- factoryTab.setControl(control);
- return control;
- }
-
- private StructuredViewer createViewer(Composite parent, int index)
- {
- int style = SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL;
- StructuredViewer viewer = WITH_TREE[index] ? new TreeViewer(parent, style) : new TableViewer(parent, style);
-
- // drillDownAdapter = new DrillDownAdapter(viewer);
- viewer.setContentProvider(ITEM_PROVIDERS[index]);
- viewer.setLabelProvider(ITEM_PROVIDERS[index]);
- viewer.setSorter(new Net4jExplorerNameSorter());
- viewer.setInput(ContainerManager.INSTANCE.getContainer());
- return viewer;
- }
-
- private void hookContextMenu()
- {
- MenuManager menuMgr = new MenuManager("#PopupMenu");
- menuMgr.setRemoveAllWhenShown(true);
- menuMgr.addMenuListener(new IMenuListener()
- {
- public void menuAboutToShow(IMenuManager manager)
- {
- Net4jExplorerView.this.fillContextMenu(manager);
- }
- });
- Menu menu = menuMgr.createContextMenu(getCurrentViewer().getControl());
- getCurrentViewer().getControl().setMenu(menu);
- getSite().registerContextMenu(menuMgr, getCurrentViewer());
- }
-
- private StructuredViewer getCurrentViewer()
- {
- int index = tabFolder.getSelectionIndex();
- return viewers[index];
- }
-
- private void contributeToActionBars()
- {
- IActionBars bars = getViewSite().getActionBars();
- fillLocalPullDown(bars.getMenuManager());
- fillLocalToolBar(bars.getToolBarManager());
- }
-
- private void fillLocalPullDown(IMenuManager manager)
- {
- manager.add(addConnectorAction);
- manager.add(addAcceptorAction);
- // manager.add(new Separator());
- // manager.add(action2);
- }
-
- private void fillContextMenu(IMenuManager manager)
- {
- // manager.add(action2);
- // manager.add(new Separator());
- // drillDownAdapter.addNavigationActions(manager);
-
- // Other plug-ins can contribute there actions here
- manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
- }
-
- private void fillLocalToolBar(IToolBarManager manager)
- {
- manager.add(addConnectorAction);
- manager.add(addAcceptorAction);
- // manager.add(action2);
- // manager.add(new Separator());
- // drillDownAdapter.addNavigationActions(manager);
- }
-
- private void makeActions()
- {
- addConnectorAction = new Action()
- {
- public void run()
- {
- InputDialog dialog = new InputDialog(getCurrentViewer().getControl().getShell(), "Net4j Explorer",
- "Enter a connector description:", null, null);
- if (dialog.open() == InputDialog.OK)
- {
- String description = dialog.getValue();
- Object object = ContainerManager.INSTANCE.getContainer().getConnector(description);
- if (object == null)
- {
- showMessage("Error while creating connector for description" + description);
- }
- }
- }
- };
- addConnectorAction.setText("Add Connector");
- addConnectorAction.setToolTipText("Add a connector");
- addConnectorAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(
- ISharedImages.IMG_TOOL_NEW_WIZARD));
-
- addAcceptorAction = new Action()
- {
- public void run()
- {
- InputDialog dialog = new InputDialog(getCurrentViewer().getControl().getShell(), "Net4j Explorer",
- "Enter an acceptor description:", null, null);
- if (dialog.open() == InputDialog.OK)
- {
- String description = dialog.getValue();
- Object object = ContainerManager.INSTANCE.getContainer().getAcceptor(description);
- if (object == null)
- {
- showMessage("Error while creating acceptor for description" + description);
- }
- }
- }
- };
- addAcceptorAction.setText("Add Acceptor");
- addAcceptorAction.setToolTipText("Add an acceptor");
- addAcceptorAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(
- ISharedImages.IMG_TOOL_NEW_WIZARD));
-
- doubleClickAction = new Action()
- {
- public void run()
- {
- ISelection selection = getCurrentViewer().getSelection();
- Object obj = ((IStructuredSelection)selection).getFirstElement();
- showMessage("Double-click detected on " + obj.toString());
- }
- };
- }
-
- private void hookDoubleClickAction()
- {
- getCurrentViewer().addDoubleClickListener(new IDoubleClickListener()
- {
- public void doubleClick(DoubleClickEvent event)
- {
- doubleClickAction.run();
- }
- });
- }
-
- private void showMessage(String message)
- {
- MessageDialog.openInformation(getCurrentViewer().getControl().getShell(), "Net4j Explorer", message);
- }
-
- public void setFocus()
- {
- getCurrentViewer().getControl().setFocus();
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/Net4jItemProvider.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/Net4jItemProvider.java
new file mode 100644
index 0000000..3d423ae
--- /dev/null
+++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/Net4jItemProvider.java
@@ -0,0 +1,69 @@
+/***************************************************************************
+ * Copyright (c) 2004, 2005, 2006 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.internal.ui.views;
+
+import org.eclipse.net4j.internal.ui.ContainerItemProvider;
+import org.eclipse.net4j.internal.ui.IElementFilter;
+import org.eclipse.net4j.internal.ui.bundle.SharedIcons;
+import org.eclipse.net4j.transport.IAcceptor;
+import org.eclipse.net4j.transport.IChannel;
+import org.eclipse.net4j.transport.IConnector;
+
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @author Eike Stepper
+ */
+public class Net4jItemProvider extends ContainerItemProvider
+{
+ public Net4jItemProvider()
+ {
+ }
+
+ public Net4jItemProvider(IElementFilter rootElementFilter)
+ {
+ super(rootElementFilter);
+ }
+
+ // @Override
+ // public String getText(Object obj)
+ // {
+ // if (obj instanceof IChannel)
+ // {
+ // IChannel channel = (IChannel)obj;
+ // return MessageFormat.format("[{0}] {1}", channel.getChannelIndex(),
+ // channel.getReceiveHandler());
+ // }
+ //
+ // return super.getText(obj);
+ // }
+
+ @Override
+ public Image getImage(Object obj)
+ {
+ if (obj instanceof IAcceptor)
+ {
+ return SharedIcons.getImage(SharedIcons.OBJ_ACCEPTOR);
+ }
+
+ if (obj instanceof IConnector)
+ {
+ return SharedIcons.getImage(SharedIcons.OBJ_CONNECTOR);
+ }
+
+ if (obj instanceof IChannel)
+ {
+ return SharedIcons.getImage(SharedIcons.OBJ_CHANNEL);
+ }
+
+ return super.getImage(obj);
+ }
+}
diff --git a/plugins/org.eclipse.net4j/plugin.xml b/plugins/org.eclipse.net4j/plugin.xml
index c22e936..158fa0e 100644
--- a/plugins/org.eclipse.net4j/plugin.xml
+++ b/plugins/org.eclipse.net4j/plugin.xml
@@ -4,5 +4,6 @@
<plugin>
<extension-point id="factories" name="Factories" schema="schema/factories.exsd"/>
+ <extension-point id="elementProcessors" name="Element Processors" schema="schema/elementProcessors.exsd"/>
</plugin>
diff --git a/plugins/org.eclipse.net4j/schema/elementProcessors.exsd b/plugins/org.eclipse.net4j/schema/elementProcessors.exsd
new file mode 100644
index 0000000..9845086
--- /dev/null
+++ b/plugins/org.eclipse.net4j/schema/elementProcessors.exsd
@@ -0,0 +1,105 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.net4j">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.net4j" id="elementProcessors" name="Element Processors"/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="elementProcessor" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="elementProcessor">
+ <complexType>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/Net4j.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/Net4j.java
index 85e1874..74ad165 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/Net4j.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/Net4j.java
@@ -94,6 +94,7 @@ public final class Net4j
public void stop(BundleContext context) throws Exception
{
+ PluginTransportContainer.dispose();
traceStop(context);
Net4j.BUNDLE.setBundleContext(null);
AbstractOMPlatform.systemContext = null;
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/PluginTransportContainer.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/PluginTransportContainer.java
new file mode 100644
index 0000000..3d708ee
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/PluginTransportContainer.java
@@ -0,0 +1,76 @@
+/***************************************************************************
+ * Copyright (c) 2004, 2005, 2006 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.internal.net4j.bundle;
+
+import org.eclipse.net4j.transport.IPluginTransportContainer;
+import org.eclipse.net4j.util.container.IElementProcessor;
+import org.eclipse.net4j.util.factory.IFactory;
+import org.eclipse.net4j.util.factory.IFactoryKey;
+import org.eclipse.net4j.util.registry.IRegistry;
+
+import org.eclipse.internal.net4j.transport.TransportContainer;
+import org.eclipse.internal.net4j.util.container.PluginElementProcessorList;
+import org.eclipse.internal.net4j.util.factory.PluginFactoryRegistry;
+
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public class PluginTransportContainer extends TransportContainer implements IPluginTransportContainer
+{
+ private static PluginTransportContainer instance;
+
+ private PluginTransportContainer()
+ {
+ }
+
+ @Override
+ protected IRegistry<IFactoryKey, IFactory> createFactoryRegistry()
+ {
+ return new PluginFactoryRegistry();
+ }
+
+ @Override
+ protected List<IElementProcessor> createPostProcessors()
+ {
+ return new PluginElementProcessorList();
+ }
+
+ static void dispose()
+ {
+ if (instance != null)
+ {
+ instance.deactivate();
+ instance = null;
+ }
+ }
+
+ public static synchronized PluginTransportContainer getInstance()
+ {
+ if (instance == null)
+ {
+ instance = new PluginTransportContainer();
+
+ try
+ {
+ instance.activate();
+ }
+ catch (Exception ex)
+ {
+ Net4j.LOG.error(ex);
+ instance = null;
+ }
+ }
+
+ return instance;
+ }
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferFactory.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferFactory.java
index 7517f9c..45f772f 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferFactory.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferFactory.java
@@ -15,6 +15,8 @@ import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.internal.net4j.bundle.Net4j;
+import java.text.MessageFormat;
+
/**
* @author Eike Stepper
*/
@@ -53,6 +55,6 @@ public class BufferFactory extends BufferProvider
@Override
public String toString()
{
- return "BufferFactory[capacity=" + getBufferCapacity() + "]"; //$NON-NLS-1$ //$NON-NLS-2$
+ return MessageFormat.format("BufferFactory[{0}]", getBufferCapacity()); //$NON-NLS-1$
}
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferPool.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferPool.java
index d744c3e..a666a5f 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferPool.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferPool.java
@@ -20,6 +20,7 @@ import org.eclipse.internal.net4j.bundle.Net4j;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.SoftReference;
+import java.text.MessageFormat;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
@@ -110,7 +111,7 @@ public class BufferPool extends BufferProvider implements IBufferPool, IBufferPo
@Override
public String toString()
{
- return "BufferPool[" + pooledBuffers + ", " + provider + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ return MessageFormat.format("BufferPool[{0}]", getBufferCapacity()); //$NON-NLS-1$
}
@Override
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/Channel.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/Channel.java
index 085a1d1..904536e 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/Channel.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/Channel.java
@@ -28,6 +28,7 @@ import org.eclipse.internal.net4j.util.concurrent.AsynchronousWorkSerializer;
import org.eclipse.internal.net4j.util.concurrent.SynchronousWorkSerializer;
import org.eclipse.internal.net4j.util.lifecycle.Lifecycle;
+import java.text.MessageFormat;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ExecutorService;
@@ -195,7 +196,7 @@ public class Channel extends Lifecycle implements IChannel, IBufferProvider
@Override
public String toString()
{
- return "Channel[" + connector + ", channelIndex=" + channelIndex + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ return MessageFormat.format("Channel[{0}, {1}]", channelIndex, receiveHandler); //$NON-NLS-1$
}
@Override
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/Connector.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/Connector.java
index 0cb1799..bb63d41 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/Connector.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/Connector.java
@@ -22,13 +22,11 @@ import org.eclipse.net4j.transport.IConnectorCredentials;
import org.eclipse.net4j.transport.IConnectorStateEvent;
import org.eclipse.net4j.transport.IProtocol;
import org.eclipse.net4j.util.StringUtil;
-import org.eclipse.net4j.util.container.IContainerDelta;
import org.eclipse.net4j.util.container.IContainerDelta.Kind;
import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.event.INotifier;
import org.eclipse.net4j.util.factory.IFactory;
import org.eclipse.net4j.util.factory.IFactoryKey;
-import org.eclipse.net4j.util.lifecycle.ILifecycleEvent;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.registry.IRegistry;
@@ -83,21 +81,23 @@ public abstract class Connector extends Lifecycle implements IConnector
* Is registered with each {@link IChannel} of this {@link IConnector}.
* <p>
*/
- private transient IListener lifecycleEventConverter = new LifecycleEventConverter(this)
- {
- @Override
- protected void added(ILifecycleEvent e)
- {
- super.added(e);
- fireEvent(new ConnectorChannelsEvent(Connector.this, (IChannel)e.getLifecycle(), IContainerDelta.Kind.ADDED));
- }
-
- @Override
- protected void removed(ILifecycleEvent e)
- {
- fireEvent(new ConnectorChannelsEvent(Connector.this, (IChannel)e.getLifecycle(), IContainerDelta.Kind.REMOVED));
- super.removed(e);
- }
+ private transient IListener lifecycleEventConverter = new LifecycleEventConverter(this);
+ {
+ // @Override
+ // protected void added(ILifecycleEvent e)
+ // {
+ // super.added(e);
+ // fireEvent(new ConnectorChannelsEvent(Connector.this,
+ // (IChannel)e.getLifecycle(), IContainerDelta.Kind.ADDED));
+ // }
+ //
+ // @Override
+ // protected void removed(ILifecycleEvent e)
+ // {
+ // fireEvent(new ConnectorChannelsEvent(Connector.this,
+ // (IChannel)e.getLifecycle(), IContainerDelta.Kind.REMOVED));
+ // super.removed(e);
+ // }
};
private transient CountDownLatch finishedConnecting;
@@ -328,6 +328,11 @@ public abstract class Connector extends Lifecycle implements IConnector
public IChannel openChannel(String protocolID) throws ConnectorException
{
IProtocol protocol = createProtocol(protocolID);
+ if (protocol == null)
+ {
+ throw new IllegalArgumentException("Unknown protocolID: " + protocolID);
+ }
+
return openChannel(protocol);
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/TransportContainer.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/TransportContainer.java
index f75c6c6..1650a03 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/TransportContainer.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/TransportContainer.java
@@ -16,35 +16,17 @@ import org.eclipse.net4j.transport.TransportUtil;
import org.eclipse.net4j.util.container.IElementProcessor;
import org.eclipse.net4j.util.container.IManagedContainer;
-import org.eclipse.internal.net4j.bundle.Net4j;
+import org.eclipse.internal.net4j.util.concurrent.NamedExecutorService;
import org.eclipse.internal.net4j.util.container.ManagedContainer;
import java.text.MessageFormat;
import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ThreadFactory;
/**
* @author Eike Stepper
*/
public class TransportContainer extends ManagedContainer implements ITransportContainer
{
- public static final String EXECUTOR_SERVICE_GROUP = Net4j.BUNDLE_ID + ".executorServices";
-
- public static final String BUFFER_PROVIDER_GROUP = Net4j.BUNDLE_ID + ".bufferProviders";
-
- public static final short DEFAULT_BUFFER_CAPACITY = 4096;
-
- public static final ThreadFactory THREAD_FACTORY = new ThreadFactory()
- {
- public Thread newThread(Runnable r)
- {
- Thread thread = new Thread(r);
- thread.setDaemon(true);
- return thread;
- }
- };
-
private short bufferCapacity;
public TransportContainer(short bufferCapacity)
@@ -98,7 +80,7 @@ public class TransportContainer extends ManagedContainer implements ITransportCo
protected ExecutorService createExecutorService()
{
- return Executors.newCachedThreadPool(THREAD_FACTORY);
+ return new NamedExecutorService();
}
/**
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/concurrent/NamedExecutorService.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/concurrent/NamedExecutorService.java
new file mode 100644
index 0000000..c9aaeda
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/concurrent/NamedExecutorService.java
@@ -0,0 +1,137 @@
+/***************************************************************************
+ * Copyright (c) 2004, 2005, 2006 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.internal.net4j.util.concurrent;
+
+import java.text.MessageFormat;
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+/**
+ * @author Eike Stepper
+ */
+public class NamedExecutorService implements ExecutorService
+{
+ public static final ThreadFactory THREAD_FACTORY = new ThreadFactory()
+ {
+ public Thread newThread(Runnable r)
+ {
+ Thread thread = new Thread(r);
+ thread.setDaemon(true);
+ return thread;
+ }
+ };
+
+ private String name;
+
+ private ExecutorService delegate;
+
+ public NamedExecutorService(String name, ExecutorService delegate)
+ {
+ this.name = name;
+ this.delegate = delegate;
+ }
+
+ public NamedExecutorService(String name, ThreadFactory threadFactory)
+ {
+ this(name, Executors.newCachedThreadPool(threadFactory));
+ }
+
+ public NamedExecutorService(String name)
+ {
+ this(name, THREAD_FACTORY);
+ }
+
+ public NamedExecutorService()
+ {
+ this("DaemonThreadPool");
+ }
+
+ public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
+ {
+ return delegate.awaitTermination(timeout, unit);
+ }
+
+ public void execute(Runnable command)
+ {
+ delegate.execute(command);
+ }
+
+ public <T> List<Future<T>> invokeAll(Collection<Callable<T>> tasks, long timeout, TimeUnit unit)
+ throws InterruptedException
+ {
+ return delegate.invokeAll(tasks, timeout, unit);
+ }
+
+ public <T> List<Future<T>> invokeAll(Collection<Callable<T>> tasks) throws InterruptedException
+ {
+ return delegate.invokeAll(tasks);
+ }
+
+ public <T> T invokeAny(Collection<Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException,
+ ExecutionException, TimeoutException
+ {
+ return delegate.invokeAny(tasks, timeout, unit);
+ }
+
+ public <T> T invokeAny(Collection<Callable<T>> tasks) throws InterruptedException, ExecutionException
+ {
+ return delegate.invokeAny(tasks);
+ }
+
+ public boolean isShutdown()
+ {
+ return delegate.isShutdown();
+ }
+
+ public boolean isTerminated()
+ {
+ return delegate.isTerminated();
+ }
+
+ public void shutdown()
+ {
+ delegate.shutdown();
+ }
+
+ public List<Runnable> shutdownNow()
+ {
+ return delegate.shutdownNow();
+ }
+
+ public <T> Future<T> submit(Callable<T> task)
+ {
+ return delegate.submit(task);
+ }
+
+ public <T> Future<T> submit(Runnable task, T result)
+ {
+ return delegate.submit(task, result);
+ }
+
+ public Future<?> submit(Runnable task)
+ {
+ return delegate.submit(task);
+ }
+
+ @Override
+ public String toString()
+ {
+ return MessageFormat.format("ExecutorService[{0}]", name); //$NON-NLS-1$
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/container/LifecycleEventConverter.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/container/LifecycleEventConverter.java
index 7d809ef..a224b79 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/container/LifecycleEventConverter.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/container/LifecycleEventConverter.java
@@ -40,28 +40,30 @@ public class LifecycleEventConverter<E> implements IListener
{
case ACTIVATED:
added(e);
- fireContainerEvent(e, IContainerDelta.Kind.ADDED);
- return;
+ break;
case DEACTIVATED:
removed(e);
- fireContainerEvent(e, IContainerDelta.Kind.REMOVED);
- return;
+ break;
}
}
-
- owner.fireEvent(event);
+ // else
+ // {
+ // owner.fireEvent(event);
+ // }
}
protected void added(ILifecycleEvent e)
{
+ fireContainerEvent(e, IContainerDelta.Kind.ADDED);
}
protected void removed(ILifecycleEvent e)
{
+ fireContainerEvent(e, IContainerDelta.Kind.REMOVED);
}
- private void fireContainerEvent(ILifecycleEvent e, IContainerDelta.Kind kind)
+ protected void fireContainerEvent(ILifecycleEvent e, IContainerDelta.Kind kind)
{
ContainerEvent<E> containerEvent = new ContainerEvent<E>((IContainer<E>)owner);
containerEvent.addDelta(new ContainerDelta<E>((E)e.getLifecycle(), kind));
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/container/ManagedContainer.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/container/ManagedContainer.java
index 0c3da3d..6d66dae 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/container/ManagedContainer.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/container/ManagedContainer.java
@@ -34,7 +34,9 @@ import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import java.util.Map.Entry;
/**
@@ -90,6 +92,44 @@ public class ManagedContainer extends Lifecycle implements IManagedContainer
getPostProcessors().remove(postProcessor);
}
+ public Set<String> getProductGroups()
+ {
+ Set<String> result = new HashSet();
+ for (IFactoryKey key : factoryRegistry.keySet())
+ {
+ result.add(key.getProductGroup());
+ }
+
+ for (ElementKey key : elementRegistry.keySet())
+ {
+ result.add(key.getProductGroup());
+ }
+
+ return result;
+ }
+
+ public Set<String> getFactoryTypes(String productGroup)
+ {
+ Set<String> result = new HashSet();
+ for (IFactoryKey key : factoryRegistry.keySet())
+ {
+ if (ObjectUtil.equals(key.getProductGroup(), productGroup))
+ {
+ result.add(key.getType());
+ }
+ }
+
+ for (ElementKey key : elementRegistry.keySet())
+ {
+ if (ObjectUtil.equals(key.getProductGroup(), productGroup))
+ {
+ result.add(key.getFactoryType());
+ }
+ }
+
+ return result;
+ }
+
public boolean isEmpty()
{
return elementRegistry.isEmpty();
@@ -259,12 +299,12 @@ public class ManagedContainer extends Lifecycle implements IManagedContainer
return "ManagedContainer";
}
- protected HashMapRegistry createFactoryRegistry()
+ protected IRegistry<IFactoryKey, IFactory> createFactoryRegistry()
{
return new HashMapRegistry();
}
- protected ArrayList createPostProcessors()
+ protected List<IElementProcessor> createPostProcessors()
{
return new ArrayList();
}
@@ -308,6 +348,14 @@ public class ManagedContainer extends Lifecycle implements IManagedContainer
}
@Override
+ protected void doActivate() throws Exception
+ {
+ super.doActivate();
+ LifecycleUtil.activate(getFactoryRegistry());
+ LifecycleUtil.activate(getPostProcessors());
+ }
+
+ @Override
protected void doDeactivate() throws Exception
{
for (Object element : elementRegistry.values())
@@ -321,6 +369,9 @@ public class ManagedContainer extends Lifecycle implements IManagedContainer
Net4j.LOG.error(ex);
}
}
+
+ LifecycleUtil.deactivate(factoryRegistry);
+ LifecycleUtil.deactivate(postProcessors);
super.doDeactivate();
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/container/PluginElementProcessorList.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/container/PluginElementProcessorList.java
index 4feabbb..4f0f55e 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/container/PluginElementProcessorList.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/container/PluginElementProcessorList.java
@@ -22,18 +22,21 @@ import org.eclipse.internal.net4j.bundle.Net4j;
import org.eclipse.internal.net4j.util.lifecycle.Lifecycle;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
import java.util.List;
+import java.util.ListIterator;
/**
* @author Eike Stepper
*/
-public class PluginElementProcessorList extends Lifecycle
+public class PluginElementProcessorList extends Lifecycle implements List<IElementProcessor>
{
private static final String ATTR_CLASS = "class";
public static final String NAMESPACE = Net4j.BUNDLE_ID;
- public static final String EXT_POINT = "postProcessors";
+ public static final String EXT_POINT = "elementProcessors";
private List<IElementProcessor> processors = new ArrayList();
@@ -54,6 +57,131 @@ public class PluginElementProcessorList extends Lifecycle
{
}
+ public boolean add(IElementProcessor o)
+ {
+ return processors.add(o);
+ }
+
+ public void add(int index, IElementProcessor element)
+ {
+ processors.add(index, element);
+ }
+
+ public boolean addAll(Collection<? extends IElementProcessor> c)
+ {
+ return processors.addAll(c);
+ }
+
+ public boolean addAll(int index, Collection<? extends IElementProcessor> c)
+ {
+ return processors.addAll(index, c);
+ }
+
+ public void clear()
+ {
+ processors.clear();
+ }
+
+ public boolean contains(Object o)
+ {
+ return processors.contains(o);
+ }
+
+ public boolean containsAll(Collection<?> c)
+ {
+ return processors.containsAll(c);
+ }
+
+ public boolean equals(Object o)
+ {
+ return processors.equals(o);
+ }
+
+ public IElementProcessor get(int index)
+ {
+ return processors.get(index);
+ }
+
+ public int hashCode()
+ {
+ return processors.hashCode();
+ }
+
+ public int indexOf(Object o)
+ {
+ return processors.indexOf(o);
+ }
+
+ public boolean isEmpty()
+ {
+ return processors.isEmpty();
+ }
+
+ public Iterator<IElementProcessor> iterator()
+ {
+ return processors.iterator();
+ }
+
+ public int lastIndexOf(Object o)
+ {
+ return processors.lastIndexOf(o);
+ }
+
+ public ListIterator<IElementProcessor> listIterator()
+ {
+ return processors.listIterator();
+ }
+
+ public ListIterator<IElementProcessor> listIterator(int index)
+ {
+ return processors.listIterator(index);
+ }
+
+ public IElementProcessor remove(int index)
+ {
+ return processors.remove(index);
+ }
+
+ public boolean remove(Object o)
+ {
+ return processors.remove(o);
+ }
+
+ public boolean removeAll(Collection<?> c)
+ {
+ return processors.removeAll(c);
+ }
+
+ public boolean retainAll(Collection<?> c)
+ {
+ return processors.retainAll(c);
+ }
+
+ public IElementProcessor set(int index, IElementProcessor element)
+ {
+ return processors.set(index, element);
+ }
+
+ public int size()
+ {
+ return processors.size();
+ }
+
+ public List<IElementProcessor> subList(int fromIndex, int toIndex)
+ {
+ return processors.subList(fromIndex, toIndex);
+ }
+
+ public Object[] toArray()
+ {
+ return processors.toArray();
+ }
+
+ public <T> T[] toArray(T[] a)
+ {
+ return processors.toArray(a);
+ }
+
@Override
protected void doActivate() throws Exception
{
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/registry/Registry.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/registry/Registry.java
index 3417deb..bb22b62 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/registry/Registry.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/util/registry/Registry.java
@@ -129,8 +129,7 @@ public abstract class Registry<K, V> extends Lifecycle implements IRegistry<K, V
{
if (!isEmpty())
{
- Set<K> keys = keySet();
- for (K key : keys)
+ for (Object key : keySet().toArray())
{
deregister(key);
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java
index 9fa8d58..5d0c85a 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java
@@ -21,6 +21,7 @@ import org.eclipse.internal.net4j.transport.BufferUtil;
import org.eclipse.internal.net4j.transport.Protocol;
import java.nio.ByteBuffer;
+import java.text.MessageFormat;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
@@ -131,7 +132,7 @@ public abstract class SignalProtocol extends Protocol
@Override
public String toString()
{
- return "SignalProtocol[" + getType() + ", " + getChannel() + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ return MessageFormat.format("SignalProtocol[{0}]", getType()); //$NON-NLS-1$
}
protected final SignalReactor createSignalReactor(short signalID)
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ConnectorException.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ConnectorException.java
index 051f2a2..294d41e 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ConnectorException.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ConnectorException.java
@@ -13,7 +13,7 @@ package org.eclipse.net4j.transport;
/**
* @author Eike Stepper
*/
-public class ConnectorException extends Exception
+public class ConnectorException extends RuntimeException
{
private static final long serialVersionUID = 1L;
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/IPluginTransportContainer.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/IPluginTransportContainer.java
new file mode 100644
index 0000000..4c7c896
--- /dev/null
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/IPluginTransportContainer.java
@@ -0,0 +1,21 @@
+/***************************************************************************
+ * Copyright (c) 2004, 2005, 2006 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.transport;
+
+import org.eclipse.internal.net4j.bundle.PluginTransportContainer;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IPluginTransportContainer extends ITransportContainer
+{
+ public static final ITransportContainer INSTANCE = PluginTransportContainer.getInstance();
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ITransportContainer.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ITransportContainer.java
index 0dba548..de130f2 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ITransportContainer.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ITransportContainer.java
@@ -1,7 +1,19 @@
+/***************************************************************************
+ * Copyright (c) 2004, 2005, 2006 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.transport;
import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.internal.net4j.bundle.Net4j;
+
import java.util.concurrent.ExecutorService;
/**
@@ -9,6 +21,12 @@ import java.util.concurrent.ExecutorService;
*/
public interface ITransportContainer extends IManagedContainer
{
+ public static final String EXECUTOR_SERVICE_GROUP = Net4j.BUNDLE_ID + ".executorServices";
+
+ public static final String BUFFER_PROVIDER_GROUP = Net4j.BUNDLE_ID + ".bufferProviders";
+
+ public static final short DEFAULT_BUFFER_CAPACITY = 4096;
+
public short getBufferCapacity();
public IBufferProvider getBufferProvider();
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/container/IManagedContainer.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/container/IManagedContainer.java
index 68f9ab6..12e9875 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/container/IManagedContainer.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/container/IManagedContainer.java
@@ -18,6 +18,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
+import java.util.Set;
/**
* @author Eike Stepper
@@ -32,6 +33,10 @@ public interface IManagedContainer extends IContainer
public void removePostProcessor(IElementProcessor postProcessor);
+ public Set<String> getProductGroups();
+
+ public Set<String> getFactoryTypes(String productGroup);
+
public Object[] getElements(String productGroup);
public Object[] getElements(String productGroup, String factoryType);