Java Code Examples for org.eclipse.swt.widgets.DirectoryDialog#setText()

The following examples show how to use org.eclipse.swt.widgets.DirectoryDialog#setText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SourceAttachmentBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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;
}
 
Example 2
Source File: RestoreDatabaseDialog.java    From Rel with Apache License 2.0 6 votes vote down vote up
/**
 * 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");
}
 
Example 3
Source File: XEI3MetaDataImportAction.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
@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();
}
 
Example 4
Source File: DFSActionImpl.java    From RDFS with Apache License 2.0 6 votes vote down vote up
/**
 * 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);

}
 
Example 5
Source File: JavadocConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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;
}
 
Example 6
Source File: ClassPathBlock.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
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;
}
 
Example 7
Source File: ExportBarWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 8
Source File: ImportTraceWizardPage.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 9
Source File: VariableCreationDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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;
}
 
Example 10
Source File: IDEResourcePageHelper.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
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 );
	}
}
 
Example 11
Source File: ExportAction.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
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();
}
 
Example 12
Source File: UstDebugInfoSymbolProviderPreferencePage.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
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();
    }
}
 
Example 13
Source File: ScriptMainTab.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
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;
}
 
Example 14
Source File: SWTDirectoryChooser.java    From tuxguitar with GNU Lesser General Public License v2.1 5 votes vote down vote up
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); 
}
 
Example 15
Source File: WizardFileSystemResourceExportPage2.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
	}
}
 
Example 16
Source File: FileChooser.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
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();
}
 
Example 17
Source File: WizardFileSystemResourceExportPage2.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
	}
}
 
Example 18
Source File: ConfigSectionBackupRestoreSWT.java    From BiglyBT with GNU General Public License v2.0 5 votes vote down vote up
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);
	}
}
 
Example 19
Source File: SpecConfigAdocPage.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
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;
	}
}
 
Example 20
Source File: Core.java    From Rel with Apache License 2.0 4 votes vote down vote up
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();		
}