1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-09 10:46:02 +02:00

Add API to set connection in browser.

Signed-off-by: Greg Watson <g.watson@computer.org>
This commit is contained in:
Greg Watson 2013-12-23 11:19:36 -05:00
parent 652dd73040
commit a4895a48d7
3 changed files with 30 additions and 15 deletions

View file

@ -33,11 +33,12 @@ public class JSchUIFileManager implements IRemoteUIFileManager {
*/ */
@Override @Override
public String browseDirectory(Shell shell, String message, String filterPath, int flags) { 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.setType(RemoteResourceBrowser.DIRECTORY_BROWSER);
browser.setInitialPath(filterPath); browser.setInitialPath(filterPath);
browser.setTitle(message); browser.setTitle(message);
browser.showConnections(showConnections); browser.showConnections(showConnections);
browser.setConnection(connection);
if (browser.open() == Window.CANCEL) { if (browser.open() == Window.CANCEL) {
return null; return null;
} }
@ -58,11 +59,12 @@ public class JSchUIFileManager implements IRemoteUIFileManager {
*/ */
@Override @Override
public String browseFile(Shell shell, String message, String filterPath, int flags) { 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.setType(RemoteResourceBrowser.FILE_BROWSER);
browser.setInitialPath(filterPath); browser.setInitialPath(filterPath);
browser.setTitle(message); browser.setTitle(message);
browser.showConnections(showConnections); browser.showConnections(showConnections);
browser.setConnection(connection);
if (browser.open() == Window.CANCEL) { if (browser.open() == Window.CANCEL) {
return null; return null;
} }
@ -83,11 +85,12 @@ public class JSchUIFileManager implements IRemoteUIFileManager {
*/ */
@Override @Override
public List<String> browseFiles(Shell shell, String message, String filterPath, int flags) { 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.setType(RemoteResourceBrowser.FILE_BROWSER);
browser.setInitialPath(filterPath); browser.setInitialPath(filterPath);
browser.setTitle(message); browser.setTitle(message);
browser.showConnections(showConnections); browser.showConnections(showConnections);
browser.setConnection(connection);
if (browser.open() == Window.CANCEL) { if (browser.open() == Window.CANCEL) {
return null; return null;
} }

View file

@ -60,25 +60,17 @@ public class RemoteResourceBrowser extends Dialog implements IRunnableContext {
private boolean showConnections = false; private boolean showConnections = false;
private String fInitialPath; private String fInitialPath;
private final IRemoteConnection fConnection; private IRemoteConnection fConnection;
private int optionFlags = SINGLE; private int optionFlags = SINGLE;
public RemoteResourceBrowser(IRemoteConnection conn, Shell parent, int flags) { public RemoteResourceBrowser(Shell parent, int flags) {
super(parent); super(parent);
setShellStyle(SWT.RESIZE | getShellStyle()); setShellStyle(SWT.RESIZE | getShellStyle());
fConnection = conn;
this.optionFlags = flags; this.optionFlags = flags;
if (conn == null) {
showConnections = true;
}
setTitle(Messages.RemoteResourceBrowser_resourceTitle); setTitle(Messages.RemoteResourceBrowser_resourceTitle);
setType(FILE_BROWSER); setType(FILE_BROWSER);
} }
public RemoteResourceBrowser(Shell parent, int flags) {
this(null, parent, flags);
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
@ -106,7 +98,7 @@ public class RemoteResourceBrowser extends Dialog implements IRunnableContext {
protected Control createContents(Composite parent) { protected Control createContents(Composite parent) {
Control contents = super.createContents(parent); Control contents = super.createContents(parent);
setTitle(dialogTitle); setTitle(dialogTitle);
if (!showConnections) { if (fConnection != null) {
fResourceBrowserWidget.setConnection(fConnection); fResourceBrowserWidget.setConnection(fConnection);
} }
if (fInitialPath != null) { 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 options = RemoteResourceBrowserWidget.SHOW_HIDDEN_CHECKBOX | RemoteResourceBrowserWidget.SHOW_NEW_FOLDER_BUTTON;
int style = SWT.NONE; int style = SWT.NONE;
if (showConnections) { if (fConnection == null || showConnections) {
options |= RemoteResourceBrowserWidget.SHOW_CONNECTIONS; options |= RemoteResourceBrowserWidget.SHOW_CONNECTIONS;
} }
if (browserType == DIRECTORY_BROWSER) { 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)); fResourceBrowserWidget.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
if (fConnection != null) {
fResourceBrowserWidget.setConnection(fConnection);
}
Composite monitorComposite = new Composite(main, SWT.NULL); Composite monitorComposite = new Composite(main, SWT.NULL);
GridLayout layout = new GridLayout(); 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 * 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 * text field, and in a future version should expand the browser to this

View file

@ -488,8 +488,16 @@ public class RemoteResourceBrowserWidget extends Composite {
fSelectionListeners.remove(listener); fSelectionListeners.remove(listener);
} }
/**
* Set the connection for the browser
*
* @param connection
*/
public void setConnection(IRemoteConnection connection) { public void setConnection(IRemoteConnection connection) {
changeInput(connection); changeInput(connection);
if (fRemoteConnectionWidget != null) {
fRemoteConnectionWidget.setConnection(connection);
}
updateEnablement(); updateEnablement();
} }