mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
Add ability to enabled disable browser widget features.
Fix setting browser title. Signed-off-by: Greg Watson <g.watson@computer.org>
This commit is contained in:
parent
95c1c4b853
commit
c6b2cfc805
1 changed files with 56 additions and 27 deletions
|
@ -56,14 +56,16 @@ public class RemoteResourceBrowser extends Dialog implements IRunnableContext {
|
||||||
|
|
||||||
private final static int widthHint = 400;
|
private final static int widthHint = 400;
|
||||||
|
|
||||||
private Button okButton;
|
private Button fOkButton;
|
||||||
private RemoteResourceBrowserWidget fResourceBrowserWidget;
|
private RemoteResourceBrowserWidget fResourceBrowserWidget;
|
||||||
private ProgressMonitorPart fProgressMonitor;
|
private ProgressMonitorPart fProgressMonitor;
|
||||||
|
|
||||||
private int browserType;
|
private int fBrowserType;
|
||||||
private String dialogTitle;
|
private String fDialogTitle;
|
||||||
|
|
||||||
private boolean showConnections = false;
|
private boolean fShowHiddenCheckbox = true;
|
||||||
|
private boolean fShowNewFolderButton = true;
|
||||||
|
private boolean fShowConnections = false;
|
||||||
private String fInitialPath;
|
private String fInitialPath;
|
||||||
private IRemoteConnection fConnection;
|
private IRemoteConnection fConnection;
|
||||||
private int fBrowserStyle = SWT.SINGLE;
|
private int fBrowserStyle = SWT.SINGLE;
|
||||||
|
@ -89,7 +91,7 @@ public class RemoteResourceBrowser extends Dialog implements IRunnableContext {
|
||||||
protected Button createButton(Composite parent, int id, String label, boolean defaultButton) {
|
protected Button createButton(Composite parent, int id, String label, boolean defaultButton) {
|
||||||
Button button = super.createButton(parent, id, label, defaultButton);
|
Button button = super.createButton(parent, id, label, defaultButton);
|
||||||
if (id == IDialogConstants.OK_ID) {
|
if (id == IDialogConstants.OK_ID) {
|
||||||
okButton = button;
|
fOkButton = button;
|
||||||
}
|
}
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
@ -104,7 +106,15 @@ public class RemoteResourceBrowser extends Dialog implements IRunnableContext {
|
||||||
@Override
|
@Override
|
||||||
protected Control createContents(Composite parent) {
|
protected Control createContents(Composite parent) {
|
||||||
Control contents = super.createContents(parent);
|
Control contents = super.createContents(parent);
|
||||||
setTitle(dialogTitle);
|
if (fDialogTitle == null) {
|
||||||
|
if (fBrowserType == DIRECTORY_BROWSER) {
|
||||||
|
setTitle(Messages.RemoteResourceBrowser_directoryTitle);
|
||||||
|
} else if (fBrowserType == FILE_BROWSER) {
|
||||||
|
setTitle(Messages.RemoteResourceBrowser_fileTitle);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setTitle(fDialogTitle);
|
||||||
|
}
|
||||||
if (fConnection != null) {
|
if (fConnection != null) {
|
||||||
fResourceBrowserWidget.setConnection(fConnection);
|
fResourceBrowserWidget.setConnection(fConnection);
|
||||||
}
|
}
|
||||||
|
@ -130,17 +140,23 @@ public class RemoteResourceBrowser extends Dialog implements IRunnableContext {
|
||||||
main.setLayoutData(gd);
|
main.setLayoutData(gd);
|
||||||
main.setLayout(new GridLayout(1, true));
|
main.setLayout(new GridLayout(1, true));
|
||||||
|
|
||||||
int options = RemoteResourceBrowserWidget.SHOW_HIDDEN_CHECKBOX | RemoteResourceBrowserWidget.SHOW_NEW_FOLDER_BUTTON;
|
int options = 0;
|
||||||
if (fConnection == null || showConnections) {
|
if (fConnection == null || fShowConnections) {
|
||||||
options |= RemoteResourceBrowserWidget.SHOW_CONNECTIONS;
|
options |= RemoteResourceBrowserWidget.SHOW_CONNECTIONS;
|
||||||
}
|
}
|
||||||
if (browserType == DIRECTORY_BROWSER) {
|
if (fBrowserType == DIRECTORY_BROWSER) {
|
||||||
options |= RemoteResourceBrowserWidget.DIRECTORY_BROWSER;
|
options |= RemoteResourceBrowserWidget.DIRECTORY_BROWSER;
|
||||||
} else if (browserType == FILE_BROWSER) {
|
} else if (fBrowserType == FILE_BROWSER) {
|
||||||
options |= RemoteResourceBrowserWidget.FILE_BROWSER;
|
options |= RemoteResourceBrowserWidget.FILE_BROWSER;
|
||||||
} else {
|
} else {
|
||||||
options |= RemoteResourceBrowserWidget.FILE_BROWSER | RemoteResourceBrowserWidget.DIRECTORY_BROWSER;
|
options |= RemoteResourceBrowserWidget.FILE_BROWSER | RemoteResourceBrowserWidget.DIRECTORY_BROWSER;
|
||||||
}
|
}
|
||||||
|
if (fShowHiddenCheckbox) {
|
||||||
|
options |= RemoteResourceBrowserWidget.SHOW_HIDDEN_CHECKBOX;
|
||||||
|
}
|
||||||
|
if (fShowNewFolderButton) {
|
||||||
|
options |= RemoteResourceBrowserWidget.SHOW_NEW_FOLDER_BUTTON;
|
||||||
|
}
|
||||||
fResourceBrowserWidget = new RemoteResourceBrowserWidget(main, fBrowserStyle, options);
|
fResourceBrowserWidget = new RemoteResourceBrowserWidget(main, fBrowserStyle, options);
|
||||||
fResourceBrowserWidget.addSelectionChangedListener(new ISelectionChangedListener() {
|
fResourceBrowserWidget.addSelectionChangedListener(new ISelectionChangedListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -156,7 +172,7 @@ public class RemoteResourceBrowser extends Dialog implements IRunnableContext {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void focusLost(FocusEvent e) {
|
public void focusLost(FocusEvent e) {
|
||||||
getShell().setDefaultButton(okButton);
|
getShell().setDefaultButton(fOkButton);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
fResourceBrowserWidget.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
fResourceBrowserWidget.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
||||||
|
@ -256,18 +272,18 @@ public class RemoteResourceBrowser extends Dialog implements IRunnableContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the dialogTitle of the dialog.
|
* Set the fDialogTitle of the dialog.
|
||||||
*
|
*
|
||||||
* @param title
|
* @param title
|
||||||
*/
|
*/
|
||||||
public void setTitle(String title) {
|
public void setTitle(String title) {
|
||||||
dialogTitle = title;
|
fDialogTitle = title;
|
||||||
if (dialogTitle == null) {
|
if (fDialogTitle == null) {
|
||||||
dialogTitle = ""; //$NON-NLS-1$
|
fDialogTitle = ""; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
Shell shell = getShell();
|
Shell shell = getShell();
|
||||||
if ((shell != null) && !shell.isDisposed()) {
|
if ((shell != null) && !shell.isDisposed()) {
|
||||||
shell.setText(dialogTitle);
|
shell.setText(fDialogTitle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,31 +293,44 @@ public class RemoteResourceBrowser extends Dialog implements IRunnableContext {
|
||||||
* a resource browser (allows selection of files and directories).
|
* a resource browser (allows selection of files and directories).
|
||||||
*/
|
*/
|
||||||
public void setType(int type) {
|
public void setType(int type) {
|
||||||
browserType = type;
|
fBrowserType = type;
|
||||||
if (type == DIRECTORY_BROWSER) {
|
|
||||||
setTitle(Messages.RemoteResourceBrowser_directoryTitle);
|
|
||||||
} else if (type == FILE_BROWSER) {
|
|
||||||
setTitle(Messages.RemoteResourceBrowser_fileTitle);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show available connections on browser if possible.
|
* Show available connections on browser if possible (default disabled).
|
||||||
*
|
*
|
||||||
* @param enable
|
* @param enable
|
||||||
*/
|
*/
|
||||||
public void showConnections(boolean enable) {
|
public void showConnections(boolean enable) {
|
||||||
this.showConnections = enable;
|
fShowConnections = enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable a checkbox to show hidden files (default enabled)
|
||||||
|
*
|
||||||
|
* @param showHidden
|
||||||
|
*/
|
||||||
|
public void showHiddenCheckbox(boolean showHidden) {
|
||||||
|
fShowHiddenCheckbox = showHidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable a button to create new folders (default enabled)
|
||||||
|
*
|
||||||
|
* @param showNewFolderButton
|
||||||
|
*/
|
||||||
|
public void showNewFolderButton(boolean showNewFolderButton) {
|
||||||
|
fShowNewFolderButton = showNewFolderButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateDialog() {
|
private void updateDialog() {
|
||||||
if (okButton != null) {
|
if (fOkButton != null) {
|
||||||
IFileStore resource = getResource();
|
IFileStore resource = getResource();
|
||||||
boolean enabled = getConnection() != null && resource != null;
|
boolean enabled = getConnection() != null && resource != null;
|
||||||
if (enabled && browserType == FILE_BROWSER) {
|
if (enabled && fBrowserType == FILE_BROWSER) {
|
||||||
enabled &= !resource.fetchInfo().isDirectory();
|
enabled &= !resource.fetchInfo().isDirectory();
|
||||||
}
|
}
|
||||||
okButton.setEnabled(enabled);
|
fOkButton.setEnabled(enabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue