Example #1
0
 private void closingEvent() {
   clearPath();
   _parent.closePathFrame(_block);
   _loc = getLocation(_loc);
   _dim = getSize(_dim);
   dispose();
 }
Example #2
0
  /**
   * Construct the array of icons that displays the path
   *
   * @param path
   */
  private ArrayList<Positionable> makePathGroup(OPath path) {
    Portal fromPortal = path.getFromPortal();
    Portal toPortal = path.getToPortal();
    String name = path.getName();

    java.util.List<Positionable> list = _parent.getCircuitGroup();
    if (log.isDebugEnabled()) {
      log.debug("makePathGroup for " + name + " CircuitGroup size= " + list.size());
    }
    ArrayList<Positionable> pathGroup = new ArrayList<Positionable>();
    for (int i = 0; i < list.size(); i++) {
      Positionable pos = list.get(i);
      if (pos instanceof IndicatorTrack) {
        ArrayList<String> paths = ((IndicatorTrack) pos).getPaths();
        if (paths != null) {
          for (int j = 0; j < paths.size(); j++) {
            if (name.equals(paths.get(j))) {
              ((IndicatorTrack) pos).setControlling(true);
              pathGroup.add(pos);
            }
          }
        }
      } else {
        PortalIcon icon = (PortalIcon) pos;
        Portal portal = icon.getPortal();
        if (portal.equals(fromPortal)) {
          pathGroup.add(icon);
        } else if (portal.equals(toPortal)) {
          pathGroup.add(icon);
        }
      }
    }
    return pathGroup;
  }
Example #3
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();
  }
Example #4
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);
       }
     }
   }
 }
Example #5
0
  private JPanel makeContentPanel() {
    JPanel pathPanel = new JPanel();
    pathPanel.setLayout(new BoxLayout(pathPanel, BoxLayout.Y_AXIS));

    pathPanel.add(Box.createVerticalStrut(STRUT_SIZE));
    JPanel panel = new JPanel();
    panel.add(new JLabel(Bundle.getMessage("PathTitle", _block.getDisplayName())));
    pathPanel.add(panel);

    _pathListModel = new PathListModel();
    _pathList = new JList<OPath>();
    _pathList.setModel(_pathListModel);
    _pathList.addListSelectionListener(this);
    _pathList.setCellRenderer(new PathCellRenderer());
    JScrollPane pane = new JScrollPane(_pathList);
    pathPanel.add(pane);
    pathPanel.add(Box.createVerticalStrut(STRUT_SIZE));

    panel = new JPanel();
    panel.setLayout(new FlowLayout());

    JButton clearButton = new JButton(Bundle.getMessage("buttonClearSelection"));
    clearButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent a) {
            clearListSelection();
          }
        });
    clearButton.setToolTipText(Bundle.getMessage("ToolTipClearList"));
    panel.add(clearButton);
    pathPanel.add(panel);
    pathPanel.add(Box.createVerticalStrut(STRUT_SIZE));

    panel = new JPanel();
    panel.add(
        CircuitBuilder.makeTextBoxPanel(false, _pathName, "pathName", true, "TooltipPathName"));
    _pathName.setPreferredSize(new Dimension(300, _pathName.getPreferredSize().height));
    pathPanel.add(panel);

    panel = new JPanel();
    JButton addButton = new JButton(Bundle.getMessage("buttonAddPath"));
    addButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent a) {
            addPath();
          }
        });
    addButton.setToolTipText(Bundle.getMessage("ToolTipAddPath"));
    panel.add(addButton);

    JButton changeButton = new JButton(Bundle.getMessage("buttonChangeName"));
    changeButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent a) {
            changePathName();
          }
        });
    changeButton.setToolTipText(Bundle.getMessage("ToolTipChangeName"));
    panel.add(changeButton);

    JButton deleteButton = new JButton(Bundle.getMessage("buttonDeletePath"));
    deleteButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent a) {
            deletePath();
          }
        });
    deleteButton.setToolTipText(Bundle.getMessage("ToolTipDeletePath"));
    panel.add(deleteButton);

    pathPanel.add(panel);
    pathPanel.add(Box.createVerticalStrut(STRUT_SIZE));

    JPanel pp = new JPanel();
    //      pp.setLayout(new BoxLayout(pp, BoxLayout.X_AXIS));
    _length.setText("0.0");
    pp.add(CircuitBuilder.makeTextBoxPanel(false, _length, "length", true, "TooltipPathLength"));
    _length.setPreferredSize(new Dimension(100, _length.getPreferredSize().height));
    _length.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            _pathChange = true;
          }
        });
    _units = new JToggleButton("", !_block.isMetric());
    _units.setToolTipText(Bundle.getMessage("TooltipPathLength"));
    _units.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            changeUnits();
          }
        });
    pp.add(_units);
    pathPanel.add(pp);
    pathPanel.add(Box.createVerticalStrut(STRUT_SIZE));

    panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    JLabel l = new JLabel(Bundle.getMessage("enterNewPath"));
    l.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    panel.add(l);
    l = new JLabel(Bundle.getMessage("selectPathIcons"));
    l.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    panel.add(l);
    l = new JLabel(Bundle.getMessage("pressAddButton"));
    l.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    panel.add(l);
    panel.add(Box.createVerticalStrut(STRUT_SIZE / 2));
    l = new JLabel(Bundle.getMessage("selectPath"));
    l.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    panel.add(l);
    l = new JLabel(Bundle.getMessage("editPathIcons"));
    l.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    panel.add(l);
    panel.add(Box.createVerticalStrut(STRUT_SIZE / 2));
    l = new JLabel(Bundle.getMessage("throwPathTO"));
    l.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    panel.add(l);
    l = new JLabel(Bundle.getMessage("holdShiftDown"));
    l.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    panel.add(l);
    JPanel p = new JPanel();
    p.add(panel);
    pathPanel.add(p);

    pathPanel.add(Box.createVerticalStrut(STRUT_SIZE));
    pathPanel.add(MakeButtonPanel());
    changeUnits();
    return pathPanel;
  }