Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Zarna2011-11-18 12:21:27 +0000
committerTomasz Zarna2011-11-18 12:21:27 +0000
commit951477fe0d9d1aa4bbfcabd936d0d7641c6f712a (patch)
tree952b09572474681f93c2570abf2fa478062b5910 /bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team
parentcfa9a16b8044938883a013f0f31a1919520603be (diff)
downloadeclipse.platform.team-951477fe0d9d1aa4bbfcabd936d0d7641c6f712a.tar.gz
eclipse.platform.team-951477fe0d9d1aa4bbfcabd936d0d7641c6f712a.tar.xz
eclipse.platform.team-951477fe0d9d1aa4bbfcabd936d0d7641c6f712a.zip
bug 352016: [Sync View] Team synchronization filteringv20111118-1221
Diffstat (limited to 'bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team')
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java5
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java8
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ComparePreferencePage.java38
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java6
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CompareSubscriberContext.java66
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceSubscriberContext.java94
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties1
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareParticipant.java68
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RegexSyncInfoFilter.java67
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java83
10 files changed, 390 insertions, 46 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java
index a49af0f10..78ce9d49b 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java
@@ -48,7 +48,6 @@ public class CVSUIMessages extends NLS {
public static String CommitWizard_13;
public static String CommitWizard_8;
public static String CommitWizard_9;
- public static String ComparePreferencePage_8;
public static String CreatePatchAction_0;
public static String CreatePatchAction_1;
public static String CVSHistoryPage_CollapseAllAction;
@@ -1011,7 +1010,10 @@ public class CVSUIMessages extends NLS {
public static String ComparePreferencePage_2;
public static String ComparePreferencePage_3;
public static String ComparePreferencePage_4;
+ public static String ComparePreferencePage_5;
public static String ComparePreferencePage_6;
+ public static String ComparePreferencePage_7;
+ public static String ComparePreferencePage_8;
public static String FileModificationValidator_3;
public static String FileModificationValidator_4;
@@ -1152,7 +1154,6 @@ public class CVSUIMessages extends NLS {
public static String CVSHistoryFilterDialog_showLocalRevisions;
public static String CVSHistoryTableProvider_base;
public static String CVSHistoryTableProvider_currentVersion;
- public static String ComparePreferencePage_7;
public static String WorkspaceTraversalAction_0;
public static String OutgoingChangesDialog_0;
public static String OutgoingChangesDialog_1;
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java
index 6d1896b0d..0112f1453 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 IBM Corporation 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
@@ -21,6 +21,7 @@ import java.util.*;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceStatus;
import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.dialogs.*;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.preference.IPreferenceStore;
@@ -578,6 +579,7 @@ public class CVSUIPlugin extends AbstractUIPlugin {
store.setDefault(ICVSUIConstants.PREF_PRUNE_EMPTY_DIRECTORIES, CVSProviderPlugin.DEFAULT_PRUNE);
store.setDefault(ICVSUIConstants.PREF_TIMEOUT, CVSProviderPlugin.DEFAULT_TIMEOUT);
store.setDefault(ICVSUIConstants.PREF_CONSIDER_CONTENTS, true);
+ store.setDefault(ICVSUIConstants.PREF_SYNCVIEW_REGEX_FILTER_PATTERN, ""); //default pattern is empty string //$NON-NLS-1$
store.setDefault(ICVSUIConstants.PREF_COMPRESSION_LEVEL, CVSProviderPlugin.DEFAULT_COMPRESSION_LEVEL);
store.setDefault(ICVSUIConstants.PREF_TEXT_KSUBST, CVSProviderPlugin.DEFAULT_TEXT_KSUBST_OPTION.toMode());
store.setDefault(ICVSUIConstants.PREF_USE_PLATFORM_LINEEND, true);
@@ -755,4 +757,8 @@ public class CVSUIPlugin extends AbstractUIPlugin {
public ActiveChangeSetManager getChangeSetManager() {
return CVSProviderPlugin.getPlugin().getChangeSetManager();
}
+
+ public org.osgi.service.prefs.Preferences getInstancePreferences() {
+ return InstanceScope.INSTANCE.getNode(getBundle().getSymbolicName());
+ }
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ComparePreferencePage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ComparePreferencePage.java
index fb199d292..7f67d0611 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ComparePreferencePage.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ComparePreferencePage.java
@@ -11,8 +11,11 @@
package org.eclipse.team.internal.ccvs.ui;
import org.eclipse.compare.CompareUI;
-import org.eclipse.jface.preference.BooleanFieldEditor;
-import org.eclipse.jface.preference.IPreferencePageContainer;
+import org.eclipse.jface.preference.*;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Event;
import org.eclipse.team.internal.ui.SWTUtils;
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
@@ -20,6 +23,8 @@ import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
* Preference page for configuring CVS comparisons
*/
public class ComparePreferencePage extends CVSFieldEditorPreferencePage {
+ private BooleanFieldEditor contents;
+ private StringFieldEditor regex;
/* (non-Javadoc)
* @see org.eclipse.team.internal.ccvs.ui.CVSFieldEditorPreferencePage#getPageHelpContextId()
@@ -39,22 +44,43 @@ public class ComparePreferencePage extends CVSFieldEditorPreferencePage {
* @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
*/
protected void createFieldEditors() {
- addField(new BooleanFieldEditor(ICVSUIConstants.PREF_CONSIDER_CONTENTS,
+ IPreferenceStore store = getPreferenceStore();
+
+ contents = new BooleanFieldEditor(ICVSUIConstants.PREF_CONSIDER_CONTENTS,
CVSUIMessages.ComparePreferencePage_4,
BooleanFieldEditor.DEFAULT, getFieldEditorParent()) {
+ private Event selectionEvent = createSelectionEvent();
+ private Event createSelectionEvent() {
+ Event event = new Event();
+ event.type = SWT.Selection;
+ return event;
+ }
// invert the UI
protected void doLoad() {
super.doLoad();
getChangeControl(getFieldEditorParent()).setSelection(!getBooleanValue());
+ getChangeControl(getFieldEditorParent()).notifyListeners(SWT.Selection,
+ selectionEvent);
}
protected void doLoadDefault() {
super.doLoadDefault();
getChangeControl(getFieldEditorParent()).setSelection(!getBooleanValue());
+ getChangeControl(getFieldEditorParent()).notifyListeners(SWT.Selection,
+ selectionEvent);
}
protected void doStore() {
getPreferenceStore().setValue(getPreferenceName(), !getBooleanValue());
}
- });
+ };
+ addField(contents);
+ regex = new StringFieldEditor(ICVSUIConstants.PREF_SYNCVIEW_REGEX_FILTER_PATTERN,
+ CVSUIMessages.ComparePreferencePage_5,
+ getFieldEditorParent());
+ addField(regex);
+ GridData data = new GridData();
+ data.horizontalIndent = 20;
+ regex.getLabelControl(getFieldEditorParent()).setLayoutData(data);
+ regex.setEnabled(store.getBoolean(ICVSUIConstants.PREF_CONSIDER_CONTENTS), getFieldEditorParent());
addField(new BooleanFieldEditor(
ICVSUIConstants.PREF_SHOW_COMPARE_REVISION_IN_DIALOG,
CVSUIMessages.ComparePreferencePage_3,
@@ -84,4 +110,8 @@ public class ComparePreferencePage extends CVSFieldEditorPreferencePage {
}
}
+ public void propertyChange(PropertyChangeEvent event) {
+ super.propertyChange(event);
+ regex.setEnabled(!contents.getBooleanValue(), getFieldEditorParent());
+ }
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java
index 35917d6a4..b5f1355ea 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 IBM Corporation 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
@@ -93,6 +93,10 @@ public interface ICVSUIConstants {
public final String PREF_CVS_RSH_PARAMETERS = "pref_cvs_rsh_parameters"; //$NON-NLS-1$
public final String PREF_CVS_SERVER = "pref_cvs_server"; //$NON-NLS-1$
public final String PREF_CONSIDER_CONTENTS = "pref_consider_contents"; //$NON-NLS-1$
+ /**
+ * Preference to save the pattern for the regex filter used in the Synchronize View.
+ */
+ public final String PREF_SYNCVIEW_REGEX_FILTER_PATTERN = "pref_syncview_regex_filter_pattern"; //$NON-NLS-1$
public final String PREF_REPLACE_UNMANAGED = "pref_replace_unmanaged"; //$NON-NLS-1$
public final String PREF_COMPRESSION_LEVEL = "pref_compression_level"; //$NON-NLS-1$
public final String PREF_TEXT_KSUBST = "pref_text_ksubst"; //$NON-NLS-1$
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CompareSubscriberContext.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CompareSubscriberContext.java
index f5a0631b4..fa871781d 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CompareSubscriberContext.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CompareSubscriberContext.java
@@ -10,9 +10,11 @@
*******************************************************************************/
package org.eclipse.team.internal.ccvs.ui.mappings;
-import org.eclipse.core.runtime.*;
-import org.eclipse.core.runtime.Preferences.IPropertyChangeListener;
-import org.eclipse.core.runtime.Preferences.PropertyChangeEvent;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.preferences.*;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
import org.eclipse.team.core.diff.DiffFilter;
import org.eclipse.team.core.diff.IDiff;
import org.eclipse.team.core.mapping.ISynchronizationScopeManager;
@@ -23,8 +25,9 @@ import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
import org.eclipse.team.internal.core.subscribers.ContentComparisonDiffFilter;
import org.eclipse.team.internal.core.subscribers.SubscriberDiffTreeEventHandler;
+import org.eclipse.team.internal.ui.synchronize.RegexDiffFilter;
-public class CompareSubscriberContext extends CVSSubscriberMergeContext implements IPropertyChangeListener {
+public class CompareSubscriberContext extends CVSSubscriberMergeContext implements IPreferenceChangeListener {
public static SynchronizationContext createContext(ISynchronizationScopeManager manager, CVSCompareSubscriber subscriber) {
CompareSubscriberContext mergeContext = new CompareSubscriberContext(subscriber, manager);
@@ -34,7 +37,7 @@ public class CompareSubscriberContext extends CVSSubscriberMergeContext implemen
protected CompareSubscriberContext(Subscriber subscriber, ISynchronizationScopeManager manager) {
super(subscriber, manager);
- CVSUIPlugin.getPlugin().getPluginPreferences().addPropertyChangeListener(this);
+ ((IEclipsePreferences) CVSUIPlugin.getPlugin().getInstancePreferences().node("")).addPreferenceChangeListener(this); //$NON-NLS-1$
}
/* (non-Javadoc)
@@ -42,7 +45,7 @@ public class CompareSubscriberContext extends CVSSubscriberMergeContext implemen
*/
public void dispose() {
super.dispose();
- CVSUIPlugin.getPlugin().getPluginPreferences().removePropertyChangeListener(this);
+ ((IEclipsePreferences) CVSUIPlugin.getPlugin().getInstancePreferences().node("")).removePreferenceChangeListener(this); //$NON-NLS-1$
}
/* (non-Javadoc)
@@ -57,20 +60,59 @@ public class CompareSubscriberContext extends CVSSubscriberMergeContext implemen
* @see org.eclipse.team.core.subscribers.SubscriberMergeContext#getDiffFilter()
*/
protected DiffFilter getDiffFilter() {
- if (CVSUIPlugin.getPlugin().getPluginPreferences().getBoolean(ICVSUIConstants.PREF_CONSIDER_CONTENTS)) {
- // Return a filter that selects any diffs whose contents are not equal
- final DiffFilter contentsEqual = new ContentComparisonDiffFilter(false);
+ final DiffFilter contentFilter = createContentFilter();
+ final DiffFilter regexFilter = createRegexFilter();
+ if (contentFilter != null && regexFilter != null) {
+ return new DiffFilter() {
+ public boolean select(IDiff diff, IProgressMonitor monitor) {
+ return !contentFilter.select(diff, monitor)
+ && !regexFilter.select(diff, monitor);
+ }
+ };
+ } else if (contentFilter != null) {
+ return new DiffFilter() {
+ public boolean select(IDiff diff, IProgressMonitor monitor) {
+ return !contentFilter.select(diff, monitor);
+ }
+ };
+ } else if (regexFilter != null) {
return new DiffFilter() {
public boolean select(IDiff diff, IProgressMonitor monitor) {
- return !contentsEqual.select(diff, monitor);
+ return !regexFilter.select(diff, monitor);
}
};
}
return null;
}
- public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equals(ICVSUIConstants.PREF_CONSIDER_CONTENTS)) {
+ private boolean isConsiderContents() {
+ return CVSUIPlugin.getPlugin().getPreferenceStore().getBoolean(ICVSUIConstants.PREF_CONSIDER_CONTENTS);
+ }
+
+ private DiffFilter createContentFilter() {
+ if (isConsiderContents()) {
+ // Return a filter that selects any diffs whose contents are not equal
+ return new ContentComparisonDiffFilter(false);
+ }
+ return null;
+ }
+
+ private DiffFilter createRegexFilter() {
+ if (isConsiderContents()) {
+ String pattern = CVSUIPlugin.getPlugin().getPreferenceStore().getString(
+ ICVSUIConstants.PREF_SYNCVIEW_REGEX_FILTER_PATTERN);
+ if (pattern != null && !pattern.equals("")) { //$NON-NLS-1$
+ return new RegexDiffFilter(pattern);
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener#preferenceChange(org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent)
+ */
+ public void preferenceChange(PreferenceChangeEvent event) {
+ if (event.getKey().equals(ICVSUIConstants.PREF_CONSIDER_CONTENTS) || event.getKey().equals(ICVSUIConstants.PREF_SYNCVIEW_REGEX_FILTER_PATTERN)) {
SubscriberDiffTreeEventHandler handler = getHandler();
if (handler != null) {
handler.setFilter(getDiffFilter());
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceSubscriberContext.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceSubscriberContext.java
index e8f8e6350..3c83216fb 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceSubscriberContext.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceSubscriberContext.java
@@ -17,18 +17,19 @@ import java.util.List;
import org.eclipse.core.resources.*;
import org.eclipse.core.resources.mapping.*;
import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.preferences.*;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.diff.IDiff;
-import org.eclipse.team.core.diff.IThreeWayDiff;
+import org.eclipse.team.core.diff.*;
import org.eclipse.team.core.diff.provider.DiffTree;
import org.eclipse.team.core.history.IFileRevision;
import org.eclipse.team.core.mapping.*;
import org.eclipse.team.core.mapping.provider.ResourceDiffTree;
import org.eclipse.team.core.subscribers.Subscriber;
import org.eclipse.team.core.subscribers.SubscriberScopeManager;
-import org.eclipse.team.core.synchronize.SyncInfo;
-import org.eclipse.team.core.synchronize.SyncInfoFilter;
+import org.eclipse.team.core.synchronize.*;
import org.eclipse.team.core.synchronize.SyncInfoFilter.ContentComparisonSyncInfoFilter;
import org.eclipse.team.core.variants.IResourceVariant;
import org.eclipse.team.internal.ccvs.core.*;
@@ -38,11 +39,14 @@ import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.core.resources.RemoteFile;
import org.eclipse.team.internal.ccvs.ui.*;
import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.team.internal.ccvs.ui.operations.*;
+import org.eclipse.team.internal.ccvs.ui.operations.CacheBaseContentsOperation;
+import org.eclipse.team.internal.ccvs.ui.operations.CacheRemoteContentsOperation;
import org.eclipse.team.internal.core.mapping.GroupProgressMonitor;
+import org.eclipse.team.internal.core.subscribers.ContentComparisonDiffFilter;
import org.eclipse.team.internal.core.subscribers.SubscriberDiffTreeEventHandler;
+import org.eclipse.team.internal.ui.synchronize.RegexDiffFilter;
-public class WorkspaceSubscriberContext extends CVSSubscriberMergeContext {
+public class WorkspaceSubscriberContext extends CVSSubscriberMergeContext implements IPreferenceChangeListener {
public static final class ChangeSetSubscriberScopeManager extends SubscriberScopeManager {
private final boolean consultSets;
@@ -79,10 +83,84 @@ public class WorkspaceSubscriberContext extends CVSSubscriberMergeContext {
mergeContext.initialize();
return mergeContext;
}
-
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.core.subscribers.SubscriberMergeContext#getDiffFilter()
+ */
+ protected DiffFilter getDiffFilter() {
+ final DiffFilter contentFilter = createContentFilter();
+ final DiffFilter regexFilter = createRegexFilter();
+ if (contentFilter != null && regexFilter != null) {
+ return new DiffFilter() {
+ public boolean select(IDiff diff, IProgressMonitor monitor) {
+ return !contentFilter.select(diff, monitor)
+ && !regexFilter.select(diff, monitor);
+ }
+ };
+ } else if (contentFilter != null) {
+ return new DiffFilter() {
+ public boolean select(IDiff diff, IProgressMonitor monitor) {
+ return !contentFilter.select(diff, monitor);
+ }
+ };
+ } else if (regexFilter != null) {
+ return new DiffFilter() {
+ public boolean select(IDiff diff, IProgressMonitor monitor) {
+ return !regexFilter.select(diff, monitor);
+ }
+ };
+ }
+ return null;
+ }
+
protected WorkspaceSubscriberContext(CVSWorkspaceSubscriber subscriber, ISynchronizationScopeManager manager, int type) {
super(subscriber, manager);
this.type = type;
+ ((IEclipsePreferences) CVSUIPlugin.getPlugin().getInstancePreferences().node("")).addPreferenceChangeListener(this); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.core.subscribers.SubscriberMergeContext#dispose()
+ */
+ public void dispose() {
+ super.dispose();
+ ((IEclipsePreferences) CVSUIPlugin.getPlugin().getInstancePreferences().node("")).removePreferenceChangeListener(this); //$NON-NLS-1$
+ }
+
+ private boolean isConsiderContents() {
+ return CVSUIPlugin.getPlugin().getPreferenceStore().getBoolean(ICVSUIConstants.PREF_CONSIDER_CONTENTS);
+ }
+
+ private DiffFilter createContentFilter() {
+ if (isConsiderContents()) {
+ // Return a filter that selects any diffs whose contents are not equal
+ return new ContentComparisonDiffFilter(false);
+ }
+ return null;
+ }
+
+ private DiffFilter createRegexFilter() {
+ if (isConsiderContents()) {
+ String pattern = CVSUIPlugin.getPlugin().getPreferenceStore().getString(
+ ICVSUIConstants.PREF_SYNCVIEW_REGEX_FILTER_PATTERN);
+ if (pattern != null && !pattern.equals("")) { //$NON-NLS-1$
+ return new RegexDiffFilter(pattern);
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener#preferenceChange(org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent)
+ */
+ public void preferenceChange(PreferenceChangeEvent event) {
+ if (event.getKey().equals(ICVSUIConstants.PREF_CONSIDER_CONTENTS) || event.getKey().equals(ICVSUIConstants.PREF_SYNCVIEW_REGEX_FILTER_PATTERN)) {
+ SubscriberDiffTreeEventHandler handler = getHandler();
+ if (handler != null) {
+ handler.setFilter(getDiffFilter());
+ handler.reset();
+ }
+ }
}
public void markAsMerged(IDiff[] nodes, boolean inSyncHint, IProgressMonitor monitor) throws CoreException {
@@ -211,7 +289,7 @@ public class WorkspaceSubscriberContext extends CVSSubscriberMergeContext {
IFileRevision remote = getRemote(node);
if (variant != null && remote != null && remote instanceof IFileRevision) {
String ci1 = variant.getContentIdentifier();
- String ci2 = ((IFileRevision)remote).getContentIdentifier();
+ String ci2 = remote.getContentIdentifier();
if (!ci1.equals(ci2)) {
throw new CVSException(NLS.bind(CVSUIMessages.WorkspaceSubscriberContext_0, resource.getFullPath().toString()));
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
index c2c0ef5d6..d7a161817 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
@@ -1028,6 +1028,7 @@ ComparePreferencePage_1=Show the &file author in compare editors
ComparePreferencePage_2=Automatically enable chan&ge set grouping in CVS synchronizations
ComparePreferencePage_3=Show revision &comparisons in a dialog
ComparePreferencePage_4=Only look at time&stamps to detect changes
+ComparePreferencePage_5=Re&gular expression to ignore changes in synchronizations:
ComparePreferencePage_6=See <a>''{0}''</a> for compare editor preferences.
ComparePreferencePage_7=Allow &models (e.g. Java) to participate in synchronizations
ComparePreferencePage_8=&Open a compare editor when comparing a single file
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareParticipant.java
index 13f425e0d..e337f044b 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareParticipant.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareParticipant.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 IBM Corporation 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
@@ -15,8 +15,9 @@ import java.util.Arrays;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Preferences.IPropertyChangeListener;
-import org.eclipse.core.runtime.Preferences.PropertyChangeEvent;
+import org.eclipse.core.runtime.preferences.*;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.subscribers.Subscriber;
@@ -31,7 +32,7 @@ import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.ui.TeamUI;
import org.eclipse.team.ui.synchronize.*;
-public class CompareParticipant extends CVSParticipant implements IPropertyChangeListener {
+public class CompareParticipant extends CVSParticipant implements IPreferenceChangeListener {
public static final String CONTEXT_MENU_CONTRIBUTION_GROUP = "context_group_1"; //$NON-NLS-1$
public static final String NON_MODAL_CONTEXT_MENU_CONTRIBUTION_GROUP = "context_group_2"; //$NON-NLS-1$
@@ -70,18 +71,56 @@ public class CompareParticipant extends CVSParticipant implements IPropertyChang
}
};
+ private SyncInfoFilter createSyncInfoFilter() {
+ final SyncInfoFilter regexFilter = createRegexFilter();
+ if (isConsiderContents() && regexFilter != null) {
+ return new SyncInfoFilter() {
+ public boolean select(SyncInfo info, IProgressMonitor monitor) {
+ return contentComparison.select(info, monitor)
+ && !regexFilter.select(info, monitor);
+ }
+ };
+ } else if (isConsiderContents()) {
+ return new SyncInfoFilter() {
+ public boolean select(SyncInfo info, IProgressMonitor monitor) {
+ return contentComparison.select(info, monitor);
+ }
+ };
+ } else if (regexFilter != null) {
+ return new SyncInfoFilter() {
+ public boolean select(SyncInfo info, IProgressMonitor monitor) {
+ // want to select infos which contain at least one unmatched difference
+ return !regexFilter.select(info, monitor);
+ }
+ };
+ }
+ return null;
+ }
+
+ private boolean isConsiderContents() {
+ return CVSUIPlugin.getPlugin().getPreferenceStore().getBoolean(ICVSUIConstants.PREF_CONSIDER_CONTENTS);
+ }
+
+ private SyncInfoFilter createRegexFilter() {
+ if (isConsiderContents()) {
+ String pattern = CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_SYNCVIEW_REGEX_FILTER_PATTERN);
+ if (pattern != null && !pattern.equals("")) { //$NON-NLS-1$
+ return new RegexSyncInfoFilter(pattern);
+ }
+ }
+ return null;
+ }
+
public CompareParticipant(CVSCompareSubscriber subscriber) {
setSubscriber(subscriber);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.team.ui.synchronize.subscriber.SubscriberParticipant#setSubscriber(org.eclipse.team.core.subscribers.Subscriber)
*/
protected void setSubscriber(Subscriber subscriber) {
super.setSubscriber(subscriber);
- if (CVSUIPlugin.getPlugin().getPluginPreferences().getBoolean(ICVSUIConstants.PREF_CONSIDER_CONTENTS)) {
- setSyncInfoFilter(contentComparison);
- }
+ setSyncInfoFilter(createSyncInfoFilter());
try {
ISynchronizeParticipantDescriptor descriptor = TeamUI.getSynchronizeManager().getParticipantDescriptor(CVSCompareSubscriber.ID);
setInitializationData(descriptor);
@@ -90,7 +129,7 @@ public class CompareParticipant extends CVSParticipant implements IPropertyChang
} catch (CoreException e) {
CVSUIPlugin.log(e);
}
- CVSUIPlugin.getPlugin().getPluginPreferences().addPropertyChangeListener(this);
+ ((IEclipsePreferences) CVSUIPlugin.getPlugin().getInstancePreferences().node("")).addPreferenceChangeListener(this); //$NON-NLS-1$
}
/* (non-Javadoc)
@@ -170,17 +209,18 @@ public class CompareParticipant extends CVSParticipant implements IPropertyChang
*/
public void dispose() {
super.dispose();
- CVSUIPlugin.getPlugin().getPluginPreferences().removePropertyChangeListener(this);
+ ((IEclipsePreferences) CVSUIPlugin.getPlugin().getInstancePreferences().node("")).removePreferenceChangeListener(this); //$NON-NLS-1$
getCVSCompareSubscriber().dispose();
}
/* (non-Javadoc)
* @see org.eclipse.core.runtime.Preferences.IPropertyChangeListener#propertyChange(org.eclipse.core.runtime.Preferences.PropertyChangeEvent)
*/
- public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equals(ICVSUIConstants.PREF_CONSIDER_CONTENTS)) {
- if (CVSUIPlugin.getPlugin().getPluginPreferences().getBoolean(ICVSUIConstants.PREF_CONSIDER_CONTENTS)) {
- setSyncInfoFilter(contentComparison);
+ public void preferenceChange(PreferenceChangeEvent event) {
+ if (event.getKey().equals(ICVSUIConstants.PREF_CONSIDER_CONTENTS) || event.getKey().equals(ICVSUIConstants.PREF_SYNCVIEW_REGEX_FILTER_PATTERN)) {
+ SyncInfoFilter filter = createSyncInfoFilter();
+ if (filter != null) {
+ setSyncInfoFilter(filter);
} else {
setSyncInfoFilter(new FastSyncInfoFilter());
}
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
new file mode 100644
index 000000000..118562ce7
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RegexSyncInfoFilter.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation 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:
+ * 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.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java
index 5f8757612..b5c219103 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 IBM Corporation 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
@@ -17,12 +17,16 @@ import java.util.Set;
import org.eclipse.compare.CompareConfiguration;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.preferences.*;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.viewers.ILabelDecorator;
import org.eclipse.jface.window.Window;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.diff.IDiff;
import org.eclipse.team.core.mapping.provider.ResourceDiffTree;
+import org.eclipse.team.core.synchronize.*;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.ui.*;
import org.eclipse.team.internal.ccvs.ui.actions.*;
@@ -33,7 +37,7 @@ import org.eclipse.team.ui.TeamUI;
import org.eclipse.team.ui.synchronize.*;
import org.eclipse.ui.*;
-public class WorkspaceSynchronizeParticipant extends ScopableSubscriberParticipant implements IChangeSetProvider {
+public class WorkspaceSynchronizeParticipant extends ScopableSubscriberParticipant implements IChangeSetProvider, IPreferenceChangeListener {
public static final String ID = "org.eclipse.team.cvs.ui.cvsworkspace-participant"; //$NON-NLS-1$
@@ -188,8 +192,61 @@ public class WorkspaceSynchronizeParticipant extends ScopableSubscriberParticipa
public WorkspaceSynchronizeParticipant(ISynchronizeScope scope) {
super(scope);
setSubscriber(CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber());
+ SyncInfoFilter filter = createSyncInfoFilter();
+ if (filter != null) {
+ setSyncInfoFilter(filter);
+ }
+ ((IEclipsePreferences) CVSUIPlugin.getPlugin().getInstancePreferences().node("")).addPreferenceChangeListener(this); //$NON-NLS-1$
}
-
+
+ private boolean isConsiderContents() {
+ return CVSUIPlugin.getPlugin().getPreferenceStore().getBoolean(ICVSUIConstants.PREF_CONSIDER_CONTENTS);
+ }
+
+ private SyncInfoFilter contentComparison = new SyncInfoFilter() {
+ private SyncInfoFilter contentCompare = new SyncInfoFilter.ContentComparisonSyncInfoFilter();
+ public boolean select(SyncInfo info, IProgressMonitor monitor) {
+ // Want to select infos whose contents do not match
+ return !contentCompare.select(info, monitor);
+ }
+ };
+
+ private SyncInfoFilter createSyncInfoFilter() {
+ final SyncInfoFilter regexFilter = createRegexFilter();
+ if (isConsiderContents() && regexFilter != null) {
+ return new SyncInfoFilter() {
+ public boolean select(SyncInfo info, IProgressMonitor monitor) {
+ return contentComparison.select(info, monitor)
+ && !regexFilter.select(info, monitor);
+ }
+ };
+ } else if (isConsiderContents()) {
+ return new SyncInfoFilter() {
+ public boolean select(SyncInfo info, IProgressMonitor monitor) {
+ return contentComparison.select(info, monitor);
+ }
+ };
+ } else if (regexFilter != null) {
+ return new SyncInfoFilter() {
+ public boolean select(SyncInfo info, IProgressMonitor monitor) {
+ // want to select infos which contain at least one unmatched difference
+ return !regexFilter.select(info, monitor);
+ }
+ };
+ }
+ return null;
+ }
+
+ private SyncInfoFilter createRegexFilter() {
+ if (isConsiderContents()) {
+ String pattern = CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_SYNCVIEW_REGEX_FILTER_PATTERN);
+ if (pattern != null && !pattern.equals("")) { //$NON-NLS-1$
+ return new RegexSyncInfoFilter(pattern);
+ }
+ }
+ return null;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#init(org.eclipse.ui.IMemento)
*/
@@ -272,5 +329,23 @@ public class WorkspaceSynchronizeParticipant extends ScopableSubscriberParticipa
public void refresh(IResource[] resources, IWorkbenchPartSite site) {
refresh(resources, getShortTaskName(), getLongTaskName(resources), site);
}
-
+
+ public void dispose() {
+ super.dispose();
+ ((IEclipsePreferences) CVSUIPlugin.getPlugin().getInstancePreferences().node("")).removePreferenceChangeListener(this); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener#preferenceChange(org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent)
+ */
+ public void preferenceChange(PreferenceChangeEvent event) {
+ if (event.getKey().equals(ICVSUIConstants.PREF_CONSIDER_CONTENTS) || event.getKey().equals(ICVSUIConstants.PREF_SYNCVIEW_REGEX_FILTER_PATTERN)) {
+ SyncInfoFilter filter = createSyncInfoFilter();
+ if (filter != null) {
+ setSyncInfoFilter(filter);
+ } else {
+ setSyncInfoFilter(new FastSyncInfoFilter());
+ }
+ }
+ }
}

Back to the top