Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » SWT property editor
SWT property editor [message #61561] Thu, 12 October 2006 13:29 Go to next message
Conor Missing name is currently offline Conor Missing nameFriend
Messages: 159
Registered: July 2009
Senior Member
Hey,

I want to set up my editor so when you double click an element a SWT
dialogue box will pop up to allow for the elements properties to be edited.

There has been some discussion on this already:

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

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

From these threads I see that I first need to extend the OpenEditPolicy
(below), this will allow for a double-click on an element to work? Where
is the OpenEditPolicy located? Where should this code go?



public class OpenEditorEditPolicy extends OpenEditPolicy {
protected Command getOpenCommand(Request request) {
EditPart targetEditPart = getTargetEditPart(request);
if (targetEditPart instanceof IGraphicalEditPart) {
IGraphicalEditPart editPart =
(IGraphicalEditPart)targetEditPart;
View view = editPart.getNotationView();
if (view !=null){
EObject element =
ViewUtil.resolveSemanticElement(view);
if (element instanceof Diagram) {
return new ICommandProxy(
new
OpenEditorCommand(element));
}
}
}
return null;
}
}
Re: SWT property editor [message #61725 is a reply to message #61561] Thu, 12 October 2006 14:20 Go to previous messageGo to next message
Cherie Revells is currently offline Cherie RevellsFriend
Messages: 299
Registered: July 2009
Senior Member
Gaff,

You don't need to extend the OpenEditPolicy, you just want to override
its behavior by installing your own editpolicy on the OPEN_ROLE that
handles the request RequestConstants.REQ_OPEN.

To get an understanding of how editpolicies work, take a look at:
- The GEF Programmer's Guide
- GraphicalEditPart.createDefaultEditPolicies()
- The "Diagram Services Layer - How-to Guide" EditPolicy provider example.

Regards,
Cherie

Gaff wrote:
> Hey,
>
> I want to set up my editor so when you double click an element a SWT
> dialogue box will pop up to allow for the elements properties to be edited.
>
> There has been some discussion on this already:
>
> http://dev.eclipse.org/newslists/news.eclipse.technology.gmf /msg03693.html
>
> http://dev.eclipse.org/newslists/news.eclipse.modeling.gmf/m sg01050.html
>
> From these threads I see that I first need to extend the OpenEditPolicy
> (below), this will allow for a double-click on an element to work? Where
> is the OpenEditPolicy located? Where should this code go?
>
>
>
> public class OpenEditorEditPolicy extends OpenEditPolicy {
> protected Command getOpenCommand(Request request) {
> EditPart targetEditPart = getTargetEditPart(request); if
> (targetEditPart instanceof IGraphicalEditPart) {
> IGraphicalEditPart editPart = (IGraphicalEditPart)targetEditPart;
> View view = editPart.getNotationView();
> if (view !=null){
> EObject element = ViewUtil.resolveSemanticElement(view);
> if (element instanceof Diagram) {
> return new ICommandProxy(
> new
> OpenEditorCommand(element)); }
> } } return null;
> } }
>
Re: SWT property editor [message #61845 is a reply to message #61725] Thu, 12 October 2006 16:15 Go to previous messageGo to next message
Cherie Revells is currently offline Cherie RevellsFriend
Messages: 299
Registered: July 2009
Senior Member
Gaff,

Actually it does make sense to also extend the OpenEditPolicy as this
will provide you with the knowledge of the request type and all you need
to do is implement the abstract method getOpenCommand().

- Cherie

Cherie Revells wrote:
> Gaff,
>
> You don't need to extend the OpenEditPolicy, you just want to override
> its behavior by installing your own editpolicy on the OPEN_ROLE that
> handles the request RequestConstants.REQ_OPEN.
>
> To get an understanding of how editpolicies work, take a look at:
> - The GEF Programmer's Guide
> - GraphicalEditPart.createDefaultEditPolicies()
> - The "Diagram Services Layer - How-to Guide" EditPolicy provider example.
>
> Regards,
> Cherie
>
> Gaff wrote:
>> Hey,
>>
>> I want to set up my editor so when you double click an element a SWT
>> dialogue box will pop up to allow for the elements properties to be
>> edited.
>>
>> There has been some discussion on this already:
>>
>> http://dev.eclipse.org/newslists/news.eclipse.technology.gmf /msg03693.html
>>
>>
>> http://dev.eclipse.org/newslists/news.eclipse.modeling.gmf/m sg01050.html
>>
>> From these threads I see that I first need to extend the
>> OpenEditPolicy (below), this will allow for a double-click on an
>> element to work? Where is the OpenEditPolicy located? Where should
>> this code go?
>>
>>
>>
>> public class OpenEditorEditPolicy extends OpenEditPolicy {
>> protected Command getOpenCommand(Request request) {
>> EditPart targetEditPart = getTargetEditPart(request);
>> if (targetEditPart instanceof IGraphicalEditPart)
>> { IGraphicalEditPart editPart =
>> (IGraphicalEditPart)targetEditPart; View view =
>> editPart.getNotationView(); if (view
>> !=null){ EObject element =
>> ViewUtil.resolveSemanticElement(view);
>> if (element instanceof Diagram) {
>> return new ICommandProxy(
>> new
>> OpenEditorCommand(element)); }
>> } } return null;
>> } }
>>
Re: SWT property editor [message #62218 is a reply to message #61725] Fri, 13 October 2006 14:55 Go to previous messageGo to next message
Conor Missing name is currently offline Conor Missing nameFriend
Messages: 159
Registered: July 2009
Senior Member
Cheers,

But what is the file location of the OpenEditPolicy class. Can't seem to
find it anywhere.

Gaff
Re: SWT property editor [message #62241 is a reply to message #62218] Fri, 13 October 2006 15:20 Go to previous messageGo to next message
Mohammed Mostafa is currently offline Mohammed MostafaFriend
Messages: 143
Registered: July 2009
Senior Member
Gaff wrote:

Open edit policy is inside the package :

org.eclipse.gmf.runtime.diagram.ui.editpolicies

in the plugin :

org.eclipse.gmf.runtime.diagram.ui


> Cheers,
>
> But what is the file location of the OpenEditPolicy class. Can't seem to
> find it anywhere.
>
> Gaff
>
Re: SWT property editor [message #63729 is a reply to message #62241] Tue, 17 October 2006 10:29 Go to previous messageGo to next message
Conor Missing name is currently offline Conor Missing nameFriend
Messages: 159
Registered: July 2009
Senior Member
Hi,

I've found the file but there's no source as it's a plug-in (thought I
could just extend it form there). When I right click the package and try
to add a new class (to do the extension) it opens a new package within the
source above, the package is the right name but the code I paste in
doesn't work...


code from:
http://dev.eclipse.org/newslists/news.eclipse.technology.gmf /msg03725.html


The first error I get is:

"The type OpenEditorEditPolicy must implement the inherited abstract
method
OpenEditPolicy.getOpenCommand(Request)"

And the rest are type cannot be resolved errors.

What am i misssing to extend this class?

Thanks.
Re: SWT property editor [message #63977 is a reply to message #63729] Tue, 17 October 2006 11:46 Go to previous message
Artem Tikhomirov is currently offline Artem TikhomirovFriend
Messages: 222
Registered: July 2009
Senior Member
GMF newsgroup is not the right place to ask general Eclipse/Java development
questions.
You can find sources for the plug-in in our downloads.

Artem

"Gaff" <conorgaff@hotmail.com> wrote in message
news:50545073bf8c1f0bdbfb5bd37a4d1721$1@www.eclipse.org...
> Hi,
>
> I've found the file but there's no source as it's a plug-in (thought I
> could just extend it form there). When I right click the package and try
> to add a new class (to do the extension) it opens a new package within the
> source above, the package is the right name but the code I paste in
> doesn't work...
>
>
> code from:
> http://dev.eclipse.org/newslists/news.eclipse.technology.gmf /msg03725.html
>
>
> The first error I get is:
>
> "The type OpenEditorEditPolicy must implement the inherited abstract
> method OpenEditPolicy.getOpenCommand(Request)"
>
> And the rest are type cannot be resolved errors.
>
> What am i misssing to extend this class?
>
> Thanks.
Previous Topic:Transparent SVG file as a figure
Next Topic:Filter out properties from EMF section
Goto Forum:
  


Current Time: Fri Apr 19 09:45:42 GMT 2024

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

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

Back to the top