private String getNoSelectionString(Resource.Kind resourceKind) {
   String key;
   if (resourceKind != null) key = "ArgumentComponent." + resourceKind.name();
   else key = "";
   return Messages.format(
       "ArgumentComponent.NO_SELECTION", Messages.getString(key)); // $NON-NLS-1$
 }
 public void actionPerformed(ActionEvent ev) {
   super.actionPerformed(ev);
   String com = ev.getActionCommand();
   if (com.equals("GameInformationFrame.LOAD")) // $NON-NLS-1$
   {
     tabs.setSelectedIndex(0);
     loadFromFile();
   }
   if (com.equals("GameInformationFrame.FILESAVE")) // $NON-NLS-1$
   {
     tabs.setSelectedIndex(0);
     saveToFile();
     return;
   }
   if (com.equals("GameInformationFrame.FONTCOLOR")) // $NON-NLS-1$
   {
     String colorStr = Messages.getString("GameInformationFrame.FONTCOLOR"); // $NON-NLS-1$
     Color c = JColorChooser.showDialog(this, colorStr, fgColor);
     if (c != null) {
       fgColor = c;
       setSelectionAttribute(StyleConstants.Foreground, c);
     }
     return;
   }
   if (com.equals("GameInformationFrame.COLOR")) // $NON-NLS-1$
   {
     String colorStr = Messages.getString("GameInformationFrame.COLOR"); // $NON-NLS-1$
     Color c = JColorChooser.showDialog(this, colorStr, editor.getBackground());
     if (c != null) setEditorBackground(c);
     return;
   }
   if (com.equals("GameInformationFrame.CUT")) // $NON-NLS-1$
   {
     editor.cut();
     return;
   }
   if (com.equals("GameInformationFrame.COPY")) // $NON-NLS-1$
   {
     editor.copy();
     return;
   }
   if (com.equals("GameInformationFrame.PASTE")) // $NON-NLS-1$
   {
     editor.paste();
     return;
   }
   if (com.equals("GameInformationFrame.SELECTALL")) // $NON-NLS-1$
   {
     editor.selectAll();
     return;
   }
 }
 public JMenuItem addItem(String key) {
   JMenuItem item = new JMenuItem(Messages.getString(key));
   item.setIcon(LGM.getIconForKey(key));
   item.setActionCommand(key);
   item.addActionListener(this);
   return item;
 }
 public Object getUserObject() {
   if (node != null) return node.getUserObject();
   for (int m = 0; m < LGM.root.getChildCount(); m++) {
     ResNode n = (ResNode) LGM.root.getChildAt(m);
     if (n.kind == GameInformation.class) return n.getUserObject();
   }
   return Messages.getString("LGM.GMI"); // $NON-NLS-1$
 }
 public JToggleButton addToggleButton(String key) {
   JToggleButton item = new JToggleButton();
   item.setToolTipText(Messages.getString(key));
   item.setIcon(LGM.getIconForKey(key));
   item.setActionCommand(key);
   item.addActionListener(this);
   return item;
 }
  private JMenuBar makeMenuBar() {
    JMenuBar menuBar = new JMenuBar();

    // File
    JMenu menu = new JMenu(Messages.getString("GameInformationFrame.MENU_FILE")); // $NON-NLS-1$
    menuBar.add(menu);
    menu.addActionListener(this);

    JMenuItem item = addItem("GameInformationFrame.LOAD"); // $NON-NLS-1$
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_DOWN_MASK));
    menu.add(item);
    item = addItem("GameInformationFrame.FILESAVE"); // $NON-NLS-1$
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_DOWN_MASK));
    menu.add(item);
    menu.addSeparator();
    item = addItem("GameInformationFrame.CLOSESAVE"); // $NON-NLS-1$
    menu.add(item);

    // Edit
    menu = new JMenu(Messages.getString("GameInformationFrame.MENU_EDIT")); // $NON-NLS-1$
    menuBar.add(menu);

    item = new JMenuItem(undoManager.getUndoAction());
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, KeyEvent.CTRL_DOWN_MASK));
    menu.add(item);
    item = new JMenuItem(undoManager.getRedoAction());
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Y, KeyEvent.CTRL_DOWN_MASK));
    menu.add(item);
    menu.addSeparator();
    item = addItem("GameInformationFrame.CUT"); // $NON-NLS-1$
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, KeyEvent.CTRL_DOWN_MASK));
    menu.add(item);
    item = addItem("GameInformationFrame.COPY"); // $NON-NLS-1$
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_DOWN_MASK));
    menu.add(item);
    item = addItem("GameInformationFrame.PASTE"); // $NON-NLS-1$
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.CTRL_DOWN_MASK));
    menu.add(item);
    menu.addSeparator();
    item = addItem("GameInformationFrame.SELECTALL"); // $NON-NLS-1$
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_DOWN_MASK));
    menu.add(item);

    return menuBar;
  }
 public void loadFromFile() {
   fc.setDialogTitle(Messages.getString("GameInformationFrame.LOAD_TITLE")); // $NON-NLS-1$
   while (true) {
     if (fc.showOpenDialog(LGM.frame) != JFileChooser.APPROVE_OPTION) return;
     if (fc.getSelectedFile().exists()) break;
     JOptionPane.showMessageDialog(
         null,
         fc.getSelectedFile().getName()
             + Messages.getString("SoundFrame.FILE_MISSING"), // $NON-NLS-1$
         Messages.getString("GameInformationFrame.LOAD_TITLE"), // $NON-NLS-1$
         JOptionPane.WARNING_MESSAGE);
   }
   try {
     FileInputStream i = new FileInputStream(fc.getSelectedFile());
     editor.setText(""); // $NON-NLS-1$
     rtf.read(i, editor.getDocument(), 0);
     i.close();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
    public SettingsFrame() {
      super();
      setAlwaysOnTop(true);
      setDefaultCloseOperation(HIDE_ON_CLOSE);
      setLocationRelativeTo(LGM.getGameInfo());

      setTitle(Messages.getString("GameInformationFrame.SETTINGS"));
      setIconImage(LGM.getIconForKey("GameInformationFrame.SETTINGS").getImage());
      setResizable(false);
      this.setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE);
      this.add(makeSettings());
      pack();
    }
 public void saveToFile() {
   fc.setDialogTitle(Messages.getString("GameInformationFrame.SAVE_TITLE")); // $NON-NLS-1$
   if (fc.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) return;
   String name = fc.getSelectedFile().getPath();
   if (CustomFileFilter.getExtension(name) == null) name += ".rtf"; // $NON-NLS-1$
   try {
     FileOutputStream i = new FileOutputStream(new File(name));
     rtf.write(i, editor.getDocument(), 0, 0);
     i.close();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
  public GameInformationFrame(GameInformation res, ResNode node) {
    super(res, node, Messages.getString("GameInformationFrame.TITLE"), true); // $NON-NLS-1$
    setDefaultCloseOperation(HIDE_ON_CLOSE);
    setSize(600, 400);

    menubar = makeMenuBar();
    setJMenuBar(menubar);
    toolbar = makeToolBar();
    add(toolbar, BorderLayout.NORTH);
    fgColor = Color.BLACK;

    tabs = new JTabbedPane();
    add(tabs, BorderLayout.CENTER);
    tabs.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            boolean enabled = tabs.getSelectedIndex() == 0;
            if (enabled) editor.requestFocusInWindow();
            JMenuBar mb = getJMenuBar();
            for (int i = 0; i < mb.getComponentCount(); i++) {
              JMenu m = (JMenu) mb.getComponent(i);
              if (!m.getText()
                  .equals(Messages.getString("GameInformationFrame.MENU_FILE"))) // $NON-NLS-1$
              m.setEnabled(enabled);
            }
            for (int i = 0; i < toolbar.getComponentCount(); i++) {
              Component c = toolbar.getComponent(i);
              if (c != save) c.setEnabled(enabled);
            }
          }
        });

    editor = new JEditorPane();
    editor.setEditorKit(rtf);
    setFocusTraversalPolicy(new TextAreaFocusTraversalPolicy(editor));

    addDocumentListeners();
    editor.addCaretListener(undoManager);

    editor.addCaretListener(
        new CaretListener() {
          public void caretUpdate(CaretEvent ce) {
            fFamilyChange = true;
            fSizeChange = true;
            StyledDocument d = (StyledDocument) editor.getDocument();
            int dot = ce.getDot();
            if (ce.getMark() <= dot) dot--;
            AttributeSet as = d.getCharacterElement(dot).getAttributes();
            String f = StyleConstants.getFontFamily(as);
            fgColor = StyleConstants.getForeground(as);
            int s = StyleConstants.getFontSize(as);
            boolean b = StyleConstants.isBold(as);
            boolean i = StyleConstants.isItalic(as);
            boolean u = StyleConstants.isUnderline(as);
            cbFonts.setSelectedItem(f);
            sSizes.setValue(s);
            tbBold.setSelected(b);
            tbItalic.setSelected(i);
            tbUnderline.setSelected(u);
          }
        });

    tabs.addTab(
        Messages.getString("GameInformationFrame.TAB_INFO"), // $NON-NLS-1$
        /**/ null,
        new JScrollPane(editor),
        Messages.getString("GameInformationFrame.HINT_INFO")); // $NON-NLS-1$
    tabs.addTab(
        Messages.getString("GameInformationFrame.TAB_SETTINGS"), // $NON-NLS-1$
        /**/ null,
        makeSettings(),
        Messages.getString("GameInformationFrame.HINT_SETTINGS")); // $NON-NLS-1$
    revertResource();

    fc = new CustomFileChooser("/org/lateralgm", "LAST_GAMEINFO_DIR"); // $NON-NLS-1$ //$NON-NLS-2$
    fc.setFileFilter(
        new CustomFileFilter(
            Messages.getString("GameInformationFrame.TYPE_RTF"),
            ".rtf")); //$NON-NLS-1$ //$NON-NLS-2$
  }
  private JPanel makeSettings() {
    JPanel p = new JPanel();
    GroupLayout gl = new GroupLayout(p);
    p.setLayout(gl);
    gl.setAutoCreateGaps(true);
    gl.setAutoCreateContainerGaps(true);

    JLabel lTitle =
        new JLabel(Messages.getString("GameInformationFrame.WINDOW_TITLE")); // $NON-NLS-1$
    sTitle = new JTextField();
    plf.make(sTitle.getDocument(), PGameInformation.FORM_CAPTION);

    JPanel position = new JPanel();
    position.setBorder(
        BorderFactory.createTitledBorder(
            /**/ Messages.getString("GameInformationFrame.POSITION"))); // $NON-NLS-1$
    GroupLayout pl = new GroupLayout(position);
    position.setLayout(pl);
    pl.setAutoCreateGaps(true);
    pl.setAutoCreateContainerGaps(true);

    JLabel lX = new JLabel(Messages.getString("GameInformationFrame.X")); // $NON-NLS-1$
    JLabel lY = new JLabel(Messages.getString("GameInformationFrame.Y")); // $NON-NLS-1$
    JLabel lWidth = new JLabel(Messages.getString("GameInformationFrame.WIDTH")); // $NON-NLS-1$
    JLabel lHeight = new JLabel(Messages.getString("GameInformationFrame.HEIGHT")); // $NON-NLS-1$
    sX = new NumberField(0);
    sY = new NumberField(0);
    sWidth = new NumberField(0);
    sHeight = new NumberField(0);
    plf.make(sX, PGameInformation.LEFT);
    plf.make(sY, PGameInformation.TOP);
    plf.make(sWidth, PGameInformation.WIDTH);
    plf.make(sHeight, PGameInformation.HEIGHT);

    sShowBorder =
        new JCheckBox(Messages.getString("GameInformationFrame.SHOW_BORDER")); // $NON-NLS-1$
    sAllowResize =
        new JCheckBox(Messages.getString("GameInformationFrame.RESIZABLE")); // $NON-NLS-1$
    sAlwaysOnTop =
        new JCheckBox(Messages.getString("GameInformationFrame.ALWAYS_ON_TOP")); // $NON-NLS-1$
    sPauseGame = new JCheckBox(Messages.getString("GameInformationFrame.PAUSE")); // $NON-NLS-1$
    sEmbed = new JCheckBox(Messages.getString("GameInformationFrame.EMBED")); // $NON-NLS-1$

    plf.make(sShowBorder, PGameInformation.SHOW_BORDER);
    plf.make(sAllowResize, PGameInformation.ALLOW_RESIZE);
    plf.make(sAlwaysOnTop, PGameInformation.STAY_ON_TOP);
    plf.make(sPauseGame, PGameInformation.PAUSE_GAME);
    plf.make(sEmbed, PGameInformation.MIMIC_GAME_WINDOW);

    pl.setHorizontalGroup(
        pl.createSequentialGroup()

            /**/ .addGroup(
                pl.createParallelGroup(Alignment.TRAILING)
                    /*		*/ .addComponent(lX)
                    /*		*/ .addComponent(lWidth))
            /**/ .addGroup(
                pl.createParallelGroup()/*		*/ .addComponent(sX)/*		*/ .addComponent(sWidth))
            /**/ .addGroup(
                pl.createParallelGroup(Alignment.TRAILING)
                    /*		*/ .addComponent(lY)
                    /*		*/ .addComponent(lHeight))
            /**/ .addGroup(
                pl.createParallelGroup()/*		*/ .addComponent(sY)/*		*/ .addComponent(sHeight)));

    pl.setVerticalGroup(
        pl.createSequentialGroup()
            /*		*/ .addGroup(
                pl.createParallelGroup()
                    /*				*/ .addComponent(lX)
                    /*				*/ .addComponent(sX, DEFAULT_SIZE, PREFERRED_SIZE, PREFERRED_SIZE)
                    /*				*/ .addComponent(lY)
                    /*				*/ .addComponent(sY, DEFAULT_SIZE, PREFERRED_SIZE, PREFERRED_SIZE))
            /*		*/ .addGroup(
                pl.createParallelGroup()
                    /*				*/ .addComponent(lWidth)
                    /*				*/ .addComponent(sWidth, DEFAULT_SIZE, PREFERRED_SIZE, PREFERRED_SIZE)
                    /*				*/ .addComponent(lHeight)
                    /*				*/ .addComponent(sHeight, DEFAULT_SIZE, PREFERRED_SIZE, PREFERRED_SIZE)));

    gl.setHorizontalGroup(
        gl.createParallelGroup()
            /**/ .addGroup(
                gl.createSequentialGroup()/*		*/ .addComponent(lTitle)/*		*/ .addComponent(sTitle))
            /**/ .addComponent(position)
            /**/ .addComponent(sShowBorder)
            /**/ .addComponent(sAllowResize)
            /**/ .addComponent(sAlwaysOnTop)
            /**/ .addComponent(sPauseGame)
            /**/ .addComponent(sEmbed));

    gl.setVerticalGroup(
        gl.createSequentialGroup()
            /**/ .addGroup(
                gl.createParallelGroup()
                    /*		*/ .addComponent(lTitle)
                    /*		*/ .addComponent(sTitle, DEFAULT_SIZE, PREFERRED_SIZE, PREFERRED_SIZE))
            /**/ .addComponent(position)
            /**/ .addComponent(sShowBorder)
            /**/ .addComponent(sAllowResize)
            /**/ .addComponent(sAlwaysOnTop)
            /**/ .addComponent(sPauseGame)
            /**/ .addComponent(sEmbed));
    return p;
  }
  // Must be delegated through ActionFrame(Action)
  private ActionFrame(Action a, LibAction la) {
    super(la.description, false);
    if (la.parent == null) setTitle(Messages.getString("Action.UNKNOWN")); // $NON-NLS-1$
    if (la.actImage != null)
      setFrameIcon(new ImageIcon(la.actImage.getScaledInstance(16, 16, Image.SCALE_SMOOTH)));
    String s;
    ResourceReference<GmObject> at = a.getAppliesTo();
    if (at == GmObject.OBJECT_SELF) s = Messages.getString("ActionFrame.SELF"); // $NON-NLS-1$
    else s = Messages.getString("ActionFrame.OTHER"); // $NON-NLS-1$
    appliesObject = new ResourceMenu<GmObject>(Resource.Kind.OBJECT, s, false, 100);
    appliesObject.setEnabled(GmObject.refAsInt(at) >= 0);
    appliesObject.setOpaque(false);
    appliesObject.setSelected(at);
    act = a;

    appliesPanel = new JPanel();
    appliesPanel.setOpaque(false);
    appliesPanel.setLayout(new GridBagLayout());

    GridBagConstraints gbc;
    applies = new IndexButtonGroup(3, true, false);
    JRadioButton button = new JRadioButton(Messages.getString("ActionFrame.SELF")); // $NON-NLS-1$
    button.setOpaque(false);
    applies.add(button, -1);
    gbc = new GridBagConstraints();
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    appliesPanel.add(button, gbc);
    button = new JRadioButton(Messages.getString("ActionFrame.OTHER")); // $NON-NLS-1$
    button.setOpaque(false);
    applies.add(button, -2);
    gbc = new GridBagConstraints();
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    appliesPanel.add(button, gbc);
    button = new JRadioButton(Messages.getString("ActionFrame.OBJECT")); // $NON-NLS-1$
    button.setHorizontalAlignment(JRadioButton.LEFT);
    button.setOpaque(false);
    button.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            boolean sel = ((JRadioButton) e.getSource()).isSelected();
            appliesObject.setEnabled(sel);
          }
        });
    applies.add(button, 0);
    gbc = new GridBagConstraints();
    gbc.gridy = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    appliesPanel.add(button, gbc);
    gbc = new GridBagConstraints();
    gbc.gridy = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 1.0;
    gbc.insets = new Insets(0, 2, 0, 6);
    appliesPanel.add(appliesObject, gbc);
    applies.setValue(Math.min(GmObject.refAsInt(at), 0));

    if (la.interfaceKind == LibAction.INTERFACE_CODE) {
      setSize(600, 400);
      setClosable(true);
      setMaximizable(true);
      setResizable(true);
      setIconifiable(true);

      tool = new JToolBar();
      tool.setFloatable(false);
      tool.setAlignmentX(0);
      save = new JButton(LGM.getIconForKey("ActionFrame.SAVE")); // $NON-NLS-1$
      save.addActionListener(this);
      //			add(save);
      tool.add(save);
      tool.addSeparator();

      code = new GMLTextArea(a.getArguments().get(0).getVal());
      code.addEditorButtons(tool);

      tool.addSeparator();
      tool.add(new JLabel(Messages.getString("ActionFrame.APPLIES"))); // $NON-NLS-1$
      tool.add(appliesPanel);

      status = new JPanel(new FlowLayout());
      status.setLayout(new BoxLayout(status, BoxLayout.X_AXIS));
      status.setMaximumSize(new Dimension(Integer.MAX_VALUE, 11));
      final JLabel caretPos =
          new JLabel((code.getCaretLine() + 1) + ":" + (code.getCaretColumn() + 1));
      status.add(caretPos);
      code.addCaretListener(
          new CaretListener() {
            public void caretUpdate(CaretEvent e) {
              caretPos.setText((code.getCaretLine() + 1) + ":" + (code.getCaretColumn() + 1));
            }
          });

      add(tool, BorderLayout.NORTH);
      add(code, BorderLayout.CENTER);
      add(status, BorderLayout.SOUTH);

      setFocusTraversalPolicy(new TextAreaFocusTraversalPolicy(code));
      appliesPanel.setLayout(new BoxLayout(appliesPanel, BoxLayout.LINE_AXIS));
    } else makeArgumentPane(a, la);
    pack();
    repaint();
    SubframeInformer.fireSubframeAppear(this);
  }
  private JMenuBar makeMenuBar() {
    JMenuBar menuBar = new JMenuBar();

    // File
    JMenu menu = new JMenu(Messages.getString("GameInformationFrame.MENU_FILE")); // $NON-NLS-1$
    menuBar.add(menu);
    menu.addActionListener(this);

    JMenuItem item = addItem("GameInformationFrame.LOAD"); // $NON-NLS-1$
    item.setAccelerator(
        KeyStroke.getKeyStroke(
            Messages.getKeyboardString("GameInformationFrame.LOAD"))); // $NON-NLS-1$
    menu.add(item);
    item = addItem("GameInformationFrame.FILESAVE"); // $NON-NLS-1$
    item.setAccelerator(
        KeyStroke.getKeyStroke(
            Messages.getKeyboardString("GameInformationFrame.FILESAVE"))); // $NON-NLS-1$
    menu.add(item);
    menu.addSeparator();
    item = addItem("GameInformationFrame.SETTINGS"); // $NON-NLS-1$
    menu.add(item);
    item = addItem("GameInformationFrame.PRINT"); // $NON-NLS-1$
    item.setAccelerator(
        KeyStroke.getKeyStroke(
            Messages.getKeyboardString("GameInformationFrame.PRINT"))); // $NON-NLS-1$
    menu.add(item);
    menu.addSeparator();
    item = new JMenuItem(Messages.getString("GameInformationFrame.CLOSESAVE")); // $NON-NLS-1$
    item.setIcon(save.getIcon());
    item.setActionCommand("GameInformationFrame.CLOSESAVE"); // $NON-NLS-1$
    item.addActionListener(this);
    menu.add(item);

    // Edit
    menu = new JMenu(Messages.getString("GameInformationFrame.MENU_EDIT")); // $NON-NLS-1$
    menuBar.add(menu);

    item = addItem("GameInformationFrame.CUT"); // $NON-NLS-1$
    item.setAccelerator(
        KeyStroke.getKeyStroke(
            Messages.getKeyboardString("GameInformationFrame.CUT"))); // $NON-NLS-1$
    menu.add(item);
    item = addItem("GameInformationFrame.COPY"); // $NON-NLS-1$
    item.setAccelerator(
        KeyStroke.getKeyStroke(
            Messages.getKeyboardString("GameInformationFrame.COPY"))); // $NON-NLS-1$
    menu.add(item);
    item = addItem("GameInformationFrame.PASTE"); // $NON-NLS-1$
    item.setAccelerator(
        KeyStroke.getKeyStroke(
            Messages.getKeyboardString("GameInformationFrame.PASTE"))); // $NON-NLS-1$
    menu.add(item);
    menu.addSeparator();
    item = new JMenuItem(undoManager.getUndoAction());
    item.setAccelerator(
        KeyStroke.getKeyStroke(
            Messages.getKeyboardString("GameInformationFrame.UNDO"))); // $NON-NLS-1$
    menu.add(item);
    item = new JMenuItem(undoManager.getRedoAction());
    item.setAccelerator(
        KeyStroke.getKeyStroke(
            Messages.getKeyboardString("GameInformationFrame.REDO"))); // $NON-NLS-1$
    menu.add(item);
    menu.addSeparator();
    item = addItem("GameInformationFrame.SELECTALL"); // $NON-NLS-1$
    item.setAccelerator(
        KeyStroke.getKeyStroke(
            Messages.getKeyboardString("GameInformationFrame.SELECTALL"))); // $NON-NLS-1$
    menu.add(item);

    // Format
    menu = new JMenu(Messages.getString("GameInformationFrame.MENU_FORMAT")); // $NON-NLS-1$
    menuBar.add(menu);

    miBold = addItem("GameInformationFrame.BOLD"); // $NON-NLS-1$
    miBold.setActionCommand("GameInformationFrame.MENU_BOLD"); // $NON-NLS-1$
    miBold.setAccelerator(
        KeyStroke.getKeyStroke(
            Messages.getKeyboardString("GameInformationFrame.BOLD"))); // $NON-NLS-1$
    menu.add(miBold);
    miItalic = addItem("GameInformationFrame.ITALIC"); // $NON-NLS-1$
    miItalic.setActionCommand("GameInformationFrame.MENU_ITALIC"); // $NON-NLS-1$
    miItalic.setAccelerator(
        KeyStroke.getKeyStroke(
            Messages.getKeyboardString("GameInformationFrame.ITALIC"))); // $NON-NLS-1$
    menu.add(miItalic);
    miUnderline = addItem("GameInformationFrame.UNDERLINE"); // $NON-NLS-1$
    miUnderline.setActionCommand("GameInformationFrame.MENU_UNDERLINE"); // $NON-NLS-1$
    miUnderline.setAccelerator(
        KeyStroke.getKeyStroke(
            Messages.getKeyboardString("GameInformationFrame.UNDERLINE"))); // $NON-NLS-1$
    menu.add(miUnderline);
    menu.addSeparator();
    miLeft = addItem("GameInformationFrame.ALIGN_LEFT"); // $NON-NLS-1$
    miLeft.setActionCommand("GameInformationFrame.ALIGN_LEFT"); // $NON-NLS-1$
    miLeft.setSelected(true);
    menu.add(miLeft);
    miCenter = addItem("GameInformationFrame.ALIGN_CENTER"); // $NON-NLS-1$
    miCenter.setActionCommand("GameInformationFrame.ALIGN_CENTER"); // $NON-NLS-1$
    menu.add(miCenter);
    miRight = addItem("GameInformationFrame.ALIGN_RIGHT"); // $NON-NLS-1$
    miRight.setActionCommand("GameInformationFrame.ALIGN_RIGHT"); // $NON-NLS-1$
    menu.add(miRight);
    menu.addSeparator();
    item = addItem("GameInformationFrame.FONTCOLOR"); // $NON-NLS-1$
    menu.add(item);
    item = addItem("GameInformationFrame.COLOR"); // $NON-NLS-1$
    menu.add(item);

    return menuBar;
  }
  private void makeArgumentPane(Action a, LibAction la) {
    setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
    JLabel lab;
    JPanel pane;
    pane = new JPanel();
    pane.setBorder(new EmptyBorder(6, 6, 0, 6));
    pane.setLayout(new BorderLayout());
    add(pane);
    if (la.actImage != null) {
      lab = new JLabel(new ImageIcon(la.actImage));
      lab.setBorder(new EmptyBorder(16, 16, 16, 20));
      pane.add(lab, BorderLayout.LINE_START);
    }

    String s = Messages.getString("ActionFrame.APPLIES"); // $NON-NLS-1$
    appliesPanel.setBorder(BorderFactory.createTitledBorder(s));
    pane.add(appliesPanel);
    if (!la.canApplyTo) appliesPanel.setVisible(false);

    List<Argument> args = a.getArguments();
    argComp = new ArgumentComponent[args.size()];
    if (args.size() > 0) {
      pane = new JPanel();
      pane.setBorder(
          BorderFactory.createCompoundBorder(
              new EmptyBorder(6, 8, 0, 8), BorderFactory.createTitledBorder("")));
      GroupLayout kvLayout = new GroupLayout(pane);
      GroupLayout.SequentialGroup hGroup, vGroup;
      GroupLayout.ParallelGroup keyGroup, valueGroup;
      hGroup = kvLayout.createSequentialGroup();
      vGroup = kvLayout.createSequentialGroup();
      keyGroup = kvLayout.createParallelGroup(Alignment.TRAILING);
      valueGroup = kvLayout.createParallelGroup();

      hGroup.addGap(4);
      hGroup.addGroup(keyGroup);
      hGroup.addGap(6);
      hGroup.addGroup(valueGroup);
      hGroup.addGap(4);

      kvLayout.setHorizontalGroup(hGroup);
      kvLayout.setVerticalGroup(vGroup);

      pane.setLayout(kvLayout);
      add(pane);

      vGroup.addGap(4);
      for (int n = 0; n < args.size(); n++) {
        argComp[n] = new ArgumentComponent(args.get(n), a.getLibAction().libArguments[n]);
        if (la.parent == null)
          lab = new JLabel(Messages.format("ActionFrame.UNKNOWN", n)); // $NON-NLS-1$
        else {
          LibArgument larg = la.libArguments[n];
          lab = new JLabel(larg.caption);
        }
        Alignment al;
        if (n == 0 && act.getLibAction().interfaceKind == LibAction.INTERFACE_ARROWS) {
          argComp[n].setEditor(new ArrowsEditor(argComp[n].getArgument().getVal()));
          al = Alignment.CENTER;
        } else {
          Component c = argComp[n].getEditor();
          c.setMaximumSize(new Dimension(240, 20));
          c.setPreferredSize(new Dimension(200, 20));
          c.setMinimumSize(new Dimension(160, 20));
          al = Alignment.BASELINE;
        }
        keyGroup.addComponent(lab);
        valueGroup.addComponent(argComp[n].getEditor());
        if (n > 0) vGroup.addGap(6);
        GroupLayout.ParallelGroup argGroup = kvLayout.createParallelGroup(al);
        argGroup.addComponent(lab).addComponent(argComp[n].getEditor());
        vGroup.addGroup(argGroup);
      }
      vGroup.addGap(4);
    }
    pane = new JPanel();
    pane.setLayout(new FlowLayout(FlowLayout.TRAILING));
    add(pane);
    if (la.allowRelative) {
      relativeBox = new JCheckBox(Messages.getString("ActionFrame.RELATIVE")); // $NON-NLS-1$
      relativeBox.setSelected(act.isRelative());
      pane.add(relativeBox);
    }
    if (la.question) {
      notBox = new JCheckBox(Messages.getString("ActionFrame.NOT")); // $NON-NLS-1$
      notBox.setSelected(act.isNot());
      pane.add(notBox);
    }

    pane = new JPanel();
    pane.setLayout(new GridLayout(1, 2, 8, 0));
    pane.setBorder(new EmptyBorder(0, 8, 8, 8));
    add(pane);
    s = Messages.getString("ActionFrame.SAVE"); // $NON-NLS-1$
    save = new JButton(s, LGM.getIconForKey("ActionFrame.SAVE")); // $NON-NLS-1$
    save.addActionListener(this);
    pane.add(save);
    s = Messages.getString("ActionFrame.DISCARD"); // $NON-NLS-1$
    discard = new JButton(s, LGM.getIconForKey("ActionFrame.DISCARD")); // $NON-NLS-1$
    discard.addActionListener(this);
    pane.add(discard);
  }
  public void actionPerformed(ActionEvent ev) {
    super.actionPerformed(ev);
    String com = ev.getActionCommand();

    if (com.equals("GameInformationFrame.LOAD")) // $NON-NLS-1$
    {
      loadFromFile();
    } else if (com.equals("GameInformationFrame.PRINT")) // $NON-NLS-1$
    {
      try {
        editor.print();
      } catch (Exception pex) {
        LGM.showDefaultExceptionHandler(pex);
      }
      return;
    } else if (com.equals("GameInformationFrame.SETTINGS")) // $NON-NLS-1$
    {
      if (settings == null) {
        settings = new SettingsFrame();
      }
      settings.setVisible(true);
    } else if (com.equals("GameInformationFrame.FILESAVE")) // $NON-NLS-1$
    {
      saveToFile();
      return;
    } else if (com.equals("GameInformationFrame.FONTCOLOR")) // $NON-NLS-1$
    {
      String colorStr = Messages.getString("GameInformationFrame.FONTCOLOR"); // $NON-NLS-1$
      Color c = JColorChooser.showDialog(this, colorStr, fgColor);
      if (c != null) {
        fgColor = c;
        setSelectionAttribute(StyleConstants.Foreground, c);
      }
      return;
    } else if (com.equals("GameInformationFrame.BOLD")) // $NON-NLS-1$
    {
      miBold.setSelected(tbBold.isSelected());
      setSelectionAttribute(StyleConstants.Bold, tbBold.isSelected());
      return;
    } else if (com.equals("GameInformationFrame.ITALIC")) // $NON-NLS-1$
    {
      miItalic.setSelected(tbItalic.isSelected());
      setSelectionAttribute(StyleConstants.Italic, tbItalic.isSelected());
      return;
    } else if (com.equals("GameInformationFrame.UNDERLINE")) // $NON-NLS-1$
    {
      miUnderline.setSelected(tbUnderline.isSelected());
      setSelectionAttribute(StyleConstants.Underline, tbUnderline.isSelected());
      return;
    } else if (com.equals("GameInformationFrame.MENU_BOLD")) // $NON-NLS-1$
    {
      miBold.setSelected(!miBold.isSelected());
      tbBold.setSelected(miBold.isSelected());
      setSelectionAttribute(StyleConstants.Bold, miBold.isSelected());
      return;
    } else if (com.equals("GameInformationFrame.MENU_ITALIC")) // $NON-NLS-1$
    {
      miItalic.setSelected(!miItalic.isSelected());
      tbItalic.setSelected(miItalic.isSelected());
      setSelectionAttribute(StyleConstants.Italic, miItalic.isSelected());
      return;
    } else if (com.equals("GameInformationFrame.MENU_UNDERLINE")) // $NON-NLS-1$
    {
      miUnderline.setSelected(!miUnderline.isSelected());
      tbUnderline.setSelected(miUnderline.isSelected());
      setSelectionAttribute(StyleConstants.Underline, miUnderline.isSelected());
      return;
    } else if (com.equals("GameInformationFrame.ALIGN_LEFT")) // $NON-NLS-1$
    {
      setSelectionAlignment(StyleConstants.ALIGN_LEFT);
      return;
    } else if (com.equals("GameInformationFrame.ALIGN_CENTER")) // $NON-NLS-1$
    {
      setSelectionAlignment(StyleConstants.ALIGN_CENTER);
      return;
    } else if (com.equals("GameInformationFrame.ALIGN_RIGHT")) // $NON-NLS-1$
    {
      setSelectionAlignment(StyleConstants.ALIGN_RIGHT);
      return;
    } else if (com.equals("GameInformationFrame.COLOR")) // $NON-NLS-1$
    {
      String colorStr = Messages.getString("GameInformationFrame.COLOR"); // $NON-NLS-1$
      Color c = JColorChooser.showDialog(this, colorStr, editor.getBackground());
      if (c != null) setEditorBackground(c);
      return;
    } else if (com.equals("GameInformationFrame.CUT")) // $NON-NLS-1$
    {
      editor.cut();
      return;
    } else if (com.equals("GameInformationFrame.COPY")) // $NON-NLS-1$
    {
      editor.copy();
      return;
    } else if (com.equals("GameInformationFrame.PASTE")) // $NON-NLS-1$
    {
      editor.paste();
      return;
    } else if (com.equals("GameInformationFrame.SELECTALL")) // $NON-NLS-1$
    {
      editor.selectAll();
      return;
    } else if (com.equals("GameInformationFrame.CLOSESAVE")) // $NON-NLS-1$
    {
      this.doDefaultSaveAction();
      return;
    } else if (com.equals("GameInformationFrame.CLOSE")) { // $NON-NLS-1$
      settings.setVisible(false);
    }
  }
  public GameInformationFrame(GameInformation res, ResNode node) {
    super(res, node, Messages.getString("GameInformationFrame.TITLE"), true); // $NON-NLS-1$
    setDefaultCloseOperation(HIDE_ON_CLOSE);

    menubar = makeMenuBar();
    setJMenuBar(menubar);
    toolbar = makeToolBar();
    add(toolbar, BorderLayout.NORTH);
    fgColor = Color.BLACK;

    editor = new JEditorPane();
    editor.setEditorKit(rtf);
    setFocusTraversalPolicy(new TextAreaFocusTraversalPolicy(editor));

    editor.addCaretListener(undoManager);

    editor.addCaretListener(
        new CaretListener() {
          public void caretUpdate(CaretEvent ce) {
            fFamilyChange = true;
            fSizeChange = true;
            StyledDocument d = (StyledDocument) editor.getDocument();
            int dot = ce.getDot();
            if (ce.getMark() <= dot) dot--;
            AttributeSet as = d.getCharacterElement(dot).getAttributes();
            String f = StyleConstants.getFontFamily(as);
            fgColor = StyleConstants.getForeground(as);
            int s = StyleConstants.getFontSize(as);
            boolean b = StyleConstants.isBold(as);
            boolean i = StyleConstants.isItalic(as);
            boolean u = StyleConstants.isUnderline(as);
            cbFonts.setSelectedItem(f);
            sSizes.setValue(s);
            miBold.setSelected(b);
            tbBold.setSelected(b);

            tbItalic.setSelected(i);
            miItalic.setSelected(i);
            tbUnderline.setSelected(u);
            miUnderline.setSelected(u);

            setAlignmentOptions(StyleConstants.getAlignment(as));
          }
        });

    revertResource();
    // NOTE: DO not add the document listeners until the first time you set the text.
    addDocumentListeners();

    this.add(new JScrollPane(editor), BorderLayout.CENTER);

    fc = new CustomFileChooser("/org/lateralgm", "LAST_GAMEINFO_DIR"); // $NON-NLS-1$ //$NON-NLS-2$
    fc.setFileFilter(
        new CustomFileFilter(
            Messages.getString("GameInformationFrame.TYPE_RTF"),
            ".rtf")); //$NON-NLS-1$ //$NON-NLS-2$

    // build popup menu
    final JPopupMenu popup = new JPopupMenu();
    JMenuItem item;

    item = addItem("GameInformationFrame.CUT"); // $NON-NLS-1$
    item.setAccelerator(
        KeyStroke.getKeyStroke(
            Messages.getKeyboardString("GameInformationFrame.CUT"))); // $NON-NLS-1$
    popup.add(item);
    item = addItem("GameInformationFrame.COPY"); // $NON-NLS-1$
    item.setAccelerator(
        KeyStroke.getKeyStroke(
            Messages.getKeyboardString("GameInformationFrame.COPY"))); // $NON-NLS-1$
    popup.add(item);
    item = addItem("GameInformationFrame.PASTE"); // $NON-NLS-1$
    item.setAccelerator(
        KeyStroke.getKeyStroke(
            Messages.getKeyboardString("GameInformationFrame.PASTE"))); // $NON-NLS-1$
    popup.add(item);
    popup.addSeparator();

    item = new JMenuItem(undoManager.getUndoAction());
    item.setAccelerator(
        KeyStroke.getKeyStroke(
            Messages.getKeyboardString("GameInformationFrame.UNDO"))); // $NON-NLS-1$
    popup.add(item);
    item = new JMenuItem(undoManager.getRedoAction());
    item.setAccelerator(
        KeyStroke.getKeyStroke(
            Messages.getKeyboardString("GameInformationFrame.REDO"))); // $NON-NLS-1$
    popup.add(item);
    popup.addSeparator();

    item = addItem("GameInformationFrame.SELECTALL"); // $NON-NLS-1$
    item.setAccelerator(
        KeyStroke.getKeyStroke(
            Messages.getKeyboardString("GameInformationFrame.SELECTALL"))); // $NON-NLS-1$
    popup.add(item);

    editor.setComponentPopupMenu(popup);

    pack();
    setSize(getWidth(), 480);
  }
  private JToolBar makeToolBar() {
    JToolBar tool = new JToolBar();
    tool.setFloatable(false);

    // Setup the buttons
    save.setRequestFocusEnabled(false);
    tool.add(save);
    tool.addSeparator();

    JButton button;

    button = addToolButton("GameInformationFrame.CUT"); // $NON-NLS-1$
    tool.add(button);
    button = addToolButton("GameInformationFrame.COPY"); // $NON-NLS-1$
    tool.add(button);
    button = addToolButton("GameInformationFrame.PASTE"); // $NON-NLS-1$
    tool.add(button);

    tool.addSeparator();

    button = new JButton(undoManager.getUndoAction());
    button.setText("");
    button.setToolTipText(Messages.getString("GameInformationFrame.UNDO")); // $NON-NLS-1$
    tool.add(button);
    button = new JButton(undoManager.getRedoAction());
    button.setText("");
    button.setToolTipText(Messages.getString("GameInformationFrame.REDO")); // $NON-NLS-1$
    tool.add(button);

    tool.addSeparator();

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    String[] fontNames = ge.getAvailableFontFamilyNames();
    cbFonts = new JComboBox<String>(fontNames);
    cbFonts.setRequestFocusEnabled(false);
    cbFonts.setMaximumSize(cbFonts.getPreferredSize());
    cbFonts.setEditable(true);
    ActionListener lst =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (fFamilyChange) {
              fFamilyChange = false;
              return;
            }
            editor.grabFocus();
            setSelectionAttribute(StyleConstants.Family, cbFonts.getSelectedItem().toString());
          }
        };

    cbFonts.addActionListener(lst);
    tool.add(cbFonts);
    tool.addSeparator();
    sSizes = new JSpinner(new SpinnerNumberModel(12, 1, 100, 1));
    sSizes.setRequestFocusEnabled(false);
    sSizes.setMaximumSize(sSizes.getPreferredSize());
    sSizes.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent arg0) {
            if (fSizeChange) {
              fSizeChange = false;
              return;
            }
            setSelectionAttribute(StyleConstants.Size, sSizes.getValue());
            editor.grabFocus();
          }
        });
    tool.add(sSizes);
    tool.addSeparator();

    tbBold = addToggleButton("GameInformationFrame.BOLD"); // $NON-NLS-1$
    tbBold.setRequestFocusEnabled(false);
    tool.add(tbBold);
    tbItalic = addToggleButton("GameInformationFrame.ITALIC"); // $NON-NLS-1$
    tbItalic.setRequestFocusEnabled(false);
    tool.add(tbItalic);
    tbUnderline = addToggleButton("GameInformationFrame.UNDERLINE"); // $NON-NLS-1$
    tbUnderline.setRequestFocusEnabled(false);
    tool.add(tbUnderline);

    tool.addSeparator();

    tbLeft = addToggleButton("GameInformationFrame.ALIGN_LEFT"); // $NON-NLS-1$
    tbLeft.setRequestFocusEnabled(false);
    tbLeft.setSelected(true);
    tool.add(tbLeft);
    tbCenter = addToggleButton("GameInformationFrame.ALIGN_CENTER"); // $NON-NLS-1$
    tbCenter.setRequestFocusEnabled(false);
    tool.add(tbCenter);
    tbRight = addToggleButton("GameInformationFrame.ALIGN_RIGHT"); // $NON-NLS-1$
    tbRight.setRequestFocusEnabled(false);
    tool.add(tbRight);

    tool.addSeparator();

    JButton butFontColor =
        new JButton(LGM.getIconForKey("GameInformationFrame.FONTCOLOR")); // $NON-NLS-1$
    butFontColor.setRequestFocusEnabled(false);
    butFontColor.setActionCommand("GameInformationFrame.FONTCOLOR"); // $NON-NLS-1$
    butFontColor.addActionListener(this);
    butFontColor.setToolTipText(
        Messages.getString("GameInformationFrame.FONTCOLOR")); // $NON-NLS-1$
    tool.add(butFontColor);
    JButton but = new JButton(LGM.getIconForKey("GameInformationFrame.COLOR")); // $NON-NLS-1$
    but.setRequestFocusEnabled(false);
    but.setActionCommand("GameInformationFrame.COLOR"); // $NON-NLS-1$
    but.addActionListener(this);
    but.setToolTipText(Messages.getString("GameInformationFrame.COLOR")); // $NON-NLS-1$
    tool.add(but);

    return tool;
  }