mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-14 12:35:22 +02:00
231346] fix: [api][regression] No longer able to restrict selection to files only in SystemSelectRemoteFileAction
This commit is contained in:
parent
e61d4b6e36
commit
8cc3815e48
3 changed files with 80 additions and 4 deletions
|
@ -13,20 +13,25 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType
|
* 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] 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;
|
package org.eclipse.rse.files.ui.actions;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.jface.dialogs.Dialog;
|
import org.eclipse.jface.dialogs.Dialog;
|
||||||
import org.eclipse.jface.viewers.ViewerFilter;
|
import org.eclipse.jface.viewers.ViewerFilter;
|
||||||
import org.eclipse.rse.core.IRSESystemType;
|
import org.eclipse.rse.core.IRSESystemType;
|
||||||
import org.eclipse.rse.core.model.IHost;
|
import org.eclipse.rse.core.model.IHost;
|
||||||
import org.eclipse.rse.files.ui.dialogs.SystemRemoteFileDialog;
|
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.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.model.RemoteFileUtility;
|
||||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
|
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
|
||||||
|
@ -34,6 +39,7 @@ import org.eclipse.rse.ui.SystemActionViewerFilter;
|
||||||
import org.eclipse.rse.ui.actions.SystemBaseDialogAction;
|
import org.eclipse.rse.ui.actions.SystemBaseDialogAction;
|
||||||
import org.eclipse.rse.ui.dialogs.SystemRemoteResourceDialog;
|
import org.eclipse.rse.ui.dialogs.SystemRemoteResourceDialog;
|
||||||
import org.eclipse.rse.ui.validators.IValidatorRemoteSelection;
|
import org.eclipse.rse.ui.validators.IValidatorRemoteSelection;
|
||||||
|
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,7 +70,7 @@ import org.eclipse.swt.widgets.Shell;
|
||||||
* <li>{@link #getSelectedConnection()}
|
* <li>{@link #getSelectedConnection()}
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
public class SystemSelectRemoteFileAction extends SystemBaseDialogAction
|
public class SystemSelectRemoteFileAction extends SystemBaseDialogAction
|
||||||
{
|
{
|
||||||
private IRSESystemType[] systemTypes;
|
private IRSESystemType[] systemTypes;
|
||||||
private IHost systemConnection, outputConnection;
|
private IHost systemConnection, outputConnection;
|
||||||
|
@ -81,7 +87,57 @@ public class SystemSelectRemoteFileAction extends SystemBaseDialogAction
|
||||||
private IValidatorRemoteSelection selectionValidator;
|
private IValidatorRemoteSelection selectionValidator;
|
||||||
private List viewerFilters = new ArrayList();
|
private List viewerFilters = new ArrayList();
|
||||||
private SystemActionViewerFilter customViewerFilter = null;
|
private SystemActionViewerFilter customViewerFilter = null;
|
||||||
|
private boolean allowFolderSelection = true;
|
||||||
|
|
||||||
|
static class RemoteFileSelectionValidator implements IValidatorRemoteSelection
|
||||||
|
{
|
||||||
|
private boolean allowFolderSelect = true;
|
||||||
|
public RemoteFileSelectionValidator(boolean allowFolderSelection)
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
this.allowFolderSelect = allowFolderSelection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 (allowFolderSelect == 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Constructor that uses default action label and tooltip
|
* Constructor that uses default action label and tooltip
|
||||||
*
|
*
|
||||||
|
@ -90,6 +146,7 @@ public class SystemSelectRemoteFileAction extends SystemBaseDialogAction
|
||||||
public SystemSelectRemoteFileAction(Shell shell)
|
public SystemSelectRemoteFileAction(Shell shell)
|
||||||
{
|
{
|
||||||
this(shell, FileResources.ACTION_SELECT_FILE_LABEL, FileResources.ACTION_SELECT_FILE_TOOLTIP);
|
this(shell, FileResources.ACTION_SELECT_FILE_LABEL, FileResources.ACTION_SELECT_FILE_TOOLTIP);
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Constructor when you have your own action label and tooltip
|
* Constructor when you have your own action label and tooltip
|
||||||
|
@ -408,6 +465,7 @@ public class SystemSelectRemoteFileAction extends SystemBaseDialogAction
|
||||||
|
|
||||||
dlg.setMultipleSelectionMode(multipleSelectionMode);
|
dlg.setMultipleSelectionMode(multipleSelectionMode);
|
||||||
dlg.setShowNewConnectionPrompt(showNewConnectionPrompt);
|
dlg.setShowNewConnectionPrompt(showNewConnectionPrompt);
|
||||||
|
dlg.setSelectionValidator(selectionValidator);
|
||||||
|
|
||||||
if (systemConnection != null)
|
if (systemConnection != null)
|
||||||
{
|
{
|
||||||
|
@ -447,8 +505,11 @@ public class SystemSelectRemoteFileAction extends SystemBaseDialogAction
|
||||||
else
|
else
|
||||||
dlg.enableAddMode(addButtonCallback);
|
dlg.enableAddMode(addButtonCallback);
|
||||||
*/
|
*/
|
||||||
if (selectionValidator != null)
|
if (selectionValidator == null)
|
||||||
dlg.setSelectionValidator(selectionValidator);
|
{
|
||||||
|
selectionValidator = new RemoteFileSelectionValidator(allowFolderSelection);
|
||||||
|
}
|
||||||
|
dlg.setSelectionValidator(selectionValidator);
|
||||||
/*
|
/*
|
||||||
if (!allowFolderSelection) {
|
if (!allowFolderSelection) {
|
||||||
dlg.setAllowFolderSelection(allowFolderSelection);
|
dlg.setAllowFolderSelection(allowFolderSelection);
|
||||||
|
@ -497,4 +558,14 @@ public class SystemSelectRemoteFileAction extends SystemBaseDialogAction
|
||||||
viewerFilters.add(filter);
|
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 <code>true</code>.
|
||||||
|
* @param allow <code>true</code> to allow folder selection, <code>false</code> otherwise.
|
||||||
|
*/
|
||||||
|
public void setAllowFolderSelection(boolean allow) {
|
||||||
|
allowFolderSelection = allow;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -404,6 +404,9 @@ public class FileResources extends NLS
|
||||||
|
|
||||||
public static String MSG_CREATEFILEGENERIC_PROGRESS;
|
public static String MSG_CREATEFILEGENERIC_PROGRESS;
|
||||||
public static String MSG_CREATEFOLDERGENERIC_PROGRESS;
|
public static String MSG_CREATEFOLDERGENERIC_PROGRESS;
|
||||||
|
|
||||||
|
public static String MSG_MAKE_SELECTION;
|
||||||
|
public static String MSG_SELECT_FOLDER_NOT_VALID;
|
||||||
|
|
||||||
|
|
||||||
// preferences
|
// preferences
|
||||||
|
|
|
@ -409,4 +409,6 @@ EditorManager_saveResourcesTitle = Save Resources
|
||||||
OpenWithMenu_Other=Other...
|
OpenWithMenu_Other=Other...
|
||||||
OpenWithMenu_OtherDialogDescription=Choose the editor for opening {0}:
|
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.
|
||||||
|
|
Loading…
Add table
Reference in a new issue