Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » SWT property editor(2)
SWT property editor(2) [message #66141] Fri, 20 October 2006 09:37 Go to next message
Conor Missing name is currently offline Conor Missing nameFriend
Messages: 159
Registered: July 2009
Senior Member
Hi,

This is continued on from previous thread:

http://dev.eclipse.org/newslists/news.eclipse.modeling.gmf/m sg01605.html

I want to use a SWT display to view and edit the properties of my model
elements, accessed through double-clicking the elements (as described in
other threads).

I've changed the elements InfoEditPart, this calls the new
OpenEditorEditPolicy when double clicked (OPEN_ROLE):

protected void createDefaultEditPolicies() {
super.createDefaultEditPolicies();
installEditPolicy(
EditPolicyRoles.OPEN_ROLE,
new OpenEditorEditPolicy ());
}

The OpenEditorEditPolicy extends the OpenEditPolicy as described in:

http://dev.eclipse.org/newslists/news.eclipse.technology.gmf /msg03767.html


I've added comments, there are some parts I'm unsure of, what I'd like to
happen first is just to open a blank SWT with nothing on it. Next step, to
have it display properties of the emlement, Finally, be able to edit
properties.

The second System.out.println works, so I know it's doing something, but
how do I get the SWT dialog to come up? Thanks.







public class OpenEditorEditPolicy extends OpenEditPolicy {
protected Command getOpenCommand(Request request) { //request is the
location of the mouse pointer - what is command used for?


EditPart targetEditPart = getTargetEditPart(request); //the Editpart
is told the location of the mouse pointer


if (targetEditPart instanceof IGraphicalEditPart) { //if the mouse
location is part of the model(IGraphicalEditPart???)

IGraphicalEditPart editPart =
(IGraphicalEditPart)targetEditPart; //model editpart is told mouse
location???

View view = editPart.getNotationView();

if (view !=null){
EObject element =
ViewUtil.resolveSemanticElement(view); //gets the element that is at the
location
if (element instanceof Diagram) { // if the
element is in the model

// open a blank SWT dialog
Display d = new Display();
Shell s = new Shell(d, SWT.CLOSE|SWT.RESIZE);
s.setSize(300, 300);
s.pack();
s.open();
System.out.println("Double click called"); // this never
gets printed
return new ICommandProxy(new
OpenDiagramCommand(element)); // don't know what this does


}
System.out.println("Double click called 2");
// this DOES get printed
}

}
return null;
}
Re: SWT property editor(2) [message #66224 is a reply to message #66141] Fri, 20 October 2006 11:16 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Gaff,

Recently double-click support for openning diagram associated with the diagram
element was added to the GMF generative part: http://wiki.eclipse.org/index.php/GMF_New_and_Noteworthy#Bas ic_support_for_diagram_partitioning.
This functionality is under development right now, but it looks like you
still can gat some advantages of the generated code.

-----------------
Alex Shatalin
Re: SWT property editor(2) [message #66245 is a reply to message #66224] Fri, 20 October 2006 11:19 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Alex,

Sorry. This functionality is about openning new diagram upon the selected
diagram element... So, please skip my message.


-----------------
Alex Shatalin
Re: SWT property editor(2) [message #66310 is a reply to message #66141] Fri, 20 October 2006 11:46 Go to previous messageGo to next message
Artem Tikhomirov is currently offline Artem TikhomirovFriend
Messages: 222
Registered: July 2009
Senior Member
Guess, you didn't put notation.Diagram as you _semantic_ element, which is
NOT what usually people do. Hence, if (element instanceof Diagram) will
never be true. Check https://bugs.eclipse.org/bugs/show_bug.cgi?id=159479.


Artem

"Gaff" <conorgaff@hotmail.com> wrote in message
news:c8d3b02a693a2e2dfb95e2c3f633449b$1@www.eclipse.org...
> Hi,
>
> This is continued on from previous thread:
>
> http://dev.eclipse.org/newslists/news.eclipse.modeling.gmf/m sg01605.html
>
> I want to use a SWT display to view and edit the properties of my model
> elements, accessed through double-clicking the elements (as described in
> other threads).
>
> I've changed the elements InfoEditPart, this calls the new
> OpenEditorEditPolicy when double clicked (OPEN_ROLE):
>
> protected void createDefaultEditPolicies() {
> super.createDefaultEditPolicies(); installEditPolicy(
> EditPolicyRoles.OPEN_ROLE, new OpenEditorEditPolicy ());
> }
>
> The OpenEditorEditPolicy extends the OpenEditPolicy as described in:
>
> http://dev.eclipse.org/newslists/news.eclipse.technology.gmf /msg03767.html
>
>
> I've added comments, there are some parts I'm unsure of, what I'd like to
> happen first is just to open a blank SWT with nothing on it. Next step, to
> have it display properties of the emlement, Finally, be able to edit
> properties.
>
> The second System.out.println works, so I know it's doing something, but
> how do I get the SWT dialog to come up? Thanks.
>
>
>
>
>
>
>
> public class OpenEditorEditPolicy extends OpenEditPolicy { protected
> Command getOpenCommand(Request request) { //request is the location of the
> mouse pointer - what is command used for?
> EditPart targetEditPart = getTargetEditPart(request); //the
> Editpart is told the location of the mouse pointer
> if (targetEditPart instanceof IGraphicalEditPart) { //if the
> mouse location is part of the model(IGraphicalEditPart???)
> IGraphicalEditPart editPart = (IGraphicalEditPart)targetEditPart;
> //model editpart is told mouse location???
> View view = editPart.getNotationView(); if (view
> !=null){ EObject element = ViewUtil.resolveSemanticElement(view); //gets
> the element that is at the location
> if (element instanceof Diagram) { // if the
> element is in the model
> // open a blank SWT dialog Display d
> = new Display();
> Shell s = new Shell(d, SWT.CLOSE|SWT.RESIZE);
> s.setSize(300, 300);
> s.pack();
> s.open(); System.out.println("Double click called"); // this
> never gets printed
> return new ICommandProxy(new OpenDiagramCommand(element)); //
> don't know what this does
> } System.out.println("Double click called 2"); // this DOES
> get printed
> } } return null; }
Re: SWT property editor(2) [message #66401 is a reply to message #66310] Fri, 20 October 2006 13:55 Go to previous messageGo to next message
Conor Missing name is currently offline Conor Missing nameFriend
Messages: 159
Registered: July 2009
Senior Member
No, didn't put notation.Diagram as sematic element.

I removed the if statement completely:

if (element instanceof Diagram)

The code will now go as far as

return new ICommandProxy(new OpenDiagramCommand(element));

Which doesn't seem to do anything. What is the purpose of this line? I'm
guessing it doesn't work same reason as described before.

Also Bug reference doesn't exist.
Re: SWT property editor(2) [message #67623 is a reply to message #66401] Mon, 23 October 2006 10:41 Go to previous message
Artem Tikhomirov is currently offline Artem TikhomirovFriend
Messages: 222
Registered: July 2009
Senior Member
Well, it's not that simple, you know - if OpenDiagramCommand do not need
instanceof Diagram, there would be no check from the very beginning. Look at
OpenDiagramCommand#canExecute.

Hint - you don't need Open_Diagram_Command if you intend to open _SWT
Property Editor_ instead (as title of your post suggests).

> Also Bug reference doesn't exist.

Hm, the link works perfectly for me. Did you try looking up by bug number
(159479)?


Artem

"Gaff" <conorgaff@hotmail.com> wrote in message
news:899e54edf3638b75bd5c49303f7776f6$1@www.eclipse.org...
> No, didn't put notation.Diagram as sematic element.
>
> I removed the if statement completely:
>
> if (element instanceof Diagram)
>
> The code will now go as far as
> return new ICommandProxy(new OpenDiagramCommand(element));
>
> Which doesn't seem to do anything. What is the purpose of this line? I'm
> guessing it doesn't work same reason as described before.
>
> Also Bug reference doesn't exist.
>
Previous Topic:Internal Error while generating gmfgen Model
Next Topic:ereference property should pop up selection window but shows a dropdown list and does not set member
Goto Forum:
  


Current Time: Sat Nov 09 02:59:59 GMT 2024

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

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

Back to the top