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 void updateButtons() { int index = list.getSelectedIndex(); remove.setEnabled(index != -1 && listModel.getSize() != 0); moveUp.setEnabled(index > 0); moveDown.setEnabled(index != -1 && index != listModel.getSize() - 1); edit.setEnabled(index != -1); }
private void updateEnabled() { combo.setEnabled(action.isSelected()); list.setEnabled(action.isSelected()); boolean iconControlsEnabled = !separator.isSelected(); builtin.setEnabled(iconControlsEnabled); file.setEnabled(iconControlsEnabled); builtinCombo.setEnabled(iconControlsEnabled && builtin.isSelected()); fileButton.setEnabled(iconControlsEnabled && file.isSelected()); }
private void updatePreview() { String family = familyField.getText(); int size; try { size = Integer.parseInt(sizeField.getText()); } catch (Exception e) { size = 12; } int style = styleList.getSelectedIndex(); preview.setFont(new Font(family, style, size)); }
private void updateList() { ActionSet actionSet = (ActionSet) combo.getSelectedItem(); EditAction[] actions = actionSet.getActions(); Vector listModel = new Vector(actions.length); for (int i = 0; i < actions.length; i++) { EditAction action = actions[i]; String label = action.getLabel(); if (label == null) continue; listModel.addElement(new ToolBarOptionPane.Button(action.getName(), null, null, label)); } MiscUtilities.quicksort(listModel, new ToolBarOptionPane.ButtonCompare()); list.setListData(listModel); }
private void init(Font font) { JPanel content = new JPanel(new BorderLayout()); content.setBorder(new EmptyBorder(12, 12, 12, 12)); setContentPane(content); JPanel listPanel = new JPanel(new GridLayout(1, 3, 6, 6)); String[] fonts; try { fonts = getFontList(); } catch (Exception e) { Log.log(Log.ERROR, this, "Broken Java implementation!"); Log.log(Log.ERROR, this, e); fonts = new String[] {"Broken Java implementation!"}; } JPanel familyPanel = createTextFieldAndListPanel( "font-selector.family", familyField = new JTextField(), familyList = new JList(fonts)); listPanel.add(familyPanel); String[] sizes = {"9", "10", "12", "14", "16", "18", "24"}; JPanel sizePanel = createTextFieldAndListPanel( "font-selector.size", sizeField = new JTextField(), sizeList = new JList(sizes)); listPanel.add(sizePanel); String[] styles = { jEdit.getProperty("font-selector.plain"), jEdit.getProperty("font-selector.bold"), jEdit.getProperty("font-selector.italic"), jEdit.getProperty("font-selector.bolditalic") }; JPanel stylePanel = createTextFieldAndListPanel( "font-selector.style", styleField = new JTextField(), styleList = new JList(styles)); styleField.setEditable(false); listPanel.add(stylePanel); familyList.setSelectedValue(font.getFamily(), true); familyField.setText(font.getFamily()); sizeList.setSelectedValue(String.valueOf(font.getSize()), true); sizeField.setText(String.valueOf(font.getSize())); styleList.setSelectedIndex(font.getStyle()); styleField.setText((String) styleList.getSelectedValue()); ListHandler listHandler = new ListHandler(); familyList.addListSelectionListener(listHandler); sizeList.addListSelectionListener(listHandler); styleList.addListSelectionListener(listHandler); content.add(BorderLayout.NORTH, listPanel); preview = new JLabel(jEdit.getProperty("font-selector.long-text")) { public void paintComponent(Graphics g) { if (fontSelector != null) fontSelector.setAntiAliasEnabled(g); super.paintComponent(g); } }; preview.setBorder(new TitledBorder(jEdit.getProperty("font-selector.preview"))); updatePreview(); Dimension prefSize = preview.getPreferredSize(); prefSize.height = 50; preview.setPreferredSize(prefSize); content.add(BorderLayout.CENTER, preview); 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 ActionHandler()); getRootPane().setDefaultButton(ok); buttons.add(ok); buttons.add(Box.createHorizontalStrut(6)); cancel = new JButton(jEdit.getProperty("common.cancel")); cancel.addActionListener(new ActionHandler()); buttons.add(cancel); buttons.add(Box.createGlue()); content.add(BorderLayout.SOUTH, buttons); pack(); setLocationRelativeTo(getParent()); setVisible(true); }
@Override protected void processKeyEvent(KeyEvent evt) { if (evt.getID() == KeyEvent.KEY_PRESSED) { ActionContext ac = VFSBrowser.getActionContext(); int row = parentDirectories.getSelectedIndex(); switch (evt.getKeyCode()) { case KeyEvent.VK_DOWN: evt.consume(); if (row < parentDirectories.getSize().height - 1) parentDirectories.setSelectedIndex(++row); break; case KeyEvent.VK_LEFT: if ((evt.getModifiers() & InputEvent.ALT_MASK) > 0) { evt.consume(); browser.previousDirectory(); } else super.processEvent(evt); break; case KeyEvent.VK_RIGHT: if ((evt.getModifiers() & InputEvent.ALT_MASK) > 0) { evt.consume(); browser.nextDirectory(); } else super.processEvent(evt); break; case KeyEvent.VK_TAB: evt.consume(); if ((evt.getModifiers() & InputEvent.SHIFT_MASK) > 0) browser.focusOnDefaultComponent(); else table.requestFocus(); break; case KeyEvent.VK_UP: evt.consume(); if (row > 0) { parentDirectories.setSelectedIndex(--row); } break; case KeyEvent.VK_BACK_SPACE: evt.consume(); EditAction up = ac.getAction("vfs.browser.up"); ac.invokeAction(evt, up); break; case KeyEvent.VK_F5: evt.consume(); EditAction reload = ac.getAction("vfs.browser.reload"); ac.invokeAction(evt, reload); break; case KeyEvent.VK_ENTER: evt.consume(); if (row != -1) { // basically the same handling as in ParentMouseHandler#mouseReleased Object obj = parentDirectories.getModel().getElementAt(row); if (obj instanceof VFSFile) { VFSFile dirEntry = (VFSFile) obj; browser.setDirectory(dirEntry.getPath()); if (browser.getMode() == VFSBrowser.BROWSER) focusOnFileView(); } } break; /* These actions don't work because they look at the EntryTable for the current selected * item. We need actions that look at the parentDirectoryList item instead. * case KeyEvent.VK_DELETE: evt.consume(); ea = ac.getAction("vfs.browser.delete"); ac.invokeAction(evt, ea); break; case KeyEvent.CTRL_MASK | KeyEvent.VK_N: evt.consume(); ea = ac.getAction("vfs.browser.new-file"); ac.invokeAction(evt, ea); break; case KeyEvent.VK_INSERT: evt.consume(); ea = ac.getAction("vfs.browser.new-directory"); ac.invokeAction(evt, ea); break; */ } } else if (evt.getID() == KeyEvent.KEY_TYPED) { if (evt.isControlDown() || evt.isAltDown() || evt.isMetaDown()) { evt.consume(); return; } switch (evt.getKeyChar()) { case '~': evt.consume(); if (browser.getMode() == VFSBrowser.BROWSER) browser.setDirectory(System.getProperty("user.home")); break; case '/': evt.consume(); if (browser.getMode() == VFSBrowser.BROWSER) browser.rootDirectory(); break; case '-': evt.consume(); if (browser.getMode() == VFSBrowser.BROWSER) { browser.setDirectory(browser.getView().getBuffer().getDirectory()); } break; } } if (!evt.isConsumed()) super.processKeyEvent(evt); }
public void processKeyEvent(KeyEvent evt) { super.processKeyEvent(evt); }