1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-15 21:15:23 +02:00

fix: [220999] [api] Need to change class SystemSelectRemoteFileAction to use SystemRemoteFileDialog

This commit is contained in:
Xuan Chen 2008-02-29 21:15:06 +00:00
parent b206974d31
commit 92db6c4100

View file

@ -1,5 +1,5 @@
/******************************************************************************** /********************************************************************************
* Copyright (c) 2002, 2007 IBM Corporation and others. All rights reserved. * Copyright (c) 2002, 2008 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the terms * This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is * of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html * available at http://www.eclipse.org/legal/epl-v10.html
@ -12,11 +12,11 @@
* *
* 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
********************************************************************************/ ********************************************************************************/
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.Iterator;
import java.util.List; import java.util.List;
import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.Dialog;
@ -24,11 +24,13 @@ 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.ISystemAddFileListener; import org.eclipse.rse.files.ui.ISystemAddFileListener;
import org.eclipse.rse.files.ui.dialogs.SystemSelectRemoteFileOrFolderDialog; import org.eclipse.rse.files.ui.dialogs.SystemRemoteFileDialog;
import org.eclipse.rse.internal.files.ui.FileResources; 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.RemoteFileFilterString;
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
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.validators.IValidatorRemoteSelection; import org.eclipse.rse.ui.validators.IValidatorRemoteSelection;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
@ -84,6 +86,7 @@ public class SystemSelectRemoteFileAction extends SystemBaseDialogAction
private ISystemAddFileListener addButtonCallback = null; private ISystemAddFileListener addButtonCallback = null;
private IValidatorRemoteSelection selectionValidator; private IValidatorRemoteSelection selectionValidator;
private List viewerFilters = new ArrayList(); private List viewerFilters = new ArrayList();
private SystemActionViewerFilter customViewerFilter = null;
/** /**
* Constructor that uses default action label and tooltip * Constructor that uses default action label and tooltip
@ -385,13 +388,28 @@ public class SystemSelectRemoteFileAction extends SystemBaseDialogAction
public IRemoteFile[] getSelectedFiles() public IRemoteFile[] getSelectedFiles()
{ {
Object o = getValue(); Object o = getValue();
if (o instanceof IRemoteFile[]) if (o instanceof Object[]) {
return (IRemoteFile[])o;
else if (o instanceof IRemoteFile) Object[] temp = (Object[])o;
return new IRemoteFile[] {(IRemoteFile)o};
else IRemoteFile[] files = new IRemoteFile[temp.length];
// ensure all objects are IRemoteFiles
for (int i = 0; i < temp.length; i++) {
if (temp[i] instanceof IRemoteFile) {
files[i] = (IRemoteFile)temp[i];
}
// should never happen
else {
return new IRemoteFile[0]; return new IRemoteFile[0];
} }
}
return files;
}
return null;
}
/** /**
* Return all selected objects. This method will return an array of one * Return all selected objects. This method will return an array of one
@ -419,6 +437,11 @@ public class SystemSelectRemoteFileAction extends SystemBaseDialogAction
return outputConnection; return outputConnection;
} }
public void setCustomViewerFilter(SystemActionViewerFilter filter)
{
customViewerFilter = filter;
}
// ------------------- // -------------------
// INTERNAL METHODS... // INTERNAL METHODS...
// ------------------- // -------------------
@ -428,19 +451,25 @@ public class SystemSelectRemoteFileAction extends SystemBaseDialogAction
*/ */
protected Dialog createDialog(Shell shell) protected Dialog createDialog(Shell shell)
{ {
SystemSelectRemoteFileOrFolderDialog dlg = null; SystemRemoteFileDialog dlg = null;
if (dlgTitle == null) if (dlgTitle == null)
dlg = new SystemSelectRemoteFileOrFolderDialog(shell, true); // true => file vs folder mode dlg = new SystemRemoteFileDialog(shell);
else else
dlg = new SystemSelectRemoteFileOrFolderDialog(shell, dlgTitle, true); // true => file vs folder mode dlg = new SystemRemoteFileDialog(shell, dlgTitle);
dlg.setShowNewConnectionPrompt(showNewConnectionPrompt);
dlg.setMultipleSelectionMode(multipleSelectionMode); dlg.setMultipleSelectionMode(multipleSelectionMode);
if (restrictFolders) if (systemConnection != null)
dlg.setRestrictFolders(true); {
dlg.setDefaultSystemConnection(systemConnection, onlyConnection);
}
dlg.setCustomViewerFilter(customViewerFilter);
if (message != null) if (message != null)
dlg.setMessage(message); dlg.setMessage(message);
if (treeTip != null) if (treeTip != null)
dlg.setSelectionTreeToolTipText(treeTip); dlg.setSelectionTreeToolTipText(treeTip);
/*
if (systemConnection != null) if (systemConnection != null)
{ {
if (onlyConnection) if (onlyConnection)
@ -448,33 +477,35 @@ public class SystemSelectRemoteFileAction extends SystemBaseDialogAction
else else
dlg.setDefaultConnection(systemConnection); dlg.setDefaultConnection(systemConnection);
} }
*/
if (systemTypes != null) if (systemTypes != null)
dlg.setSystemTypes(systemTypes); dlg.setSystemTypes(systemTypes);
if (expandDepth != 0)
dlg.setAutoExpandDepth(expandDepth);
if (fileTypes != null)
dlg.setFileTypes(fileTypes); // must be called before setRootFolder!
if (preSelection != null) if (preSelection != null)
dlg.setPreSelection(preSelection); dlg.setPreSelection(preSelection);
else if (rootFolderConnection != null)
dlg.setRootFolder(rootFolderConnection, rootFolderAbsPath);
if (showPropertySheet) if (showPropertySheet)
if (showPropertySheetDetailsButton) if (showPropertySheetDetailsButton)
dlg.setShowPropertySheet(true, showPropertySheetDetailsButtonInitialState); dlg.setShowPropertySheet(true, showPropertySheetDetailsButtonInitialState);
else else
dlg.setShowPropertySheet(true); dlg.setShowPropertySheet(true);
/*
if (addButtonCallback != null) if (addButtonCallback != null)
if ((addLabel!=null) || (addToolTipText!=null)) if ((addLabel!=null) || (addToolTipText!=null))
dlg.enableAddMode(addButtonCallback, addLabel, addToolTipText); dlg.enableAddMode(addButtonCallback, addLabel, addToolTipText);
else else
dlg.enableAddMode(addButtonCallback); dlg.enableAddMode(addButtonCallback);
*/
if (selectionValidator != null) if (selectionValidator != null)
dlg.setSelectionValidator(selectionValidator); dlg.setSelectionValidator(selectionValidator);
/*
if (!allowFolderSelection) { if (!allowFolderSelection) {
dlg.setAllowFolderSelection(allowFolderSelection); dlg.setAllowFolderSelection(allowFolderSelection);
} }
*/
/*
// add viewer filters if any // add viewer filters if any
if (viewerFilters != null) { if (viewerFilters != null) {
Iterator iter = viewerFilters.iterator(); Iterator iter = viewerFilters.iterator();
@ -484,6 +515,7 @@ public class SystemSelectRemoteFileAction extends SystemBaseDialogAction
dlg.addViewerFilter(filter); dlg.addViewerFilter(filter);
} }
} }
*/
return dlg; return dlg;
} }
@ -493,16 +525,16 @@ public class SystemSelectRemoteFileAction extends SystemBaseDialogAction
*/ */
protected Object getDialogValue(Dialog dlg) protected Object getDialogValue(Dialog dlg)
{ {
SystemSelectRemoteFileOrFolderDialog ourDlg = (SystemSelectRemoteFileOrFolderDialog)dlg; SystemRemoteResourceDialog ourDlg = (SystemRemoteResourceDialog)dlg;
Object outputObject = null; Object outputObject = null;
outputConnection = null; outputConnection = null;
if (!ourDlg.wasCancelled()) if (!ourDlg.wasCancelled())
{ {
outputConnection = ourDlg.getSelectedConnection();
if (multipleSelectionMode) if (multipleSelectionMode)
outputObject = ourDlg.getSelectedObjects(); outputObject = ourDlg.getSelectedObjects();
else else
outputObject = ourDlg.getSelectedObject(); outputObject = ourDlg.getSelectedObject();
outputConnection = ourDlg.getSelectedConnection();
} }
return outputObject; // parent class calls setValue on what we return return outputObject; // parent class calls setValue on what we return
} }