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

The following examples show how to use org.eclipse.swt.widgets.DirectoryDialog#setFilterPath() . 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: AddSourceFolderWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public void changeControlPressed(DialogField field) {
	final DirectoryDialog dialog= new DirectoryDialog(getShell());
	dialog.setMessage(NewWizardMessages.AddSourceFolderWizardPage_directory_message);
	String directoryName = fLinkLocation.getText().trim();
	if (directoryName.length() == 0) {
		String prevLocation= JavaPlugin.getDefault().getDialogSettings().get(DIALOGSTORE_LAST_EXTERNAL_LOC);
		if (prevLocation != null) {
			directoryName= prevLocation;
		}
	}

	if (directoryName.length() > 0) {
		final File path = new File(directoryName);
		if (path.exists())
			dialog.setFilterPath(directoryName);
	}
	final String selectedDirectory = dialog.open();
	if (selectedDirectory != null) {
		fLinkLocation.setText(selectedDirectory);
		fRootDialogField.setText(selectedDirectory.substring(selectedDirectory.lastIndexOf(File.separatorChar) + 1));
		JavaPlugin.getDefault().getDialogSettings().put(DIALOGSTORE_LAST_EXTERNAL_LOC, selectedDirectory);
		if (fAdapter != null) {
			fAdapter.dialogFieldChanged(fRootDialogField);
		}
	}
}
 
Example 2
Source File: InstallableView.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
private void onBrowse() {
	DirectoryDialog directoryDialog = new DirectoryDialog(getShell());

	File file = new File(destinationDirectoryValue.getText());
	while (file != null) {
		if (file.exists() && file.isDirectory()) {
			directoryDialog.setFilterPath(file.getAbsolutePath());
			break;
		}
		file = file.getParentFile();
	}

	String path = directoryDialog.open();
	if (path != null) {
		eventManager.invoke(l -> l.onDestinationChanged(path + File.separator + destinationProjectFolder));
	}
}
 
Example 3
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 4
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 5
Source File: BuildPathDialogAccess.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Shows the UI to configure an external class folder.
 * The dialog returns the configured or <code>null</code> if the dialog has
 * been canceled. The dialog does not apply any changes.
 *
 * @param shell The parent shell for the dialog.
 * @param initialEntry The path of the initial archive entry.
 * @return Returns the configured external class folder path or <code>null</code> if the dialog has
 * been canceled by the user.
 *
 * @since 3.4
 */
public static IPath configureExternalClassFolderEntries(Shell shell, IPath initialEntry) {
	DirectoryDialog dialog= new DirectoryDialog(shell, SWT.SINGLE);
	dialog.setText(NewWizardMessages.BuildPathDialogAccess_ExtClassFolderDialog_edit_title);
	dialog.setMessage(NewWizardMessages.BuildPathDialogAccess_ExtClassFolderDialog_edit_description);
	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 6
Source File: CompilerWorkingDirectoryBlock.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Show a dialog that lets the user select a working directory
 */
private void handleWorkingDirBrowseButtonSelected() {
    DirectoryDialog dialog = new DirectoryDialog(getShell());
    dialog.setMessage(Messages.CompilerWorkingDirectoryBlock_SelectXcWorkDir); 
    String currentWorkingDir = getOtherDirectoryText();
    if (!currentWorkingDir.trim().equals("")) { //$NON-NLS-1$
        File path = new File(currentWorkingDir);
        if (path.exists()) {
            dialog.setFilterPath(currentWorkingDir);
        }       
    }
    String selectedDirectory = dialog.open();
    if (selectedDirectory != null) {
        setOtherWorkingDirectoryText(selectedDirectory);
        if (actionListener != null) {
            actionListener.actionPerformed(null);
        }
    }       
}
 
Example 7
Source File: DirectoryDialogButtonListenerFactory.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public static final SelectionAdapter getSelectionAdapter( final Shell shell, final Text destination ) {
  // Listen to the Browse... button
  return new SelectionAdapter() {
    public void widgetSelected( SelectionEvent e ) {
      DirectoryDialog dialog = new DirectoryDialog( shell, SWT.OPEN );
      if ( destination.getText() != null ) {
        String fpath = destination.getText();
        // String fpath = StringUtil.environmentSubstitute(destination.getText());
        dialog.setFilterPath( fpath );
      }

      if ( dialog.open() != null ) {
        String str = dialog.getFilterPath();
        destination.setText( str );
      }
    }
  };
}
 
Example 8
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 9
Source File: DirectoryDialogButtonListenerFactory.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public static final SelectionAdapter getSelectionAdapter( final Shell shell, final Text destination ) {
  // Listen to the Browse... button
  return new SelectionAdapter() {
    public void widgetSelected( SelectionEvent e ) {
      DirectoryDialog dialog = new DirectoryDialog( shell, SWT.OPEN );
      if ( destination.getText() != null ) {
        String fpath = destination.getText();
        // String fpath = StringUtil.environmentSubstitute(destination.getText());
        dialog.setFilterPath( fpath );
      }

      if ( dialog.open() != null ) {
        String str = dialog.getFilterPath();
        destination.setText( str );
      }
    }
  };
}
 
Example 10
Source File: ClassPathBlock.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public static IPath[] chooseExternalClassFolderEntries( Shell shell )
{
	if ( lastUsedPath == null )
	{
		lastUsedPath = ""; //$NON-NLS-1$
	}
	DirectoryDialog dialog = new DirectoryDialog( shell, SWT.MULTI );
	dialog.setText( Messages.getString( "ClassPathBlock_FolderDialog.text" ) ); //$NON-NLS-1$
	dialog.setMessage( Messages.getString( "ClassPathBlock_FolderDialog.message" ) ); //$NON-NLS-1$
	dialog.setFilterPath( lastUsedPath );

	String res = dialog.open( );
	if ( res == null )
	{
		return null;
	}

	File file = new File( res );
	if ( file.isDirectory( ) )
		return new IPath[]{
			new Path( file.getAbsolutePath( ) )
		};

	return null;
}
 
Example 11
Source File: WizardFolderImportPage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * The browse button has been selected. Select the location.
 */
protected void handleLocationDirectoryButtonPressed()
{

	DirectoryDialog dialog = new DirectoryDialog(directoryPathField.getShell());
	dialog.setMessage(DataTransferMessages.WizardProjectsImportPage_SelectDialogTitle);

	String dirName = directoryPathField.getText().trim();
	if (dirName.length() == 0)
	{
		dirName = previouslyBrowsedDirectory;
	}

	if (dirName.length() == 0)
	{
		dialog.setFilterPath(IDEWorkbenchPlugin.getPluginWorkspace().getRoot().getLocation().toOSString());
	}
	else
	{
		File path = new File(dirName);
		if (path.exists())
		{
			dialog.setFilterPath(new Path(dirName).toOSString());
		}
	}

	String selectedDirectory = dialog.open();
	if (selectedDirectory != null)
	{
		previouslyBrowsedDirectory = selectedDirectory;
		directoryPathField.setText(previouslyBrowsedDirectory);
	}

	setProjectName();

	setPageComplete(directoryPathField.getText() != null);

}
 
Example 12
Source File: TreeWithAddRemove.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
public void addItemWithDialog(DirectoryDialog dialog) {
    dialog.setFilterPath(lastDirectoryDialogPath);
    String filePath = dialog.open();
    if (filePath != null) {
        lastDirectoryDialogPath = filePath;
    }
    addTreeItem(filePath);
}
 
Example 13
Source File: ImportProjectWizardPage.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
/**
 * The browse button has been selected. Select the location.
 */
protected void handleLocationDirectoryButtonPressed() {

	final DirectoryDialog dialog = new DirectoryDialog(directoryPathField.getShell(), SWT.SHEET);
	dialog.setMessage(DataTransferMessages.WizardProjectsImportPage_SelectDialogTitle);

	String dirName = directoryPathField.getText().trim();
	if (dirName.length() == 0) {
		dirName = previouslyBrowsedDirectory;
	}

	if (dirName.length() == 0) {
		dialog.setFilterPath(IDEWorkbenchPlugin.getPluginWorkspace().getRoot().getLocation().toOSString());
	} else {
		final File path = new File(dirName);
		if (path.exists()) {
			dialog.setFilterPath(new Path(dirName).toOSString());
		}
	}

	final String selectedDirectory = dialog.open();
	if (selectedDirectory != null) {
		previouslyBrowsedDirectory = selectedDirectory;
		directoryPathField.setText(previouslyBrowsedDirectory);
		updateProjectsList(selectedDirectory);
	}

}
 
Example 14
Source File: GwtFacetWizardPage.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
private void showDirectoryDialog() {
  DirectoryDialog directoryDialog = new DirectoryDialog(getShell(), SWT.OPEN);
  directoryDialog.setFilterPath("Choose SDK Directory");
  directoryDialog.setMessage("Please select the root directory of your SDK installation.");

  String pathToDir = directoryDialog.open();
  if (pathToDir != null) {
    textPath.setText(pathToDir);
  }
}
 
Example 15
Source File: DirectoryBluemixWizardPage.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
@Override
public void widgetSelected(SelectionEvent event) {
    if (event.widget == _dirBtn) {
        DirectoryDialog dlg = new DirectoryDialog(getShell());
        dlg.setFilterPath(getDirectory());
        dlg.setMessage("Choose a deployment directory for your application:"); // $NLX-DirectoryBluemixWizardPage.Chooseadeploymentdirectoryforyour-1$
        String loc = dlg.open();
        if (StringUtil.isNotEmpty(loc)) {
            _dirText.setText(loc);
        }
    }
}
 
Example 16
Source File: LibraryPathComposite.java    From tlaplus with MIT License 5 votes vote down vote up
/**
 * Allows users to select a directory with a use scan in it
 * 
 * @param prevLocation
 * @return the new directory or <code>null</code> if the dialog was
 *         cancelled
 */
String getDirectory(String prevLocation) {
	DirectoryDialog dialog = new DirectoryDialog(this.preferencePage.getShell());
	dialog.setMessage("Select the library path location");
	if (prevLocation != null) {
		dialog.setFilterPath(prevLocation);
	}
	final String open = dialog.open();
	if (open != null) {
		return open + File.separator;
	}
	return null;
}
 
Example 17
Source File: SWTFactory.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
public static String browseDirectory(Shell shell, String text, String message, String preferredPath) {
	DirectoryDialog fd = new DirectoryDialog(shell);
	fd.setText(text);
       fd.setMessage(message);
       fd.setFilterPath(mkPrefPath(preferredPath));
       String res = fd.open();
	if (res != null)
		lastBrowsePath = res;
       return res; // null => cancel
}
 
Example 18
Source File: AbstractExportAction.java    From erflute with Apache License 2.0 5 votes vote down vote up
protected String getSaveDirPath(IEditorPart editorPart, GraphicalViewer viewer) {
    final IFile file = ((IFileEditorInput) editorPart.getEditorInput()).getFile();
    final DirectoryDialog directoryDialog = new DirectoryDialog(editorPart.getEditorSite().getShell(), SWT.SAVE);
    final IProject project = file.getProject();
    directoryDialog.setFilterPath(project.getLocation().toString());
    return directoryDialog.open();
}
 
Example 19
Source File: ERDiagramActivator.java    From ermasterr with Apache License 2.0 4 votes vote down vote up
public static String showDirectoryDialog(final String filePath, final String message) {
    String fileName = null;

    if (filePath != null && !"".equals(filePath.trim())) {
        final File file = new File(filePath.trim());
        fileName = file.getPath();
    }

    final DirectoryDialog dialog = new DirectoryDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.NONE);

    dialog.setMessage(ResourceString.getResourceString(message));

    dialog.setFilterPath(fileName);

    return dialog.open();
}
 
Example 20
Source File: AbstractExportAction.java    From ermasterr with Apache License 2.0 3 votes vote down vote up
protected String getSaveDirPath(final IEditorPart editorPart, final GraphicalViewer viewer) {

        final DirectoryDialog directoryDialog = new DirectoryDialog(editorPart.getEditorSite().getShell(), SWT.SAVE);

        directoryDialog.setFilterPath(getBasePath());

        return directoryDialog.open();
    }