Ejemplo n.º 1
0
  public ErrorListDialog(
      Frame frame, String title, String caption, Vector messages, boolean showPluginMgrButton) {
    super(frame, title, true);

    JPanel content = new JPanel(new BorderLayout(12, 12));
    content.setBorder(new EmptyBorder(12, 12, 12, 12));
    setContentPane(content);

    Box iconBox = new Box(BoxLayout.Y_AXIS);
    iconBox.add(new JLabel(UIManager.getIcon("OptionPane.errorIcon")));
    iconBox.add(Box.createGlue());
    content.add(BorderLayout.WEST, iconBox);

    JPanel centerPanel = new JPanel(new BorderLayout());

    JLabel label = new JLabel(caption);
    label.setBorder(new EmptyBorder(0, 0, 6, 0));
    centerPanel.add(BorderLayout.NORTH, label);

    JList errors = new JList(messages);
    errors.setCellRenderer(new ErrorListCellRenderer());
    errors.setVisibleRowCount(Math.min(messages.size(), 4));

    JScrollPane scrollPane =
        new JScrollPane(
            errors, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    Dimension size = scrollPane.getPreferredSize();
    size.width = Math.min(size.width, 400);
    scrollPane.setPreferredSize(size);

    centerPanel.add(BorderLayout.CENTER, scrollPane);

    content.add(BorderLayout.CENTER, centerPanel);

    Box buttons = new Box(BoxLayout.X_AXIS);
    buttons.add(Box.createGlue());

    ok = new JButton(jEdit.getProperty("common.ok"));
    ok.addActionListener(new ActionHandler());

    if (showPluginMgrButton) {
      pluginMgr = new JButton(jEdit.getProperty("error-list.plugin-manager"));
      pluginMgr.addActionListener(new ActionHandler());
      buttons.add(pluginMgr);
      buttons.add(Box.createHorizontalStrut(6));
    }

    buttons.add(ok);

    buttons.add(Box.createGlue());
    content.add(BorderLayout.SOUTH, buttons);

    getRootPane().setDefaultButton(ok);

    pack();
    setLocationRelativeTo(frame);
    show();
  }
Ejemplo n.º 2
0
  /**
   * Returns the file name component of the specified path.
   *
   * @param path The path
   * @since jEdit 3.1pre4
   */
  public String getFileName(String path) {
    if (path.equals("/")) return path;

    while (path.endsWith("/") || path.endsWith(File.separator))
      path = path.substring(0, path.length() - 1);

    int index = Math.max(path.lastIndexOf('/'), path.lastIndexOf(File.separatorChar));
    if (index == -1) index = path.indexOf(':');

    // don't want getFileName("roots:") to return ""
    if (index == -1 || index == path.length() - 1) return path;

    return path.substring(index + 1);
  } // }}}
Ejemplo n.º 3
0
  /**
   * Returns the parent of the specified path. This must be overridden to return a non-null value
   * for browsing of this filesystem to work.
   *
   * @param path The path
   * @since jEdit 2.6pre5
   */
  public String getParentOfPath(String path) {
    // ignore last character of path to properly handle
    // paths like /foo/bar/
    int lastIndex = path.length() - 1;
    while (lastIndex > 0
        && (path.charAt(lastIndex) == File.separatorChar || path.charAt(lastIndex) == '/')) {
      lastIndex--;
    }

    int count = Math.max(0, lastIndex);
    int index = path.lastIndexOf(File.separatorChar, count);
    if (index == -1) index = path.lastIndexOf('/', count);
    if (index == -1) {
      // this ensures that getFileParent("protocol:"), for
      // example, is "protocol:" and not "".
      index = path.lastIndexOf(':');
    }

    return path.substring(0, index + 1);
  } // }}}
Ejemplo n.º 4
0
    AboutPanel() {
      setFont(UIManager.getFont("Label.font"));
      fm = getFontMetrics(getFont());

      setForeground(new Color(96, 96, 96));
      image = new ImageIcon(getClass().getResource("/org/gjt/sp/jedit/icons/about.png"));

      setBorder(new MatteBorder(1, 1, 1, 1, Color.gray));

      text = new Vector(50);
      StringTokenizer st = new StringTokenizer(jEdit.getProperty("about.text"), "\n");
      while (st.hasMoreTokens()) {
        String line = st.nextToken();
        text.addElement(line);
        maxWidth = Math.max(maxWidth, fm.stringWidth(line) + 10);
      }

      scrollPosition = -250;

      thread = new AnimationThread();
    }