Ejemplo n.º 1
0
  public ConverterView(ConverterModel model) {
    //        this.model = model;

    this.fileChooser = new JFileChooser();
    this.fileChooser.setFileFilter(new ConverterFileFilter());
    this.fileChooser.setMultiSelectionEnabled(true);

    setTitle(getGuiString(model.getName()));

    this.addButton = new JButton(getGuiString("buttons.change"));
    this.addButton.addActionListener(
        e -> {
          if (this.changeActionListener != null) {
            Action details = fileChooser.getActionMap().get("viewTypeDetails");
            details.actionPerformed(null);
            if (FilePath.getFilePath(this.getTitle()) != null) {
              File file = new File(FilePath.getFilePath(this.getTitle()).getPath());
              fileChooser.setCurrentDirectory(file);
            }
            int ret = fileChooser.showDialog(null, getGuiString("buttons.openFile"));
            if (ret == JFileChooser.APPROVE_OPTION) {
              File[] files = fileChooser.getSelectedFiles();
              FilePath.setFilePath(this.getTitle(), fileChooser.getCurrentDirectory().getPath());
              this.changeActionListener.actionPerformed(files);
            }
          }
          hide();
        });
    this.cancelButton = new JButton(getGuiString("buttons.cancel"));
    this.cancelButton.addActionListener(
        e -> {
          hide();
        });

    buildLayout();
    show();
  }