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);
    }
  }
 /** {@inheritDoc} */
 public Object executeImpl(ExecutionEvent event) {
   DirectoryDialog directoryDialog = createDirectoryDialog();
   genPath = directoryDialog.open();
   if (genPath != null) {
     org.eclipse.jubula.client.ui.rcp.utils.Utils.storeLastDirPath(
         directoryDialog.getFilterPath());
     File directory = new File(genPath);
     if (directory.list().length == 0) {
       InputDialog inputDialog =
           new InputDialog(
               getActiveShell(),
               Messages.InputDialogName,
               Messages.InputDialogMessage,
               StringConstants.EMPTY,
               new PackageNameValidator());
       if (inputDialog.open() == Window.OK) {
         genPackage = inputDialog.getValue();
         IWorkbench workbench = PlatformUI.getWorkbench();
         try {
           workbench.getProgressService().run(true, true, new ConvertProjectOperation());
         } catch (InvocationTargetException | InterruptedException e) {
           LOG.error(Messages.ErrorWhileConverting, e);
         }
       }
     } else {
       ErrorHandlingUtil.createMessageDialog(MessageIDs.E_NON_EMPTY_DIRECTORY);
     }
   }
   return null;
 }
Esempio n. 3
0
  public static void main(String[] args) throws IOException {
    List<Emoticon> emoticons = new ArrayList<Emoticon>();
    new EmoFormat(emoticons, protocols).load();

    Display display = new Display();

    shell = new Shell(display);
    DirectoryDialog dialog = new DirectoryDialog(shell, SWT.NONE);
    dialog.setText("Select folder with emoticon images");
    String path = dialog.open();
    if (path == null) return;
    //		String path = "C:\\Desenvolvimento\\Miranda\\bin\\Debug
    // Unicode\\Customize\\Emoticons\\Originals";
    File mepPath = new File(path);
    if (!mepPath.exists()) return;

    mepFormat = new MepFormat(mepPath, emoticons, protocols);
    mep = mepFormat.load();

    createMainWindow(shell);

    shell.setText("Emoticon Pack Editor");
    shell.setImage(Images.get("data/Defaults/smile.png"));
    shell.setSize(500, 600);
    shell.open();

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
  /** 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));
    }
  }
Esempio n. 5
0
  public void cmdIedeaExportsSelected() {
    DirectoryDialog dlg = new DirectoryDialog(getShell());
    dlg.setText("Select a folder to save the export files in");
    dlg.setMessage("Select a directory");
    final String dir = dlg.open();
    if (dir == null) {
      return;
    }

    final IedeaExporter iedeaExporter = new IedeaExporter();
    try {
      new ProgressMonitorDialog(null)
          .run(
              true,
              true,
              new IRunnableWithProgress() {
                @Override
                public void run(IProgressMonitor monitor)
                    throws InvocationTargetException, InterruptedException {
                  try {
                    iedeaExporter.setMonitor(monitor);
                    iedeaExporter.generate(dir);
                  } catch (TaskException e) {
                    throw new InvocationTargetException(e);
                  }
                }
              });
      MessageDialog.openInformation(null, "Completed", "Tier.net export successful");
    } catch (InvocationTargetException e) {
      MessageUtil.showError(e, "Error running export", e.getMessage());
    } catch (InterruptedException e) {
      MessageDialog.openInformation(null, "Cancelled", e.getMessage());
    }
  }
    /*
     * (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();
 }
 /** Listener for Browse Button. */
 protected void browseBtnListener() {
   DirectoryDialog dialog = new DirectoryDialog(this.getShell());
   dialog.setText(Messages.wizPageSelFolder);
   dialog.setMessage(Messages.wizPageChooseDir);
   String directory = dialog.open();
   if (directory != null) {
     textLocation.setText(directory);
   }
 }
 /**
  * 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();
   }
 }
Esempio n. 10
0
  /** 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;
      // }
      // }
    }
  }
 public void openDirectoryDialog(
     final ImageExporterSettings settings,
     final TGSongStreamContext context,
     final Runnable callback) {
   DirectoryDialog dialog = new DirectoryDialog(TuxGuitar.getInstance().getShell());
   dialog.setText(TuxGuitar.getProperty("tuxguitar-image.directory-dialog.title"));
   settings.setPath(dialog.open());
   if (settings.getPath() != null) {
     context.setAttribute(ImageExporterSettings.class.getName(), settings);
     callback.run();
   }
 }
 /*
  * 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;
 }
  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);
    }
  }
Esempio n. 14
0
  /**
   * ************************************************************************* The command has been
   * executed, so extract extract the needed information from the application context.
   * ************************************************************************
   */
  public CommandResult execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IRuntimeSettings runtime = (IRuntimeSettings) ServiceManager.get(IRuntimeSettings.class);
    String instanceId = (String) runtime.getRuntimeProperty(RuntimeProperty.ID_PROCEDURE_SELECTION);

    try {
      IProcedureManager mgr = (IProcedureManager) ServiceManager.get(IProcedureManager.class);
      IProcedure proc = null;
      if (mgr.isLocallyLoaded(instanceId)) {
        proc = mgr.getProcedure(instanceId);
      } else {
        proc = mgr.getRemoteProcedure(instanceId);
      }

      List<AsRunFile> toExport = new LinkedList<AsRunFile>();

      ExportAsRunFileJob job = new ExportAsRunFileJob(proc);
      CommandHelper.executeInProgress(job, true, true);

      if (job.result.equals(CommandResult.SUCCESS)) {
        toExport.add(job.asrunFile);
        if (!job.asrunFile.getChildren().isEmpty()) {
          boolean alsoChildren =
              MessageDialog.openQuestion(
                  window.getShell(),
                  "Export children ASRUN files",
                  "This procedure has executed sub-procedures.\n\nDo you want to export these ASRUN files as well?");
          if (alsoChildren) {
            gatherChildAsRunFiles(job.asrunFile, toExport);
          }
        }
      }

      DirectoryDialog dialog = new DirectoryDialog(window.getShell(), SWT.SAVE);
      dialog.setMessage(
          "Select directory to export ASRUN file(s) for '" + proc.getProcName() + "'");
      dialog.setText("Export ASRUN");
      String destination = dialog.open();
      if (destination != null && !destination.isEmpty()) {
        SaveAsRunFileJob saveJob = new SaveAsRunFileJob(destination, toExport);
        CommandHelper.executeInProgress(saveJob, true, true);
        return saveJob.result;
      } else {
        return CommandResult.NO_EFFECT;
      }
    } catch (Exception ex) {
      ex.printStackTrace();
      return CommandResult.FAILED;
    }
  }
Esempio n. 15
0
 /** 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);
   }
 }
Esempio n. 16
0
  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);
    }
  }
Esempio n. 17
0
 public static void loadFile(Shell shell, Text text, String msg, boolean isDirectory) {
   if (isDirectory) {
     DirectoryDialog dialog = new DirectoryDialog(shell, SWT.NONE);
     dialog.setMessage(msg);
     String value = dialog.open();
     if (value != null) {
       text.setText(value);
     }
   } else {
     FileDialog dialog = new FileDialog(shell, SWT.NONE);
     dialog.setText(msg);
     String value = dialog.open();
     if (value != null) {
       text.setText(value);
     }
   }
 }
  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);
    }
  }
  protected void handleBrowseButton() {
    if (!pageReady) {
      new UIJob(I18n.get("job")) {
        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
          handleBrowseButton();
          return Status.OK_STATUS;
        }
      }.schedule();
      return;
    }

    DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.OPEN);
    String path = dialog.open();
    if (path != null) {
      directoryText.setText(path);
    }
  }
  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;
  }
  @Override
  public Object execute(ExecutionEvent event) throws ExecutionException {
    final ISelection selection = HandlerUtil.getCurrentSelection(event);

    if (selection instanceof IStructuredSelection) {
      final IStructuredSelection structSelection = (IStructuredSelection) selection;
      Object element = structSelection.getFirstElement();
      if (!(element instanceof DBNResource)) {
        return null;
      }
      final IResource resource = ((DBNResource) element).getResource();
      if (resource instanceof IFolder) {
        final IWorkbenchWindow workbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
        DirectoryDialog dialog = new DirectoryDialog(workbenchWindow.getShell(), SWT.NONE);
        String folder = dialog.open();
        if (folder != null) {
          createLink(workbenchWindow, (IFolder) resource, folder);
        }
      }
    }
    return null;
  }
Esempio n. 22
0
  private void init() {

    if (COConfigurationManager.getBooleanParameter("Save Torrent Files")) {
      try {
        dirName = COConfigurationManager.getDirectoryParameter("General_sDefaultTorrent_Directory");
      } catch (Exception egnore) {
      }
    }
    if (dirName == null) {
      DirectoryDialog dd = new DirectoryDialog(parent, SWT.NULL);
      dd.setText(MessageText.getString("fileDownloadWindow.saveTorrentIn"));
      dirName = dd.open();
    }
    if (dirName == null) return;

    pReporter = ProgressReportingManager.getInstance().addReporter();
    setupAndShowDialog();

    downloader =
        TorrentDownloaderFactory.create(this, original_url, referrer, request_properties, dirName);
    downloader.setIgnoreReponseCode(true);
    downloader.start();
  }
Esempio n. 23
0
  private File getFile(Object exportItem) {
    File file = null;
    if (exportItem instanceof Class) {
      DirectoryDialog directoryDialog = new DirectoryDialog(getShell());

      directoryDialog.setMessage(Messages.ExportWizardSelectDirectory);

      String dir = directoryDialog.open();
      if (dir != null) file = new File(dir);
    } else {
      String name = null;
      if (exportItem instanceof Account) name = ((Account) exportItem).getName();
      else if (exportItem instanceof Portfolio) name = ((Portfolio) exportItem).getName();
      else if (exportItem instanceof Security) name = ((Security) exportItem).getIsin();
      else if (exportItem instanceof String) name = (String) exportItem;

      FileDialog dialog = new FileDialog(getShell(), SWT.SAVE);
      if (name != null) dialog.setFileName(name + ".csv"); // $NON-NLS-1$
      String fileName = dialog.open();

      if (fileName != null) file = new File(fileName);
    }
    return file;
  }
Esempio n. 24
0
  private void openDialog() {
    DirectoryDialog dialog = new DirectoryDialog(BrowserMain.shell);
    String folder = dialog.open();
    if (folder == null) return;
    File file = new File(folder);
    File[] files =
        file.listFiles(
            new FilenameFilter() {
              public boolean accept(File dir, String name) {
                return name.endsWith(".html") || name.endsWith(".htm");
              }
            });
    if (files.length == 0) return;
    BrowserMain.urls = new String[files.length];
    BrowserMain.titles = new String[files.length];
    BrowserMain.index = 0;
    for (int i = 0; i < files.length; i++) {
      try {
        String url = files[i].toURL().toString();
        BrowserMain.urls[i] = url;
      } catch (MalformedURLException ex) {
      }
    }

    final TitleListener tocTitleListener =
        new TitleListener() {
          public void changed(TitleEvent event) {
            BrowserMain.titles[BrowserMain.index] = event.title;
          }
        };
    final LocationListener locationListener =
        new LocationListener() {
          public void changed(LocationEvent event) {
            // BrowserMain.back.setEnabled(false);
            // BrowserMain.forward.setEnabled(false);
          }

          public void changing(LocationEvent event) {}
        };
    final ProgressListener tocProgressListener =
        new ProgressListener() {
          public void changed(ProgressEvent event) {}

          public void completed(ProgressEvent event) {
            Browser browser = (Browser) event.widget;
            BrowserMain.index++;
            boolean tocCompleted = BrowserMain.index >= BrowserMain.titles.length;
            if (tocCompleted) {
              browser.dispose();
              browser = new Browser(BrowserMain.form, SWT.NONE);
              browser.setMenu(new Menu(browser));
              BrowserMain.browser = browser;
              BrowserMain.form.layout(true);
              BrowserMain.form.setWeights(new int[] {20, 75});
              browser.addLocationListener(locationListener);
              browser.addMouseListener(BrowserMain.catcher);
              browser.addMouseMoveListener(BrowserMain.catcher);
              BrowserMain.list.removeAll();
              for (int i = 0; i < BrowserMain.titles.length; i++)
                BrowserMain.list.add(BrowserMain.titles[i]);
              BrowserMain.list.select(0);
              browser.setUrl(BrowserMain.urls[0]);
              BrowserMain.shell.setText("SWT Browser - Documentation Viewer");
              return;
            }
            BrowserMain.shell.setText(
                "Building index " + BrowserMain.index + "/" + BrowserMain.urls.length);
            browser.setUrl(BrowserMain.urls[BrowserMain.index]);
          }
        };

    BrowserMain.shell.setText("Building index");
    BrowserMain.browser.addTitleListener(tocTitleListener);
    BrowserMain.browser.addProgressListener(tocProgressListener);
    /*browser.addMouseListener(catcher);
    browser.addMouseMoveListener(catcher);
    browser.setMenu(new Menu(browser));*/

    if (BrowserMain.urls.length > 0) BrowserMain.browser.setUrl(BrowserMain.urls[0]);
  }
Esempio n. 25
0
  /**
   * Handle the create button selection event.
   *
   * @param event org.eclipse.swt.events.SelectionEvent
   */
  void createButtonSelected(SelectionEvent event) {

    /* Compute the appropriate dialog style */
    int style = getDefaultStyle();
    if (okButton.getEnabled() && okButton.getSelection()) style |= SWT.OK;
    if (cancelButton.getEnabled() && cancelButton.getSelection()) style |= SWT.CANCEL;
    if (yesButton.getEnabled() && yesButton.getSelection()) style |= SWT.YES;
    if (noButton.getEnabled() && noButton.getSelection()) style |= SWT.NO;
    if (retryButton.getEnabled() && retryButton.getSelection()) style |= SWT.RETRY;
    if (abortButton.getEnabled() && abortButton.getSelection()) style |= SWT.ABORT;
    if (ignoreButton.getEnabled() && ignoreButton.getSelection()) style |= SWT.IGNORE;
    if (iconErrorButton.getEnabled() && iconErrorButton.getSelection()) style |= SWT.ICON_ERROR;
    if (iconInformationButton.getEnabled() && iconInformationButton.getSelection())
      style |= SWT.ICON_INFORMATION;
    if (iconQuestionButton.getEnabled() && iconQuestionButton.getSelection())
      style |= SWT.ICON_QUESTION;
    if (iconWarningButton.getEnabled() && iconWarningButton.getSelection())
      style |= SWT.ICON_WARNING;
    if (iconWorkingButton.getEnabled() && iconWorkingButton.getSelection())
      style |= SWT.ICON_WORKING;
    if (primaryModalButton.getEnabled() && primaryModalButton.getSelection())
      style |= SWT.PRIMARY_MODAL;
    if (applicationModalButton.getEnabled() && applicationModalButton.getSelection())
      style |= SWT.APPLICATION_MODAL;
    if (systemModalButton.getEnabled() && systemModalButton.getSelection())
      style |= SWT.SYSTEM_MODAL;
    if (saveButton.getEnabled() && saveButton.getSelection()) style |= SWT.SAVE;
    if (openButton.getEnabled() && openButton.getSelection()) style |= SWT.OPEN;
    if (multiButton.getEnabled() && multiButton.getSelection()) style |= SWT.MULTI;

    /* Open the appropriate dialog type */
    String name = dialogCombo.getText();

    if (name.equals(ControlExample.getResourceString("ColorDialog"))) {
      ColorDialog dialog = new ColorDialog(shell, style);
      dialog.setRGB(new RGB(100, 100, 100));
      dialog.setText(ControlExample.getResourceString("Title"));
      RGB result = dialog.open();
      textWidget.append(ControlExample.getResourceString("ColorDialog") + Text.DELIMITER);
      textWidget.append(
          ControlExample.getResourceString("Result", new String[] {"" + result}) + Text.DELIMITER);
      textWidget.append("getRGB() = " + dialog.getRGB() + Text.DELIMITER + Text.DELIMITER);
      return;
    }

    if (name.equals(ControlExample.getResourceString("DirectoryDialog"))) {
      DirectoryDialog dialog = new DirectoryDialog(shell, style);
      dialog.setMessage(ControlExample.getResourceString("Example_string"));
      dialog.setText(ControlExample.getResourceString("Title"));
      String result = dialog.open();
      textWidget.append(ControlExample.getResourceString("DirectoryDialog") + Text.DELIMITER);
      textWidget.append(
          ControlExample.getResourceString("Result", new String[] {"" + result})
              + Text.DELIMITER
              + Text.DELIMITER);
      return;
    }

    if (name.equals(ControlExample.getResourceString("FileDialog"))) {
      FileDialog dialog = new FileDialog(shell, style);
      dialog.setFileName(ControlExample.getResourceString("readme_txt"));
      dialog.setFilterNames(FilterNames);
      dialog.setFilterExtensions(FilterExtensions);
      dialog.setText(ControlExample.getResourceString("Title"));
      String result = dialog.open();
      textWidget.append(ControlExample.getResourceString("FileDialog") + Text.DELIMITER);
      textWidget.append(
          ControlExample.getResourceString("Result", new String[] {"" + result}) + Text.DELIMITER);
      textWidget.append("getFileNames() =" + Text.DELIMITER);
      if ((dialog.getStyle() & SWT.MULTI) != 0) {
        String[] files = dialog.getFileNames();
        for (int i = 0; i < files.length; i++) {
          textWidget.append("\t" + files[i] + Text.DELIMITER);
        }
      }
      textWidget.append(
          "getFilterIndex() = " + dialog.getFilterIndex() + Text.DELIMITER + Text.DELIMITER);
      return;
    }

    if (name.equals(ControlExample.getResourceString("FontDialog"))) {
      FontDialog dialog = new FontDialog(shell, style);
      dialog.setText(ControlExample.getResourceString("Title"));
      FontData result = dialog.open();
      textWidget.append(ControlExample.getResourceString("FontDialog") + Text.DELIMITER);
      textWidget.append(
          ControlExample.getResourceString("Result", new String[] {"" + result}) + Text.DELIMITER);
      textWidget.append("getFontList() =" + Text.DELIMITER);
      FontData[] fonts = dialog.getFontList();
      if (fonts != null) {
        for (int i = 0; i < fonts.length; i++) {
          textWidget.append("\t" + fonts[i] + Text.DELIMITER);
        }
      }
      textWidget.append("getRGB() = " + dialog.getRGB() + Text.DELIMITER + Text.DELIMITER);
      return;
    }

    if (name.equals(ControlExample.getResourceString("PrintDialog"))) {
      PrintDialog dialog = new PrintDialog(shell, style);
      dialog.setText(ControlExample.getResourceString("Title"));
      PrinterData result = dialog.open();
      textWidget.append(ControlExample.getResourceString("PrintDialog") + Text.DELIMITER);
      textWidget.append(
          ControlExample.getResourceString("Result", new String[] {"" + result}) + Text.DELIMITER);
      textWidget.append("getScope() = " + dialog.getScope() + Text.DELIMITER);
      textWidget.append("getStartPage() = " + dialog.getStartPage() + Text.DELIMITER);
      textWidget.append("getEndPage() = " + dialog.getEndPage() + Text.DELIMITER);
      textWidget.append(
          "getPrintToFile() = " + dialog.getPrintToFile() + Text.DELIMITER + Text.DELIMITER);
      return;
    }

    if (name.equals(ControlExample.getResourceString("MessageBox"))) {
      MessageBox dialog = new MessageBox(shell, style);
      dialog.setMessage(ControlExample.getResourceString("Example_string"));
      dialog.setText(ControlExample.getResourceString("Title"));
      int result = dialog.open();
      textWidget.append(ControlExample.getResourceString("MessageBox") + Text.DELIMITER);
      /*
       * The resulting integer depends on the original
       * dialog style.  Decode the result and display it.
       */
      switch (result) {
        case SWT.OK:
          textWidget.append(ControlExample.getResourceString("Result", new String[] {"SWT.OK"}));
          break;
        case SWT.YES:
          textWidget.append(ControlExample.getResourceString("Result", new String[] {"SWT.YES"}));
          break;
        case SWT.NO:
          textWidget.append(ControlExample.getResourceString("Result", new String[] {"SWT.NO"}));
          break;
        case SWT.CANCEL:
          textWidget.append(
              ControlExample.getResourceString("Result", new String[] {"SWT.CANCEL"}));
          break;
        case SWT.ABORT:
          textWidget.append(ControlExample.getResourceString("Result", new String[] {"SWT.ABORT"}));
          break;
        case SWT.RETRY:
          textWidget.append(ControlExample.getResourceString("Result", new String[] {"SWT.RETRY"}));
          break;
        case SWT.IGNORE:
          textWidget.append(
              ControlExample.getResourceString("Result", new String[] {"SWT.IGNORE"}));
          break;
        default:
          textWidget.append(ControlExample.getResourceString("Result", new String[] {"" + result}));
          break;
      }
      textWidget.append(Text.DELIMITER + Text.DELIMITER);
    }
  }
  private void handleBrowse() {
    DirectoryDialog appDirDialog = new DirectoryDialog(this.getContainer().getShell());
    String newPath = appDirDialog.open();

    if (newPath != null) m_rhodesPathText.setText(newPath);
  }
 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();
 }
 /** @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);
 }