// $$ modif from Oury
  private static JFileChooser getFileChooser(Component owner, int mode) {
    JFileChooser chooser = null;
    String last = /*Jext*/ AbstractEditorPanel.getProperty("lastdir." + mode);
    if (last == null) last = /*Jext*/ AbstractEditorPanel.getHomeDirectory();

    if (owner instanceof AbstractEditorPanel) {
      chooser = ((/*Jext*/ AbstractEditorPanel) owner).getFileChooser(mode);
      if (
      /*Jext*/ AbstractEditorPanel.getBooleanProperty("editor.dirDefaultDialog")
          && mode != SCRIPT) {
        String file =
            ((AbstractEditorPanel) owner)
                // $$ from Seb [[
                // .getTextArea()
                // $$ from Seb ]]
                .getCurrentFile();
        if (file != null) chooser.setCurrentDirectory(new File(file));
      } else chooser.setCurrentDirectory(new File(last));
    } else {
      chooser = new JFileChooser(last);
      if (mode == SAVE) chooser.setDialogType(JFileChooser.SAVE_DIALOG);
      else chooser.setDialogType(JFileChooser.OPEN_DIALOG);
    }

    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooser.setFileHidingEnabled(true);

    return chooser;
  }
 public File showDirOpenDialog(Component parent, File defaultDir) {
   if (Platform.isMacOS()) {
     System.setProperty("apple.awt.fileDialogForDirectories", "true");
     FileDialog dialog = null;
     if (parent instanceof JFrame == false && parent instanceof JDialog == false) {
       parent = ((JComponent) parent).getTopLevelAncestor();
     }
     if (parent instanceof JFrame) dialog = new FileDialog((JFrame) parent);
     else dialog = new FileDialog((JDialog) parent);
     if (defaultDir != null) dialog.setDirectory(defaultDir.getAbsolutePath());
     dialog.setVisible(true);
     if (dialog.getDirectory() == null || dialog.getFile() == null) return null;
     File file = new File(dialog.getDirectory(), dialog.getFile());
     System.setProperty("apple.awt.fileDialogForDirectories", "false");
     return file;
   } else {
     JFileChooser chooser = new JFileChooser();
     if (defaultDir != null) chooser.setCurrentDirectory(defaultDir);
     chooser.setDialogType(JFileChooser.OPEN_DIALOG);
     chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
     chooser.showOpenDialog(parent);
     File file = chooser.getSelectedFile();
     return file;
   }
 }
Example #3
0
 public void handleSave() {
     JFileChooser fc = new JFileChooser(System.getProperty("user.dir") + System.getProperty("file.separator") + "saves");
     fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
     fc.setDialogTitle(_("Save game"));
     fc.setDialogType(JFileChooser.SAVE_DIALOG);
     fc.setFileFilter(new SavegameFileFilter());
     fc.setLocale(getLocale());
     int returnVal = fc.showSaveDialog(this);
     if (returnVal == JFileChooser.APPROVE_OPTION) {
         File file = fc.getSelectedFile();
         if (file != null) {
             if (!file.getName().endsWith(".jcz")) {
                 file = new File(file.getAbsolutePath() + ".jcz");
             }
             try {
                 Snapshot snapshot = new Snapshot(game, getClientId());
                 DebugConfig debugConfig = getConfig().getDebug();
                 if (debugConfig != null && "plain".equals(debugConfig.getSave_format())) {
                     snapshot.setGzipOutput(false);
                 }
                 snapshot.save(file);
             } catch (Exception ex) {
                 logger.error(ex.getMessage(), ex);
                 JOptionPane.showMessageDialog(this, ex.getLocalizedMessage(), _("Error"), JOptionPane.ERROR_MESSAGE);
             }
         }
     }
 }
Example #4
0
  void exportToExcel(JasperPrint jasperPrint) throws Exception {
    javax.swing.JFileChooser jfc = new javax.swing.JFileChooser("reportsample/");

    jfc.setDialogTitle("Send Report to Excel");
    jfc.setFileFilter(
        new javax.swing.filechooser.FileFilter() {
          public boolean accept(java.io.File file) {
            String filename = file.getName();
            return (filename.toLowerCase().endsWith(".xls")
                || file.isDirectory()
                || filename.toLowerCase().endsWith(".jrxml"));
          }

          public String getDescription() {
            return "Laporan *.xls";
          }
        });

    jfc.setMultiSelectionEnabled(false);

    jfc.setDialogType(javax.swing.JFileChooser.SAVE_DIALOG);
    if (jfc.showSaveDialog(null) == javax.swing.JOptionPane.OK_OPTION) {

      JExcelApiExporter exporter = new JExcelApiExporter();
      exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
      exporter.setParameter(
          JRExporterParameter.OUTPUT_FILE_NAME,
          changeFileExtension(jfc.getSelectedFile().getPath(), "xls"));
      exporter.setParameter(JExcelApiExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.TRUE);
      exporter.setParameter(JExcelApiExporterParameter.IS_FONT_SIZE_FIX_ENABLED, Boolean.TRUE);
      exporter.exportReport();
    }
  }
Example #5
0
 public void handleLoad() {
     JFileChooser fc = new JFileChooser(System.getProperty("user.dir") + System.getProperty("file.separator") + "saves");
     fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
     fc.setDialogTitle(_("Load game"));
     fc.setDialogType(JFileChooser.OPEN_DIALOG);
     fc.setFileFilter(new SavegameFileFilter());
     fc.setLocale(getLocale());
     int returnVal = fc.showOpenDialog(this);
     if (returnVal == JFileChooser.APPROVE_OPTION) {
         File file = fc.getSelectedFile();
         if (file != null) {
             if (!closeGame()) return;
             try {
                 localServer = new Server(new Snapshot(file));
                 localServer.start(config.getPort());
                 connect(InetAddress.getLocalHost(), config.getPort());
             } catch (SnapshotVersionException ex1) {
                 //do not create error.log
                 JOptionPane.showMessageDialog(this, ex1.getLocalizedMessage(), _("Error"), JOptionPane.ERROR_MESSAGE);
             } catch (Exception ex) {
                 logger.error(ex.getMessage(), ex);
                 JOptionPane.showMessageDialog(this, ex.getLocalizedMessage(), _("Error"), JOptionPane.ERROR_MESSAGE);
             }
         }
     }
 }
Example #6
0
 public JFileChooser getFileChooserSalvaXmlXsd() {
   fileChooser.resetChoosableFileFilters();
   fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
   fileChooser.setFileFilter(new FileNameExtensionFilter("XML, XSD ", "xml", "xsd"));
   fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
   return fileChooser;
 }
Example #7
0
  /** Descripción de Método */
  private void loadFile() {
    log.info("");

    JFileChooser chooser = new JFileChooser();

    chooser.setDialogType(JFileChooser.OPEN_DIALOG);
    chooser.setDialogTitle(Msg.getMsg(Env.getCtx(), "AttachmentNew"));

    int returnVal = chooser.showOpenDialog(this);

    if (returnVal != JFileChooser.APPROVE_OPTION) {
      return;
    }

    //

    String fileName = chooser.getSelectedFile().getName();

    log.config(fileName);

    File file = chooser.getSelectedFile();

    if (m_attachment.addEntry(file)) {
      cbContent.addItem(fileName);
      cbContent.setSelectedIndex(cbContent.getItemCount() - 1);
      m_change = true;
    }
  } // getFileName
 private void setupFileChooser() {
   fileChooser = new JFileChooser();
   fileChooser.setDialogTitle("Select directory to output ISArchive to...");
   fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
   fileChooser.setApproveButtonText("Output to selected directory");
   fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
 }
Example #9
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);
    }
  }
Example #10
0
  public File chooseFile() {
    final JFileChooser chooser = new JFileChooser("Choose file");
    chooser.setDialogType(JFileChooser.OPEN_DIALOG);
    chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);

    chooser.setFileFilter(getFileFilter());

    path = Preference.pref.get(preferenceKey, path);
    chooser.setCurrentDirectory(new File(path));
    chooser.addPropertyChangeListener(
        new PropertyChangeListener() {
          @Override
          public void propertyChange(PropertyChangeEvent e) {
            if (e.getPropertyName().equals(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY)
                || e.getPropertyName().equals(JFileChooser.DIRECTORY_CHANGED_PROPERTY)) {
              e.getNewValue();
            }
          }
        });

    chooser.setVisible(true);

    if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
      path = chooser.getSelectedFile().getParent();
      Preference.pref.put(preferenceKey, path);
      return chooser.getSelectedFile();
    } else {
      return null;
    }
  }
Example #11
0
  /** Handles the saving of a drawing to a file. */
  private void doSave() {
    JFileChooser chooser = new JFileChooser(getClass().getResource("").getFile());
    chooser.setDialogTitle("Save Graphic");
    chooser.setDialogType(JFileChooser.SAVE_DIALOG);
    FileFilter filter =
        new FileFilter() {
          @Override
          public String getDescription() {
            return "JDraw Graphic (*.draw)";
          }

          @Override
          public boolean accept(File f) {
            return f.getName().endsWith(".draw");
          }
        };
    chooser.setFileFilter(filter);
    int res = chooser.showOpenDialog(this);

    if (res == JFileChooser.APPROVE_OPTION) {
      // save graphic
      File file = chooser.getSelectedFile();
      if (chooser.getFileFilter() == filter && !filter.accept(file)) {
        file = new File(chooser.getCurrentDirectory(), file.getName() + ".draw");
      }
      System.out.println("save current graphic to file " + file.getName());
    }
  }
Example #12
0
  public LoaderCustomizer() {
    /*    m_fileEditor.addPropertyChangeListener(new PropertyChangeListener() {
    public void propertyChange(PropertyChangeEvent e) {
      if (m_dsLoader != null) {
        m_dsLoader.setDataSetFile((File)m_fileEditor.getValue());
      }
    }
    }); */

    try {
      /*      m_LoaderEditor.setClassType(weka.core.converters.Loader.class);
      m_LoaderEditor.setValue(new weka.core.converters.ArffLoader()); */
      m_LoaderEditor.addPropertyChangeListener(
          new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent e) {
              repaint();
              if (m_dsLoader != null) {
                System.err.println("Property change!!");
                m_dsLoader.setLoader(m_dsLoader.getLoader());
              }
            }
          });
      repaint();
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    setLayout(new BorderLayout());
    //    add(m_fileEditor.getCustomEditor(), BorderLayout.CENTER);
    //    add(m_LoaderEditor, BorderLayout.CENTER);
    m_fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
    m_fileChooser.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (e.getActionCommand().equals(JFileChooser.APPROVE_SELECTION)) {
              try {
                File selectedFile = m_fileChooser.getSelectedFile();
                /*              EnvironmentField ef = m_environmentFields.get(0);
                ef.setText(selectedFile.toString()); */
                m_fileText.setText(selectedFile.toString());

                /*	      ((FileSourcedConverter)m_dsLoader.getLoader()).
                setFile(selectedFile);
                     // tell the loader that a new file has been selected so
                     // that it can attempt to load the header
                     //m_dsLoader.setLoader(m_dsLoader.getLoader());
                     m_dsLoader.newFileSelected(); */
              } catch (Exception ex) {
                ex.printStackTrace();
              }
            }
            // closing
            if (m_fileChooserFrame != null) {
              // m_parentFrame.dispose();
              m_fileChooserFrame.dispose();
            }
          }
        });
  }
Example #13
0
  /**
   * Displays a custom file chooser sheet with a custom approve button.
   *
   * @param chooser the chooser
   * @param parent the parent component of the dialog; can be {@code null}
   * @param approveButtonText the text of the {@code ApproveButton}
   * @param listener The listener for SheetEvents.
   */
  public static void showSheet(
      final JFileChooser chooser,
      Component parent,
      String approveButtonText,
      SheetListener listener) {
    if (approveButtonText != null) {
      chooser.setApproveButtonText(approveButtonText);
      chooser.setDialogType(JFileChooser.CUSTOM_DIALOG);
    }

    // Begin Create Dialog
    Frame frame =
        parent instanceof Frame
            ? (Frame) parent
            : (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent);

    String title = chooser.getUI().getDialogTitle(chooser);
    chooser.getAccessibleContext().setAccessibleDescription(title);

    final JSheet sheet = new JSheet(frame);
    sheet.addSheetListener(listener);

    Container contentPane = sheet.getContentPane();
    contentPane.setLayout(new BorderLayout());
    contentPane.add(chooser, BorderLayout.CENTER);
    // End Create Dialog

    final ActionListener actionListener =
        new ActionListener() {

          public void actionPerformed(ActionEvent evt) {
            int option;
            if (evt.getActionCommand().equals("ApproveSelection")) {
              option = JFileChooser.APPROVE_OPTION;
            } else {
              option = JFileChooser.CANCEL_OPTION;
            }
            sheet.hide();
            sheet.fireOptionSelected(chooser, option);
            chooser.removeActionListener(this);
          }
        };
    chooser.addActionListener(actionListener);
    sheet.addWindowListener(
        new WindowAdapter() {

          @Override
          public void windowClosing(WindowEvent e) {
            sheet.fireOptionSelected(chooser, JFileChooser.CANCEL_OPTION);
            chooser.removeActionListener(actionListener);
          }
        });
    chooser.rescanCurrentDirectory();
    sheet.pack();
    sheet.show();
    sheet.toFront();
  }
Example #14
0
 private void jMenuItem2ActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jMenuItem2ActionPerformed
   JFileChooser chooser = new JFileChooser(txtCHEMIN);
   chooser.setDialogType(JFileChooser.SAVE_DIALOG);
   chooser.showOpenDialog(this);
   if (chooser.getSelectedFile() != null) {
     pc.sauvegarderModele(chooser.getSelectedFile());
   }
 } // GEN-LAST:event_jMenuItem2ActionPerformed
 private void showChooseJobDir() {
   _filechooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
   _filechooser.setDialogType(JFileChooser.OPEN_DIALOG);
   _filechooser.showOpenDialog(this);
   if (_filechooser.getSelectedFile() != null) {
     _filechooser.setCurrentDirectory(_filechooser.getSelectedFile());
     String selected_file = _filechooser.getSelectedFile().getAbsolutePath();
     _jobfolder_textfield.setText(selected_file);
     _parameters.put(_jobfolder, selected_file);
   }
 }
Example #16
0
 private void jMenuItem1ActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jMenuItem1ActionPerformed
   JFileChooser chooser = new JFileChooser(txtCHEMIN);
   chooser.setDialogType(JFileChooser.OPEN_DIALOG);
   chooser.showOpenDialog(this);
   if (chooser.getSelectedFile() != null) {
     pc.chargerModele(chooser.getSelectedFile());
     pc.modeleModifie();
     controlsEditor1.setText(pc.modeleTXT());
   }
 } // GEN-LAST:event_jMenuItem1ActionPerformed
 private void showChooseAlignmentFile() {
   _filechooser.setDialogType(JFileChooser.OPEN_DIALOG);
   _filechooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
   _filechooser.showOpenDialog(this);
   if (_filechooser.getSelectedFile() != null) {
     _filechooser.setCurrentDirectory(_filechooser.getSelectedFile());
     String selected_file = _filechooser.getSelectedFile().getAbsolutePath();
     _alignment_textfield.setText(selected_file);
     _parameters.put(_alignmentfile, selected_file);
   }
 }
 /** メニュー->保存 マップを保存する */
 public void saveMap() {
   fileChooser.addChoosableFileFilter(new MapFileFilter()); // ファイルフィルタ
   fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
   fileChooser.setDialogTitle("マップを保存する");
   int ret = fileChooser.showSaveDialog(null);
   File mapFile;
   if (ret == JFileChooser.APPROVE_OPTION) {
     // もし保存ボタンが押されたらそのマップファイルをセーブする
     mapFile = fileChooser.getSelectedFile();
     mainPanel.saveMap(mapFile);
   }
 }
  private JFileChooser getFileChooser() {
    if (fileChooser == null) {
      JFileChooser chooser = new JFileChooser();
      chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
      chooser.setMultiSelectionEnabled(false);
      chooser.setDialogType(JFileChooser.OPEN_DIALOG);
      chooser.setDialogTitle(Bundle.SnapshotCustomizer_SelectSnapshotDialogCaption());
      fileChooser = chooser;
    }

    return fileChooser;
  }
Example #20
0
 public PathwayChooser(
     String taskName, int dialogType, Preference dirPreference, Set<? extends PathwayIO> set) {
   fileDialog = new FileDialog(new Frame(), taskName + " pathway", dialogType);
   fileDialog.setDirectory(
       PreferenceManager.getCurrent().getFile(dirPreference).getAbsolutePath());
   jfc = new JFileChooser();
   this.taskName = taskName;
   this.dirPreference = dirPreference;
   createFileFilters(set);
   jfc.setDialogTitle(taskName + " pathway");
   jfc.setDialogType(dialogType);
   jfc.setCurrentDirectory(PreferenceManager.getCurrent().getFile(dirPreference));
 }
 /** メニュー->開く マップを開く */
 public void openMap() {
   fileChooser.addChoosableFileFilter(new MapFileFilter()); // ファイルフィルタ
   fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
   fileChooser.setDialogTitle("マップを開く");
   int ret = fileChooser.showOpenDialog(null);
   File mapFile;
   if (ret == JFileChooser.APPROVE_OPTION) {
     // もし開くボタンが押されたらそのマップファイルをロードする
     mapFile = fileChooser.getSelectedFile();
     mainPanel.loadMap(mapFile);
     // パネルが大きくなったらスクロールバーを表示する
     scrollPane.getViewport().revalidate();
     scrollPane.getViewport().repaint();
   }
 }
  private void openRecordPathFileChooser() {
    JFileChooser fc = new JFileChooser();
    fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    fc.setDialogType(JFileChooser.SAVE_DIALOG);

    fc.setApproveButtonText(ControlMain.getProperty("msg_choose"));
    fc.setApproveButtonToolTipText(ControlMain.getProperty("msg_chooseDirectory"));
    int returnVal = fc.showSaveDialog(null);

    if (returnVal == JFileChooser.APPROVE_OPTION) {
      String path = fc.getSelectedFile().toString();
      this.getView().getJTextFieldRecordSavePath().setText(path);
      this.getTimer().setSavePath(path);
    }
  }
  public void actionPerformed(ActionEvent e) {
    JFileChooser chooser = new JFileChooser();
    chooser.setDialogTitle(toolTip);
    chooser.setDialogType(dialogType);
    chooser.setFileSelectionMode(fileSelectionMode);
    chooser.setSelectedFile(new File(textField.getText()));
    chooser.setFileFilter(preferredFileFilter);

    // if the user selects APPROVE then take the text
    if (chooser.showOpenDialog(parent) == JFileChooser.APPROVE_OPTION) {
      // put the text in the text field
      String pathString = chooser.getSelectedFile().getAbsolutePath();
      textField.setText(pathString);
    }
  }
Example #24
0
  public void init() {
    tabbedPane.addMouseListener(
        new MouseAdapter() {
          public void mousePressed(MouseEvent e) {
            if (e.getModifiers() == InputEvent.BUTTON3_MASK) {
              contextMenu.show(e.getComponent(), e.getX(), e.getY());
            }
          }

          public void mouseReleased(MouseEvent e) {}
        });
    fileChooser = new JFileChooser();
    fileChooser.setDialogTitle("Save file");
    fileChooser.setApproveButtonText("Save file");
    fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
  }
Example #25
0
 private void displayDialogChangeDir() {
   final JFileChooser chooser = new JFileChooser();
   chooser.setDialogType(JFileChooser.CUSTOM_DIALOG);
   chooser.setDialogTitle("Directory to watch:");
   chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
   chooser.setAcceptAllFileFilterUsed(false);
   final String currentPath = prefs.get(KEY_DIR, ".");
   chooser.setCurrentDirectory(new File(currentPath));
   Log.info("Showing OpenDialog");
   final int returnVal = chooser.showOpenDialog(this);
   Log.info("Closing OpenDialog");
   if (returnVal == JFileChooser.APPROVE_OPTION) {
     final File dir = chooser.getSelectedFile();
     changeDir(dir);
   }
 }
Example #26
0
  public static Map[] showOpenMapDialog(final JFrame owner) throws IOException {
    final JFileChooser ch = new JFileChooser();
    if (config.getFile("mapLastOpenDir") != null) {
      ch.setCurrentDirectory(config.getFile("mapLastOpenDir"));
    }
    ch.setDialogType(JFileChooser.OPEN_DIALOG);
    ch.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    if (ch.showOpenDialog(MainFrame.getInstance()) != JFileChooser.APPROVE_OPTION) {
      return null;
    }
    final File dir = ch.getSelectedFile();
    config.set("mapLastOpenDir", dir);
    final String[] maps = dir.list(FILTER_TILES);
    for (int i = 0; i < maps.length; ++i) {
      maps[i] = maps[i].substring(0, maps[i].length() - MapIO.EXT_TILE.length());
    }
    final JDialog dialog = new JDialog(owner, Lang.getMsg("gui.chooser"));
    dialog.setModal(true);
    dialog.setLocationRelativeTo(null);
    dialog.setLayout(new BorderLayout());

    final JList list = new JList(maps);
    final JButton btn = new JButton(Lang.getMsg("gui.chooser.Ok"));

    btn.addActionListener(
        new AbstractAction() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            if (list.getSelectedValue() != null) {
              dialog.setVisible(false);
            }
          }
        });

    dialog.add(new JScrollPane(list), BorderLayout.CENTER);
    dialog.add(btn, BorderLayout.SOUTH);
    dialog.pack();
    dialog.setVisible(true);
    dialog.dispose();

    Map[] loadedMaps = new Map[list.getSelectedIndices().length];
    for (int i = 0; i < list.getSelectedIndices().length; i++) {
      loadedMaps[i] = MapIO.loadMap(dir.getPath(), (String) list.getSelectedValues()[i]);
    }
    return loadedMaps;
  }
Example #27
0
  /** Constructor */
  public SaverCustomizer() {

    try {
      m_SaverEditor.addPropertyChangeListener(
          new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent e) {
              repaint();
              if (m_dsSaver != null) {
                System.err.println("Property change!!");
                m_dsSaver.setSaver(m_dsSaver.getSaver());
              }
            }
          });
      repaint();
    } catch (Exception ex) {
      ex.printStackTrace();
    }
    setLayout(new BorderLayout());
    m_fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
    m_fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    m_fileChooser.setApproveButtonText("Select directory");
    m_fileChooser.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (e.getActionCommand().equals(JFileChooser.APPROVE_SELECTION)) {
              try {
                File selectedFile = m_fileChooser.getSelectedFile();
                m_directoryText.setText(selectedFile.toString());

                /* (m_dsSaver.getSaver()).setFilePrefix(m_prefixText.getText());
                (m_dsSaver.getSaver()).setDir(m_fileChooser.getSelectedFile().getPath());
                m_dsSaver.
                  setRelationNameForFilename(m_relationNameForFilename.isSelected()); */

              } catch (Exception ex) {
                ex.printStackTrace();
              }
            }
            // closing
            if (m_fileChooserFrame != null) {
              m_fileChooserFrame.dispose();
            }
          }
        });
  }
Example #28
0
  /** Opens dialog for selecting starting folder. */
  public void actionPerformed(ActionEvent e) {
    Object source = e.getSource();

    JFileChooser chooser = new JFileChooser();
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setDialogTitle(Translator.get("choose_folder"));
    chooser.setDialogType(JFileChooser.OPEN_DIALOG);
    if (chooser.showDialog(parent, Translator.get("choose")) == JFileChooser.APPROVE_OPTION) {
      File file = chooser.getSelectedFile();
      if (source == leftCustomFolderButton) {
        leftCustomFolderTextField.setText(file.getPath());
        if (!customFoldersRadioButton.isSelected()) customFoldersRadioButton.setSelected(true);
      } else if (source == rightCustomFolderButton) {
        rightCustomFolderTextField.setText(file.getPath());
        if (!customFoldersRadioButton.isSelected()) customFoldersRadioButton.setSelected(true);
      }
    }
  }
Example #29
0
 /** Save a file as something else. Called when the user goes to File -> Save As */
 public void saveFileAs() {
   JFileChooser chooser = new JFileChooser();
   chooser.addChoosableFileFilter(new CakeFileChooser());
   chooser.setDialogType(JFileChooser.SAVE_DIALOG);
   chooser.showSaveDialog(window);
   File f = chooser.getSelectedFile();
   if (f == null) return;
   try {
     if (calendar.getSettings().getName() == CakeCal.UNTITLED) {
       calendar.getSettings().setName(f.getName());
       parent.updateGUI(CakeCal.UNTITLED);
     }
     calendar.saveCal(f.getPath());
   } catch (IOException e) {
     System.out.println(e.getMessage());
   }
   calendar.getSettings().setFilename(f.getPath());
   // save.setEnabled(calendar.modified);
 }
Example #30
0
  private void init() {
    scaler = new ScaleSelector();
    chooser = new JFileChooser();
    chooser.setDialogType(JFileChooser.SAVE_DIALOG);
    chooser.setDialogTitle("Export Prefuse Display...");
    chooser.setAcceptAllFileFilterUsed(false);

    HashSet seen = new HashSet();
    String[] fmts = ImageIO.getWriterFormatNames();
    for (int i = 0; i < fmts.length; i++) {
      String s = fmts[i].toLowerCase();
      if (s.length() == 3 && !seen.contains(s)) {
        seen.add(s);
        chooser.setFileFilter(new SimpleFileFilter(s, s.toUpperCase() + " Image (*." + s + ")"));
      }
    }
    seen.clear();
    seen = null;
    chooser.setAccessory(scaler);
  }