Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2015-06-13 09:49:15 +0000
committerEike Stepper2015-06-13 10:03:59 +0000
commitecfe7762b683080904d7269b571baa10aaef58f6 (patch)
treeb56a6d33ae168966ed5dabca0502a5143fb43956 /plugins/org.eclipse.emf.cdo.explorer.ui
parent3604ce2e0da2759228172fa03fd61dba3e16c9b8 (diff)
downloadcdo-ecfe7762b683080904d7269b571baa10aaef58f6.tar.gz
cdo-ecfe7762b683080904d7269b571baa10aaef58f6.tar.xz
cdo-ecfe7762b683080904d7269b571baa10aaef58f6.zip
[458349] Consolidate UI
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=458349
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.explorer.ui')
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer.ui/META-INF/MANIFEST.MF24
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutDropAdapterAssistant.java57
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutBranchPointPage.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutLabelPage.java39
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutWizardPage.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/handlers/RepositoryCheckoutHandlerQuick.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/AbstractRepositoryPage.java57
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/RepositoryClonePage.java19
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/RepositoryLocalPage.java50
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/RepositoryRemotePage.java7
10 files changed, 185 insertions, 77 deletions
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.explorer.ui/META-INF/MANIFEST.MF
index c8ffeed18d..78976289df 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.emf.cdo.explorer.ui;singleton:=true
-Bundle-Version: 4.4.0.qualifier
+Bundle-Version: 4.4.100.qualifier
Bundle-Activator: org.eclipse.emf.cdo.explorer.ui.bundle.OM$Activator
Bundle-Vendor: %providerName
Bundle-ClassPath: .
@@ -24,15 +24,15 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
org.eclipse.emf.cdo.ui.shared;bundle-version="[4.0.0,5.0.0)",
org.eclipse.emf.cdo.ui.compare;bundle-version="[4.0.0,5.0.0)";resolution:=optional,
org.eclipse.emf.cdo.ui.team;bundle-version="[4.0.0,5.0.0)";resolution:=optional
-Export-Package: org.eclipse.emf.cdo.explorer.ui;version="4.4.0";x-internal:=true,
- org.eclipse.emf.cdo.explorer.ui.actions;version="4.4.0";x-internal:=true,
- org.eclipse.emf.cdo.explorer.ui.application;version="4.4.0";x-internal:=true,
- org.eclipse.emf.cdo.explorer.ui.bundle;version="4.4.0";x-internal:=true,
- org.eclipse.emf.cdo.explorer.ui.checkouts;version="4.4.0";x-internal:=true,
- org.eclipse.emf.cdo.explorer.ui.checkouts.actions;version="4.4.0";x-internal:=true,
- org.eclipse.emf.cdo.explorer.ui.checkouts.wizards;version="4.4.0";x-internal:=true,
- org.eclipse.emf.cdo.explorer.ui.handlers;version="4.4.0";x-internal:=true,
- org.eclipse.emf.cdo.explorer.ui.properties;version="4.4.0";x-internal:=true,
- org.eclipse.emf.cdo.explorer.ui.repositories;version="4.4.0";x-internal:=true,
- org.eclipse.emf.cdo.explorer.ui.repositories.wizards;version="4.4.0";x-internal:=true
+Export-Package: org.eclipse.emf.cdo.explorer.ui;version="4.4.100";x-internal:=true,
+ org.eclipse.emf.cdo.explorer.ui.actions;version="4.4.100";x-internal:=true,
+ org.eclipse.emf.cdo.explorer.ui.application;version="4.4.100";x-internal:=true,
+ org.eclipse.emf.cdo.explorer.ui.bundle;version="4.4.100";x-internal:=true,
+ org.eclipse.emf.cdo.explorer.ui.checkouts;version="4.4.100";x-internal:=true,
+ org.eclipse.emf.cdo.explorer.ui.checkouts.actions;version="4.4.100";x-internal:=true,
+ org.eclipse.emf.cdo.explorer.ui.checkouts.wizards;version="4.4.100";x-internal:=true,
+ org.eclipse.emf.cdo.explorer.ui.handlers;version="4.4.100";x-internal:=true,
+ org.eclipse.emf.cdo.explorer.ui.properties;version="4.4.100";x-internal:=true,
+ org.eclipse.emf.cdo.explorer.ui.repositories;version="4.4.100";x-internal:=true,
+ org.eclipse.emf.cdo.explorer.ui.repositories.wizards;version="4.4.100";x-internal:=true
Eclipse-BuddyPolicy: registered
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutDropAdapterAssistant.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutDropAdapterAssistant.java
index 4f3f07e879..fc62ec3e00 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutDropAdapterAssistant.java
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/CDOCheckoutDropAdapterAssistant.java
@@ -31,6 +31,7 @@ import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.net4j.util.AdapterUtil;
import org.eclipse.net4j.util.ObjectUtil;
+import org.eclipse.net4j.util.collection.Pair;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
@@ -82,10 +83,29 @@ public class CDOCheckoutDropAdapterAssistant extends CommonDropAdapterAssistant
@Override
public IStatus validateDrop(Object target, int dropOperation, TransferData transferType)
{
- CDOBranchPoint branchPoint = getSelectedBranchPoint(target, transferType);
- if (branchPoint != null)
+ Pair<CDOBranchPoint, CDOCheckout> result = getSelectedBranchPoint(target, dropOperation, transferType);
+ if (result != null)
{
- return Status.OK_STATUS;
+ CDOBranchPoint branchPoint = result.getElement1();
+ CDOCheckout checkout = result.getElement2();
+
+ if (dropOperation == DND.DROP_MOVE)
+ {
+ if (checkout.isReadOnly() || branchPoint.getTimeStamp() == CDOBranchPoint.UNSPECIFIED_DATE)
+ {
+ return Status.OK_STATUS;
+ }
+ }
+ else if (dropOperation == DND.DROP_COPY)
+ {
+ return Status.OK_STATUS;
+ }
+ else if (dropOperation == DND.DROP_LINK)
+ {
+ return Status.OK_STATUS;
+ }
+
+ return Status.CANCEL_STATUS;
}
if (dropOperation != DND.DROP_LINK)
@@ -116,19 +136,24 @@ public class CDOCheckoutDropAdapterAssistant extends CommonDropAdapterAssistant
TransferData transferType = dropAdapter.getCurrentTransfer();
int dropOperation = dropAdapter.getCurrentOperation();
- CDOBranchPoint branchPoint = getSelectedBranchPoint(target, transferType);
- if (branchPoint != null)
+ Pair<CDOBranchPoint, CDOCheckout> result = getSelectedBranchPoint(target, dropOperation, transferType);
+ if (result != null)
{
- CDOCheckout checkout = (CDOCheckout)target;
+ CDOBranchPoint branchPoint = result.getElement1();
+ CDOCheckout checkout = result.getElement2();
+
if (dropOperation == DND.DROP_MOVE)
{
- if (checkout.isOnline())
- {
- SwitchToActionProvider.switchTo(checkout, branchPoint);
- }
- else
+ if (checkout.isReadOnly() || branchPoint.getTimeStamp() == CDOBranchPoint.UNSPECIFIED_DATE)
{
- ReplaceWithActionProvider.replaceWith(checkout, branchPoint);
+ if (checkout.isOnline())
+ {
+ SwitchToActionProvider.switchTo(checkout, branchPoint);
+ }
+ else
+ {
+ ReplaceWithActionProvider.replaceWith(checkout, branchPoint);
+ }
}
}
else if (dropOperation == DND.DROP_COPY)
@@ -153,7 +178,8 @@ public class CDOCheckoutDropAdapterAssistant extends CommonDropAdapterAssistant
return Status.CANCEL_STATUS;
}
- private static CDOBranchPoint getSelectedBranchPoint(Object target, TransferData transferType)
+ private static Pair<CDOBranchPoint, CDOCheckout> getSelectedBranchPoint(Object target, int dropOperation,
+ TransferData transferType)
{
// Drag within Eclipse?
if (LocalSelectionTransfer.getTransfer().isSupportedType(transferType))
@@ -200,10 +226,7 @@ public class CDOCheckoutDropAdapterAssistant extends CommonDropAdapterAssistant
CDOSession session = CDOUtil.getSession(branchPoint);
if (session == checkout.getView().getSession())
{
- if (checkout.isReadOnly() || branchPoint.getTimeStamp() == CDOBranchPoint.UNSPECIFIED_DATE)
- {
- return branchPoint;
- }
+ return Pair.create(branchPoint, checkout);
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutBranchPointPage.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutBranchPointPage.java
index 75e43ad13e..c796762531 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutBranchPointPage.java
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutBranchPointPage.java
@@ -177,6 +177,7 @@ public class CheckoutBranchPointPage extends CheckoutWizardPage
CDOBranch branch = branchPoint.getBranch();
branchViewer.setSelection(new StructuredSelection(branch));
branchViewer.expandToLevel(branch, 1);
+ validate();
}
});
}
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutLabelPage.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutLabelPage.java
index 980c5116e2..66a4947dd2 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutLabelPage.java
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutLabelPage.java
@@ -20,6 +20,7 @@ import org.eclipse.emf.cdo.explorer.repositories.CDORepository;
import org.eclipse.emf.cdo.internal.explorer.AbstractElement;
import org.eclipse.emf.cdo.internal.explorer.checkouts.CDOCheckoutImpl;
+import org.eclipse.net4j.util.ObjectUtil;
import org.eclipse.net4j.util.StringUtil;
import org.eclipse.swt.SWT;
@@ -67,12 +68,12 @@ public class CheckoutLabelPage extends CheckoutWizardPage
public final void setLabel(String label)
{
- if (this.label != label)
+ if (!ObjectUtil.equals(this.label, label))
{
log("Setting label to " + label);
this.label = label;
- if (labelText != null)
+ if (labelText != null && !labelText.getText().equals(label))
{
labelText.setText(StringUtil.safe(label));
}
@@ -118,6 +119,7 @@ public class CheckoutLabelPage extends CheckoutWizardPage
{
public void modifyText(ModifyEvent e)
{
+ setLabel(labelText.getText());
validate();
}
});
@@ -156,7 +158,9 @@ public class CheckoutLabelPage extends CheckoutWizardPage
{
CheckoutWizard wizard = getWizard();
repositoryLabel.setText(wizard.getRepositoryPage().getRepository().getLabel());
- typeLabel.setText(wizard.getTypePage().getType());
+
+ String type = wizard.getTypePage().getType();
+ typeLabel.setText(type);
CDOBranchPoint branchPoint = wizard.getBranchPointPage().getBranchPoint();
branchLabel.setText(branchPoint.getBranch().getPathName());
@@ -165,25 +169,10 @@ public class CheckoutLabelPage extends CheckoutWizardPage
String rootObjectText = wizard.getRootObjectPage().getRootObjectText();
rootLabel.setText(rootObjectText);
- if (label == null)
+ if (StringUtil.isEmpty(label))
{
- Set<String> names = new HashSet<String>();
-
- CDOCheckoutManager checkoutManager = CDOExplorerUtil.getCheckoutManager();
- for (CDOCheckout checkout : checkoutManager.getCheckouts())
- {
- names.add(checkout.getLabel());
- }
-
- for (int i = 1; i < Integer.MAX_VALUE; i++)
- {
- String name = i == 1 ? rootObjectText : rootObjectText + " (" + i + ")";
- if (!names.contains(name))
- {
- setLabel(name);
- break;
- }
- }
+ String label = StringUtil.capAll(type.replace('-', ' ')) + " Checkout";
+ setLabel(getUniqueLabel(label));
}
labelText.setFocus();
@@ -211,13 +200,9 @@ public class CheckoutLabelPage extends CheckoutWizardPage
}
}
- CDOCheckoutManager checkoutManager = CDOExplorerUtil.getCheckoutManager();
- for (CDOCheckout checkout : checkoutManager.getCheckouts())
+ if (CDOExplorerUtil.getCheckoutManager().getCheckoutByLabel(label) != null)
{
- if (label.equals(checkout.getLabel()))
- {
- throw new ValidationProblem("Label is not unique.");
- }
+ throw new ValidationProblem("Label is not unique.");
}
return true;
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutWizardPage.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutWizardPage.java
index 3be71b6d5b..f3410d4f48 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutWizardPage.java
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/wizards/CheckoutWizardPage.java
@@ -152,6 +152,10 @@ public abstract class CheckoutWizardPage extends WizardPage
{
private static final long serialVersionUID = 1L;
+ public ValidationProblem()
+ {
+ }
+
public ValidationProblem(String message)
{
super(message);
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/handlers/RepositoryCheckoutHandlerQuick.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/handlers/RepositoryCheckoutHandlerQuick.java
index 8d15b811a1..53c08b917a 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/handlers/RepositoryCheckoutHandlerQuick.java
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/handlers/RepositoryCheckoutHandlerQuick.java
@@ -19,6 +19,7 @@ import org.eclipse.emf.cdo.explorer.ui.checkouts.wizards.CheckoutWizard;
import org.eclipse.emf.cdo.internal.explorer.checkouts.CDOCheckoutImpl;
import org.eclipse.net4j.util.AdapterUtil;
+import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.ui.handlers.AbstractBaseHandler;
import org.eclipse.core.commands.ExecutionEvent;
@@ -46,10 +47,11 @@ public class RepositoryCheckoutHandlerQuick extends AbstractBaseHandler<CDORepos
{
CDORepository repository = repositoryElement.getRepository();
String readOnly = (CDOCheckout.TYPE_ONLINE_HISTORICAL.equals(type) ? Boolean.TRUE : Boolean.FALSE).toString();
+ String label = StringUtil.capAll(type.replace('-', ' ')) + " Checkout";
Properties properties = new Properties();
properties.setProperty("type", type);
- properties.setProperty("label", CheckoutLabelPage.getUniqueLabel(repository.getLabel()));
+ properties.setProperty("label", CheckoutLabelPage.getUniqueLabel(label));
properties.setProperty("repository", repository.getID());
properties.setProperty("branchID", Integer.toString(repositoryElement.getBranchID()));
properties.setProperty("timeStamp", Long.toString(repositoryElement.getTimeStamp()));
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/AbstractRepositoryPage.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/AbstractRepositoryPage.java
index 125b4c10bd..ad6adf6696 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/AbstractRepositoryPage.java
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/AbstractRepositoryPage.java
@@ -10,7 +10,12 @@
*/
package org.eclipse.emf.cdo.explorer.ui.repositories.wizards;
+import org.eclipse.emf.cdo.explorer.CDOExplorerUtil;
+import org.eclipse.emf.cdo.explorer.repositories.CDORepository;
+import org.eclipse.emf.cdo.explorer.repositories.CDORepositoryManager;
import org.eclipse.emf.cdo.explorer.ui.bundle.OM;
+import org.eclipse.emf.cdo.explorer.ui.checkouts.wizards.CheckoutWizardPage.ValidationProblem;
+import org.eclipse.emf.cdo.internal.explorer.AbstractElement;
import org.eclipse.emf.cdo.internal.explorer.repositories.CDORepositoryImpl;
import org.eclipse.jface.wizard.IWizardPage;
@@ -26,7 +31,9 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
+import java.util.HashSet;
import java.util.Properties;
+import java.util.Set;
/**
* @author Eike Stepper
@@ -43,7 +50,7 @@ public abstract class AbstractRepositoryPage extends WizardPage implements Selec
{
super(pageName);
setImageDescriptor(OM.getImageDescriptor("icons/wiz/new_repo.gif"));
- this.defaultLabel = defaultLabel;
+ this.defaultLabel = getUniqueLabel(defaultLabel);
}
@Override
@@ -75,6 +82,13 @@ public abstract class AbstractRepositoryPage extends WizardPage implements Selec
labelText = new Text(container, SWT.BORDER);
labelText.setText(defaultLabel);
labelText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ labelText.addModifyListener(new ModifyListener()
+ {
+ public void modifyText(ModifyEvent e)
+ {
+ validate();
+ }
+ });
fillPage(container);
@@ -121,7 +135,24 @@ public abstract class AbstractRepositoryPage extends WizardPage implements Selec
String label = labelText.getText();
if (label.length() == 0)
{
- throw new Exception("Label is empty.");
+ throw new ValidationProblem("Label is empty.");
+ }
+
+ for (int i = 0; i < label.length(); i++)
+ {
+ char c = label.charAt(i);
+ for (int j = 0; j < AbstractElement.ILLEGAL_LABEL_CHARACTERS.length(); j++)
+ {
+ if (c == AbstractElement.ILLEGAL_LABEL_CHARACTERS.charAt(j))
+ {
+ throw new ValidationProblem("Invalid character: " + AbstractElement.ILLEGAL_LABEL_CHARACTERS.substring(j, 1));
+ }
+ }
+ }
+
+ if (CDOExplorerUtil.getRepositoryManager().getRepositoryByLabel(label) != null)
+ {
+ throw new ValidationProblem("Label is not unique.");
}
properties.setProperty(CDORepositoryImpl.PROP_LABEL, label);
@@ -146,4 +177,26 @@ public abstract class AbstractRepositoryPage extends WizardPage implements Selec
text.setLayoutData(gridData);
return text;
}
+
+ public static String getUniqueLabel(String label)
+ {
+ Set<String> names = new HashSet<String>();
+
+ CDORepositoryManager repositoryManager = CDOExplorerUtil.getRepositoryManager();
+ for (CDORepository repository : repositoryManager.getRepositories())
+ {
+ names.add(repository.getLabel());
+ }
+
+ for (int i = 1; i < Integer.MAX_VALUE; i++)
+ {
+ String name = i == 1 ? label : label + " (" + i + ")";
+ if (!names.contains(name))
+ {
+ return name;
+ }
+ }
+
+ throw new IllegalStateException("Too many repositories");
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/RepositoryClonePage.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/RepositoryClonePage.java
index 9c0c4c8929..66b58c3de2 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/RepositoryClonePage.java
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/RepositoryClonePage.java
@@ -10,6 +10,7 @@
*/
package org.eclipse.emf.cdo.explorer.ui.repositories.wizards;
+import org.eclipse.emf.cdo.explorer.ui.checkouts.wizards.CheckoutWizardPage.ValidationProblem;
import org.eclipse.emf.cdo.internal.explorer.repositories.CloneCDORepository;
import org.eclipse.emf.cdo.server.IRepositorySynchronizer;
@@ -35,9 +36,9 @@ public class RepositoryClonePage extends AbstractRepositoryPage
public RepositoryClonePage()
{
- super("clone", "Clone Repository 1");
+ super("clone", "Clone Repository");
setTitle("New Clone Repository");
- setMessage("Enter the label and the connection parameters of the new remote location.");
+ setMessage("Enter label and connection parameters of the new clone repository.");
}
@Override
@@ -78,13 +79,13 @@ public class RepositoryClonePage extends AbstractRepositoryPage
if (StringUtil.isEmpty(connectorDescription))
{
// TODO Port could be empty/invalid!
- throw new Exception("Host is empty.");
+ throw new ValidationProblem("Host is empty.");
}
String repositoryName = controller.getRepositoryName();
if (StringUtil.isEmpty(repositoryName))
{
- throw new Exception("Repository name is empty.");
+ throw new ValidationProblem("Repository name is empty.");
}
String reconnectSeconds = reconnectSecondsText.getText();
@@ -94,12 +95,12 @@ public class RepositoryClonePage extends AbstractRepositoryPage
int value = Integer.parseInt(reconnectSeconds);
if (value < 0)
{
- throw new Exception();
+ throw new ValidationProblem();
}
}
catch (Exception ex)
{
- throw new Exception("Invalid reconnect seconds.");
+ throw new ValidationProblem("Invalid reconnect seconds.");
}
String recommitSeconds = recommitSecondsText.getText();
@@ -109,12 +110,12 @@ public class RepositoryClonePage extends AbstractRepositoryPage
int value = Integer.parseInt(recommitSeconds);
if (value < 0)
{
- throw new Exception();
+ throw new ValidationProblem();
}
}
catch (Exception ex)
{
- throw new Exception("Invalid recommit seconds.");
+ throw new ValidationProblem("Invalid recommit seconds.");
}
String recommitAttempts = recommitAttemptsText.getText();
@@ -129,7 +130,7 @@ public class RepositoryClonePage extends AbstractRepositoryPage
}
catch (Exception ex)
{
- throw new Exception("Invalid recommit attempts.");
+ throw new ValidationProblem("Invalid recommit attempts.");
}
properties.setProperty(CloneCDORepository.PROP_CONNECTOR_TYPE, "tcp");
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/RepositoryLocalPage.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/RepositoryLocalPage.java
index 7e29615035..1f3fa81cbf 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/RepositoryLocalPage.java
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/RepositoryLocalPage.java
@@ -15,6 +15,7 @@ import org.eclipse.emf.cdo.explorer.repositories.CDORepository;
import org.eclipse.emf.cdo.explorer.repositories.CDORepository.IDGeneration;
import org.eclipse.emf.cdo.explorer.repositories.CDORepository.VersioningMode;
import org.eclipse.emf.cdo.explorer.repositories.CDORepositoryManager;
+import org.eclipse.emf.cdo.explorer.ui.checkouts.wizards.CheckoutWizardPage.ValidationProblem;
import org.eclipse.emf.cdo.internal.explorer.repositories.CDORepositoryImpl;
import org.eclipse.emf.cdo.internal.explorer.repositories.LocalCDORepository;
@@ -60,9 +61,9 @@ public class RepositoryLocalPage extends AbstractRepositoryPage
public RepositoryLocalPage()
{
- super("local", "Local Repository 1");
+ super("local", "Local Repository");
setTitle("New Local Repository");
- setMessage("Enter the label and the connection parameters of the new remote location.");
+ setMessage("Enter label and database parameters of the new local repository.");
CDORepositoryManager repositoryManager = CDOExplorerUtil.getRepositoryManager();
for (CDORepository repository : repositoryManager.getRepositories())
@@ -92,7 +93,7 @@ public class RepositoryLocalPage extends AbstractRepositoryPage
{
createLabel(container, "Repository name:");
nameText = new Text(container, SWT.BORDER);
- nameText.setText("repo2");
+ nameText.setText(getUniqueRepositoryName());
nameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
nameText.addModifyListener(this);
@@ -154,7 +155,18 @@ public class RepositoryLocalPage extends AbstractRepositoryPage
String name = nameText.getText();
if (StringUtil.isEmpty(name))
{
- throw new Exception("Name is empty.");
+ throw new ValidationProblem("Repository name is empty.");
+ }
+
+ for (CDORepository repository : CDOExplorerUtil.getRepositoryManager().getRepositories())
+ {
+ if (CDORepository.TYPE_LOCAL.equals(repository.getType()))
+ {
+ if (name.equals(repository.getName()))
+ {
+ throw new ValidationProblem("Repository name is not unique.");
+ }
+ }
}
properties.setProperty(LocalCDORepository.PROP_NAME, name);
@@ -198,12 +210,12 @@ public class RepositoryLocalPage extends AbstractRepositoryPage
}
catch (Exception ex)
{
- throw new Exception("Invalid TCP port.");
+ throw new ValidationProblem("Invalid TCP port.");
}
if (!isFreePort(port))
{
- throw new Exception("TCP port " + port + " is not available.");
+ throw new ValidationProblem("TCP port " + port + " is not available.");
}
properties.setProperty(LocalCDORepository.PROP_TCP_PORT, Integer.toString(port));
@@ -232,4 +244,30 @@ public class RepositoryLocalPage extends AbstractRepositoryPage
return IOUtil.isFreePort(port);
}
+
+ public static String getUniqueRepositoryName()
+ {
+ Set<String> names = new HashSet<String>();
+
+ CDORepositoryManager repositoryManager = CDOExplorerUtil.getRepositoryManager();
+ for (CDORepository repository : repositoryManager.getRepositories())
+ {
+ if (CDORepository.TYPE_LOCAL.equals(repository.getType()))
+ {
+ names.add(repository.getName());
+ }
+ }
+
+ String defaultName = "repo";
+ for (int i = 1; i < Integer.MAX_VALUE; i++)
+ {
+ String name = i == 1 ? defaultName : defaultName + i;
+ if (!names.contains(name))
+ {
+ return name;
+ }
+ }
+
+ throw new IllegalStateException("Too many repositories");
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/RepositoryRemotePage.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/RepositoryRemotePage.java
index 5e5cc6be76..f7463ead73 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/RepositoryRemotePage.java
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/RepositoryRemotePage.java
@@ -12,6 +12,7 @@ package org.eclipse.emf.cdo.explorer.ui.repositories.wizards;
import org.eclipse.emf.cdo.explorer.repositories.CDORepository.IDGeneration;
import org.eclipse.emf.cdo.explorer.repositories.CDORepository.VersioningMode;
+import org.eclipse.emf.cdo.explorer.ui.checkouts.wizards.CheckoutWizardPage.ValidationProblem;
import org.eclipse.emf.cdo.internal.explorer.repositories.RemoteCDORepository;
import org.eclipse.net4j.util.StringUtil;
@@ -29,9 +30,9 @@ public class RepositoryRemotePage extends AbstractRepositoryPage
public RepositoryRemotePage()
{
- super("remote", "Remote Repository 1");
+ super("remote", "Remote Repository");
setTitle("New Remote Repository");
- setMessage("Enter the label and the connection parameters of the new remote location.");
+ setMessage("Enter label and connection parameters of the new remote location.");
}
@Override
@@ -63,7 +64,7 @@ public class RepositoryRemotePage extends AbstractRepositoryPage
String repositoryName = controller.getRepositoryName();
if (StringUtil.isEmpty(repositoryName))
{
- throw new Exception("Repository name is empty.");
+ throw new ValidationProblem("Repository name is empty.");
}
properties.setProperty(RemoteCDORepository.PROP_CONNECTOR_TYPE, "tcp");

Back to the top