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); } }
/** Open an appropriate directory browser */ private void handleLocationBrowseButtonPressed() { DirectoryDialog dialog = new DirectoryDialog(locationPathField.getShell(), SWT.SHEET); dialog.setMessage(DataTransferMessages.WizardExternalProjectImportPage_directoryLabel); String dirName = getProjectLocationFieldValue(); if (dirName.length() == 0) { dirName = previouslyBrowsedDirectory; } if (dirName.length() == 0) { dialog.setFilterPath(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; locationPathField.setText(previouslyBrowsedDirectory); setProjectName(projectFile(previouslyBrowsedDirectory)); } }
/* * (non-Javadoc) * * @see * org.eclipse.jdt.internal.ui.wizards.dialogfields.IStringButtonAdapter * #changeControlPressed(org.eclipse.jdt * .internal.ui.wizards.dialogfields.DialogField) */ public void changeControlPressed(DialogField field) { final DirectoryDialog dialog = new DirectoryDialog(getShell()); dialog.setMessage(NewWizardMessages.NewJavaProjectWizardPageOne_directory_message); String directoryName = fLocation.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) { String oldDirectory = new Path(fLocation.getText().trim()).lastSegment(); fLocation.setText(selectedDirectory); String lastSegment = new Path(selectedDirectory).lastSegment(); if (lastSegment != null && (fNameGroup.getName().length() == 0 || fNameGroup.getName().equals(oldDirectory))) { fNameGroup.setName(lastSegment); } JavaPlugin.getDefault() .getDialogSettings() .put(DIALOGSTORE_LAST_EXTERNAL_LOC, selectedDirectory); } }
@Override protected String getNewValueFromButtonSelection() { DirectoryDialog dialog = new DirectoryDialog(button.getShell()); if (!getFieldValue().isEmpty()) { dialog.setFilterPath(getFieldValue()); } return dialog.open(); }
/** Allow user to specify a TAU bin directory. */ protected void handleBinBrowseButtonSelected(Text field, String group) { final DirectoryDialog dialog = new DirectoryDialog(getShell()); IFileStore path = null; final String correctPath = getFieldContent(field.getText()); if (correctPath != null) { path = EFS.getLocalFileSystem().getStore(new Path(correctPath)); // new File(correctPath); if (path.fetchInfo().exists()) { dialog.setFilterPath( !path.fetchInfo().isDirectory() ? correctPath : path.getParent().toURI().getPath()); } } // The specified directory previously had to contain at least one // recognizable TAU makefile in its lib sub-directory to be accepted. // String tlpath = correctPath+File.separator+"lib"; // // class makefilter implements FilenameFilter{ // public boolean accept(File dir, String name) { // if(name.indexOf("Makefile.tau")!=0 || name.indexOf("-pdt")<=0) // return false; // return true; // } // } // File[] mfiles=null; // makefilter mfilter = new makefilter(); // File test = new File(tlpath); dialog.setText( Messages.ToolLocationPreferencePage_Select + group + Messages.ToolLocationPreferencePage_BinDirectory); // dialog.setMessage("You must select a valid TAU bin directory. Such a directory should be // created when you configure and install TAU. It should contain least one valid stub makefile // configured with the Program Database Toolkit (pdt)"); final String selectedPath = dialog.open(); // null; if (selectedPath != null) { field.setText(selectedPath); // while(true) // { // selectedPath = dialog.open(); // if(selectedPath==null) // break; // // tlpath=selectedPath+File.separator+"lib"; // test = new File(tlpath); // if(test.exists()){ // mfiles = test.listFiles(mfilter); // } // if (mfiles!=null&&mfiles.length>0) // { // if (selectedPath != null) // tauBin.setText(selectedPath); // break; // } // } } }
/** * Uses the standard container selection dialog to choose the new value for the container field. */ private void handleDownloadDirBrowse() { DirectoryDialog dirDialog = new DirectoryDialog(getShell(), SWT.OPEN); dirDialog.setFilterPath(getDirectory()); final String filepath = dirDialog.open(); if (filepath != null) { txtDirectory.setText(filepath); dialogChanged(); } }
public void select() { final String directory = _preferencesStore.get(_preferencesString, Utilities.getWorkingDirectory()); final Shell shell = new Shell(Display.getDefault()); DirectoryDialog dialog = new DirectoryDialog(shell, SWT.MULTI); dialog.setFilterPath(directory); dialog.setText("Save JavaSeis Volume(s)"); String rtn = dialog.open(); if (rtn != null) { _preferencesStore.put(_preferencesString, rtn); PreferencesUtil.saveInstanceScopePreferences(ServiceComponent.PLUGIN_ID); } }
/* * Get the directory path using the given location as default. */ private String getDirectoryPath(String location) { DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.OPEN); dialog.setText(getDialogTitle()); dialog.setMessage("Select local database directory:"); dialog.setFilterPath(location); String path = dialog.open(); if (path != null) { File dir = new File(path); if (dir.exists() && dir.isDirectory()) { return dir.getAbsolutePath(); } } return null; }
/** 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); } }
protected void handleBrowseSelected() { DirectoryDialog dialog = new DirectoryDialog(getShell()); dialog.setMessage(browseDialogMessage); String currentWorkingDir = textField.getText(); if (!currentWorkingDir.trim().equals("")) { File path = new File(currentWorkingDir); if (path.exists()) { dialog.setFilterPath(currentWorkingDir); } } String selectedDirectory = dialog.open(); if (selectedDirectory != null) { textField.setText(selectedDirectory); } }
protected void handleBrowseButton(Text locationField) { DirectoryDialog directoryDialog = new DirectoryDialog(getShell()); String location = locationField.getText().trim(); if (!new File(location).exists()) { if (new File(defaultLocation).exists()) { location = defaultLocation; } else { location = new Path(defaultLocation).removeLastSegments(1).toString(); } } directoryDialog.setFilterPath(location); String directory = directoryDialog.open(); if (directory != null) { locationField.setText(directory); } }
public static Object run(ActionContext actionContext) throws OgnlException { Thing self = (Thing) actionContext.get("self"); Shell shell = (Shell) self.doAction("getShell", actionContext); DirectoryDialog dialog = new DirectoryDialog(shell, SWT.NONE); String filterPath = (String) self.doAction("getFilterPath", actionContext); if (filterPath != null && !"".equals(filterPath)) { dialog.setFilterPath(UtilString.getString(filterPath, actionContext)); } String message = self.getString("message"); if (message != null && !"".equals(message)) { dialog.setMessage(UtilString.getString(message, actionContext)); } String dir = dialog.open(); self.doAction("open", actionContext, UtilMap.toMap("fileName", dir)); return dir; }
/** @return a directory dialog */ private DirectoryDialog createDirectoryDialog() { DirectoryDialog directoryDialog = new DirectoryDialog(getActiveShell(), SWT.SAVE); String filterPath = org.eclipse.jubula.client.ui.rcp.utils.Utils.getLastDirPath(); directoryDialog.setFilterPath(filterPath); return directoryDialog; }
@Override protected String browse(final SapphireRenderingContext context) { final Property property = property(); final List<Path> roots = getBasePaths(); String selectedAbsolutePath = null; final List<String> extensions; if (this.fileExtensionService == null) { extensions = this.staticFileExtensionsList; } else { extensions = this.fileExtensionService.extensions(); } if (enclosed()) { final List<IContainer> baseContainers = new ArrayList<IContainer>(); for (Path path : roots) { final IContainer baseContainer = getWorkspaceContainer(path.toFile()); if (baseContainer != null) { baseContainers.add(baseContainer); } else { break; } } final ITreeContentProvider contentProvider; final ILabelProvider labelProvider; final ViewerComparator viewerComparator; final Object input; if (roots.size() == baseContainers.size()) { // All paths are in the Eclipse Workspace. Use the available content and label // providers. contentProvider = new WorkspaceContentProvider(baseContainers); labelProvider = new WorkbenchLabelProvider(); viewerComparator = new ResourceComparator(); input = ResourcesPlugin.getWorkspace().getRoot(); } else { // At least one of the roots is not in the Eclipse Workspace. Use custom file // system content and label providers. contentProvider = new FileSystemContentProvider(roots); labelProvider = new FileSystemLabelProvider(context); viewerComparator = new FileSystemNodeComparator(); input = new Object(); } final ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(context.getShell(), labelProvider, contentProvider); dialog.setTitle(property.definition().getLabel(false, CapitalizationType.TITLE_STYLE, false)); dialog.setMessage( createBrowseDialogMessage( property.definition().getLabel(true, CapitalizationType.NO_CAPS, false))); dialog.setAllowMultiple(false); dialog.setHelpAvailable(false); dialog.setInput(input); dialog.setComparator(viewerComparator); final Path currentPathAbsolute = convertToAbsolute((Path) ((Value<?>) property).content()); if (currentPathAbsolute != null) { Object initialSelection = null; if (contentProvider instanceof WorkspaceContentProvider) { final URI uri = currentPathAbsolute.toFile().toURI(); final IWorkspaceRoot wsroot = ResourcesPlugin.getWorkspace().getRoot(); final IFile[] files = wsroot.findFilesForLocationURI(uri); if (files.length > 0) { final IFile file = files[0]; if (file.exists()) { initialSelection = file; } } if (initialSelection == null) { final IContainer[] containers = wsroot.findContainersForLocationURI(uri); if (containers.length > 0) { final IContainer container = containers[0]; if (container.exists()) { initialSelection = container; } } } } else { initialSelection = ((FileSystemContentProvider) contentProvider).find(currentPathAbsolute); } if (initialSelection != null) { dialog.setInitialSelection(initialSelection); } } if (this.type == FileSystemResourceType.FILE) { dialog.setValidator(new FileSelectionStatusValidator()); } else if (this.type == FileSystemResourceType.FOLDER) { dialog.addFilter(new ContainersOnlyViewerFilter()); } if (!extensions.isEmpty()) { dialog.addFilter(new ExtensionBasedViewerFilter(extensions)); } if (dialog.open() == Window.OK) { final Object firstResult = dialog.getFirstResult(); if (firstResult instanceof IResource) { selectedAbsolutePath = ((IResource) firstResult).getLocation().toString(); } else { selectedAbsolutePath = ((FileSystemNode) firstResult).getFile().getPath(); } } } else if (this.type == FileSystemResourceType.FOLDER) { final DirectoryDialog dialog = new DirectoryDialog(context.getShell()); dialog.setText( property.definition().getLabel(true, CapitalizationType.FIRST_WORD_ONLY, false)); dialog.setMessage( createBrowseDialogMessage( property.definition().getLabel(true, CapitalizationType.NO_CAPS, false))); final Value<?> value = (Value<?>) property; final Path path = (Path) value.content(); if (path != null) { dialog.setFilterPath(path.toOSString()); } else if (roots.size() > 0) { dialog.setFilterPath(roots.get(0).toOSString()); } selectedAbsolutePath = dialog.open(); } else { final FileDialog dialog = new FileDialog(context.getShell()); dialog.setText( property.definition().getLabel(true, CapitalizationType.FIRST_WORD_ONLY, false)); final Value<?> value = (Value<?>) property; final Path path = (Path) value.content(); if (path != null && path.segmentCount() > 1) { dialog.setFilterPath(path.removeLastSegments(1).toOSString()); dialog.setFileName(path.lastSegment()); } else if (roots.size() > 0) { dialog.setFilterPath(roots.get(0).toOSString()); } if (!extensions.isEmpty()) { final StringBuilder buf = new StringBuilder(); for (String extension : extensions) { if (buf.length() > 0) { buf.append(';'); } buf.append("*."); buf.append(extension); } dialog.setFilterExtensions(new String[] {buf.toString()}); } selectedAbsolutePath = dialog.open(); } if (selectedAbsolutePath != null) { final Path relativePath = convertToRelative(new Path(selectedAbsolutePath)); if (relativePath != null) { String result = relativePath.toPortableString(); if (this.includeLeadingSlash) { result = "/" + result; } return result; } } return null; }
private void _selectFolder(Text control) { DirectoryDialog dd = new DirectoryDialog(m_shell); dd.setFilterPath(control.getText()); String newValue = dd.open(); if (newValue != null) control.setText(newValue); }
public String openBrowseDialog(IServerAttributes server, String original) { DirectoryDialog d = new DirectoryDialog(new Shell()); String filterPath = ServerUtil.makeGlobal(server.getRuntime(), new Path(original)).toString(); d.setFilterPath(filterPath); return d.open(); }