Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-06-06 16:26:06 +0000
committerEike Stepper2012-06-06 16:26:06 +0000
commitbc6860460ea734dc2dfa4cc82238486f53c81d41 (patch)
tree18e8504d09c047a2faea9596e241c493234bbdb3 /plugins/org.eclipse.net4j.ui/src
parentbeaf88a6d18849a3d00476ca046a111f636ace5a (diff)
downloadcdo-bc6860460ea734dc2dfa4cc82238486f53c81d41.tar.gz
cdo-bc6860460ea734dc2dfa4cc82238486f53c81d41.tar.xz
cdo-bc6860460ea734dc2dfa4cc82238486f53c81d41.zip
[381472] Design a repository administration API
https://bugs.eclipse.org/bugs/show_bug.cgi?id=381472
Diffstat (limited to 'plugins/org.eclipse.net4j.ui/src')
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/container/JVMAcceptorWizard.java93
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/container/TCPAcceptorWizard.java84
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/AcceptorsView.java171
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/ConnectorsView.java114
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/Net4jItemProvider.java (renamed from plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/Net4jItemProvider.java)197
5 files changed, 431 insertions, 228 deletions
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/container/JVMAcceptorWizard.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/container/JVMAcceptorWizard.java
new file mode 100644
index 0000000000..88604cbc7a
--- /dev/null
+++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/container/JVMAcceptorWizard.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.net4j.internal.ui.container;
+
+import org.eclipse.net4j.util.ObjectUtil;
+import org.eclipse.net4j.util.factory.ProductCreationException;
+import org.eclipse.net4j.util.ui.container.ElementWizard;
+import org.eclipse.net4j.util.ui.container.ElementWizardFactory;
+
+import org.eclipse.spi.net4j.AcceptorFactory;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * @author Eike Stepper
+ * @since 4.0
+ */
+public class JVMAcceptorWizard extends ElementWizard implements ModifyListener
+{
+ private Text acceptorNameText;
+
+ public JVMAcceptorWizard()
+ {
+ }
+
+ @Override
+ protected void create(Composite parent)
+ {
+ acceptorNameText = addText(parent, "Acceptor Name:");
+ acceptorNameText.addModifyListener(this);
+ }
+
+ public void modifyText(ModifyEvent e)
+ {
+ String acceptorName = acceptorNameText.getText();
+ if (acceptorName.length() == 0)
+ {
+ setValidationError(acceptorNameText, "Acceptor name is empty.");
+ return;
+ }
+
+ try
+ {
+ for (Object element : getContainer().getElements(AcceptorFactory.PRODUCT_GROUP, "jvm"))
+ {
+ if (element instanceof org.eclipse.net4j.jvm.IJVMAcceptor)
+ {
+ org.eclipse.net4j.jvm.IJVMAcceptor acceptor = (org.eclipse.net4j.jvm.IJVMAcceptor)element;
+ if (ObjectUtil.equals(acceptor.getName(), acceptorName))
+ {
+ setValidationError(acceptorNameText, "Duplicate acceptor name.");
+ return;
+ }
+ }
+ }
+ }
+ catch (NoClassDefFoundError error)
+ {
+ // Ignore.
+ }
+
+ setResultDescription(acceptorName);
+ setValidationError(acceptorNameText, null);
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static class Factory extends ElementWizardFactory
+ {
+ public Factory()
+ {
+ super(AcceptorFactory.PRODUCT_GROUP, "jvm");
+ }
+
+ @Override
+ public JVMAcceptorWizard create(String description) throws ProductCreationException
+ {
+ return new JVMAcceptorWizard();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/container/TCPAcceptorWizard.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/container/TCPAcceptorWizard.java
new file mode 100644
index 0000000000..95393b79b5
--- /dev/null
+++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/container/TCPAcceptorWizard.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.net4j.internal.ui.container;
+
+import org.eclipse.net4j.util.factory.ProductCreationException;
+import org.eclipse.net4j.util.ui.container.ElementWizard;
+import org.eclipse.net4j.util.ui.container.ElementWizardFactory;
+
+import org.eclipse.spi.net4j.AcceptorFactory;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * @author Eike Stepper
+ * @author Martin Fluegge
+ * @since 4.0
+ */
+public class TCPAcceptorWizard extends ElementWizard implements ModifyListener
+{
+ private Text addressText;
+
+ private Text portText;
+
+ public TCPAcceptorWizard()
+ {
+ }
+
+ @Override
+ protected void create(Composite parent)
+ {
+ addressText = addText(parent, "Address:");
+ addressText.addModifyListener(this);
+
+ portText = addText(parent, "Port:");
+ portText.addModifyListener(this);
+ }
+
+ public void modifyText(ModifyEvent e)
+ {
+ String host = addressText.getText();
+ if (host.length() == 0)
+ {
+ setValidationError(addressText, "Address is empty.");
+ return;
+ }
+
+ String port = portText.getText();
+ if (port.length() != 0)
+ {
+ host += ":" + port;
+ }
+
+ setResultDescription(host);
+ setValidationError(addressText, null);
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static class Factory extends ElementWizardFactory
+ {
+ public Factory()
+ {
+ super(AcceptorFactory.PRODUCT_GROUP, "tcp");
+ }
+
+ @Override
+ public TCPAcceptorWizard create(String description) throws ProductCreationException
+ {
+ return new TCPAcceptorWizard();
+ }
+ }
+}
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
index 4718ac7635..d4593002a8 100644
--- 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
@@ -1,83 +1,88 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.Net4jUtil;
-import org.eclipse.net4j.acceptor.IAcceptor;
-import org.eclipse.net4j.internal.ui.messages.Messages;
-import org.eclipse.net4j.util.container.IContainer;
-import org.eclipse.net4j.util.container.IManagedContainer;
-import org.eclipse.net4j.util.container.IPluginContainer;
-import org.eclipse.net4j.util.ui.actions.SafeAction;
-import org.eclipse.net4j.util.ui.views.ContainerItemProvider;
-import org.eclipse.net4j.util.ui.views.ContainerView;
-import org.eclipse.net4j.util.ui.views.IElementFilter;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IToolBarManager;
-
-/**
- * @author Eike Stepper
- */
-public class AcceptorsView extends ContainerView
-{
- private Action addAcceptorAction2036 = new SafeAction(Messages.getString("AcceptorsView_0"), //$NON-NLS-1$
- Messages.getString("AcceptorsView_1"), //$NON-NLS-1$
- getAddImageDescriptor())
- {
- @Override
- protected void safeRun() throws Exception
- {
- Net4jUtil.getAcceptor(IPluginContainer.INSTANCE, "tcp", "0.0.0.0:2036"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- };
-
- private Action addAcceptorAction2037 = new SafeAction(Messages.getString("AcceptorsView_4"),
- Messages.getString("AcceptorsView_5"), //$NON-NLS-1$
- getAddImageDescriptor())
- {
- @Override
- protected void safeRun() throws Exception
- {
- Net4jUtil.getAcceptor(IPluginContainer.INSTANCE, "tcp", "0.0.0.0:2037"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- };
-
- public AcceptorsView()
- {
- }
-
- @Override
- protected IManagedContainer getContainer()
- {
- return IPluginContainer.INSTANCE;
- }
-
- @Override
- protected ContainerItemProvider<IContainer<Object>> createContainerItemProvider()
- {
- return new Net4jItemProvider(new IElementFilter()
- {
- public boolean filter(Object element)
- {
- return element instanceof IAcceptor;
- }
- });
- }
-
- @Override
- protected void fillLocalToolBar(IToolBarManager manager)
- {
- manager.add(addAcceptorAction2036);
- manager.add(addAcceptorAction2037);
- super.fillLocalToolBar(manager);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.acceptor.IAcceptor;
+import org.eclipse.net4j.ui.Net4jItemProvider;
+import org.eclipse.net4j.ui.shared.SharedIcons;
+import org.eclipse.net4j.util.container.IContainer;
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.container.IPluginContainer;
+import org.eclipse.net4j.util.ui.container.ElementWizardAction;
+import org.eclipse.net4j.util.ui.views.ContainerItemProvider;
+import org.eclipse.net4j.util.ui.views.ContainerView;
+import org.eclipse.net4j.util.ui.views.IElementFilter;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.spi.net4j.AcceptorFactory;
+
+/**
+ * @author Eike Stepper
+ */
+public class AcceptorsView extends ContainerView
+{
+ public final static String ID = "org.eclipse.net4j.AcceptorsView"; //$NON-NLS-1$
+
+ private IAction newAcceptorAction = new ElementWizardAction(getShell(), "New Acceptor", "Open a new Net4j acceptor",
+ SharedIcons.getDescriptor(SharedIcons.ETOOL_ADD_ACCEPTOR), AcceptorFactory.PRODUCT_GROUP, getContainer());
+
+ // private Action addAcceptorAction2036 = new SafeAction(Messages.getString("AcceptorsView_0"), //$NON-NLS-1$
+ // Messages.getString("AcceptorsView_1"), //$NON-NLS-1$
+ // getAddImageDescriptor())
+ // {
+ // @Override
+ // protected void safeRun() throws Exception
+ // {
+ // Net4jUtil.getAcceptor(IPluginContainer.INSTANCE, "tcp", "0.0.0.0:2036"); //$NON-NLS-1$ //$NON-NLS-2$
+ // }
+ // };
+ //
+ // private Action addAcceptorAction2037 = new SafeAction(Messages.getString("AcceptorsView_4"),
+ // Messages.getString("AcceptorsView_5"), //$NON-NLS-1$
+ // getAddImageDescriptor())
+ // {
+ // @Override
+ // protected void safeRun() throws Exception
+ // {
+ // Net4jUtil.getAcceptor(IPluginContainer.INSTANCE, "tcp", "0.0.0.0:2037"); //$NON-NLS-1$ //$NON-NLS-2$
+ // }
+ // };
+
+ public AcceptorsView()
+ {
+ }
+
+ @Override
+ protected IManagedContainer getContainer()
+ {
+ return IPluginContainer.INSTANCE;
+ }
+
+ @Override
+ protected ContainerItemProvider<IContainer<Object>> createContainerItemProvider()
+ {
+ return new Net4jItemProvider(new IElementFilter()
+ {
+ public boolean filter(Object element)
+ {
+ return element instanceof IAcceptor;
+ }
+ });
+ }
+
+ @Override
+ protected void fillLocalToolBar(IToolBarManager manager)
+ {
+ manager.add(newAcceptorAction);
+ super.fillLocalToolBar(manager);
+ }
+}
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
index 3843a269e7..dd6c17607f 100644
--- 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
@@ -1,47 +1,67 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.connector.IConnector;
-import org.eclipse.net4j.util.container.IContainer;
-import org.eclipse.net4j.util.container.IManagedContainer;
-import org.eclipse.net4j.util.container.IPluginContainer;
-import org.eclipse.net4j.util.ui.views.ContainerItemProvider;
-import org.eclipse.net4j.util.ui.views.ContainerView;
-import org.eclipse.net4j.util.ui.views.IElementFilter;
-
-/**
- * @author Eike Stepper
- */
-public class ConnectorsView extends ContainerView
-{
- public ConnectorsView()
- {
- }
-
- @Override
- protected IManagedContainer getContainer()
- {
- return IPluginContainer.INSTANCE;
- }
-
- @Override
- protected ContainerItemProvider<IContainer<Object>> createContainerItemProvider()
- {
- return new Net4jItemProvider(new IElementFilter()
- {
- public boolean filter(Object element)
- {
- return element instanceof IConnector;
- }
- });
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.connector.IConnector;
+import org.eclipse.net4j.ui.Net4jItemProvider;
+import org.eclipse.net4j.ui.shared.SharedIcons;
+import org.eclipse.net4j.util.container.IContainer;
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.container.IPluginContainer;
+import org.eclipse.net4j.util.ui.container.ElementWizardAction;
+import org.eclipse.net4j.util.ui.views.ContainerItemProvider;
+import org.eclipse.net4j.util.ui.views.ContainerView;
+import org.eclipse.net4j.util.ui.views.IElementFilter;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.spi.net4j.ConnectorFactory;
+
+/**
+ * @author Eike Stepper
+ */
+public class ConnectorsView extends ContainerView
+{
+ public final static String ID = "org.eclipse.net4j.ConnectorsView"; //$NON-NLS-1$
+
+ private IAction newConnectorAction = new ElementWizardAction(getShell(), "New Connector",
+ "Open a new Net4j connector", SharedIcons.getDescriptor(SharedIcons.ETOOL_ADD_CONNECTOR),
+ ConnectorFactory.PRODUCT_GROUP, getContainer());
+
+ public ConnectorsView()
+ {
+ }
+
+ @Override
+ protected IManagedContainer getContainer()
+ {
+ return IPluginContainer.INSTANCE;
+ }
+
+ @Override
+ protected ContainerItemProvider<IContainer<Object>> createContainerItemProvider()
+ {
+ return new Net4jItemProvider(new IElementFilter()
+ {
+ public boolean filter(Object element)
+ {
+ return element instanceof IConnector;
+ }
+ });
+ }
+
+ @Override
+ protected void fillLocalToolBar(IToolBarManager manager)
+ {
+ manager.add(newConnectorAction);
+ super.fillLocalToolBar(manager);
+ }
+}
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/ui/Net4jItemProvider.java
index ec84fd74c6..e6cd5dc16c 100644
--- 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/ui/Net4jItemProvider.java
@@ -1,98 +1,99 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.acceptor.IAcceptor;
-import org.eclipse.net4j.channel.IChannel;
-import org.eclipse.net4j.connector.IConnector;
-import org.eclipse.net4j.internal.ui.messages.Messages;
-import org.eclipse.net4j.ui.shared.SharedIcons;
-import org.eclipse.net4j.util.container.IContainer;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-import org.eclipse.net4j.util.ui.actions.LongRunningAction;
-import org.eclipse.net4j.util.ui.views.ContainerItemProvider;
-import org.eclipse.net4j.util.ui.views.ContainerView;
-import org.eclipse.net4j.util.ui.views.IElementFilter;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.viewers.ITreeSelection;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * @author Eike Stepper
- */
-public class Net4jItemProvider extends ContainerItemProvider<IContainer<Object>>
-{
- public Net4jItemProvider()
- {
- }
-
- public Net4jItemProvider(IElementFilter rootElementFilter)
- {
- super(rootElementFilter);
- }
-
- @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);
- }
-
- @Override
- protected void fillContextMenu(IMenuManager manager, ITreeSelection selection)
- {
- if (selection.size() == 1)
- {
- Object obj = selection.getFirstElement();
- if (obj instanceof IAcceptor || obj instanceof IConnector || obj instanceof IChannel)
- {
- manager.add(new RemoveAction(obj));
- }
- }
- }
-
- /**
- * @author Eike Stepper
- */
- public static class RemoveAction extends LongRunningAction
- {
- private Object object;
-
- public RemoveAction(Object object)
- {
- super(
- Messages.getString("Net4jItemProvider.0"), Messages.getString("Net4jItemProvider.1"), ContainerView.getDeleteImageDescriptor()); //$NON-NLS-1$ //$NON-NLS-2$
- this.object = object;
- }
-
- @Override
- protected void doRun(IProgressMonitor progressMonitor) throws Exception
- {
- LifecycleUtil.deactivateNoisy(object);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.ui;
+
+import org.eclipse.net4j.acceptor.IAcceptor;
+import org.eclipse.net4j.channel.IChannel;
+import org.eclipse.net4j.connector.IConnector;
+import org.eclipse.net4j.internal.ui.messages.Messages;
+import org.eclipse.net4j.ui.shared.SharedIcons;
+import org.eclipse.net4j.util.container.IContainer;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.ui.actions.LongRunningAction;
+import org.eclipse.net4j.util.ui.views.ContainerItemProvider;
+import org.eclipse.net4j.util.ui.views.ContainerView;
+import org.eclipse.net4j.util.ui.views.IElementFilter;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.viewers.ITreeSelection;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @author Eike Stepper
+ * @since 4.1
+ */
+public class Net4jItemProvider extends ContainerItemProvider<IContainer<Object>>
+{
+ public Net4jItemProvider()
+ {
+ }
+
+ public Net4jItemProvider(IElementFilter rootElementFilter)
+ {
+ super(rootElementFilter);
+ }
+
+ @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);
+ }
+
+ @Override
+ protected void fillContextMenu(IMenuManager manager, ITreeSelection selection)
+ {
+ if (selection.size() == 1)
+ {
+ Object obj = selection.getFirstElement();
+ if (obj instanceof IAcceptor || obj instanceof IConnector || obj instanceof IChannel)
+ {
+ manager.add(new RemoveAction(obj));
+ }
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static class RemoveAction extends LongRunningAction
+ {
+ private Object object;
+
+ public RemoveAction(Object object)
+ {
+ super(
+ Messages.getString("Net4jItemProvider.0"), Messages.getString("Net4jItemProvider.1"), ContainerView.getDeleteImageDescriptor()); //$NON-NLS-1$ //$NON-NLS-2$
+ this.object = object;
+ }
+
+ @Override
+ protected void doRun(IProgressMonitor progressMonitor) throws Exception
+ {
+ LifecycleUtil.deactivateNoisy(object);
+ }
+ }
+}

Back to the top