Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2004-01-26 17:45:07 +0000
committerMichael Valenta2004-01-26 17:45:07 +0000
commit361cfd29f6e41959ead5613528021383f9fa41f8 (patch)
tree4673268f17ad333f3f7552ab709475be6c26461d /bundles
parent09e8623904c126cc5c3ef3c185b34242bcf7fc85 (diff)
downloadeclipse.platform.team-361cfd29f6e41959ead5613528021383f9fa41f8.tar.gz
eclipse.platform.team-361cfd29f6e41959ead5613528021383f9fa41f8.tar.xz
eclipse.platform.team-361cfd29f6e41959ead5613528021383f9fa41f8.zip
30657: Better CVS watch/edit options needed for prompts when a read-only file is modified in an editorI20040127
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java7
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/FileModificationValidator.java48
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java12
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WatchEditPreferencePage.java61
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/EditorsAction.java36
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties10
6 files changed, 128 insertions, 46 deletions
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 24d5fb4bf..baccae4bd 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
@@ -95,10 +95,6 @@ public class CVSUIPlugin extends AbstractUIPlugin {
*/
private RepositoryManager repositoryManager;
- // constants used by watch/edit as values for string preference
- public static final String EDIT = "edit"; //$NON-NLS-1$
- public static final String HIGHJACK = "highjack"; //$NON-NLS-1$
-
/**
* CVSUIPlugin constructor
*
@@ -643,7 +639,8 @@ public class CVSUIPlugin extends AbstractUIPlugin {
// Set the watch/edit preferences defaults and values
store.setDefault(ICVSUIConstants.PREF_CHECKOUT_READ_ONLY, corePrefs.getDefaultBoolean(CVSProviderPlugin.READ_ONLY));
- store.setDefault(ICVSUIConstants.PREF_EDIT_ACTION, EDIT);
+ store.setDefault(ICVSUIConstants.PREF_EDIT_ACTION, ICVSUIConstants.PREF_EDIT_PROMPT_EDIT);
+ store.setDefault(ICVSUIConstants.PREF_EDIT_PROMPT, ICVSUIConstants.PREF_EDIT_PROMPT_IF_EDITORS);
// Ensure that the preference values in UI match Core
store.setValue(ICVSUIConstants.PREF_CHECKOUT_READ_ONLY, corePrefs.getBoolean(CVSProviderPlugin.READ_ONLY));
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/FileModificationValidator.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/FileModificationValidator.java
index c9c53ec2d..c87acd89a 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/FileModificationValidator.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/FileModificationValidator.java
@@ -19,6 +19,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.core.RepositoryProvider;
@@ -30,6 +31,7 @@ import org.eclipse.team.internal.ccvs.core.ICVSFile;
import org.eclipse.team.internal.ccvs.core.ICVSFileModificationValidator;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.ui.actions.EditorsAction;
+import org.eclipse.team.internal.ccvs.ui.Policy;
/**
* IFileModificationValidator that is pluged into the CVS Repository Provider
@@ -152,14 +154,22 @@ public class FileModificationValidator implements ICVSFileModificationValidator
private boolean promptToEditFiles(IFile[] files, Shell shell) throws InvocationTargetException, InterruptedException {
if (files.length == 0)
- return true;
-
- EditorsAction editors = new EditorsAction(getProvider(files),files);
- if (editors.isPerformEdit()) {
- // determine if there are any editors of the file registered on the server
- run(shell, editors);
- // prompt if there are
- return editors.promptToEdit(shell);
+ return true;
+
+ if (isPerformEdit() ) {
+ if(isNeverPrompt())
+ return true;
+
+ // Contact the server to see if anyone else is editing the files
+ EditorsAction editors = fetchEditors(files, shell);
+ if (editors.isEmpty()) {
+ if (isAlwaysPrompt())
+ return (promptEdit(shell));
+ else
+ return true;
+ } else {
+ return (editors.promptToEdit(shell));
+ }
} else {
// Allow the files to be edited without notifying the server
for (int i = 0; i < files.length; i++) {
@@ -171,6 +181,28 @@ public class FileModificationValidator implements ICVSFileModificationValidator
}
+ private boolean promptEdit(Shell shell) {
+ return MessageDialog.openQuestion(shell,Policy.bind("FileModificationValidator.3"),Policy.bind("FileModificationValidator.4")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public boolean isPerformEdit() {
+ return ICVSUIConstants.PREF_EDIT_PROMPT_EDIT.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_EDIT_ACTION));
+ }
+
+ private EditorsAction fetchEditors(IFile[] files, Shell shell) throws InvocationTargetException, InterruptedException {
+ EditorsAction editors = new EditorsAction(getProvider(files),files);
+ run(shell, editors);
+ return editors;
+ }
+
+ private boolean isNeverPrompt() {
+ return ICVSUIConstants.PREF_EDIT_PROMPT_NEVER.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_EDIT_PROMPT));
+ }
+
+ private boolean isAlwaysPrompt() {
+ return ICVSUIConstants.PREF_EDIT_PROMPT_ALWAYS.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_EDIT_PROMPT));
+ }
+
private void run(Shell shell, final IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException {
final InvocationTargetException[] exception = new InvocationTargetException[] { null };
CVSUIPlugin.runWithProgress(shell, false, runnable, CVSUIPlugin.PERFORM_SYNC_EXEC);
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 2bf8d1148..6fcad9f96 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
@@ -12,7 +12,7 @@
package org.eclipse.team.internal.ccvs.ui;
public interface ICVSUIConstants {
- public static final String PREFIX = CVSUIPlugin.ID + "."; //$NON-NLS-1$
+ public final String PREFIX = CVSUIPlugin.ID + "."; //$NON-NLS-1$
// image path
public final String ICON_PATH = "icons/full/"; //$NON-NLS-1$
@@ -102,6 +102,12 @@ public interface ICVSUIConstants {
// watch/edit preferences
public final String PREF_CHECKOUT_READ_ONLY = "pref_checkout_read_only"; //$NON-NLS-1$
public final String PREF_EDIT_ACTION = "pref_edit_action"; //$NON-NLS-1$
+ public final String PREF_EDIT_PROMPT_EDIT = "edit"; //$NON-NLS-1$
+ public final String PREF_EDIT_PROMPT_HIGHJACK = "highjack"; //$NON-NLS-1$
+ public final String PREF_EDIT_PROMPT = "pref_edit_prompt"; //$NON-NLS-1$
+ public final String PREF_EDIT_PROMPT_NEVER = "never"; //$NON-NLS-1$
+ public final String PREF_EDIT_PROMPT_ALWAYS = "always"; //$NON-NLS-1$
+ public final String PREF_EDIT_PROMPT_IF_EDITORS = "only"; //$NON-NLS-1$
// Repositories view preferences
public final String PREF_GROUP_VERSIONS_BY_PROJECT = "pref_group_versions_by_project"; //$NON-NLS-1$
@@ -133,8 +139,8 @@ public interface ICVSUIConstants {
public final String PROP_ROOT = "cvs.root"; //$NON-NLS-1$
// preference options
- public final int OPTION_NEVER = 1; //$NON-NLS-1$
- public final int OPTION_PROMPT = 2; //$NON-NLS-1$
+ public final int OPTION_NEVER = 1;
+ public final int OPTION_PROMPT = 2;
public final int OPTION_AUTOMATIC = 3;
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WatchEditPreferencePage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WatchEditPreferencePage.java
index a36bee70c..9787524bb 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WatchEditPreferencePage.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WatchEditPreferencePage.java
@@ -11,9 +11,8 @@
package org.eclipse.team.internal.ccvs.ui;
import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jface.preference.BooleanFieldEditor;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.RadioGroupFieldEditor;
+import org.eclipse.jface.preference.*;
+import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
/**
@@ -21,6 +20,11 @@ import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
*/
public class WatchEditPreferencePage extends CVSFieldEditorPreferencePage {
+ private RadioGroupFieldEditor promptEditor;
+ private RadioGroupFieldEditor actionEditor;
+ private IPreferenceStore source;
+ private IPreferenceStore store;
+
/**
* @see org.eclipse.team.internal.ccvs.ui.CVSPreferencePage#getPageHelpContextId()
*/
@@ -43,14 +47,35 @@ public class WatchEditPreferencePage extends CVSFieldEditorPreferencePage {
Policy.bind("WatchEditPreferencePage.checkoutReadOnly"), //$NON-NLS-1$
BooleanFieldEditor.DEFAULT,
getFieldEditorParent()));
- addField(new RadioGroupFieldEditor(
+
+ actionEditor = new RadioGroupFieldEditor(
ICVSUIConstants.PREF_EDIT_ACTION,
Policy.bind("WatchEditPreferencePage.validateEditSaveAction"), //$NON-NLS-1$
1,
- new String[][] {{Policy.bind("WatchEditPreferencePage.edit"), CVSUIPlugin.EDIT}, {Policy.bind("WatchEditPreferencePage.highjack"), CVSUIPlugin.HIGHJACK}}, //$NON-NLS-1$ //$NON-NLS-2$
- getFieldEditorParent(), true));
+ new String[][] {{Policy.bind("WatchEditPreferencePage.edit"), ICVSUIConstants.PREF_EDIT_PROMPT_EDIT}, //$NON-NLS-1$
+ {Policy.bind("WatchEditPreferencePage.highjack"), ICVSUIConstants.PREF_EDIT_PROMPT_HIGHJACK}, //$NON-NLS-1$
+ }, //$NON-NLS-1$ //$NON-NLS-2$
+ getFieldEditorParent(), true);
+ addField(actionEditor);
+
+
+ promptEditor = new RadioGroupFieldEditor(
+ ICVSUIConstants.PREF_EDIT_PROMPT,
+ Policy.bind("WatchEditPreferencePage.editPrompt"), //$NON-NLS-1$
+ 1,
+ new String[][] {{Policy.bind("WatchEditPreferencePage.alwaysPrompt"), ICVSUIConstants.PREF_EDIT_PROMPT_ALWAYS}, //$NON-NLS-1$
+ {Policy.bind("WatchEditPreferencePage.onlyPrompt"), ICVSUIConstants.PREF_EDIT_PROMPT_IF_EDITORS}, //$NON-NLS-1$
+ {Policy.bind("WatchEditPreferencePage.neverPrompt"), ICVSUIConstants.PREF_EDIT_PROMPT_NEVER}, //$NON-NLS-1$
+ }, //$NON-NLS-1$ //$NON-NLS-2$
+ getFieldEditorParent(), true);
+ store = getCVSPreferenceStore();
+ addField(promptEditor);
}
+ private boolean isEditEnabled() {
+ return store.getString(ICVSUIConstants.PREF_EDIT_ACTION).equals(ICVSUIConstants.PREF_EDIT_PROMPT_EDIT);
+ }
+
/**
* @see org.eclipse.jface.preference.IPreferencePage#performOk()
*/
@@ -61,11 +86,31 @@ public class WatchEditPreferencePage extends CVSFieldEditorPreferencePage {
}
private void pushPreferences() {
- IPreferenceStore source = getCVSPreferenceStore();
+ store = getCVSPreferenceStore();
Preferences target = CVSProviderPlugin.getPlugin().getPluginPreferences();
target.setValue(
CVSProviderPlugin.READ_ONLY,
- source.getBoolean(ICVSUIConstants.PREF_CHECKOUT_READ_ONLY));
+ store.getBoolean(ICVSUIConstants.PREF_CHECKOUT_READ_ONLY));
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getSource() == actionEditor) {
+ promptEditor.setEnabled(
+ event.getNewValue().equals(ICVSUIConstants.PREF_EDIT_PROMPT_EDIT),
+ getFieldEditorParent());
+ }
+ super.propertyChange(event);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.FieldEditorPreferencePage#initialize()
+ */
+ protected void initialize() {
+ super.initialize();
+ promptEditor.setEnabled(isEditEnabled(), getFieldEditorParent());
+ }
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/EditorsAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/EditorsAction.java
index 53000f69f..f1c3c5d85 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/EditorsAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/EditorsAction.java
@@ -18,15 +18,10 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.core.Team;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSTeamProvider;
-import org.eclipse.team.internal.ccvs.core.EditorsInfo;
-import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
-import org.eclipse.team.internal.ccvs.ui.EditorsDialog;
-import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
-import org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction.IProviderAction;
+import org.eclipse.team.internal.ccvs.core.*;
+import org.eclipse.team.internal.ccvs.ui.*;
import org.eclipse.team.internal.ccvs.ui.Policy;
-
+import org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction.IProviderAction;
/**
* This Action gets the <code>EditorsInfo[]</code>
@@ -57,17 +52,9 @@ public class EditorsAction implements IProviderAction, IRunnableWithProgress {
f_editorsInfo = provider.editors(resources, monitor);
return Team.OK_STATUS;
}
-
- public boolean isPerformEdit() {
- return CVSUIPlugin.EDIT.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_EDIT_ACTION));
- }
-
public boolean promptToEdit(Shell shell) {
-
- if (!isPerformEdit()) return true;
-
- if (f_editorsInfo.length > 0) {
+ if (!isEmpty()) {
final EditorsDialog view = new EditorsDialog(shell, f_editorsInfo);
// Open the dialog using a sync exec (there are no guarentees that we
// were called from the UI thread
@@ -79,12 +66,11 @@ public class EditorsAction implements IProviderAction, IRunnableWithProgress {
return (view.getReturnCode() == EditorsDialog.OK);
}
return true;
-
-
-
}
/**
+ * Contact the server to determine if there are any editors on the associatd files.
+ *
* @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
*/
public void run(IProgressMonitor monitor)
@@ -107,4 +93,14 @@ public class EditorsAction implements IProviderAction, IRunnableWithProgress {
return f_editorsInfo;
}
+ /**
+ * Indicates whether there are editors of any of the associated files.
+ * The <code>run(IProgressMonitor)</code> must be invoked first to
+ * fetch any editors from the server.
+ * @return boolean
+ */
+ public boolean isEmpty() {
+ return f_editorsInfo.length == 0;
+ }
+
}
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 f897563ed..e359744d0 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
@@ -863,8 +863,12 @@ RefreshTagsAction.message=Repository ''{0}'' has {1} projects to refresh. Contin
WatchEditPreferencePage.description=Settings for CVS Watch/Edit.
WatchEditPreferencePage.checkoutReadOnly=&Configure projects to use Watch/Edit on checkout
WatchEditPreferencePage.validateEditSaveAction=When read-only files are modified in an editor
-WatchEditPreferencePage.edit=Send a cvs &edit notification to the server
+WatchEditPreferencePage.edit=Send a CVS &edit notification to the server
WatchEditPreferencePage.highjack=Edit the file &without informing the server
+WatchEditPreferencePage.editPrompt=Before a CVS edit notification is sent to the server
+WatchEditPreferencePage.neverPrompt=&Never prompt
+WatchEditPreferencePage.alwaysPrompt=Always &prompt
+WatchEditPreferencePage.onlyPrompt=&Only prompt if there are other editors
Uneditaction.confirmMessage=Overwrite local changes to edited files?
Uneditaction.confirmTitle=Confirm Unedit
@@ -886,7 +890,7 @@ EditorsView.date=Date
EditorsView.computer=Computer name
EditorsDialog.title=Editors
-EditorsDialog.question=The resource already has editors. Do you still want to edit the resource?
+EditorsDialog.question=The resource already has editors. Do you still want to edit the resource and send a CVS edit notification to server?
EditorsAction.classNotInitialized={0} not initialized
TargetLocationSelectionDialog.projectNameLabel=&Project Name:
@@ -1053,3 +1057,5 @@ DisconnectOperation.0=Disconnecting
SubscriberConfirmMergedAction.0=Synchronization information is missing for resource {0}
SubscriberConfirmMergedAction.jobName=Performing a CVS Mark as Merged operation on {0} resources.
CVSSubscriberAction.0=Invalid attemp to make unsupervised resource {0} in-sync.
+FileModificationValidator.3=Perform Edit?
+FileModificationValidator.4=A CVS edit notification is required to be sent to the server in order to allow editing of one or more selected files. Continue?

Back to the top