Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Multiple view for the same semantic model
Multiple view for the same semantic model [message #521723] Thu, 18 March 2010 15:14 Go to next message
cuong  is currently offline cuong Friend
Messages: 4
Registered: March 2010
Junior Member
Hi everybody,

I am trying to create multiple view (on the same diagram) for the same semantic model.

On GMF tips website, we have "Creating New Elements And Corresponding Views ", but this is to create a new view + semantic model at the same time. I already have a semantic model (EObject) and its notation view on the diagram. I want to create one more notation view on the same diagram. Any ideas how to do it ?

Thanks very much in advance !!!!
Re: Multiple view for the same semantic model [message #521779 is a reply to message #521723] Thu, 18 March 2010 17:32 Go to previous messageGo to next message
Ali Koudri is currently offline Ali KoudriFriend
Messages: 118
Registered: July 2009
Senior Member
How do you plan to create your view ? Through DnD ?

Le 18/03/2010 16:14, cuong a écrit :
> Hi everybody,
>
> I am trying to create multiple view (on the same diagram) for the same
> semantic model.
> On GMF tips website, we have "http://wiki.eclipse.org/GMF_Tips ", but
> this is to create a new view + semantic model at the same time. I
> already have a semantic model (EObject) and its notation view on the
> diagram. I want to create one more notation view on the same diagram.
> Any ideas how to do it ?
>
> Thanks very much in advance !!!!
Re: Multiple view for the same semantic model [message #521925 is a reply to message #521779] Fri, 19 March 2010 10:44 Go to previous messageGo to next message
cuong  is currently offline cuong Friend
Messages: 4
Registered: March 2010
Junior Member
Hi,

Thanks for reply. I'm sorry for my unclear post. Let's say I have an EObject A and want to have to 2 nodes A1 and A2 on the diagram that correspond to the same EObject A.

One simple scenario is to right click on A1 and then click on sth like "Duplicate.." then I would like to have a duplicate node A2 on the diagram.

I hope it's clear now Smile.

[Updated on: Fri, 19 March 2010 10:46]

Report message to a moderator

Re: Multiple view for the same semantic model [message #522093 is a reply to message #521925] Fri, 19 March 2010 21:40 Go to previous messageGo to next message
Ali Koudri is currently offline Ali KoudriFriend
Messages: 118
Registered: July 2009
Senior Member
See below.

Le 19/03/2010 11:44, cuong a écrit :
> Hi,
>
> Thanks for reply. I'm sorry for my unclear post. Let's say I have an
> EObject A and want to have to 2 nodes A1 and A2 on the diagram that
> correspond to the same EObject a.
> I hope it's clear now :).

Not really. You want to use the generated to create one domain object
and two nodes at the same time ? Do you want your tool to create just
notational element that references domain elements ? Please be clearer.
Re: Multiple view for the same semantic model [message #522317 is a reply to message #522093] Mon, 22 March 2010 10:02 Go to previous messageGo to next message
cuong  is currently offline cuong Friend
Messages: 4
Registered: March 2010
Junior Member
Hi, please take a look at my editor

http://s3.postimage.org/7LgKA.jpg

It is an agent modeling editor. Let say we create an agent "Actor 24" using the palette tool. Then we want to duplicate the view of this actor to have another view of "Actor 24" as shown in the above screen shot. Both of these "Actor 24" corresponds to the same domain model.

I know how to add one new agent programmatically but don't know how to create a new view of it from an existing domain model of an agent.

I hope this is clearer. Thanks for your support and patience Smile

Regards,
Re: Multiple view for the same semantic model [message #522321 is a reply to message #522317] Mon, 22 March 2010 10:34 Go to previous messageGo to next message
Salva is currently offline SalvaFriend
Messages: 29
Registered: July 2009
Junior Member
Hi!

If the notation is the same for the original and the copy you can try using shortcuts

Regards,

Salva.
Re: Multiple view for the same semantic model [message #522331 is a reply to message #522317] Mon, 22 March 2010 11:47 Go to previous messageGo to next message
Ali Koudri is currently offline Ali KoudriFriend
Messages: 118
Registered: July 2009
Senior Member
Ok, you have several ways to do that. The simplest way I think is to
provide a keyboard shortcut to duplicate your view (Ctrl + D) and
install a new policy to manage related command. See CreateViewRequest
class as well as its nested class CreateViewDescriptor. Let me know if
you need more explanations.

Cheers.

Le 22/03/2010 11:02, cuong a écrit :
> Hi, please take a look at my editor
> http://www.postimage.org/image.php?v=Pq7LgKA
>
> It is an agent modeling editor. Let say we create an agent "Actor 24"
> using the palette tool. Then we want to duplicate the view of this actor
> to have another view of "Actor 24" as shown in the above screen shot.
> Both of these "Actor 24" corresponds to the same domain model.
> I know how to add one new agent programmatically but don't know how to
> create a new view of it from an existing domain model of an agent.
> I hope this is clearer. Thanks for your support and patience :)
>
> Regards,
Re: Multiple view for the same semantic model [message #522675 is a reply to message #522331] Tue, 23 March 2010 15:04 Go to previous messageGo to next message
cuong  is currently offline cuong Friend
Messages: 4
Registered: March 2010
Junior Member
Hi Ali,

Thanks for replying. Based on your suggestion I create a new edit policy ActorDuplicateViewPolicy which extends OpenEditPolicy

public class ActorDuplicateViewPolicy extends OpenEditPolicy{

@Override
protected Command getOpenCommand(Request request) {
final TransactionalEditingDomain ted;

//I get the ActorEditPart
ActorEditPart actor = (ActorEditPart)getHost();
//I get the editing domain
ted = actor.getEditingDomain();
//get the diagramEditor
TroposModelEditPart troposModel = (TroposModelEditPart)actor.getParent();
Diagram diagramView = troposModel.getDiagramView();
//create a command the duplicate the view
AbstractTransactionalCommand command = new CreateCommand(ted, viewDescriptor, diagramView);

return new ICommandProxy(command);
}

}

My idea is to double click on an Actor to duplicate them on the diagram view. So inside getOpenCommand function, I use CreateCommand to create a new view for Actor. But I have no idea how to create a correct viewDescriptor. Or maybe CreateCommand is not the right command to duplicate a view ?

Waiting for your reply Smile...

Re: Multiple view for the same semantic model [message #522743 is a reply to message #522675] Tue, 23 March 2010 19:35 Go to previous messageGo to next message
Ali Koudri is currently offline Ali KoudriFriend
Messages: 118
Registered: July 2009
Senior Member
According to related documentation:

"This edit policy handles double click (open) gestures on shapes. When
the user double clicks on an edit part, GEF creates a REQ_OPEN request
and subclasses of this edit policy should handle that request. This
policy should be installed with the policy role OPEN_ROLE. Normally, the
corresponding edit policy role would be defined in EditPolicy, but no
such role currently exists."

I guess you know what you are doing. See below. You will probably have
to adapt the code presented since I never used this policy and I don't
know which kind of request is sent to controller.

Le 23/03/2010 16:04, cuong a écrit :
> Hi Ali,
>
> Thanks for replying. Based on your suggestion I create a new edit policy
> ActorDuplicateViewPolicy which extends OpenEditPolicy
>
> public class ActorDuplicateViewPolicy extends OpenEditPolicy{
>
> @Override
> protected Command getOpenCommand(Request request) {
//retrieve the view targeted by the request
Object element = request.getObjects().get(0);
List<CreateViewRequest.ViewDescriptor> descriptors =
new ArrayList<CreateViewRequest.ViewDescriptor>();
CreateViewRequest.ViewDescriptor viewDescriptor =
new CreateViewRequest.ViewDescriptor(
new EObjectAdapter((EObject) element),
Node.class,
((IHintedType)
XXXElementTypes.getElementType(XXXEditPart.VISUAL_ID)).getSe manticHint(),
getDiagramPreferencesHint());
viewDescriptor.setPersisted(true);
descriptors.add(viewDescriptor);
Command res = null;
if (!descriptors.isEmpty()) {
res = createViews(request, descriptors);
}
if (res == null)
return UnexecutableCommand.INSTANCE;
return res;

> }

private Command createViews(
Request request, List<CreateViewRequest.ViewDescriptor> viewDescriptors)
{
CreateViewRequest createViewRequest =
new CreateViewRequest(viewDescriptors);
//FIXME: set location of new view next to current location
createViewRequest.setLocation(request.getLocation());
Command createCommand = getHost().getCommand(createViewRequest);
if (createCommand != null) {
List result = (List) createViewRequest.getNewObject();
dropRequest.setResult(result);
ArrangeRequest arrangeRequest = new ArrangeRequest(
RequestConstants.REQ_ARRANGE_DEFERRED);
arrangeRequest.setViewAdaptersToArrange(result);
createCommand.chain(getHost().getCommand(arrangeRequest));
}
return createCommand;
}

private View getHostView() {
return (View) (getHost().getModel());
}

private PreferencesHint getDiagramPreferencesHint() {
return ((IGraphicalEditPart)getHost()).getDiagramPreferencesHint();
}

Hope it will help.
Cheers.

>
> }
>
> My idea is to double click on an Actor to duplicate them on the diagram
> view. So inside getOpenCommand function, I use CreateCommand to create a
> new view for Actor. But I have no idea how to create a correct
> viewDescriptor. Or maybe CreateCommand is not the right command to
> duplicate a view ?
> Waiting for your reply :)...
>
>
Re: Multiple view for the same semantic model [message #522744 is a reply to message #522743] Tue, 23 March 2010 19:39 Go to previous message
Ali Koudri is currently offline Ali KoudriFriend
Messages: 118
Registered: July 2009
Senior Member
Le 23/03/2010 20:35, exquisitus a écrit :
> According to related documentation:
>
> "This edit policy handles double click (open) gestures on shapes. When
> the user double clicks on an edit part, GEF creates a REQ_OPEN request
> and subclasses of this edit policy should handle that request. This
> policy should be installed with the policy role OPEN_ROLE. Normally, the
> corresponding edit policy role would be defined in EditPolicy, but no
> such role currently exists."
>
> I guess you know what you are doing. See below. You will probably have
> to adapt the code presented since I never used this policy and I don't
> know which kind of request is sent to controller.
>
> Le 23/03/2010 16:04, cuong a écrit :
>> Hi Ali,
>>
>> Thanks for replying. Based on your suggestion I create a new edit policy
>> ActorDuplicateViewPolicy which extends OpenEditPolicy
>>
>> public class ActorDuplicateViewPolicy extends OpenEditPolicy{
>>
>> @Override
>> protected Command getOpenCommand(Request request) {
> //retrieve the view targeted by the request
> Object element = request.getObjects().get(0);
> List<CreateViewRequest.ViewDescriptor> descriptors =
> new ArrayList<CreateViewRequest.ViewDescriptor>();
> CreateViewRequest.ViewDescriptor viewDescriptor =
> new CreateViewRequest.ViewDescriptor(
> new EObjectAdapter((EObject) element),
> Node.class,
> ((IHintedType)
> XXXElementTypes.getElementType(XXXEditPart.VISUAL_ID)).getSe manticHint(), getDiagramPreferencesHint());
>
> viewDescriptor.setPersisted(true);
> descriptors.add(viewDescriptor);
> Command res = null;
> if (!descriptors.isEmpty()) {
> res = createViews(request, descriptors);
> }
> if (res == null)
> return UnexecutableCommand.INSTANCE;
> return res;
>
>> }
>
> private Command createViews(
> Request request, List<CreateViewRequest.ViewDescriptor> viewDescriptors)
> {
> CreateViewRequest createViewRequest =
> new CreateViewRequest(viewDescriptors);
> //FIXME: set location of new view next to current location
> createViewRequest.setLocation(request.getLocation());
> Command createCommand = getHost().getCommand(createViewRequest);
> if (createCommand != null) {
> List result = (List) createViewRequest.getNewObject();
> dropRequest.setResult(result);
sorry: request.setResult(result); (this method has been adapted from my
DnD policy)
> ArrangeRequest arrangeRequest = new ArrangeRequest(
> RequestConstants.REQ_ARRANGE_DEFERRED);
> arrangeRequest.setViewAdaptersToArrange(result);
> createCommand.chain(getHost().getCommand(arrangeRequest));
> }
> return createCommand;
> }
>
> private View getHostView() {
> return (View) (getHost().getModel());
> }
>
> private PreferencesHint getDiagramPreferencesHint() {
> return ((IGraphicalEditPart)getHost()).getDiagramPreferencesHint();
> }
>
> Hope it will help.
> Cheers.
>
>>
>> }
>>
>> My idea is to double click on an Actor to duplicate them on the diagram
>> view. So inside getOpenCommand function, I use CreateCommand to create a
>> new view for Actor. But I have no idea how to create a correct
>> viewDescriptor. Or maybe CreateCommand is not the right command to
>> duplicate a view ?
>> Waiting for your reply :)...
>>
>>
>
Previous Topic:Label centered ?
Next Topic:Remove Arrow close to Node
Goto Forum:
  


Current Time: Wed Sep 30 22:32:16 GMT 2020

Powered by FUDForum. Page generated in 0.03185 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top