Beispiel #1
0
  private void changePathName() {
    String name = _pathName.getText();
    OPath path = _pathList.getSelectedValue();
    if (name == null || name.trim().length() == 0 || path == null) {
      JOptionPane.showMessageDialog(
          this,
          Bundle.getMessage("changePathName"),
          Bundle.getMessage("makePath"),
          JOptionPane.INFORMATION_MESSAGE);
      return;
    }
    String oldName = path.getName();
    OPath oldPath = _block.getPathByName(name);
    if (oldPath != null) {
      JOptionPane.showMessageDialog(
          this,
          Bundle.getMessage("duplicatePathName", name, _block.getDisplayName()),
          Bundle.getMessage("makePath"),
          JOptionPane.INFORMATION_MESSAGE);
      return;
    }
    path.setName(name);

    // Change the path name in the track icons
    java.util.List<Positionable> list = _parent.getCircuitGroup();
    // cannot do remove/add path on the fly due to conncurrent access with Iterator
    ArrayList<IndicatorTrack> changeGroup = new ArrayList<IndicatorTrack>();
    for (int i = 0; i < list.size(); i++) {
      if (list.get(i) instanceof IndicatorTrack) {
        IndicatorTrack icon = (IndicatorTrack) list.get(i);
        ArrayList<String> paths = icon.getPaths();
        if (paths != null) {
          for (int j = 0; j < paths.size(); j++) {
            if (oldName.equals(paths.get(j))) {
              changeGroup.add(icon);
            }
          }
        }
      }
    }
    for (int i = 0; i < changeGroup.size(); i++) {
      IndicatorTrack track = changeGroup.get(i);
      track.removePath(oldName);
      track.addPath(name);
    }
    _pathChange = false;
    _pathListModel.dataChange();
  }
Beispiel #2
0
 private void changePathNameInIcons(String name, OPath path) {
   // add or remove path name from IndicatorTrack icons
   Iterator<Positionable> iter = _parent.getCircuitGroup().iterator();
   while (iter.hasNext()) {
     Positionable pos = iter.next();
     if (_pathGroup.contains(pos)) {
       if (pos instanceof IndicatorTrack) {
         ((IndicatorTrack) pos).addPath(name);
       }
     } else {
       if (pos instanceof IndicatorTrack) {
         ((IndicatorTrack) pos).removePath(name);
       } else {
         PortalIcon pi = (PortalIcon) pos;
         //                   pi.setStatus(PortalIcon.VISIBLE);
         Portal p = pi.getPortal();
         p.removePath(path);
       }
     }
   }
 }
Beispiel #3
0
 /**
  * Sets the path icons for display
  *
  * @param pathChanged
  */
 protected void updatePath(boolean pathChanged) {
   // to avoid ConcurrentModificationException now set data
   Iterator<Positionable> iter = _pathGroup.iterator();
   while (iter.hasNext()) {
     Positionable pos = iter.next();
     if (pos instanceof IndicatorTrack) {
       ((IndicatorTrack) pos).addPath(TEST_PATH);
     } else {
       ((PortalIcon) pos).setStatus(PortalIcon.PATH);
     }
   }
   _pathChange = pathChanged;
   String name = _pathName.getText();
   if (name == null || name.length() == 0) {
     JOptionPane.showMessageDialog(
         this,
         Bundle.getMessage("needPathName"),
         Bundle.getMessage("makePath"),
         JOptionPane.INFORMATION_MESSAGE);
   } else {
   }
 }