Пример #1
0
  protected void filterOpcItem() {
    opcItemsPanel.removeAll();

    List<YGOpcItem> filted = filter.doFiter(opcItemList);
    if (filted == null) {
      return;
    }

    MouseAdapter mouseAdapter =
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (e.getSource() instanceof JCheckBox) {
              JCheckBox clickedButton = (JCheckBox) e.getSource();

              if (clickedButton.isSelected()) {
                jTextFieldForOPCItemName.setText(clickedButton.getText());
              }
            }
          }
        };

    opcItemsPanel.setLayout(new GridLayout(filted.size() < 6 ? 6 : filted.size(), 1));
    for (YGOpcItem item : filted) {
      JCheckBox checkBox = new JCheckBox(item.getItemName());
      checkBox.setBackground(Color.white);
      checkBox.addMouseListener(mouseAdapter);

      selectItemButtonGroup.add(checkBox);
      opcItemsPanel.add(checkBox);
    }
    opcItemsPanel.updateUI();
  }
Пример #2
0
  @Action
  public void confirm() {
    String itemName = jTextFieldForOPCItemName.getText();

    if (StringUtils.isBlank(itemName)) {
      JOptionPane.showMessageDialog(this, "请选择OPC项");
      return;
    }

    filter.removeAccessPath();
    filter.removeServerId();
    filter.removeVarType();
    filter.setNameFilter(itemName);

    List<YGOpcItem> opcItems = filter.doFiter(opcItemList);
    if (opcItems == null || opcItems.size() < 1) {
      JOptionPane.showMessageDialog(this, "选择OPC项失败,不存在此编码的OPC项");
      return;
    }

    YGOpcItem selectOpcItem = opcItems.get(0);
    String selectOpcItemName = selectOpcItem.getItemName();

    baseTable.setValueAt(selectOpcItemName, row, col);
    this.setVisible(false);
  }