[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools.gef] Re: Please Help!!!

try what I said.

Jose wrote:
Hi all,

I have tried what Gunay said, but it doesn't work. This is the code for the getConnectionCreateCommand and getConnectionCompleteCommand methods:

protected Command getConnectionCompleteCommand(
CreateConnectionRequest request) {

target = request.getSourceEditPart(); source = request.getTargetEditPart();


if(!sanityCheck(source,target)) { return UnexecutableCommand.INSTANCE; }


ModelObject model = (ModelObject) getHost().getModel();
if(model==null){
return null;
}
else{
ConnectionCommand command = (ConnectionCommand) request
.getStartCommand();
command.setTarget(getJCLECSubpart());
ConnectionAnchor ctor = getJCLECEditPart().getTargetConnectionAnchor(
request);
if (ctor == null)
return null;
command.setTargetTerminal(getJCLECEditPart()
.mapConnectionAnchorToTerminal(ctor));
return command;
}
}



also do sanity check for getReconnectTargetCommand and getReconnectSourceCommand


protected Command getConnectionCreateCommand(CreateConnectionRequest request) {
ModelObject model = (ModelObject) getHost().getModel();
if(model == null){
return null;
}
else{
ConnectionCommand command = new ConnectionCommand();
command.setConnection(new Arrow());
command.setSource(getJCLECSubpart());
ConnectionAnchor ctor = getJCLECEditPart().getSourceConnectionAnchor(
request);
command.setSourceTerminal(getJCLECEditPart()
.mapConnectionAnchorToTerminal(ctor));
request.setStartCommand(command);
return command;
}
}



Why it doesn't work? Please, help me. Thankyou very much.

  --Jose



public boolean sanityCheck(Node source, Node target){
    if(source.getModel().hasConnection()){
         return false;
    }
    if(target.getModel().hasConnection()){
          return false;
   }
}


This is the gist of what I do. ask your nodes if they already have connections, and if so, just return false;




CL