Java Code Examples for org.eclipse.swt.widgets.DirectoryDialog

The following are top voted examples for showing how to use org.eclipse.swt.widgets.DirectoryDialog. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: tap17-muggl-javaee   File: OptionsComposite.java   View source code 6 votes vote down vote up
/**
    * Open the dialog to chose a directory for the test case classes.
    */
protected void chooseTestClassesDirectory() {
	// Initialize the dialog.
	DirectoryDialog dialog = new DirectoryDialog(this.shell);
	dialog.setMessage("Please chose a directory for the test case classes.");
	// Check if the test cases directory exists.
	File file = new File(this.testClassesDirectoryText.getText());
	if (file.exists() && file.isDirectory()) {
		// Set as the start directory.
		dialog.setFilterPath(this.testClassesDirectoryText.getText());
	}

	// Open the dialog and process its result.
	String path = dialog.open();
	if (path != null) {
		// First of all replace double backslashes against slashes.
		path = path.replace("\\\\", "\\");

		// Convert backslashes to slashes.
		path = path.replace("\\", "/");

		// Set it as the text.
		this.testClassesDirectoryText.setText(path);
	}
}
 
Example 2
Project: termsuite-ui   File: BrowseDirText.java   View source code 6 votes vote down vote up
private void createContents() {
	GridLayoutFactory.swtDefaults().numColumns(2).applyTo(this);

	text = new Text(this, SWT.NONE);
	GridDataFactory.fillDefaults().grab(true, false).applyTo(text);

	Button button = new Button(this, SWT.PUSH);
	button.setText("Browse...");
	button.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			DirectoryDialog fileDialog = new DirectoryDialog(getShell());
			// Set the text
			fileDialog.setText("Select directory");
			// Set filter on .txt files
			String selection = fileDialog.open();
			if (selection != null)
				text.setText(selection);
		}
	});
}
 
Example 3
Project: team-explorer-everywhere   File: OpenDropFolderAction.java   View source code 6 votes vote down vote up
private File promptForLocation(final String dropPath) {
    final DirectoryDialog dialog = new DirectoryDialog(getShell());

    final String directoryPath = dialog.open();
    if (directoryPath != null) {
        final File targetFile = new File(directoryPath, dropPath);
        if (targetFile.exists()) {
            final String title = Messages.getString("BuildDropDownload.ConfirmOverwriteDialogTitle"); //$NON-NLS-1$
            final String messageFormat = Messages.getString("BuildDropDownload.ConfirmOverwriteDialogTextFormat"); //$NON-NLS-1$
            final String message = MessageFormat.format(messageFormat, targetFile.getAbsolutePath());

            if (!MessageBoxHelpers.dialogConfirmPrompt(getShell(), title, message)) {
                return null;
            }
        }
        return targetFile;
    }
    return null;

}
 
Example 4
Project: eclipse-weblogic-plugin   File: ClasspathFieldEditor.java   View source code 6 votes vote down vote up
/**
 * @return
 */
protected String getNewDir() {
    final DirectoryDialog dialog = new DirectoryDialog(this.addDirButton.getShell());
    if ((this.lastPath != null) && new File(this.lastPath).exists()) {
        dialog.setFilterPath(this.lastPath);
    }
    String dir = dialog.open();
    if (dir != null) {
        dir = dir.trim();
        if (dir.length() == 0) {
            return null;
        }
        this.lastPath = dir;
    }
    return dir;
}
 
Example 5
Project: eclipse-weblogic-plugin   File: PathFieldEditor.java   View source code 6 votes vote down vote up
/**
 * @return
 */
protected String getNewDir() {
    final DirectoryDialog dialog = new DirectoryDialog(this.addDirButton.getShell());
    if ((this.lastPath != null) && new File(this.lastPath).exists()) {
        dialog.setFilterPath(this.lastPath);
    }
    String dir = dialog.open();
    if (dir != null) {
        dir = dir.trim();
        if (dir.length() == 0) {
            return null;
        }
        this.lastPath = dir;
    }
    return dir;
}
 
Example 6
Project: Black   File: blackAction.java   View source code 6 votes vote down vote up
public void saveAllAsText() {
	if (b.fileindex.size() == 0)
		return;
	String dir = b.projectFile.getParentFile().getAbsolutePath() + "\\Files\\";
	DirectoryDialog getdir = new DirectoryDialog(b);
	getdir.setText("ѡ�����Ŀ¼");
	String dirpath = getdir.open();
	if (dirpath != null && b.fileindex.size() > 0) {
		Iterator<String> it = b.fileindex.iterator();
		while (it.hasNext()) {
			String filename = it.next();
			File file = new File(dir + filename);
			if (file.exists()) {
				String outputname = getShowNameByRealName(filename);
				File output = new File(dirpath + "\\" + outputname + ".txt");
				ioThread io = new ioThread(b);
				String text = io.readBlackFile(file, null).get();
				if (!io.writeTextFile(output, text, "utf-8"))
					getMessageBox("ת���ļ�", "ת��" + outputname + "ʱʧ�ܣ�");
			}
		}
		getMessageBox("ת���ļ�", "�ѽ���Ŀ�е������ļ�ת������ѡ��Ŀ¼��");
		showinExplorer(dirpath, false);
	}
}
 
Example 7
Project: ermaster-k   File: ERDiagramActivator.java   View source code 6 votes vote down vote up
public static String showDirectoryDialog(String filePath, String message) {
	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.setMessage(ResourceString.getResourceString(message));

	dialog.setFilterPath(fileName);

	return dialog.open();
}
 
Example 8
Project: hadoop-2.6.0-cdh5.4.3   File: DFSActionImpl.java   View source code 6 votes vote down vote up
/**
 * 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 9
Project: hadoop-EAR   File: DFSActionImpl.java   View source code 6 votes vote down vote up
/**
 * 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 10
Project: agui_eclipse_plugin   File: AguiPreferencePage.java   View source code 6 votes vote down vote up
@Override
public void widgetSelected(SelectionEvent e) {
	DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.OPEN | SWT.SHEET);
	if (TextUtils.isNullorEmpty(sdkLocationText.getText())) {
		dialog.setText(sdkLocationText.getText());
	} 
	String path = dialog.open();
	if (path != null) {
		sdkLocationText.setText(path);
		if (new File(path).exists()) {
			setSdkLocation(path);
		} else {
			cleanTable();
			AguiPlugin.displayError("Error", "Xml format is wrong");	
		}
	} else {
		cleanTable();
	}
}
 
Example 11
Project: openhab-hdl   File: SelectConfigFolderAction.java   View source code 6 votes vote down vote up
@Override
public void run() {
	Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
	DirectoryDialog dialog = new DirectoryDialog(shell, SWT.OPEN);
	dialog.setMessage("Select the configuration folder of the openHAB runtime");
	String selection = dialog.open();
	if(selection!=null) {
		try {
			File file = new File(selection);
			if(isValidConfigurationFolder(file)) {
				ConfigurationFolderProvider.saveFolderToPreferences(selection);
				ConfigurationFolderProvider.setRootConfigurationFolder(new File(selection));
				viewer.setInput(ConfigurationFolderProvider.getRootConfigurationFolder());
			} else {
				MessageDialog.openError(shell, "No valid configuration directory", "The chosen directory is not a valid openHAB configuration" +
						" directory. Please choose a different one.");
			}
		} catch (CoreException e) {
			IStatus status = new Status(IStatus.ERROR, UIActivator.PLUGIN_ID,  "An error occurred while opening the configuration folder", e);
			ErrorDialog.openError(shell, "Cannot open configuration folder!", null, status);
		}
	}
}
 
Example 12
Project: JFaceUtils   File: EnhancedDirectoryFieldEditor.java   View source code 6 votes vote down vote up
protected File getDirectory(final File startingDirectory) {
	final DirectoryDialog fileDialog = new DirectoryDialog(getShell(), SWT.OPEN | SWT.SHEET);
	if (dialogMessage != null && dialogMessage.get() != null) {
		fileDialog.setMessage(dialogMessage.get());
	}
	if (startingDirectory != null) {
		fileDialog.setFilterPath(startingDirectory.getPath());
	}
	else if (filterPath != null) {
		fileDialog.setFilterPath(filterPath.getPath());
	}
	String dir = fileDialog.open();
	if (dir != null) {
		dir = dir.trim();
		if (dir.length() > 0) {
			return new File(dir);
		}
	}
	return null;
}
 
Example 13
Project: JFaceUtils   File: LocalizedPathEditor.java   View source code 6 votes vote down vote up
@Override
protected String getNewInputObject() {
	final DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.SHEET);
	if (dirChooserLabelText != null && dirChooserLabelText.get() != null) {
		dialog.setMessage(dirChooserLabelText.get());
	}
	if (lastPath != null && new File(lastPath).exists()) {
		dialog.setFilterPath(lastPath);
	}
	String dir = dialog.open();
	if (dir != null) {
		dir = dir.trim();
		if (dir.length() == 0) {
			return null;
		}
		lastPath = dir;
	}
	return dir;
}
 
Example 14
Project: cmake-eclipse-helper   File: PluginDataIO.java   View source code 6 votes vote down vote up
public static Path getDataDirectory() {
	String url = Activator.getCMakePath();
	if (url == null)
	{
		// create a dialog with ok and cancel buttons and a question icon
		DirectoryDialog dialog = new DirectoryDialog(Display.getDefault().getActiveShell(), SWT.ICON_QUESTION | SWT.OK| SWT.CANCEL);
		dialog.setText("Unable to find CMakeEnvironment");
		dialog.setMessage("Please specify path to the CMakeEnvironment");

		// open dialog and await user selection
		String returnCode = dialog.open();
		if(returnCode != null)
		{
			Activator.getDefault().getPreferenceStore().setValue("USE_CMAKE_PATH", returnCode);
		}
	}
		
	return new File(url).toPath();
}
 
Example 15
Project: OpenSPIFe   File: DirectoryFieldEditor.java   View source code 6 votes vote down vote up
/**
   * Helper that opens the directory chooser dialog.
   * @param startingDirectory The directory the dialog will open in.
   * @return File File or <code>null</code>.
   * 
   */
  private File getDirectory(File startingDirectory) {

      DirectoryDialog fileDialog = new DirectoryDialog(getShell(), SWT.OPEN | SWT.SHEET);
      if (startingDirectory != null) {
	fileDialog.setFilterPath(startingDirectory.getPath());
}
      else if (filterPath != null) {
      	fileDialog.setFilterPath(filterPath.getPath());
      }
      String dir = fileDialog.open();
      if (dir != null) {
          dir = dir.trim();
          if (dir.length() > 0) {
		return new File(dir);
	}
      }

      return null;
  }
 
Example 16
Project: Eclipse-Postfix-Code-Completion   File: BuildPathDialogAccess.java   View source code 6 votes vote down vote up
/**
 * 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 17
Project: Eclipse-Postfix-Code-Completion   File: BuildPathDialogAccess.java   View source code 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 18
Project: Eclipse-Postfix-Code-Completion   File: JavadocConfigurationBlock.java   View source code 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 19
Project: Eclipse-Postfix-Code-Completion   File: NativeLibrariesConfigurationBlock.java   View source code 6 votes vote down vote up
private String chooseExternal() {
	IPath currPath= new Path(fPathField.getText());
	if (currPath.isEmpty()) {
		currPath= fEntry.getPath();
	} else {
		currPath= currPath.removeLastSegments(1);
	}

	DirectoryDialog dialog= new DirectoryDialog(fShell);
	dialog.setMessage(NewWizardMessages.NativeLibrariesDialog_external_message);
	dialog.setText(NewWizardMessages.NativeLibrariesDialog_extfiledialog_text);
	dialog.setFilterPath(currPath.toOSString());
	String res= dialog.open();
	if (res != null) {
		return res;
	}
	return null;
}
 
Example 20
Project: Eclipse-Postfix-Code-Completion   File: SourceAttachmentBlock.java   View source code 6 votes vote down vote up
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 21
Project: Eclipse-Postfix-Code-Completion   File: AddSourceFolderWizardPage.java   View source code 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 22
Project: EASyProducer   File: ReasonerPreferencePage.java   View source code 6 votes vote down vote up
/**
 * Display the directory dialog for choosing the URL source.
 */
private void displayDirDialog() {
    ReasonerDescriptor descriptor = getSelected();
    if (null != descriptor) {
        URL url = descriptor.getDownloadSource();
        if (null != url) {
            DirectoryDialog dd = new DirectoryDialog(getShell());
            String input = dd.open();
            if (null != input) {
                File file = new File(input);
                try {
                    this.url.setText(file.toURI().toURL().toString());
                } catch (MalformedURLException e) {
                    MessageBox mb = new MessageBox(getShell(), SWT.OK);
                    mb.setText("Input problem");
                    mb.setMessage("Input is not a valid URL");
                    mb.open();
                }
            }
        }
    }
}
 
Example 23
Project: DropTillLate_Application   File: InitialView.java   View source code 6 votes vote down vote up
private void openFolderDialog(boolean dropbox)
{
	try
	{
		DirectoryDialog dialog = new DirectoryDialog(shell);
		if (dropbox == true)
		{
			dialog.setText("Choose Dropbox Directory");
			text_dropboxPath.setText(dialog.open());

		} else
		{
			dialog.setText("Choose Local Temp Directory");
			text_tempPath.setText(dialog.open());
		}
	} catch (Exception e)
	{
	}
}
 
Example 24
Project: ermaster-nhit   File: ERDiagramActivator.java   View source code 6 votes vote down vote up
public static String showDirectoryDialog(String filePath, String message) {
	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.setMessage(ResourceString.getResourceString(message));

	dialog.setFilterPath(fileName);

	return dialog.open();
}
 
Example 25
Project: cmake4cdt   File: DestdirFieldEditor.java   View source code 6 votes vote down vote up
/**
   * Helper that opens the directory chooser dialog.
   * @param startingDirectory The directory the dialog will open in.
   * @return File File or <code>null</code>.
   * 
   */
  private File getDirectory(File startingDirectory) {

      DirectoryDialog fileDialog = new DirectoryDialog(getShell(), SWT.OPEN | SWT.SHEET);
      if (startingDirectory != null) {
	fileDialog.setFilterPath(startingDirectory.getPath());
}
      else if (filterPath != null) {
      	fileDialog.setFilterPath(filterPath.getPath());
      }
      String dir = fileDialog.open();
      if (dir != null) {
          dir = dir.trim();
          if (dir.length() > 0) {
		return new File(dir);
	}
      }

      return null;
  }
 
Example 26
Project: sadlos2   File: OwlFileResourceImportPage1.java   View source code 6 votes vote down vote up
/**
  *	Open an appropriate source browser so that the user can specify a source
  *	to import from
  */
 protected void handleSourceBrowseButtonPressed() {

     String currentSource = this.sourceNameField.getText();
     DirectoryDialog dialog = new DirectoryDialog(
             sourceNameField.getShell(), SWT.SAVE | SWT.SHEET);
     dialog.setText(SELECT_SOURCE_TITLE);
     dialog.setMessage(SELECT_SOURCE_MESSAGE);
     dialog.setFilterPath(getSourceDirectoryName(currentSource));

     String selectedDirectory = dialog.open();
     if (selectedDirectory != null) {
         //Just quit if the directory is not valid
         if ((getSourceDirectory(selectedDirectory) == null)
                 || selectedDirectory.equals(currentSource)) {
	return;
}
         //If it is valid then proceed to populate
         setErrorMessage(null);
         setSourceName(selectedDirectory);
         selectionGroup.setFocus();
     }
 }
 
Example 27
Project: thym   File: HybridProjectImportPage.java   View source code 6 votes vote down vote up
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 28
Project: Eclipse-Postfix-Code-Completion-Juno38   File: BuildPathDialogAccess.java   View source code 6 votes vote down vote up
/**
 * 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 29
Project: Eclipse-Postfix-Code-Completion-Juno38   File: BuildPathDialogAccess.java   View source code 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 30
Project: Eclipse-Postfix-Code-Completion-Juno38   File: JavadocConfigurationBlock.java   View source code 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= (new File(fURLResult.getFile())).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).toURL();
			return url.toExternalForm();
		} catch (MalformedURLException e) {
			JavaPlugin.log(e);
		}
	}
	return null;
}
 
Example 31
Project: Eclipse-Postfix-Code-Completion-Juno38   File: NativeLibrariesConfigurationBlock.java   View source code 6 votes vote down vote up
private String chooseExternal() {
	IPath currPath= new Path(fPathField.getText());
	if (currPath.isEmpty()) {
		currPath= fEntry.getPath();
	} else {
		currPath= currPath.removeLastSegments(1);
	}

	DirectoryDialog dialog= new DirectoryDialog(fShell);
	dialog.setMessage(NewWizardMessages.NativeLibrariesDialog_external_message);
	dialog.setText(NewWizardMessages.NativeLibrariesDialog_extfiledialog_text);
	dialog.setFilterPath(currPath.toOSString());
	String res= dialog.open();
	if (res != null) {
		return res;
	}
	return null;
}
 
Example 32
Project: Eclipse-Postfix-Code-Completion-Juno38   File: SourceAttachmentBlock.java   View source code 6 votes vote down vote up
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 33
Project: Eclipse-Postfix-Code-Completion-Juno38   File: AddSourceFolderWizardPage.java   View source code 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 34
Project: hawk-ui   File: HWizardPage.java   View source code 6 votes vote down vote up
/**
 * Uses the standard container selection dialog to choose the new value for
 * the container field.
 */

private void handleBrowse() {
	DirectoryDialog dd = new DirectoryDialog(getShell(), SWT.OPEN);
	
	dd.setFilterPath(ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile().toString());
	dd.setMessage("Select a folder where the index files will be stored");
	dd.setText("Select a directory");
	String result = dd.open();

	if (result!= null){
		basePath=result;
		folderText.setText(basePath+File.separator+this.getIndexerName());
	}

}
 
Example 35
Project: eclipse-timekeeper   File: DatabasePreferences.java   View source code 6 votes vote down vote up
private void addExportButton(Composite g) {
	Button button = new Button(g, SWT.PUSH);
	button.setText(Messages.DatabasePreferences_Export);
	button.setLayoutData(new GridData());
	button.addSelectionListener(new SelectionAdapter() {

		@Override
		public void widgetSelected(SelectionEvent e) {
			DirectoryDialog dialog = new DirectoryDialog(getFieldEditorParent().getShell(), SWT.SAVE);
			dialog.setText(Messages.DatabasePreferences_ChooseExportFolder);
			String open = dialog.open();
			if (open!=null){
				Path location = Paths.get(open);
				try {
					int count = TimekeeperPlugin.getDefault().exportTo(location);
					MessageDialog.openInformation(g.getShell(), Messages.DatabasePreferences_DataExported, String
							.format(Messages.DatabasePreferences_ExportMessage, count));
				} catch (IOException e1) {
					MessageDialog.openError(g.getShell(), Messages.DatabasePreferences_ExportError, e1.getMessage());
				}
			}
		}
	});
}
 
Example 36
Project: OpsDev   File: NewProjectNameAndLocationWizardPage.java   View source code 6 votes vote down vote up
/**
 *  Open an appropriate directory browser
 */
private void handleLocationBrowseButtonPressed() {
    DirectoryDialog dialog = new DirectoryDialog(schemalocationPathField.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;
        schemalocationPathField.setText(customLocationFieldValue);
        setSchemaPath(schemalocationPathField.getText());
    }
}
 
Example 37
Project: OpsDev   File: NewProjectNameAndLocationWizardPage.java   View source code 6 votes vote down vote up
/**
 * user手动选择ops路径是调取的方法 可以获取
 * @ToDo ops服务器的路径是否符合规范的验证
 */
private void handleOpsLocationBrowseButtonPressed() {
    DirectoryDialog dialog = new DirectoryDialog(opsLocationPathField.getShell());
    dialog.setText( "Select the ops contents directory");
    String dirName = getOpsLocationFieldValue();
    //ops服务器的规格在这个地方进行验证
    
    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) {
        opsCustomLocationFieldValue = selectedDirectory;
        opsLocationPathField.setText(opsCustomLocationFieldValue);
    }
}
 
Example 38
Project: OpsDev   File: NewProjectLocationWizardPage.java   View source code 6 votes vote down vote up
/**
 *  Open an appropriate directory browser
 */
private void handleLocationBrowseButtonPressed() {
    DirectoryDialog dialog = new DirectoryDialog(schemalocationPathField.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;
        schemalocationPathField.setText(customLocationFieldValue);
        setSchemaPath(schemalocationPathField.getText());
    }
}
 
Example 39
Project: OpsDev   File: NewProjectLocationWizardPage.java   View source code 6 votes vote down vote up
/**
 * user手动选择ops路径是调取的方法 可以获取
 * @ToDo ops服务器的路径是否符合规范的验证
 */
private void handleOpsLocationBrowseButtonPressed() {
    DirectoryDialog dialog = new DirectoryDialog(opsLocationPathField.getShell());
    dialog.setText( "Select the ops contents directory");
    String dirName = getOpsLocationFieldValue();
    //ops服务器的规格在这个地方进行验证
    
    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) {
        opsCustomLocationFieldValue = selectedDirectory;
        opsLocationPathField.setText(opsCustomLocationFieldValue);
    }
}
 
Example 40
Project: OpsDev   File: NewProjectNameAndLocationWizardPage.java   View source code 6 votes vote down vote up
/**
 *  Open an appropriate directory browser
 */
private void handleLocationBrowseButtonPressed() {
    DirectoryDialog dialog = new DirectoryDialog(schemalocationPathField.getShell());
    dialog.setMessage( "Select the project contents directory" );

    String dirName = getProjectLocationFieldValue();
    if (!dirName.equals("")) { 
        File path = new File(dirName);
        if (path.exists())
            dialog.setFilterPath(new Path(dirName).toOSString());
    }

    String selectedDirectory = dialog.open();
    if (selectedDirectory != null) {
        customLocationFieldValue = selectedDirectory;
        schemalocationPathField.setText(customLocationFieldValue);
        setSchemaPath(schemalocationPathField.getText());
    }
}