diff options
author | Eike Stepper | 2015-06-13 09:49:15 +0000 |
---|---|---|
committer | Eike Stepper | 2015-06-13 10:03:59 +0000 |
commit | ecfe7762b683080904d7269b571baa10aaef58f6 (patch) | |
tree | b56a6d33ae168966ed5dabca0502a5143fb43956 /plugins | |
parent | 3604ce2e0da2759228172fa03fd61dba3e16c9b8 (diff) | |
download | cdo-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')
16 files changed, 253 insertions, 116 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"); diff --git a/plugins/org.eclipse.emf.cdo.explorer/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.explorer/META-INF/MANIFEST.MF index a803f5d5a9..3df4f3e844 100644 --- a/plugins/org.eclipse.emf.cdo.explorer/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.cdo.explorer/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;singleton:=true -Bundle-Version: 4.4.0.qualifier +Bundle-Version: 4.5.0.qualifier Bundle-Activator: org.eclipse.emf.cdo.internal.explorer.bundle.OM$Activator Bundle-Vendor: %providerName Bundle-ClassPath: . @@ -23,11 +23,11 @@ Import-Package: org.h2;version="[1.0.0,2.0.0)";resolution:=optional, org.h2.jdbcx;version="[1.0.0,2.0.0)";resolution:=optional, org.h2.util;version="[1.0.0,2.0.0)";resolution:=optional, org.h2.value;version="[1.0.0,2.0.0)";resolution:=optional -Export-Package: org.eclipse.emf.cdo.explorer;version="4.4.0", - org.eclipse.emf.cdo.explorer.checkouts;version="4.4.0", - org.eclipse.emf.cdo.explorer.repositories;version="4.4.0", - org.eclipse.emf.cdo.internal.explorer;version="4.4.0";x-friends:="org.eclipse.emf.cdo.explorer.ui", - org.eclipse.emf.cdo.internal.explorer.bundle;version="4.4.0";x-internal:=true, - org.eclipse.emf.cdo.internal.explorer.checkouts;version="4.4.0";x-friends:="org.eclipse.emf.cdo.explorer.ui", - org.eclipse.emf.cdo.internal.explorer.repositories;version="4.4.0";x-friends:="org.eclipse.emf.cdo.explorer.ui" +Export-Package: org.eclipse.emf.cdo.explorer;version="4.5.0", + org.eclipse.emf.cdo.explorer.checkouts;version="4.5.0", + org.eclipse.emf.cdo.explorer.repositories;version="4.5.0", + org.eclipse.emf.cdo.internal.explorer;version="4.5.0";x-friends:="org.eclipse.emf.cdo.explorer.ui", + org.eclipse.emf.cdo.internal.explorer.bundle;version="4.5.0";x-internal:=true, + org.eclipse.emf.cdo.internal.explorer.checkouts;version="4.5.0";x-friends:="org.eclipse.emf.cdo.explorer.ui", + org.eclipse.emf.cdo.internal.explorer.repositories;version="4.5.0";x-friends:="org.eclipse.emf.cdo.explorer.ui" Eclipse-BuddyPolicy: registered diff --git a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/repositories/CDORepositoryManager.java b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/repositories/CDORepositoryManager.java index 3fadd248d8..6299906de9 100644 --- a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/repositories/CDORepositoryManager.java +++ b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/repositories/CDORepositoryManager.java @@ -32,6 +32,11 @@ public interface CDORepositoryManager extends CDOExplorerManager<CDORepository> public CDORepository getRepository(CDOSession session); + /** + * @since 4.5 + */ + public CDORepository getRepositoryByLabel(String label); + public CDORepository[] getRepositories(); public CDORepository addRepository(Properties properties); diff --git a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/AbstractElement.java b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/AbstractElement.java index 50aa6f2367..ef3970d082 100644 --- a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/AbstractElement.java +++ b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/AbstractElement.java @@ -151,15 +151,9 @@ public abstract class AbstractElement extends Notifier implements CDOExplorerEle } AbstractManager<?> manager = getManager(); - if (manager != null) + if (manager != null && manager.getElementByLabel(label) != null) { - for (CDOExplorerElement element : manager.getElements()) - { - if (ObjectUtil.equals(element.getLabel(), label)) - { - return "Label is not unique."; - } - } + return "Label is not unique."; } return null; diff --git a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/repositories/CDORepositoryManagerImpl.java b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/repositories/CDORepositoryManagerImpl.java index e368078207..3eaeb6e794 100644 --- a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/repositories/CDORepositoryManagerImpl.java +++ b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/repositories/CDORepositoryManagerImpl.java @@ -54,6 +54,11 @@ public class CDORepositoryManagerImpl extends AbstractManager<CDORepository>impl return sessionMap.get(session); } + public CDORepository getRepositoryByLabel(String label) + { + return getElementByLabel(label); + } + public CDORepository[] getRepositories() { return getElements(); 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 56befc6cbb..072ff46dfe 100644 --- a/plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.cdo.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.ui;singleton:=true -Bundle-Version: 4.4.0.qualifier +Bundle-Version: 4.4.100.qualifier Bundle-Activator: org.eclipse.emf.cdo.internal.ui.bundle.OM$Activator Bundle-Vendor: %providerName Bundle-ClassPath: . @@ -26,7 +26,7 @@ Require-Bundle: org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)";reso org.eclipse.emf.ecp.edit;bundle-version="[1.5.0,2.0.0)";resolution:=optional, org.eclipse.emf.ecp.edit.swt;bundle-version="[1.5.0,2.0.0)";resolution:=optional, org.eclipse.emf.ecp.ui.view.swt;bundle-version="[1.5.0,2.0.0)";resolution:=optional -Export-Package: org.eclipse.emf.cdo.internal.ui;version="4.4.0"; +Export-Package: org.eclipse.emf.cdo.internal.ui;version="4.4.100"; x-friends:="org.eclipse.emf.cdo.ui.defs, org.eclipse.emf.cdo.ui.ide, org.eclipse.emf.cdo.ui.location, @@ -36,7 +36,7 @@ Export-Package: org.eclipse.emf.cdo.internal.ui;version="4.4.0"; org.eclipse.emf.cdo.explorer.ui, org.eclipse.emf.cdo.ui.team, org.eclipse.emf.cdo.ui.compare", - org.eclipse.emf.cdo.internal.ui.actions;version="4.4.0"; + org.eclipse.emf.cdo.internal.ui.actions;version="4.4.100"; x-friends:="org.eclipse.emf.cdo.ui.defs, org.eclipse.emf.cdo.ui.ide, org.eclipse.emf.cdo.ui.location, @@ -46,7 +46,7 @@ Export-Package: org.eclipse.emf.cdo.internal.ui;version="4.4.0"; org.eclipse.emf.cdo.explorer.ui, org.eclipse.emf.cdo.ui.team, org.eclipse.emf.cdo.ui.compare", - org.eclipse.emf.cdo.internal.ui.handlers;version="4.4.0"; + org.eclipse.emf.cdo.internal.ui.handlers;version="4.4.100"; x-friends:="org.eclipse.emf.cdo.ui.defs, org.eclipse.emf.cdo.ui.ide, org.eclipse.emf.cdo.ui.location, @@ -56,9 +56,9 @@ Export-Package: org.eclipse.emf.cdo.internal.ui;version="4.4.0"; org.eclipse.emf.cdo.explorer.ui, org.eclipse.emf.cdo.ui.team, org.eclipse.emf.cdo.ui.compare", - org.eclipse.emf.cdo.internal.ui.actions.delegates;version="4.4.0";x-internal:=true, - org.eclipse.emf.cdo.internal.ui.bundle;version="4.4.0";x-internal:=true, - org.eclipse.emf.cdo.internal.ui.dialogs;version="4.4.0"; + org.eclipse.emf.cdo.internal.ui.actions.delegates;version="4.4.100";x-internal:=true, + org.eclipse.emf.cdo.internal.ui.bundle;version="4.4.100";x-internal:=true, + org.eclipse.emf.cdo.internal.ui.dialogs;version="4.4.100"; x-friends:="org.eclipse.emf.cdo.ui.defs, org.eclipse.emf.cdo.ui.ide, org.eclipse.emf.cdo.ui.location, @@ -68,7 +68,7 @@ Export-Package: org.eclipse.emf.cdo.internal.ui;version="4.4.0"; org.eclipse.emf.cdo.explorer.ui, org.eclipse.emf.cdo.ui.team, org.eclipse.emf.cdo.ui.compare", - org.eclipse.emf.cdo.internal.ui.dnd;version="4.4.0"; + org.eclipse.emf.cdo.internal.ui.dnd;version="4.4.100"; x-friends:="org.eclipse.emf.cdo.ui.defs, org.eclipse.emf.cdo.ui.ide, org.eclipse.emf.cdo.ui.location, @@ -78,7 +78,7 @@ Export-Package: org.eclipse.emf.cdo.internal.ui;version="4.4.0"; org.eclipse.emf.cdo.explorer.ui, org.eclipse.emf.cdo.ui.team, org.eclipse.emf.cdo.ui.compare", - org.eclipse.emf.cdo.internal.ui.editor;version="4.4.0"; + org.eclipse.emf.cdo.internal.ui.editor;version="4.4.100"; x-friends:="org.eclipse.emf.cdo.ui.defs, org.eclipse.emf.cdo.ui.ide, org.eclipse.emf.cdo.ui.location, @@ -88,7 +88,7 @@ Export-Package: org.eclipse.emf.cdo.internal.ui;version="4.4.0"; org.eclipse.emf.cdo.explorer.ui, org.eclipse.emf.cdo.ui.team, org.eclipse.emf.cdo.ui.compare", - org.eclipse.emf.cdo.internal.ui.filters;version="4.4.0"; + org.eclipse.emf.cdo.internal.ui.filters;version="4.4.100"; x-friends:="org.eclipse.emf.cdo.ui.defs, org.eclipse.emf.cdo.ui.ide, org.eclipse.emf.cdo.ui.location, @@ -98,7 +98,7 @@ Export-Package: org.eclipse.emf.cdo.internal.ui;version="4.4.0"; org.eclipse.emf.cdo.explorer.ui, org.eclipse.emf.cdo.ui.team, org.eclipse.emf.cdo.ui.compare", - org.eclipse.emf.cdo.internal.ui.history;version="4.4.0"; + org.eclipse.emf.cdo.internal.ui.history;version="4.4.100"; x-friends:="org.eclipse.emf.cdo.ui.defs, org.eclipse.emf.cdo.ui.ide, org.eclipse.emf.cdo.ui.location, @@ -108,7 +108,7 @@ Export-Package: org.eclipse.emf.cdo.internal.ui;version="4.4.0"; org.eclipse.emf.cdo.explorer.ui, org.eclipse.emf.cdo.ui.team, org.eclipse.emf.cdo.ui.compare", - org.eclipse.emf.cdo.internal.ui.messages;version="4.4.0"; + org.eclipse.emf.cdo.internal.ui.messages;version="4.4.100"; x-friends:="org.eclipse.emf.cdo.ui.defs, org.eclipse.emf.cdo.ui.ide, org.eclipse.emf.cdo.ui.location, @@ -118,7 +118,7 @@ Export-Package: org.eclipse.emf.cdo.internal.ui;version="4.4.0"; org.eclipse.emf.cdo.explorer.ui, org.eclipse.emf.cdo.ui.team, org.eclipse.emf.cdo.ui.compare", - org.eclipse.emf.cdo.internal.ui.perspectives;version="4.4.0"; + org.eclipse.emf.cdo.internal.ui.perspectives;version="4.4.100"; x-friends:="org.eclipse.emf.cdo.ui.defs, org.eclipse.emf.cdo.ui.ide, org.eclipse.emf.cdo.ui.location, @@ -128,7 +128,7 @@ Export-Package: org.eclipse.emf.cdo.internal.ui;version="4.4.0"; org.eclipse.emf.cdo.explorer.ui, org.eclipse.emf.cdo.ui.team, org.eclipse.emf.cdo.ui.compare", - org.eclipse.emf.cdo.internal.ui.preferences;version="4.4.0"; + org.eclipse.emf.cdo.internal.ui.preferences;version="4.4.100"; x-friends:="org.eclipse.emf.cdo.ui.defs, org.eclipse.emf.cdo.ui.ide, org.eclipse.emf.cdo.ui.location, @@ -138,7 +138,7 @@ Export-Package: org.eclipse.emf.cdo.internal.ui;version="4.4.0"; org.eclipse.emf.cdo.explorer.ui, org.eclipse.emf.cdo.ui.team, org.eclipse.emf.cdo.ui.compare", - org.eclipse.emf.cdo.internal.ui.transfer;version="4.4.0"; + org.eclipse.emf.cdo.internal.ui.transfer;version="4.4.100"; x-friends:="org.eclipse.emf.cdo.ui.defs, org.eclipse.emf.cdo.ui.ide, org.eclipse.emf.cdo.ui.location, @@ -148,7 +148,7 @@ Export-Package: org.eclipse.emf.cdo.internal.ui;version="4.4.0"; org.eclipse.emf.cdo.explorer.ui, org.eclipse.emf.cdo.ui.team, org.eclipse.emf.cdo.ui.compare", - org.eclipse.emf.cdo.internal.ui.views;version="4.4.0"; + org.eclipse.emf.cdo.internal.ui.views;version="4.4.100"; x-friends:="org.eclipse.emf.cdo.ui.defs, org.eclipse.emf.cdo.ui.ide, org.eclipse.emf.cdo.ui.location, @@ -158,5 +158,5 @@ Export-Package: org.eclipse.emf.cdo.internal.ui;version="4.4.0"; org.eclipse.emf.cdo.explorer.ui, org.eclipse.emf.cdo.ui.team, org.eclipse.emf.cdo.ui.compare", - org.eclipse.emf.cdo.ui;version="4.4.0", - org.eclipse.emf.cdo.ui.widgets;version="4.4.0" + org.eclipse.emf.cdo.ui;version="4.4.100", + org.eclipse.emf.cdo.ui.widgets;version="4.4.100" diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/widgets/SelectTimeStampComposite.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/widgets/SelectTimeStampComposite.java index 272819dcf5..f28d7621ab 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/widgets/SelectTimeStampComposite.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/widgets/SelectTimeStampComposite.java @@ -17,6 +17,7 @@ import org.eclipse.emf.cdo.internal.ui.dialogs.OpenAuditDialog; import org.eclipse.emf.cdo.internal.ui.messages.Messages; import org.eclipse.emf.cdo.ui.shared.SharedIcons; +import org.eclipse.net4j.util.StringUtil; import org.eclipse.net4j.util.ui.UIUtil; import org.eclipse.net4j.util.ui.ValidationContext; import org.eclipse.net4j.util.ui.ValidationParticipant; @@ -73,7 +74,7 @@ public class SelectTimeStampComposite extends Composite implements ValidationPar */ public SelectTimeStampComposite(Composite parent, int style) { - this(parent, style, null, CDOBranchPoint.INVALID_DATE); + this(parent, style, null, CDOBranchPoint.UNSPECIFIED_DATE); } public SelectTimeStampComposite(Composite parent, int style, CDOBranch branch, long timeStamp) @@ -123,7 +124,8 @@ public class SelectTimeStampComposite extends Composite implements ValidationPar timeText = new Text(pointGroup, SWT.BORDER); timeText.setLayoutData(createTimeGridData()); - timeText.setText(CDOCommonUtil.formatTimeStamp(timeStamp)); + timeText.setText(CDOCommonUtil + .formatTimeStamp(timeStamp > CDOBranchPoint.UNSPECIFIED_DATE ? timeStamp : System.currentTimeMillis())); timeText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) @@ -176,7 +178,6 @@ public class SelectTimeStampComposite extends Composite implements ValidationPar this.timeStamp = timeStamp; setBranch(branch); - // setTimeStamp(timeStamp); } public ValidationContext getValidationContext() @@ -283,10 +284,34 @@ public class SelectTimeStampComposite extends Composite implements ValidationPar { try { - setTimeStamp(CDOCommonUtil.parseTimeStamp(timeText.getText())); + String text = timeText.getText(); + if (StringUtil.isEmpty(text)) + { + if (validationContext != null) + { + validationContext.setValidationError(timeText, "Please enter a valid time stamp."); + } + + return; + } + + long timeStamp = CDOCommonUtil.parseTimeStamp(text); + setTimeStamp(timeStamp); + if (validationContext != null) { - validationContext.setValidationError(timeText, null); + String message = null; + + if (branch != null && timeStamp != CDOBranchPoint.UNSPECIFIED_DATE && timeStamp != CDOBranchPoint.INVALID_DATE) + { + long repositoryCreation = branch.getBranchManager().getMainBranch().getBase().getTimeStamp(); + if (timeStamp < repositoryCreation) + { + message = "The repository did not exist before " + CDOCommonUtil.formatTimeStamp(repositoryCreation) + "."; + } + } + + validationContext.setValidationError(timeText, message); } } catch (ParseException ex) |