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

Allow local file/directory selection to be enabled on the resource

browser.

Signed-off-by: Greg Watson <g.watson@computer.org>
This commit is contained in:
Greg Watson 2014-01-27 16:48:38 -05:00
parent ba07d662e4
commit ec0d118e23
2 changed files with 27 additions and 6 deletions

View file

@ -66,6 +66,7 @@ public class RemoteResourceBrowser extends Dialog implements IRunnableContext {
private boolean fShowHiddenCheckbox = true;
private boolean fShowNewFolderButton = true;
private boolean fShowConnections = false;
private boolean fShowLocalSelection = false;
private String fInitialPath;
private IRemoteConnection fConnection;
private int fBrowserStyle = SWT.SINGLE;
@ -157,6 +158,9 @@ public class RemoteResourceBrowser extends Dialog implements IRunnableContext {
if (fShowNewFolderButton) {
options |= RemoteResourceBrowserWidget.SHOW_NEW_FOLDER_BUTTON;
}
if (fShowLocalSelection) {
options |= RemoteResourceBrowserWidget.SHOW_LOCAL_SELECTION;
}
fResourceBrowserWidget = new RemoteResourceBrowserWidget(main, fBrowserStyle, options);
fResourceBrowserWidget.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
@ -314,6 +318,15 @@ public class RemoteResourceBrowser extends Dialog implements IRunnableContext {
fShowHiddenCheckbox = showHidden;
}
/**
* Enable selection of local files
*
* @param showNewFolderButton
*/
public void showLocalSelection(boolean showLocalSelection) {
fShowLocalSelection = showLocalSelection;
}
/**
* Enable a button to create new folders (default enabled)
*

View file

@ -76,6 +76,10 @@ public class RemoteResourceBrowserWidget extends Composite {
* Browse for directories (files are not shown)
*/
public static final int DIRECTORY_BROWSER = 0x02;
/**
* Show local selection button
*/
public static final int SHOW_LOCAL_SELECTION = 0x04;
/**
* Display checkbox to show/hide hidden files
*/
@ -136,7 +140,7 @@ public class RemoteResourceBrowserWidget extends Composite {
if ((fOptionFlags & SHOW_CONNECTIONS) != 0) {
fRemoteConnectionWidget = new RemoteConnectionWidget(mainComp, SWT.NONE, "", //$NON-NLS-1$
RemoteConnectionWidget.FLAG_NO_LOCAL_SELECTION);
(fOptionFlags & SHOW_LOCAL_SELECTION) == 0 ? RemoteConnectionWidget.FLAG_NO_LOCAL_SELECTION : 0);
fRemoteConnectionWidget.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
fRemoteConnectionWidget.addSelectionListener(new SelectionAdapter() {
@Override
@ -345,7 +349,8 @@ public class RemoteResourceBrowserWidget extends Composite {
*/
private boolean changeInput(final IRemoteConnection conn) {
if (conn == null) {
return false;
setRoot(null);
return true;
}
IRemoteUIConnectionManager uiMgr = RemoteUIServices.getRemoteUIServices(conn.getRemoteServices()).getUIConnectionManager();
if (uiMgr != null) {
@ -521,18 +526,21 @@ public class RemoteResourceBrowserWidget extends Composite {
/**
* Set the root directory for the browser. This will also update the text
* field with the path.
* field with the path. If the path is null, the browser will be set to the initial state.
*
* @param path
* path of root directory
* path of root directory or null
*/
private void setRoot(String path) {
if (fFileMgr != null) {
fResources.clear();
fRootPath = null;
if (path == null) {
fTreeViewer.setInput(null);
} else if (fFileMgr != null) {
IFileStore root = fFileMgr.getResource(path);
fTreeViewer.setInput(new DeferredFileStore(root, !fShowHidden));
fRemotePathText.setText(path);
fRemotePathText.setSelection(fRemotePathText.getText().length());
fResources.clear();
fResources.add(root);
fRootPath = new Path(path);
}