示例#1
0
 public int getRowCount() {
   if (scenario != null && scenario.getDataSource() != null) {
     int count = 0;
     for (Edge edge : scenario.getDataSource().getEdgeLibrary()) {
       if ((networkTab.getEdgeTypeFilter() == null
               || edge.getEdgeType() == networkTab.getEdgeTypeFilter())
           && edge.getName()
               .toLowerCase()
               .contains(networkTab.getEdgeSearchText().toLowerCase())) {
         count++;
       }
     }
     return count;
   } else return 0;
 }
示例#2
0
 public void setValueAt(Object value, int row, int col) {
   if (col == 0) {
     Edge edge = (Edge) getValueAt(row, 1);
     if (value.equals(Boolean.TRUE)) {
       scenario.getNetwork().getEdges().add(edge);
       for (Node node : scenario.getDataSource().getNodeLibrary()) {
         if (!scenario.getNetwork().getNodes().contains(node)
             && (edge.getOrigin().equals(node) || edge.getDestination().equals(node))) {
           scenario.getNetwork().getNodes().add(node);
         }
       }
     } else {
       List<Object> uses = networkTab.getScenario().getEdgeUses(edge);
       if (uses.size() > 0) {
         JPanel warningPanel = new JPanel();
         warningPanel.setLayout(new GridBagLayout());
         GridBagConstraints c = new GridBagConstraints();
         c.insets = new Insets(2, 2, 2, 2);
         c.gridx = 0;
         c.gridy = 0;
         c.weightx = 0;
         c.weighty = 0;
         c.anchor = GridBagConstraints.LINE_START;
         c.fill = GridBagConstraints.BOTH;
         warningPanel.add(
             new JLabel("The following use " + edge + " and must be changed before removal:"),
             c);
         c.gridy++;
         c.weighty = 1;
         DefaultListModel usagesList = new DefaultListModel();
         for (Object o : uses) {
           usagesList.addElement(o);
         }
         warningPanel.add(new JScrollPane(new JList(usagesList)), c);
         JOptionPane.showMessageDialog(
             networkTab.getScenarioPanel(),
             warningPanel,
             "SpaceNet Warning",
             JOptionPane.WARNING_MESSAGE);
       } else {
         scenario.getNetwork().remove(edge);
       }
     }
   }
   fireTableRowsUpdated(row, row);
   networkTab.getNetworkPanel().repaint();
 }
示例#3
0
 public Object getValueAt(int row, int col) {
   if (col == 0) {
     Edge edge = (Edge) getValueAt(row, 1);
     for (Edge e : scenario.getNetwork().getEdges()) {
       if (e.equals(edge)) return true;
     }
     return false;
   } else if (col == 2) return ((Edge) getValueAt(row, 1)).getOrigin();
   else if (col == 3) return ((Edge) getValueAt(row, 1)).getDestination();
   else {
     int count = 0;
     for (Edge edge : scenario.getDataSource().getEdgeLibrary()) {
       if ((networkTab.getEdgeTypeFilter() == null
               || edge.getEdgeType() == networkTab.getEdgeTypeFilter())
           && edge.getName()
               .toLowerCase()
               .contains(networkTab.getEdgeSearchText().toLowerCase())) {
         if (count == row) return edge;
         count++;
       }
     }
     return null;
   }
 }