org.eclipse.swt.widgets.DirectoryDialog#setFilterPath ( )源码实例Demo

下面列出了org.eclipse.swt.widgets.DirectoryDialog#setFilterPath ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

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);
		}
	}
}
 
源代码2 项目: scava   文件: InstallableView.java
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));
	}
}
 
源代码3 项目: birt   文件: ClassPathBlock.java
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;
}
 
源代码4 项目: Rel   文件: RestoreDatabaseDialog.java
/**
 * 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");
}
 
/**
 * 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;
}
 
源代码6 项目: xds-ide   文件: CompilerWorkingDirectoryBlock.java
/**
 * 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);
        }
    }       
}
 
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 );
      }
    }
  };
}
 
源代码8 项目: birt   文件: ClassPathBlock.java
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;
}
 
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;
}
 
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 );
      }
    }
  };
}
 
源代码11 项目: Pydev   文件: TreeWithAddRemove.java
public void addItemWithDialog(DirectoryDialog dialog) {
    dialog.setFilterPath(lastDirectoryDialogPath);
    String filePath = dialog.open();
    if (filePath != null) {
        lastDirectoryDialogPath = filePath;
    }
    addTreeItem(filePath);
}
 
源代码12 项目: erflute   文件: AbstractExportAction.java
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();
}
 
源代码13 项目: xds-ide   文件: SWTFactory.java
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
}
 
源代码14 项目: tlaplus   文件: LibraryPathComposite.java
/**
 * 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;
}
 
@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);
        }
    }
}
 
源代码16 项目: gwt-eclipse-plugin   文件: GwtFacetWizardPage.java
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);
  }
}
 
源代码17 项目: gama   文件: ImportProjectWizardPage.java
/**
 * 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);
	}

}
 
源代码18 项目: APICloud-Studio   文件: WizardFolderImportPage.java
/**
 * 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);

}
 
源代码19 项目: ermasterr   文件: ERDiagramActivator.java
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();
}
 
源代码20 项目: ermasterr   文件: AbstractExportAction.java
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();
    }