diff options
author | Michael Valenta | 2006-10-02 18:46:53 +0000 |
---|---|---|
committer | Michael Valenta | 2006-10-02 18:46:53 +0000 |
commit | f21b7f50c3f93d2c62155624546f231b1994dd51 (patch) | |
tree | 956b559ac7712a16ff58746d53c5e5513912bc7b /bundles/org.eclipse.team.cvs.ui/src | |
parent | 8dc04ed44781b4e907774218faa13dbf8bf15251 (diff) | |
download | eclipse.platform.team-f21b7f50c3f93d2c62155624546f231b1994dd51.tar.gz eclipse.platform.team-f21b7f50c3f93d2c62155624546f231b1994dd51.tar.xz eclipse.platform.team-f21b7f50c3f93d2c62155624546f231b1994dd51.zip |
Bug 153879 [Wizards] configurable size of cvs commit comment history
Diffstat (limited to 'bundles/org.eclipse.team.cvs.ui/src')
5 files changed, 63 insertions, 13 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPreferencesPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPreferencesPage.java index d29662531..a90ef1bfa 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPreferencesPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPreferencesPage.java @@ -414,6 +414,27 @@ public class CVSPreferencesPage extends PreferencePage implements IWorkbenchPref } } }; + new TextField( + textComposite, + ICVSUIConstants.PREF_COMMIT_COMMENTS_MAX_HISTORY, + "Maximum number of comments on &history:", + null) { + protected void modifyText(Text text) { + try { + final int x = Integer.parseInt(text.getText()); + if (x > 0) { + setErrorMessage(null); + setValid(true); + } else { + setErrorMessage("Maximum number of comments must be positive"); + setValid(false); + } + } catch (NumberFormatException ex) { + setErrorMessage("Maximum number of comments must be a number"); + setValid(false); + } + } + }; return composite; } 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 4d43ac07f..abcb5980b 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 @@ -539,6 +539,7 @@ public class CVSUIPlugin extends AbstractUIPlugin { store.setDefault(ICVSUIConstants.PREF_ENABLE_WATCH_ON_EDIT, false); store.setDefault(ICVSUIConstants.PREF_USE_PROJECT_NAME_ON_CHECKOUT, false); store.setDefault(ICVSUIConstants.PREF_COMMIT_FILES_DISPLAY_THRESHOLD, 1000); + store.setDefault(ICVSUIConstants.PREF_COMMIT_COMMENTS_MAX_HISTORY, RepositoryManager.DEFAULT_MAX_COMMENTS); PreferenceConverter.setDefault(store, ICVSUIConstants.PREF_CONSOLE_COMMAND_COLOR, new RGB(0, 0, 0)); PreferenceConverter.setDefault(store, ICVSUIConstants.PREF_CONSOLE_MESSAGE_COLOR, new RGB(0, 0, 255)); 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 a67dbd2d3..16986f3cd 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 @@ -111,6 +111,7 @@ public interface ICVSUIConstants { public final String PREF_COMMIT_SET_DEFAULT_ENABLEMENT = "pref_enable_commit_sets"; //$NON-NLS-1$ public final String PREF_AUTO_REFRESH_TAGS_IN_TAG_SELECTION_DIALOG = "pref_auto_refresh_tags_in_tag_selection_dialog"; //$NON-NLS-1$ public final String PREF_COMMIT_FILES_DISPLAY_THRESHOLD = "pref_commit_files_display_threshold"; //$NON-NLS-1$ + public final String PREF_COMMIT_COMMENTS_MAX_HISTORY = "pref_commit_comments_max_history"; //$NON-NLS-1$ public final String PREF_AUTO_SHARE_ON_IMPORT = "pref_auto_share_on_import"; //$NON-NLS-1$ public final String PREF_ENABLE_WATCH_ON_EDIT = "pref_enable_watch_on_edit"; //$NON-NLS-1$ public final String PREF_USE_PROJECT_NAME_ON_CHECKOUT = "pref_use_project_name_on_checkout"; //$NON-NLS-1$ diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CommentHistoryContentHandler.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CommentHistoryContentHandler.java index ebd2eeace..5ee76b40f 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CommentHistoryContentHandler.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CommentHistoryContentHandler.java @@ -48,7 +48,7 @@ class CommentHistoryContentHandler extends DefaultHandler { return; } if (elementName.equals(RepositoryManager.ELEMENT_COMMIT_HISTORY)) { - comments = new Vector(RepositoryManager.MAX_COMMENTS); + comments = new Vector(RepositoryManager.DEFAULT_MAX_COMMENTS); return; } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java index 04b12986e..82e216149 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java @@ -15,15 +15,7 @@ package org.eclipse.team.internal.ccvs.ui.repo; import java.io.*; import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import javax.xml.parsers.*; @@ -32,6 +24,9 @@ import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.*; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.window.Window; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.widgets.Shell; @@ -77,7 +72,20 @@ public class RepositoryManager { private int notificationLevel = 0; private Map changedRepositories = new HashMap(); - static final int MAX_COMMENTS = 10; + public static final int DEFAULT_MAX_COMMENTS = 10; + + private int maxComments = DEFAULT_MAX_COMMENTS; + + public void setMaxComments(int maxComments) { + if (maxComments > 0) { + this.maxComments = maxComments; + if (maxComments < previousComments.length) { + String[] newComments = new String[maxComments]; + System.arraycopy(previousComments, 0, newComments, 0, maxComments); + previousComments = newComments; + } + } + } /** * Answer an array of all known remote roots. @@ -326,6 +334,25 @@ public class RepositoryManager { rootRemoved(root); } }); + + IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore(); + store.addPropertyChangeListener(new IPropertyChangeListener() { + + public void propertyChange(PropertyChangeEvent event) { + if (event.getProperty().equals(ICVSUIConstants.PREF_COMMIT_COMMENTS_MAX_HISTORY)) { + Object newValue = event.getNewValue(); + if (newValue instanceof String) { + try { + setMaxComments(Integer.parseInt((String) newValue)); + } catch (NumberFormatException e) { + // fail silently + } + } + } + } + + }); + setMaxComments(store.getInt(ICVSUIConstants.PREF_COMMIT_COMMENTS_MAX_HISTORY)); } public void shutdown() throws TeamException { @@ -548,7 +575,7 @@ public class RepositoryManager { } private void writeCommentHistory(XMLWriter writer) { writer.startTag(ELEMENT_COMMIT_HISTORY, null, false); - for (int i=0; i<previousComments.length && i<MAX_COMMENTS; i++) + for (int i = 0; i < previousComments.length && i < maxComments; i++) writer.printSimpleTag(ELEMENT_COMMIT_COMMENT, previousComments[i]); writer.endTag(ELEMENT_COMMIT_HISTORY); } @@ -827,7 +854,7 @@ public class RepositoryManager { return; // Insert the comment as the first element - String[] newComments = new String[Math.min(previousComments.length + 1, MAX_COMMENTS)]; + String[] newComments = new String[Math.min(previousComments.length + 1, maxComments)]; newComments[0] = comment; for (int i = 1; i < newComments.length; i++) { newComments[i] = previousComments[i-1]; |