Ejemplo 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();
  }
Ejemplo n.º 2
0
  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);
  }
Ejemplo n.º 3
0
  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));
    }
  }
Ejemplo n.º 4
0
  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();
  }
  /** Constructor. Sets up and shows the GUI */
  public TextToolsSortDialog(View view, JEditTextArea textArea) {
    super(view, jEdit.getProperty("text-tools.sortadvanced.label"), false);

    this.view = view;
    this.textArea = textArea;
    //		this.data = data;
    //		this.selection = selection;

    view.showWaitCursor();

    sortTableModel = new SortTableModel();

    // preset sortTable if there is a rect selection
    boolean rectSel = false;
    int[] selRows = TextToolsSorting.getRectSelectionRows(textArea);
    if (selRows != null) {
      // we have rectangular selection: assign values to 1st row of table
      sortTableModel.setValueAt(new Integer(selRows[0] + 1), 0, 0);
      sortTableModel.setValueAt(new Integer(selRows[1] + 1), 0, 1);
      rectSel = true;
    }

    sortTable = new JTable(sortTableModel);
    TableColumnModel cMod = sortTable.getColumnModel();
    sortTable.setTableHeader((new SortTableHeader(cMod)));
    sortTable.setRowHeight(25);

    sortTable.setPreferredScrollableViewportSize(new Dimension(430, 200));

    JScrollPane scroll = new JScrollPane(sortTable);

    JPanel content = new JPanel(new BorderLayout());
    content.setBorder(new EmptyBorder(5, 8, 8, 8));
    content.setLayout(new BorderLayout());
    setContentPane(content);
    content.add(scroll, BorderLayout.CENTER);

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

    ok = new JButton(jEdit.getProperty("common.ok"));
    ok.addActionListener(this);
    buttons.add(ok);
    buttons.add(Box.createHorizontalStrut(6));
    getRootPane().setDefaultButton(ok);

    cancel = new JButton(jEdit.getProperty("common.cancel"));
    cancel.addActionListener(this);
    buttons.add(cancel);
    buttons.add(Box.createHorizontalStrut(6));

    clear = new JButton("Clear");
    clear.addActionListener(this);
    buttons.add(clear);
    buttons.add(Box.createHorizontalStrut(6));

    help = new JButton("Help");
    help.addActionListener(this);
    buttons.add(help);
    buttons.add(Box.createHorizontalStrut(6));

    buttons.add(Box.createGlue());

    content.add(buttons, BorderLayout.SOUTH);

    delDupsCheckBox =
        new JCheckBox(jEdit.getProperty("text-tools.sortadvanced.delete-identic-lines"));
    onlySelectionCheckBox =
        new JCheckBox(jEdit.getProperty("text-tools.sortadvanced.sort-only-selection"));

    /*
    dontSortCheckBox = new JCheckBox(
    	jEdit.getProperty("text-tools.sortadvanced.dont-sort"));
    delDupsCheckBox.addActionListener(new java.awt.event.ActionListener() {
    	public void actionPerformed(ActionEvent e) {
    		dontSortCheckBox.setEnabled(delDupsCheckBox.isSelected());
    		dontSortCheckBox.setSelected(false);
    	}
    });
    dontSortCheckBox.setEnabled(false);
    */
    JPanel checkBoxes = new JPanel();
    if (rectSel) checkBoxes.add(onlySelectionCheckBox);
    checkBoxes.add(delDupsCheckBox);
    // checkBoxes.add(dontSortCheckBox);  not used, this is an extra action
    content.add(checkBoxes, BorderLayout.NORTH);
    view.hideWaitCursor();
    pack();
    GUIUtilities.loadGeometry(this, "texttools-sort-control");
    setLocationRelativeTo(view);
    setVisible(true);
  } // }}}