Package org.aavso.tools.vstar.ui.dialog

Examples of org.aavso.tools.vstar.ui.dialog.AdditiveLoadFileOrUrlChooser


   *
   * @return The file chooser or null if no file was selected.
   */
  public static AdditiveLoadFileOrUrlChooser chooseFileForReading(
      String id, List<String> additionalFileExtensions, boolean allowURL) {
    AdditiveLoadFileOrUrlChooser fileChooser = null;

    if (id != null) {
      if (!fileChoosers.containsKey(id)) {
        fileChoosers.put(id, new AdditiveLoadFileOrUrlChooser(allowURL));

        if (additionalFileExtensions != null) {
          List<String> newFileExtensions = new ArrayList<String>();
          newFileExtensions.addAll(additionalFileExtensions);
          newFileExtensions.addAll(fileChoosers.get(id)
              .getDefaultFileExtensions());
          fileChoosers.get(id).setFileExtensions(newFileExtensions);
        }
      }
      fileChooser = fileChoosers.get(id);
      fileChooser.reset();
    } else {
      fileChooser = new AdditiveLoadFileOrUrlChooser(allowURL);
    }

    // Was a file chosen or a URL string accepted?
    boolean approved = fileChooser.showDialog(Mediator.getUI()
        .getComponent()) || fileChooser.isUrlProvided();

    return approved ? fileChooser : null;
  }
View Full Code Here


          fileNames = fileNames.substring(0, fileNames
              .lastIndexOf(", "));
          obSourcePlugin.setInputInfo(streams, fileNames);
        } else {
          // Request a file or URL from the user.
          AdditiveLoadFileOrUrlChooser fileChooser = PluginComponentFactory
              .chooseFileForReading(
                  obSourcePlugin.getDisplayName(),
                  obSourcePlugin
                      .getAdditionalFileExtensions(),
                  obSourcePlugin.getInputType() == InputType.FILE_OR_URL);
          if (fileChooser != null) {
            // If a file was chosen or a URL obtained, use as input.
            obSourcePlugin
                .setAdditive(fileChooser.isLoadAdditive());

            if (fileChooser.isUrlProvided()) {
              String urlStr = fileChooser.getUrlString();
              URL url = new URL(urlStr);
              streams.add(url.openStream());
              obSourcePlugin.setInputInfo(streams, urlStr);
            } else {
              File file = fileChooser.getSelectedFile();
              streams.add(new FileInputStream(file));
              obSourcePlugin
                  .setInputInfo(streams, file.getName());
            }
          } else {
View Full Code Here

    super();

    this.parent = parent;
    this.uiType = uiType;

    this.fileOpenDialog = new AdditiveLoadFileOrUrlChooser(false);

    createFileMenu();
    createEditMenu();
    createViewMenu();
    createAnalysisMenu();
View Full Code Here

   *
   * The action is to open a file dialog to allow the user to select a single
   * file.
   */
  public ActionListener createNewStarFromFileListener() {
    final AdditiveLoadFileOrUrlChooser fileOpenDialog = this.fileOpenDialog;
    fileOpenDialog.reset();

    final IMainUI parent = this.parent;

    return new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        boolean approved = fileOpenDialog.showDialog(parent
            .getComponent());

        if (approved) {
          File f = fileOpenDialog.getSelectedFile();

          try {
            mediator.createObservationArtefactsFromFile(f,
                fileOpenDialog.isLoadAdditive());
          } catch (Exception ex) {
            MessageBox.showErrorDialog(parent.getComponent(),
                NEW_STAR_FROM_FILE, ex);
          }
        }
View Full Code Here

TOP

Related Classes of org.aavso.tools.vstar.ui.dialog.AdditiveLoadFileOrUrlChooser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.