Java 类org.eclipse.swt.widgets.DirectoryDialog 实例源码

项目:tap17-muggl-javaee    文件:OptionsComposite.java   
/**
    * 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);
    }
}
项目:termsuite-ui    文件:BrowseDirText.java   
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);
        }
    });
}
项目:team-explorer-everywhere    文件:OpenDropFolderAction.java   
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;

}
项目:eclipse-weblogic-plugin    文件:ClasspathFieldEditor.java   
/**
 * @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;
}
项目:eclipse-weblogic-plugin    文件:PathFieldEditor.java   
/**
 * @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;
}
项目:Black    文件:blackAction.java   
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);
    }
}
项目:ermaster-k    文件:ERDiagramActivator.java   
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();
}
项目:hadoop-2.6.0-cdh5.4.3    文件:DFSActionImpl.java   
/**
 * 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);

}
项目:hadoop-EAR    文件:DFSActionImpl.java   
/**
 * 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);

}
项目:agui_eclipse_plugin    文件:AguiPreferencePage.java   
@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();
    }
}
项目:openhab-hdl    文件:SelectConfigFolderAction.java   
@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);
        }
    }
}
项目:JFaceUtils    文件:EnhancedDirectoryFieldEditor.java   
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;
}
项目:JFaceUtils    文件:LocalizedPathEditor.java   
@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;
}
项目:cmake-eclipse-helper    文件:PluginDataIO.java   
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();
}
项目:OpenSPIFe    文件:DirectoryFieldEditor.java   
/**
   * 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;
  }
项目:Eclipse-Postfix-Code-Completion    文件:BuildPathDialogAccess.java   
/**
 * 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;
}
项目:Eclipse-Postfix-Code-Completion    文件:BuildPathDialogAccess.java   
/**
 * 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;
}
项目:Eclipse-Postfix-Code-Completion    文件:JavadocConfigurationBlock.java   
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;
}
项目:Eclipse-Postfix-Code-Completion    文件:NativeLibrariesConfigurationBlock.java   
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;
}
项目:Eclipse-Postfix-Code-Completion    文件:SourceAttachmentBlock.java   
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;
}
项目:Eclipse-Postfix-Code-Completion    文件:AddSourceFolderWizardPage.java   
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);
        }
    }
}
项目:EASyProducer    文件:ReasonerPreferencePage.java   
/**
 * 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();
                }
            }
        }
    }
}
项目:DropTillLate_Application    文件:InitialView.java   
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)
    {
    }
}
项目:ermaster-nhit    文件:ERDiagramActivator.java   
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();
}
项目:cmake4cdt    文件:DestdirFieldEditor.java   
/**
   * 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;
  }
项目:sadlos2    文件:OwlFileResourceImportPage1.java   
/**
  * 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();
     }
 }
项目: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);
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:BuildPathDialogAccess.java   
/**
 * 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;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:BuildPathDialogAccess.java   
/**
 * 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;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavadocConfigurationBlock.java   
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;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:NativeLibrariesConfigurationBlock.java   
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;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:SourceAttachmentBlock.java   
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;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:AddSourceFolderWizardPage.java   
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);
        }
    }
}
项目:hawk-ui    文件:HWizardPage.java   
/**
 * 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());
    }

}
项目:eclipse-timekeeper    文件:DatabasePreferences.java   
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());
                }
            }
        }
    });
}
项目:OpsDev    文件:NewProjectNameAndLocationWizardPage.java   
/**
 *  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());
    }
}
项目:OpsDev    文件:NewProjectNameAndLocationWizardPage.java   
/**
 * 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);
    }
}
项目:OpsDev    文件:NewProjectLocationWizardPage.java   
/**
 *  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());
    }
}
项目:OpsDev    文件:NewProjectLocationWizardPage.java   
/**
 * 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);
    }
}
项目:OpsDev    文件:NewProjectNameAndLocationWizardPage.java   
/**
 *  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());
    }
}