Commit 24eff079 authored by agurov's avatar agurov

Remember last choice for the "ignore ancestry option" in compare dialogs (bug 512313)

https://bugs.eclipse.org/bugs/show_bug.cgi?id=512313

git-svn-id: https://dev.eclipse.org/svnroot/technology/org.eclipse.subversive/trunk@21656 ee007c2a-0a25-0410-9ab9-bf268980928c
parent 8fbc0a36
......@@ -26,6 +26,7 @@ import org.eclipse.team.svn.ui.SVNUIMessages;
import org.eclipse.team.svn.ui.composite.BranchTagSelectionComposite;
import org.eclipse.team.svn.ui.composite.DiffFormatComposite;
import org.eclipse.team.svn.ui.panel.AbstractDialogPanel;
import org.eclipse.team.svn.ui.utility.InputHistory;
import org.eclipse.team.svn.ui.utility.UIMonitorUtility;
import org.eclipse.team.svn.ui.verifier.AbstractVerifier;
......@@ -45,6 +46,7 @@ public class CompareBranchTagPanel extends AbstractDialogPanel {
protected Label resultText;
protected long options;
protected Button ignoreAncestryButton;
protected InputHistory ignoreHistory;
protected IRepositoryResource resourceToCompareWith;
......@@ -78,7 +80,8 @@ public class CompareBranchTagPanel extends AbstractDialogPanel {
this.ignoreAncestryButton = new Button(parent, SWT.CHECK);
this.ignoreAncestryButton.setLayoutData(data);
this.ignoreAncestryButton.setText(SVNUIMessages.MergePanel_Button_IgnoreAncestry);
this.ignoreAncestryButton.setSelection((this.options & ISVNConnector.Options.IGNORE_ANCESTRY) != 0);
this.ignoreHistory = new InputHistory("ignoreAncestry", InputHistory.TYPE_BOOLEAN, (this.options & ISVNConnector.Options.IGNORE_ANCESTRY) != 0); //$NON-NLS-1$
this.ignoreAncestryButton.setSelection((Boolean)this.ignoreHistory.getValue());
this.diffFormatComposite = new DiffFormatComposite(parent, this);
......@@ -158,6 +161,7 @@ public class CompareBranchTagPanel extends AbstractDialogPanel {
protected void saveChangesImpl() {
this.selectionComposite.saveChanges();
this.options |= this.ignoreAncestryButton.getSelection() ? ISVNConnector.Options.IGNORE_ANCESTRY : ISVNConnector.Options.NONE;
this.ignoreHistory.setValue(this.ignoreAncestryButton.getSelection());
}
protected void cancelChangesImpl() {
......
......@@ -22,6 +22,7 @@ import org.eclipse.team.svn.ui.SVNUIMessages;
import org.eclipse.team.svn.ui.composite.DiffFormatComposite;
import org.eclipse.team.svn.ui.composite.RepositoryResourceSelectionComposite;
import org.eclipse.team.svn.ui.panel.common.AbstractRepositoryResourceSelectionPanel;
import org.eclipse.team.svn.ui.utility.InputHistory;
/**
* Compare operation repository resource selection panel
......@@ -33,6 +34,7 @@ public class ComparePanel extends AbstractRepositoryResourceSelectionPanel {
protected DiffFormatComposite diffFormatComposite;
protected long options;
protected Button ignoreAncestryButton;
protected InputHistory ignoreHistory;
public ComparePanel(IRepositoryResource baseResource) {
super(baseResource, SVNRevision.INVALID_REVISION_NUMBER, SVNUIMessages.ComparePanel_Title, SVNUIMessages.ComparePanel_Description, "compareUrl", SVNUIMessages.ComparePanel_Selection_Title, SVNUIMessages.ComparePanel_Selection_Description, RepositoryResourceSelectionComposite.TEXT_BASE); //$NON-NLS-1$
......@@ -59,7 +61,8 @@ public class ComparePanel extends AbstractRepositoryResourceSelectionPanel {
this.ignoreAncestryButton = new Button(parent, SWT.CHECK);
this.ignoreAncestryButton.setLayoutData(data);
this.ignoreAncestryButton.setText(SVNUIMessages.MergePanel_Button_IgnoreAncestry);
this.ignoreAncestryButton.setSelection((this.options & ISVNConnector.Options.IGNORE_ANCESTRY) != 0);
this.ignoreHistory = new InputHistory("ignoreAncestry", InputHistory.TYPE_BOOLEAN, (this.options & ISVNConnector.Options.IGNORE_ANCESTRY) != 0); //$NON-NLS-1$
this.ignoreAncestryButton.setSelection((Boolean)this.ignoreHistory.getValue());
this.diffFormatComposite = new DiffFormatComposite(parent, this);
}
......@@ -75,6 +78,7 @@ public class ComparePanel extends AbstractRepositoryResourceSelectionPanel {
protected void saveChangesImpl() {
super.saveChangesImpl();
this.options |= this.ignoreAncestryButton.getSelection() ? ISVNConnector.Options.IGNORE_ANCESTRY : ISVNConnector.Options.NONE;
this.ignoreHistory.setValue(this.ignoreAncestryButton.getSelection());
}
}
/*******************************************************************************
* Copyright (c) 2005-2008 Polarion Software.
* 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:
* Alexander Gurov - Initial API and implementation
*******************************************************************************/
package org.eclipse.team.svn.ui.utility;
import org.eclipse.team.svn.ui.SVNTeamUIPlugin;
/**
* This storage allow us to handle comment, user name etc. histories in one way
*
* @author Alexander Gurov
*/
public class InputHistory {
public static final int TYPE_BOOLEAN = 0;
public static final int TYPE_DOUBLE = 1;
public static final int TYPE_FLOAT = 2;
public static final int TYPE_INT = 3;
public static final int TYPE_LONG = 4;
public static final int TYPE_STRING = 5;
protected static final String HISTORY_NAME_BASE = "history."; //$NON-NLS-1$
protected String name;
protected int type;
protected Object value;
public InputHistory(String name, int type, Object defaultValue) {
this.name = name;
this.type = type;
this.loadHistoryValue(defaultValue);
}
public String getName() {
return this.name;
}
public Object getValue() {
return this.value;
}
public void clear() {
this.value = null;
this.saveHistoryValue();
}
public void setValue(Object value) {
this.value = value;
this.saveHistoryValue();
}
protected void loadHistoryValue(Object defaultValue) {
String fullName = UserInputHistory.HISTORY_NAME_BASE + this.name;
switch (this.type) {
case InputHistory.TYPE_BOOLEAN: {
SVNTeamUIPlugin.instance().getPreferenceStore().setDefault(fullName, defaultValue == null ? false : ((Boolean)defaultValue).booleanValue());
this.value = SVNTeamUIPlugin.instance().getPreferenceStore().getBoolean(fullName);
break;
}
case InputHistory.TYPE_DOUBLE: {
SVNTeamUIPlugin.instance().getPreferenceStore().setDefault(fullName, defaultValue == null ? 0 : ((Double)defaultValue).doubleValue());
this.value = SVNTeamUIPlugin.instance().getPreferenceStore().getDouble(fullName);
break;
}
case InputHistory.TYPE_FLOAT: {
SVNTeamUIPlugin.instance().getPreferenceStore().setDefault(fullName, defaultValue == null ? 0 : ((Float)defaultValue).floatValue());
this.value = SVNTeamUIPlugin.instance().getPreferenceStore().getFloat(fullName);
break;
}
case InputHistory.TYPE_INT: {
SVNTeamUIPlugin.instance().getPreferenceStore().setDefault(fullName, defaultValue == null ? 0 : ((Integer)defaultValue).intValue());
this.value = SVNTeamUIPlugin.instance().getPreferenceStore().getInt(fullName);
break;
}
case InputHistory.TYPE_LONG: {
SVNTeamUIPlugin.instance().getPreferenceStore().setDefault(fullName, defaultValue == null ? 0 : ((Long)defaultValue).longValue());
this.value = SVNTeamUIPlugin.instance().getPreferenceStore().getLong(fullName);
break;
}
default: {
SVNTeamUIPlugin.instance().getPreferenceStore().setDefault(fullName, defaultValue == null ? "" : (String)defaultValue); //$NON-NLS-1$
this.value = SVNTeamUIPlugin.instance().getPreferenceStore().getString(fullName);
}
}
}
protected void saveHistoryValue() {
Object value = this.value;
String fullName = UserInputHistory.HISTORY_NAME_BASE + this.name;
switch (this.type) {
case InputHistory.TYPE_BOOLEAN: {
SVNTeamUIPlugin.instance().getPreferenceStore().setValue(fullName, value == null ? false : ((Boolean)value).booleanValue());
break;
}
case InputHistory.TYPE_DOUBLE: {
SVNTeamUIPlugin.instance().getPreferenceStore().setValue(fullName, value == null ? 0 : ((Double)value).doubleValue());
break;
}
case InputHistory.TYPE_FLOAT: {
SVNTeamUIPlugin.instance().getPreferenceStore().setValue(fullName, value == null ? 0 : ((Float)value).floatValue());
break;
}
case InputHistory.TYPE_INT: {
SVNTeamUIPlugin.instance().getPreferenceStore().setValue(fullName, value == null ? 0 : ((Integer)value).intValue());
break;
}
case InputHistory.TYPE_LONG: {
SVNTeamUIPlugin.instance().getPreferenceStore().setValue(fullName, value == null ? 0 : ((Long)value).longValue());
break;
}
default: {
SVNTeamUIPlugin.instance().getPreferenceStore().setValue(fullName, value == null ? "" : (String)value); //$NON-NLS-1$
}
}
}
}
......@@ -27,12 +27,11 @@ import org.eclipse.team.svn.ui.preferences.SVNTeamPreferences;
*
* @author Alexander Gurov
*/
public class UserInputHistory {
public class UserInputHistory extends InputHistory {
protected static final String HISTORY_NAME_BASE = "history."; //$NON-NLS-1$
protected final static String ENCODING = "UTF-8";
protected String name;
protected int depth;
protected List history;
......@@ -41,7 +40,7 @@ public class UserInputHistory {
}
public UserInputHistory(String name, int depth) {
this.name = name;
super(name, InputHistory.TYPE_STRING, null);
this.depth = depth;
this.loadHistoryLines();
......@@ -56,10 +55,6 @@ public class UserInputHistory {
}
}
public String getName() {
return this.name;
}
public int getDepth() {
return this.depth;
}
......@@ -82,12 +77,12 @@ public class UserInputHistory {
public void clear() {
this.history.clear();
this.saveHistoryLines();
super.clear();
}
protected void loadHistoryLines() {
this.history = new ArrayList();
String historyData = SVNTeamUIPlugin.instance().getPreferenceStore().getString(UserInputHistory.HISTORY_NAME_BASE + this.name);
String historyData = (String)this.value;
if (historyData != null && historyData.length() > 0) {
String []historyArray = historyData.split(";"); //$NON-NLS-1$
for (int i = 0; i < historyArray.length; i++) {
......@@ -112,7 +107,7 @@ public class UserInputHistory {
}
result += result.length() == 0 ? str : (";" + str); //$NON-NLS-1$
}
SVNTeamUIPlugin.instance().getPreferenceStore().setValue(UserInputHistory.HISTORY_NAME_BASE + this.name, result);
this.setValue(result);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment