### Eclipse Workspace Patch 1.0 #P org.eclipse.rse.files.ui Index: src/org/eclipse/rse/internal/files/ui/FileResources.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/FileResources.java,v retrieving revision 1.22 diff -u -r1.22 FileResources.java --- src/org/eclipse/rse/internal/files/ui/FileResources.java 13 May 2008 23:15:17 -0000 1.22 +++ src/org/eclipse/rse/internal/files/ui/FileResources.java 16 May 2008 19:22:27 -0000 @@ -404,6 +404,9 @@ public static String MSG_CREATEFILEGENERIC_PROGRESS; public static String MSG_CREATEFOLDERGENERIC_PROGRESS; + + public static String MSG_MAKE_SELECTION; + public static String MSG_SELECT_FOLDER_NOT_VALID; // preferences Index: src/org/eclipse/rse/internal/files/ui/FileResources.properties =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/FileResources.properties,v retrieving revision 1.28 diff -u -r1.28 FileResources.properties --- src/org/eclipse/rse/internal/files/ui/FileResources.properties 13 May 2008 23:15:17 -0000 1.28 +++ src/org/eclipse/rse/internal/files/ui/FileResources.properties 16 May 2008 19:22:27 -0000 @@ -409,4 +409,6 @@ OpenWithMenu_Other=Other... OpenWithMenu_OtherDialogDescription=Choose the editor for opening {0}: +MSG_MAKE_SELECTION = Please make a selection. +MSG_SELECT_FOLDER_NOT_VALID=Folder is not a valid selection. \ No newline at end of file Index: src/org/eclipse/rse/files/ui/actions/SystemSelectRemoteFileAction.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/actions/SystemSelectRemoteFileAction.java,v retrieving revision 1.9 diff -u -r1.9 SystemSelectRemoteFileAction.java --- src/org/eclipse/rse/files/ui/actions/SystemSelectRemoteFileAction.java 10 Mar 2008 20:38:23 -0000 1.9 +++ src/org/eclipse/rse/files/ui/actions/SystemSelectRemoteFileAction.java 16 May 2008 19:22:27 -0000 @@ -13,20 +13,25 @@ * Contributors: * Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType * Xuan Chen (IBM) - [220999] [api] Need to change class SystemSelectRemoteFileAction to use SystemRemoteFileDialog - * Xuan Chen (IBM) - [220999] [api] Also need to remove unnecessary APIs + * Xuan Chen (IBM) - [220999] [api] [breaking] Also need to remove unnecessary APIs + * Xuan Chen (IBM) - [231346] [api][regression] No longer able to restrict selection to files only in SystemSelectRemoteFileAction ********************************************************************************/ package org.eclipse.rse.files.ui.actions; import java.util.ArrayList; import java.util.List; +import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.rse.core.IRSESystemType; import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.files.ui.dialogs.SystemRemoteFileDialog; +import org.eclipse.rse.internal.files.ui.Activator; import org.eclipse.rse.internal.files.ui.FileResources; +import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage; +import org.eclipse.rse.services.clientserver.messages.SystemMessage; import org.eclipse.rse.subsystems.files.core.model.RemoteFileUtility; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem; @@ -34,6 +39,7 @@ import org.eclipse.rse.ui.actions.SystemBaseDialogAction; import org.eclipse.rse.ui.dialogs.SystemRemoteResourceDialog; import org.eclipse.rse.ui.validators.IValidatorRemoteSelection; +import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter; import org.eclipse.swt.widgets.Shell; @@ -64,7 +70,7 @@ *
  • {@link #getSelectedConnection()} * */ -public class SystemSelectRemoteFileAction extends SystemBaseDialogAction +public class SystemSelectRemoteFileAction extends SystemBaseDialogAction implements IValidatorRemoteSelection { private IRSESystemType[] systemTypes; private IHost systemConnection, outputConnection; @@ -81,6 +87,7 @@ private IValidatorRemoteSelection selectionValidator; private List viewerFilters = new ArrayList(); private SystemActionViewerFilter customViewerFilter = null; + private boolean allowFolderSelection = true; /** * Constructor that uses default action label and tooltip @@ -408,6 +415,7 @@ dlg.setMultipleSelectionMode(multipleSelectionMode); dlg.setShowNewConnectionPrompt(showNewConnectionPrompt); + dlg.setSelectionValidator(this); if (systemConnection != null) { @@ -497,4 +505,53 @@ viewerFilters.add(filter); } + /** + * Sets whether to allow folder selection. The default selection validator will use this to + * determine whether the OK button will be enabled when a folder is selected. The default + * is true. + * @param allow true to allow folder selection, false otherwise. + */ + public void setAllowFolderSelection(boolean allow) { + allowFolderSelection = allow; + } + + /** + * The user has selected a remote object. Return null if OK is to be enabled, or a SystemMessage + * if it is not to be enabled. The message will be displayed on the message line. + */ + public SystemMessage isValid(IHost selectedConnection, Object[] selectedObjects, ISystemRemoteElementAdapter[] remoteAdaptersForSelectedObjects) + { + //if (selectedConnection != sourceConnection) {} // someday, but can't happen today. + SimpleSystemMessage msg = null; + + if (selectedObjects == null || selectedObjects.length == 0) + { + msg = new SimpleSystemMessage(Activator.PLUGIN_ID, + IStatus.INFO, + FileResources.MSG_MAKE_SELECTION); + return msg; + } + + if (allowFolderSelection == true) + { + return null; + } + + for (int i = 0; i < selectedObjects.length; i++) + { + if (selectedObjects[i] instanceof IRemoteFile) + { + IRemoteFile selectedFile = (IRemoteFile)selectedObjects[i]; + if (selectedFile != null && selectedFile.isDirectory()) { + msg = new SimpleSystemMessage(Activator.PLUGIN_ID, + IStatus.INFO, + FileResources.MSG_SELECT_FOLDER_NOT_VALID); + return msg; + } + } + } + + return null; + } + } \ No newline at end of file