SWT property editor(2) [message #66141] |
Fri, 20 October 2006 09:37 |
Conor Missing name 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 #66310 is a reply to message #66141] |
Fri, 20 October 2006 11:46 |
Artem Tikhomirov 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; }
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04535 seconds