Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Pazderski2019-05-17 11:10:34 +0000
committerPaul Pazderski2019-05-18 12:52:49 +0000
commit5e9e26b1abe5bd1df37faa91fde2d87fd79ed06b (patch)
tree8e5ee9064468d7d051715dcb67637b08e0c01ad0
parent47b1fa3fbb58588f218c6138e4bcd9ecbcc5d036 (diff)
downloadeclipse.platform.team-5e9e26b1abe5bd1df37faa91fde2d87fd79ed06b.tar.gz
eclipse.platform.team-5e9e26b1abe5bd1df37faa91fde2d87fd79ed06b.tar.xz
eclipse.platform.team-5e9e26b1abe5bd1df37faa91fde2d87fd79ed06b.zip
Bug 547304 - [cleanup] Fix wrong line delimiters
This updates all Java files with wrong or mixed line delimiters to use Unix style delimiters. The change includes only whitespace formatting and no code changes. Change-Id: I1f6bc53b2a6827208b42ec562a855874d9ce69ae
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/ICompareFilter.java194
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/AbstractContentComparator.java214
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RegexSyncInfoFilter.java134
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RangeDifferenceComparator.java150
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RegexDiffComparator.java146
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RegexDiffFilter.java128
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/SaveableCompareEditorInputTest.java862
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/RepositoriesViewTests.java508
8 files changed, 1168 insertions, 1168 deletions
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/ICompareFilter.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/ICompareFilter.java
index 4a9ba830e..354c8094c 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/ICompareFilter.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/ICompareFilter.java
@@ -1,100 +1,100 @@
-package org.eclipse.compare;
-
-import java.util.HashMap;
-
-import org.eclipse.jface.text.IRegion;
-
-/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation and others.
+package org.eclipse.compare;
+
+import java.util.HashMap;
+
+import org.eclipse.jface.text.IRegion;
+
+/*******************************************************************************
+ * Copyright (c) 2013 IBM Corporation and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-/**
- * A filter that can be applied during the comparison of documents that can be
- * used to customize the detection of text differences via the compareFilter
- * extension point. Filters are exposed as toggle actions in the compare viewer.
- *
- * @noreference This interface is not intended to be referenced by clients
- * @since 3.6
- */
-public interface ICompareFilter {
-
- /**
- * Key for the <code>String</code> of the line of text being compared.
- */
- public static final String THIS_LINE = "THIS_LINE"; //$NON-NLS-1$
-
- /**
- * Key for the <code>Character</code> representing contributor of this line.
- * Value is either 'A' for ancestor, 'L' for left, or 'R' for right.
- */
- public static final String THIS_CONTRIBUTOR = "THIS_CONTRIBUTOR"; //$NON-NLS-1$
-
- /**
- * Key for the <code>String</code> of the line of text this line is being
- * compared to.
- */
- public static final String OTHER_LINE = "OTHER_LINE"; //$NON-NLS-1$
-
- /**
- * Key for the <code>Character</code> representing contributor of the other
- * line. Value is either 'A' for ancestor, 'L' for left, or 'R' for right.
- */
- public static final String OTHER_CONTRIBUTOR = "OTHER_CONTRIBUTOR"; //$NON-NLS-1$
-
- /**
- * Forwards the current input objects of the compare
- *
- * @param input
- * the merge viewer input
- * @param ancestor
- * input into ancestor viewer
- * @param left
- * input into left viewer
- * @param right
- * input into right viewer
- */
- public void setInput(Object input, Object ancestor, Object left,
- Object right);
-
- /**
- * Identifies the regions of a line of text in a comparison that should be
- * ignored for comparison purposes.
- *
- * @param lineComparison
- * contains values for the keys <CODE>THIS_LINE</CODE>,
- * <CODE>THIS_CONTRIBUTOR</CODE>, <CODE>OTHER_LINE</CODE> and
- * <CODE>OTHER_CONTRIBUTOR</CODE>
- * @return Regions of <code>THIS_LINE</code> to be ignored for comparison
- * purposes.
- */
- public IRegion[] getFilteredRegions(HashMap lineComparison);
-
- /**
- * Returns whether the filter should be enabled when first initialized
- *
- * @return default enablement
- */
- public boolean isEnabledInitially();
-
- /**
- * Because the comparison routine may compare each line multiple times to
- * other lines, the ignored regions may need to be calculated multiple times
- * for the same line during a comparison. If the ignored regions for each
- * line will be the same regardless of what line it is being compared to,
- * returning <code>true</code> to this method will cause the ignored region
- * calculations to be re-used and improve the performance of the comparison.
- *
- * @return ignored region results can be cached
- */
- public boolean canCacheFilteredRegions();
-}
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+/**
+ * A filter that can be applied during the comparison of documents that can be
+ * used to customize the detection of text differences via the compareFilter
+ * extension point. Filters are exposed as toggle actions in the compare viewer.
+ *
+ * @noreference This interface is not intended to be referenced by clients
+ * @since 3.6
+ */
+public interface ICompareFilter {
+
+ /**
+ * Key for the <code>String</code> of the line of text being compared.
+ */
+ public static final String THIS_LINE = "THIS_LINE"; //$NON-NLS-1$
+
+ /**
+ * Key for the <code>Character</code> representing contributor of this line.
+ * Value is either 'A' for ancestor, 'L' for left, or 'R' for right.
+ */
+ public static final String THIS_CONTRIBUTOR = "THIS_CONTRIBUTOR"; //$NON-NLS-1$
+
+ /**
+ * Key for the <code>String</code> of the line of text this line is being
+ * compared to.
+ */
+ public static final String OTHER_LINE = "OTHER_LINE"; //$NON-NLS-1$
+
+ /**
+ * Key for the <code>Character</code> representing contributor of the other
+ * line. Value is either 'A' for ancestor, 'L' for left, or 'R' for right.
+ */
+ public static final String OTHER_CONTRIBUTOR = "OTHER_CONTRIBUTOR"; //$NON-NLS-1$
+
+ /**
+ * Forwards the current input objects of the compare
+ *
+ * @param input
+ * the merge viewer input
+ * @param ancestor
+ * input into ancestor viewer
+ * @param left
+ * input into left viewer
+ * @param right
+ * input into right viewer
+ */
+ public void setInput(Object input, Object ancestor, Object left,
+ Object right);
+
+ /**
+ * Identifies the regions of a line of text in a comparison that should be
+ * ignored for comparison purposes.
+ *
+ * @param lineComparison
+ * contains values for the keys <CODE>THIS_LINE</CODE>,
+ * <CODE>THIS_CONTRIBUTOR</CODE>, <CODE>OTHER_LINE</CODE> and
+ * <CODE>OTHER_CONTRIBUTOR</CODE>
+ * @return Regions of <code>THIS_LINE</code> to be ignored for comparison
+ * purposes.
+ */
+ public IRegion[] getFilteredRegions(HashMap lineComparison);
+
+ /**
+ * Returns whether the filter should be enabled when first initialized
+ *
+ * @return default enablement
+ */
+ public boolean isEnabledInitially();
+
+ /**
+ * Because the comparison routine may compare each line multiple times to
+ * other lines, the ignored regions may need to be calculated multiple times
+ * for the same line during a comparison. If the ignored regions for each
+ * line will be the same regardless of what line it is being compared to,
+ * returning <code>true</code> to this method will cause the ignored region
+ * calculations to be re-used and improve the performance of the comparison.
+ *
+ * @return ignored region results can be cached
+ */
+ public boolean canCacheFilteredRegions();
+}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/AbstractContentComparator.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/AbstractContentComparator.java
index 492d9bf10..c0de0d6b3 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/AbstractContentComparator.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/AbstractContentComparator.java
@@ -1,111 +1,111 @@
-/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.core.subscribers;
-
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.history.IFileRevision;
-import org.eclipse.team.core.variants.IResourceVariant;
-import org.eclipse.team.internal.core.Policy;
-import org.eclipse.team.internal.core.TeamPlugin;
-
-/**
- * Compare local and remote contents.
- *
- * This comparator makes use of the <code>IStorage</code> provided by
- * an <code>IResourceVariant</code> or an <code>IFileRevision</code>to obtain the remote contents.
- * This means that the comparison may contact the server unless the contents
- * were cached locally by a previous operation. The caching of remote
- * contents is subscriber specific.
- */
-public abstract class AbstractContentComparator {
- private boolean ignoreWhitespace = false;
-
- public AbstractContentComparator(boolean ignoreWhitespace) {
- this.ignoreWhitespace = ignoreWhitespace;
- }
-
- public boolean compare(IResource e1, IResourceVariant e2, IProgressMonitor monitor) {
- return compareObjects(e1, e2, monitor);
- }
-
- public boolean compare(IResource e1, IFileRevision e2, IProgressMonitor monitor) {
- return compareObjects(e1, e2, monitor);
- }
-
- private boolean compareObjects(Object e1, Object e2, IProgressMonitor monitor) {
- InputStream is1 = null;
- InputStream is2 = null;
- try {
- monitor.beginTask(null, 100);
- is1 = getContents(e1, Policy.subMonitorFor(monitor, 30));
- is2 = getContents(e2, Policy.subMonitorFor(monitor, 30));
- return contentsEqual(Policy.subMonitorFor(monitor, 40), is1, is2, shouldIgnoreWhitespace());
- } catch (TeamException e) {
- TeamPlugin.log(e);
- return false;
- } finally {
- try {
- try {
- if (is1 != null) {
- is1.close();
- }
- } finally {
- if (is2 != null) {
- is2.close();
- }
- }
- } catch (IOException e) {
- // Ignore
- }
- monitor.done();
- }
- }
-
- protected boolean shouldIgnoreWhitespace() {
- return ignoreWhitespace;
- }
-
- abstract protected boolean contentsEqual(IProgressMonitor monitor, InputStream is1, InputStream is2,
- boolean ignoreWhitespace);
-
- private InputStream getContents(Object resource, IProgressMonitor monitor)
- throws TeamException {
- try {
- if (resource instanceof IFile) {
- return new BufferedInputStream(((IFile) resource).getContents());
- } else if (resource instanceof IResourceVariant) {
- IResourceVariant remote = (IResourceVariant) resource;
- if (!remote.isContainer()) {
- return new BufferedInputStream(remote.getStorage(monitor)
- .getContents());
- }
- } else if (resource instanceof IFileRevision) {
- IFileRevision remote = (IFileRevision) resource;
- return new BufferedInputStream(remote.getStorage(monitor)
- .getContents());
- }
- return null;
- } catch (CoreException e) {
- throw TeamException.asTeamException(e);
- }
- }
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.core.subscribers;
+
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.history.IFileRevision;
+import org.eclipse.team.core.variants.IResourceVariant;
+import org.eclipse.team.internal.core.Policy;
+import org.eclipse.team.internal.core.TeamPlugin;
+
+/**
+ * Compare local and remote contents.
+ *
+ * This comparator makes use of the <code>IStorage</code> provided by
+ * an <code>IResourceVariant</code> or an <code>IFileRevision</code>to obtain the remote contents.
+ * This means that the comparison may contact the server unless the contents
+ * were cached locally by a previous operation. The caching of remote
+ * contents is subscriber specific.
+ */
+public abstract class AbstractContentComparator {
+ private boolean ignoreWhitespace = false;
+
+ public AbstractContentComparator(boolean ignoreWhitespace) {
+ this.ignoreWhitespace = ignoreWhitespace;
+ }
+
+ public boolean compare(IResource e1, IResourceVariant e2, IProgressMonitor monitor) {
+ return compareObjects(e1, e2, monitor);
+ }
+
+ public boolean compare(IResource e1, IFileRevision e2, IProgressMonitor monitor) {
+ return compareObjects(e1, e2, monitor);
+ }
+
+ private boolean compareObjects(Object e1, Object e2, IProgressMonitor monitor) {
+ InputStream is1 = null;
+ InputStream is2 = null;
+ try {
+ monitor.beginTask(null, 100);
+ is1 = getContents(e1, Policy.subMonitorFor(monitor, 30));
+ is2 = getContents(e2, Policy.subMonitorFor(monitor, 30));
+ return contentsEqual(Policy.subMonitorFor(monitor, 40), is1, is2, shouldIgnoreWhitespace());
+ } catch (TeamException e) {
+ TeamPlugin.log(e);
+ return false;
+ } finally {
+ try {
+ try {
+ if (is1 != null) {
+ is1.close();
+ }
+ } finally {
+ if (is2 != null) {
+ is2.close();
+ }
+ }
+ } catch (IOException e) {
+ // Ignore
+ }
+ monitor.done();
+ }
+ }
+
+ protected boolean shouldIgnoreWhitespace() {
+ return ignoreWhitespace;
+ }
+
+ abstract protected boolean contentsEqual(IProgressMonitor monitor, InputStream is1, InputStream is2,
+ boolean ignoreWhitespace);
+
+ private InputStream getContents(Object resource, IProgressMonitor monitor)
+ throws TeamException {
+ try {
+ if (resource instanceof IFile) {
+ return new BufferedInputStream(((IFile) resource).getContents());
+ } else if (resource instanceof IResourceVariant) {
+ IResourceVariant remote = (IResourceVariant) resource;
+ if (!remote.isContainer()) {
+ return new BufferedInputStream(remote.getStorage(monitor)
+ .getContents());
+ }
+ } else if (resource instanceof IFileRevision) {
+ IFileRevision remote = (IFileRevision) resource;
+ return new BufferedInputStream(remote.getStorage(monitor)
+ .getContents());
+ }
+ return null;
+ } catch (CoreException e) {
+ throw TeamException.asTeamException(e);
+ }
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RegexSyncInfoFilter.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RegexSyncInfoFilter.java
index 21576c8d1..f5d8d1666 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RegexSyncInfoFilter.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RegexSyncInfoFilter.java
@@ -1,70 +1,70 @@
-/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui.subscriber;
-
-import java.util.regex.Pattern;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.core.synchronize.SyncInfo;
-import org.eclipse.team.core.synchronize.SyncInfoFilter;
-import org.eclipse.team.core.variants.IResourceVariant;
-import org.eclipse.team.internal.core.subscribers.AbstractContentComparator;
-import org.eclipse.team.internal.ui.synchronize.RegexDiffComparator;
-
-/**
- * Selects <code>SyncInfo</code> whose all diffs match the given pattern.
- * This filter makes use of the <code>IStorage</code> provided by
- * an <code>IResourceVariant</code> to obtain the remote contents.
- * This means that the comparison may contact the server unless the contents
- * were cached locally by a previous operation. The caching of remote
- * contents is subscriber specific.
- * <p>
- * For folders, the comparison always returns <code>true</code>.
- *
- * @since 3.6
- */
-public class RegexSyncInfoFilter extends SyncInfoFilter {
-
- AbstractContentComparator criteria;
-
- boolean ignoreWhiteSpace;
-
- /**
- * Create a filter that does not ignore whitespace.
- *
- * @param pattern
- * regex pattern
- */
- public RegexSyncInfoFilter(String pattern) {
- this(false, pattern);
- }
-
- public RegexSyncInfoFilter(boolean ignoreWhitespace, String pattern) {
- criteria = new RegexDiffComparator(Pattern.compile(pattern,
- Pattern.DOTALL), ignoreWhitespace);
- }
-
- public boolean select(SyncInfo info, IProgressMonitor monitor) {
- IResourceVariant remote = info.getRemote();
- IResource local = info.getLocal();
- if (local.getType() != IResource.FILE)
- return true;
- if (remote == null)
- return !local.exists();
- if (!local.exists())
- return false;
- return criteria.compare(local, remote, monitor);
- }
-}
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ccvs.ui.subscriber;
+
+import java.util.regex.Pattern;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.core.synchronize.SyncInfo;
+import org.eclipse.team.core.synchronize.SyncInfoFilter;
+import org.eclipse.team.core.variants.IResourceVariant;
+import org.eclipse.team.internal.core.subscribers.AbstractContentComparator;
+import org.eclipse.team.internal.ui.synchronize.RegexDiffComparator;
+
+/**
+ * Selects <code>SyncInfo</code> whose all diffs match the given pattern.
+ * This filter makes use of the <code>IStorage</code> provided by
+ * an <code>IResourceVariant</code> to obtain the remote contents.
+ * This means that the comparison may contact the server unless the contents
+ * were cached locally by a previous operation. The caching of remote
+ * contents is subscriber specific.
+ * <p>
+ * For folders, the comparison always returns <code>true</code>.
+ *
+ * @since 3.6
+ */
+public class RegexSyncInfoFilter extends SyncInfoFilter {
+
+ AbstractContentComparator criteria;
+
+ boolean ignoreWhiteSpace;
+
+ /**
+ * Create a filter that does not ignore whitespace.
+ *
+ * @param pattern
+ * regex pattern
+ */
+ public RegexSyncInfoFilter(String pattern) {
+ this(false, pattern);
+ }
+
+ public RegexSyncInfoFilter(boolean ignoreWhitespace, String pattern) {
+ criteria = new RegexDiffComparator(Pattern.compile(pattern,
+ Pattern.DOTALL), ignoreWhitespace);
+ }
+
+ public boolean select(SyncInfo info, IProgressMonitor monitor) {
+ IResourceVariant remote = info.getRemote();
+ IResource local = info.getLocal();
+ if (local.getType() != IResource.FILE)
+ return true;
+ if (remote == null)
+ return !local.exists();
+ if (!local.exists())
+ return false;
+ return criteria.compare(local, remote, monitor);
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RangeDifferenceComparator.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RangeDifferenceComparator.java
index db893fc7d..467a4d616 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RangeDifferenceComparator.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RangeDifferenceComparator.java
@@ -1,78 +1,78 @@
-/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ui.synchronize;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.eclipse.compare.internal.DocLineComparator;
-import org.eclipse.compare.internal.Utilities;
-import org.eclipse.compare.rangedifferencer.RangeDifference;
-import org.eclipse.compare.rangedifferencer.RangeDifferencer;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.Region;
-import org.eclipse.team.internal.core.subscribers.AbstractContentComparator;
-
-/**
- * Compare differences between local and remote contents.
- * <p>
- * Subclass to specify a criterion for comparison.
- */
-public abstract class RangeDifferenceComparator extends
- AbstractContentComparator {
-
- public RangeDifferenceComparator(boolean ignoreWhitespace) {
- super(ignoreWhitespace);
- }
-
- /**
- * Return <code>true</code> if the provided differences match a criterion.
- *
- * @param ranges the differences found
- * @param lDoc the left document
- * @param rDoc the right document
- * @return <code>true</code> if all differences match a criterion
- */
- abstract protected boolean compareRangeDifferences(RangeDifference[] ranges,
- IDocument lDoc, IDocument rDoc);
-
- @Override
- protected boolean contentsEqual(IProgressMonitor monitor, InputStream is1,
- InputStream is2, boolean ignoreWhitespace) {
- try {
- final String left = Utilities.readString(is1, ResourcesPlugin.getEncoding());
- final String right = Utilities.readString(is2, ResourcesPlugin.getEncoding());
- return compareStrings(left, right, monitor);
- } catch (IOException e) {
- // ignore
- }
- return false;
- }
-
- private boolean compareStrings(String left, String right,
- IProgressMonitor monitor) {
- IDocument lDoc = new Document(left);
- IDocument rDoc = new Document(right);
- DocLineComparator sleft = new DocLineComparator(lDoc, new Region(0,
- lDoc.getLength()), shouldIgnoreWhitespace());
- DocLineComparator sright = new DocLineComparator(rDoc, new Region(0,
- rDoc.getLength()), shouldIgnoreWhitespace());
- final DocLineComparator sl = sleft, sr = sright;
- RangeDifference[] ranges = RangeDifferencer.findRanges(monitor, sl, sr);
- return compareRangeDifferences(ranges, lDoc, rDoc);
- }
-}
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.eclipse.compare.internal.DocLineComparator;
+import org.eclipse.compare.internal.Utilities;
+import org.eclipse.compare.rangedifferencer.RangeDifference;
+import org.eclipse.compare.rangedifferencer.RangeDifferencer;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.Region;
+import org.eclipse.team.internal.core.subscribers.AbstractContentComparator;
+
+/**
+ * Compare differences between local and remote contents.
+ * <p>
+ * Subclass to specify a criterion for comparison.
+ */
+public abstract class RangeDifferenceComparator extends
+ AbstractContentComparator {
+
+ public RangeDifferenceComparator(boolean ignoreWhitespace) {
+ super(ignoreWhitespace);
+ }
+
+ /**
+ * Return <code>true</code> if the provided differences match a criterion.
+ *
+ * @param ranges the differences found
+ * @param lDoc the left document
+ * @param rDoc the right document
+ * @return <code>true</code> if all differences match a criterion
+ */
+ abstract protected boolean compareRangeDifferences(RangeDifference[] ranges,
+ IDocument lDoc, IDocument rDoc);
+
+ @Override
+ protected boolean contentsEqual(IProgressMonitor monitor, InputStream is1,
+ InputStream is2, boolean ignoreWhitespace) {
+ try {
+ final String left = Utilities.readString(is1, ResourcesPlugin.getEncoding());
+ final String right = Utilities.readString(is2, ResourcesPlugin.getEncoding());
+ return compareStrings(left, right, monitor);
+ } catch (IOException e) {
+ // ignore
+ }
+ return false;
+ }
+
+ private boolean compareStrings(String left, String right,
+ IProgressMonitor monitor) {
+ IDocument lDoc = new Document(left);
+ IDocument rDoc = new Document(right);
+ DocLineComparator sleft = new DocLineComparator(lDoc, new Region(0,
+ lDoc.getLength()), shouldIgnoreWhitespace());
+ DocLineComparator sright = new DocLineComparator(rDoc, new Region(0,
+ rDoc.getLength()), shouldIgnoreWhitespace());
+ final DocLineComparator sl = sleft, sr = sright;
+ RangeDifference[] ranges = RangeDifferencer.findRanges(monitor, sl, sr);
+ return compareRangeDifferences(ranges, lDoc, rDoc);
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RegexDiffComparator.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RegexDiffComparator.java
index b7bedc8ab..9176a40c1 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RegexDiffComparator.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RegexDiffComparator.java
@@ -1,77 +1,77 @@
-/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ui.synchronize;
-
-import java.util.regex.Pattern;
-
-import org.eclipse.compare.internal.DocLineComparator;
-import org.eclipse.compare.rangedifferencer.RangeDifference;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-
-/**
- * Compute differences between local and remote contents and checks if all match
- * the given regex pattern. If there is at least one diff whose either left or
- * right side don't match the pattern
- * <code>{@link #compareRangeDifferences(RangeDifference[], IDocument, IDocument)}</code>
- * returns <code>false</code>.
- */
-public class RegexDiffComparator extends RangeDifferenceComparator {
-
- private Pattern pattern;
-
- public RegexDiffComparator(Pattern pattern, boolean ignoreWhitespace) {
- super(ignoreWhitespace);
- this.pattern = pattern;
- }
-
- @Override
- protected boolean compareRangeDifferences(RangeDifference[] ranges,
- IDocument lDoc, IDocument rDoc) {
- try {
- for (int i = 0; i < ranges.length; i++) {
- RangeDifference diff = ranges[i];
- if (diff.kind() == RangeDifference.NOCHANGE)
- continue;
-
- DocLineComparator sleft = new DocLineComparator(lDoc, null,
- shouldIgnoreWhitespace());
- DocLineComparator sright = new DocLineComparator(rDoc, null,
- shouldIgnoreWhitespace());
-
- IRegion lRegion = lDoc.getLineInformation(diff.leftStart());
- int leftEnd = sleft.getTokenStart(diff.leftStart()
- + diff.leftLength());
- String left = lDoc.get(lRegion.getOffset(),
- leftEnd - lRegion.getOffset());
- IRegion rRegion = rDoc.getLineInformation(diff.rightStart());
- int rightEnd = sright.getTokenStart(diff.rightStart()
- + diff.rightLength());
- String right = rDoc.get(rRegion.getOffset(),
- rightEnd - rRegion.getOffset());
-
- boolean m1 = pattern.matcher(left).matches();
- boolean m2 = pattern.matcher(right).matches();
-
- if (!m1 && !m2)
- // it's false that all diffs match the pattern
- return false;
- }
- } catch (BadLocationException e) {
- // ignore
- }
- return true;
- }
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize;
+
+import java.util.regex.Pattern;
+
+import org.eclipse.compare.internal.DocLineComparator;
+import org.eclipse.compare.rangedifferencer.RangeDifference;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+
+/**
+ * Compute differences between local and remote contents and checks if all match
+ * the given regex pattern. If there is at least one diff whose either left or
+ * right side don't match the pattern
+ * <code>{@link #compareRangeDifferences(RangeDifference[], IDocument, IDocument)}</code>
+ * returns <code>false</code>.
+ */
+public class RegexDiffComparator extends RangeDifferenceComparator {
+
+ private Pattern pattern;
+
+ public RegexDiffComparator(Pattern pattern, boolean ignoreWhitespace) {
+ super(ignoreWhitespace);
+ this.pattern = pattern;
+ }
+
+ @Override
+ protected boolean compareRangeDifferences(RangeDifference[] ranges,
+ IDocument lDoc, IDocument rDoc) {
+ try {
+ for (int i = 0; i < ranges.length; i++) {
+ RangeDifference diff = ranges[i];
+ if (diff.kind() == RangeDifference.NOCHANGE)
+ continue;
+
+ DocLineComparator sleft = new DocLineComparator(lDoc, null,
+ shouldIgnoreWhitespace());
+ DocLineComparator sright = new DocLineComparator(rDoc, null,
+ shouldIgnoreWhitespace());
+
+ IRegion lRegion = lDoc.getLineInformation(diff.leftStart());
+ int leftEnd = sleft.getTokenStart(diff.leftStart()
+ + diff.leftLength());
+ String left = lDoc.get(lRegion.getOffset(),
+ leftEnd - lRegion.getOffset());
+ IRegion rRegion = rDoc.getLineInformation(diff.rightStart());
+ int rightEnd = sright.getTokenStart(diff.rightStart()
+ + diff.rightLength());
+ String right = rDoc.get(rRegion.getOffset(),
+ rightEnd - rRegion.getOffset());
+
+ boolean m1 = pattern.matcher(left).matches();
+ boolean m2 = pattern.matcher(right).matches();
+
+ if (!m1 && !m2)
+ // it's false that all diffs match the pattern
+ return false;
+ }
+ } catch (BadLocationException e) {
+ // ignore
+ }
+ return true;
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RegexDiffFilter.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RegexDiffFilter.java
index 90076303d..9a01c1135 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RegexDiffFilter.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RegexDiffFilter.java
@@ -1,68 +1,68 @@
-/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ui.synchronize;
-
-import java.util.regex.Pattern;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.core.diff.DiffFilter;
-import org.eclipse.team.core.diff.IDiff;
-import org.eclipse.team.core.history.IFileRevision;
-import org.eclipse.team.core.mapping.provider.ResourceDiffTree;
-import org.eclipse.team.internal.core.mapping.SyncInfoToDiffConverter;
-import org.eclipse.team.internal.core.subscribers.AbstractContentComparator;
-
-public class RegexDiffFilter extends DiffFilter {
-
- AbstractContentComparator criteria;
-
- boolean ignoreWhiteSpace;
-
- /**
- * Create a filter that does not ignore whitespace.
- *
- * @param pattern
- * regex pattern
- */
- public RegexDiffFilter(String pattern) {
- this(false, pattern);
- }
-
- /**
- * Create a filter and configure how whitespace is handled.
- *
- * @param ignoreWhitespace
- * whether whitespace should be ignored
- * @param pattern
- * regex pattern
- */
- public RegexDiffFilter(boolean ignoreWhitespace, String pattern) {
- criteria = new RegexDiffComparator(Pattern.compile(pattern,
- Pattern.DOTALL), ignoreWhitespace);
- }
-
- @Override
- public boolean select(IDiff diff, IProgressMonitor monitor) {
- IFileRevision remote = SyncInfoToDiffConverter.getRemote(diff);
- IResource local = ResourceDiffTree.getResourceFor(diff);
- if (local == null || local.getType() != IResource.FILE)
- return true;
- if (remote == null)
- return !local.exists();
- if (!local.exists())
- return false;
- return criteria.compare(local, remote, monitor);
- }
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize;
+
+import java.util.regex.Pattern;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.core.diff.DiffFilter;
+import org.eclipse.team.core.diff.IDiff;
+import org.eclipse.team.core.history.IFileRevision;
+import org.eclipse.team.core.mapping.provider.ResourceDiffTree;
+import org.eclipse.team.internal.core.mapping.SyncInfoToDiffConverter;
+import org.eclipse.team.internal.core.subscribers.AbstractContentComparator;
+
+public class RegexDiffFilter extends DiffFilter {
+
+ AbstractContentComparator criteria;
+
+ boolean ignoreWhiteSpace;
+
+ /**
+ * Create a filter that does not ignore whitespace.
+ *
+ * @param pattern
+ * regex pattern
+ */
+ public RegexDiffFilter(String pattern) {
+ this(false, pattern);
+ }
+
+ /**
+ * Create a filter and configure how whitespace is handled.
+ *
+ * @param ignoreWhitespace
+ * whether whitespace should be ignored
+ * @param pattern
+ * regex pattern
+ */
+ public RegexDiffFilter(boolean ignoreWhitespace, String pattern) {
+ criteria = new RegexDiffComparator(Pattern.compile(pattern,
+ Pattern.DOTALL), ignoreWhitespace);
+ }
+
+ @Override
+ public boolean select(IDiff diff, IProgressMonitor monitor) {
+ IFileRevision remote = SyncInfoToDiffConverter.getRemote(diff);
+ IResource local = ResourceDiffTree.getResourceFor(diff);
+ if (local == null || local.getType() != IResource.FILE)
+ return true;
+ if (remote == null)
+ return !local.exists();
+ if (!local.exists())
+ return false;
+ return criteria.compare(local, remote, monitor);
+ }
} \ No newline at end of file
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/SaveableCompareEditorInputTest.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/SaveableCompareEditorInputTest.java
index 3e2f44306..265450dde 100644
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/SaveableCompareEditorInputTest.java
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/SaveableCompareEditorInputTest.java
@@ -1,434 +1,434 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2013 IBM Corporation and others.
+/*******************************************************************************
+ * Copyright (c) 2011, 2013 IBM Corporation and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ui;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.Test;
-
-import org.eclipse.compare.CompareConfiguration;
-import org.eclipse.compare.CompareViewerSwitchingPane;
-import org.eclipse.compare.ITypedElement;
-import org.eclipse.compare.contentmergeviewer.TextMergeViewer;
-import org.eclipse.compare.internal.CompareEditor;
-import org.eclipse.compare.internal.CompareUIPlugin;
-import org.eclipse.compare.internal.MergeSourceViewer;
-import org.eclipse.compare.structuremergeviewer.Differencer;
-import org.eclipse.compare.structuremergeviewer.ICompareInput;
-import org.eclipse.compare.tests.ReflectionUtils;
-import org.eclipse.core.internal.runtime.RuntimeLog;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.ILogListener;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.team.internal.ui.mapping.AbstractCompareInput;
-import org.eclipse.team.internal.ui.mapping.CompareInputChangeNotifier;
-import org.eclipse.team.internal.ui.synchronize.LocalResourceTypedElement;
-import org.eclipse.team.internal.ui.synchronize.SaveablesCompareEditorInput;
-import org.eclipse.team.tests.core.TeamTest;
-import org.eclipse.team.ui.synchronize.SaveableCompareEditorInput;
-import org.eclipse.ui.PlatformUI;
-
-public class SaveableCompareEditorInputTest extends TeamTest {
-
- public static Test suite() {
- return suite(SaveableCompareEditorInputTest.class);
- }
-
- private static final String COMPARE_EDITOR = CompareUIPlugin.PLUGIN_ID
- + ".CompareEditor"; //$NON-NLS-1$
-
- private IFile file1;
- private IFile file2;
- private String appendFileContents = "_append";
- private String fileContents1 = "FileContents";
- private String fileContents2 = "FileContents2";
- private TestLogListener logListener = new TestLogListener();
- private IProject project;
-
- protected void setUp() throws Exception {
- super.setUp();
-
- project = createProject("Project_", new String[] {
- "File1.txt", "File2.txt" });
-
- file1 = project.getFile("File1.txt");
- file2 = project.getFile("File2.txt");
- file1.setContents(new ByteArrayInputStream(fileContents1.getBytes()),
- true, true, null);
- file2.setContents(new ByteArrayInputStream(fileContents2.getBytes()),
- true, true, null);
-
- RuntimeLog.addLogListener(logListener);
- }
-
- protected void tearDown() throws Exception {
- // remove log listener
- RuntimeLog.removeLogListener(logListener);
- super.tearDown();
- }
-
- private class TestFileElement implements ITypedElement {
-
- private IFile file;
-
- public IFile getFile() {
- return file;
- }
-
- public TestFileElement(IFile file) {
- super();
- this.file = file;
- }
-
- public String getName() {
- return file.getName();
- }
-
- public Image getImage() {
- return null;
- }
-
- public String getType() {
- return TEXT_TYPE;
- }
- }
-
- private class TestLogListener implements ILogListener {
- public void logging(IStatus status, String plugin) {
- if (status.getSeverity() == IStatus.ERROR)
- fail(status.toString());
- }
- }
-
- private class TestDiffNode extends AbstractCompareInput {
-
- private CompareInputChangeNotifier notifier = new CompareInputChangeNotifier() {
-
- private IResource getResource(ITypedElement el) {
- if (el instanceof LocalResourceTypedElement) {
- return ((LocalResourceTypedElement) el).getResource();
- }
- if (el instanceof TestFileElement) {
- return ((TestFileElement) el).getFile();
- }
- return null;
- }
-
- protected IResource[] getResources(ICompareInput input) {
-
- List resources = new ArrayList();
- if (getResource(getLeft()) != null) {
- resources.add(getResource(getLeft()));
- }
- if (getResource(getRight()) != null) {
- resources.add(getResource(getRight()));
- }
- return (IResource[]) resources.toArray(new IResource[2]);
- }
- };
-
- public TestDiffNode(ITypedElement left, ITypedElement right) {
- super(Differencer.CHANGE, null, left, right);
- }
-
- public void fireChange() {
- super.fireChange();
- }
-
- protected CompareInputChangeNotifier getChangeNotifier() {
- return notifier;
- }
-
- public boolean needsUpdate() {
- // The remote never changes
- return false;
- }
-
- public void update() {
- fireChange();
- }
- }
-
- private class TestSaveableEditorInput extends SaveableCompareEditorInput {
-
- protected ITypedElement left;
- protected ITypedElement right;
- private ICompareInput input;
-
- public Object getCompareResult() {
- return input;
- }
-
- public TestSaveableEditorInput(ITypedElement left, ITypedElement right,
- CompareConfiguration conf) {
- super(conf, PlatformUI.getWorkbench().getActiveWorkbenchWindow()
- .getActivePage());
- this.left = left;
- this.right = right;
- }
-
- protected ICompareInput prepareCompareInput(IProgressMonitor monitor)
- throws InvocationTargetException, InterruptedException {
- input = createCompareInput();
- getCompareConfiguration().setLeftEditable(true);
- getCompareConfiguration().setRightEditable(false);
- return null;
- }
-
- private ICompareInput createCompareInput() {
- return new TestDiffNode(left, right);
- }
-
- protected void fireInputChange() {
- ((TestDiffNode) getCompareResult()).fireChange();
- }
- }
-
- private void verifyDirtyStateChanges(
- TestSaveableEditorInput compareEditorInput)
- throws IllegalArgumentException, SecurityException,
- IllegalAccessException, NoSuchFieldException {
- Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
- .getShell();
-
- TextMergeViewer viewer = (TextMergeViewer) compareEditorInput
- .findContentViewer(null, compareEditorInput.input, shell);
- viewer.setInput(compareEditorInput.getCompareResult());
-
- MergeSourceViewer left = (MergeSourceViewer) ReflectionUtils.getField(
- viewer, "fLeft");
-
- StyledText leftText = left.getSourceViewer().getTextWidget();
-
- // modify the left side of editor
- leftText.append(appendFileContents);
-
- assertTrue(compareEditorInput.isDirty());
-
- // save editor
- viewer.flush(null);
-
- assertFalse(compareEditorInput.isDirty());
- }
-
- public void testDirtyFlagOnLocalResourceTypedElement()
- throws CoreException, InvocationTargetException,
- InterruptedException, IllegalArgumentException, SecurityException,
- IllegalAccessException, NoSuchFieldException,
- NoSuchMethodException, IOException {
-
- // Create left element by SaveableCompareEditorInput to be properly
- // saved, see javadoc to SaveableCompareEditorInput
- LocalResourceTypedElement el1 = (LocalResourceTypedElement) SaveableCompareEditorInput
- .createFileElement(file1);
- ITypedElement el2 = new TestFileElement(file2);
-
- CompareConfiguration conf = new CompareConfiguration();
- conf.setLeftEditable(true);
- TestSaveableEditorInput compareEditorInput = new TestSaveableEditorInput(
- el1, el2, conf);
-
- compareEditorInput.prepareCompareInput(null);
-
- verifyDirtyStateChanges(compareEditorInput);
-
- // check whether file was saved
-
- assertTrue(compareContent(new ByteArrayInputStream(
- (fileContents1 + appendFileContents).getBytes()),
- file1.getContents()));
- }
-
- public void testDirtyFlagOnCustomTypedElement() throws CoreException,
- InvocationTargetException, InterruptedException,
- IllegalArgumentException, SecurityException,
- IllegalAccessException, NoSuchFieldException,
- NoSuchMethodException, IOException {
-
- ITypedElement el1 = new TestFileElement(file1);
- ITypedElement el2 = new TestFileElement(file2);
-
- CompareConfiguration conf = new CompareConfiguration();
- conf.setLeftEditable(true);
- TestSaveableEditorInput compareEditorInput = new TestSaveableEditorInput(
- el1, el2, conf);
-
- compareEditorInput.prepareCompareInput(null);
-
- verifyDirtyStateChanges(compareEditorInput);
-
- /*
- * not checking if changes were saved because in this case saving is not
- * handled, see javadoc to SaveableCompareEditorInput.
- */
- }
-
- public void testDirtyFlagOnLocalResourceTypedElementAndEmptyRight()
- throws CoreException, InvocationTargetException,
- InterruptedException, IllegalArgumentException, SecurityException,
- IllegalAccessException, NoSuchFieldException,
- NoSuchMethodException, IOException {
-
- // Create left element by SaveableCompareEditorInput to be properly
- // saved, see javadoc to SaveableCompareEditorInput
- LocalResourceTypedElement el1 = (LocalResourceTypedElement) SaveableCompareEditorInput
- .createFileElement(file1);
- ITypedElement el2 = null;
-
- CompareConfiguration conf = new CompareConfiguration();
- conf.setLeftEditable(true);
- TestSaveableEditorInput compareEditorInput = new TestSaveableEditorInput(
- el1, el2, conf);
-
- compareEditorInput.prepareCompareInput(null);
-
- verifyDirtyStateChanges(compareEditorInput);
-
- // check whether file was saved
-
- assertTrue(compareContent(new ByteArrayInputStream(
- (fileContents1 + appendFileContents).getBytes()),
- file1.getContents()));
- }
-
- public void testDirtyFlagOnCustomTypedElementAndEmptyRight()
- throws CoreException, InvocationTargetException,
- InterruptedException, IllegalArgumentException, SecurityException,
- IllegalAccessException, NoSuchFieldException,
- NoSuchMethodException, IOException {
-
- ITypedElement el1 = new TestFileElement(file1);
- ITypedElement el2 = null;
-
- CompareConfiguration conf = new CompareConfiguration();
- conf.setLeftEditable(true);
- TestSaveableEditorInput compareEditorInput = new TestSaveableEditorInput(
- el1, el2, conf);
-
- compareEditorInput.prepareCompareInput(null);
-
- verifyDirtyStateChanges(compareEditorInput);
-
- /*
- * not checking if changes were saved because in this case saving is not
- * handled, see javadoc to SaveableCompareEditorInput.
- */
- }
-
- private void verifyModifyAndSaveBothSidesOfCompareEditor(String extention)
- throws InterruptedException, InvocationTargetException,
- IllegalArgumentException, SecurityException,
- IllegalAccessException, NoSuchFieldException, CoreException {
-
- // create files to compare
- IFile file1 = project.getFile("CompareFile1." + extention);
- IFile file2 = project.getFile("CompareFile2." + extention);
- file1.create(new ByteArrayInputStream(fileContents1.getBytes()), true,
- null);
- file2.create(new ByteArrayInputStream(fileContents2.getBytes()), true,
- null);
-
- // prepare comparison
- SaveablesCompareEditorInput input = new SaveablesCompareEditorInput(
- null, SaveablesCompareEditorInput.createFileElement(file1),
- SaveablesCompareEditorInput.createFileElement(file2),
- PlatformUI.getWorkbench().getActiveWorkbenchWindow()
- .getActivePage());
- input.run(null);
-
- // open CompareEditor
- CompareEditor editor = (CompareEditor) PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getActivePage()
- .openEditor(input, COMPARE_EDITOR, true);
-
- CompareViewerSwitchingPane pane = (CompareViewerSwitchingPane) ReflectionUtils
- .getField(input, "fContentInputPane", true);
-
- Viewer viewer = pane.getViewer();
-
- MergeSourceViewer left = (MergeSourceViewer) ReflectionUtils.getField(
- viewer, "fLeft", true);
- MergeSourceViewer right = (MergeSourceViewer) ReflectionUtils.getField(
- viewer, "fRight", true);
-
- // modify both sides of CompareEditor
- StyledText leftText = left.getSourceViewer().getTextWidget();
- StyledText rightText = right.getSourceViewer().getTextWidget();
- leftText.append(appendFileContents);
- rightText.append(appendFileContents);
-
- // save both sides
- editor.doSave(null);
-
- assertFalse(editor.isDirty());
-
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
- .closeEditor(editor, false);
-
- // validate if both sides where saved
- assertTrue(compareContent(new ByteArrayInputStream(
- (fileContents1 + appendFileContents).getBytes()),
- file1.getContents()));
- assertTrue(compareContent(new ByteArrayInputStream(
- (fileContents2 + appendFileContents).getBytes()),
- file2.getContents()));
- }
-
- public void testModifyAndSaveBothSidesOfCompareEditorHtml()
- throws IllegalArgumentException, SecurityException,
- InterruptedException, InvocationTargetException,
- IllegalAccessException, NoSuchFieldException, CoreException {
- verifyModifyAndSaveBothSidesOfCompareEditor("html");
- }
-
- public void testModifyAndSaveBothSidesOfCompareEditorTxt()
- throws IllegalArgumentException, SecurityException,
- InterruptedException, InvocationTargetException,
- IllegalAccessException, NoSuchFieldException, CoreException {
- verifyModifyAndSaveBothSidesOfCompareEditor("txt");
- }
-
- public void testModifyAndSaveBothSidesOfCompareEditorJava()
- throws IllegalArgumentException, SecurityException,
- InterruptedException, InvocationTargetException,
- IllegalAccessException, NoSuchFieldException, CoreException {
- verifyModifyAndSaveBothSidesOfCompareEditor("java");
- }
-
- public void testModifyAndSaveBothSidesOfCompareEditorXml()
- throws IllegalArgumentException, SecurityException,
- InterruptedException, InvocationTargetException,
- IllegalAccessException, NoSuchFieldException, CoreException {
- verifyModifyAndSaveBothSidesOfCompareEditor("xml");
- }
-
- public void testModifyAndSaveBothSidesOfCompareEditorProperties()
- throws IllegalArgumentException, SecurityException,
- InterruptedException, InvocationTargetException,
- IllegalAccessException, NoSuchFieldException, CoreException {
- verifyModifyAndSaveBothSidesOfCompareEditor("properties");
- }
-}
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.tests.ui;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Test;
+
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.CompareViewerSwitchingPane;
+import org.eclipse.compare.ITypedElement;
+import org.eclipse.compare.contentmergeviewer.TextMergeViewer;
+import org.eclipse.compare.internal.CompareEditor;
+import org.eclipse.compare.internal.CompareUIPlugin;
+import org.eclipse.compare.internal.MergeSourceViewer;
+import org.eclipse.compare.structuremergeviewer.Differencer;
+import org.eclipse.compare.structuremergeviewer.ICompareInput;
+import org.eclipse.compare.tests.ReflectionUtils;
+import org.eclipse.core.internal.runtime.RuntimeLog;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.ILogListener;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.team.internal.ui.mapping.AbstractCompareInput;
+import org.eclipse.team.internal.ui.mapping.CompareInputChangeNotifier;
+import org.eclipse.team.internal.ui.synchronize.LocalResourceTypedElement;
+import org.eclipse.team.internal.ui.synchronize.SaveablesCompareEditorInput;
+import org.eclipse.team.tests.core.TeamTest;
+import org.eclipse.team.ui.synchronize.SaveableCompareEditorInput;
+import org.eclipse.ui.PlatformUI;
+
+public class SaveableCompareEditorInputTest extends TeamTest {
+
+ public static Test suite() {
+ return suite(SaveableCompareEditorInputTest.class);
+ }
+
+ private static final String COMPARE_EDITOR = CompareUIPlugin.PLUGIN_ID
+ + ".CompareEditor"; //$NON-NLS-1$
+
+ private IFile file1;
+ private IFile file2;
+ private String appendFileContents = "_append";
+ private String fileContents1 = "FileContents";
+ private String fileContents2 = "FileContents2";
+ private TestLogListener logListener = new TestLogListener();
+ private IProject project;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ project = createProject("Project_", new String[] {
+ "File1.txt", "File2.txt" });
+
+ file1 = project.getFile("File1.txt");
+ file2 = project.getFile("File2.txt");
+ file1.setContents(new ByteArrayInputStream(fileContents1.getBytes()),
+ true, true, null);
+ file2.setContents(new ByteArrayInputStream(fileContents2.getBytes()),
+ true, true, null);
+
+ RuntimeLog.addLogListener(logListener);
+ }
+
+ protected void tearDown() throws Exception {
+ // remove log listener
+ RuntimeLog.removeLogListener(logListener);
+ super.tearDown();
+ }
+
+ private class TestFileElement implements ITypedElement {
+
+ private IFile file;
+
+ public IFile getFile() {
+ return file;
+ }
+
+ public TestFileElement(IFile file) {
+ super();
+ this.file = file;
+ }
+
+ public String getName() {
+ return file.getName();
+ }
+
+ public Image getImage() {
+ return null;
+ }
+
+ public String getType() {
+ return TEXT_TYPE;
+ }
+ }
+
+ private class TestLogListener implements ILogListener {
+ public void logging(IStatus status, String plugin) {
+ if (status.getSeverity() == IStatus.ERROR)
+ fail(status.toString());
+ }
+ }
+
+ private class TestDiffNode extends AbstractCompareInput {
+
+ private CompareInputChangeNotifier notifier = new CompareInputChangeNotifier() {
+
+ private IResource getResource(ITypedElement el) {
+ if (el instanceof LocalResourceTypedElement) {
+ return ((LocalResourceTypedElement) el).getResource();
+ }
+ if (el instanceof TestFileElement) {
+ return ((TestFileElement) el).getFile();
+ }
+ return null;
+ }
+
+ protected IResource[] getResources(ICompareInput input) {
+
+ List resources = new ArrayList();
+ if (getResource(getLeft()) != null) {
+ resources.add(getResource(getLeft()));
+ }
+ if (getResource(getRight()) != null) {
+ resources.add(getResource(getRight()));
+ }
+ return (IResource[]) resources.toArray(new IResource[2]);
+ }
+ };
+
+ public TestDiffNode(ITypedElement left, ITypedElement right) {
+ super(Differencer.CHANGE, null, left, right);
+ }
+
+ public void fireChange() {
+ super.fireChange();
+ }
+
+ protected CompareInputChangeNotifier getChangeNotifier() {
+ return notifier;
+ }
+
+ public boolean needsUpdate() {
+ // The remote never changes
+ return false;
+ }
+
+ public void update() {
+ fireChange();
+ }
+ }
+
+ private class TestSaveableEditorInput extends SaveableCompareEditorInput {
+
+ protected ITypedElement left;
+ protected ITypedElement right;
+ private ICompareInput input;
+
+ public Object getCompareResult() {
+ return input;
+ }
+
+ public TestSaveableEditorInput(ITypedElement left, ITypedElement right,
+ CompareConfiguration conf) {
+ super(conf, PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getActivePage());
+ this.left = left;
+ this.right = right;
+ }
+
+ protected ICompareInput prepareCompareInput(IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
+ input = createCompareInput();
+ getCompareConfiguration().setLeftEditable(true);
+ getCompareConfiguration().setRightEditable(false);
+ return null;
+ }
+
+ private ICompareInput createCompareInput() {
+ return new TestDiffNode(left, right);
+ }
+
+ protected void fireInputChange() {
+ ((TestDiffNode) getCompareResult()).fireChange();
+ }
+ }
+
+ private void verifyDirtyStateChanges(
+ TestSaveableEditorInput compareEditorInput)
+ throws IllegalArgumentException, SecurityException,
+ IllegalAccessException, NoSuchFieldException {
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getShell();
+
+ TextMergeViewer viewer = (TextMergeViewer) compareEditorInput
+ .findContentViewer(null, compareEditorInput.input, shell);
+ viewer.setInput(compareEditorInput.getCompareResult());
+
+ MergeSourceViewer left = (MergeSourceViewer) ReflectionUtils.getField(
+ viewer, "fLeft");
+
+ StyledText leftText = left.getSourceViewer().getTextWidget();
+
+ // modify the left side of editor
+ leftText.append(appendFileContents);
+
+ assertTrue(compareEditorInput.isDirty());
+
+ // save editor
+ viewer.flush(null);
+
+ assertFalse(compareEditorInput.isDirty());
+ }
+
+ public void testDirtyFlagOnLocalResourceTypedElement()
+ throws CoreException, InvocationTargetException,
+ InterruptedException, IllegalArgumentException, SecurityException,
+ IllegalAccessException, NoSuchFieldException,
+ NoSuchMethodException, IOException {
+
+ // Create left element by SaveableCompareEditorInput to be properly
+ // saved, see javadoc to SaveableCompareEditorInput
+ LocalResourceTypedElement el1 = (LocalResourceTypedElement) SaveableCompareEditorInput
+ .createFileElement(file1);
+ ITypedElement el2 = new TestFileElement(file2);
+
+ CompareConfiguration conf = new CompareConfiguration();
+ conf.setLeftEditable(true);
+ TestSaveableEditorInput compareEditorInput = new TestSaveableEditorInput(
+ el1, el2, conf);
+
+ compareEditorInput.prepareCompareInput(null);
+
+ verifyDirtyStateChanges(compareEditorInput);
+
+ // check whether file was saved
+
+ assertTrue(compareContent(new ByteArrayInputStream(
+ (fileContents1 + appendFileContents).getBytes()),
+ file1.getContents()));
+ }
+
+ public void testDirtyFlagOnCustomTypedElement() throws CoreException,
+ InvocationTargetException, InterruptedException,
+ IllegalArgumentException, SecurityException,
+ IllegalAccessException, NoSuchFieldException,
+ NoSuchMethodException, IOException {
+
+ ITypedElement el1 = new TestFileElement(file1);
+ ITypedElement el2 = new TestFileElement(file2);
+
+ CompareConfiguration conf = new CompareConfiguration();
+ conf.setLeftEditable(true);
+ TestSaveableEditorInput compareEditorInput = new TestSaveableEditorInput(
+ el1, el2, conf);
+
+ compareEditorInput.prepareCompareInput(null);
+
+ verifyDirtyStateChanges(compareEditorInput);
+
+ /*
+ * not checking if changes were saved because in this case saving is not
+ * handled, see javadoc to SaveableCompareEditorInput.
+ */
+ }
+
+ public void testDirtyFlagOnLocalResourceTypedElementAndEmptyRight()
+ throws CoreException, InvocationTargetException,
+ InterruptedException, IllegalArgumentException, SecurityException,
+ IllegalAccessException, NoSuchFieldException,
+ NoSuchMethodException, IOException {
+
+ // Create left element by SaveableCompareEditorInput to be properly
+ // saved, see javadoc to SaveableCompareEditorInput
+ LocalResourceTypedElement el1 = (LocalResourceTypedElement) SaveableCompareEditorInput
+ .createFileElement(file1);
+ ITypedElement el2 = null;
+
+ CompareConfiguration conf = new CompareConfiguration();
+ conf.setLeftEditable(true);
+ TestSaveableEditorInput compareEditorInput = new TestSaveableEditorInput(
+ el1, el2, conf);
+
+ compareEditorInput.prepareCompareInput(null);
+
+ verifyDirtyStateChanges(compareEditorInput);
+
+ // check whether file was saved
+
+ assertTrue(compareContent(new ByteArrayInputStream(
+ (fileContents1 + appendFileContents).getBytes()),
+ file1.getContents()));
+ }
+
+ public void testDirtyFlagOnCustomTypedElementAndEmptyRight()
+ throws CoreException, InvocationTargetException,
+ InterruptedException, IllegalArgumentException, SecurityException,
+ IllegalAccessException, NoSuchFieldException,
+ NoSuchMethodException, IOException {
+
+ ITypedElement el1 = new TestFileElement(file1);
+ ITypedElement el2 = null;
+
+ CompareConfiguration conf = new CompareConfiguration();
+ conf.setLeftEditable(true);
+ TestSaveableEditorInput compareEditorInput = new TestSaveableEditorInput(
+ el1, el2, conf);
+
+ compareEditorInput.prepareCompareInput(null);
+
+ verifyDirtyStateChanges(compareEditorInput);
+
+ /*
+ * not checking if changes were saved because in this case saving is not
+ * handled, see javadoc to SaveableCompareEditorInput.
+ */
+ }
+
+ private void verifyModifyAndSaveBothSidesOfCompareEditor(String extention)
+ throws InterruptedException, InvocationTargetException,
+ IllegalArgumentException, SecurityException,
+ IllegalAccessException, NoSuchFieldException, CoreException {
+
+ // create files to compare
+ IFile file1 = project.getFile("CompareFile1." + extention);
+ IFile file2 = project.getFile("CompareFile2." + extention);
+ file1.create(new ByteArrayInputStream(fileContents1.getBytes()), true,
+ null);
+ file2.create(new ByteArrayInputStream(fileContents2.getBytes()), true,
+ null);
+
+ // prepare comparison
+ SaveablesCompareEditorInput input = new SaveablesCompareEditorInput(
+ null, SaveablesCompareEditorInput.createFileElement(file1),
+ SaveablesCompareEditorInput.createFileElement(file2),
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getActivePage());
+ input.run(null);
+
+ // open CompareEditor
+ CompareEditor editor = (CompareEditor) PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage()
+ .openEditor(input, COMPARE_EDITOR, true);
+
+ CompareViewerSwitchingPane pane = (CompareViewerSwitchingPane) ReflectionUtils
+ .getField(input, "fContentInputPane", true);
+
+ Viewer viewer = pane.getViewer();
+
+ MergeSourceViewer left = (MergeSourceViewer) ReflectionUtils.getField(
+ viewer, "fLeft", true);
+ MergeSourceViewer right = (MergeSourceViewer) ReflectionUtils.getField(
+ viewer, "fRight", true);
+
+ // modify both sides of CompareEditor
+ StyledText leftText = left.getSourceViewer().getTextWidget();
+ StyledText rightText = right.getSourceViewer().getTextWidget();
+ leftText.append(appendFileContents);
+ rightText.append(appendFileContents);
+
+ // save both sides
+ editor.doSave(null);
+
+ assertFalse(editor.isDirty());
+
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
+ .closeEditor(editor, false);
+
+ // validate if both sides where saved
+ assertTrue(compareContent(new ByteArrayInputStream(
+ (fileContents1 + appendFileContents).getBytes()),
+ file1.getContents()));
+ assertTrue(compareContent(new ByteArrayInputStream(
+ (fileContents2 + appendFileContents).getBytes()),
+ file2.getContents()));
+ }
+
+ public void testModifyAndSaveBothSidesOfCompareEditorHtml()
+ throws IllegalArgumentException, SecurityException,
+ InterruptedException, InvocationTargetException,
+ IllegalAccessException, NoSuchFieldException, CoreException {
+ verifyModifyAndSaveBothSidesOfCompareEditor("html");
+ }
+
+ public void testModifyAndSaveBothSidesOfCompareEditorTxt()
+ throws IllegalArgumentException, SecurityException,
+ InterruptedException, InvocationTargetException,
+ IllegalAccessException, NoSuchFieldException, CoreException {
+ verifyModifyAndSaveBothSidesOfCompareEditor("txt");
+ }
+
+ public void testModifyAndSaveBothSidesOfCompareEditorJava()
+ throws IllegalArgumentException, SecurityException,
+ InterruptedException, InvocationTargetException,
+ IllegalAccessException, NoSuchFieldException, CoreException {
+ verifyModifyAndSaveBothSidesOfCompareEditor("java");
+ }
+
+ public void testModifyAndSaveBothSidesOfCompareEditorXml()
+ throws IllegalArgumentException, SecurityException,
+ InterruptedException, InvocationTargetException,
+ IllegalAccessException, NoSuchFieldException, CoreException {
+ verifyModifyAndSaveBothSidesOfCompareEditor("xml");
+ }
+
+ public void testModifyAndSaveBothSidesOfCompareEditorProperties()
+ throws IllegalArgumentException, SecurityException,
+ InterruptedException, InvocationTargetException,
+ IllegalAccessException, NoSuchFieldException, CoreException {
+ verifyModifyAndSaveBothSidesOfCompareEditor("properties");
+ }
+}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/RepositoriesViewTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/RepositoriesViewTests.java
index 78f7d9cd6..3ebc90b65 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/RepositoriesViewTests.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/RepositoriesViewTests.java
@@ -1,257 +1,257 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 IBM Corporation and others.
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 IBM Corporation and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.ui;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteFolder;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteResource;
-import org.eclipse.team.internal.ccvs.ui.model.AllRootsElement;
-import org.eclipse.team.internal.ccvs.ui.model.BranchCategory;
-import org.eclipse.team.internal.ccvs.ui.model.CVSTagElement;
-import org.eclipse.team.internal.ccvs.ui.model.RemoteContentProvider;
-import org.eclipse.team.internal.ccvs.ui.model.RemoteModule;
-import org.eclipse.team.internal.ccvs.ui.model.VersionCategory;
-import org.eclipse.team.internal.ccvs.ui.repo.RepositoryRoot;
-import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
-import org.eclipse.team.tests.ccvs.core.EclipseTest;
-
-public class RepositoriesViewTests extends EclipseTest {
-
- public RepositoriesViewTests(String testName) {
- super(testName);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- // clear repository root cache
- RepositoryRoot repositoryRoot = getRepositoryRoot();
- String remotePaths[] = repositoryRoot.getKnownRemotePaths();
- for (int i = 0; i < remotePaths.length; i++) {
- repositoryRoot.removeTags(remotePaths[i],
- repositoryRoot.getAllKnownTags(remotePaths[i]));
- }
- }
-
- private RepositoryRoot getRepositoryRoot() {
- RemoteContentProvider rcp = new RemoteContentProvider();
- AllRootsElement are = new AllRootsElement();
- Object[] repositoryRoots = rcp.getElements(are);
- for (int i = 0; i < repositoryRoots.length; i++) {
- RepositoryRoot repositoryRoot = (RepositoryRoot) repositoryRoots[i];
- if (getRepository().equals(repositoryRoot.getRoot())) {
- return repositoryRoot;
- }
- }
- fail(getRepository() + " not found");
- return null;
- }
-
- public static Test suite() {
- String testName = System.getProperty("eclipse.cvs.testName");
- if (testName == null) {
- TestSuite suite = new TestSuite(RepositoriesViewTests.class);
- return new CVSTestSetup(suite);
- } else {
- return new CVSTestSetup(new RepositoriesViewTests(testName));
- }
- }
-
- public void testBranchSubmoduleChildren() throws TeamException,
- CoreException {
-
- String time = Long.toString(System.currentTimeMillis());
- String moduleName = "TestBranchSubmoduleChildrenTestModule" + time;
- String branchName = "TestBranchSubmoduleChildrenBranch" + time;
- String versionName = "Root_" + branchName;
-
- // create project
- IProject project = getUniqueTestProject("TestBranchSubmoduleChildrenProject");
- // share project under module
- shareProject(getRepository(), project,
- moduleName + "/" + project.getName(), DEFAULT_MONITOR);
- assertValidCheckout(project);
-
- // add some files
- addResources(project, new String[] { "file1.txt" }, true);
-
- // make branch
- CVSTag version = new CVSTag(versionName, CVSTag.VERSION);
- CVSTag branch = new CVSTag(branchName, CVSTag.BRANCH);
-
- makeBranch(new IResource[] { project }, version, branch, true);
-
- // check if module is the only branch child
- RemoteContentProvider rcp = new RemoteContentProvider();
- Object[] categories = rcp.getChildren(getRepositoryRoot());
- assertEquals(4, categories.length);
- assertTrue(categories[1] instanceof BranchCategory);
- Object[] branches = rcp.getChildren(categories[1]);
- assertEquals(1, branches.length);
- assertEquals(branchName, ((CVSTagElement) (branches[0])).getTag()
- .getName());
- Object[] modules = rcp.getChildren(branches[0]);
- assertEquals(1, modules.length);
- assertEquals(moduleName, ((RemoteResource) modules[0]).getName());
-
- // check if after refresh module is still the only branch child
- branches = rcp.getChildren(categories[1]);
- assertEquals(1, branches.length);
- assertEquals(branchName, ((CVSTagElement) (branches[0])).getTag()
- .getName());
- modules = rcp.getChildren(branches[0]);
- assertEquals(1, modules.length);
- assertEquals(moduleName, ((RemoteResource) modules[0]).getName());
- }
-
- public void testTagSubmoduleChildren() throws TeamException, CoreException {
-
- String time = Long.toString(System.currentTimeMillis());
- String moduleName = "TestTagSubmoduleChildrenTestModule" + time;
- String versionName = "TestTagSubmoduleChildrenBranch" + time;
-
- // create project
- IProject project = getUniqueTestProject("TestTagSubmoduleChildrenProject");
- // share project under module
- shareProject(getRepository(), project,
- moduleName + "/" + project.getName(), DEFAULT_MONITOR);
- assertValidCheckout(project);
-
- // make some changes
- addResources(project, new String[] { "file1.txt" }, true);
-
- // tag project
- CVSTag tag = new CVSTag(versionName, CVSTag.VERSION);
-
- tagProject(project, tag, true);
-
-
- RemoteContentProvider rcp = new RemoteContentProvider();
- Object[] categories = rcp.getChildren(getRepositoryRoot());
- assertEquals(4, categories.length);
-
- // check if version exists for module
- assertTrue(categories[2] instanceof VersionCategory);
- Object[] modules = rcp.getChildren(categories[2]);
- for (int i = 0; i < modules.length; i++) {
- if (modules[i] instanceof RemoteModule
- && ((RemoteModule) (modules[i])).getCVSResource().getName()
- .equals(moduleName)) {
- Object folders[] = rcp.getChildren(modules[i]);
- assertEquals(1, folders.length);
- assertEquals(versionName, ((RemoteFolder) folders[0]).getTag()
- .getName());
- return;
- }
- }
- fail(moduleName + " not found");
- }
-
- public void testTagsOnDifferentLevels() throws CoreException {
- String time = Long.toString(System.currentTimeMillis());
- String firstModule = "Module_1" + time;
- String secondModule = "Module_2" + time;
- String secondModulePath = firstModule + "/" + secondModule;
- // Create repository data
- // Module_1/Project_1
- IProject project1 = getUniqueTestProject("Project_1");
- shareProject(getRepository(), project1,
- firstModule + "/" + project1.getName(), DEFAULT_MONITOR);
- // Module_1/Module_2/Project_2
- IProject project2 = getUniqueTestProject("Project_2");
- shareProject(getRepository(), project2, secondModulePath + "/"
- + project2.getName(), DEFAULT_MONITOR);
- // Module_1/Module_2/Project_3
- IProject project3 = getUniqueTestProject("Project_3");
- shareProject(getRepository(), project3, secondModulePath + "/"
- + project3.getName(), DEFAULT_MONITOR);
- // Module_1/Project_4
- IProject project4 = getUniqueTestProject("Project_4");
- shareProject(getRepository(), project4,
- firstModule + "/" + project4.getName(), DEFAULT_MONITOR);
-
- // Create branches
- String branch1 = "Branch_1" + time;
- String version1 = "Root_" + branch1;
- String branch2 = "Branch_2" + time;
- String version2 = "Root_" + branch2;
-
- // Tag projects:
- // Module_1/Project_1 -> [Branch_1][Branch_2]
- // Module_1/Module_2/Project_2 -> [Branch_1][Branch_2]
- // Module_1/Module_2/Project_3 -> [Branch_2]
- // Module_1/Project_4 -> [Branch_4]
- makeBranch(new IResource[] { project1, project2 }, new CVSTag(version1,
- CVSTag.VERSION), new CVSTag(branch1, CVSTag.BRANCH), true);
- makeBranch(new IResource[] { project1, project2, project2, project4 },
- new CVSTag(version2, CVSTag.VERSION), new CVSTag(branch2,
- CVSTag.BRANCH), true);
-
- // verify if tree structure is built from cache
- RemoteContentProvider rcp = new RemoteContentProvider();
- Object[] categories = rcp.getChildren(getRepositoryRoot());
- assertEquals(4, categories.length);
- assertTrue(categories[1] instanceof BranchCategory);
- Object[] branches = rcp.getChildren(categories[1]);
- assertEquals(2, branches.length); // should be [Branch_1] and [Branch_2]
- CVSTagElement branch1Element;
- CVSTagElement branch2Element;
- if (((CVSTagElement) branches[0]).getTag().getName().equals(branch1)) {
- branch1Element = (CVSTagElement) branches[0];
- branch2Element = (CVSTagElement) branches[1];
- } else {
- branch1Element = (CVSTagElement) branches[1];
- branch2Element = (CVSTagElement) branches[0];
- }
- Object[] modules = rcp.getChildren(branch1Element);
- assertEquals(1, modules.length); // should be [Branch_1]/Module_1
- assertEquals(firstModule, ((RemoteResource) modules[0]).getName());
- modules = rcp.getChildren(modules[0]);
- // should contain:
- // [Branch_1]/Module_1/Project_1
- // [Branch_1]/Module_1/Module_2
- assertEquals(2, modules.length);
- for (int i = 0; i < modules.length; i++) {
- if (((RemoteResource) (modules[i])).getName().equals(
- project1.getName())) {
- // Project_1 should have contents retrieved from CVS
- assertTrue(rcp.hasChildren(modules[i]));
- } else if (((RemoteResource) (modules[i])).getName().equals(
- secondModule)) {
- // should be only [Branch_1]/Module_1/Module_2/Project_2.
- // [Branch_1]/Module_1/Module_2/Project_3 should NOT be on the
- // list, it is not branched with Branch_1
- Object[] module2Children = rcp.getChildren(modules[i]);
- assertEquals(1, module2Children.length);
- assertEquals(project2.getName(),
- ((RemoteResource) module2Children[0]).getName());
- }
- }
- modules = rcp.getChildren(branch2Element);
- assertEquals(1, modules.length); // should be [Branch_2]/Module_1
- assertEquals(firstModule, ((RemoteResource) modules[0]).getName());
- // should contain:
- // [Branch_2]/Module_1/Project_1
- // [Branch_2]/Module_1/Module_2
- // [Branch_2]/Module_1/Project_4
- modules = rcp.getChildren(modules[0]);
- assertEquals(3, modules.length);
- }
-}
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.tests.ccvs.ui;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.internal.ccvs.core.CVSTag;
+import org.eclipse.team.internal.ccvs.core.resources.RemoteFolder;
+import org.eclipse.team.internal.ccvs.core.resources.RemoteResource;
+import org.eclipse.team.internal.ccvs.ui.model.AllRootsElement;
+import org.eclipse.team.internal.ccvs.ui.model.BranchCategory;
+import org.eclipse.team.internal.ccvs.ui.model.CVSTagElement;
+import org.eclipse.team.internal.ccvs.ui.model.RemoteContentProvider;
+import org.eclipse.team.internal.ccvs.ui.model.RemoteModule;
+import org.eclipse.team.internal.ccvs.ui.model.VersionCategory;
+import org.eclipse.team.internal.ccvs.ui.repo.RepositoryRoot;
+import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
+import org.eclipse.team.tests.ccvs.core.EclipseTest;
+
+public class RepositoriesViewTests extends EclipseTest {
+
+ public RepositoriesViewTests(String testName) {
+ super(testName);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ // clear repository root cache
+ RepositoryRoot repositoryRoot = getRepositoryRoot();
+ String remotePaths[] = repositoryRoot.getKnownRemotePaths();
+ for (int i = 0; i < remotePaths.length; i++) {
+ repositoryRoot.removeTags(remotePaths[i],
+ repositoryRoot.getAllKnownTags(remotePaths[i]));
+ }
+ }
+
+ private RepositoryRoot getRepositoryRoot() {
+ RemoteContentProvider rcp = new RemoteContentProvider();
+ AllRootsElement are = new AllRootsElement();
+ Object[] repositoryRoots = rcp.getElements(are);
+ for (int i = 0; i < repositoryRoots.length; i++) {
+ RepositoryRoot repositoryRoot = (RepositoryRoot) repositoryRoots[i];
+ if (getRepository().equals(repositoryRoot.getRoot())) {
+ return repositoryRoot;
+ }
+ }
+ fail(getRepository() + " not found");
+ return null;
+ }
+
+ public static Test suite() {
+ String testName = System.getProperty("eclipse.cvs.testName");
+ if (testName == null) {
+ TestSuite suite = new TestSuite(RepositoriesViewTests.class);
+ return new CVSTestSetup(suite);
+ } else {
+ return new CVSTestSetup(new RepositoriesViewTests(testName));
+ }
+ }
+
+ public void testBranchSubmoduleChildren() throws TeamException,
+ CoreException {
+
+ String time = Long.toString(System.currentTimeMillis());
+ String moduleName = "TestBranchSubmoduleChildrenTestModule" + time;
+ String branchName = "TestBranchSubmoduleChildrenBranch" + time;
+ String versionName = "Root_" + branchName;
+
+ // create project
+ IProject project = getUniqueTestProject("TestBranchSubmoduleChildrenProject");
+ // share project under module
+ shareProject(getRepository(), project,
+ moduleName + "/" + project.getName(), DEFAULT_MONITOR);
+ assertValidCheckout(project);
+
+ // add some files
+ addResources(project, new String[] { "file1.txt" }, true);
+
+ // make branch
+ CVSTag version = new CVSTag(versionName, CVSTag.VERSION);
+ CVSTag branch = new CVSTag(branchName, CVSTag.BRANCH);
+
+ makeBranch(new IResource[] { project }, version, branch, true);
+
+ // check if module is the only branch child
+ RemoteContentProvider rcp = new RemoteContentProvider();
+ Object[] categories = rcp.getChildren(getRepositoryRoot());
+ assertEquals(4, categories.length);
+ assertTrue(categories[1] instanceof BranchCategory);
+ Object[] branches = rcp.getChildren(categories[1]);
+ assertEquals(1, branches.length);
+ assertEquals(branchName, ((CVSTagElement) (branches[0])).getTag()
+ .getName());
+ Object[] modules = rcp.getChildren(branches[0]);
+ assertEquals(1, modules.length);
+ assertEquals(moduleName, ((RemoteResource) modules[0]).getName());
+
+ // check if after refresh module is still the only branch child
+ branches = rcp.getChildren(categories[1]);
+ assertEquals(1, branches.length);
+ assertEquals(branchName, ((CVSTagElement) (branches[0])).getTag()
+ .getName());
+ modules = rcp.getChildren(branches[0]);
+ assertEquals(1, modules.length);
+ assertEquals(moduleName, ((RemoteResource) modules[0]).getName());
+ }
+
+ public void testTagSubmoduleChildren() throws TeamException, CoreException {
+
+ String time = Long.toString(System.currentTimeMillis());
+ String moduleName = "TestTagSubmoduleChildrenTestModule" + time;
+ String versionName = "TestTagSubmoduleChildrenBranch" + time;
+
+ // create project
+ IProject project = getUniqueTestProject("TestTagSubmoduleChildrenProject");
+ // share project under module
+ shareProject(getRepository(), project,
+ moduleName + "/" + project.getName(), DEFAULT_MONITOR);
+ assertValidCheckout(project);
+
+ // make some changes
+ addResources(project, new String[] { "file1.txt" }, true);
+
+ // tag project
+ CVSTag tag = new CVSTag(versionName, CVSTag.VERSION);
+
+ tagProject(project, tag, true);
+
+
+ RemoteContentProvider rcp = new RemoteContentProvider();
+ Object[] categories = rcp.getChildren(getRepositoryRoot());
+ assertEquals(4, categories.length);
+
+ // check if version exists for module
+ assertTrue(categories[2] instanceof VersionCategory);
+ Object[] modules = rcp.getChildren(categories[2]);
+ for (int i = 0; i < modules.length; i++) {
+ if (modules[i] instanceof RemoteModule
+ && ((RemoteModule) (modules[i])).getCVSResource().getName()
+ .equals(moduleName)) {
+ Object folders[] = rcp.getChildren(modules[i]);
+ assertEquals(1, folders.length);
+ assertEquals(versionName, ((RemoteFolder) folders[0]).getTag()
+ .getName());
+ return;
+ }
+ }
+ fail(moduleName + " not found");
+ }
+
+ public void testTagsOnDifferentLevels() throws CoreException {
+ String time = Long.toString(System.currentTimeMillis());
+ String firstModule = "Module_1" + time;
+ String secondModule = "Module_2" + time;
+ String secondModulePath = firstModule + "/" + secondModule;
+ // Create repository data
+ // Module_1/Project_1
+ IProject project1 = getUniqueTestProject("Project_1");
+ shareProject(getRepository(), project1,
+ firstModule + "/" + project1.getName(), DEFAULT_MONITOR);
+ // Module_1/Module_2/Project_2
+ IProject project2 = getUniqueTestProject("Project_2");
+ shareProject(getRepository(), project2, secondModulePath + "/"
+ + project2.getName(), DEFAULT_MONITOR);
+ // Module_1/Module_2/Project_3
+ IProject project3 = getUniqueTestProject("Project_3");
+ shareProject(getRepository(), project3, secondModulePath + "/"
+ + project3.getName(), DEFAULT_MONITOR);
+ // Module_1/Project_4
+ IProject project4 = getUniqueTestProject("Project_4");
+ shareProject(getRepository(), project4,
+ firstModule + "/" + project4.getName(), DEFAULT_MONITOR);
+
+ // Create branches
+ String branch1 = "Branch_1" + time;
+ String version1 = "Root_" + branch1;
+ String branch2 = "Branch_2" + time;
+ String version2 = "Root_" + branch2;
+
+ // Tag projects:
+ // Module_1/Project_1 -> [Branch_1][Branch_2]
+ // Module_1/Module_2/Project_2 -> [Branch_1][Branch_2]
+ // Module_1/Module_2/Project_3 -> [Branch_2]
+ // Module_1/Project_4 -> [Branch_4]
+ makeBranch(new IResource[] { project1, project2 }, new CVSTag(version1,
+ CVSTag.VERSION), new CVSTag(branch1, CVSTag.BRANCH), true);
+ makeBranch(new IResource[] { project1, project2, project2, project4 },
+ new CVSTag(version2, CVSTag.VERSION), new CVSTag(branch2,
+ CVSTag.BRANCH), true);
+
+ // verify if tree structure is built from cache
+ RemoteContentProvider rcp = new RemoteContentProvider();
+ Object[] categories = rcp.getChildren(getRepositoryRoot());
+ assertEquals(4, categories.length);
+ assertTrue(categories[1] instanceof BranchCategory);
+ Object[] branches = rcp.getChildren(categories[1]);
+ assertEquals(2, branches.length); // should be [Branch_1] and [Branch_2]
+ CVSTagElement branch1Element;
+ CVSTagElement branch2Element;
+ if (((CVSTagElement) branches[0]).getTag().getName().equals(branch1)) {
+ branch1Element = (CVSTagElement) branches[0];
+ branch2Element = (CVSTagElement) branches[1];
+ } else {
+ branch1Element = (CVSTagElement) branches[1];
+ branch2Element = (CVSTagElement) branches[0];
+ }
+ Object[] modules = rcp.getChildren(branch1Element);
+ assertEquals(1, modules.length); // should be [Branch_1]/Module_1
+ assertEquals(firstModule, ((RemoteResource) modules[0]).getName());
+ modules = rcp.getChildren(modules[0]);
+ // should contain:
+ // [Branch_1]/Module_1/Project_1
+ // [Branch_1]/Module_1/Module_2
+ assertEquals(2, modules.length);
+ for (int i = 0; i < modules.length; i++) {
+ if (((RemoteResource) (modules[i])).getName().equals(
+ project1.getName())) {
+ // Project_1 should have contents retrieved from CVS
+ assertTrue(rcp.hasChildren(modules[i]));
+ } else if (((RemoteResource) (modules[i])).getName().equals(
+ secondModule)) {
+ // should be only [Branch_1]/Module_1/Module_2/Project_2.
+ // [Branch_1]/Module_1/Module_2/Project_3 should NOT be on the
+ // list, it is not branched with Branch_1
+ Object[] module2Children = rcp.getChildren(modules[i]);
+ assertEquals(1, module2Children.length);
+ assertEquals(project2.getName(),
+ ((RemoteResource) module2Children[0]).getName());
+ }
+ }
+ modules = rcp.getChildren(branch2Element);
+ assertEquals(1, modules.length); // should be [Branch_2]/Module_1
+ assertEquals(firstModule, ((RemoteResource) modules[0]).getName());
+ // should contain:
+ // [Branch_2]/Module_1/Project_1
+ // [Branch_2]/Module_1/Module_2
+ // [Branch_2]/Module_1/Project_4
+ modules = rcp.getChildren(modules[0]);
+ assertEquals(3, modules.length);
+ }
+}

Back to the top