public void mouseReleased(MouseEvent e) { if (ltool.isEnabled()) { if (endComponent instanceof GigEDescriptor) endComponent = ((GigEDescriptor) endComponent).getUnlinkedPort(); if (!ltool.addLink(linkGraphic, endComponent)) { ExpCoordinator.print( new String( "LinkTool.ComponentListener::mouseReleased from " + startComponent.getLabel() + " cancelled"), TEST_ADD); if (ltool.isVirtualTopology()) ltool .expCoordinator .getCurrentExp() .getVirtualTopology() .getTopologyPanel() .removeLink(linkGraphic); else ExpCoordinator.getMainWindow().getTopologyPanel().removeLink(linkGraphic); } startComponent = null; endComponent = null; linkGraphic = null; ltool.setEnabled(false); } }
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); } } }