Exemplo 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();
  }
  private JPanel createContentPanel() {
    // compute content and other buttons
    SpringLayout springLayout = new SpringLayout();
    JPanel panel = new JPanel(springLayout);
    int panelHeight = 0;
    JTable propertiesPanel = createPropertiesPanel();
    panelHeight += propertiesPanel.getPreferredSize().getHeight();
    panel.add(propertiesPanel);
    panelHeight += 10;
    panel.add(Box.createVerticalStrut(10));
    JScrollPane scrollPane = new JScrollPane(createAdaptersPanel());
    panelHeight += scrollPane.getPreferredSize().getHeight();
    panel.add(scrollPane);
    panelHeight += 10;
    panel.add(Box.createVerticalStrut(10));
    JPanel buttonsPanel = createButtonsPanel();
    panelHeight += buttonsPanel.getPreferredSize().getHeight();
    panel.add(buttonsPanel);

    springLayout.putConstraint(
        SpringLayout.NORTH, panel, DEFAULT_PADDING, SpringLayout.NORTH, propertiesPanel);
    springLayout.putConstraint(
        SpringLayout.WEST, panel, DEFAULT_PADDING, SpringLayout.WEST, propertiesPanel);
    springLayout.putConstraint(
        SpringLayout.EAST, panel, DEFAULT_PADDING, SpringLayout.EAST, propertiesPanel);
    springLayout.putConstraint(
        SpringLayout.NORTH, scrollPane, DEFAULT_PADDING, SpringLayout.SOUTH, propertiesPanel);
    springLayout.putConstraint(
        SpringLayout.WEST, panel, DEFAULT_PADDING, SpringLayout.WEST, scrollPane);
    springLayout.putConstraint(
        SpringLayout.EAST, panel, DEFAULT_PADDING, SpringLayout.EAST, scrollPane);
    springLayout.putConstraint(
        SpringLayout.NORTH, scrollPane, DEFAULT_PADDING, SpringLayout.SOUTH, buttonsPanel);
    springLayout.putConstraint(
        SpringLayout.WEST, panel, DEFAULT_PADDING, SpringLayout.WEST, buttonsPanel);
    springLayout.putConstraint(
        SpringLayout.EAST, panel, DEFAULT_PADDING, SpringLayout.EAST, buttonsPanel);

    panel.setPreferredSize(
        new Dimension(
            CHECK_COLUMN_WIDTH + LABEL_COLUMN_WIDTH + COLUMN_WIDTH - 32,
            panelHeight + DEFAULT_PADDING));
    makeCompactGrid(panel, 5, 1, 0, 0, 0, 0);
    return panel;
  }
  private void initialize() {
    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    JLabel label =
        new JLabel(
            "It is up to you whether or not to include the source when you distribute your robot.");

    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(label);

    label =
        new JLabel(
            "If you include the source, other people will be able to look at your code and learn from it.");
    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(label);

    getIncludeSource().setAlignmentX(Component.LEFT_ALIGNMENT);
    add(getIncludeSource());

    label = new JLabel(" ");
    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(label);

    add(getVersionLabel());

    JPanel p = new JPanel();

    p.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    p.setAlignmentX(Component.LEFT_ALIGNMENT);
    getVersionField().setAlignmentX(Component.LEFT_ALIGNMENT);
    getVersionField().setMaximumSize(getVersionField().getPreferredSize());
    p.setMaximumSize(new Dimension(Integer.MAX_VALUE, getVersionField().getPreferredSize().height));
    p.add(getVersionField());
    p.add(getVersionHelpLabel());
    add(p);

    label = new JLabel(" ");
    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(label);

    add(getDescriptionLabel());

    JScrollPane scrollPane =
        new JScrollPane(
            getDescriptionArea(),
            ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);

    scrollPane.setMaximumSize(scrollPane.getPreferredSize());
    scrollPane.setMinimumSize(new Dimension(100, scrollPane.getPreferredSize().height));
    scrollPane.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(scrollPane);

    label = new JLabel(" ");
    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(label);

    add(getAuthorLabel());

    getAuthorField().setAlignmentX(Component.LEFT_ALIGNMENT);
    getAuthorField().setMaximumSize(getAuthorField().getPreferredSize());
    add(getAuthorField());

    label = new JLabel(" ");
    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(label);

    add(getWebpageLabel());

    getWebpageField().setAlignmentX(Component.LEFT_ALIGNMENT);
    getWebpageField().setMaximumSize(getWebpageField().getPreferredSize());
    add(getWebpageField());

    getWebpageHelpLabel().setAlignmentX(Component.LEFT_ALIGNMENT);
    add(getWebpageHelpLabel());

    JPanel panel = new JPanel();

    panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(panel);
    addComponentListener(eventHandler);
  }
Exemplo n.º 4
0
  // {{{ HyperSearchResults constructor
  public HyperSearchResults(View view) {
    super(new BorderLayout());

    this.view = view;

    caption = new JLabel();

    Box toolBar = new Box(BoxLayout.X_AXIS);
    toolBar.add(caption);
    toolBar.add(Box.createGlue());

    ActionHandler ah = new ActionHandler();

    highlight = new RolloverButton();
    highlight.setToolTipText(jEdit.getProperty("hypersearch-results.highlight.label"));
    highlight.addActionListener(ah);
    toolBar.add(highlight);

    clear =
        new RolloverButton(
            GUIUtilities.loadIcon(jEdit.getProperty("hypersearch-results.clear.icon")));
    clear.setToolTipText(jEdit.getProperty("hypersearch-results.clear.label"));
    clear.addActionListener(ah);
    toolBar.add(clear);

    multi = new RolloverButton();
    multi.setToolTipText(jEdit.getProperty("hypersearch-results.multi.label"));
    multi.addActionListener(ah);
    toolBar.add(multi);

    stop =
        new RolloverButton(
            GUIUtilities.loadIcon(jEdit.getProperty("hypersearch-results.stop.icon")));
    stop.setToolTipText(jEdit.getProperty("hypersearch-results.stop.label"));
    stop.addActionListener(ah);
    toolBar.add(stop);
    stop.setEnabled(false);

    add(BorderLayout.NORTH, toolBar);

    resultTreeRoot = new DefaultMutableTreeNode();
    resultTreeModel = new DefaultTreeModel(resultTreeRoot);
    resultTree = new HighlightingTree(resultTreeModel);
    resultTree.setToolTipText(null);
    resultTree.setCellRenderer(new ResultCellRenderer());
    resultTree.setVisibleRowCount(16);
    resultTree.setRootVisible(false);
    resultTree.setShowsRootHandles(true);
    // the ESCAPE keystroke is assigned to hideTip action by swing
    // it breaks the action usually assigned to close-docking-area by jEdit,
    // so we remove this keystroke binding bug #1955140
    KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    resultTree.getInputMap().remove(keyStroke);
    // looks bad with the OS X L&F, apparently...
    if (!OperatingSystem.isMacOSLF()) resultTree.putClientProperty("JTree.lineStyle", "Angled");

    resultTree.setEditable(false);

    resultTree.addKeyListener(new KeyHandler());
    resultTree.addMouseListener(new MouseHandler());

    JScrollPane scrollPane = new JScrollPane(resultTree);
    Dimension dim = scrollPane.getPreferredSize();
    dim.width = 400;
    scrollPane.setPreferredSize(dim);
    add(BorderLayout.CENTER, scrollPane);
    resultTree.setTransferHandler(new ResultTreeTransferHandler());
  } // }}}