protected void addLink(LinkGraphic lg) { LinkDescriptor comp = (LinkDescriptor) lg.getONLComponent(); ExpCoordinator.print( new String( "LinkTool::addLink " + comp.getPoint1().getLabel() + " to " + comp.getPoint2().getLabel())); lg.getONLComponent().setLabel(new String("explink" + count)); expCoordinator.getCurrentExp().addLink(comp); ++count; }
public void mousePressed(MouseEvent e) { if (ltool.isEnabled()) { startComponent = ((ONLComponentButton) e.getSource()).getONLComponent(); if (startComponent instanceof GigEDescriptor) { ExpCoordinator.print( new String( "LinkTool.ComponentListener.mousePressed gige startComponent:" + startComponent.getLabel()), TEST_GIGE); startComponent = ((GigEDescriptor) startComponent).getUnlinkedPort(); if (startComponent != null) ExpCoordinator.print( new String(" unlinked port: " + startComponent.getLabel()), TEST_GIGE); else ExpCoordinator.print(" unlinked port: null", TEST_GIGE); } if (startComponent instanceof HardwareHost) startComponent = ((HardwareHost) startComponent).getPort(0); endComponent = null; if (startComponent.isLinkable() && (!startComponent.isLinked())) { LinkDescriptor ld = ltool.createLinkDescriptor( startComponent); // new LinkDescriptor(ltool.getNextLabel(), startComponent, // ltool.currentBW, ltool.expCoordinator); linkGraphic = (LinkGraphic) ld.getGraphic(); if (linkGraphic.getONLComponent() == null) ExpCoordinator.print("LinkTool.ComponentListener::mousePressed onlcomp == null", 2); // linkGraphic = new LinkGraphic(); // linkGraphic.setPoint1(startComponent.getGraphic()); linkGraphic.setVisible(true); ltool .getTopologyPanel() .addLink(linkGraphic); // expCoordinator.getMainWindow().getTopologyPanel() // System.out.println("LinkTool.ComponentListener::mousePressed component " + // startComponent.getLabel()); setIntermediate( e.getPoint(), ((ONLComponentButton) e.getSource()).getONLComponent().getGraphic()); } else { ExpCoordinator.print( new String( "LinkTool::mousePressed startComponent " + startComponent.getLabel() + " is Linked"), 2); startComponent = null; ltool.setEnabled(false); } } }
protected boolean addLink( LinkGraphic lg, ONLComponent end_comp) // returns true if successfully added { if (lg == null) return false; LinkDescriptor comp = (LinkDescriptor) lg.getONLComponent(); ONLComponent start_comp = comp.getPoint1(); // fail link if end_comp is not a component, it's a loop, the end_comp is unlinkable or is // already linked if (end_comp == null || end_comp == start_comp || !end_comp.isLinkable() || end_comp.isLinked()) { if (end_comp == null) ExpCoordinator.print( new String("LinkTool.addLink " + comp.toString() + " fail end is null"), TEST_ADD); else { if (end_comp == start_comp) ExpCoordinator.print( new String( "LinkTool.addLink " + comp.toString() + " fail end(" + end_comp.getLabel() + ") is same as start"), TEST_ADD); if (!end_comp.isLinkable() || end_comp.isLinked()) ExpCoordinator.print( new String( "LinkTool.addLink " + comp.toString() + " fail diend(" + end_comp.getLabel() + ") unlinkable isLinkable:" + end_comp.isLinkable() + " isLinked:" + end_comp.isLinked()), TEST_ADD); } return false; } else { // 10G change for gige to gige connections remove GigE to GigE restriction // if (((start_comp instanceof GigEDescriptor.Port) || (start_comp instanceof GigEDescriptor)) // && // ((end_comp instanceof GigEDescriptor.Port) || (end_comp instanceof GigEDescriptor))) // return false; // 10G change return false if interface types not equal & not a GigE-GigE link if (!start_comp.getInterfaceType().equals(end_comp.getInterfaceType()) && !(((start_comp instanceof GigEDescriptor.Port) || (start_comp instanceof GigEDescriptor)) && ((end_comp instanceof GigEDescriptor.Port) || (end_comp instanceof GigEDescriptor)))) { ExpCoordinator.print( new String( "LinkTool.addLink " + comp.toString() + " fail diff interface start:" + start_comp.getLabel() + "(" + start_comp.getInterfaceType() + ") end:" + end_comp.getLabel() + "(" + end_comp.getInterfaceType() + ")"), TEST_ADD); return false; } // SUBNET:add call SubnetManager addLink here try { if (ExpCoordinator.isOldSubnet()) { // check for cycles if (expCoordinator.getTopology().isCycle(start_comp, end_comp)) return false; OldSubnetManager.addLink( (ONLComponent.PortBase) start_comp, (ONLComponent.PortBase) end_comp); } else SubnetManager.addLink( (ONLComponent.PortBase) start_comp, (ONLComponent.PortBase) end_comp); } catch (SubnetManager.SubnetException e) { ExpCoordinator.print( new String( "LinkTool.addLink failed (" + start_comp.getLabel() + ", " + end_comp.getLabel() + ") -- " + e.getMessage())); return false; } } comp.setPoint2(end_comp); addLink(lg); return true; }