org.eclipse.swt.widgets.DirectoryDialog Java Examples
The following examples show how to use
org.eclipse.swt.widgets.DirectoryDialog.
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: Activator.java From ermaster-b with Apache License 2.0 | 6 votes |
/** * �f�B���N�g���I���_�C�A���O��\�����܂� * * @param filePath * �f�t�H���g�̃t�@�C���p�X * @return �f�B���N�g���I���_�C�A���O�őI�����ꂽ�f�B���N�g���̃p�X */ public static String showDirectoryDialog(String filePath) { String fileName = null; if (filePath != null && !"".equals(filePath.trim())) { File file = new File(filePath.trim()); fileName = file.getPath(); } DirectoryDialog dialog = new DirectoryDialog(PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getShell(), SWT.NONE); dialog.setFilterPath(fileName); return dialog.open(); }
Example #2
Source File: NewProjectNameAndLocationWizardPage.java From Pydev with Eclipse Public License 1.0 | 6 votes |
/** * Open an appropriate directory browser */ private void handleLocationBrowseButtonPressed() { DirectoryDialog dialog = new DirectoryDialog(locationPathField.getShell()); dialog.setMessage("Select the project contents directory."); String dirName = getProjectLocationFieldValue(); if (!dirName.equals("")) { //$NON-NLS-1$ File path = new File(dirName); if (path.exists()) { dialog.setFilterPath(new Path(dirName).toOSString()); } } String selectedDirectory = dialog.open(); if (selectedDirectory != null) { customLocationFieldValue = selectedDirectory; locationPathField.setText(customLocationFieldValue); } }
Example #3
Source File: MainShell.java From RepDev with GNU General Public License v3.0 | 6 votes |
private void addFolder() { DirectoryDialog dialog = new DirectoryDialog(shell, SWT.NONE); dialog.setMessage("Select a folder to mount in RepDev"); String dir; if ((dir = dialog.open()) != null) { boolean exists = false; for (TreeItem current : tree.getItems()) { if (current.getData() instanceof String && ((String) current.getData()).equals(dir)) exists = true; } if (!exists) { TreeItem item = new TreeItem(tree, SWT.NONE); item.setText(dir.substring(dir.lastIndexOf("\\"))); item.setImage(RepDevMain.smallFolderImage); item.setData(dir); new TreeItem(item, SWT.NONE).setText("Loading..."); Config.getMountedDirs().add(dir); } } }
Example #4
Source File: DFSActionImpl.java From RDFS with Apache License 2.0 | 6 votes |
/** * 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: DirectoryDialogButtonListenerFactory.java From pentaho-kettle with Apache License 2.0 | 6 votes |
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 #6
Source File: PWDirectoryChooser.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * @see org.eclipse.nebula.widgets.opal.preferencewindow.widgets.PWChooser#setButtonAction(org.eclipse.swt.widgets.Text, * org.eclipse.swt.widgets.Button) */ @Override protected void setButtonAction(final Text text, final Button button) { final String originalDirectory = (String) PreferenceWindow.getInstance().getValueFor(getPropertyKey()); text.setText(originalDirectory); button.addListener(SWT.Selection, event -> { final DirectoryDialog dialog = new DirectoryDialog(text.getShell()); dialog.setMessage(ResourceManager.getLabel(ResourceManager.CHOOSE_DIRECTORY)); final String result = dialog.open(); if (result != null) { text.setText(result); PreferenceWindow.getInstance().setValue(getPropertyKey(), result); } }); }
Example #7
Source File: NewReportPageSupport.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Open an appropriate directory browser */ private void handleLocationBrowseButtonPressed( ) { DirectoryDialog dialog = new DirectoryDialog( locationPathField.getShell( ) ); dialog.setMessage( LABEL_SELECT_A_DIRECTORY ); String dirName = getFileLocationFullPath( ).toOSString( ); if ( !dirName.equals( "" ) )//$NON-NLS-1$ { File path = new File( dirName ); if ( path.exists( ) ) { dialog.setFilterPath( new Path( dirName ).toOSString( ) ); } } String selectedDirectory = dialog.open( ); if ( selectedDirectory != null ) { customLocationFieldValue = selectedDirectory; locationPathField.setText( customLocationFieldValue ); } }
Example #8
Source File: DirectoryDialogButtonListenerFactory.java From hop with Apache License 2.0 | 6 votes |
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 #9
Source File: WorkingDirectoryBlock.java From Pydev with Eclipse Public License 1.0 | 6 votes |
/** * Show a dialog that lets the user select a working directory */ private void handleWorkingDirBrowseButtonSelected() { DirectoryDialog dialog = new DirectoryDialog(getShell()); dialog.setMessage("Select a working directory for the launch configuration:"); String currentWorkingDir = getWorkingDirectoryText(); 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) { fOtherWorkingText.setText(selectedDirectory); } }
Example #10
Source File: InstallableView.java From scava with Eclipse Public License 2.0 | 6 votes |
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 #11
Source File: InstallView.java From scava with Eclipse Public License 2.0 | 6 votes |
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)); } }
Example #12
Source File: ClassPathBlock.java From birt with Eclipse Public License 1.0 | 6 votes |
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 #13
Source File: DirectoryDialogButtonListenerFactory.java From pentaho-kettle with Apache License 2.0 | 6 votes |
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 #14
Source File: DFSActionImpl.java From hadoop-gpu with Apache License 2.0 | 6 votes |
/** * 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 #15
Source File: RestoreDatabaseDialog.java From Rel with Apache License 2.0 | 6 votes |
/** * 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 #16
Source File: LocationSelector.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
private void browseFileSystem() { String result = null; if (fileMode) { result = SWTFactory.browseFile(text.getShell(), false, Messages.LocationSelector_SelectAFile, new String[]{"*" + (fileBrowseExtension == null ? "" : fileBrowseExtension)}, //$NON-NLS-1$ //$NON-NLS-2$ fileBrowsePath); } else { DirectoryDialog dialog = new DirectoryDialog(text.getShell()); dialog.setFilterPath(getLocationTxt()); dialog.setText(Messages.LocationSelector_DirSelection); dialog.setMessage(Messages.LocationSelector_ChooseADir+':'); result = dialog.open(); } if (result != null) text.setText(result); }
Example #17
Source File: CompilerWorkingDirectoryBlock.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
/** * 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 #18
Source File: HybridProjectImportPage.java From thym with Eclipse Public License 1.0 | 6 votes |
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); } }
Example #19
Source File: ExportBarWizardPage.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * 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 #20
Source File: BuildPathDialogAccess.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Shows the UI to select new external class folder entries. * The dialog returns the selected entry paths 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. * @return Returns the new external class folder path or <code>null</code> if the dialog has * been canceled by the user. * * @since 3.4 */ public static IPath[] chooseExternalClassFolderEntries(Shell shell) { String lastUsedPath= JavaPlugin.getDefault().getDialogSettings().get(IUIConstants.DIALOGSTORE_LASTEXTJARFOLDER); if (lastUsedPath == null) { lastUsedPath= ""; //$NON-NLS-1$ } DirectoryDialog dialog= new DirectoryDialog(shell, SWT.MULTI); dialog.setText(NewWizardMessages.BuildPathDialogAccess_ExtClassFolderDialog_new_title); dialog.setMessage(NewWizardMessages.BuildPathDialogAccess_ExtClassFolderDialog_new_description); 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 #21
Source File: BuildPathDialogAccess.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * 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 #22
Source File: XMLAnalysesManagerPreferencePage.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
/** * Export analysis to new file. */ private void exportAnalysis() { TableItem[] selection = fAnalysesTable.getSelection(); DirectoryDialog dialog = DirectoryDialogFactory.create(Display.getCurrent().getActiveShell(), SWT.SAVE); dialog.setText(NLS.bind(Messages.ManageXMLAnalysisDialog_SelectDirectoryExport, selection.length)); String directoryPath = dialog.open(); if (directoryPath != null) { File directory = new File(directoryPath); for (TableItem item : selection) { String fileName = item.getText(); String fileNameXml = XmlUtils.createXmlFileString(fileName); String path = new File(directory, fileNameXml).getAbsolutePath(); if (!XmlUtils.exportXmlFile(fileNameXml, path).isOK()) { Activator.logError(NLS.bind(Messages.ManageXMLAnalysisDialog_FailedToExport, fileNameXml)); } } } }
Example #23
Source File: ExportToHtmlAction.java From ermaster-b with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override protected String getSaveFilePath(IEditorPart editorPart, GraphicalViewer viewer) { IFile file = ((IFileEditorInput) editorPart.getEditorInput()).getFile(); DirectoryDialog fileDialog = new DirectoryDialog(editorPart .getEditorSite().getShell(), SWT.SAVE); IProject project = file.getProject(); fileDialog.setFilterPath(project.getLocation().toString()); fileDialog.setMessage(ResourceString .getResourceString("dialog.message.export.html.dir.select")); String saveFilePath = fileDialog.open(); if (saveFilePath != null) { saveFilePath = saveFilePath + OUTPUT_DIR; } return saveFilePath; }
Example #24
Source File: SourceAttachmentBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
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 #25
Source File: RepositoryConnectController.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public String browse() { Spoon spoon = spoonSupplier.get(); CompletableFuture<String> name = new CompletableFuture<>(); Runnable execute = () -> { DirectoryDialog directoryDialog = new DirectoryDialog( spoonSupplier.get().getShell() ); name.complete( directoryDialog.open() ); }; if ( spoon.getShell() != null ) { spoon.getShell().getDisplay().asyncExec( execute ); } else { execute.run(); } try { return name.get(); } catch ( Exception e ) { return "/"; } }
Example #26
Source File: JavadocConfigurationBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
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 #27
Source File: Activator.java From erflute with Apache License 2.0 | 5 votes |
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(); }
Example #28
Source File: AbstractExportAction.java From erflute with Apache License 2.0 | 5 votes |
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 #29
Source File: DirectorySelectionGroup.java From thym with Eclipse Public License 1.0 | 5 votes |
private void chooseDirectory(){ final DirectoryDialog dialog = new DirectoryDialog(this.getShell()); dialog.setText("Select Destination"); dialog.setMessage("Select a destination directory"); String directory = dialog.open(); if(directory != null ){ this.destinationCombo.setText(directory); sendModifyEvent(); } }
Example #30
Source File: ExportAction.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
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(); }