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

📄 tasknodepanel.java

📁 人工智能中Agent开发包。多 Agent 系统是处理自治 Agent 之间知识层的协作问题
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
* The contents of this file are subject to the BT "ZEUS" Open Source 
* Licence (L77741), Version 1.0 (the "Licence"); you may not use this file 
* except in compliance with the Licence. You may obtain a copy of the Licence
* from $ZEUS_INSTALL/licence.html or alternatively from
* http://www.labs.bt.com/projects/agents/zeus/licence.htm
* 
* Except as stated in Clause 7 of the Licence, software distributed under the
* Licence is distributed WITHOUT WARRANTY OF ANY KIND, either express or 
* implied. See the Licence for the specific language governing rights and 
* limitations under the Licence.
* 
* The Original Code is within the package zeus.*.
* The Initial Developer of the Original Code is British Telecommunications
* public limited company, whose registered office is at 81 Newgate Street, 
* London, EC1A 7AJ, England. Portions created by British Telecommunications 
* public limited company are Copyright 1996-9. All Rights Reserved.
* 
* THIS NOTICE MUST BE INCLUDED ON ANY COPY OF THIS FILE
*/



/***************************************************************************
* TaskNodePanel.java
*
* Panel through which task attributes are entered
***************************************************************************/

package zeus.generator.task;

import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.text.*;
import javax.swing.event.*;

import zeus.util.*;
import zeus.concepts.*;
import zeus.concepts.fn.*;
import zeus.generator.*;
import zeus.generator.event.*;
import zeus.generator.util.*;
import zeus.gui.fields.*;
import zeus.gui.help.*;

public class TaskNodePanel extends JPanel {
  static final String[] ERROR_MESSAGE = {
     /* 0 */ "Invalid name"
  };
  protected EventListenerList nameListeners = new EventListenerList();
  protected boolean           isConditionalNode;
  protected NameField         namefield;
  protected FactPanel         preconditionsPanel, postconditionsPanel;
  protected JPanel            factPanel, leftPanel, rightPanel;
  protected GroupManager      leftGroupManager, rightGroupManager;
  protected JComboBox         leftCombo, rightCombo;
  protected GroupToolBar      toolbar;
  protected Hashtable         nameTable;
  protected String            previousName = null;
  protected AttributeModel    preAttrModel, postAttrModel;
  protected AttributeTable    preAttrTable, postAttrTable;

  public TaskNodePanel(OntologyDb ontologyDb, ChangeListener parent)  {
    GridBagLayout gridBagLayout = new GridBagLayout();
    GridBagConstraints gbc = new GridBagConstraints();
    setLayout(gridBagLayout);
    setBackground(Color.lightGray);
    setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));

    // Add the panel show that shows the node name to this panel.
    JPanel namePanel = new JPanel();
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(8,8,8,8);
    gridBagLayout.setConstraints(namePanel,gbc);
    add(namePanel);

    // Add the panel containing the task's facts to this panel.
    factPanel = new JPanel();
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = gbc.weighty = 1;
    gridBagLayout.setConstraints(factPanel,gbc);
    add(factPanel);

    // Cost Panel information
    TitledBorder border =
       BorderFactory.createTitledBorder("Node Name");
    border.setTitlePosition(TitledBorder.TOP);
    border.setTitleJustification(TitledBorder.RIGHT);
    border.setTitleFont(new Font("Helvetica", Font.BOLD, 14));
    border.setTitleColor(Color.blue);
    namePanel.setBorder(border);

    gridBagLayout = new GridBagLayout();
    namePanel.setLayout(gridBagLayout);
    namePanel.setBackground(Color.lightGray);

    JLabel label = new JLabel("Name:");
    label.setToolTipText("Name of this node");
    gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.NONE;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(0,8,0,0);
    gridBagLayout.setConstraints(label,gbc);
    namePanel.add(label);

    namefield = new NameField(20);
    namefield.addChangeListener(parent);
    namefield.addFocusListener(new SymFocusAction());

    gbc = new GridBagConstraints();
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = gbc.weighty = 1;
    gbc.insets = new Insets(0,8,8,8);
    gridBagLayout.setConstraints(namefield,gbc);
    namePanel.add(namefield);

    // Add factPanel info
    factPanel.setLayout(new GridLayout(1,2,5,5));
    factPanel.setBackground(Color.lightGray);

    leftGroupManager = new GroupManager(ontologyDb, new AttributeModel(),
       Fact.VARIABLE, FactPanel.PRECONDITION, new Fact[0]);
    rightGroupManager = new GroupManager(ontologyDb, new AttributeModel(),
       Fact.VARIABLE, FactPanel.POSTCONDITION, new Fact[0]);

    preconditionsPanel = new FactPanel(parent, FactPanel.PRECONDITION,
       "Node Preconditions", leftGroupManager);
    postconditionsPanel = new FactPanel(parent, FactPanel.POSTCONDITION,
       "Node Effects", rightGroupManager);

    preAttrModel = preconditionsPanel.getAttributeModel();
    postAttrModel = postconditionsPanel.getAttributeModel();

    preAttrTable = preconditionsPanel.getAttributeTable();
    postAttrTable = postconditionsPanel.getAttributeTable();

    // for pre/post attribute renaming
    leftGroupManager.addRenameListener(preAttrModel);
    leftGroupManager.addRenameListener(postAttrModel);

    rightGroupManager.addRenameListener(preAttrModel);
    rightGroupManager.addRenameListener(postAttrModel);

    // for pre/post conditions renaming
    SymRenameAction symRenameAction = new SymRenameAction();
    leftGroupManager.addRenameListener(symRenameAction);
    rightGroupManager.addRenameListener(symRenameAction);

    nameTable = new Hashtable();

    // left and right panels
    leftPanel = new JPanel();
    gridBagLayout = new GridBagLayout();
    leftPanel.setLayout(gridBagLayout);
    leftPanel.setBackground(Color.lightGray);

    label = new JLabel("Group:");
    label.setToolTipText("Name of this preconditions group");
    gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.NONE;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(0,8,0,0);
    gridBagLayout.setConstraints(label,gbc);
    leftPanel.add(label);

    leftCombo = new JComboBox(leftGroupManager.getComboBoxModel()) {
       public void contentsChanged(ListDataEvent e) {
          selectedItemReminder = null;
          super.contentsChanged(e);
       }
    };

    leftCombo.setEnabled(false);
    leftCombo.addActionListener(leftGroupManager);

    gbc = new GridBagConstraints();
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.NONE;
    gbc.insets = new Insets(0,8,0,8);
    gridBagLayout.setConstraints(leftCombo,gbc);
    leftPanel.add(leftCombo);

    gbc = new GridBagConstraints();
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = gbc.weighty = 1;
    gbc.insets = new Insets(8,8,8,8);
    gridBagLayout.setConstraints(preconditionsPanel,gbc);
    leftPanel.add(preconditionsPanel);

    rightPanel = new JPanel();
    gridBagLayout = new GridBagLayout();
    rightPanel.setLayout(gridBagLayout);
    rightPanel.setBackground(Color.lightGray);

    label = new JLabel("Group:");
    label.setToolTipText("Name of this postconditions group");
    gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.NONE;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(0,8,0,0);
    gridBagLayout.setConstraints(label,gbc);
    rightPanel.add(label);

    rightCombo = new JComboBox(rightGroupManager.getComboBoxModel()) {
       public void contentsChanged(ListDataEvent e) {
          selectedItemReminder = null;
          super.contentsChanged(e);
       }
    };

    rightCombo.setEditable(true);
    rightCombo.addActionListener(rightGroupManager);

    gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.NONE;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(0,8,0,0);
    gridBagLayout.setConstraints(rightCombo,gbc);
    rightPanel.add(rightCombo);

    toolbar = new GroupToolBar(rightGroupManager);
    gbc = new GridBagConstraints();
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.NONE;
    gbc.insets = new Insets(0,8,0,8);

⌨️ 快捷键说明

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