How to allow PollylineConnections to be re-connected [message #60642] |
Tue, 10 October 2006 19:57 |
Eclipse User |
|
|
|
Originally posted by: rbbnjmn.yahoo.com
I've looked at the tutorial notes on moving/re-connecting node
connections but don't see how to apply this after the 3.1 release.
Anyone know how to allow the user to move/re-connect connections ?
Thanks
Roy
|
|
|
Re: How to allow PollylineConnections to be re-connected [message #60644 is a reply to message #60642] |
Tue, 10 October 2006 22:26 |
Eclipse User |
|
|
|
Originally posted by: vcciubot.uwaterloo.ca
It's shown in the logic diagram example:
Basically, create an EditHelper for your connections:
public class ConnectionEditHelper extends AbstractEditHelper {
protected ICommand getReorientRelationshipCommand(
ReorientRelationshipRequest req) {
return new ReorientConnectionCommand(req);
}
}
and then return a command to reorient the connection:
public class ReorientConnectionCommand
extends EditElementCommand {
/**
* The reorient direction.
*/
private final int reorientDirection;
/**
* The relationship's new source or target.
*/
private final EObject newEnd;
/**
* Constructs a new command.
*
* @param request
* the reorient relationship request
*/
public ReorientConnectionCommand(ReorientRelationshipRequest request) {
super(request.getLabel(), request.getRelationship(), request);
this.reorientDirection = request.getDirection();
this.newEnd = request.getNewRelationshipEnd();
}
/**
* Reorients the wire.
*/
protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
IAdaptable info)
throws ExecutionException {
Connection connection = (Connection) getElementToEdit();
if (reorientDirection == ReorientRelationshipRequest.REORIENT_SOURCE) {
connection.setSrc((End) newEnd);
} else if (reorientDirection == ReorientRelationshipRequest.REORIENT_TARGET) {
connection.setDst((End) newEnd);
}
return CommandResult.newOKCommandResult(connection);
}
/**
* The source can be changed to a new output terminal. The target can be
* changed to a new target terminal.
*/
public boolean canExecute() {
if (reorientDirection == ReorientRelationshipRequest.REORIENT_SOURCE
&& !(newEnd instanceof Block)) {
return false;
}
if (reorientDirection == ReorientRelationshipRequest.REORIENT_TARGET
&& !(newEnd instanceof Block)) {
return false;
}
return super.canExecute();
}
}
On Tue, 10 Oct 2006 12:57:23 -0700, rbbnjmn wrote:
> I've looked at the tutorial notes on moving/re-connecting node
> connections but don't see how to apply this after the 3.1 release.
>
> Anyone know how to allow the user to move/re-connect connections ?
>
> Thanks
>
> Roy
|
|
|
Re: How to allow PollylineConnections to be re-connected [message #60651 is a reply to message #60644] |
Wed, 11 October 2006 09:44 |
Eclipse User |
|
|
|
Originally posted by: tobk.gmx.de
Vlad Ciubotariu wrote:
> It's shown in the logic diagram example:
>
> Basically, create an EditHelper for your connections:
I had a similar problem, so I tried this, too.
First to say: You forget to write that the Connection's EditPolicy's
getReorientCommand has to be Overwritten, too, since it returns a
UnexecutableCommand else. Still there are some problems:
Strangely the canExecute method returns only true when hovering over an
'allowed' node's external name label. It then returns the label's node's
impl, but not when hovering over the node itself. For nodes with an
internal label there seems to be no way to connect to.
Second, the command is executed and the model's source/target feature is
set, but the view is not updated but still shows the connection in it's old
place. Any ideas?
The Logic Diagram Example's project structure is so different from the usual
genrated structure, I doubt I could find out what's different so fast...
tobias
|
|
|
Re: How to allow PollylineConnections to be re-connected [message #60924 is a reply to message #60651] |
Wed, 11 October 2006 16:08 |
Eclipse User |
|
|
|
Originally posted by: vcciubot.uwaterloo.ca
My configuration is different from generated code:
I'm running vanilla semantic policies and create all the model
customization from the edit helpers. I know the generated code does a lot
of fine tuning from the customized semantic edit policies - mostly to
disallow creation of elements without the correct nesting specified in the
generator model.
So, try to comment out the installation of the customized edit policy
(look in the corresponding edit part for createDefaultEditPolicies()) and
create an edit helper for your connection type and register it in
plugin.xml.
My ConnectionEditPart has no customization other than createFigure().
Check to see whether the command to reorient the connection returned by
the ConnectionEditHelper is executable in the right case, i.e. when the
semantic element of the targeted edit part is of the right kind.
Give this a shot and let me know if it works.
vlad
On Wed, 11 Oct 2006 11:44:04 +0200, tobias wrote:
> Vlad Ciubotariu wrote:
>
>> It's shown in the logic diagram example:
>>
>> Basically, create an EditHelper for your connections:
>
> I had a similar problem, so I tried this, too.
>
> First to say: You forget to write that the Connection's EditPolicy's
> getReorientCommand has to be Overwritten, too, since it returns a
> UnexecutableCommand else. Still there are some problems:
>
> Strangely the canExecute method returns only true when hovering over an
> 'allowed' node's external name label. It then returns the label's node's
> impl, but not when hovering over the node itself. For nodes with an
> internal label there seems to be no way to connect to.
>
> Second, the command is executed and the model's source/target feature is
> set, but the view is not updated but still shows the connection in it's old
> place. Any ideas?
>
> The Logic Diagram Example's project structure is so different from the usual
> genrated structure, I doubt I could find out what's different so fast...
>
> tobias
|
|
|
Re: How to allow PollylineConnections to be re-connected [message #61044 is a reply to message #60924] |
Wed, 11 October 2006 21:57 |
Eclipse User |
|
|
|
Originally posted by: rbbnjmn.yahoo.com
Thanks for the help, but at this point I've tried about everything
to be able to reconnect connections.
I've got two ReorientConnectionCommand classes both of which always
return true for canExecute().
GefReorientConnectionCommand extends Command
ReorientConnectionCommand extends EditElementCommand
They are being used, but connection can't be re-connected...
Hmmm.
Let me know if you have ideas about hos to do this in GMF.
Thanks/Multumesc !
Roy
p.s. my wife is Romanian and I lived there for many years ;-)
"Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
news:pan.2006.10.11.16.08.24.614311@uwaterloo.ca...
>
> My configuration is different from generated code:
>
> I'm running vanilla semantic policies and create all the model
> customization from the edit helpers. I know the generated code does a lot
> of fine tuning from the customized semantic edit policies - mostly to
> disallow creation of elements without the correct nesting specified in the
> generator model.
>
> So, try to comment out the installation of the customized edit policy
> (look in the corresponding edit part for createDefaultEditPolicies()) and
> create an edit helper for your connection type and register it in
> plugin.xml.
>
> My ConnectionEditPart has no customization other than createFigure().
>
> Check to see whether the command to reorient the connection returned by
> the ConnectionEditHelper is executable in the right case, i.e. when the
> semantic element of the targeted edit part is of the right kind.
>
> Give this a shot and let me know if it works.
>
>
> vlad
>
>
>
> On Wed, 11 Oct 2006 11:44:04 +0200, tobias wrote:
>
>> Vlad Ciubotariu wrote:
>>
>>> It's shown in the logic diagram example:
>>>
>>> Basically, create an EditHelper for your connections:
>>
>> I had a similar problem, so I tried this, too.
>>
>> First to say: You forget to write that the Connection's EditPolicy's
>> getReorientCommand has to be Overwritten, too, since it returns a
>> UnexecutableCommand else. Still there are some problems:
>>
>> Strangely the canExecute method returns only true when hovering over an
>> 'allowed' node's external name label. It then returns the label's node's
>> impl, but not when hovering over the node itself. For nodes with an
>> internal label there seems to be no way to connect to.
>>
>> Second, the command is executed and the model's source/target feature is
>> set, but the view is not updated but still shows the connection in it's
>> old
>> place. Any ideas?
>>
>> The Logic Diagram Example's project structure is so different from the
>> usual
>> genrated structure, I doubt I could find out what's different so fast...
>>
>> tobias
>
|
|
|
Powered by
FUDForum. Page generated in 0.03623 seconds