コード例 #1
0
    /*----------------------------------------------------------------------*/
    public void actionPerformed(ActionEvent e) {
      SwingEditor.instance.setDirty(dirtyFlag);

      if (e.getSource() == add) {
        TileScript script = new FlavourText("");
        TileScriptEditor dialog =
            new TileScriptEditor(SwingEditor.instance, script, dirtyFlag, zone);
        if (dialog.getResult() != null) {
          SwingEditor.instance.setDirty(dirtyFlag);
          dataModel.add(dialog.getResult());
        }
      } else if (e.getSource() == delete) {
        int index = list.getSelectedIndex();
        if (index > -1) {
          SwingEditor.instance.setDirty(dirtyFlag);
          dataModel.remove(index);
        }
      } else if (e.getSource() == edit) {
        editListItem();
      } else if (e.getSource() == moveUp) {
        dataModel.moveUp(list.getSelectedIndex());
        list.setSelectedIndex(list.getSelectedIndex() - 1);
      } else if (e.getSource() == moveDown) {
        dataModel.moveDown(list.getSelectedIndex());
        list.setSelectedIndex(list.getSelectedIndex() + 1);
      }
    }
コード例 #2
0
    /*----------------------------------------------------------------------*/
    private void editListItem() {
      int index = list.getSelectedIndex();
      if (index > -1) {
        TileScript script = dataModel.data.get(index);

        TileScriptEditor dialog =
            new TileScriptEditor(SwingEditor.instance, script, dirtyFlag, zone);

        if (dialog.getResult() != null) {
          dataModel.data.set(index, dialog.getResult());
        }
      }
    }