Пример #1
0
 public File showDirectoryDialog() {
   JFileChooser fc = new JFileChooser();
   fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
   fc.addChoosableFileFilter(new OpenFileFilter("", ""));
   fc.showDialog(null, "選擇目錄");
   return fc.getSelectedFile();
 }
Пример #2
0
 private void openConnArgMenuItemActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_openConnArgMenuItemActionPerformed
   JFileChooser fileChooser = new JFileChooser(".//resource//ml//data");
   fileChooser.showDialog(this, "Open Connective Argument Annotated Text");
   File file = fileChooser.getSelectedFile();
   System.out.println(file.getAbsolutePath());
   if (file != null) {
     markup = new ClauseArgMarkup();
     annotator = new SerialAnnotator();
     annotator.add(new GeniaTagger());
     annotator.add(new ClauseBoundaryAnnotator(false));
     annotator.add(new ClauseAnnotator());
     annotator.add(new DiscourseMarkerAnnotator(false));
     textReader =
         new GenericTextReader(
             "\n\n",
             "\n",
             "\t",
             new String[] {"word", "CONN", "ARG1S", "ARG1E", "ARG2S", "ARG2E"});
     // initTable(new String[]{"POS", "CHUNK", "DIS_CON",
     // "DIS_CON_SCP","DIS_CON_TYP","CLS_ANN","CLS_S#","CLS_E#","Arg"});
     initTable(new String[] {"POS", "CHUNK", "DIS_CON", "CLS_ANN", "CLS_S#", "CLS_E#"});
     loadFile(file);
   }
 } // GEN-LAST:event_openConnArgMenuItemActionPerformed
Пример #3
0
 private void choosePath(JTextField pathField) {
   File current = new File(pathField.getText()).getAbsoluteFile();
   fileChooser.setSelectedFile(current);
   if (fileChooser.showDialog(this, null) == JFileChooser.APPROVE_OPTION) {
     pathField.setText(fileChooser.getSelectedFile().getAbsolutePath());
   }
 }
  private void doParcourir() {
    JFileChooser fileChooser = new JFileChooser(".");
    fileChooser.setDialogTitle(Bundle.getText("BD_ImporterProcessus_parcourir"));
    fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    fileChooser.setAcceptAllFileFilterUsed(false);
    fileChooser.setFileFilter(new FiltreFichier("dpe", Bundle.getText("DPE")));
    int res = fileChooser.showDialog(this, Bundle.getText("Valider"));
    if (res == JFileChooser.APPROVE_OPTION) {
      // Vérification si le chemin contient le nom du fichier
      nomDuFichier = null;
      if (fileChooser.getSelectedFile().isFile()) {
        cImportation.addChemin(
            fileChooser
                .getSelectedFile()
                .getAbsolutePath()
                .substring(
                    0,
                    fileChooser.getSelectedFile().getAbsolutePath().lastIndexOf(File.separator)));
        LD_Chemin.setSelectedItem(
            fileChooser
                .getSelectedFile()
                .getAbsolutePath()
                .substring(
                    0,
                    fileChooser.getSelectedFile().getAbsolutePath().lastIndexOf(File.separator)));
        nomDuFichier = fileChooser.getSelectedFile().getName();
      } else {
        cImportation.addChemin(fileChooser.getSelectedFile().getAbsolutePath());
        LD_Chemin.setSelectedItem(fileChooser.getSelectedFile().getAbsolutePath());
      }
    }

    doRechercher();
  }
Пример #5
0
  /**
   * Gets called when the menu option export is called.
   *
   * @param e The action event.
   */
  public void actionPerformed(final ActionEvent e) {
    saveFile();
    if (getMenuView().hasLastFileLocation()) {
      if (!allGoalFilesExist()) {
        ScenarioEditor.getOptionPrompt()
            .showMessageDialog(null, "Warning: Some goal files are missing.");
      }
      File saveLocation = new File(getMenuView().getLastFileLocation());

      JFileChooser filechooser = getCurrentFileChooser();

      filechooser.setSelectedFile(new File(saveLocation.getName().split("\\.")[0]));
      filechooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
      filechooser.setAcceptAllFileFilterUsed(false);
      filechooser.setFileFilter(FileFilters.masFilter());

      if (filechooser.showDialog(getController().getMainView(), "Export MAS project")
          == JFileChooser.APPROVE_OPTION) {
        File xmlFile = filechooser.getSelectedFile();
        exportAsMASProject(xmlFile);
      }
    } else {
      ScenarioEditor.getOptionPrompt()
          .showMessageDialog(null, "Error: Can not export an unsaved scenario.");
    }
  }
Пример #6
0
  @Override
  public void performAction() {
    Scenario scenario = (Scenario) modello.getBean(Costanti.CURRENT_SCENARIO);
    MappingTask mappingTask = scenario.getMappingTask();

    JFileChooser chooser = vista.getFileChooserApriTXT();
    File file;
    continua = true;
    while (continua) {
      int returnVal =
          chooser.showDialog(
              WindowManager.getDefault().getMainWindow(),
              NbBundle.getMessage(Costanti.class, Costanti.EXPORT_TGDS));
      if (returnVal == JFileChooser.APPROVE_OPTION) {
        file = chooser.getSelectedFile();
        if (!file.exists()) {
          saveTGDs(mappingTask, file);
        } else {
          confirmSave(mappingTask, file);
        }
      } else {
        continua = false;
      }
    }
    /*    List<FORule> foRules = mappingTask.getMappingData().getSTTgds();
    for (FORule foRule : foRules) {
        System.out.println(foRule.toLogicalString(mappingTask));
    }*/
  }
Пример #7
0
  /**
   * Starts file chooser.
   *
   * @param dir whether it needs dir or file
   */
  protected void startFileChooser(
      final Widget paramWi, final String directory, final boolean dirOnly) {
    final Host host = getFirstConnectedHost();
    if (host == null) {
      Tools.appError("Connection to host lost.");
      return;
    }
    final VMSHardwareInfo thisClass = this;
    final JFileChooser fc =
        new JFileChooser(getLinuxDir(directory, host), getFileSystemView(host, directory)) {
          /** Serial version UID. */
          private static final long serialVersionUID = 1L;

          @Override
          public final void setCurrentDirectory(final File dir) {
            super.setCurrentDirectory(new LinuxFile(thisClass, host, dir.toString(), "d", 0, 0));
          }
        };
    fc.setBackground(ClusterBrowser.STATUS_BACKGROUND);
    fc.setDialogType(JFileChooser.CUSTOM_DIALOG);
    if (dirOnly) {
      fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    }
    fc.setDialogTitle(Tools.getString("VMSDiskInfo.FileChooserTitle") + host.getName());
    //        fc.setApproveButtonText(Tools.getString("VMSDiskInfo.Approve"));
    fc.setApproveButtonToolTipText(Tools.getString("VMSDiskInfo.Approve.ToolTip"));
    fc.putClientProperty("FileChooser.useShellFolder", Boolean.FALSE);
    final int ret =
        fc.showDialog(Tools.getGUIData().getMainFrame(), Tools.getString("VMSDiskInfo.Approve"));
    linuxFileCache.clear();
    if (ret == JFileChooser.APPROVE_OPTION && fc.getSelectedFile() != null) {
      final String name = fc.getSelectedFile().getAbsolutePath();
      paramWi.setValue(name);
    }
  }
Пример #8
0
  public ImageChooser() {
    // Set up the file chooser.
    if (fileChooser == null) {
      fileChooser = new JFileChooser();

      // Add a custom file filter and disable the default
      // (Accept All) file filter.
      fileChooser.addChoosableFileFilter(new ImageFilter());
      fileChooser.setAcceptAllFileFilterUsed(false);
      // Add the preview pane.
      fileChooser.setAccessory(new ImagePreview(fileChooser));
    }

    // Show it.
    int returnVal = fileChooser.showDialog(this, "Attach");

    image = null;
    // Process the results.
    if (returnVal == JFileChooser.APPROVE_OPTION) {
      File file = fileChooser.getSelectedFile();
      extension = file.getPath().substring(file.getPath().lastIndexOf(".") + 1);
      System.out.println(file.getPath());
      System.out.println(file.getAbsolutePath());
      try {
        image = ImageIO.read(file);
      } catch (IOException e) {
        System.out.println("Error loading image");
        e.printStackTrace();
      }
    } else {
      // user don't want nuthin
    }
    // Reset the file chooser for the next time it's shown.
    fileChooser.setSelectedFile(null);
  }
Пример #9
0
 /** Open a JFileChooser to select a directory to use. */
 private void chooseDirectory() {
   JFileChooser chooser = new JFileChooser(getCurrentPath().toFile());
   chooser.setAcceptAllFileFilterUsed(false);
   chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
   if (chooser.showDialog(parentComponent, "Select folder") == JFileChooser.APPROVE_OPTION) {
     setSettingValue(chooser.getSelectedFile().getPath());
   }
 }
 // called when the load script button is pressed.
 private void scriptPressed() {
   int returnVal = fileChooser.showDialog(this, "Load Script");
   if (returnVal == JFileChooser.APPROVE_OPTION) {
     notifyControllerListeners(
         ControllerEvent.SCRIPT_CHANGE, fileChooser.getSelectedFile().getAbsoluteFile());
     scriptComponent.setContents(fileChooser.getSelectedFile().getAbsolutePath());
   }
 }
 public void actionPerformed(ActionEvent e) {
   JFileChooser chooser = new JFileChooser();
   if (isDirectoriesOnly()) {
     chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
   }
   if (chooser.showDialog(parent, "Select") == JFileChooser.APPROVE_OPTION) {
     location.setText(chooser.getSelectedFile().getAbsolutePath());
   }
 }
Пример #12
0
 /** Opens a dialogue and prompts the user to select a game to load. */
 private void loadGame() {
   final int returnVal = fileChooser.showDialog(this, "Load");
   if (returnVal == JFileChooser.APPROVE_OPTION) {
     final File file = fileChooser.getSelectedFile();
     if (fileChooser.accept(file)) {
       IO.loadTiles(game.getBoard(), file);
     }
   }
 }
Пример #13
0
  public static String getLoadFileName(Frame frame) {

    if (applet != null) {

      showAppletWarning(frame);

      return null;
    }

    String extension = RiskFileFilter.RISK_SAVE_FILES;

    if (webstart != null) {

      try {

        javax.jnlp.FileOpenService fos =
            (javax.jnlp.FileOpenService)
                javax.jnlp.ServiceManager.lookup("javax.jnlp.FileOpenService");

        javax.jnlp.FileContents fc = fos.openFileDialog(SAVES_DIR, new String[] {extension});

        if (fc != null) {

          fileio.put(fc.getName(), fc);

          return fc.getName();
        } else {

          return null;
        }
      } catch (Exception e) {

        return null;
      }
    } else {

      File dir = getSaveGameDir();
      JFileChooser fc = new JFileChooser(dir);

      fc.setFileFilter(new RiskFileFilter(extension));

      int returnVal =
          fc.showDialog(
              frame, TranslationBundle.getBundle().getString("mainmenu.loadgame.loadbutton"));
      if (returnVal == javax.swing.JFileChooser.APPROVE_OPTION) {

        java.io.File file = fc.getSelectedFile();
        // Write your code here what to do with selected file
        return file.getAbsolutePath();

      } else {
        // Write your code here what to do if user has canceled Open dialog
        return null;
      }
    }
  }
Пример #14
0
 private File openFile(String title) {
   JFileChooser chooser = new JFileChooser();
   FileNameExtensionFilter filter =
       new FileNameExtensionFilter("Images (*.jpg, *.png, *.gif)", "jpg", "png", "gif");
   chooser.setFileFilter(filter);
   chooser.setCurrentDirectory(openPath);
   int ret = chooser.showDialog(this, title);
   if (ret == JFileChooser.APPROVE_OPTION) return chooser.getSelectedFile();
   return null;
 }
 private File askPictureFile() {
   JFileChooser fileChooser = new JFileChooser();
   FileNameExtensionFilter filter =
       new FileNameExtensionFilter(
           "Image Files", "jpg", "jpeg", "gif", "png", "JPG", "JPEG", "GIF", "PNG");
   fileChooser.setFileFilter(filter);
   fileChooser.showDialog(mainPanel, "OK");
   fileChooser.setVisible(true);
   return fileChooser.getSelectedFile();
 }
Пример #16
0
 @Override
 public void actionPerformed(ActionEvent e) {
   final JFileChooser fc = new JFileChooser(lastDirectory);
   final FileFilter filter = new JavaFileFilter();
   fc.setFileFilter(filter);
   final Component parent = SwingUtilities.getRoot(ParseTreeInfoPanel.this);
   fc.showDialog(parent, "Open");
   final File file = fc.getSelectedFile();
   openFile(file, parent);
 }
Пример #17
0
  public void actionPerformed(ActionEvent arg0) {
    String action = arg0.getActionCommand();

    if (action.equalsIgnoreCase(btnCustomDir.getText())) {
      flchCustomDir.setVisible(true);
      int status = flchCustomDir.showDialog(configPanel, "Accept");
      if (status == JFileChooser.APPROVE_OPTION) {
        lblCustomOutDir.setText(flchCustomDir.getSelectedFile().getPath());
      }
    }
  }
 private void browseButtonActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_browseButtonActionPerformed
   JFileChooser chooser = new JFileChooser();
   chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
   int option = chooser.showDialog(this, "Select Directory");
   if (option == JFileChooser.APPROVE_OPTION) {
     if ((chooser.getSelectedFile()).exists()) {
       filePathTextField.setText(chooser.getSelectedFile().getAbsolutePath());
     }
   }
 } // GEN-LAST:event_browseButtonActionPerformed
Пример #19
0
  @Action(block = Task.BlockingScope.APPLICATION)
  public Task add() throws IOException {
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setMultiSelectionEnabled(true);

    if (fileChooser.showDialog(this, i18n.text(WorkspaceResources.create_attachment))
        == JFileChooser.APPROVE_OPTION) {
      final File[] selectedFiles = fileChooser.getSelectedFiles();

      return new AddAttachmentTask(selectedFiles);
    } else return null;
  }
Пример #20
0
  /**
   * Save the current project settings. Asks the user for a project file name.
   *
   * @param usename Use the last name as default?
   */
  protected void saveProjectAs() {
    if (filechooser.showDialog(this, "Save Project As") == JFileChooser.APPROVE_OPTION) {
      final File f = filechooser.getSelectedFile();

      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              File file = f;
              if (file != null) {
                if (file.exists()) {
                  String msg =
                      SUtil.wrapText(
                          "The file: "
                              + file.getAbsolutePath()
                              + " exists.\n"
                              + " Do you want to overwrite the file?");
                  int o =
                      JOptionPane.showConfirmDialog(
                          ControlCenterWindow.this,
                          msg,
                          "Overwrite Warning",
                          JOptionPane.YES_NO_OPTION,
                          JOptionPane.WARNING_MESSAGE);

                  if (JOptionPane.NO_OPTION == o) return;
                } else if (!file.getName()
                    .toLowerCase()
                    .endsWith(ControlCenter.JCCPROJECT_EXTENSION)) {
                  file = new File(file.getAbsolutePath() + ControlCenter.JCCPROJECT_EXTENSION);
                  filechooser.setSelectedFile(file);
                }
                try {
                  file.createNewFile();
                } catch (IOException e) {
                }

                if (file.canWrite()) {
                  controlcenter.setCurrentProject(file);
                  controlcenter.saveProject();
                } else {
                  JOptionPane.showMessageDialog(
                      ControlCenterWindow.this,
                      "Cannot save project here. The project file: \n"
                          + file.getAbsolutePath()
                          + "\n cannot be written",
                      "New Project Error",
                      JOptionPane.ERROR_MESSAGE);
                }
              }
            }
          });
    }
  }
Пример #21
0
  /**
   * Display a file chooser dialog box.
   *
   * @param owner <code>Component</code> which 'owns' the dialog
   * @param mode Can be either <code>OPEN</code>, <code>SCRIPT</code> or <code>SAVE</code>
   * @return The path to selected file, null otherwise
   */
  public static String chooseFile(Component owner, int mode) {
    JFileChooser chooser = getFileChooser(owner, mode);
    chooser.setMultiSelectionEnabled(false);

    if (chooser.showDialog(owner, null) == JFileChooser.APPROVE_OPTION) {
      /*Jext*/ AbstractEditorPanel.setProperty(
          "lastdir." + mode, chooser.getSelectedFile().getParent());
      return chooser.getSelectedFile().getAbsolutePath();
    } else owner.repaint();

    return null;
  }
  /** Shows */
  private static File showOpenDialog(Component parent, String title, File basedir) {
    JFileChooser jfc = new JFileChooser();
    File fx;
    if (basedir != null && basedir.exists()) {
      fx = basedir;
    } else {
      fx = new File(ConfigFetch.getConfigFile());
      fx = new File(fx.getParentFile(), "checklists");
      if (!fx.exists()) {
        fx = new File(ConfigFetch.resolvePath("."));
        if (!fx.exists()) {
          fx = new File(".");
        }
      }
    }
    jfc.setCurrentDirectory(fx);
    jfc.setAccessory(new ChecklistPreview(jfc));
    jfc.setFileView(new NeptusFileView());
    jfc.setFileFilter(
        new FileFilter() {
          public boolean accept(File f) {
            if (f.isDirectory()) {
              return true;
            }

            String extension = FileUtil.getFileExtension(f);
            if (extension != null) {
              if (FileUtil.FILE_TYPE_CHECKLIST.equalsIgnoreCase(extension)
                  || FileUtil.FILE_TYPE_XML.equalsIgnoreCase(extension)) {
                // return ChecklistType.validate(f);
                return true;
              } else {
                return false;
              }
            }
            return false;
          }

          public String getDescription() {
            return I18n.text("Checklist files")
                + " ('"
                + FileUtil.FILE_TYPE_CHECKLIST
                + "', '"
                + FileUtil.FILE_TYPE_XML
                + "')";
          }
        });

    int result = jfc.showDialog((parent == null) ? new JFrame() : parent, title);
    if (result == JFileChooser.CANCEL_OPTION) return null;
    return jfc.getSelectedFile();
  }
Пример #23
0
    public void actionPerformed(ActionEvent e) {
      JFileChooser fileopen = new JFileChooser();
      FileFilter filter = new FileNameExtensionFilter("c files", "c");
      fileopen.addChoosableFileFilter(filter);

      int ret = fileopen.showDialog(null, "Open file");

      if (ret == JFileChooser.APPROVE_OPTION) {
        File file = fileopen.getSelectedFile();
        System.out.println(file);
        textfieldPoleTekstowe.setText("" + file);
      }
    }
Пример #24
0
    @Override
    public void actionPerformed(ActionEvent e) {
      JFileChooser file_chooser = new JFileChooser();
      int choose = file_chooser.showDialog(null, "apri");

      if (choose == JFileChooser.APPROVE_OPTION) {
        File file = file_chooser.getSelectedFile();

        if (isFile_selected()) control.addFileChoice(file.getAbsolutePath());
        else if (isImg_selected()) control.addImageChoice(file.getAbsolutePath());
        // updateList();
      }
    }
Пример #25
0
  private File chooseCsrFile() {
    JFileChooser chooser = FileChooserFactory.getCsrFileChooser();
    chooser.setCurrentDirectory(CurrentDirectory.get());
    chooser.setDialogTitle(res.getString("SignCsrAction.ChooseCsr.Title"));
    chooser.setMultiSelectionEnabled(false);

    int rtnValue = chooser.showDialog(frame, res.getString("SignCsrAction.ChooseCsr.button"));
    if (rtnValue == JFileChooser.APPROVE_OPTION) {
      File importFile = chooser.getSelectedFile();
      CurrentDirectory.updateForFile(importFile);
      return importFile;
    }
    return null;
  }
Пример #26
0
  public File showOpenImageDialog() {
    JFileChooser jfc = new JFileChooser();
    File fx;
    if (openedFile != null && openedFile.exists()) {
      fx = openedFile;
    } else {
      fx = new File(ConfigFetch.getConfigFile());
      if (!fx.exists()) {
        fx = new File(ConfigFetch.resolvePath("."));
        if (!fx.exists()) {
          fx = new File(".");
        }
      }
    }
    jfc.setCurrentDirectory(fx);
    // jfc.setCurrentDirectory(new File(ConfigFetch.getConfigFile()));
    jfc.setFileView(new NeptusFileView());
    // jfc.setAccessory(new MissionPreview(jfc));
    jfc.setFileFilter(
        new FileFilter() {

          public boolean accept(File f) {
            if (f.isDirectory()) {
              return true;
            }

            String extension = FileUtil.getFileExtension(f).toLowerCase();
            if (extension != null) {
              if (extension.equals("j3d")
                  || extension.equals("3ds")
                  || extension.equals("x3d")
                  || extension.equals("wrl")) {
                return true;
              } else {
                return false;
              }
            }

            return false;
          }

          public String getDescription() {
            return "3D model files ('j3d', '3ds', 'x3d', 'wrl')";
          }
        });

    int result = jfc.showDialog(Viewer3D.this, "Open 3D File");
    if (result == JFileChooser.CANCEL_OPTION) return null;
    return jfc.getSelectedFile();
  }
Пример #27
0
  /** Lets the user select a file using a file chooser dialog. */
  private void handleSelectFileWithDialog() {
    JFileChooser chooser = new JFileChooser(fileModel.getFile());
    FileFilter fileFilter = fileModel.getFileFilter();
    if (fileFilter != null) {
      chooser.setFileFilter(fileFilter);
    }

    TextResource tr = Factory.getInstance(TextResource.class);
    String buttonText = tr.getString(fileModel.getButtonId());
    int returnVal = chooser.showDialog(getTopLevelAncestor(), buttonText);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
      fileModel.setFile(chooser.getSelectedFile(), null);
    }
  }
Пример #28
0
  // Stategy 1 : use a JFileChooser
  private static File selectDirectory1(
      Component parent, String defaultDirectory, String title, String approve) {
    JFileChooser chooser = new JFileChooser(defaultDirectory);
    File chosenDirectory = null;
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setMultiSelectionEnabled(false);
    int result = chooser.showDialog(parent, title);

    if (result == JFileChooser.APPROVE_OPTION) {
      chosenDirectory = chooser.getSelectedFile();
    }

    return chosenDirectory;
  } // end selectOutputDirectory1()
Пример #29
0
 private void openAnnMenuItemActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_openAnnMenuItemActionPerformed
   JFileChooser fileChooser = new JFileChooser(".//resource//ml//data");
   fileChooser.showDialog(this, "Open Annotated Text");
   File file = fileChooser.getSelectedFile();
   System.out.println(file.getAbsolutePath());
   if (file != null) {
     markup = new ClauseMarkup();
     annotator = new SerialAnnotator();
     textReader = new CONLL01TextReader(true);
     initTable(new String[] {"POS", "CHUNK", "CLS_BN_S", "CLS_BN_E"});
     loadFile(file);
   }
 } // GEN-LAST:event_openAnnMenuItemActionPerformed
  private void chooseFileFor(JButton chooserBtn) {
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.showDialog(this, "Choose a file");
    File file = fileChooser.getSelectedFile();

    if (chooserBtn == btnInput) {
      inputFile = file;
    } else {
      outputFile = file;
    }
    if (file != null) {
      chooserBtn.setText(file.getAbsolutePath());
    }
  }