diff options
author | Eike Stepper | 2015-02-21 11:21:04 +0000 |
---|---|---|
committer | Eike Stepper | 2015-02-21 14:30:52 +0000 |
commit | 39354c367bba7df8b5c993b2462e495c4def1e28 (patch) | |
tree | a70ff9c9b8625e152e00ba980bf342b0cf377de4 /plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo | |
parent | d0cf654686666cdea5ff5e819e694bc11acc5e7e (diff) | |
download | cdo-39354c367bba7df8b5c993b2462e495c4def1e28.tar.gz cdo-39354c367bba7df8b5c993b2462e495c4def1e28.tar.xz cdo-39354c367bba7df8b5c993b2462e495c4def1e28.zip |
[458349] Consolidate UI
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=458349
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo')
5 files changed, 122 insertions, 4 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranchCreationContext.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranchCreationContext.java new file mode 100644 index 0000000000..2c42db7222 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranchCreationContext.java @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2004-2014 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.emf.cdo.common.branch; + +/** + * @author Eike Stepper + * @since 4.4 + */ +public interface CDOBranchCreationContext +{ + public CDOBranchPoint getBase(); +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOCommonUtil.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOCommonUtil.java index 6c32488a7e..a5023c7032 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOCommonUtil.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOCommonUtil.java @@ -41,6 +41,8 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Comparator; import java.util.Date; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * Various static methods that may help with I/O and time stamps. @@ -56,6 +58,12 @@ public final class CDOCommonUtil public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss'.'SSS"); /** + * @since 4.4 + */ + public static final Pattern DATE_PATTERN = Pattern + .compile("(\\d+)[ -/](\\d+)[ -/](\\d+)( +(\\d+):?(\\d*):?(\\d*)\\.?(\\d*))?"); + + /** * @since 4.2 */ public static final String SYSTEM_USER_ID = "CDO_SYSTEM"; //$NON-NLS-1$ @@ -221,7 +229,10 @@ public final class CDOCommonUtil return "*"; } - return DATE_FORMAT.format(new Date(timeStamp)); + synchronized (DATE_FORMAT) + { + return DATE_FORMAT.format(new Date(timeStamp)); + } } /** @@ -229,12 +240,29 @@ public final class CDOCommonUtil */ public static long parseTimeStamp(String timeStamp) throws ParseException { - if ("*".equals(timeStamp)) + String trimmed = timeStamp.trim(); + + if ("*".equals(trimmed)) { return CDORevision.UNSPECIFIED_DATE; } - return DATE_FORMAT.parse(timeStamp).getTime(); + Matcher matcher = DATE_PATTERN.matcher(trimmed); + if (!matcher.matches()) + { + throw new ParseException("Not a valid date: " + trimmed + " --> pattern = " + DATE_PATTERN, 0); + } + + timeStamp = matcher.group(1) + "-" + matcher.group(2) + "-" + matcher.group(3) + " " + safe(matcher.group(5)) + ":" + + safe(matcher.group(6)) + ":" + safe(matcher.group(7)) + "." + safe(matcher.group(8)); + + Date date = DATE_FORMAT.parse(timeStamp); + return date.getTime(); + } + + private static String safe(String value) + { + return StringUtil.isEmpty(value) ? "0" : value; } /** diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDORenameContext.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDORenameContext.java new file mode 100644 index 0000000000..13a9bc04cb --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDORenameContext.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2004-2014 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.emf.cdo.common.util; + +/** + * @author Eike Stepper + * @since 4.4 + */ +public interface CDORenameContext +{ + public String getType(); + + public String getName(); + + public void setName(String name); + + public String validateName(String name); +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchImpl.java index f89a015141..b876db4ed4 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchImpl.java @@ -11,8 +11,10 @@ */ package org.eclipse.emf.cdo.internal.common.branch; +import org.eclipse.emf.cdo.common.CDOCommonRepository; import org.eclipse.emf.cdo.common.branch.CDOBranch; import org.eclipse.emf.cdo.common.branch.CDOBranchChangedEvent.ChangeKind; +import org.eclipse.emf.cdo.common.branch.CDOBranchCreationContext; import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; import org.eclipse.emf.cdo.common.branch.CDOBranchVersion; import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch; @@ -325,6 +327,21 @@ public class CDOBranchImpl extends Container<CDOBranch> implements InternalCDOBr @SuppressWarnings({ "unchecked", "rawtypes" }) public Object getAdapter(Class adapter) { + if (adapter == CDOBranchCreationContext.class) + { + CDOCommonRepository repository = branchManager.getRepository(); + if (repository.isSupportingBranches()) + { + return new CDOBranchCreationContext() + { + public CDOBranchPoint getBase() + { + return getHead(); + } + }; + } + } + return AdapterUtil.adapt(this, adapter, false); } diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoImpl.java index afd7517a1f..186ed2e5c1 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoImpl.java @@ -10,7 +10,10 @@ */ package org.eclipse.emf.cdo.internal.common.commit; +import org.eclipse.emf.cdo.common.CDOCommonRepository; import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.branch.CDOBranchCreationContext; +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; import org.eclipse.emf.cdo.common.commit.CDOChangeKind; import org.eclipse.emf.cdo.common.commit.CDOChangeSetData; import org.eclipse.emf.cdo.common.commit.CDOCommitData; @@ -23,8 +26,11 @@ import org.eclipse.emf.cdo.common.util.CDOCommonUtil; import org.eclipse.emf.cdo.internal.common.branch.CDOBranchPointImpl; import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager; +import org.eclipse.net4j.util.AdapterUtil; import org.eclipse.net4j.util.CheckUtil; +import org.eclipse.core.runtime.IAdaptable; + import java.text.MessageFormat; import java.util.List; import java.util.Map; @@ -32,7 +38,7 @@ import java.util.Map; /** * @author Eike Stepper */ -public class CDOCommitInfoImpl extends CDOBranchPointImpl implements CDOCommitInfo +public class CDOCommitInfoImpl extends CDOBranchPointImpl implements CDOCommitInfo, IAdaptable { // private static final CDOCommitInfo[] NO_PARENTS = {}; @@ -156,6 +162,27 @@ public class CDOCommitInfoImpl extends CDOBranchPointImpl implements CDOCommitIn return commitData.getChangeKind(id); } + @SuppressWarnings({ "unchecked", "rawtypes" }) + public Object getAdapter(Class adapter) + { + if (adapter == CDOBranchCreationContext.class) + { + CDOCommonRepository repository = getBranch().getBranchManager().getRepository(); + if (repository.isSupportingBranches()) + { + return new CDOBranchCreationContext() + { + public CDOBranchPoint getBase() + { + return CDOCommitInfoImpl.this; + } + }; + } + } + + return AdapterUtil.adapt(this, adapter, false); + } + @Override public int hashCode() { |