mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 02:36:01 +02:00
Add API to set connection in browser.
Signed-off-by: Greg Watson <g.watson@computer.org>
This commit is contained in:
parent
652dd73040
commit
a4895a48d7
3 changed files with 30 additions and 15 deletions
|
@ -33,11 +33,12 @@ public class JSchUIFileManager implements IRemoteUIFileManager {
|
|||
*/
|
||||
@Override
|
||||
public String browseDirectory(Shell shell, String message, String filterPath, int flags) {
|
||||
RemoteResourceBrowser browser = new RemoteResourceBrowser(connection, shell, RemoteResourceBrowser.SINGLE);
|
||||
RemoteResourceBrowser browser = new RemoteResourceBrowser(shell, RemoteResourceBrowser.SINGLE);
|
||||
browser.setType(RemoteResourceBrowser.DIRECTORY_BROWSER);
|
||||
browser.setInitialPath(filterPath);
|
||||
browser.setTitle(message);
|
||||
browser.showConnections(showConnections);
|
||||
browser.setConnection(connection);
|
||||
if (browser.open() == Window.CANCEL) {
|
||||
return null;
|
||||
}
|
||||
|
@ -58,11 +59,12 @@ public class JSchUIFileManager implements IRemoteUIFileManager {
|
|||
*/
|
||||
@Override
|
||||
public String browseFile(Shell shell, String message, String filterPath, int flags) {
|
||||
RemoteResourceBrowser browser = new RemoteResourceBrowser(connection, shell, RemoteResourceBrowser.SINGLE);
|
||||
RemoteResourceBrowser browser = new RemoteResourceBrowser(shell, RemoteResourceBrowser.SINGLE);
|
||||
browser.setType(RemoteResourceBrowser.FILE_BROWSER);
|
||||
browser.setInitialPath(filterPath);
|
||||
browser.setTitle(message);
|
||||
browser.showConnections(showConnections);
|
||||
browser.setConnection(connection);
|
||||
if (browser.open() == Window.CANCEL) {
|
||||
return null;
|
||||
}
|
||||
|
@ -83,11 +85,12 @@ public class JSchUIFileManager implements IRemoteUIFileManager {
|
|||
*/
|
||||
@Override
|
||||
public List<String> browseFiles(Shell shell, String message, String filterPath, int flags) {
|
||||
RemoteResourceBrowser browser = new RemoteResourceBrowser(connection, shell, RemoteResourceBrowser.MULTI);
|
||||
RemoteResourceBrowser browser = new RemoteResourceBrowser(shell, RemoteResourceBrowser.MULTI);
|
||||
browser.setType(RemoteResourceBrowser.FILE_BROWSER);
|
||||
browser.setInitialPath(filterPath);
|
||||
browser.setTitle(message);
|
||||
browser.showConnections(showConnections);
|
||||
browser.setConnection(connection);
|
||||
if (browser.open() == Window.CANCEL) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -60,25 +60,17 @@ public class RemoteResourceBrowser extends Dialog implements IRunnableContext {
|
|||
|
||||
private boolean showConnections = false;
|
||||
private String fInitialPath;
|
||||
private final IRemoteConnection fConnection;
|
||||
private IRemoteConnection fConnection;
|
||||
private int optionFlags = SINGLE;
|
||||
|
||||
public RemoteResourceBrowser(IRemoteConnection conn, Shell parent, int flags) {
|
||||
public RemoteResourceBrowser(Shell parent, int flags) {
|
||||
super(parent);
|
||||
setShellStyle(SWT.RESIZE | getShellStyle());
|
||||
fConnection = conn;
|
||||
this.optionFlags = flags;
|
||||
if (conn == null) {
|
||||
showConnections = true;
|
||||
}
|
||||
setTitle(Messages.RemoteResourceBrowser_resourceTitle);
|
||||
setType(FILE_BROWSER);
|
||||
}
|
||||
|
||||
public RemoteResourceBrowser(Shell parent, int flags) {
|
||||
this(null, parent, flags);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
@ -106,7 +98,7 @@ public class RemoteResourceBrowser extends Dialog implements IRunnableContext {
|
|||
protected Control createContents(Composite parent) {
|
||||
Control contents = super.createContents(parent);
|
||||
setTitle(dialogTitle);
|
||||
if (!showConnections) {
|
||||
if (fConnection != null) {
|
||||
fResourceBrowserWidget.setConnection(fConnection);
|
||||
}
|
||||
if (fInitialPath != null) {
|
||||
|
@ -133,7 +125,7 @@ public class RemoteResourceBrowser extends Dialog implements IRunnableContext {
|
|||
|
||||
int options = RemoteResourceBrowserWidget.SHOW_HIDDEN_CHECKBOX | RemoteResourceBrowserWidget.SHOW_NEW_FOLDER_BUTTON;
|
||||
int style = SWT.NONE;
|
||||
if (showConnections) {
|
||||
if (fConnection == null || showConnections) {
|
||||
options |= RemoteResourceBrowserWidget.SHOW_CONNECTIONS;
|
||||
}
|
||||
if (browserType == DIRECTORY_BROWSER) {
|
||||
|
@ -162,6 +154,9 @@ public class RemoteResourceBrowser extends Dialog implements IRunnableContext {
|
|||
}
|
||||
});
|
||||
fResourceBrowserWidget.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
||||
if (fConnection != null) {
|
||||
fResourceBrowserWidget.setConnection(fConnection);
|
||||
}
|
||||
|
||||
Composite monitorComposite = new Composite(main, SWT.NULL);
|
||||
GridLayout layout = new GridLayout();
|
||||
|
@ -234,6 +229,15 @@ public class RemoteResourceBrowser extends Dialog implements IRunnableContext {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the initial connection for the browser.
|
||||
*
|
||||
* @param connection
|
||||
*/
|
||||
public void setConnection(IRemoteConnection connection) {
|
||||
fConnection = connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the initial path to start browsing. This will be set in the browser
|
||||
* text field, and in a future version should expand the browser to this
|
||||
|
|
|
@ -488,8 +488,16 @@ public class RemoteResourceBrowserWidget extends Composite {
|
|||
fSelectionListeners.remove(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the connection for the browser
|
||||
*
|
||||
* @param connection
|
||||
*/
|
||||
public void setConnection(IRemoteConnection connection) {
|
||||
changeInput(connection);
|
||||
if (fRemoteConnectionWidget != null) {
|
||||
fRemoteConnectionWidget.setConnection(connection);
|
||||
}
|
||||
updateEnablement();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue