コード例 #1
0
  private void populateNetworkTree() {

    DefaultTreeModel tree = (DefaultTreeModel) networkJTree.getModel();
    DefaultMutableTreeNode root = (DefaultMutableTreeNode) tree.getRoot();
    root.removeAllChildren();
    DefaultMutableTreeNode networkNode;
    DefaultMutableTreeNode stateNode;
    DefaultMutableTreeNode cityNode;
    ArrayList<Network> networkList = system.getNetworkList();
    for (int i = 0; i < networkList.size(); i++) {
      Network country = networkList.get(i);
      networkNode = new DefaultMutableTreeNode(country.getNetworkname());
      root.insert(networkNode, i);
      ArrayList<Network> stateList = country.getSubnetworklist();
      DefaultMutableTreeNode enterpriseNode;
      for (int j = 0; j < stateList.size(); j++) {
        Network state = stateList.get(j);
        stateNode = new DefaultMutableTreeNode(state.getNetworkname());
        networkNode.insert(stateNode, j);
        ArrayList<Network> cityList = state.getSubnetworklist();
        for (int k = 0; k < cityList.size(); k++) {
          Network city = cityList.get(k);
          cityNode = new DefaultMutableTreeNode(city.getNetworkname());
          stateNode.insert(cityNode, k);
        }
      }
    }
    tree.reload();
  }
コード例 #2
0
  private void submitJButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_submitJButtonActionPerformed

    Enterprise.EnterpriseType entType =
        (Enterprise.EnterpriseType) enterpriseTypeJComboBox.getSelectedItem();
    if (entType.equals(Enterprise.EnterpriseType.RETAILER)) {

      Network citynet = (Network) cityJComboBox.getSelectedItem();

      for (Network country : system.getNetworkList()) {
        for (Network state : country.getSubnetworklist()) {
          for (Network city : state.getSubnetworklist()) {
            String name = enterpriseNameJTextField.getText();
            if (city.getNetworkname().equalsIgnoreCase(String.valueOf(citynet))) {

              Enterprise e =
                  city.getEnterpriseDirectory()
                      .createAndAddEnterprise(name, Enterprise.EnterpriseType.RETAILER);
              // e.setName(name);
              populateEnterpriseNetworkTable(citynet);
            }
          }
        }
      }
      JOptionPane.showMessageDialog(null, "created successfully");
      // populateEnterpriseNetworkTable();
    }
  } // GEN-LAST:event_submitJButtonActionPerformed
コード例 #3
0
  private void populateEnterpriseNetworkTable(Network n) {

    //        for (Network country : system.getNetworkList())
    //            for (Network state : country.getSubnetworklist())
    //                for (Network city : state.getSubnetworklist())

    DefaultTableModel model = (DefaultTableModel) InfoJTable.getModel();
    model.setRowCount(0);
    for (Enterprise ent : n.getEnterpriseDirectory().getEnterpriseList()) {
      Object row[] = new Object[3];
      row[0] = ent.getName();
      row[1] = n.getNetworkname() + " , " + n.getNetworkname() + " , " + n.getNetworkname();
      row[2] = ent.getEnterpriseType();
      model.addRow(row);
    }
  }
コード例 #4
0
 private void networkJTreeValueChanged(
     javax.swing.event.TreeSelectionEvent evt) { // GEN-FIRST:event_networkJTreeValueChanged
   // TODO add your handling code here:
   DefaultMutableTreeNode selectedNode =
       (DefaultMutableTreeNode) networkJTree.getLastSelectedPathComponent();
   if (selectedNode != null) {
     for (Network country : system.getNetworkList()) {
       if (selectedNode.toString().equalsIgnoreCase((country.getNetworkname()))) {
         network = country;
         break;
       }
       for (Network state : country.getSubnetworklist()) {
         if (selectedNode.toString().equalsIgnoreCase((state.getNetworkname()))) {
           network = state;
           break;
         }
       }
     }
   } else {
     network = null;
   }
 } // GEN-LAST:event_networkJTreeValueChanged