コード例 #1
0
  // $$ 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;
  }
コード例 #2
0
 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);
 }
コード例 #3
0
ファイル: JSheet.java プロジェクト: karlvr/Quaqua
  /**
   * 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();
  }
コード例 #4
0
  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);
    }
  }
コード例 #5
0
ファイル: TabView.java プロジェクト: linvald/JarFileAnalyser
  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);
  }
コード例 #6
0
ファイル: MapDialogs.java プロジェクト: Tiim/Illarion-Java
  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;
  }
コード例 #7
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();
            }
          }
        });
  }
コード例 #8
0
ファイル: JSheet.java プロジェクト: karlvr/Quaqua
 /**
  * Displays an "Open File" file chooser sheet. Note that the text that appears in the approve
  * button is determined by the L&amp;F.
  *
  * @param chooser the chooser
  * @param parent the parent component of the dialog, can be {@code null}.
  * @param listener The listener for SheetEvents.
  */
 public static void showOpenSheet(JFileChooser chooser, Component parent, SheetListener listener) {
   chooser.setDialogType(JFileChooser.OPEN_DIALOG);
   showSheet(chooser, parent, null, listener);
 }
コード例 #9
0
  public void takeScreenshot(boolean flag) {
    BufferedImage bufferedimage;
    try {
      Robot robot = new Robot();
      Point point = getLocationOnScreen();
      Rectangle rectangle = new Rectangle(point.x, point.y, getWidth(), getHeight());
      bufferedimage = robot.createScreenCapture(rectangle);
    } catch (Throwable throwable) {
      JOptionPane.showMessageDialog(
          frame, "An error occured while trying to create a screenshot!", "Screenshot Error", 0);
      return;
    }
    String s = null;
    try {
      s = getNearestScreenshotFilename();
    } catch (IOException ioexception) {
      if (flag) {
        JOptionPane.showMessageDialog(
            frame,
            "A screenshot directory does not exist, and could not be created!",
            "No Screenshot Directory",
            0);
        return;
      }
    }
    if (s == null && flag) {
      JOptionPane.showMessageDialog(
          frame,
          "There are too many screenshots in the screenshot directory!\n"
              + "Delete some screen\n"
              + "shots and try again.",
          "Screenshot Directory Full",
          0);
      return;
    }
    if (!flag) {
      final JFileChooser fileChooser = new JFileChooser();
      final JDialog fileDialog = createFileChooserDialog(fileChooser, "Save Screenshot", this);
      final BufferedImage si = bufferedimage;
      JFileChooser _tmp = fileChooser;
      fileChooser.setFileSelectionMode(0);
      fileChooser.addChoosableFileFilter(new imageFileFilter());
      fileChooser.setCurrentDirectory(new File("C:/.hack3rClient/Scre/"));
      fileChooser.setSelectedFile(new File(s));
      JFileChooser _tmp1 = fileChooser;
      fileChooser.setDialogType(1);
      fileChooser.addActionListener(
          new ActionListener() {

            public void actionPerformed(ActionEvent actionevent) {
              String s1 = actionevent.getActionCommand();
              if (s1.equals("ApproveSelection")) {
                File file = fileChooser.getSelectedFile();
                if (file != null && file.isFile()) {
                  int i =
                      JOptionPane.showConfirmDialog(
                          frame,
                          (new StringBuilder())
                              .append(file.getAbsolutePath())
                              .append(" already exists.\n" + "Do you want to replace it?")
                              .toString(),
                          "Save Screenshot",
                          2);
                  if (i != 0) {
                    return;
                  }
                }
                try {
                  ImageIO.write(si, "png", file);
                  // client.pushMessage("Screenshot taken.", 3, "@cr2@ Client");
                  // JOptionPane.showMessageDialog(frame,"Screenshot Taken");
                } catch (IOException ioexception2) {
                  JOptionPane.showMessageDialog(
                      frame,
                      "An error occured while trying to save the screenshot!\n"
                          + "Please make sure you have\n"
                          + " write access to the screenshot directory.",
                      "Screenshot Error",
                      0);
                }
                fileDialog.dispose();
              } else if (s1.equals("CancelSelection")) {
                fileDialog.dispose();
              }
            }

            {
            }
          });
      fileDialog.setVisible(true);
    } else {
      try {
        ImageIO.write(
            bufferedimage,
            "png",
            new File((new StringBuilder()).append("C:/.hack3rClient/Scre/").append(s).toString()));
        JOptionPane.showMessageDialog(
            frame,
            "Image has been saved to C:/.hack3rclient/Scre. You can view your images by pushing File>View Images in the menu dropdowns.",
            "Screenshot manager",
            JOptionPane.INFORMATION_MESSAGE);
        // client.pushMessage("Screenshot taken.", 3, "@cr2@ Client");
        // JOptionPane.showMessageDialog(frame,"Screenshot taken.");
      } catch (IOException ioexception1) {
        JOptionPane.showMessageDialog(
            frame,
            "An error occured while trying to save the screenshot!\n"
                + "Please make sure you have\n"
                + " write access to the screenshot directory.",
            "Screenshot Error",
            0);
      }
    }
  }
コード例 #10
0
ファイル: Auswertung.java プロジェクト: nlsltz/DBIS
  // Listener für die Menüelemente und Buttons
  @Override
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == btnAusw) {
      LOG.info("DB Verbindung wird hergestellt.");
      dbgetter = new DBConnection(SERVERNAME, PORT, DB, USER, PWD);

      dwAusw = new DWAuswertung(dbgetter);

      lblErgebnis.setText(
          dwAusw.getQuartal(
              (String) cBoxJahr.getSelectedItem(), (String) cBoxQuartal.getSelectedItem()));
    }

    if (e.getSource() == btnAusw2) {
      LOG.info("DB Verbindung wird hergestellt.");
      dbgetter = new DBConnection(SERVERNAME, PORT, DB, USER, PWD);

      dwAusw = new DWAuswertung(dbgetter);
      String[] array =
          dwAusw.getAuswertung(
              (String) cBoxJahr2.getSelectedItem(),
              (String) cBoxQuartal2.getSelectedItem(),
              (String) cBoxEinArt.getSelectedItem(),
              (String) cBoxMitglied.getSelectedItem());

      lblErgebnis_2.setText(array[0]);
      lblMengeErg.setText(array[1]);
    }

    if (e.getSource() == mnItmQExp) {
      pfad = null;
      chooser = new JFileChooser(pfad);
      chooser.setDialogType(JFileChooser.SAVE_DIALOG);
      plainFilter = new FileNameExtensionFilter("*.csv", "csv");
      chooser.removeChoosableFileFilter(chooser.getAcceptAllFileFilter());
      chooser.setFileFilter(plainFilter);
      chooser.setDialogTitle("Speichern unter...");
      chooser.setVisible(true);

      file = null;

      int result = chooser.showSaveDialog(frmAuswertung);
      if (result == JFileChooser.APPROVE_OPTION) {
        file = chooser.getSelectedFile();
      }

      if (plainFilter.accept(file)) {
        LOG.info(file.getAbsolutePath() + " bereit zum speichern.");
        entries = new String[3];
        entries[0] = lblErgebnis.getText().substring(0, lblErgebnis.getText().length() - 4);
        entries[1] = (String) cBoxJahr.getSelectedItem();
        entries[2] = (String) cBoxQuartal.getSelectedItem();

        if (new CSVParser().saveAs(file, entries)) {
          LOG.info("Datei erfolgreich gespeichert.");
          JOptionPane.showMessageDialog(
              new JFrame(),
              "Daten erfolgreich exportiert nach:\n" + file.getAbsolutePath(),
              "Datenexport",
              JOptionPane.INFORMATION_MESSAGE);
        } else {
          LOG.log(Level.WARNING, "Datei nicht gespeichert.");
          JOptionPane.showMessageDialog(
              new JFrame(), "Daten nicht exportiert!", "Datenexport", JOptionPane.ERROR_MESSAGE);
        }
      } else {
        LOG.info(file.getAbsolutePath() + " ist der falsche Dateityp.");
        JOptionPane.showMessageDialog(
            new JFrame(),
            "Bitte folgendes Format nutzen:\n" + "{DATEINAME}.csv",
            "Datenexport",
            JOptionPane.ERROR_MESSAGE);
      }
      chooser.setVisible(false);
    }

    if (e.getSource() == mnItmAExp) {
      pfad = null;
      chooser = new JFileChooser(pfad);
      chooser.setDialogType(JFileChooser.SAVE_DIALOG);
      plainFilter = new FileNameExtensionFilter("*.csv", "csv");
      chooser.removeChoosableFileFilter(chooser.getAcceptAllFileFilter());
      chooser.setFileFilter(plainFilter);
      chooser.setDialogTitle("Speichern unter...");
      chooser.setVisible(true);

      file = null;

      int result = chooser.showSaveDialog(frmAuswertung);
      if (result == JFileChooser.APPROVE_OPTION) {
        file = chooser.getSelectedFile();
      }

      if (plainFilter.accept(file)) {
        LOG.info(file.getAbsolutePath() + " bereit zum speichern.");
        entries = new String[6];
        entries[0] = lblErgebnis.getText().substring(0, lblErgebnis.getText().length() - 4);
        entries[1] = lblMengeErg.getText().substring(0, lblMengeErg.getText().length() - 4);
        entries[2] = (String) cBoxEinArt.getSelectedItem();
        entries[3] = (String) cBoxMitglied.getSelectedItem();
        entries[4] = (String) cBoxJahr.getSelectedItem();
        entries[5] = (String) cBoxQuartal.getSelectedItem();

        if (new CSVParser().saveAs(file, entries)) {
          LOG.info("Datei erfolgreich gespeichert.");
          JOptionPane.showMessageDialog(
              new JFrame(),
              "Daten erfolgreich exportiert nach:\n" + file.getAbsolutePath(),
              "Datenexport",
              JOptionPane.INFORMATION_MESSAGE);
        } else {
          LOG.log(Level.WARNING, "Datei nicht gespeichert.");
          JOptionPane.showMessageDialog(
              new JFrame(), "Daten nicht exportiert!", "Datenexport", JOptionPane.ERROR_MESSAGE);
        }
      } else {
        LOG.info(file.getAbsolutePath() + " ist der falsche Dateityp.");
        JOptionPane.showMessageDialog(
            new JFrame(),
            "Bitte folgendes Format nutzen:\n" + "{DATEINAME}.csv",
            "Datenexport",
            JOptionPane.ERROR_MESSAGE);
      }
      chooser.setVisible(false);
    }

    if (e.getSource() == mnItmLog) {
      try {
        Desktop.getDesktop()
            .browse(
                new URI(
                    "file://"
                        + System.getProperty("user.home")
                        + System.getProperty("file.separator")
                        + "dw-log.html"));
      } catch (URISyntaxException | IOException e1) {
        LOG.log(Level.WARNING, "Protokoll kann nicht geöffnet werden.", e1);
        JOptionPane.showMessageDialog(
            new JFrame(),
            "Protokoll konnte nicht geöffnet werden.",
            "Protokoll öffnen...",
            JOptionPane.ERROR_MESSAGE);
      }
    }

    if (e.getSource() == mnItmQuit) {
      frmAuswertung.dispose();
    }

    if (e.getSource() == mnItmAbout) {
      About frame = new About();
      frame.setVisible(true);
    }
  }
コード例 #11
0
ファイル: ThumbMaker.java プロジェクト: ctrueden/web-toys
  /** Called for button presses and checkbox toggles. */
  public void actionPerformed(ActionEvent e) {
    Object src = e.getSource();

    // the source of the event is the add files button
    // so we need to let the user add some files!
    if (src == addFiles) {
      // create an appropriate file chooser
      JFileChooser myTempFileChooser = new JFileChooser((new File("")).getAbsolutePath());
      myTempFileChooser.setMultiSelectionEnabled(true);
      myTempFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
      myTempFileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
      myTempFileChooser.setFileHidingEnabled(true);

      // open the file chooser and get the user's selctions
      int returnCode = myTempFileChooser.showOpenDialog(this);

      // use the return info to add files if the
      // user selected any in the file chooser
      if (returnCode == JFileChooser.APPROVE_OPTION) {
        // grab the files the user selected
        File[] selectedFiles = myTempFileChooser.getSelectedFiles();

        // pull the files into the list
        changeFilesInList.importFileData(list, selectedFiles);
      }
    }

    // the source of the event was the process button
    else if (src == process) {
      if (((DefaultListModel) list.getModel()).size() == 0) return;

      setComponentsEnabled(false);
      final ThumbMaker tm = this;
      Thread t =
          new Thread(
              new Runnable() {
                public void run() {
                  tm.process();
                  setComponentsEnabled(true);
                }
              });
      t.start();

      // because we can't do it on quit, we are going to save
      // all the preference values when the user processes a set
      // of images
      savePreferences();
    }

    // the source of the event was the remove button
    else if (src == remove) {
      DefaultListModel model = (DefaultListModel) list.getModel();
      while (true) {
        int ndx = list.getSelectedIndex();
        if (ndx < 0) break;
        model.removeElementAt(ndx);
      }
    }

    // the source of the event was the preserve aspect check box
    else if (src == aspect) {
      boolean b = aspect.isSelected();
      colorLabel.setEnabled(b);
      colorBox.setEnabled(b);
      redLabel.setEnabled(b);
      red.setEnabled(b);
      redValue.setEnabled(b);
      greenLabel.setEnabled(b);
      green.setEnabled(b);
      greenValue.setEnabled(b);
      blueLabel.setEnabled(b);
      blue.setEnabled(b);
      blueValue.setEnabled(b);
    }

    // the source of the event is the "..." button,
    // we need to let the user select a destination file
    else if (src == dotDotDot) {
      // create an appropriate file chooser
      JFileChooser myTempFileChooser =
          new JFileChooser(new File(output.getText()).getAbsolutePath());
      myTempFileChooser.setMultiSelectionEnabled(false);
      myTempFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
      myTempFileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
      myTempFileChooser.setFileHidingEnabled(true);

      // open the file chooser and get the user's selctions
      int returnCode = myTempFileChooser.showOpenDialog(this);

      // use the return info to set the directory if the
      // user selected one in the file chooser
      if (returnCode == JFileChooser.APPROVE_OPTION) {
        // grab the file the user selected
        File selectedFile = myTempFileChooser.getSelectedFile();

        // stuff the file path into the text field
        output.setText(selectedFile.getAbsolutePath());
      }
    }
  }
コード例 #12
0
ファイル: AutoDetectPaths.java プロジェクト: sekia556/jabref
  private boolean autoDetectPaths() {

    if (Globals.ON_WIN) {
      List<File> progFiles = AutoDetectPaths.findProgramFilesDir();
      File sOffice = null;
      if (fileSearchCancelled) {
        return false;
      }
      for (File dir : progFiles) {
        sOffice = findFileDir(dir, "soffice.exe");
        if (sOffice != null) {
          break;
        }
      }
      if (sOffice == null) {
        JOptionPane.showMessageDialog(
            parent,
            Globals.lang(
                "Unable to autodetect OpenOffice installation. Please choose the installation directory manually."),
            Globals.lang("Could not find OpenOffice installation"),
            JOptionPane.INFORMATION_MESSAGE);
        JFileChooser jfc = new JFileChooser(new File("C:\\"));
        jfc.setDialogType(JFileChooser.OPEN_DIALOG);
        jfc.setFileFilter(
            new javax.swing.filechooser.FileFilter() {

              @Override
              public boolean accept(File file) {
                return file.isDirectory();
              }

              @Override
              public String getDescription() {
                return Globals.lang("Directories");
              }
            });
        jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        jfc.showOpenDialog(parent);
        if (jfc.getSelectedFile() != null) {
          sOffice = jfc.getSelectedFile();
        }
      }
      if (sOffice == null) {
        return false;
      }

      Globals.prefs.put("ooExecutablePath", new File(sOffice, "soffice.exe").getPath());
      File unoil = findFileDir(sOffice.getParentFile(), "unoil.jar");
      if (fileSearchCancelled) {
        return false;
      }
      File jurt = findFileDir(sOffice.getParentFile(), "jurt.jar");
      if (fileSearchCancelled) {
        return false;
      }
      if ((unoil != null) && (jurt != null)) {
        Globals.prefs.put("ooUnoilPath", unoil.getPath());
        Globals.prefs.put("ooJurtPath", jurt.getPath());
        return true;
      } else {
        return false;
      }

    } else if (Globals.ON_MAC) {
      File rootDir = new File("/Applications");
      File[] files = rootDir.listFiles();
      for (File file : files) {
        if (file.isDirectory() && file.getName().equals("OpenOffice.org.app")) {
          rootDir = file;
          // System.out.println("Setting starting dir to: "+file.getPath());
          break;
        }
      }
      // System.out.println("Searching for soffice.bin");
      File sOffice = findFileDir(rootDir, "soffice.bin");
      // System.out.println("Found: "+(sOffice != null ? sOffice.getPath() : "-"));
      if (fileSearchCancelled) {
        return false;
      }
      if (sOffice != null) {
        Globals.prefs.put("ooExecutablePath", new File(sOffice, "soffice.bin").getPath());
        // System.out.println("Searching for unoil.jar");
        File unoil = findFileDir(rootDir, "unoil.jar");
        // System.out.println("Found: "+(unoil != null ? unoil.getPath(): "-"));
        if (fileSearchCancelled) {
          return false;
        }
        // System.out.println("Searching for jurt.jar");
        File jurt = findFileDir(rootDir, "jurt.jar");
        // System.out.println("Found: "+(jurt != null ? jurt.getPath(): "-"));
        if (fileSearchCancelled) {
          return false;
        }
        if ((unoil != null) && (jurt != null)) {
          Globals.prefs.put("ooUnoilPath", unoil.getPath());
          Globals.prefs.put("ooJurtPath", jurt.getPath());
          return true;
        } else {
          return false;
        }
      } else {
        return false;
      }
    } else {
      // Linux:
      String usrRoot = "/usr/lib";
      File inUsr = findFileDir(new File("/usr/lib"), "soffice");
      if (fileSearchCancelled) {
        return false;
      }
      if (inUsr == null) {
        inUsr = findFileDir(new File("/usr/lib64"), "soffice");
        if (inUsr != null) {
          usrRoot = "/usr/lib64";
        }
      }

      if (fileSearchCancelled) {
        return false;
      }
      File inOpt = findFileDir(new File("/opt"), "soffice");
      if (fileSearchCancelled) {
        return false;
      }
      if ((inUsr != null) && (inOpt == null)) {
        return setupPreferencesForOO(usrRoot, inUsr);
      } else if ((inOpt != null) && (inUsr == null)) {
        Globals.prefs.put("ooExecutablePath", new File(inOpt, "soffice.bin").getPath());
        File unoil = findFileDir(new File("/opt"), "unoil.jar");
        File jurt = findFileDir(new File("/opt"), "jurt.jar");
        if ((unoil != null) && (jurt != null)) {
          Globals.prefs.put("ooUnoilPath", unoil.getPath());
          Globals.prefs.put("ooJurtPath", jurt.getPath());
          return true;
        } else {
          return false;
        }
      } else if (inOpt != null) { // Found both
        JRadioButton optRB = new JRadioButton(inOpt.getPath(), true);
        JRadioButton usrRB = new JRadioButton(inUsr.getPath(), false);
        ButtonGroup bg = new ButtonGroup();
        bg.add(optRB);
        bg.add(usrRB);
        DefaultFormBuilder b = new DefaultFormBuilder(new FormLayout("left:pref", ""));
        b.append(
            Globals.lang(
                "Found more than one OpenOffice executable. Please choose which one to connect to:"));
        b.append(optRB);
        b.append(usrRB);
        int answer =
            JOptionPane.showConfirmDialog(
                null,
                b.getPanel(),
                Globals.lang("Choose OpenOffice executable"),
                JOptionPane.OK_CANCEL_OPTION);
        if (answer == JOptionPane.CANCEL_OPTION) {
          return false;
        } else {
          if (optRB.isSelected()) {
            return setupPreferencesForOO("/opt", inOpt);
          } else {
            return setupPreferencesForOO(usrRoot, inUsr);
          }
        }
      } else {
        return false;
      }
    }
  }