diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/UniversalFileTransferUtility.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/UniversalFileTransferUtility.java
index 084e6a3f0dd..34f4d446982 100644
--- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/UniversalFileTransferUtility.java
+++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/UniversalFileTransferUtility.java
@@ -37,13 +37,16 @@ import org.eclipse.core.resources.ResourceAttributes;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.rse.core.SystemBasePlugin;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.model.SystemWorkspaceResourceSet;
import org.eclipse.rse.core.subsystems.ISubSystem;
+import org.eclipse.rse.files.ui.Activator;
import org.eclipse.rse.files.ui.FileResources;
import org.eclipse.rse.model.SystemRemoteResourceSet;
import org.eclipse.rse.services.clientserver.SystemEncodingUtil;
@@ -80,6 +83,22 @@ public class UniversalFileTransferUtility
static final String _rootPath = SystemRemoteEditManager.getDefault().getRemoteEditProjectLocation().makeAbsolute().toOSString();
+ public static class RenameStatus extends Status {
+
+ private static final int CANCEL_ALL = 16;
+
+ /**
+ * @param severity
+ * @param pluginId
+ * @param code
+ * @param message
+ * @param exception
+ */
+ public RenameStatus(int severity, String pluginId, int code, String message, Throwable exception) {
+ super(severity, pluginId, code, message, exception);
+ }
+ }
+
/**
* Transfer a remote file or folder from one remote location to another.
* @param srcFileOrFolder the file or folder to copy
@@ -962,11 +981,22 @@ public class UniversalFileTransferUtility
String oldPath = newPathBuf.toString() + name;
if (checkForCollisions)
{
- name = checkForCollision(existingFiles, targetFolder, name, oldPath);
- if (name == null)
- {
- continue;
- //return null;
+ RenameStatus status = checkForCollision(existingFiles, targetFolder, name, oldPath);
+ int severity = status.getSeverity();
+
+ if (severity == IStatus.OK) {
+ name = status.getMessage();
+ }
+ else if (severity == IStatus.CANCEL) {
+
+ int code = status.getCode();
+
+ if (code == IStatus.CANCEL) {
+ continue;
+ }
+ else if (code == RenameStatus.CANCEL_ALL) {
+ break;
+ }
}
}
@@ -1894,48 +1924,84 @@ public class UniversalFileTransferUtility
return SystemRemoteEditManager.getDefault().getWorkspacePathFor(hostname, remotePath);
}
- protected static String checkForCollision(SystemRemoteResourceSet existingFiles, IRemoteFile targetFolder, String oldName, String oldPath)
+ protected static RenameStatus checkForCollision(SystemRemoteResourceSet existingFiles, IRemoteFile targetFolder, String oldName, String oldPath)
{
String newName = oldName;
- IRemoteFileSubSystem ss = targetFolder.getParentRemoteFileSubSystem();
- IRemoteFile targetFileOrFolder = (IRemoteFile)existingFiles.get(oldPath);
+ IRemoteFileSubSystem ss = targetFolder.getParentRemoteFileSubSystem();
+ IRemoteFile targetFileOrFolder = (IRemoteFile) existingFiles.get(oldPath);
- if (targetFileOrFolder != null && targetFileOrFolder.exists())
- {
- RenameRunnable rr = new RenameRunnable(targetFileOrFolder);
- Display.getDefault().syncExec(rr);
- newName = rr.getNewName();
+ RenameStatus status = new RenameStatus(IStatus.OK, Activator.getDefault().getBundle().getSymbolicName(), IStatus.OK, newName, null);
+
+ if (targetFileOrFolder != null && targetFileOrFolder.exists()) {
+ RenameRunnable rr = new RenameRunnable(targetFileOrFolder);
+ Display.getDefault().syncExec(rr);
+ newName = rr.getNewName();
+
+ if (newName == null) {
+
+ int state = rr.getCancelStatus();
+
+ if (state == RenameRunnable.RENAME_DIALOG_CANCELLED_ALL) {
+ status = new RenameStatus(IStatus.CANCEL, Activator.getDefault().getBundle().getSymbolicName(), RenameStatus.CANCEL_ALL, "", null);
+ }
+ else if (state == RenameRunnable.RENAME_DIALOG_CANCELLED) {
+ status = new RenameStatus(IStatus.CANCEL, Activator.getDefault().getBundle().getSymbolicName(), IStatus.CANCEL, "", null);
+ }
}
+ else {
+ status = new RenameStatus(IStatus.OK, Activator.getDefault().getBundle().getSymbolicName(), IStatus.OK, newName, null);
+ }
+ }
- return newName;
+ return status;
}
public static class RenameRunnable implements Runnable
{
private IRemoteFile _targetFileOrFolder;
private String _newName;
+ private int cancelStatus;
+
+ public static int RENAME_DIALOG_NOT_CANCELLED = -1;
+ public static int RENAME_DIALOG_CANCELLED = 0;
+ public static int RENAME_DIALOG_CANCELLED_ALL = 1;
+
public RenameRunnable(IRemoteFile targetFileOrFolder)
{
_targetFileOrFolder = targetFileOrFolder;
+ cancelStatus = RENAME_DIALOG_NOT_CANCELLED;
}
public void run() {
ValidatorFileUniqueName validator = null;
SystemRenameSingleDialog dlg = new SystemRenameSingleDialog(null, true, _targetFileOrFolder, validator); // true => copy-collision-mode
+ dlg.setShowCancelAllButton(true);
dlg.open();
- if (!dlg.wasCancelled())
+ if (!dlg.wasCancelled() && !dlg.wasCancelledAll())
_newName = dlg.getNewName();
- else
+ else {
_newName = null;
+
+ if (dlg.wasCancelledAll()) {
+ cancelStatus = RENAME_DIALOG_CANCELLED_ALL;
+ }
+ else {
+ cancelStatus = RENAME_DIALOG_CANCELLED;
+ }
+ }
}
public String getNewName()
{
return _newName;
}
+
+ public int getCancelStatus() {
+ return cancelStatus;
+ }
}
protected static String checkForCollision(IRemoteFile targetFolder, String oldName)
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemResources.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemResources.java
index bfa521c7ef9..1f35880f3b9 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemResources.java
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemResources.java
@@ -51,7 +51,8 @@ public class SystemResources extends NLS
public static String BUTTON_APPLY_TOOLTIP;
public static String BUTTON_RESET_LABEL;
public static String BUTTON_RESET_TOOLTIP;
-
+ public static String BUTTON_CANCEL_ALL;
+ public static String BUTTON_CANCEL_ALL_TOOLTIP;
// THESE TERMS ARE USED POTENTIALLY ANYWHERE
public static String TERM_YES;
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemResources.properties b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemResources.properties
index 38165e98440..d169e2f1fc0 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemResources.properties
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemResources.properties
@@ -29,6 +29,8 @@ BUTTON_APPLY_LABEL=Apply
BUTTON_APPLY_TOOLTIP=Press to apply pending changes
BUTTON_RESET_LABEL=Reset
BUTTON_RESET_TOOLTIP=Press to reset to original values
+BUTTON_CANCEL_ALL = Cancel All
+BUTTON_CANCEL_ALL_TOOLTIP = Cancel for all
TERM_YES=Yes
TERM_NO=No
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/SystemPromptDialog.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/SystemPromptDialog.java
index 1e52f2542b0..bd5193cd99e 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/SystemPromptDialog.java
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/SystemPromptDialog.java
@@ -134,6 +134,7 @@ public abstract class SystemPromptDialog
{
protected boolean okPressed = false;
+ protected boolean cancelAllPressed = false;
protected boolean showBrowseButton = false;
protected boolean showTestButton = false;
protected boolean showAddButton = false;
@@ -144,12 +145,13 @@ public abstract class SystemPromptDialog
protected boolean initialDetailsButtonEnabledState = true;
protected boolean detailsButtonHideMode = false;
protected boolean showOkButton = true;
+ protected boolean showCancelAllButton = false;
protected Shell overallShell = null;
protected Composite parentComposite, dialogAreaComposite;
protected Composite buttonsComposite;
- protected Button okButton, cancelButton, testButton, browseButton, addButton, detailsButton;
- protected String title, labelOk, labelBrowse, labelTest, labelCancel, labelAdd, labelDetailsShow, labelDetailsHide;
- protected String tipOk, tipBrowse, tipTest, tipCancel, tipAdd, tipDetailsShow, tipDetailsHide;
+ protected Button okButton, cancelButton, cancelAllButton, testButton, browseButton, addButton, detailsButton;
+ protected String title, labelOk, labelBrowse, labelTest, labelCancel, labelCancelAll, labelAdd, labelDetailsShow, labelDetailsHide;
+ protected String tipOk, tipBrowse, tipTest, tipCancel, tipCancelAll, tipAdd, tipDetailsShow, tipDetailsHide;
protected boolean noShowAgainOption;
protected Button noShowAgainButton;
protected String detailsShowLabel;
@@ -191,6 +193,8 @@ public abstract class SystemPromptDialog
protected static final int TEST_ID = 60;
protected static final int ADD_ID = 70;
protected static final int DETAILS_ID = 80;
+ protected static final int CANCEL_ALL_ID = 90;
+
protected static final boolean BROWSE_BUTTON_YES = true;
protected static final boolean BROWSE_BUTTON_NO = false;
protected static final boolean TEST_BUTTON_YES = true;
@@ -376,12 +380,17 @@ public abstract class SystemPromptDialog
/**
* Allow caller to determine if window was cancelled or not.
+ * Will return false
if Cancel All was pressed.
*/
public boolean wasCancelled()
{
return !okPressed;
}
+ public boolean wasCancelledAll() {
+ return cancelAllPressed;
+ }
+
/**
* If validation of the output object is desired, set the validator here.
* It will be used when the child class calls setOutputObject().
@@ -454,6 +463,7 @@ public abstract class SystemPromptDialog
{
this.showOkButton = showOk;
}
+
/**
* For explicitly setting ok button label
*/
@@ -461,6 +471,7 @@ public abstract class SystemPromptDialog
{
this.labelOk = label;
}
+
/**
* For explicitly setting ok button tooltip text
*/
@@ -468,6 +479,7 @@ public abstract class SystemPromptDialog
{
this.tipOk = tip;
}
+
/**
* For explicitly enabling/disabling ok button.
*/
@@ -545,7 +557,59 @@ public abstract class SystemPromptDialog
protected boolean processCancel()
{
return true;
- }
+ }
+
+ // ------------------------------
+ // CANCEL ALL BUTTON CONFIGURATION...
+ // ------------------------------
+ /**
+ * Enable or disable showing of Cancel All button
+ */
+ public void setShowCancelAllButton(boolean showCancelAll)
+ {
+ this.showCancelAllButton = showCancelAll;
+ }
+
+ /**
+ * For explicitly setting cancel button label
+ */
+ public void setCancelAllButtonLabel(String label)
+ {
+ this.labelCancelAll = label;
+ }
+ /**
+ * For explicitly setting cancel button tooltip text
+ */
+ public void setCancelAllButtonToolTipText(String tip)
+ {
+ this.tipCancelAll = tip;
+ }
+ /**
+ * For explicitly enabling/disabling cancel button.
+ */
+ public void enableCancelAllButton(boolean enable)
+ {
+ if (cancelAllButton != null)
+ cancelAllButton.setEnabled(enable);
+ }
+ /**
+ * Return cancel button widget.
+ * Be careful not to call the deprecated inherited method getCancelButton()!
+ */
+ public Button getCancelAllButton()
+ {
+ return cancelAllButton;
+ }
+ /**
+ * To be overridden by children.
+ * Called when user presses CANCEL button.
+ * Return true to close dialog.
+ * Return false to not close dialog.
+ */
+ protected boolean processCancelAll()
+ {
+ return true;
+ }
// ------------------------------
// BROWSE BUTTON CONFIGURATION...
@@ -894,8 +958,14 @@ public abstract class SystemPromptDialog
else if (!detailsButtonHideMode && (tipDetailsHide != null))
detailsButton.setToolTipText(tipDetailsHide);
}
- }
-
+ }
+ else if (buttonId == CANCEL_ALL_ID) {
+
+ if (processCancelAll()) {
+ cancelAllPressed = true;
+ close();
+ }
+ }
}
/**
@@ -1009,6 +1079,15 @@ public abstract class SystemPromptDialog
}
};
cancelButton.addSelectionListener(cancelListener);
+
+ if (showCancelAllButton) {
+ String cancelAllLabel = (labelCancelAll != null) ? labelCancelAll: SystemResources.BUTTON_CANCEL_ALL;
+ cancelAllButton = createButton(parent, CANCEL_ALL_ID, cancelAllLabel, false);
+
+ if (tipCancelAll != null) {
+ cancelAllButton.setToolTipText(tipCancelAll);
+ }
+ }
buttonsComposite = parent;
if (helpId != null)