Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-06-07 10:39:11 +0000
committerEike Stepper2012-06-07 10:39:11 +0000
commit9b52277f7c4465faf18b74562958f9a660c802a3 (patch)
treef79a4a015121f7df8a18ac1832da56aa00616a4a /plugins
parenta25531ae8a5c85586fdb590c0f806be3a807b634 (diff)
downloadcdo-9b52277f7c4465faf18b74562958f9a660c802a3.tar.gz
cdo-9b52277f7c4465faf18b74562958f9a660c802a3.tar.xz
cdo-9b52277f7c4465faf18b74562958f9a660c802a3.zip
[381472] Design a repository administration API
https://bugs.eclipse.org/bugs/show_bug.cgi?id=381472
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.ui.admin/src/org/eclipse/emf/cdo/ui/internal/admin/CDOAdminView.java3
-rw-r--r--plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMClientConnector.java139
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/container/JVMAcceptorWizard.java6
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/container/JVMConnectorWizard.java86
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/AcceptorsView.java7
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/views/ConnectorsView.java10
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/container/ElementWizard.java289
7 files changed, 315 insertions, 225 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui.admin/src/org/eclipse/emf/cdo/ui/internal/admin/CDOAdminView.java b/plugins/org.eclipse.emf.cdo.ui.admin/src/org/eclipse/emf/cdo/ui/internal/admin/CDOAdminView.java
index 5e09d9c805..7ba99c6972 100644
--- a/plugins/org.eclipse.emf.cdo.ui.admin/src/org/eclipse/emf/cdo/ui/internal/admin/CDOAdminView.java
+++ b/plugins/org.eclipse.emf.cdo.ui.admin/src/org/eclipse/emf/cdo/ui/internal/admin/CDOAdminView.java
@@ -48,8 +48,7 @@ public class CDOAdminView extends ContainerView
private final Map<IConnector, CDOAdminClient> admins = new HashMap<IConnector, CDOAdminClient>();
- private IAction newConnectorAction = new ElementWizardAction(getShell(), "New Connector",
- "Open a new Net4j connector",
+ private IAction newConnectorAction = new ElementWizardAction(getShell(), "New Connector", "Open a new connector",
org.eclipse.net4j.ui.shared.SharedIcons
.getDescriptor(org.eclipse.net4j.ui.shared.SharedIcons.ETOOL_ADD_CONNECTOR), ConnectorFactory.PRODUCT_GROUP,
getContainer(), "tcp")
diff --git a/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMClientConnector.java b/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMClientConnector.java
index bfb2395e89..460c479e6b 100644
--- a/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMClientConnector.java
+++ b/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMClientConnector.java
@@ -1,63 +1,76 @@
-/*
- * 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.jvm;
-
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-
-/**
- * @author Eike Stepper
- */
-public class JVMClientConnector extends JVMConnector
-{
- private JVMAcceptor acceptor;
-
- public JVMClientConnector()
- {
- }
-
- @Override
- public Location getLocation()
- {
- return Location.CLIENT;
- }
-
- public JVMAcceptor getAcceptor()
- {
- return acceptor;
- }
-
- @Override
- protected void doBeforeActivate() throws Exception
- {
- super.doBeforeActivate();
- String name = getName();
- acceptor = JVMAcceptorManager.INSTANCE.getAcceptor(name);
- if (acceptor == null)
- {
- throw new IllegalStateException("JVM acceptor not found: " + name); //$NON-NLS-1$
- }
- }
-
- @Override
- protected void doActivate() throws Exception
- {
- super.doActivate();
- JVMConnector peer = acceptor.handleAccept(this);
- setPeer(peer);
- }
-
- @Override
- protected void doDeactivate() throws Exception
- {
- LifecycleUtil.deactivateNoisy(getPeer());
- super.doDeactivate();
- }
-}
+/*
+ * 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.jvm;
+
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+
+import java.text.MessageFormat;
+
+/**
+ * @author Eike Stepper
+ */
+public class JVMClientConnector extends JVMConnector
+{
+ private JVMAcceptor acceptor;
+
+ public JVMClientConnector()
+ {
+ }
+
+ @Override
+ public Location getLocation()
+ {
+ return Location.CLIENT;
+ }
+
+ public JVMAcceptor getAcceptor()
+ {
+ return acceptor;
+ }
+
+ @Override
+ public String toString()
+ {
+ if (getUserID() == null)
+ {
+ return MessageFormat.format("JVMClientConnector[{0}]", getName()); //$NON-NLS-1$
+ }
+
+ return MessageFormat.format("JVMClientConnector[{1}@{0}]", getName(), getUserID()); //$NON-NLS-1$
+ }
+
+ @Override
+ protected void doBeforeActivate() throws Exception
+ {
+ super.doBeforeActivate();
+ String name = getName();
+ acceptor = JVMAcceptorManager.INSTANCE.getAcceptor(name);
+ if (acceptor == null)
+ {
+ throw new IllegalStateException("JVM acceptor not found: " + name); //$NON-NLS-1$
+ }
+ }
+
+ @Override
+ protected void doActivate() throws Exception
+ {
+ super.doActivate();
+ JVMConnector peer = acceptor.handleAccept(this);
+ setPeer(peer);
+ }
+
+ @Override
+ protected void doDeactivate() throws Exception
+ {
+ LifecycleUtil.deactivateNoisy(getPeer());
+ super.doDeactivate();
+ }
+}
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
index 88604cbc7a..3c59fbc836 100644
--- 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
@@ -39,6 +39,12 @@ public class JVMAcceptorWizard extends ElementWizard implements ModifyListener
{
acceptorNameText = addText(parent, "Acceptor Name:");
acceptorNameText.addModifyListener(this);
+
+ String description = getDefaultDescription();
+ if (description != null)
+ {
+ acceptorNameText.setText(description);
+ }
}
public void modifyText(ModifyEvent e)
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/container/JVMConnectorWizard.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/container/JVMConnectorWizard.java
index beae7000bc..fb04f21361 100644
--- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/container/JVMConnectorWizard.java
+++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/internal/ui/container/JVMConnectorWizard.java
@@ -11,6 +11,9 @@
*/
package org.eclipse.net4j.internal.ui.container;
+import org.eclipse.net4j.internal.jvm.JVMAcceptorFactory;
+import org.eclipse.net4j.internal.ui.bundle.OM;
+import org.eclipse.net4j.jvm.IJVMAcceptor;
import org.eclipse.net4j.util.factory.ProductCreationException;
import org.eclipse.net4j.util.ui.container.ElementWizard;
import org.eclipse.net4j.util.ui.container.ElementWizardFactory;
@@ -18,18 +21,23 @@ import org.eclipse.net4j.util.ui.container.ElementWizardFactory;
import org.eclipse.spi.net4j.ConnectorFactory;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
/**
* @author Eike Stepper
* @author Martin Fluegge
* @since 4.0
*/
-public class JVMConnectorWizard extends ElementWizard implements ModifyListener
+public class JVMConnectorWizard extends ElementWizard
{
- private Text acceptorNameText;
-
public JVMConnectorWizard()
{
}
@@ -37,27 +45,71 @@ public class JVMConnectorWizard extends ElementWizard implements ModifyListener
@Override
protected void create(Composite parent)
{
- acceptorNameText = addText(parent, "Acceptor Name:");
- acceptorNameText.addModifyListener(this);
+ List<String> choices = new ArrayList<String>();
- String description = getDefaultDescription();
- if (description != null)
+ try
{
- acceptorNameText.setText(description);
+ Object[] elements = getContainer().getElements(JVMAcceptorFactory.PRODUCT_GROUP, JVMAcceptorFactory.TYPE);
+ for (Object object : elements)
+ {
+ if (object instanceof IJVMAcceptor)
+ {
+ IJVMAcceptor acceptor = (IJVMAcceptor)object;
+ choices.add(acceptor.getName());
+ }
+ }
+ }
+ catch (NoClassDefFoundError error)
+ {
+ OM.LOG.error(error);
}
- }
- public void modifyText(ModifyEvent e)
- {
- String acceptorName = acceptorNameText.getText();
- if (acceptorName.length() == 0)
+ if (!choices.isEmpty())
{
- setValidationError(acceptorNameText, "Acceptor name is empty.");
- return;
+ Collections.sort(choices);
+
+ final Combo acceptorCombo = addCombo(parent, "Acceptor:", choices);
+ acceptorCombo.addSelectionListener(new SelectionAdapter()
+ {
+ @Override
+ public void widgetSelected(SelectionEvent e)
+ {
+ String acceptorName = acceptorCombo.getText();
+ setResultDescription(acceptorName);
+ }
+ });
+
+ String description = getDefaultDescription();
+ if (description != null)
+ {
+ acceptorCombo.setText(description);
+ }
}
+ else
+ {
+ final Text acceptorNameText = addText(parent, "Acceptor Name:");
+ acceptorNameText.addModifyListener(new ModifyListener()
+ {
+ public void modifyText(ModifyEvent e)
+ {
+ String acceptorName = acceptorNameText.getText();
+ if (acceptorName.length() == 0)
+ {
+ setValidationError(acceptorNameText, "Acceptor name is empty.");
+ return;
+ }
- setResultDescription(acceptorName);
- setValidationError(acceptorNameText, null);
+ setResultDescription(acceptorName);
+ setValidationError(acceptorNameText, null);
+ }
+ });
+
+ String description = getDefaultDescription();
+ if (description != null)
+ {
+ acceptorNameText.setText(description);
+ }
+ }
}
/**
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 5791387f7b..759cad3a73 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
@@ -32,12 +32,17 @@ 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",
+ private IAction newAcceptorAction = new ElementWizardAction(getShell(), "New Acceptor", "Open a new acceptor",
SharedIcons.getDescriptor(SharedIcons.ETOOL_ADD_ACCEPTOR), AcceptorFactory.PRODUCT_GROUP, getContainer(), "tcp")
{
@Override
public String getDefaultDescription(String factoryType)
{
+ if ("jvm".equals(factoryType))
+ {
+ return "default";
+ }
+
if ("tcp".equals(factoryType))
{
return "0.0.0.0:2036";
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 67f5bd90b0..699e7251bb 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
@@ -32,13 +32,17 @@ 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(), "tcp")
+ private IAction newConnectorAction = new ElementWizardAction(getShell(), "New Connector", "Open a new connector",
+ SharedIcons.getDescriptor(SharedIcons.ETOOL_ADD_CONNECTOR), ConnectorFactory.PRODUCT_GROUP, getContainer(), "tcp")
{
@Override
public String getDefaultDescription(String factoryType)
{
+ if ("jvm".equals(factoryType))
+ {
+ return "default";
+ }
+
if ("tcp".equals(factoryType))
{
return "localhost";
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/container/ElementWizard.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/container/ElementWizard.java
index f22d098b8b..e6a489be0c 100644
--- a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/container/ElementWizard.java
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/container/ElementWizard.java
@@ -1,139 +1,150 @@
-/*
- * 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.util.ui.container;
-
-import org.eclipse.net4j.util.ObjectUtil;
-import org.eclipse.net4j.util.container.IManagedContainer;
-import org.eclipse.net4j.util.event.Notifier;
-import org.eclipse.net4j.util.ui.UIUtil;
-import org.eclipse.net4j.util.ui.ValidationContext;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * @author Eike Stepper
- * @since 3.1
- */
-public abstract class ElementWizard extends Notifier implements IElementWizard, ValidationContext
-{
- private IManagedContainer container;
-
- private String productGroup;
-
- private String factoryType;
-
- private String defaultDescription;
-
- private String resultDescription;
-
- private ValidationContext context;
-
- public ElementWizard()
- {
- }
-
- protected IManagedContainer getContainer()
- {
- return container;
- }
-
- protected String getProductGroup()
- {
- return productGroup;
- }
-
- protected String getFactoryType()
- {
- return factoryType;
- }
-
- protected String getDefaultDescription()
- {
- return defaultDescription;
- }
-
- public String getResultDescription()
- {
- return resultDescription;
- }
-
- public Object getResultElement()
- {
- return container.getElement(productGroup, factoryType, resultDescription);
- }
-
- public void create(Composite parent, IManagedContainer container, String productGroup, String factoryType,
- String defaultDescription, ValidationContext context)
- {
- this.container = container;
- this.productGroup = productGroup;
- this.factoryType = factoryType;
- this.defaultDescription = defaultDescription;
- this.context = context;
-
- create(parent);
- }
-
- protected void setResultDescription(String resultDescription)
- {
- String oldDescription = this.resultDescription;
- if (!ObjectUtil.equals(resultDescription, oldDescription))
- {
- this.resultDescription = resultDescription;
- fireEvent();
- }
- }
-
- public void setValidationError(Object source, String message)
- {
- if (context != null)
- {
- context.setValidationError(source, message);
- }
- }
-
- protected abstract void create(Composite parent);
-
- public static Label addLabel(Composite parent, String label)
- {
- Label control = new Label(parent, SWT.NONE);
- control.setText(label);
- control.setLayoutData(UIUtil.createGridData(false, false));
- return control;
- }
-
- public static Text addText(Composite parent, String label)
- {
- addLabel(parent, label);
-
- Text control = new Text(parent, SWT.BORDER);
- control.setLayoutData(UIUtil.createGridData(true, false));
- return control;
- }
-
- public static Combo addCombo(Composite parent, String label, String... choices)
- {
- addLabel(parent, label);
-
- Combo control = new Combo(parent, SWT.SINGLE);
- control.setLayoutData(UIUtil.createGridData(true, false));
- for (String choice : choices)
- {
- control.add(choice);
- }
-
- return control;
- }
-}
+/*
+ * 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.util.ui.container;
+
+import org.eclipse.net4j.util.ObjectUtil;
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.event.Notifier;
+import org.eclipse.net4j.util.ui.UIUtil;
+import org.eclipse.net4j.util.ui.ValidationContext;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ * @since 3.1
+ */
+public abstract class ElementWizard extends Notifier implements IElementWizard, ValidationContext
+{
+ private IManagedContainer container;
+
+ private String productGroup;
+
+ private String factoryType;
+
+ private String defaultDescription;
+
+ private String resultDescription;
+
+ private ValidationContext context;
+
+ public ElementWizard()
+ {
+ }
+
+ protected IManagedContainer getContainer()
+ {
+ return container;
+ }
+
+ protected String getProductGroup()
+ {
+ return productGroup;
+ }
+
+ protected String getFactoryType()
+ {
+ return factoryType;
+ }
+
+ protected String getDefaultDescription()
+ {
+ return defaultDescription;
+ }
+
+ public String getResultDescription()
+ {
+ return resultDescription;
+ }
+
+ public Object getResultElement()
+ {
+ return container.getElement(productGroup, factoryType, resultDescription);
+ }
+
+ public void create(Composite parent, IManagedContainer container, String productGroup, String factoryType,
+ String defaultDescription, ValidationContext context)
+ {
+ this.container = container;
+ this.productGroup = productGroup;
+ this.factoryType = factoryType;
+ this.defaultDescription = defaultDescription;
+ this.context = context;
+
+ create(parent);
+ }
+
+ protected void setResultDescription(String resultDescription)
+ {
+ String oldDescription = this.resultDescription;
+ if (!ObjectUtil.equals(resultDescription, oldDescription))
+ {
+ this.resultDescription = resultDescription;
+ fireEvent();
+ }
+ }
+
+ public void setValidationError(Object source, String message)
+ {
+ if (context != null)
+ {
+ context.setValidationError(source, message);
+ }
+ }
+
+ protected abstract void create(Composite parent);
+
+ public static Label addLabel(Composite parent, String label)
+ {
+ Label control = new Label(parent, SWT.NONE);
+ control.setText(label);
+ control.setLayoutData(UIUtil.createGridData(false, false));
+ return control;
+ }
+
+ public static Text addText(Composite parent, String label)
+ {
+ addLabel(parent, label);
+
+ Text control = new Text(parent, SWT.BORDER);
+ control.setLayoutData(UIUtil.createGridData(true, false));
+ return control;
+ }
+
+ /**
+ * @since 3.2
+ */
+ public static Combo addCombo(Composite parent, String label, List<String> choices)
+ {
+ addLabel(parent, label);
+
+ Combo control = new Combo(parent, SWT.SINGLE);
+ control.setLayoutData(UIUtil.createGridData(true, false));
+ for (String choice : choices)
+ {
+ control.add(choice);
+ }
+
+ return control;
+ }
+
+ public static Combo addCombo(Composite parent, String label, String... choices)
+ {
+ return addCombo(parent, label, Arrays.asList(choices));
+ }
+}

Back to the top