下面列出了org.eclipse.swt.widgets.DirectoryDialog#setText ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Create the dialog.
* @param parent
* @param style
*/
public RestoreDatabaseDialog(Shell parent) {
super(parent, SWT.DIALOG_TRIM | SWT.RESIZE);
setText("Create and Restore Database");
newDatabaseDialog = new DirectoryDialog(parent);
newDatabaseDialog.setText("Create Database");
newDatabaseDialog.setMessage("Select a folder to hold a new database.");
newDatabaseDialog.setFilterPath(System.getProperty("user.home"));
restoreFileDialog = new FileDialog(Core.getShell(), SWT.OPEN);
restoreFileDialog.setFilterPath(System.getProperty("user.home"));
restoreFileDialog.setFilterExtensions(new String[] {"*.rel", "*.*"});
restoreFileDialog.setFilterNames(new String[] {"Rel script", "All Files"});
restoreFileDialog.setText("Load Backup");
}
/**
* Implement the import action (upload directory from the current machine
* to HDFS)
*
* @param object
* @throws SftpException
* @throws JSchException
* @throws InvocationTargetException
* @throws InterruptedException
*/
private void uploadDirectoryToDFS(IStructuredSelection selection)
throws InvocationTargetException, InterruptedException {
// Ask the user which local directory to upload
DirectoryDialog dialog =
new DirectoryDialog(Display.getCurrent().getActiveShell(), SWT.OPEN
| SWT.MULTI);
dialog.setText("Select the local file or directory to upload");
String dirName = dialog.open();
final File dir = new File(dirName);
List<File> files = new ArrayList<File>();
files.add(dir);
// TODO enable upload command only when selection is exactly one folder
final List<DFSFolder> folders =
filterSelection(DFSFolder.class, selection);
if (folders.size() >= 1)
uploadToDFS(folders.get(0), files);
}
/**
* Handle the button pressed event
*/
protected void handleSourceDirectoryBrowseButtonPressed() {
String currentSource = directoryNameField.getText();
DirectoryDialog dialog = DirectoryDialogFactory.create(directoryNameField.getShell(), SWT.SAVE | SWT.SHEET);
dialog.setText(Messages.ImportTraceWizard_SelectTraceDirectoryTitle);
dialog.setMessage(Messages.ImportTraceWizard_SelectTraceDirectoryMessage);
dialog.setFilterPath(getSourceDirectoryName(currentSource));
String selectedDirectory = dialog.open();
if (selectedDirectory != null) {
// Just quit if the directory is not valid
if ((getSourceDirectory(selectedDirectory) == null) || selectedDirectory.equals(currentSource)) {
return;
}
// If it is valid then proceed to populate
setErrorMessage(null);
setSourcePath(selectedDirectory);
}
}
/**
* Open an appropriate destination browser so that the user can specify a source
* to import from
*/
protected void handleDestinationBrowseButtonPressed() {
final DirectoryDialog dialog = new DirectoryDialog(getContainer().getShell(), SWT.SAVE | SWT.SHEET);
// dialog.setFilterExtensions(new String[] { "*.bar" }); //$NON-NLS-1$
dialog.setText(Messages.selectDestinationTitle);
final String currentSourceString = getDetinationPath();
final int lastSeparatorIndex = currentSourceString.lastIndexOf(File.separator);
if (lastSeparatorIndex != -1) {
dialog.setFilterPath(currentSourceString.substring(0,
lastSeparatorIndex));
}
final String selectedFileName = dialog.open();
if (selectedFileName != null) {
destinationCombo.setText(selectedFileName);
}
}
public static IPath configureExternalClassFolderEntries( Shell shell,
IPath initialEntry )
{
DirectoryDialog dialog = new DirectoryDialog( shell, SWT.SINGLE );
dialog.setText( Messages.getString( "ClassPathBlock_FolderDialog.edit.text" ) ); //$NON-NLS-1$
dialog.setMessage( Messages.getString( "ClassPathBlock_FolderDialog.edit.message" ) ); //$NON-NLS-1$
dialog.setFilterPath( initialEntry.toString( ) );
String res = dialog.open( );
if ( res == null )
{
return null;
}
File file = new File( res );
if ( file.isDirectory( ) )
return new Path( file.getAbsolutePath( ) );
return null;
}
private String chooseJavaDocFolder() {
String initPath= ""; //$NON-NLS-1$
if (fURLResult != null && "file".equals(fURLResult.getProtocol())) { //$NON-NLS-1$
initPath= JavaDocLocations.toFile(fURLResult).getPath();
}
DirectoryDialog dialog= new DirectoryDialog(fShell);
dialog.setText(PreferencesMessages.JavadocConfigurationBlock_javadocFolderDialog_label);
dialog.setMessage(PreferencesMessages.JavadocConfigurationBlock_javadocFolderDialog_message);
dialog.setFilterPath(initPath);
String result= dialog.open();
if (result != null) {
try {
URL url= new File(result).toURI().toURL();
return url.toExternalForm();
} catch (MalformedURLException e) {
JavaPlugin.log(e);
}
}
return null;
}
@Override
public void run() {
DirectoryDialog dialog = new DirectoryDialog(UI.shell());
dialog.setText("Master data directory");
dialog.setMessage("Select the EcoSpold 02 directory that contains the "
+ "master data.");
String path = dialog.open();
if (path == null)
return;
File masterDataDir = new File(path);
if (masterDataDir == null || !masterDataDir.isDirectory())
return;
File personFile = new File(masterDataDir, "Persons.xml");
if (personFile.exists())
new PersonUpdate(Database.get(), personFile).run();
File sourceFile = new File(masterDataDir, "Sources.xml");
if (sourceFile.exists())
new SourceUpdate(Database.get(), sourceFile).run();
updateIsicTree();
}
private IPath chooseExtFolder() {
IPath currPath= getFilePath();
if (currPath.segmentCount() == 0) {
currPath= fEntry.getPath();
}
if (ArchiveFileFilter.isArchivePath(currPath, true)) {
currPath= currPath.removeLastSegments(1);
}
DirectoryDialog dialog= new DirectoryDialog(getShell());
dialog.setMessage(NewWizardMessages.SourceAttachmentBlock_extfolderdialog_message);
dialog.setText(NewWizardMessages.SourceAttachmentBlock_extfolderdialog_text);
dialog.setFilterPath(currPath.toOSString());
String res= dialog.open();
if (res != null) {
return Path.fromOSString(res).makeAbsolute();
}
return null;
}
private IPath chooseDropLocation( String title, String message,
String filterPath )
{
DirectoryDialog dialog = new DirectoryDialog( getShell( ) );
dialog.setFilterPath( filterPath );
dialog.setText( title );
dialog.setMessage( message );
String res = dialog.open( );
if ( res != null )
{
return new Path( res );
}
return null;
}
private void selectDocRoot(Event e) {
switch (e.type) {
case SWT.Selection:
DirectoryDialog dialog = new DirectoryDialog(Display.getCurrent().getActiveShell(), SWT.OPEN | SWT.MULTI);
dialog.setText("Select the documentation root directory");
String result = dialog.open();
if (result != null && !result.isEmpty()) {
txtDocRootDirName.setText(result);
saveProperty(result);
checkPageComplete();
}
break;
}
}
private void doManualBackup(BackupManager backup_manager,
Runnable stats_updater) {
if (Utils.runIfNotSWTThread(
() -> doManualBackup(backup_manager, stats_updater))) {
return;
}
if (shell == null) {
shell = Utils.findAnyShell();
}
String def_dir = COConfigurationManager.getStringParameter(
SCFG_BACKUP_FOLDER_DEFAULT);
DirectoryDialog dialog = new DirectoryDialog(shell, SWT.APPLICATION_MODAL);
if (!def_dir.isEmpty()) {
dialog.setFilterPath(def_dir);
}
dialog.setMessage(MessageText.getString("br.backup.folder.info"));
dialog.setText(MessageText.getString("br.backup.folder.title"));
String path = dialog.open();
if (path != null) {
COConfigurationManager.setParameter(SCFG_BACKUP_FOLDER_DEFAULT, path);
runBackup(backup_manager, path, stats_updater);
}
}
/**
* Open an appropriate destination browser so that the user can specify a source to import from
*/
protected void handleDestinationBrowseButtonPressed() {
DirectoryDialog dialog = new DirectoryDialog(getContainer().getShell(), SWT.SAVE | SWT.SHEET);
dialog.setMessage(SELECT_DESTINATION_MESSAGE);
dialog.setText(SELECT_DESTINATION_TITLE);
dialog.setFilterPath(getDestinationValue());
String selectedDirectoryName = dialog.open();
if (selectedDirectoryName != null) {
setErrorMessage(null);
setDestinationValue(selectedDirectoryName);
}
}
private static String openDirectoryDialog(Shell shell, String filterPath,
int swtFlag) {
DirectoryDialog dialog = new DirectoryDialog(shell, swtFlag);
dialog.setText(M.SelectADirectory);
if (filterPath != null)
dialog.setFilterPath(filterPath);
return dialog.open();
}
/**
* Open an appropriate destination browser so that the user can specify a source to import from
*/
protected void handleDestinationBrowseButtonPressed() {
DirectoryDialog dialog = new DirectoryDialog(getContainer().getShell(), SWT.SAVE | SWT.SHEET);
dialog.setMessage(SELECT_DESTINATION_MESSAGE);
dialog.setText(SELECT_DESTINATION_TITLE);
dialog.setFilterPath(getDestinationValue());
String selectedDirectoryName = dialog.open();
if (selectedDirectoryName != null) {
setErrorMessage(null);
setDestinationValue(selectedDirectoryName);
}
}
public void choose(UIDirectoryChooserHandler selectionHandler) {
DirectoryDialog dialog = new DirectoryDialog(this.window.getControl());
if( this.text != null ) {
dialog.setText(this.text);
}
if( this.defaultPath != null ) {
dialog.setFilterPath(this.defaultPath.getAbsolutePath());
}
String path = dialog.open();
selectionHandler.onSelectDirectory(path != null ? new File(path) : null);
}
private IPath chooseExtDirectory() {
String initPath= getInitPath();
DirectoryDialog dialog= new DirectoryDialog(getShell());
dialog.setText(NewWizardMessages.VariableCreationDialog_extdirdialog_text);
dialog.setMessage(NewWizardMessages.VariableCreationDialog_extdirdialog_message);
dialog.setFilterPath(initPath);
String res= dialog.open();
if (res != null) {
fDialogSettings.put(IUIConstants.DIALOGSTORE_LASTEXTJAR, dialog.getFilterPath());
return Path.fromOSString(res);
}
return null;
}
private void browseDirectory(Text textField, @Nullable String dialogTitle) {
DirectoryDialog dialog = DirectoryDialogFactory.create(getShell());
dialog.setText(dialogTitle);
String dirPath = dialog.open();
if (dirPath != null) {
textField.setText(dirPath);
updateContents();
}
}
protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.SAVE);
dialog.setText(Policy.bind("ExportAction.exportTo")); //$NON-NLS-1$
dialog.setFilterPath(getLastLocation());
String directory = dialog.open();
if (directory == null) return;
saveLocation(directory);
new ExportOperation(getTargetPart(), getSelectedResources(), directory).run();
}
protected void handleBrowseFileSystem( )
{
DirectoryDialog dialog = new DirectoryDialog( getControl( ).getShell( ) );
dialog.setFilterPath( getLocation( ) );
dialog.setText( DirectoryDialog_Text );
dialog.setMessage( DirectoryDialog_Message );
String result = dialog.open( );
if ( result != null )
{
// fLocationText.setText(result);
location = result;
result = replaceString( result );
notifyTextChange( result );
}
}
public static void launch(OpenDocumentEventProcessor openDocProcessor, Composite parent) {
parent.setLayout(new FillLayout());
mainPanel = new MainPanel(parent, SWT.None);
openDatabaseDialog = new DirectoryDialog(getShell());
openDatabaseDialog.setText("Open Database");
openDatabaseDialog.setMessage("Select a folder that contains a database.");
openDatabaseDialog.setFilterPath(System.getProperty("user.home"));
newDatabaseDialog = new DirectoryDialog(getShell());
newDatabaseDialog.setText("Create Database");
newDatabaseDialog.setMessage(
"Select a folder to hold a new database. If a database already exists there, it will be opened.");
newDatabaseDialog.setFilterPath(System.getProperty("user.home"));
remoteDatabaseDialog = new RemoteDatabaseDialog(getShell());
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
private int failureCount = 0;
public void uncaughtException(Thread t, Throwable e) {
if (failureCount > 1) {
System.err
.println("SYSTEM ERROR! It's gotten even worse. This is a last-ditch attempt to escape.");
failureCount++;
Thread.setDefaultUncaughtExceptionHandler(null);
System.exit(1);
return;
}
if (failureCount > 0) {
System.err.println(
"SYSTEM ERROR! Things have gone so horribly wrong that we can't recover or even pop up a message. I hope someone sees this...\nShutting down now, if we can.");
failureCount++;
System.exit(1);
return;
}
failureCount++;
if (e instanceof OutOfMemoryError) {
System.err.println("Out of memory!");
e.printStackTrace();
mainPanel.dispose();
MessageDialog.openError(getShell(), "OUT OF MEMORY", "Out of memory! Shutting down NOW!");
} else {
System.err.println("Unknown error: " + t);
e.printStackTrace();
mainPanel.dispose();
MessageDialog.openError(getShell(), "Unexpected Error", e.toString());
}
System.exit(1);
}
});
DbTab dbTab = new DbTab();
if (!Preferences.getPreferenceBoolean(PreferencePageGeneral.SKIP_DEFAULT_DB_LOAD))
dbTab.openDefaultDatabase(defaultDatabasePath);
String[] filesToOpen = openDocProcessor.retrieveFilesToOpen();
for (String fname: filesToOpen)
openFile(fname);
Core.setSelectionToLastDatabaseTab();
}