⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aclpropertylist.java

📁 JADE(JAVA Agent开发框架)是一个完全由JAVA语言开发的软件,它简化了多Agent系统的实现。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     * @param  index         the index
     * @param  isSelected    is it selected
     * @param  cellHasFocus  does it has the focus?
     * @return               The ListCellRendererComponent value
     */
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
      if ((value != null) && (value instanceof String) && (msg != null)) {
        String sValue = (String)value;
        String key = msg.getUserDefinedParameter(sValue);
        setText(sValue + " = " + key);
      }
      setBackground(isSelected ? Color.blue : Color.white);
      setForeground(isSelected ? Color.white : Color.black);
      return this;
    }


    /**
     *  register the ACLMessage
     *
     * @param  msg  the ACLMessage
     */
    public void register(ACLMessage msg) {
      this.msg = msg;
    }


    private ACLMessage msg;
  }


  private class ACLPropertyDialog extends JDialog {

    /**
     *  Constructor for the ACLPropertyDialog object
     */
    public ACLPropertyDialog() {
      this.setModal(true);
      try {
        jbInit();
        pack();
      }
      catch (Exception ex) {
        ex.printStackTrace();
      }
    }


    /**
     *  Gets the UserAction attribute of the ACLPropertyDialog object
     *
     * @return    The UserAction value
     */
    public String getUserAction() {
      return userAction;
    }


    /**
     *  Gets the OK attribute of the ACLPropertyDialog object
     *
     * @return    The OK value
     */
    public boolean getOK() {
      return userAction.equals(OK);
    }


    /**
     *  Gets the Itskey attribute of the ACLPropertyDialog object
     *
     * @return    The Itskey value
     */
    public String getItskey() {
      return itskey;
    }


    /**
     *  Gets the Itsvalue attribute of the ACLPropertyDialog object
     *
     * @return    The Itsvalue value
     */
    public String getItsvalue() {
      return itsvalue;
    }


    /**
     *  Sets the Editable attribute of the ACLPropertyDialog object
     *
     * @param  theBool  The new Editable value
     */
    public void setEditable(boolean theBool) {
      if (!theBool) {
        OK = "CLOSED";
        this.cancelButton.setVisible(false);
        this.valueTextField.setEditable(false);
      }
    }


    /**
     *  Sets the UserAction attribute of the ACLPropertyDialog object
     *
     * @param  newUserAction  The new UserAction value
     */
    public void setUserAction(String newUserAction) {
      userAction = newUserAction;
    }


    /**
     *  Sets the Itskey attribute of the ACLPropertyDialog object
     *
     * @param  newItskey  The new Itskey value
     */
    public void setItskey(String newItskey) {
      keyTextField.setText(newItskey);
      itskey = newItskey;
    }


    /**
     *  Sets the Edit attribute of the ACLPropertyDialog object
     */
    public void setEdit() {
      keyTextField.setEditable(false);
    }


    /**
     *  Sets the Itsvalue attribute of the ACLPropertyDialog object
     *
     * @param  newItsvalue  The new Itsvalue value
     */
    public void setItsvalue(String newItsvalue) {
      valueTextField.setText(newItsvalue);
      itsvalue = newItsvalue;
    }


    /**
     *  Description of the Method
     *
     * @exception  Exception  Description of Exception
     */
    void jbInit() throws Exception {
      this.getContentPane().setLayout(gridBagLayout1);
      jLabel1.setFont(new java.awt.Font("Dialog", 0, 12));
      jLabel1.setText("key");
      this.getContentPane().setBackground(Color.white);
      okButton.setBackground(Color.white);
      okButton.setFont(new java.awt.Font("Dialog", 0, 12));
      okButton.setText("ok");
      okButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            okButton_actionPerformed(e);
          }
        });
      cancelButton.setBackground(Color.white);
      cancelButton.setFont(new java.awt.Font("Dialog", 0, 12));
      cancelButton.setText("cancel");
      cancelButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            cancelButton_actionPerformed(e);
          }
        });
      jLabel2.setFont(new java.awt.Font("Dialog", 0, 12));
      jLabel2.setText("value");
      this.getContentPane().add(keyTextField, new GridBagConstraints(1, 0, 2, 1, 1.0, 0.0
        , GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
      this.getContentPane().add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
        , GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
      this.getContentPane().add(jLabel2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
        , GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
      this.getContentPane().add(cancelButton, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0
        , GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
      this.getContentPane().add(valueTextField, new GridBagConstraints(1, 1, 2, 1, 1.0, 0.0
        , GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
      this.getContentPane().add(okButton, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0
        , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, -16, 0, 0), 0, 0));
    }


    /**
     *  Description of the Method
     *
     * @param  e  Description of Parameter
     */
    void cancelButton_actionPerformed(ActionEvent e) {
      setUserAction(CANCELLED);
      hide();
    }


    /**
     *  Description of the Method
     *
     * @param  e  Description of Parameter
     */
    void okButton_actionPerformed(ActionEvent e) {
      setItskey(keyTextField.getText());
      setItsvalue(valueTextField.getText());
      setUserAction(OK);
      hide();
    }


    private String OK = "ok";
    private String CANCELLED = "cancelled";
    private String CLOSED = "closed";

    private GridBagLayout gridBagLayout1 = new GridBagLayout();
    private JTextField keyTextField = new JTextField();
    private JLabel jLabel1 = new JLabel();
    private JButton okButton = new JButton();
    private JButton cancelButton = new JButton();
    private JLabel jLabel2 = new JLabel();
    private JTextField valueTextField = new JTextField();
    private String userAction;
    private String itsAddress;
    private String itskey;
    private String itsvalue;

  }


  /**
   *  This class is the ListDataListener of the ACLPropertyList.
   *
   * @author     Chris van Aart - Acklin B.V., the Netherlands
   * @created    April 26, 2002
   */

  private class ACLPropertyListener implements ListDataListener {
    /**
     *  Description of the Method
     *
     * @param  obj        Description of Parameter
     * @param  fieldName  Description of Parameter
     */
    public void register(Object obj, String fieldName) {
      itsMsg = (ACLMessage)obj;
      this.fieldName = fieldName;
    }


    /**
     *  Description of the Method
     *
     * @param  parm1  Description of Parameter
     */
    public void intervalAdded(ListDataEvent parm1) {
      DefaultListModel lm = (DefaultListModel)parm1.getSource();
      int index = parm1.getIndex0();
      String key = (String)lm.elementAt(index);
      itsMsg.addUserDefinedParameter(theChangedKey, theChangedValue);
    }


    /**
     *  Description of the Method
     *
     * @param  theChangedKey    Description of Parameter
     * @param  theChangedValue  Description of Parameter
     */
    public void registerChangedProperty(String theChangedKey, String theChangedValue) {
      this.theChangedKey = theChangedKey;
      this.theChangedValue = theChangedValue;
    }


    /**
     *  Description of the Method
     *
     * @param  theRemovedKey  Description of Parameter
     */
    public void registerRemovedKey(String theRemovedKey) {
      this.theRemovedKey = theRemovedKey;
    }


    /**
     *  Description of the Method
     *
     * @param  parm1  Description of Parameter
     */
    public void intervalRemoved(ListDataEvent parm1) {
      String methodName = "remove" + fieldName;
      String theType = "jade.core.AID";
      itsMsg.removeUserDefinedParameter(theRemovedKey);
    }


    /**
     *  Description of the Method
     *
     * @param  parm1  Description of Parameter
     */
    public void contentsChanged(ListDataEvent parm1) {
      DefaultListModel lm = (DefaultListModel)parm1.getSource();
      int index = parm1.getIndex0();
      itsMsg.removeUserDefinedParameter(theChangedKey);
      itsMsg.addUserDefinedParameter(theChangedKey, theChangedValue);
    }


    private String fieldName = "";
    private String theRemovedKey, theChangedKey, theChangedValue;
    private ACLMessage itsMsg;
  }


  private boolean editable = true;

  private GridBagLayout gridBagLayout1 = new GridBagLayout();
  private JList contentList = new JList();
  private JButton viewButton = new JButton();
  private JButton addButton = new JButton();
  private JButton deleteButton = new JButton();

  private DefaultListModel listModel = new DefaultListModel();
  private ACLPropertyListCellRenderer aclPropertyListCellRenderer = new ACLPropertyListCellRenderer();
  private ACLPropertyListener theDataListener = new ACLPropertyListener();
  private JScrollPane contentScrollPane = new JScrollPane();

  private String fieldName = "";
  private ACLMessage msg;

}
//  ***EOF***

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -