From 894fbb040aef4d012f39e153bd971d07b7b300e4 Mon Sep 17 00:00:00 2001 From: Xuan Chen Date: Mon, 10 Mar 2008 20:38:23 +0000 Subject: [PATCH] [220999][220995] [api] Need to remove unnecessary APIs from both SystemSelectRemoteFileAction and SystemSelectRemoteFolderAction classes --- .../actions/SystemSelectRemoteFileAction.java | 113 +++++------------- .../SystemSelectRemoteFolderAction.java | 97 +++++---------- .../dialogs/SystemRemoteResourceDialog.java | 10 +- 3 files changed, 67 insertions(+), 153 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/actions/SystemSelectRemoteFileAction.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/actions/SystemSelectRemoteFileAction.java index 1c3bd6cb8a3..18cd95641ad 100644 --- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/actions/SystemSelectRemoteFileAction.java +++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/actions/SystemSelectRemoteFileAction.java @@ -13,21 +13,23 @@ * 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 ********************************************************************************/ package org.eclipse.rse.files.ui.actions; import java.util.ArrayList; import java.util.List; +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.ISystemAddFileListener; import org.eclipse.rse.files.ui.dialogs.SystemRemoteFileDialog; import org.eclipse.rse.internal.files.ui.FileResources; -import org.eclipse.rse.subsystems.files.core.model.RemoteFileFilterString; +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; import org.eclipse.rse.ui.SystemActionViewerFilter; import org.eclipse.rse.ui.actions.SystemBaseDialogAction; import org.eclipse.rse.ui.dialogs.SystemRemoteResourceDialog; @@ -44,10 +46,7 @@ import org.eclipse.swt.widgets.Shell; *
  • {@link #setHost(IHost) or #setDefaultConnection(SystemConnection)} *
  • {@link #setSystemType(IRSESystemType)} or {@link #setSystemTypes(IRSESystemType[])} *
  • {@link #setRootFolder(IHost, String)} or {@link #setRootFolder(IRemoteFile)} or {@link #setPreSelection(IRemoteFile)} - *
  • {@link #setFileTypes(String[])} or {@link #setFileTypes(String)} - *
  • {@link #setAutoExpandDepth(int)} *
  • {@link #setShowPropertySheet(boolean)} or {@link #setShowPropertySheet(boolean,boolean)} - *
  • {@link #enableAddMode(ISystemAddFileListener)} *
  • {@link #setMultipleSelectionMode(boolean)} *
  • {@link #setSelectionValidator(IValidatorRemoteSelection)} * @@ -71,19 +70,14 @@ public class SystemSelectRemoteFileAction extends SystemBaseDialogAction private IHost systemConnection, outputConnection; private IHost rootFolderConnection; private IRemoteFile preSelection; - private String rootFolderAbsPath, fileTypes; + private String rootFolderAbsPath; private String message, treeTip, dlgTitle; - private String addLabel, addToolTipText; - private int expandDepth = 0; private boolean showNewConnectionPrompt = true; - private boolean restrictFolders = false; private boolean showPropertySheet = false; private boolean showPropertySheetDetailsButtonInitialState; private boolean showPropertySheetDetailsButton = false; private boolean multipleSelectionMode = false; private boolean onlyConnection = false; - private boolean allowFolderSelection = true; - private ISystemAddFileListener addButtonCallback = null; private IValidatorRemoteSelection selectionValidator; private List viewerFilters = new ArrayList(); private SystemActionViewerFilter customViewerFilter = null; @@ -101,8 +95,8 @@ public class SystemSelectRemoteFileAction extends SystemBaseDialogAction * Constructor when you have your own action label and tooltip * * @param shell The shell to hang the dialog off of - * @param label - * @param tooltip + * @param label string to display in menu or toolbar + * @param tooltip string to display when user hovers mouse over action. */ public SystemSelectRemoteFileAction(Shell shell, String label, String tooltip) { @@ -172,15 +166,6 @@ public class SystemSelectRemoteFileAction extends SystemBaseDialogAction this.showNewConnectionPrompt = show; } - /** - * Specify the zero-based auto-expand level for the tree. The default is zero, meaning - * only show the connections. - */ - public void setAutoExpandDepth(int depth) - { - this.expandDepth = depth; - } - /** * Set the root folder from which to start listing files. * This version identifies the folder via a connection object and absolute path. @@ -193,6 +178,24 @@ public class SystemSelectRemoteFileAction extends SystemBaseDialogAction { rootFolderConnection = connection; rootFolderAbsPath = folderAbsolutePath; + + IRemoteFileSubSystem ss = RemoteFileUtility.getFileSubSystem(rootFolderConnection); + if (ss != null) + { + try + { + IRemoteFile rootFolder = ss.getRemoteFileObject(rootFolderAbsPath, new NullProgressMonitor()); + if (rootFolder != null) + { + setPreSelection(rootFolder); + } + } + catch (Exception e) + { + e.printStackTrace(); + } + } + onlyConnection = true; } /** * Set the root folder from which to start listing files. @@ -224,61 +227,6 @@ public class SystemSelectRemoteFileAction extends SystemBaseDialogAction preSelection = selection; } - /** - * For files mode, restrict the files list by an array of file types - */ - public void setFileTypes(String[] fileTypes) - { - if (fileTypes != null) - this.fileTypes = RemoteFileFilterString.getTypesString(fileTypes); - else - this.fileTypes = null; - } - /** - * For files mode, restrict the files list by a comman-delimited array of file types. - * The last type must also end in a comma. Eg "java, class," or "class,". - */ - public void setFileTypes(String fileTypes) - { - this.fileTypes = fileTypes; - } - - /** - * Specify whether setRootFolder should prevent the user from being able to see or select - * any other folder. This causes two effects: - *
      - *
    1. The special filter for root/drives is not shown - *
    2. No subfolders are listed in the root folder - *
    - */ - public void setRestrictFolders(boolean restrict) - { - this.restrictFolders = restrict; - } - - /** - * Enable Add mode. This means the OK button is replaced with an Add button, and - * the Cancel with a Close button. When Add is pressed, the caller is called back. - * The dialog is not exited until Close is pressed. - *

    - * When a library is selected, the caller is called back to decide to enable the Add - * button or not. - */ - public void enableAddMode(ISystemAddFileListener caller) - { - this.addButtonCallback = caller; - } - /** - * Overloaded method that allows setting the label and tooltip text of the Add button. - * If you pass null for the label, the default is used ("Add"). - */ - public void enableAddMode(ISystemAddFileListener caller, String addLabel, String addToolTipText) - { - enableAddMode(caller); - this.addLabel = addLabel; - this.addToolTipText = addToolTipText; - } - /** * Show the property sheet on the right hand side, to show the properties of the * selected object. @@ -459,6 +407,8 @@ public class SystemSelectRemoteFileAction extends SystemBaseDialogAction dlg.setMultipleSelectionMode(multipleSelectionMode); + dlg.setShowNewConnectionPrompt(showNewConnectionPrompt); + if (systemConnection != null) { dlg.setDefaultSystemConnection(systemConnection, onlyConnection); @@ -547,13 +497,4 @@ public class SystemSelectRemoteFileAction extends SystemBaseDialogAction 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; - } } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/actions/SystemSelectRemoteFolderAction.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/actions/SystemSelectRemoteFolderAction.java index ffa12d14c7b..c1195c0d2cd 100644 --- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/actions/SystemSelectRemoteFolderAction.java +++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/actions/SystemSelectRemoteFolderAction.java @@ -13,17 +13,20 @@ * Contributors: * Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType * Xuan Chen (IBM) - [220995] [api] Need to add setCustomViewFilter API to SystemSelectRemoteFileAction + * Xuan Chen (IBM) - [220995] [api] Need to remove unnecessary APIs. ********************************************************************************/ package org.eclipse.rse.files.ui.actions; +import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.rse.core.IRSESystemType; import org.eclipse.rse.core.model.IHost; -import org.eclipse.rse.files.ui.ISystemAddFileListener; import org.eclipse.rse.files.ui.dialogs.SystemRemoteFileDialog; import org.eclipse.rse.files.ui.dialogs.SystemRemoteFolderDialog; import org.eclipse.rse.internal.files.ui.FileResources; +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; import org.eclipse.rse.ui.SystemActionViewerFilter; import org.eclipse.rse.ui.actions.SystemBaseDialogAction; import org.eclipse.rse.ui.dialogs.SystemRemoteResourceDialog; @@ -40,10 +43,7 @@ import org.eclipse.swt.widgets.Shell; *

  • {@link #setShowNewConnectionPrompt(boolean)} *
  • {@link #setHost(IHost) or #setDefaultConnection(SystemConnection)} *
  • {@link #setSystemType(IRSESystemType)} or {@link #setSystemTypes(IRSESystemType[])} - *
  • {@link #setRootFolder(IHost, String)} or {@link #setRootFolder(IRemoteFile)} or {@link #setPreSelection(IRemoteFile)} - *
  • {@link #setAutoExpandDepth(int)} *
  • {@link #setShowPropertySheet(boolean)} - *
  • {@link #enableAddMode(ISystemAddFileListener)} *
  • {@link #setMultipleSelectionMode(boolean)} *
  • {@link #setSelectionValidator(IValidatorRemoteSelection)} * @@ -70,17 +70,12 @@ public class SystemSelectRemoteFolderAction extends SystemBaseDialogAction private IRemoteFile preSelection; private String rootFolderAbsPath; private String message, treeTip, dlgTitle; - private String addLabel, addToolTipText; - private int expandDepth = 0; private boolean showNewConnectionPrompt = true; - private boolean restrictFolders = false; private boolean showPropertySheet = false; private boolean showPropertySheetDetailsButtonInitialState; private boolean showPropertySheetDetailsButton = false; private boolean multipleSelectionMode = false; - private boolean allowForMultipleParents = false; private boolean onlyConnection = false; - private ISystemAddFileListener addButtonCallback = null; private IValidatorRemoteSelection selectionValidator; private SystemActionViewerFilter customViewerFilter = null; @@ -97,8 +92,8 @@ public class SystemSelectRemoteFolderAction extends SystemBaseDialogAction * Constructor when you have your own action label and tooltip * * @param shell The shell to hang the dialog off of - * @param label - * @param tooltip + * @param label string to display in menu or toolbar + * @param tooltip string to display when user hovers mouse over action. */ public SystemSelectRemoteFolderAction(Shell shell, String label, String tooltip) { @@ -183,7 +178,7 @@ public class SystemSelectRemoteFolderAction extends SystemBaseDialogAction else setSystemTypes(new IRSESystemType[] {systemType}); } - + /** * Set to true if a "New Connection..." special connection is to be shown for creating new connections */ @@ -191,14 +186,6 @@ public class SystemSelectRemoteFolderAction extends SystemBaseDialogAction { this.showNewConnectionPrompt = show; } - /** - * Specify the zero-based auto-expand level for the tree. The default is zero, meaning - * only show the connections. - */ - public void setAutoExpandDepth(int depth) - { - this.expandDepth = depth; - } /** * Set the root folder from which to start listing files. @@ -220,6 +207,24 @@ public class SystemSelectRemoteFolderAction extends SystemBaseDialogAction { rootFolderConnection = connection; rootFolderAbsPath = folderAbsolutePath; + + IRemoteFileSubSystem ss = RemoteFileUtility.getFileSubSystem(rootFolderConnection); + if (ss != null) + { + try + { + IRemoteFile rootFolder = ss.getRemoteFileObject(rootFolderAbsPath, new NullProgressMonitor()); + if (rootFolder != null) + { + setPreSelection(rootFolder); + } + } + catch (Exception e) + { + e.printStackTrace(); + } + } + onlyConnection = true; } /** * Set the root folder from which to start listing folders. @@ -259,41 +264,6 @@ public class SystemSelectRemoteFolderAction extends SystemBaseDialogAction preSelection = selection; } - /** - * Specify whether setRootFolder should prevent the user from being able to see or select - * any other folder. This causes this effect: - *
      - *
    1. The special filter for root/drives is not shown - *
    - */ - public void setRestrictFolders(boolean restrict) - { - restrictFolders = true; - } - - /** - * Enable Add mode. This means the OK button is replaced with an Add button, and - * the Cancel with a Close button. When Add is pressed, the caller is called back. - * The dialog is not exited until Close is pressed. - *

    - * When a library is selected, the caller is called back to decide to enable the Add - * button or not. - */ - public void enableAddMode(ISystemAddFileListener caller) - { - this.addButtonCallback = caller; - } - /** - * Overloaded method that allows setting the label and tooltip text of the Add button. - * If you pass null for the label, the default is used ("Add"). - */ - public void enableAddMode(ISystemAddFileListener caller, String addLabel, String addToolTipText) - { - enableAddMode(caller); - this.addLabel = addLabel; - this.addToolTipText = addToolTipText; - } - /** * Show the property sheet on the right hand side, to show the properties of the * selected object. @@ -338,14 +308,6 @@ public class SystemSelectRemoteFolderAction extends SystemBaseDialogAction this.multipleSelectionMode = multiple; } - /* - * Indicates whether to allow selection of objects from differnet parents - */ - public void setAllowForMultipleParents(boolean multiple) - { - this.allowForMultipleParents = multiple; - } - /** * Specify a validator to use when the user selects a remote file or folder. * This allows you to decide if OK should be enabled or not for that remote file or folder. @@ -487,16 +449,18 @@ public class SystemSelectRemoteFolderAction extends SystemBaseDialogAction dlg = new SystemSelectRemoteFileOrFolderDialog(shell, false); // false => folder vs file mode else dlg = new SystemSelectRemoteFileOrFolderDialog(shell, dlgTitle, false); // false => folder vs file mode - + */ dlg.setShowNewConnectionPrompt(showNewConnectionPrompt); dlg.setMultipleSelectionMode(multipleSelectionMode); + + /* dlg.setAllowForMultipleParents(allowForMultipleParents); if (restrictFolders) dlg.setRestrictFolders(true); - - + + if (systemConnection != null) { if (onlyConnection) @@ -519,6 +483,7 @@ public class SystemSelectRemoteFolderAction extends SystemBaseDialogAction */ if (preSelection != null) dlg.setPreSelection(preSelection); + /* else if (rootFolderConnection != null) dlg.setRootFolder(rootFolderConnection, rootFolderAbsPath); diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/SystemRemoteResourceDialog.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/SystemRemoteResourceDialog.java index 67c1eeb5173..c4852ac436f 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/SystemRemoteResourceDialog.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/SystemRemoteResourceDialog.java @@ -14,6 +14,7 @@ * Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType * Martin Oberhuber (Wind River) - [190442] made SystemActionViewerFilter API * Kevin Doyle (IBM) - [198114] Allowed to move file into existing folder/archive on first attempt + * Xuan Chen (IBM) - [220999] [api] Need to change class SystemSelectRemoteFileAction to use SystemRemoteFileDialog ********************************************************************************/ package org.eclipse.rse.ui.dialogs; @@ -53,6 +54,7 @@ public abstract class SystemRemoteResourceDialog extends SystemPromptDialog { _form = new SystemResourceSelectionForm(getShell(), parent, this, _inputProvider, getVerbiage(), _multipleSelectionMode, getMessageLine()); initForm(); + _form.setPreSelection(_preSelection); createMessageLine(parent); return _form.getInitialFocusControl(); } @@ -247,7 +249,13 @@ public abstract class SystemRemoteResourceDialog extends SystemPromptDialog else setOutputObject(null); return closeDialog; - } + } + + public void setShowNewConnectionPrompt(boolean showNewConnectionPrompt) + { + _inputProvider.setAllowNewConnection(showNewConnectionPrompt); + } + /** * Private method. *