Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2006-01-07 19:07:37 +0000
committerMichael Valenta2006-01-07 19:07:37 +0000
commitfcb1e397ebbf3347ca9dc597b9f7f5e961593b83 (patch)
tree53589c0a597d1277aa64ede566274ac9ec5ba36b
parent69a475f6bf0cc009e0720ea69bce2b6693f804b0 (diff)
downloadeclipse.platform.team-fcb1e397ebbf3347ca9dc597b9f7f5e961593b83.tar.gz
eclipse.platform.team-fcb1e397ebbf3347ca9dc597b9f7f5e961593b83.tar.xz
eclipse.platform.team-fcb1e397ebbf3347ca9dc597b9f7f5e961593b83.zip
Bug 121886 [Model Sync] Add option to force preview when scope expanded
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelUpdateOperation.java6
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/AdditionalMappingsDialog.java37
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/operations/ResourceMappingMergeOperation.java23
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/operations/ResourceMappingOperation.java46
4 files changed, 90 insertions, 22 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelUpdateOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelUpdateOperation.java
index 70903552d..20564703b 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelUpdateOperation.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelUpdateOperation.java
@@ -32,8 +32,12 @@ public class ModelUpdateOperation extends AbstractModelMergeOperation {
}
/* (non-Javadoc)
- * @see org.eclipse.team.ui.operations.ResourceMappingMergeOperation#isAttemptHeadlessMerge()
+ * @see org.eclipse.team.ui.operations.ResourceMappingOperation#isPreviewRequested()
*/
+ public boolean isPreviewRequested() {
+ return super.isPreviewRequested() || !isAttemptHeadlessMerge();
+ }
+
protected boolean isAttemptHeadlessMerge() {
return CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_UPDATE_HANDLING).equals(ICVSUIConstants.PREF_UPDATE_HANDLING_PERFORM);
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/AdditionalMappingsDialog.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/AdditionalMappingsDialog.java
index d48a6db5e..6220f20b6 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/AdditionalMappingsDialog.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/AdditionalMappingsDialog.java
@@ -11,10 +11,13 @@
package org.eclipse.team.internal.ui.dialogs;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.*;
import org.eclipse.team.core.mapping.*;
import org.eclipse.team.core.mapping.provider.ScopeGenerator;
+import org.eclipse.team.internal.ui.SWTUtils;
import org.eclipse.team.internal.ui.TeamUIMessages;
public class AdditionalMappingsDialog extends DetailsDialog {
@@ -23,6 +26,8 @@ public class AdditionalMappingsDialog extends DetailsDialog {
private ResourceMappingHierarchyArea allMappingsArea;
private final IResourceMappingScope scope;
private final ISynchronizationContext context;
+ private String previewMessage;
+ protected boolean forcePreview = true;
public AdditionalMappingsDialog(Shell parentShell, String dialogTitle, IResourceMappingScope scope, ISynchronizationContext context) {
super(parentShell, dialogTitle);
@@ -34,9 +39,10 @@ public class AdditionalMappingsDialog extends DetailsDialog {
createWrappingLabel(parent, TeamUIMessages.AdditionalMappingsDialog_0);
createSelectedMappingsArea(parent);
createAllMappingsArea(parent);
+ createPreviewOptionArea(parent);
}
-
- /*
+
+ /*
* Create a list that allows the selection of mappings via checkbox
*/
private void createSelectedMappingsArea(Composite parent) {
@@ -60,6 +66,21 @@ public class AdditionalMappingsDialog extends DetailsDialog {
allMappingsArea.createArea(composite);
}
+ private void createPreviewOptionArea(Composite parent) {
+ if (previewMessage != null) {
+ final Button forcePreviewButton = SWTUtils.createCheckBox(parent, previewMessage);
+ forcePreviewButton.setSelection(forcePreview);
+ forcePreviewButton.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // Ignore
+ }
+ public void widgetSelected(SelectionEvent e) {
+ forcePreview = forcePreviewButton.getSelection();
+ }
+ });
+ }
+ }
+
protected Composite createDropDownDialogArea(Composite parent) {
// TODO Auto-generated method stub
return null;
@@ -74,4 +95,16 @@ public class AdditionalMappingsDialog extends DetailsDialog {
return false;
}
+ public String getPreviewMessage() {
+ return previewMessage;
+ }
+
+ public void setPreviewMessage(String previewMessage) {
+ this.previewMessage = previewMessage;
+ }
+
+ public boolean isForcePreview() {
+ return forcePreview;
+ }
+
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/operations/ResourceMappingMergeOperation.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/operations/ResourceMappingMergeOperation.java
index 8c9464c07..cafb05e14 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/operations/ResourceMappingMergeOperation.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/operations/ResourceMappingMergeOperation.java
@@ -119,7 +119,7 @@ public abstract class ResourceMappingMergeOperation extends ResourceMappingOpera
context.dispose();
return;
}
- if (isAttemptHeadlessMerge()) {
+ if (!isPreviewRequested()) {
IStatus status = validateMerge(context, Policy.subMonitorFor(monitor, 5));
if (status.isOK()) {
if (performMerge(Policy.subMonitorFor(monitor, 20)))
@@ -182,17 +182,6 @@ public abstract class ResourceMappingMergeOperation extends ResourceMappingOpera
return new MultiStatus(TeamUIPlugin.ID, 0, (IStatus[]) notOK.toArray(new IStatus[notOK.size()]), "Multiple potential side effects of this operation have been detected.", null);
}
- /**
- * Return whether a headless merge should be attempted without showing a preview to
- * the user. If the merge succeeds, the operations finishes. However, if conflicts
- * exist, the user will be prompted to handle these conflicts. By default, <code>false</code>
- * is returned.
- * @return whether a headless merge should be attempted
- */
- protected boolean isAttemptHeadlessMerge() {
- return false;
- }
-
private void promptForNoChanges() {
Display.getDefault().syncExec(new Runnable() {
public void run() {
@@ -284,5 +273,15 @@ public abstract class ResourceMappingMergeOperation extends ResourceMappingOpera
protected ISynchronizationContext getContext() {
return context;
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.operations.ResourceMappingOperation#getPreviewRequestMessage()
+ */
+ protected String getPreviewRequestMessage() {
+ if (!isPreviewRequested()) {
+ return "Preview the merge before it is performed";
+ }
+ return super.getPreviewRequestMessage();
+ }
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/operations/ResourceMappingOperation.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/operations/ResourceMappingOperation.java
index ce297516f..9758053f4 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/operations/ResourceMappingOperation.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/operations/ResourceMappingOperation.java
@@ -70,6 +70,7 @@ public abstract class ResourceMappingOperation extends ModelProviderOperation {
private final ResourceMapping[] selectedMappings;
private final ResourceMappingContext context;
private IResourceMappingScope scope;
+ private boolean previewRequested;
/**
* Create a resource mapping based operation
@@ -165,14 +166,27 @@ public abstract class ResourceMappingOperation extends ModelProviderOperation {
}
}
}
- if (prompt)
- promptForInputChange(monitor);
+ if (prompt) {
+ String previewMessage = getPreviewRequestMessage();
+ previewRequested = promptForInputChange(previewMessage, monitor);
+ }
}
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
}
+ /**
+ * Return a string to be used in the preview request on the scope prompt
+ * or <code>null</code> if a preview of the operation results is not possible.
+ * By default, <code>null</code> is returned but subclasses may override.
+ * @return a string to be used in the preview request on the scope prompt
+ * or <code>null</code> if a preview of the operation results is not possible
+ */
+ protected String getPreviewRequestMessage() {
+ return null;
+ }
+
private boolean hasAdditionalMappingsFromIndependantModel(ModelProvider[] inputModelProviders, ModelProvider[] modelProviders) {
ModelProvider[] additionalProviders = getAdditionalProviders(inputModelProviders, modelProviders);
for (int i = 0; i < additionalProviders.length; i++) {
@@ -301,27 +315,35 @@ public abstract class ResourceMappingOperation extends ModelProviderOperation {
/**
* Prompt the user to inform them that additional resource mappings
* have been included in the operations.
+ * @param requestPreviewMessage message to be displayed for the option to force a preview
+ * (or <code>null</code> if the preview option shoudl not be presented
* @param monitor a progress monitor
+ * @returns whether a preview of the operation results was requested
* @throws OperationCanceledException if the user choose to cancel
*/
- protected void promptForInputChange(IProgressMonitor monitor) {
- showAllMappings();
+ protected boolean promptForInputChange(String requestPreviewMessage, IProgressMonitor monitor) {
+ return showAllMappings(requestPreviewMessage);
}
- private void showAllMappings() {
+ private boolean showAllMappings(final String requestPreviewMessage) {
final boolean[] canceled = new boolean[] { false };
+ final boolean[] forcePreview = new boolean[] { false };
getShell().getDisplay().syncExec(new Runnable() {
public void run() {
AdditionalMappingsDialog dialog = new AdditionalMappingsDialog(getShell(), TeamUIMessages.ResourceMappingOperation_0, getScope(), getContext());
+ dialog.setPreviewMessage(requestPreviewMessage);
int result = dialog.open();
canceled[0] = result != Window.OK;
- }
-
+ if (requestPreviewMessage != null) {
+ forcePreview[0] = dialog.isForcePreview();
+ }
+ }
});
if (canceled[0]) {
throw new OperationCanceledException();
}
+ return forcePreview[0];
}
/**
@@ -340,5 +362,15 @@ public abstract class ResourceMappingOperation extends ModelProviderOperation {
public IResourceMappingScope getScope() {
return scope;
}
+
+ /**
+ * Return whether a preview of the operation before it is performed is
+ * desired.
+ * @return whether a preview of the operation before it is performed is
+ * desired
+ */
+ public boolean isPreviewRequested() {
+ return previewRequested;
+ }
}

Back to the top