예제 #1
1
  public DialogPanel(boolean canok, boolean cancancel) {
    super(new GridBagLayout());
    actions = new LinkedHashMap<String, Action>();
    keystrokes = new HashMap<KeyStroke, String>();

    if (canok) {
      addButton(
          "ok",
          UIManager.getString("OptionPane.okButtonText"),
          KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),
          new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
              acceptDialog();
            }
          });
      keystrokes.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_MASK), "ok");
    }

    if (cancancel) {
      addButton(
          "cancel",
          UIManager.getString("OptionPane.cancelButtonText"),
          KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
          new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
              cancelDialog();
            }
          });
      keystrokes.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, InputEvent.CTRL_MASK), "cancel");
    }
  }
예제 #2
0
  /** installs the tabbed pane related properties */
  public void installTabbedContainerSettings() {
    final String prefix = "/com/vlsolutions/swing/docking/";
    UIManager.put("TabbedDockableContainer.tabPlacement", new Integer(SwingConstants.TOP));

    UIManager.put(
        "DockTabbedPane.closeButtonText",
        UIManager.getString("InternalFrameTitlePane.closeButtonText"));
    UIManager.put(
        "DockTabbedPane.minimizeButtonText",
        UIManager.getString("InternalFrameTitlePane.minimizeButtonText"));
    UIManager.put(
        "DockTabbedPane.restoreButtonText",
        UIManager.getString("InternalFrameTitlePane.restoreButtonText"));
    UIManager.put(
        "DockTabbedPane.maximizeButtonText",
        UIManager.getString("InternalFrameTitlePane.maximizeButtonText"));
    UIManager.put("DockTabbedPane.floatButtonText", "Detach");
    UIManager.put("DockTabbedPane.attachButtonText", "Attach"); // 2005/10/07

    UIManager.put("JTabbedPaneSmartIcon.font", UIManager.getFont("TabbedPane.font")); // 2006/01/23

    // set to true to set focus directly into a tabbed component when it becomes
    // selected
    UIManager.put("TabbedContainer.requestFocusOnTabSelection", Boolean.FALSE);
  }
예제 #3
0
/** FileSystemView that handles some specific unix-isms. */
class UnixFileSystemView extends FileSystemView {

  private static final String newFolderString = UIManager.getString("FileChooser.other.newFolder");
  private static final String newFolderNextString =
      UIManager.getString("FileChooser.other.newFolder.subsequent");

  /** Creates a new folder with a default folder name. */
  public File createNewFolder(File containingDir) throws IOException {
    if (containingDir == null) {
      throw new IOException("Containing directory is null:");
    }
    File newFolder;
    // Unix - using OpenWindows' default folder name. Can't find one for Motif/CDE.
    newFolder = createFileObject(containingDir, newFolderString);
    int i = 1;
    while (newFolder.exists() && i < 100) {
      newFolder =
          createFileObject(
              containingDir, MessageFormat.format(newFolderNextString, new Integer(i)));
      i++;
    }

    if (newFolder.exists()) {
      throw new IOException("Directory already exists:" + newFolder.getAbsolutePath());
    } else {
      newFolder.mkdirs();
    }

    return newFolder;
  }

  public boolean isFileSystemRoot(File dir) {
    return dir != null && dir.getAbsolutePath().equals("/");
  }

  public boolean isDrive(File dir) {
    return isFloppyDrive(dir);
  }

  public boolean isFloppyDrive(File dir) {
    // Could be looking at the path for Solaris, but wouldn't be reliable.
    // For example:
    // return (dir != null && dir.getAbsolutePath().toLowerCase().startsWith("/floppy"));
    return false;
  }

  public boolean isComputerNode(File dir) {
    if (dir != null) {
      String parent = dir.getParent();
      if (parent != null && parent.equals("/net")) {
        return true;
      }
    }
    return false;
  }
}
예제 #4
0
 @Override
 public void actionPerformed(final ActionEvent e) {
   final int picturesToUpload = core.countPicturesToBeUploaded();
   if (picturesToUpload == 0) {
     JOptionPane.showMessageDialog(
         SwingUtilities.getWindowAncestor((Component) e.getSource()),
         UI.BUNDLE.getString("action.upload.none"));
   } else {
     final int choice =
         JOptionPane.showConfirmDialog(
             SwingUtilities.getWindowAncestor((Component) e.getSource()),
             MessageFormat.format(
                 UI.BUNDLE.getString("action.upload.confirm"),
                 picturesToUpload,
                 wikis.getActiveWiki().getName()),
             UIManager.getString("OptionPane.titleText"),
             JOptionPane.OK_CANCEL_OPTION,
             JOptionPane.QUESTION_MESSAGE,
             ICON);
     if (JOptionPane.OK_OPTION == choice) {
       new SwingWorker<Void, Void>() {
         @Override
         protected Void doInBackground() throws Exception {
           core.uploadPictures();
           return null;
         }
       }.execute();
     }
   }
 }
예제 #5
0
    void enqueue(Runnable r, boolean showdialog) {
      if (runlist == null) {
        runlist = new ArrayList<Runnable>();
      }
      runlist.add(r);
      if (showdialog && dialog == null) {
        dialog =
            new LongRunningTask() {
              public float getProgress() {
                return 1 - (float) state.getBytesRemaining() / state.getBytes();
              }

              public void run() {
                while (!isCancelled()) {
                  synchronized (this) {
                    try {
                      wait();
                    } catch (InterruptedException e) {
                    }
                  }
                }
              }
            };
        dialog.setCancellable(false);
        dialog.setModal(false);
        dialog.start(docpanel, UIManager.getString("PDFViewer.Loading"));
      }
    }
예제 #6
0
 protected void fileOpened(final DocumentView documentView, File file, Object value) {
   final DocumentOrientedApplication application = getApplication();
   if (value == null) {
     documentView.setFile(file);
     documentView.setEnabled(true);
     Frame w = (Frame) SwingUtilities.getWindowAncestor(documentView.getComponent());
     if (w != null) {
       w.setExtendedState(w.getExtendedState() & ~Frame.ICONIFIED);
       w.toFront();
     }
     documentView.getComponent().requestFocus();
     application.addRecentFile(file);
     application.setEnabled(true);
   } else {
     if (value instanceof Throwable) {
       ((Throwable) value).printStackTrace();
     }
     JSheet.showMessageSheet(
         documentView.getComponent(),
         "<html>"
             + UIManager.getString("OptionPane.css")
             + "<b>Couldn't open the file \""
             + file
             + "\".</b><br>"
             + value,
         JOptionPane.ERROR_MESSAGE,
         new SheetListener() {
           public void optionSelected(SheetEvent evt) {
             // application.dispose(documentView);
           }
         });
   }
 }
 @Override
 public String getAccessibleActionDescription(int i) {
   if (i == 0) {
     return UIManager.getString("AbstractButton.clickText");
   } else {
     return null;
   }
 }
예제 #8
0
  public static int showNegativeConfirmDialog(
      Component parentComponent, Object message, String title) {
    List<Object> options = new ArrayList<Object>();
    Object defaultOption;

    options.add(UIManager.getString("OptionPane.yesButtonText"));
    options.add(UIManager.getString("OptionPane.noButtonText"));
    defaultOption = UIManager.getString("OptionPane.noButtonText");

    return JOptionPane.showOptionDialog(
        parentComponent,
        message,
        title,
        JOptionPane.YES_NO_OPTION,
        JOptionPane.QUESTION_MESSAGE,
        null,
        options.toArray(),
        defaultOption);
  }
  protected void installStrings(JFileChooser fc) {
    super.installStrings(fc);

    Locale l = fc.getLocale();

    enterFileNameLabelText = UIManager.getString("FileChooser.enterFileNameLabelText", l);
    enterFileNameLabelMnemonic = UIManager.getInt("FileChooser.enterFileNameLabelMnemonic");

    filesLabelText = UIManager.getString("FileChooser.filesLabelText", l);
    filesLabelMnemonic = UIManager.getInt("FileChooser.filesLabelMnemonic");

    foldersLabelText = UIManager.getString("FileChooser.foldersLabelText", l);
    foldersLabelMnemonic = UIManager.getInt("FileChooser.foldersLabelMnemonic");

    pathLabelText = UIManager.getString("FileChooser.pathLabelText", l);
    pathLabelMnemonic = UIManager.getInt("FileChooser.pathLabelMnemonic");

    filterLabelText = UIManager.getString("FileChooser.filterLabelText", l);
    filterLabelMnemonic = UIManager.getInt("FileChooser.filterLabelMnemonic");
  }
예제 #10
0
  /*
   * (non-Javadoc)
   *
   * @see com.jidesoft.dialog.StandardDialog#createButtonPanel()
   */
  public ButtonPanel createButtonPanel() {
    final ButtonPanel buttonPanel = new ButtonPanel(SwingConstants.RIGHT);

    AbstractAction okButtonAction =
        new AbstractAction(UIManager.getString("OptionPane.okButtonText")) {
          /** */
          private static final long serialVersionUID = -7972988497933837263L;

          public void actionPerformed(ActionEvent arg0) {
            mapPanel.doOK();
            setDialogResult(RESULT_AFFIRMED);
            setVisible(false);
            dispose();
          }
        };

    AbstractAction cancelButtonAction =
        new AbstractAction(UIManager.getString("OptionPane.cancelButtonText")) {
          /** */
          private static final long serialVersionUID = -4199961023918150328L;

          public void actionPerformed(ActionEvent arg0) {
            mapPanel.doCancel();
            setDialogResult(RESULT_CANCELLED);
            setVisible(false);
            dispose();
          }
        };

    JButton okButton = new JButton(okButtonAction);
    JButton cancelButton = new JButton(cancelButtonAction);

    buttonPanel.addButton(okButton);
    buttonPanel.addButton(cancelButton);
    buttonPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    cancelButton.setEnabled(mapPanel.isEditable());

    return buttonPanel;
  }
예제 #11
0
  // EDIT: in response to comment
  public static void showMessageDialog(Component parent, Object message, int timeout) {
    // run all of this on the EDT
    final JOptionPane optionPane = new JOptionPane(message);
    String title = UIManager.getString("OptionPane.messageDialogTitle");
    // int style = styleFromMessageType(JOptionPane.INFORMATION_MESSAGE);
    final JDialog dialog = optionPane.createDialog(parent, title);

    // timeout default is 5000 milliseconds
    Timer timer = new Timer(timeout, new AutoDismiss(dialog));
    timer.setRepeats(false);
    timer.start();
    if (dialog.isDisplayable()) dialog.setVisible(true);
  }
예제 #12
0
 private static Object convert(Locale locale, String key) {
   if (key.endsWith("Text")) { // NON-NLS: suffix for text message
     return UIManager.getString(key, locale);
   }
   if (key.endsWith("Size")) { // NON-NLS: suffix for dimension
     return UIManager.getDimension(key, locale);
   }
   if (key.endsWith("Color")) { // NON-NLS: suffix for color
     return UIManager.getColor(key, locale);
   }
   int value = SwingUtilities2.getUIDefaultsInt(key, locale, -1);
   return Integer.valueOf(value);
 }
예제 #13
0
  /**
   * Retrieve the optional internal frame icon.
   *
   * <p>The following 2 steps are used to determine the optional internal frame icon:
   *
   * <ol>
   *   <li>The internal frame icon set with {@link #setOptionalIFrameIcon(javax.swing.Icon)
   *       setOptionalIFrameIcon} if it is not null.
   *   <li>The optional internal frame icon filed under the key <b>"swingx.iframe.icon"</b> in the
   *       UIManager.
   * </ol>
   *
   * @return Image An optional internal frame icon.
   */
  public static Icon getOptionalIFrameIcon() {
    Icon optionalIFrameIcon = getInstance().optionalIFrameIcon;

    if (optionalIFrameIcon != null) {
      return optionalIFrameIcon;
    }

    String uiOptionalIFrameIcon = UIManager.getString("swingx.iframe.icon");

    if (uiOptionalIFrameIcon != null) {
      return Utils.getIcon(uiOptionalIFrameIcon);
    }

    return null;
  }
예제 #14
0
  /** installs the DockVieTitleBar related properties */
  public void installDockViewTitleBarSettings() {
    UIManager.put("DockViewTitleBarUI", "com.vlsolutions.swing.docking.ui.DockViewTitleBarUI");

    UIManager.put("DockViewTitleBar.height", new Integer(20));
    UIManager.put(
        "DockViewTitleBar.closeButtonText",
        UIManager.getString("InternalFrameTitlePane.closeButtonText"));
    UIManager.put(
        "DockViewTitleBar.minimizeButtonText",
        UIManager.getString("InternalFrameTitlePane.minimizeButtonText"));
    UIManager.put(
        "DockViewTitleBar.restoreButtonText",
        UIManager.getString("InternalFrameTitlePane.restoreButtonText"));
    UIManager.put(
        "DockViewTitleBar.maximizeButtonText",
        UIManager.getString("InternalFrameTitlePane.maximizeButtonText"));
    UIManager.put("DockViewTitleBar.floatButtonText", "Detach");
    UIManager.put("DockViewTitleBar.attachButtonText", "Attach");

    // font to be used in the title bar
    UIManager.put("DockViewTitleBar.titleFont", UIManager.get("InternalFrame.titleFont"));

    // are buttons displayed or just accessible from the contextual menu ?
    // setting one of these flags to false hide the button from the title bar
    // setting to true not necessarily shows the button, as it then depends
    // on the DockKey allowed states.
    UIManager.put("DockViewTitleBar.isCloseButtonDisplayed", Boolean.TRUE);
    UIManager.put("DockViewTitleBar.isHideButtonDisplayed", Boolean.TRUE);
    UIManager.put("DockViewTitleBar.isDockButtonDisplayed", Boolean.TRUE);
    UIManager.put("DockViewTitleBar.isMaximizeButtonDisplayed", Boolean.TRUE);
    UIManager.put("DockViewTitleBar.isRestoreButtonDisplayed", Boolean.TRUE);
    UIManager.put("DockViewTitleBar.isFloatButtonDisplayed", Boolean.TRUE);
    UIManager.put("DockViewTitleBar.isAttachButtonDisplayed", Boolean.TRUE);

    UIManager.put("DockViewTitleBar.border", BorderFactory.createMatteBorder(0, 0, 1, 0, shadow));
  }
예제 #15
0
 private static void createNativesFolder(File folder) {
   if (folder.exists() && !folder.isDirectory()) {
     Desktop desktop = Desktop.getDesktop();
     JButton browseFolder;
     JButton ok = new JButton(UIManager.getString("OptionPane.okButtonText"));
     Object[] options;
     if (desktop.isSupported(Action.BROWSE)) {
       browseFolder = new JButton("Browse Folder");
       options = new Object[] {browseFolder, ok};
     } else {
       browseFolder = null;
       options = new Object[] {ok};
     }
     JOptionPane msg =
         new JOptionPane(
             "We must create this folder \""
                 + folder
                 + "\" and there is a file called natives in its place.\n"
                 + "Rename or move at this time or it will be deleted. Resistance is futile.",
             JOptionPane.INFORMATION_MESSAGE,
             JOptionPane.DEFAULT_OPTION,
             null,
             options);
     if (browseFolder != null) {
       browseFolder.addActionListener(
           action -> {
             try {
               Desktop.getDesktop().browse(folder.getParentFile().toURI());
             } catch (Exception e) {
               UIUtils.displayException("Unable to browse folder", e);
             }
           });
     }
     ok.addActionListener(action -> msg.setValue(0));
     JDialog dialog = msg.createDialog("Slyther");
     try (InputStream icon = ClientMain.class.getResourceAsStream("/textures/icon_32.png")) {
       dialog.setIconImage(ImageIO.read(icon));
     } catch (IOException e) {
     }
     dialog.setVisible(true);
     dialog.dispose();
     folder.delete();
   }
   folder.mkdirs();
 }
예제 #16
0
  /**
   * Creates the crayons.
   *
   * @return Array of crayons in z-order from bottom to top.
   */
  protected Crayon[] createCrayons() {
    Color[] colors = DefaultPalettes.CRAYONS;
    crayons = new Crayon[colors.length];
    for (int i = 0; i < colors.length; i++) {
      crayons[i] =
          new Crayon(
              colors[i],
              UIManager.getString(
                  "ColorChooser.crayon."
                      + Integer.toHexString(0xff000000 | colors[i].getRGB()).substring(2)),
              new Polygon(
                  (int[]) crayonXPoints.clone(),
                  (int[]) crayonYPoints.clone(),
                  crayonXPoints.length));
      crayons[i].shape.translate((i % 8) * 22 + 4 + ((i / 8) % 2) * 11, (i / 8) * 20 + 23);
    }

    return crayons;
  }
예제 #17
0
/** Fallthrough FileSystemView in case we can't determine the OS. */
class GenericFileSystemView extends FileSystemView {

  private static final String newFolderString = UIManager.getString("FileChooser.other.newFolder");

  /** Creates a new folder with a default folder name. */
  public File createNewFolder(File containingDir) throws IOException {
    if (containingDir == null) {
      throw new IOException("Containing directory is null:");
    }
    // Using NT's default folder name
    File newFolder = createFileObject(containingDir, newFolderString);

    if (newFolder.exists()) {
      throw new IOException("Directory already exists:" + newFolder.getAbsolutePath());
    } else {
      newFolder.mkdirs();
    }

    return newFolder;
  }
}
예제 #18
0
 protected void fileOpened(final Project project, File file, Object value) {
   if (value == null) {
     project.setFile(file);
     project.setEnabled(true);
     getApplication().addRecentFile(file);
   } else {
     JSheet.showMessageSheet(
         project.getComponent(),
         "<html>"
             + UIManager.getString("OptionPane.css")
             + "<b>Couldn't open the file \""
             + file
             + "\".</b><br>"
             + value,
         JOptionPane.ERROR_MESSAGE,
         new SheetListener() {
           public void optionSelected(SheetEvent evt) {
             project.clear();
             project.setEnabled(true);
           }
         });
   }
 }
예제 #19
0
  protected void fileOpened(final DocumentView documentView, File file, Object value) {
    if (value == null) {
      documentView.setFile(file);
      documentView.setEnabled(true);
      getApplication().addRecentFile(file);
    } else {
      JSheet.showMessageSheet(
          documentView.getComponent(),
          "<html>"
              + UIManager.getString("OptionPane.css")
              + "<b>Couldn't open the file \""
              + file
              + "\".</b><br>"
              + value,
          JOptionPane.ERROR_MESSAGE,
          new SheetListener() {
            public void optionSelected(SheetEvent evt) {
              documentView.execute(
                  new Worker() {
                    public Object construct() {
                      try {
                        documentView.clear();
                        return null;
                      } catch (IOException ex) {
                        return ex;
                      }
                    }

                    public void finished(Object result) {
                      documentView.setEnabled(true);
                    }
                  });
            }
          });
    }
  }
예제 #20
0
 public String getDescription() {
   return UIManager.getString("FileChooser.acceptAllFileFilterText");
 }
 public MaximizeAction() {
   super(UIManager.getString("DarculaTitlePane.maximizeTitle", getLocale()));
 }
예제 #22
0
  /**
   * Returns the buttons to display from the JOptionPane the receiver is providing the look and feel
   * for. If the JOptionPane has options set, they will be provided, otherwise if the optionType is
   * YES_NO_OPTION, yesNoOptions is returned, if the type is YES_NO_CANCEL_OPTION yesNoCancelOptions
   * is returned, otherwise defaultButtons are returned.
   */
  protected Object[] getButtons() {
    if (optionPane != null) {
      Object[] suppliedOptions = optionPane.getOptions();

      if (suppliedOptions == null) {
        Object[] defaultOptions;
        int type = optionPane.getOptionType();
        Locale l = optionPane.getLocale();
        int minimumWidth =
            DefaultLookup.getInt(optionPane, this, "OptionPane.buttonMinimumWidth", -1);
        if (type == JOptionPane.YES_NO_OPTION) {
          defaultOptions = new ButtonFactory[2];
          defaultOptions[0] =
              new ButtonFactory(
                  UIManager.getString("OptionPane.yesButtonText", l),
                  getMnemonic("OptionPane.yesButtonMnemonic", l),
                  (Icon) DefaultLookup.get(optionPane, this, "OptionPane.yesIcon"),
                  minimumWidth);
          defaultOptions[1] =
              new ButtonFactory(
                  UIManager.getString("OptionPane.noButtonText", l),
                  getMnemonic("OptionPane.noButtonMnemonic", l),
                  (Icon) DefaultLookup.get(optionPane, this, "OptionPane.noIcon"),
                  minimumWidth);
        } else if (type == JOptionPane.YES_NO_CANCEL_OPTION) {
          defaultOptions = new ButtonFactory[3];
          defaultOptions[0] =
              new ButtonFactory(
                  UIManager.getString("OptionPane.yesButtonText", l),
                  getMnemonic("OptionPane.yesButtonMnemonic", l),
                  (Icon) DefaultLookup.get(optionPane, this, "OptionPane.yesIcon"),
                  minimumWidth);
          defaultOptions[1] =
              new ButtonFactory(
                  UIManager.getString("OptionPane.noButtonText", l),
                  getMnemonic("OptionPane.noButtonMnemonic", l),
                  (Icon) DefaultLookup.get(optionPane, this, "OptionPane.noIcon"),
                  minimumWidth);
          defaultOptions[2] =
              new ButtonFactory(
                  UIManager.getString("OptionPane.cancelButtonText", l),
                  getMnemonic("OptionPane.cancelButtonMnemonic", l),
                  (Icon) DefaultLookup.get(optionPane, this, "OptionPane.cancelIcon"),
                  minimumWidth);
        } else if (type == JOptionPane.OK_CANCEL_OPTION) {
          defaultOptions = new ButtonFactory[2];
          defaultOptions[0] =
              new ButtonFactory(
                  UIManager.getString("OptionPane.okButtonText", l),
                  getMnemonic("OptionPane.okButtonMnemonic", l),
                  (Icon) DefaultLookup.get(optionPane, this, "OptionPane.okIcon"),
                  minimumWidth);
          defaultOptions[1] =
              new ButtonFactory(
                  UIManager.getString("OptionPane.cancelButtonText", l),
                  getMnemonic("OptionPane.cancelButtonMnemonic", l),
                  (Icon) DefaultLookup.get(optionPane, this, "OptionPane.cancelIcon"),
                  minimumWidth);
        } else {
          defaultOptions = new ButtonFactory[1];
          defaultOptions[0] =
              new ButtonFactory(
                  UIManager.getString("OptionPane.okButtonText", l),
                  getMnemonic("OptionPane.okButtonMnemonic", l),
                  (Icon) DefaultLookup.get(optionPane, this, "OptionPane.okIcon"),
                  minimumWidth);
        }
        return defaultOptions;
      }
      return suppliedOptions;
    }
    return null;
  }
 private String cancelButtonText() {
   return UIManager.getString("FileChooser.cancelButtonText");
 }
  protected void buildChooser() {

    String redString = UIManager.getString("ColorChooser.rgbRedText");
    String greenString = UIManager.getString("ColorChooser.rgbGreenText");
    String blueString = UIManager.getString("ColorChooser.rgbBlueText");

    setLayout(new BorderLayout());
    Color color = getColorFromModel();

    JPanel enclosure = new JPanel();
    enclosure.setLayout(new SmartGridLayout(3, 3));
    enclosure.setInheritsPopupMenu(true);

    // The panel that holds the sliders

    add(enclosure, BorderLayout.CENTER);
    //        sliderPanel.setBorder(new LineBorder(Color.black));

    // The row for the red value
    JLabel l = new JLabel(redString);
    l.setDisplayedMnemonic(AbstractColorChooserPanel.getInt("ColorChooser.rgbRedMnemonic", -1));
    enclosure.add(l);
    redSlider = new JSlider(JSlider.HORIZONTAL, 0, 255, color.getRed());
    redSlider.setMajorTickSpacing(85);
    redSlider.setMinorTickSpacing(17);
    redSlider.setPaintTicks(true);
    redSlider.setPaintLabels(true);
    redSlider.setInheritsPopupMenu(true);
    enclosure.add(redSlider);
    redField = new JSpinner(new SpinnerNumberModel(color.getRed(), minValue, maxValue, 1));
    l.setLabelFor(redSlider);
    redField.setInheritsPopupMenu(true);
    JPanel redFieldHolder = new JPanel(new CenterLayout());
    redFieldHolder.setInheritsPopupMenu(true);
    redField.addChangeListener(this);
    redFieldHolder.add(redField);
    enclosure.add(redFieldHolder);

    // The row for the green value
    l = new JLabel(greenString);
    l.setDisplayedMnemonic(AbstractColorChooserPanel.getInt("ColorChooser.rgbGreenMnemonic", -1));
    enclosure.add(l);
    greenSlider = new JSlider(JSlider.HORIZONTAL, 0, 255, color.getGreen());
    greenSlider.setMajorTickSpacing(85);
    greenSlider.setMinorTickSpacing(17);
    greenSlider.setPaintTicks(true);
    greenSlider.setPaintLabels(true);
    greenSlider.setInheritsPopupMenu(true);
    enclosure.add(greenSlider);
    greenField = new JSpinner(new SpinnerNumberModel(color.getGreen(), minValue, maxValue, 1));
    l.setLabelFor(greenSlider);
    greenField.setInheritsPopupMenu(true);
    JPanel greenFieldHolder = new JPanel(new CenterLayout());
    greenFieldHolder.add(greenField);
    greenFieldHolder.setInheritsPopupMenu(true);
    greenField.addChangeListener(this);
    enclosure.add(greenFieldHolder);

    // The slider for the blue value
    l = new JLabel(blueString);
    l.setDisplayedMnemonic(AbstractColorChooserPanel.getInt("ColorChooser.rgbBlueMnemonic", -1));
    enclosure.add(l);
    blueSlider = new JSlider(JSlider.HORIZONTAL, 0, 255, color.getBlue());
    blueSlider.setMajorTickSpacing(85);
    blueSlider.setMinorTickSpacing(17);
    blueSlider.setPaintTicks(true);
    blueSlider.setPaintLabels(true);
    blueSlider.setInheritsPopupMenu(true);
    enclosure.add(blueSlider);
    blueField = new JSpinner(new SpinnerNumberModel(color.getBlue(), minValue, maxValue, 1));
    l.setLabelFor(blueSlider);
    blueField.setInheritsPopupMenu(true);
    JPanel blueFieldHolder = new JPanel(new CenterLayout());
    blueFieldHolder.add(blueField);
    blueField.addChangeListener(this);
    blueFieldHolder.setInheritsPopupMenu(true);
    enclosure.add(blueFieldHolder);

    redSlider.addChangeListener(this);
    greenSlider.addChangeListener(this);
    blueSlider.addChangeListener(this);

    redSlider.putClientProperty("JSlider.isFilled", Boolean.TRUE);
    greenSlider.putClientProperty("JSlider.isFilled", Boolean.TRUE);
    blueSlider.putClientProperty("JSlider.isFilled", Boolean.TRUE);
  }
  // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
  private void initComponents() {
    java.awt.GridBagConstraints gridBagConstraints;

    fc = new javax.swing.JPanel();
    fromPanel = new javax.swing.JPanel();
    fileNameLabel = new javax.swing.JLabel();
    fileNameTextField = new javax.swing.JTextField();
    strutPanel1 = new javax.swing.JPanel();
    lookInLabel = new javax.swing.JLabel();
    directoryComboBox = new javax.swing.JComboBox();
    strutPanel2 = new javax.swing.JPanel();
    separatorPanel1 = new javax.swing.JPanel();
    separatorPanel2 = new javax.swing.JPanel();
    browserScrollPane = new javax.swing.JScrollPane();
    browser = new ch.randelshofer.quaqua.JBrowser();
    newFolderButton = new javax.swing.JButton();
    separatorPanel = new javax.swing.JPanel();
    formatPanel = new javax.swing.JPanel();
    formatPanel2 = new javax.swing.JPanel();
    filesOfTypeLabel = new javax.swing.JLabel();
    filterComboBox = new javax.swing.JComboBox();
    accessoryPanel = new javax.swing.JPanel();
    buttonPanel = new javax.swing.JPanel();
    cancelButton = new javax.swing.JButton();
    approveButton = new javax.swing.JButton();

    setLayout(new java.awt.BorderLayout());

    fc.setLayout(new java.awt.GridBagLayout());

    fromPanel.setLayout(new java.awt.GridBagLayout());

    fileNameLabel.setText(UIManager.getString("FileChooser.fileNameLabelText"));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
    gridBagConstraints.insets = new java.awt.Insets(0, 0, 14, 0);
    fromPanel.add(fileNameLabel, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(0, 2, 14, 0);
    fromPanel.add(fileNameTextField, gridBagConstraints);

    strutPanel1.setLayout(null);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.ipadx = 40;
    gridBagConstraints.ipady = 5;
    fromPanel.add(strutPanel1, gridBagConstraints);

    lookInLabel.setText(UIManager.getString("FileChooser.fromLabelText"));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.gridheight = 2;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
    gridBagConstraints.insets = new java.awt.Insets(0, 1, 0, 0);
    fromPanel.add(lookInLabel, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.gridheight = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(0, 2, 0, 0);
    fromPanel.add(directoryComboBox, gridBagConstraints);

    strutPanel2.setLayout(new java.awt.BorderLayout());

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.ipadx = 40;
    gridBagConstraints.ipady = 5;
    fromPanel.add(strutPanel2, gridBagConstraints);

    separatorPanel1.setLayout(new java.awt.BorderLayout());

    separatorPanel1.setBackground(
        javax.swing.UIManager.getDefaults().getColor("Separator.foreground"));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.ipadx = 40;
    gridBagConstraints.ipady = 1;
    gridBagConstraints.weightx = 1.0E-4;
    fromPanel.add(separatorPanel1, gridBagConstraints);

    separatorPanel2.setLayout(new java.awt.BorderLayout());

    separatorPanel2.setBackground(
        javax.swing.UIManager.getDefaults().getColor("Separator.foreground"));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.ipadx = 40;
    gridBagConstraints.ipady = 1;
    fromPanel.add(separatorPanel2, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new java.awt.Insets(14, 0, 0, 0);
    fc.add(fromPanel, gridBagConstraints);

    browserScrollPane.setHorizontalScrollBarPolicy(
        javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    browserScrollPane.setVerticalScrollBarPolicy(
        javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
    browserScrollPane.setViewportView(browser);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridy = 1;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(8, 23, 0, 23);
    fc.add(browserScrollPane, gridBagConstraints);

    newFolderButton.setText(UIManager.getString("FileChooser.newFolderButtonText"));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.insets = new java.awt.Insets(4, 0, 0, 0);
    fc.add(newFolderButton, gridBagConstraints);

    separatorPanel.setLayout(new java.awt.BorderLayout());

    separatorPanel.setBackground(
        javax.swing.UIManager.getDefaults().getColor("Separator.foreground"));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.ipady = 1;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(14, 0, 0, 0);
    fc.add(separatorPanel, gridBagConstraints);

    formatPanel.setLayout(new java.awt.GridBagLayout());

    formatPanel2.setLayout(new java.awt.BorderLayout(2, 0));

    filesOfTypeLabel.setText(UIManager.getString("FileChooser.filesOfTypeLabelText"));
    formatPanel2.add(filesOfTypeLabel, java.awt.BorderLayout.WEST);

    formatPanel2.add(filterComboBox, java.awt.BorderLayout.CENTER);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.insets = new java.awt.Insets(0, 40, 0, 40);
    formatPanel.add(formatPanel2, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new java.awt.Insets(14, 0, 0, 0);
    fc.add(formatPanel, gridBagConstraints);

    accessoryPanel.setLayout(new java.awt.BorderLayout());

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 5;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.insets = new java.awt.Insets(14, 20, 0, 20);
    fc.add(accessoryPanel, gridBagConstraints);

    buttonPanel.setLayout(new java.awt.GridBagLayout());

    cancelButton.setText(UIManager.getString("FileChooser.cancelButtonText"));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(0, 18, 16, 0);
    buttonPanel.add(cancelButton, gridBagConstraints);

    approveButton.setText(UIManager.getString("FileChooser.openButtonText"));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.insets = new java.awt.Insets(0, 6, 16, 22);
    buttonPanel.add(approveButton, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridy = 6;
    gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.insets = new java.awt.Insets(14, 0, 0, 0);
    fc.add(buttonPanel, gridBagConstraints);

    add(fc, java.awt.BorderLayout.CENTER);
  } // </editor-fold>//GEN-END:initComponents
예제 #26
0
 public String getAnnotationType() {
   return UIManager.getString("PDFViewer.annot.Stamp");
 }
 public String getDisplayName() {
   return UIManager.getString("ColorChooser.rgbNameText");
 }
예제 #28
0
/** FileSystemView that handles some specific windows concepts. */
class WindowsFileSystemView extends FileSystemView {

  private static final String newFolderString = UIManager.getString("FileChooser.win32.newFolder");
  private static final String newFolderNextString =
      UIManager.getString("FileChooser.win32.newFolder.subsequent");

  public Boolean isTraversable(File f) {
    return Boolean.valueOf(isFileSystemRoot(f) || isComputerNode(f) || f.isDirectory());
  }

  public File getChild(File parent, String fileName) {
    if (fileName.startsWith("\\") && !fileName.startsWith("\\\\") && isFileSystem(parent)) {

      // Path is relative to the root of parent's drive
      String path = parent.getAbsolutePath();
      if (path.length() >= 2 && path.charAt(1) == ':' && Character.isLetter(path.charAt(0))) {

        return createFileObject(path.substring(0, 2) + fileName);
      }
    }
    return super.getChild(parent, fileName);
  }

  /**
   * Type description for a file, directory, or folder as it would be displayed in a system file
   * browser. Example from Windows: the "Desktop" folder is desribed as "Desktop".
   *
   * <p>The Windows implementation gets information from the ShellFolder class.
   */
  public String getSystemTypeDescription(File f) {
    if (f == null) {
      return null;
    }

    try {
      return getShellFolder(f).getFolderType();
    } catch (FileNotFoundException e) {
      return null;
    }
  }

  /** @return the Desktop folder. */
  public File getHomeDirectory() {
    return getRoots()[0];
  }

  /** Creates a new folder with a default folder name. */
  public File createNewFolder(File containingDir) throws IOException {
    if (containingDir == null) {
      throw new IOException("Containing directory is null:");
    }
    // Using NT's default folder name
    File newFolder = createFileObject(containingDir, newFolderString);
    int i = 2;
    while (newFolder.exists() && i < 100) {
      newFolder =
          createFileObject(
              containingDir, MessageFormat.format(newFolderNextString, new Integer(i)));
      i++;
    }

    if (newFolder.exists()) {
      throw new IOException("Directory already exists:" + newFolder.getAbsolutePath());
    } else {
      newFolder.mkdirs();
    }

    return newFolder;
  }

  public boolean isDrive(File dir) {
    return isFileSystemRoot(dir);
  }

  public boolean isFloppyDrive(final File dir) {
    String path =
        AccessController.doPrivileged(
            new PrivilegedAction<String>() {
              public String run() {
                return dir.getAbsolutePath();
              }
            });

    return path != null && (path.equals("A:\\") || path.equals("B:\\"));
  }

  /** Returns a File object constructed from the given path string. */
  public File createFileObject(String path) {
    // Check for missing backslash after drive letter such as "C:" or "C:filename"
    if (path.length() >= 2 && path.charAt(1) == ':' && Character.isLetter(path.charAt(0))) {
      if (path.length() == 2) {
        path += "\\";
      } else if (path.charAt(2) != '\\') {
        path = path.substring(0, 2) + "\\" + path.substring(2);
      }
    }
    return super.createFileObject(path);
  }

  protected File createFileSystemRoot(File f) {
    // Problem: Removable drives on Windows return false on f.exists()
    // Workaround: Override exists() to always return true.
    return new FileSystemRoot(f) {
      public boolean exists() {
        return true;
      }
    };
  }
}
예제 #29
0
  protected void installStrings(JFileChooser fc) {

    Locale l = fc.getLocale();
    newFolderErrorText = UIManager.getString("FileChooser.newFolderErrorText", l);
    newFolderErrorSeparator = UIManager.getString("FileChooser.newFolderErrorSeparator", l);

    newFolderParentDoesntExistTitleText =
        UIManager.getString("FileChooser.newFolderParentDoesntExistTitleText", l);
    newFolderParentDoesntExistText =
        UIManager.getString("FileChooser.newFolderParentDoesntExistText", l);

    fileDescriptionText = UIManager.getString("FileChooser.fileDescriptionText", l);
    directoryDescriptionText = UIManager.getString("FileChooser.directoryDescriptionText", l);

    saveButtonText = UIManager.getString("FileChooser.saveButtonText", l);
    openButtonText = UIManager.getString("FileChooser.openButtonText", l);
    saveDialogTitleText = UIManager.getString("FileChooser.saveDialogTitleText", l);
    openDialogTitleText = UIManager.getString("FileChooser.openDialogTitleText", l);
    cancelButtonText = UIManager.getString("FileChooser.cancelButtonText", l);
    updateButtonText = UIManager.getString("FileChooser.updateButtonText", l);
    helpButtonText = UIManager.getString("FileChooser.helpButtonText", l);
    directoryOpenButtonText = UIManager.getString("FileChooser.directoryOpenButtonText", l);

    saveButtonMnemonic = getMnemonic("FileChooser.saveButtonMnemonic", l);
    openButtonMnemonic = getMnemonic("FileChooser.openButtonMnemonic", l);
    cancelButtonMnemonic = getMnemonic("FileChooser.cancelButtonMnemonic", l);
    updateButtonMnemonic = getMnemonic("FileChooser.updateButtonMnemonic", l);
    helpButtonMnemonic = getMnemonic("FileChooser.helpButtonMnemonic", l);
    directoryOpenButtonMnemonic = getMnemonic("FileChooser.directoryOpenButtonMnemonic", l);

    saveButtonToolTipText = UIManager.getString("FileChooser.saveButtonToolTipText", l);
    openButtonToolTipText = UIManager.getString("FileChooser.openButtonToolTipText", l);
    cancelButtonToolTipText = UIManager.getString("FileChooser.cancelButtonToolTipText", l);
    updateButtonToolTipText = UIManager.getString("FileChooser.updateButtonToolTipText", l);
    helpButtonToolTipText = UIManager.getString("FileChooser.helpButtonToolTipText", l);
    directoryOpenButtonToolTipText =
        UIManager.getString("FileChooser.directoryOpenButtonToolTipText", l);
  }
예제 #30
0
/* http://jython.svn.sourceforge.net/viewvc/jython/branches/Release_2_2maint/installer/src/java/org/python/util/install/RestrictedFileSystemView.java?view=markup&pathrev=4161
 * licence: http://www.jython.org/Project/license.html
 * This FileSystemView only provides basic functionality (and probably a poor look & feel), but it can be a life saver
 * if otherwise no dialog pops up in your application.
 * <p>
 * The implementation does <strong>not</strong> use <code>sun.awt.shell.*</code> classes.
 *
 */
public class RestrictedFileSystemView extends FileSystemView {
  private static final String newFolderString = UIManager.getString("FileChooser.other.newFolder");

  private File _defaultDirectory;

  public RestrictedFileSystemView() {
    this(null);
  }

  public RestrictedFileSystemView(File defaultDirectory) {
    _defaultDirectory = defaultDirectory;
  }

  /**
   * Determines if the given file is a root in the navigatable tree(s).
   *
   * @param f a <code>File</code> object representing a directory
   * @return <code>true</code> if <code>f</code> is a root in the navigatable tree.
   * @see #isFileSystemRoot
   */
  public boolean isRoot(File f) {
    if (f == null || !f.isAbsolute()) {
      return false;
    }

    File[] roots = getRoots();
    for (int i = 0; i < roots.length; i++) {
      if (roots[i].equals(f)) {
        return true;
      }
    }
    return false;
  }

  /**
   * Returns true if the file (directory) can be visited. Returns false if the directory cannot be
   * traversed.
   *
   * @param f the <code>File</code>
   * @return <code>true</code> if the file/directory can be traversed, otherwise <code>false</code>
   * @see JFileChooser#isTraversable
   * @see FileView#isTraversable
   */
  public Boolean isTraversable(File f) {
    return Boolean.valueOf(f.isDirectory());
  }

  /**
   * Name of a file, directory, or folder as it would be displayed in a system file browser
   *
   * @param f a <code>File</code> object
   * @return the file name as it would be displayed by a native file chooser
   * @see JFileChooser#getName
   */
  public String getSystemDisplayName(File f) {
    String name = null;
    if (f != null) {
      if (isRoot(f)) {
        name = f.getAbsolutePath();
      } else {
        name = f.getName();
      }
    }
    return name;
  }

  /**
   * Type description for a file, directory, or folder as it would be displayed in a system file
   * browser.
   *
   * @param f a <code>File</code> object
   * @return the file type description as it would be displayed by a native file chooser or null if
   *     no native information is available.
   * @see JFileChooser#getTypeDescription
   */
  public String getSystemTypeDescription(File f) {
    return null;
  }

  /**
   * Icon for a file, directory, or folder as it would be displayed in a system file browser.
   *
   * @param f a <code>File</code> object
   * @return an icon as it would be displayed by a native file chooser, null if not available
   * @see JFileChooser#getIcon
   */
  public Icon getSystemIcon(File f) {
    if (f != null) {
      return UIManager.getIcon(f.isDirectory() ? "FileView.directoryIcon" : "FileView.fileIcon");
    } else {
      return null;
    }
  }

  /**
   * @param folder a <code>File</code> object repesenting a directory
   * @param file a <code>File</code> object
   * @return <code>true</code> if <code>folder</code> is a directory and contains <code>file</code>.
   */
  public boolean isParent(File folder, File file) {
    if (folder == null || file == null) {
      return false;
    } else {
      return folder.equals(file.getParentFile());
    }
  }

  /**
   * @param parent a <code>File</code> object repesenting a directory
   * @param fileName a name of a file or folder which exists in <code>parent</code>
   * @return a File object. This is normally constructed with <code>new
   * File(parent, fileName)</code>.
   */
  public File getChild(File parent, String fileName) {
    return createFileObject(parent, fileName);
  }

  /**
   * Checks if <code>f</code> represents a real directory or file as opposed to a special folder
   * such as <code>"Desktop"</code>. Used by UI classes to decide if a folder is selectable when
   * doing directory choosing.
   *
   * @param f a <code>File</code> object
   * @return <code>true</code> if <code>f</code> is a real file or directory.
   */
  public boolean isFileSystem(File f) {
    return true;
  }

  /** Returns whether a file is hidden or not. */
  public boolean isHiddenFile(File f) {
    return f.isHidden();
  }

  /**
   * Is dir the root of a tree in the file system, such as a drive or partition.
   *
   * @param f a <code>File</code> object representing a directory
   * @return <code>true</code> if <code>f</code> is a root of a filesystem
   * @see #isRoot
   */
  public boolean isFileSystemRoot(File dir) {
    return isRoot(dir);
  }

  /**
   * Used by UI classes to decide whether to display a special icon for drives or partitions, e.g. a
   * "hard disk" icon.
   *
   * <p>The default implementation has no way of knowing, so always returns false.
   *
   * @param dir a directory
   * @return <code>false</code> always
   */
  public boolean isDrive(File dir) {
    return false;
  }

  /**
   * Used by UI classes to decide whether to display a special icon for a floppy disk. Implies
   * isDrive(dir).
   *
   * <p>The default implementation has no way of knowing, so always returns false.
   *
   * @param dir a directory
   * @return <code>false</code> always
   */
  public boolean isFloppyDrive(File dir) {
    return false;
  }

  /**
   * Used by UI classes to decide whether to display a special icon for a computer node, e.g. "My
   * Computer" or a network server.
   *
   * <p>The default implementation has no way of knowing, so always returns false.
   *
   * @param dir a directory
   * @return <code>false</code> always
   */
  public boolean isComputerNode(File dir) {
    return false;
  }

  /**
   * Returns all root partitions on this system. For example, on Windows, this would be the
   * "Desktop" folder, while on DOS this would be the A: through Z: drives.
   */
  public File[] getRoots() {
    return File.listRoots();
  }

  // Providing default implementations for the remaining methods
  // because most OS file systems will likely be able to use this
  // code. If a given OS can't, override these methods in its
  // implementation.

  public File getHomeDirectory() {
    return createFileObject(System.getProperty("user.home"));
  }

  /**
   * Return the user's default starting directory for the file chooser.
   *
   * @return a <code>File</code> object representing the default starting folder
   */
  public File getDefaultDirectory() {
    if (_defaultDirectory == null) {
      try {
        File tempFile = File.createTempFile("filesystemview", "restricted");
        tempFile.deleteOnExit();
        _defaultDirectory = tempFile.getParentFile();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
    return _defaultDirectory;
  }

  /** Returns a File object constructed in dir from the given filename. */
  public File createFileObject(File dir, String filename) {
    if (dir == null) {
      return new File(filename);
    } else {
      return new File(dir, filename);
    }
  }

  /** Returns a File object constructed from the given path string. */
  public File createFileObject(String path) {
    File f = new File(path);
    if (isFileSystemRoot(f)) {
      f = createFileSystemRoot(f);
    }
    return f;
  }

  /** Gets the list of shown (i.e. not hidden) files. */
  public File[] getFiles(File dir, boolean useFileHiding) {
    Vector<File> files = new Vector<File>();

    // add all files in dir
    File[] names;
    names = dir.listFiles();
    File f;

    int nameCount = (names == null) ? 0 : names.length;
    for (int i = 0; i < nameCount; i++) {
      if (Thread.currentThread().isInterrupted()) {
        break;
      }
      f = names[i];
      if (!useFileHiding || !isHiddenFile(f)) {
        files.addElement(f);
      }
    }

    return (File[]) files.toArray(new File[files.size()]);
  }

  /**
   * Returns the parent directory of <code>dir</code>.
   *
   * @param dir the <code>File</code> being queried
   * @return the parent directory of <code>dir</code>, or <code>null</code> if <code>dir</code> is
   *     <code>null</code>
   */
  public File getParentDirectory(File dir) {
    if (dir != null && dir.exists()) {
      File psf = dir.getParentFile();
      if (psf != null) {
        if (isFileSystem(psf)) {
          File f = psf;
          if (f != null && !f.exists()) {
            // This could be a node under "Network Neighborhood".
            File ppsf = psf.getParentFile();
            if (ppsf == null || !isFileSystem(ppsf)) {
              // We're mostly after the exists() override for
              // windows below.
              f = createFileSystemRoot(f);
            }
          }
          return f;
        } else {
          return psf;
        }
      }
    }
    return null;
  }

  /**
   * Creates a new <code>File</code> object for <code>f</code> with correct behavior for a file
   * system root directory.
   *
   * @param f a <code>File</code> object representing a file system root directory, for example "/"
   *     on Unix or "C:\" on Windows.
   * @return a new <code>File</code> object
   */
  protected File createFileSystemRoot(File f) {
    return new FileSystemRoot(f);
  }

  static class FileSystemRoot extends File {
    private static final long serialVersionUID = 1L;

    public FileSystemRoot(File f) {
      super(f, "");
    }

    public FileSystemRoot(String s) {
      super(s);
    }

    public boolean isDirectory() {
      return true;
    }

    public String getName() {
      return getPath();
    }
  }

  public File createNewFolder(File containingDir) throws IOException {
    if (containingDir == null) {
      throw new IOException("Containing directory is null:");
    }
    File newFolder = null;
    newFolder = createFileObject(containingDir, newFolderString);
    int i = 2;
    while (newFolder.exists() && (i < 100)) {
      newFolder =
          createFileObject(
              containingDir, MessageFormat.format(newFolderString, new Object[] {new Integer(i)}));
      i++;
    }

    if (newFolder.exists()) {
      throw new IOException("Directory already exists:" + newFolder.getAbsolutePath());
    } else {
      newFolder.mkdirs();
    }

    return newFolder;
  }
}