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;
}
}
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;
> } }
>
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;
>> } }
>>
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...
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.