| SWT property editor(2) [message #66141] | 
Fri, 20 October 2006 05:37   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
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 07:46    | 
 
Eclipse User  | 
 | 
 | 
   | 
 
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 #67623 is a reply to message #66401] | 
Mon, 23 October 2006 06:41   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
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. 
>
 |  
 |  
  | 
Powered by 
FUDForum. Page generated in 0.18225 seconds