Package org.eclipse.gef.examples.logicdesigner.model

Examples of org.eclipse.gef.examples.logicdesigner.model.Wire


* ConnectionEditPart's source.
*
* @return  ConnectionAnchor.
*/
public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connEditPart) {
  Wire wire = (Wire) connEditPart.getModel();
  return getNodeFigure().getConnectionAnchor(wire.getSourceTerminal());
}
View Full Code Here


* ConnectionEditPart's target.
*
* @return  ConnectionAnchor.
*/
public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connEditPart) {
  Wire wire = (Wire) connEditPart.getModel();
  return getNodeFigure().getConnectionAnchor(wire.getTargetTerminal());
}
View Full Code Here

  return command;
}

protected Command getConnectionCreateCommand(CreateConnectionRequest request) {
  ConnectionCommand command = new ConnectionCommand();
  command.setWire(new Wire());
  command.setSource(getLogicSubpart());
  ConnectionAnchor ctor = getLogicEditPart().getSourceConnectionAnchor(request);
  command.setSourceTerminal(getLogicEditPart().mapConnectionAnchorToTerminal(ctor));
  request.setStartCommand(command);
  return command;
View Full Code Here

    editor.drag(100, 20, 130, 20);
    editor.click(130, 20);

    final SWTBotGefEditPart circuitPart = editor.editParts(instanceOf(CircuitEditPart.class)).get(0);
    final SWTBotGefConnectionEditPart wirePart = circuitPart.sourceConnections().get(0);
    final Wire wire = (Wire) (wirePart.part()).getModel();
    final Connection connection = (Connection) wirePart.part().getFigure();

    editor.activateTool("Select");
    assertEquals("Select", getActiveToolLabel());

    Point startMove = connection.getPoints().getMidpoint().getCopy();
    editor.click(startMove.x, startMove.y);

   
   
    /* we need to wait element selection before proceed or drag will fail */
    syncWithUIThread();
    assertTrue(editor.selectedEditParts().contains(wirePart));

    assertEquals(0, wire.getBendpoints().size());

    editor.drag(startMove.x, startMove.y, 130, 250);
    /* we need to wait the drag operates */
    syncWithUIThread();

    assertEquals(1, wire.getBendpoints().size());
    /* we do not check the location, as WireBendpoint overrides getLocation to return null */
  }
 
View Full Code Here

    editor.activateTool("Select");
    assertEquals("Select", getActiveToolLabel());

    final SWTBotGefEditPart circuitPart = editor.editParts(instanceOf(CircuitEditPart.class)).get(0);
    final SWTBotGefConnectionEditPart wirePart = circuitPart.sourceConnections().get(0);
    final Wire wire = (Wire) wirePart.part().getModel();

    assertEquals(0, wire.getBendpoints().size());
    wirePart.createBenpoint(130, 250);
    /* we need to wait the drag operates */
    syncWithUIThread();
    assertEquals(1, wire.getBendpoints().size());
  }
View Full Code Here

    for (int i = 0; i < children.size(); i++)
      deleteConnections((LogicSubpart)children.get(i));
  }
  sourceConnections.addAll(part.getSourceConnections());
  for (int i = 0; i < sourceConnections.size(); i++) {
    Wire wire = (Wire)sourceConnections.get(i);
    wire.detachSource();
    wire.detachTarget();
  }
  targetConnections.addAll(part.getTargetConnections());
  for (int i = 0; i < targetConnections.size(); i++) {
    Wire wire = (Wire)targetConnections.get(i);
    wire.detachSource();
    wire.detachTarget();
  }
}
View Full Code Here

  primExecute();
}

private void restoreConnections() {
  for (int i = 0; i < sourceConnections.size(); i++) {
    Wire wire = (Wire)sourceConnections.get(i);
    wire.attachSource();
    wire.attachTarget();
  }
  sourceConnections.clear();
  for (int i = 0; i < targetConnections.size(); i++) {
    Wire wire = (Wire)targetConnections.get(i);
    wire.attachSource();
    wire.attachTarget();
  }
  targetConnections.clear();
}
View Full Code Here

public boolean canExecute(){
  if (target != null) {
    Vector conns = target.getConnections();
    Iterator i = conns.iterator();
    while (i.hasNext()) {
      Wire conn = (Wire)i.next();
      if (targetTerminal != null && conn.getTargetTerminal() != null)
        if (conn.getTargetTerminal().equals(targetTerminal)
            && conn.getTarget().equals(target))
          return false;
    }
  }
  return true;
}
View Full Code Here

    }
  }
 
  Iterator i = oldPart.getTargetConnections().iterator();
  while (i.hasNext()) {
    Wire connection = (Wire)i.next();
    Wire newConnection = new Wire();
    newConnection.setValue(connection.getValue());
    newConnection.setTarget(newPart);
    newConnection.setTargetTerminal(connection.getTargetTerminal());
    newConnection.setSourceTerminal(connection.getSourceTerminal());
    newConnection.setSource(connection.getSource());
 
    Iterator b = connection.getBendpoints().iterator();
    Vector newBendPoints = new Vector();
   
    while (b.hasNext()) {
      WireBendpoint bendPoint = (WireBendpoint)b.next();
      WireBendpoint newBendPoint = new WireBendpoint();
      newBendPoint.setRelativeDimensions(bendPoint.getFirstRelativeDimension(),
          bendPoint.getSecondRelativeDimension());
      newBendPoint.setWeight(bendPoint.getWeight());
      newBendPoints.add(newBendPoint);
    }
   
    newConnection.setBendpoints(newBendPoints);
    newConnections.add(newConnection);
  }
 
 
  if (index < 0) {
View Full Code Here

 
  // go through and set the source of each connection to the proper source.
  Iterator c = newConnections.iterator();
 
  while (c.hasNext()) {
    Wire conn = (Wire)c.next();
    LogicSubpart source = conn.getSource();
    if (connectionPartMap.containsKey(source)) {
      conn.setSource((LogicSubpart)connectionPartMap.get(source));
      conn.attachSource();
      conn.attachTarget();
    }
  }
 
  if (hGuide != null) {
    hGuideCommand = new ChangeGuideCommand(
View Full Code Here

TOP

Related Classes of org.eclipse.gef.examples.logicdesigner.model.Wire

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.