[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.tools.gef] Re: Please Help!!!
|
What does "it doesn't work" mean? You need to be a little more descriptive.
You shouldn't use CreateConnectionRequest.getTargetEditPart() (and
admittedly, it is confusing what it is doing -- perhaps even a bug). Every
EditPolicy knows the of the EditPart it is installed on: getHost(). So, if
getConnectionCreateCommand() is invoked, getHost() will give you the source
of the connection and if getConnectionCompleteCommand() is invoked,
getHost() will give you the target of the connection. That, however, is not
what your problem is here.
If you got the first scenario working (one input, one output), you should be
able to get this working too. Your logic seems correct, so you'll just have
to debug to see what you're doing wrong. Your Command implements
canExecute() properly, right?
"Jose" <jdelgad@xxxxxxxxxxxxx> wrote in message
news:64170d3285b1528d1e9c9e36ed813783$1@xxxxxxxxxxxxxxxxxx
> Hi everyone,
>
> my problem is the following: I am developing a GEF based application,
> in which all the figures has only one input connection and one output
> connection. But now, I would like to create a figure which has several
> input connections and only one output connection. I have changed the
> method getConnectionCompleteCommand but it doesn't work. This is the code
> for the getConnectionCompleteCommand and getConnectionCreateCommand
> methods:
>
> protected Command getConnectionCompleteCommand(
> CreateConnectionRequest request) {
>
> JclecEditPart target = (JclecEditPart) request.getTargetEditPart();
>
> if(getJCLECSubpart() instanceof InitModel){
> return null;
> }
>
> if(target.hasInputConnections() && !(getJCLECSubpart() instanceof
> CollectorModel)){
>
> return null;
> }
> else{
>
> ConnectionCommand command = (ConnectionCommand) request
> .getStartCommand();
> command.setTarget(getJCLECSubpart());
> ConnectionAnchor ctor = getJCLECEditPart().getTargetConnectionAnchor(
> request);
>
> command.setTargetTerminal(getJCLECEditPart()
> .mapConnectionAnchorToTerminal(ctor));
>
> return command;
> }
>
> }
>
> protected Command getConnectionCreateCommand(CreateConnectionRequest
> request) {
>
> JclecEditPart target = (JclecEditPart) request.getTargetEditPart();
>
> if(getJCLECSubpart() instanceof EndModel)
> return null;
>
> if(target.hasOutputConnections()){
> 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;
> }
>
> }
>
>
> The figure which should have several input connections and only one
> output connection is "CollectorModel". Could you tell me why the code
> above doesn't work? What others method should I modify?
> Please, help me!!!
>
> Thank you very much.
>
>
>
> --Jose.
>
>