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

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

源代码1 项目: MergeProcessor   文件: DirectorySelectionDialog.java
/**
 * Open the directory dialog and set the selected directory into
 * {@link #textRepository}.
 */
private void openDirectoryDialog() {
	final DirectoryDialog dialog = new DirectoryDialog(textRepository.getShell());
	dialog.setText(directoryDialogTitle == null ? "Select directory" : directoryDialogTitle);
	final String currentText = textRepository.getText();
	if (fileExists(currentText)) {
		dialog.setFilterPath(currentText);
	} else if (fileExists(directoryDialogFilterPath)) {
		dialog.setFilterPath(directoryDialogFilterPath);
	}
	dialog.setMessage(directoryDialogMessage == null ? "Select a directory." : directoryDialogMessage);
	final String directory = dialog.open();
	if (directory != null) {
		textRepository.setText(directory);
		selectedPath = Paths.get(textRepository.getText());
	}
}
 
源代码2 项目: thym   文件: HybridProjectImportPage.java
private void handleBrowseButtonPressed() {
	final DirectoryDialog dialog = new DirectoryDialog(
			directoryPathField.getShell(), SWT.SHEET);
	dialog.setMessage("Select search directory");

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

	if (dirName.isEmpty()) {
		dialog.setFilterPath(ResourcesPlugin.getWorkspace().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);
		updateProjectsList(selectedDirectory);
	}
}
 
源代码3 项目: 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;
}
 
源代码4 项目: scava   文件: InstallView.java
protected void onBrowseBasePath() {
	DirectoryDialog directoryDialog = new DirectoryDialog(getShell());

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

	String path = directoryDialog.open();
	if (path != null) {
		String normalizedPath = Paths.get(path).toString();
		eventManager.invoke(l -> l.onChangeBasePath(normalizedPath));
	}
}
 
源代码5 项目: 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);
        }
    }       
}
 
源代码6 项目: tmxeditor8   文件: TmxConvert2FileDialog.java
/**
 * (non-Javadoc)
 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
 */
@Override
public void widgetSelected(SelectionEvent e) {
	DirectoryDialog dialog = new DirectoryDialog(getShell());
	dialog.open();

	String filterPath = dialog.getFilterPath();
	if (null == filterPath || filterPath.isEmpty()) {
		return;
	}
	text.setText(filterPath);
	setOkState();
}
 
/**
 * 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);
	}
}
 
源代码8 项目: BiglyBT   文件: ConfigSectionBackupRestoreSWT.java
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);
	}
}
 
源代码9 项目: APICloud-Studio   文件: ExportAction.java
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();
}
 
源代码10 项目: tuxguitar   文件: SWTDirectoryChooser.java
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); 
}
 
源代码11 项目: workspacemechanic   文件: TaskResourceDialog.java
private void getFromDirectory() {
  DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.SHEET);
  dialog.setMessage("Task source directories");

  String currentValue = getText().getText();
  if (currentValue != null && new File(currentValue).isDirectory()) {
    dialog.setFilterPath(currentValue);
  }
  String newValue = dialog.open();
  if (newValue != null) {
    getText().setText(newValue);
  }
}
 
源代码12 项目: erflute   文件: Activator.java
public static String showDirectoryDialog(String filePath) {
    String fileName = null;
    if (filePath != null && !"".equals(filePath.trim())) {
        final File file = new File(filePath.trim());
        fileName = file.getPath();
    }
    final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    final DirectoryDialog dialog = new DirectoryDialog(shell, SWT.NONE);
    dialog.setFilterPath(fileName);
    return dialog.open();
}
 
源代码13 项目: APICloud-Studio   文件: NodePreferencePage.java
private IPath getDirectory()
{
	DirectoryDialog fileDialog = new DirectoryDialog(getShell(), SWT.OPEN | SWT.SHEET);
	fileDialog.setMessage(MessageFormat.format(Messages.NodePreferencePage_nodejsDirSelectionMessage,
			NODE_JS_ROOT_NAME));
	String dir = fileDialog.open();
	if (!StringUtil.isEmpty(dir))
	{
		return Path.fromOSString(dir);
	}
	return null;
}
 
源代码14 项目: 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);
	}

}
 
源代码15 项目: Pydev   文件: TreeWithAddRemove.java
public void addItemWithDialog(DirectoryDialog dialog) {
    dialog.setFilterPath(lastDirectoryDialogPath);
    String filePath = dialog.open();
    if (filePath != null) {
        lastDirectoryDialogPath = filePath;
    }
    addTreeItem(filePath);
}
 
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;
}
 
/**
 * 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);
	}
}
 
源代码18 项目: gwt-eclipse-plugin   文件: AddSdkDialog.java
protected String browseForDirectory() {
  DirectoryDialog dlg = new DirectoryDialog(getShell(), SWT.OPEN);
  dlg.setFilterPath(directoryText.getText().trim());
  dlg.setMessage("Please select the root directory of your SDK installation.");

  return dlg.open();
}
 
protected String openFileDialog(Shell shell) {
    final DirectoryDialog dd = new DirectoryDialog(shell, SWT.OPEN | SWT.SINGLE);
    dd.setText(Messages.selectABonitaStudioWorkspace);
    dd.setFilterPath(getLastPath());
    return dd.open();
}
 
/**
 * Open an appropriate directory browser
 */
private void handleLocationBrowseButtonPressed()
{

	String selectedDirectory = null;
	String dirName = getPathFromLocationField();

	if (!dirName.equals(IDEResourceInfoUtils.EMPTY_STRING))
	{
		IFileInfo info;
		info = IDEResourceInfoUtils.getFileInfo(dirName);

		if (info == null || !(info.exists()))
			dirName = IDEResourceInfoUtils.EMPTY_STRING;
	}
	else
	{
		String value = getDialogSettings().get(SAVED_LOCATION_ATTR);
		if (value != null)
		{
			dirName = value;
		}
	}

	FileSystemConfiguration config = getSelectedConfiguration();
	if (config == null || config.equals(FileSystemSupportRegistry.getInstance().getDefaultConfiguration()))
	{
		DirectoryDialog dialog = new DirectoryDialog(locationPathField.getShell(), SWT.SHEET);
		dialog.setMessage(IDEWorkbenchMessages.ProjectLocationSelectionDialog_directoryLabel);

		dialog.setFilterPath(dirName);

		selectedDirectory = dialog.open();

	}
	else
	{
		URI uri = getSelectedConfiguration().getContributor().browseFileSystem(dirName, browseButton.getShell());
		if (uri != null)
			selectedDirectory = uri.toString();
	}

	if (selectedDirectory != null)
	{
		updateLocationField(selectedDirectory);
		getDialogSettings().put(SAVED_LOCATION_ATTR, selectedDirectory);
	}
}