Esempio n. 1
0
  public AboutDialog(View view) {
    super(view, jEdit.getProperty("about.title"), true);

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

    content.add(BorderLayout.CENTER, new AboutPanel());

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
    buttonPanel.setBorder(new EmptyBorder(12, 0, 0, 0));

    buttonPanel.add(Box.createGlue());
    close = new JButton(jEdit.getProperty("common.close"));
    close.addActionListener(new ActionHandler());
    getRootPane().setDefaultButton(close);
    buttonPanel.add(close);
    buttonPanel.add(Box.createGlue());
    content.add(BorderLayout.SOUTH, buttonPanel);

    pack();
    setResizable(false);
    setLocationRelativeTo(view);
    show();
  }
Esempio n. 2
0
    private JTextField addField(JPanel directoryPanel, String label, String defaultText) {
      JTextField field = new JTextField(defaultText);

      directoryPanel.add(new JLabel(label, SwingConstants.RIGHT));

      Box fieldBox = new Box(BoxLayout.Y_AXIS);
      fieldBox.add(Box.createGlue());
      Dimension dim = field.getPreferredSize();
      dim.width = Integer.MAX_VALUE;
      field.setMaximumSize(dim);
      fieldBox.add(field);
      fieldBox.add(Box.createGlue());
      directoryPanel.add(fieldBox);
      JButton choose = new JButton("Choose...");
      choose.setRequestFocusEnabled(false);
      choose.addActionListener(new ActionHandler(field));
      directoryPanel.add(choose);

      return field;
    }
  public PasteSpecialDialog(View view, TextArea textArea) {
    super(view, jEdit.getProperty("paste-special.title"), true);
    this.textArea = textArea;
    JPanel content = new JPanel(new BorderLayout());
    content.setBorder(new EmptyBorder(12, 12, 12, 12));
    setContentPane(content);
    Registers.Register register = Registers.getRegister('$');
    Transferable transferable = register.getTransferable();
    DataFlavor[] flavors = transferable.getTransferDataFlavors();
    List<DataFlavor> flavorList = Arrays.asList(flavors);
    Vector<DataFlavor> supportedFlavors = new Vector<DataFlavor>(this.flavors.length);
    for (DataFlavor flavor : this.flavors) {
      if (flavorList.contains(flavor)) {
        supportedFlavors.add(flavor);
      }
    }
    this.flavorList = new JList(supportedFlavors);
    this.flavorList.setCellRenderer(
        new DefaultListCellRenderer() {
          @Override
          public Component getListCellRendererComponent(
              JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            if (value.equals(DataFlavor.stringFlavor)) {
              setText("Plain text");
            } else if (value.equals(JEditDataFlavor.jEditRichTextDataFlavor)) {
              setText("jEdit rich text");
            } else if (value.equals(JEditDataFlavor.html)) {
              setText("html");
            }
            return this;
          }
        });
    getContentPane().add(new JScrollPane(this.flavorList));

    // {{{ Buttons

    JPanel buttons = new JPanel();
    buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS));
    buttons.setBorder(new EmptyBorder(12, 0, 0, 0));
    buttons.add(Box.createGlue());

    ok = new JButton(jEdit.getProperty("common.ok"));
    ok.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            ok();
          }
        });
    getRootPane().setDefaultButton(ok);
    buttons.add(ok);

    buttons.add(Box.createHorizontalStrut(6));

    cancel = new JButton(jEdit.getProperty("common.cancel"));
    cancel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            cancel();
          }
        });
    buttons.add(cancel);

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

    // }}}

    pack();
    setLocationRelativeTo(view);
    setVisible(true);
  }
Esempio n. 4
0
  public static JToolBar getToolbar(String label, int size, boolean hasStrings) {
    JToolBar toolBar = new JToolBar();

    JButton buttonCut = new JButton(hasStrings ? "cut" : null, getIcon(size + "/edit-cut"));
    buttonCut.putClientProperty(SubstanceLookAndFeel.BUTTON_NO_MIN_SIZE_PROPERTY, Boolean.TRUE);
    toolBar.add(buttonCut);
    JButton buttonCopy = new JButton(hasStrings ? "copy" : null, getIcon(size + "/edit-copy"));
    buttonCopy.putClientProperty(SubstanceLookAndFeel.BUTTON_NO_MIN_SIZE_PROPERTY, Boolean.TRUE);
    buttonCopy.setEnabled(false);
    toolBar.add(buttonCopy);
    JButton buttonPaste = new JButton(getIcon(size + "/edit-paste"));
    toolBar.add(buttonPaste);
    JButton buttonSelectAll = new JButton(getIcon(size + "/edit-select-all"));
    toolBar.add(buttonSelectAll);
    JButton buttonDelete = new JButton(getIcon(size + "/edit-delete"));
    toolBar.add(buttonDelete);
    toolBar.addSeparator();

    // add an inner toolbar to check the painting of toolbar
    // gradient and drop shadows under different skins.
    JToolBar innerToolbar = new JToolBar(JToolBar.HORIZONTAL);
    innerToolbar.setFloatable(false);
    JToggleButton buttonFormatCenter = new JToggleButton(getIcon(size + "/format-justify-center"));
    buttonFormatCenter.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 5.0f);
    innerToolbar.add(buttonFormatCenter);
    JToggleButton buttonFormatLeft = new JToggleButton(getIcon(size + "/format-justify-left"));
    innerToolbar.add(buttonFormatLeft);
    JToggleButton buttonFormatRight = new JToggleButton(getIcon(size + "/format-justify-right"));
    innerToolbar.add(buttonFormatRight);
    JToggleButton buttonFormatFill = new JToggleButton(getIcon(size + "/format-justify-fill"));
    buttonFormatFill.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 0.0f);
    innerToolbar.add(buttonFormatFill);

    toolBar.add(innerToolbar);
    toolBar.addSeparator();

    if (size > 20) {
      JToolBar innerToolbar2 = new JToolBar(JToolBar.HORIZONTAL);
      innerToolbar2.setFloatable(false);

      JPanel innerPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
      innerToolbar2.add(innerPanel, BorderLayout.CENTER);

      final JToggleButton buttonStyleBold = new JToggleButton(getIcon(size + "/format-text-bold"));
      Set<Side> rightSide = EnumSet.of(Side.RIGHT);
      buttonStyleBold.putClientProperty(SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, rightSide);
      buttonStyleBold.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 3.0f);

      final JToggleButton buttonStyleItalic =
          new JToggleButton(getIcon(size + "/format-text-italic"));
      buttonStyleItalic.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 0.0f);
      buttonStyleItalic.putClientProperty(
          SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, rightSide);

      final JToggleButton buttonStyleUnderline =
          new JToggleButton(getIcon(size + "/format-text-underline"));
      buttonStyleUnderline.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 0.0f);
      buttonStyleUnderline.putClientProperty(
          SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, rightSide);

      final JToggleButton buttonStyleStrikethrough =
          new JToggleButton(getIcon(size + "/format-text-strikethrough"));
      buttonStyleStrikethrough.putClientProperty(
          SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY, EnumSet.of(Side.LEFT));
      buttonStyleStrikethrough.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 3.0f);
      buttonStyleBold.setSelected(true);

      innerPanel.add(buttonStyleBold);
      innerPanel.add(buttonStyleItalic);
      innerPanel.add(buttonStyleUnderline);
      innerPanel.add(buttonStyleStrikethrough);

      toolBar.add(innerToolbar2);
    }

    toolBar.add(Box.createGlue());
    JButton buttonExit = new JButton(getIcon(size + "/process-stop"));
    buttonExit.setToolTipText("Closes the test application");
    buttonExit.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            System.exit(0);
          }
        });
    toolBar.add(buttonExit);

    return toolBar;
  }
Esempio n. 5
0
  // {{{ InstallPanel constructor
  InstallPanel(PluginManager window, boolean updates) {
    super(new BorderLayout(12, 12));

    this.window = window;
    this.updates = updates;

    setBorder(new EmptyBorder(12, 12, 12, 12));

    final JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    split.setResizeWeight(0.75);
    /* Setup the table */
    table = new JTable(pluginModel = new PluginTableModel());
    table.setShowGrid(false);
    table.setIntercellSpacing(new Dimension(0, 0));
    table.setRowHeight(table.getRowHeight() + 2);
    table.setPreferredScrollableViewportSize(new Dimension(500, 200));
    table.setDefaultRenderer(
        Object.class,
        new TextRenderer((DefaultTableCellRenderer) table.getDefaultRenderer(Object.class)));
    table.addFocusListener(new TableFocusHandler());
    InputMap tableInputMap = table.getInputMap(JComponent.WHEN_FOCUSED);
    ActionMap tableActionMap = table.getActionMap();
    tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "tabOutForward");
    tableActionMap.put("tabOutForward", new KeyboardAction(KeyboardCommand.TAB_OUT_FORWARD));
    tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK), "tabOutBack");
    tableActionMap.put("tabOutBack", new KeyboardAction(KeyboardCommand.TAB_OUT_BACK));
    tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "editPlugin");
    tableActionMap.put("editPlugin", new KeyboardAction(KeyboardCommand.EDIT_PLUGIN));
    tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "closePluginManager");
    tableActionMap.put(
        "closePluginManager", new KeyboardAction(KeyboardCommand.CLOSE_PLUGIN_MANAGER));

    TableColumn col1 = table.getColumnModel().getColumn(0);
    TableColumn col2 = table.getColumnModel().getColumn(1);
    TableColumn col3 = table.getColumnModel().getColumn(2);
    TableColumn col4 = table.getColumnModel().getColumn(3);
    TableColumn col5 = table.getColumnModel().getColumn(4);

    col1.setPreferredWidth(30);
    col1.setMinWidth(30);
    col1.setMaxWidth(30);
    col1.setResizable(false);

    col2.setPreferredWidth(180);
    col3.setPreferredWidth(130);
    col4.setPreferredWidth(70);
    col5.setPreferredWidth(70);

    JTableHeader header = table.getTableHeader();
    header.setReorderingAllowed(false);
    header.addMouseListener(new HeaderMouseHandler());
    header.setDefaultRenderer(
        new HeaderRenderer((DefaultTableCellRenderer) header.getDefaultRenderer()));

    scrollpane = new JScrollPane(table);
    scrollpane.getViewport().setBackground(table.getBackground());
    split.setTopComponent(scrollpane);

    /* Create description */
    JScrollPane infoPane = new JScrollPane(infoBox = new PluginInfoBox());
    infoPane.setPreferredSize(new Dimension(500, 100));
    split.setBottomComponent(infoPane);

    EventQueue.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            split.setDividerLocation(0.75);
          }
        });

    final JTextField searchField = new JTextField();
    searchField.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_UP) {
              table.dispatchEvent(e);
              table.requestFocus();
            }
          }
        });
    searchField
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              void update() {
                pluginModel.setFilterString(searchField.getText());
              }

              @Override
              public void changedUpdate(DocumentEvent e) {
                update();
              }

              @Override
              public void insertUpdate(DocumentEvent e) {
                update();
              }

              @Override
              public void removeUpdate(DocumentEvent e) {
                update();
              }
            });
    table.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            int i = table.getSelectedRow(), n = table.getModel().getRowCount();
            if (e.getKeyCode() == KeyEvent.VK_DOWN && i == (n - 1)
                || e.getKeyCode() == KeyEvent.VK_UP && i == 0) {
              searchField.requestFocus();
              searchField.selectAll();
            }
          }
        });
    Box filterBox = Box.createHorizontalBox();
    filterBox.add(new JLabel("Filter : "));
    filterBox.add(searchField);
    add(BorderLayout.NORTH, filterBox);
    add(BorderLayout.CENTER, split);

    /* Create buttons */
    Box buttons = new Box(BoxLayout.X_AXIS);

    buttons.add(new InstallButton());
    buttons.add(Box.createHorizontalStrut(12));
    buttons.add(new SelectallButton());
    buttons.add(chooseButton = new ChoosePluginSet());
    buttons.add(new ClearPluginSet());
    buttons.add(Box.createGlue());
    buttons.add(new SizeLabel());

    add(BorderLayout.SOUTH, buttons);
    String path = jEdit.getProperty(PluginManager.PROPERTY_PLUGINSET, "");
    if (!path.isEmpty()) {
      loadPluginSet(path);
    }
  } // }}}
  public ToolBarEditDialog(
      Component comp, DefaultComboBoxModel iconListModel, ToolBarOptionPane.Button current) {
    super(
        GUIUtilities.getParentDialog(comp), jEdit.getProperty("options.toolbar.edit.title"), true);

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

    ActionHandler actionHandler = new ActionHandler();
    ButtonGroup grp = new ButtonGroup();

    JPanel typePanel = new JPanel(new GridLayout(3, 1, 6, 6));
    typePanel.setBorder(new EmptyBorder(0, 0, 6, 0));
    typePanel.add(new JLabel(jEdit.getProperty("options.toolbar.edit.caption")));

    separator = new JRadioButton(jEdit.getProperty("options.toolbar" + ".edit.separator"));
    separator.addActionListener(actionHandler);
    grp.add(separator);
    typePanel.add(separator);

    action = new JRadioButton(jEdit.getProperty("options.toolbar" + ".edit.action"));
    action.addActionListener(actionHandler);
    grp.add(action);
    typePanel.add(action);

    content.add(BorderLayout.NORTH, typePanel);

    JPanel actionPanel = new JPanel(new BorderLayout(6, 6));

    ActionSet[] actionsList = jEdit.getActionSets();
    Vector vec = new Vector(actionsList.length);
    for (int i = 0; i < actionsList.length; i++) {
      ActionSet actionSet = actionsList[i];
      if (actionSet.getActionCount() != 0) vec.addElement(actionSet);
    }
    combo = new JComboBox(vec);
    combo.addActionListener(actionHandler);
    actionPanel.add(BorderLayout.NORTH, combo);

    list = new JList();
    list.setVisibleRowCount(8);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    actionPanel.add(BorderLayout.CENTER, new JScrollPane(list));

    JPanel iconPanel = new JPanel(new BorderLayout(0, 3));
    JPanel labelPanel = new JPanel(new GridLayout(2, 1));
    labelPanel.setBorder(new EmptyBorder(0, 0, 0, 12));
    JPanel compPanel = new JPanel(new GridLayout(2, 1));
    grp = new ButtonGroup();
    labelPanel.add(builtin = new JRadioButton(jEdit.getProperty("options.toolbar.edit.builtin")));
    builtin.addActionListener(actionHandler);
    grp.add(builtin);
    labelPanel.add(file = new JRadioButton(jEdit.getProperty("options.toolbar.edit.file")));
    grp.add(file);
    file.addActionListener(actionHandler);
    iconPanel.add(BorderLayout.WEST, labelPanel);
    builtinCombo = new JComboBox(iconListModel);
    builtinCombo.setRenderer(new ToolBarOptionPane.IconCellRenderer());
    compPanel.add(builtinCombo);

    fileButton = new JButton(jEdit.getProperty("options.toolbar.edit.no-icon"));
    fileButton.setMargin(new Insets(1, 1, 1, 1));
    fileButton.setIcon(GUIUtilities.loadIcon("Blank24.gif"));
    fileButton.setHorizontalAlignment(SwingConstants.LEFT);
    fileButton.addActionListener(actionHandler);
    compPanel.add(fileButton);
    iconPanel.add(BorderLayout.CENTER, compPanel);
    actionPanel.add(BorderLayout.SOUTH, iconPanel);

    content.add(BorderLayout.CENTER, actionPanel);

    JPanel southPanel = new JPanel();
    southPanel.setLayout(new BoxLayout(southPanel, BoxLayout.X_AXIS));
    southPanel.setBorder(new EmptyBorder(12, 0, 0, 0));
    southPanel.add(Box.createGlue());
    ok = new JButton(jEdit.getProperty("common.ok"));
    ok.addActionListener(actionHandler);
    getRootPane().setDefaultButton(ok);
    southPanel.add(ok);
    southPanel.add(Box.createHorizontalStrut(6));
    cancel = new JButton(jEdit.getProperty("common.cancel"));
    cancel.addActionListener(actionHandler);
    southPanel.add(cancel);
    southPanel.add(Box.createGlue());

    content.add(BorderLayout.SOUTH, southPanel);

    if (current == null) {
      action.setSelected(true);
      builtin.setSelected(true);
      updateList();
    } else {
      if (current.actionName.equals("-")) {
        separator.setSelected(true);
        builtin.setSelected(true);
      } else {
        action.setSelected(true);
        ActionSet set = jEdit.getActionSetForAction(current.actionName);
        combo.setSelectedItem(set);
        updateList();
        list.setSelectedValue(current, true);

        if (MiscUtilities.isURL(current.iconName)) {
          file.setSelected(true);
          fileIcon = current.iconName;
          try {
            fileButton.setIcon(new ImageIcon(new URL(fileIcon)));
          } catch (MalformedURLException mf) {
            Log.log(Log.ERROR, this, mf);
          }
          fileButton.setText(MiscUtilities.getFileName(fileIcon));
        } else {
          String iconName = MiscUtilities.getFileName(current.iconName);
          builtin.setSelected(true);
          ListModel model = builtinCombo.getModel();
          for (int i = 0; i < model.getSize(); i++) {
            ToolBarOptionPane.IconListEntry entry =
                (ToolBarOptionPane.IconListEntry) model.getElementAt(i);
            if (entry.name.equals(iconName)) {
              builtinCombo.setSelectedIndex(i);
              break;
            }
          }
        }
      }
    }

    updateEnabled();

    pack();
    setLocationRelativeTo(GUIUtilities.getParentDialog(comp));
    show();
  }
  protected void _init() {
    setLayout(new BorderLayout());

    JPanel panel = new JPanel(new GridLayout(2, 1));

    showToolbar = new JCheckBox(jEdit.getProperty("options.toolbar.showToolbar"));
    showToolbar.setSelected(jEdit.getBooleanProperty("view.showToolbar"));
    panel.add(showToolbar);

    panel.add(new JLabel(jEdit.getProperty("options.toolbar.caption")));

    add(BorderLayout.NORTH, panel);

    String toolbar = jEdit.getProperty("view.toolbar");
    StringTokenizer st = new StringTokenizer(toolbar);
    listModel = new DefaultListModel();
    while (st.hasMoreTokens()) {
      String actionName = (String) st.nextToken();
      if (actionName.equals("-"))
        listModel.addElement(new ToolBarOptionPane.Button("-", null, null, "-"));
      else {
        EditAction action = jEdit.getAction(actionName);
        if (action == null) continue;
        String label = action.getLabel();
        if (label == null) continue;

        Icon icon;
        String iconName;
        if (actionName.equals("-")) {
          iconName = null;
          icon = null;
        } else {
          iconName = jEdit.getProperty(actionName + ".icon");
          if (iconName == null) icon = GUIUtilities.loadIcon("BrokenImage.png");
          else {
            icon = GUIUtilities.loadIcon(iconName);
            if (icon == null) icon = GUIUtilities.loadIcon("BrokenImage.png");
          }
        }
        listModel.addElement(new Button(actionName, iconName, icon, label));
      }
    }

    list = new JList(listModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.addListSelectionListener(new ListHandler());
    list.setCellRenderer(new ButtonCellRenderer());

    add(BorderLayout.CENTER, new JScrollPane(list));

    JPanel buttons = new JPanel();
    buttons.setBorder(new EmptyBorder(3, 0, 0, 0));
    buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS));
    ActionHandler actionHandler = new ActionHandler();
    add = new RolloverButton(GUIUtilities.loadIcon("Plus.png"));
    add.setToolTipText(jEdit.getProperty("options.toolbar.add"));
    add.addActionListener(actionHandler);
    buttons.add(add);
    buttons.add(Box.createHorizontalStrut(6));
    remove = new RolloverButton(GUIUtilities.loadIcon("Minus.png"));
    remove.setToolTipText(jEdit.getProperty("options.toolbar.remove"));
    remove.addActionListener(actionHandler);
    buttons.add(remove);
    buttons.add(Box.createHorizontalStrut(6));
    moveUp = new RolloverButton(GUIUtilities.loadIcon("ArrowU.png"));
    moveUp.setToolTipText(jEdit.getProperty("options.toolbar.moveUp"));
    moveUp.addActionListener(actionHandler);
    buttons.add(moveUp);
    buttons.add(Box.createHorizontalStrut(6));
    moveDown = new RolloverButton(GUIUtilities.loadIcon("ArrowD.png"));
    moveDown.setToolTipText(jEdit.getProperty("options.toolbar.moveDown"));
    moveDown.addActionListener(actionHandler);
    buttons.add(moveDown);
    buttons.add(Box.createHorizontalStrut(6));
    edit = new RolloverButton(GUIUtilities.loadIcon("ButtonProperties.png"));
    edit.setToolTipText(jEdit.getProperty("options.toolbar.edit"));
    edit.addActionListener(actionHandler);
    buttons.add(edit);
    buttons.add(Box.createGlue());

    updateButtons();
    add(BorderLayout.SOUTH, buttons);

    iconList = new DefaultComboBoxModel();
    st = new StringTokenizer(jEdit.getProperty("icons"));
    while (st.hasMoreElements()) {
      String icon = st.nextToken();
      iconList.addElement(new IconListEntry(GUIUtilities.loadIcon(icon), icon));
    }
  }
Esempio n. 8
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());
  } // }}}
  public void installComponents(JFileChooser fc) {
    fc.setLayout(new BorderLayout(10, 10));
    fc.setAlignmentX(JComponent.CENTER_ALIGNMENT);

    JPanel interior =
        new JPanel() {
          public Insets getInsets() {
            return insets;
          }
        };
    align(interior);
    interior.setLayout(new BoxLayout(interior, BoxLayout.PAGE_AXIS));

    fc.add(interior, BorderLayout.CENTER);

    // PENDING(jeff) - I18N
    JLabel l = new JLabel(pathLabelText);
    l.setDisplayedMnemonic(pathLabelMnemonic);
    align(l);
    interior.add(l);

    File currentDirectory = fc.getCurrentDirectory();
    String curDirName = null;
    if (currentDirectory != null) {
      curDirName = currentDirectory.getPath();
    }
    pathField =
        new JTextField(curDirName) {
          public Dimension getMaximumSize() {
            Dimension d = super.getMaximumSize();
            d.height = getPreferredSize().height;
            return d;
          }
        };
    l.setLabelFor(pathField);
    align(pathField);

    // Change to folder on return
    pathField.addActionListener(getUpdateAction());
    interior.add(pathField);

    interior.add(Box.createRigidArea(vstrut10));

    // CENTER: left, right accessory
    JPanel centerPanel = new JPanel();
    centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.LINE_AXIS));
    align(centerPanel);

    // left panel - Filter & folderList
    JPanel leftPanel = new JPanel();
    leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.PAGE_AXIS));
    align(leftPanel);

    // add the filter PENDING(jeff) - I18N
    l = new JLabel(filterLabelText);
    l.setDisplayedMnemonic(filterLabelMnemonic);
    align(l);
    leftPanel.add(l);

    filterComboBox =
        new JComboBox() {
          public Dimension getMaximumSize() {
            Dimension d = super.getMaximumSize();
            d.height = getPreferredSize().height;
            return d;
          }
        };
    l.setLabelFor(filterComboBox);
    filterComboBoxModel = createFilterComboBoxModel();
    filterComboBox.setModel(filterComboBoxModel);
    filterComboBox.setRenderer(createFilterComboBoxRenderer());
    fc.addPropertyChangeListener(filterComboBoxModel);
    align(filterComboBox);
    leftPanel.add(filterComboBox);

    // leftPanel.add(Box.createRigidArea(vstrut10));

    // Add the Folder List PENDING(jeff) - I18N
    l = new JLabel(foldersLabelText);
    l.setDisplayedMnemonic(foldersLabelMnemonic);
    align(l);
    leftPanel.add(l);
    JScrollPane sp = createDirectoryList();
    sp.getVerticalScrollBar().setFocusable(false);
    sp.getHorizontalScrollBar().setFocusable(false);
    l.setLabelFor(sp.getViewport().getView());
    leftPanel.add(sp);

    // create files list
    JPanel rightPanel = new JPanel();
    align(rightPanel);
    rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.PAGE_AXIS));

    l = new JLabel(filesLabelText);
    l.setDisplayedMnemonic(filesLabelMnemonic);
    align(l);
    rightPanel.add(l);
    sp = createFilesList();
    l.setLabelFor(sp);
    rightPanel.add(sp);

    centerPanel.add(leftPanel);
    centerPanel.add(Box.createRigidArea(hstrut10));
    centerPanel.add(rightPanel);

    JComponent accessoryPanel = getAccessoryPanel();
    JComponent accessory = fc.getAccessory();
    if (accessoryPanel != null) {
      if (accessory == null) {
        accessoryPanel.setPreferredSize(ZERO_ACC_SIZE);
        accessoryPanel.setMaximumSize(ZERO_ACC_SIZE);
      } else {
        getAccessoryPanel().add(accessory, BorderLayout.CENTER);
        accessoryPanel.setPreferredSize(PREF_ACC_SIZE);
        accessoryPanel.setMaximumSize(MAX_SIZE);
      }
      align(accessoryPanel);
      centerPanel.add(accessoryPanel);
    }
    interior.add(centerPanel);
    interior.add(Box.createRigidArea(vstrut10));

    // add the filename field PENDING(jeff) - I18N
    l = new JLabel(enterFileNameLabelText);
    l.setDisplayedMnemonic(enterFileNameLabelMnemonic);
    align(l);
    interior.add(l);

    filenameTextField =
        new JTextField() {
          public Dimension getMaximumSize() {
            Dimension d = super.getMaximumSize();
            d.height = getPreferredSize().height;
            return d;
          }
        };
    l.setLabelFor(filenameTextField);
    filenameTextField.addActionListener(getApproveSelectionAction());
    align(filenameTextField);
    filenameTextField.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    interior.add(filenameTextField);

    bottomPanel = getBottomPanel();
    bottomPanel.add(new JSeparator(), BorderLayout.NORTH);

    // Add buttons
    JPanel buttonPanel = new JPanel();
    align(buttonPanel);
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
    buttonPanel.add(Box.createGlue());

    approveButton =
        new JButton(getApproveButtonText(fc)) {
          public Dimension getMaximumSize() {
            return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
          }
        };
    approveButton.setMnemonic(getApproveButtonMnemonic(fc));
    approveButton.setToolTipText(getApproveButtonToolTipText(fc));
    align(approveButton);
    approveButton.setMargin(buttonMargin);
    approveButton.addActionListener(getApproveSelectionAction());
    buttonPanel.add(approveButton);
    buttonPanel.add(Box.createGlue());

    JButton updateButton =
        new JButton(updateButtonText) {
          public Dimension getMaximumSize() {
            return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
          }
        };
    updateButton.setMnemonic(updateButtonMnemonic);
    updateButton.setToolTipText(updateButtonToolTipText);
    align(updateButton);
    updateButton.setMargin(buttonMargin);
    updateButton.addActionListener(getUpdateAction());
    buttonPanel.add(updateButton);
    buttonPanel.add(Box.createGlue());

    JButton cancelButton =
        new JButton(cancelButtonText) {
          public Dimension getMaximumSize() {
            return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
          }
        };
    cancelButton.setMnemonic(cancelButtonMnemonic);
    cancelButton.setToolTipText(cancelButtonToolTipText);
    align(cancelButton);
    cancelButton.setMargin(buttonMargin);
    cancelButton.addActionListener(getCancelSelectionAction());
    buttonPanel.add(cancelButton);
    buttonPanel.add(Box.createGlue());

    JButton helpButton =
        new JButton(helpButtonText) {
          public Dimension getMaximumSize() {
            return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
          }
        };
    helpButton.setMnemonic(helpButtonMnemonic);
    helpButton.setToolTipText(helpButtonToolTipText);
    align(helpButton);
    helpButton.setMargin(buttonMargin);
    helpButton.setEnabled(false);
    buttonPanel.add(helpButton);
    buttonPanel.add(Box.createGlue());

    bottomPanel.add(buttonPanel, BorderLayout.SOUTH);
    if (fc.getControlButtonsAreShown()) {
      fc.add(bottomPanel, BorderLayout.SOUTH);
    }
  }
Esempio n. 10
0
  /** Construct the toolbar panel. */
  protected JPanel getToolbar() {
    JPanel toolbar = new JPanel();

    getExecuteButton().setText("Execute*");
    getExecuteButton()
        .addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                removeStatsTabs();
                execute();
              }
            });

    JButton statsButton = new JButton("Calc Stats");
    statsButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Window owner = (Window) getTopLevelAncestor();

            new WatchedProcess(owner) {
              public void watch() {
                calcStats();
              }
            };
          }
        });

    Box b1 = Box.createVerticalBox();
    b1.add(getParamsPanel());
    b1.add(Box.createVerticalStrut(10));

    Box b2 = Box.createHorizontalBox();
    b2.add(Box.createGlue());
    b2.add(getExecuteButton());
    b1.add(b2);
    b1.add(Box.createVerticalStrut(10));

    if (getAlgorithmRunner().getDataModel() instanceof DataSet) {
      Box b3 = Box.createHorizontalBox();
      b3.add(Box.createGlue());
      b3.add(statsButton);
      b1.add(b3);
    }

    //        if (getAlgorithmRunner().getParams() instanceof MeekSearchParams) {
    //            MeekSearchParams params = (MeekSearchParams) getAlgorithmRunner().getParams();
    //            JCheckBox preventCycles = new JCheckBox("Aggressively Prevent Cycles");
    //            preventCycles.setHorizontalTextPosition(AbstractButton.RIGHT);
    //            preventCycles.setSelected(params.isAggressivelyPreventCycles());
    //
    //            preventCycles.addActionListener(new ActionListener() {
    //                public void actionPerformed(ActionEvent e) {
    //                    JCheckBox box = (JCheckBox) e.getSource();
    //                    MeekSearchParams params = (MeekSearchParams)
    // getAlgorithmRunner().getParams();
    //                    params.setAggressivelyPreventCycles(box.isSelected());
    //                }
    //            });
    //
    //            b1.add(Box.createVerticalStrut(5));
    //            Box hBox = Box.createHorizontalBox();
    //            hBox.add(Box.createHorizontalGlue());
    //            hBox.add(preventCycles);
    //            b1.add(hBox);
    //            b1.add(Box.createVerticalStrut(5));
    //        }

    Box b4 = Box.createHorizontalBox();
    JLabel label =
        new JLabel(
            "<html>"
                + "*Please note that some"
                + "<br>searches may take a"
                + "<br>long time to complete."
                + "</html>");
    label.setHorizontalAlignment(SwingConstants.CENTER);
    label.setVerticalAlignment(SwingConstants.CENTER);
    label.setBorder(new TitledBorder(""));
    b4.add(label);

    b1.add(Box.createVerticalStrut(10));
    b1.add(b4);

    toolbar.add(b1);
    return toolbar;
  }