Dynamic loading plugin when bringup up the popup menu [message #262961] |
Wed, 21 July 2004 16:37  |
Eclipse User |
|
|
|
Originally posted by: gracelo.ca.ibm.com
Hi,
I am writing a plugin which includes a popup menu specific for a
graphical editor defined in another dependent plugin. I define the
menu like this:
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
objectClass="com.ibm.example.ObjectA"
id="com.ibm.myPlugin.AddMarkerAction">
<action
label="Add Marker to A"
class="com.ibm.myPlugins.actions.AddMarkerActionDelegate"
enablesFor="1"
id="com.ibm.myPlugins.actions.AddMarkerAction">
</action>
</objectContribution>
<-- ... more other menu , e.g., RemoveMarkerAction -->
</extension>
The menu is correctly popped whenever I choose an object of class
ObjectA in the graphical editor. My menu is added as MB_additions.
My AddATagAction is already implementing IObjectActionDelegate.
However, what I want is the menu be enabled and disabled depending on
some situations other than the ObjectA's attributes. For example, I
only want to add a marker if there is no marker of a certain marker type
already defined for ObjectA. I have to programatically check this
condition rather than specifying it in the plugin.xml. I currently do
this by overriding the selectionChanged() method in IActionDelegate to
call action.Enabled(true/false).
I find that the first time when I bring up the editor (which is not
implemented by me), all my menu would show up regardless. After I
choose my menu item, my plugin is loaded. Then from that time onwards,
the menu could be enabled or disabled programatically.
How could I fix the problem of all menu are showing without calling my
condition code when first brought up?
Thanks,
Grace
|
|
|
Re: Dynamic loading plugin when bringup up the popup menu [message #263043 is a reply to message #262961] |
Wed, 21 July 2004 22:08   |
Eclipse User |
|
|
|
Originally posted by: lizhihongde.hotmail.com
This is a multi-part message in MIME format.
------=_NextPart_000_003F_01C46FD3.D832D890
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Hi Grace,
.. Don't make extension point of the eclipse popup menu in the plugin.xml
.. Set your context menu in your graphical editor.Please refer the =
following code:
protected void configureGraphicalViewer(){
...
viewer.setContextMenuProvider(getPopupMenuProvider());
...
}
"Grace" <gracelo@ca.ibm.com> =E5=86=99=E5=85=A5=E9=82=AE=E4=BB=B6 =
news:40FED414.9DDE1C1@ca.ibm.com...
Hi,
I am writing a plugin which includes a popup menu specific for a
graphical editor defined in another dependent plugin. I define the
menu like this:
<extension
point=3D"org.eclipse.ui.popupMenus">
<objectContribution
objectClass=3D"com.ibm.example.ObjectA"
id=3D"com.ibm.myPlugin.AddMarkerAction">
<action
label=3D"Add Marker to A"
=
class=3D"com.ibm.myPlugins.actions.AddMarkerActionDelegate"
enablesFor=3D"1"
id=3D"com.ibm.myPlugins.actions.AddMarkerAction">
</action>
</objectContribution>
<-- ... more other menu , e.g., RemoveMarkerAction -->
</extension>
The menu is correctly popped whenever I choose an object of class
ObjectA in the graphical editor. My menu is added as MB_additions.
My AddATagAction is already implementing IObjectActionDelegate.
However, what I want is the menu be enabled and disabled depending on
some situations other than the ObjectA's attributes. For example, I
only want to add a marker if there is no marker of a certain marker =
type
already defined for ObjectA. I have to programatically check this
condition rather than specifying it in the plugin.xml. I currently =
do
this by overriding the selectionChanged() method in IActionDelegate to
call action.Enabled(true/false).
I find that the first time when I bring up the editor (which is not
implemented by me), all my menu would show up regardless. After I
choose my menu item, my plugin is loaded. Then from that time =
onwards,
the menu could be enabled or disabled programatically.
How could I fix the problem of all menu are showing without calling my
condition code when first brought up?
Thanks,
Grace
------=_NextPart_000_003F_01C46FD3.D832D890
Content-Type: text/html;
charset="utf-8"
Content-Transfer-Encoding: quoted-printable
=EF=BB=BF<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dutf-8">
<META content=3D"MSHTML 6.00.2800.1400" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV>
<DIV>Hi Grace,</DIV>
<DIV> </DIV>
<DIV>. Don't make extension point of the eclipse popup menu in the=20
plugin.xml</DIV>
<DIV>. Set your context menu in your graphical editor.Please refer the =
following=20
code:</DIV>
<DIV> </DIV>
<DIV> protected void =
configureGraphicalViewer(){<BR> ...</DIV >
<DIV> viewer.setContextMenuProvider(getPopupMe nuProvider()); <B=
R> ...</DIV>
<DIV> }</DIV>
<DIV> </DIV></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Grace" <<A=20
href=3D"mailto:gracelo@ca.ibm.com">gracelo@ca.ibm.com</A>> =
=E5=86=99=E5=85=A5=E9=82=AE=E4=BB=B6 <A=20
=
href=3D"news:40FED414.9DDE1C1@ca.ibm.com">news:40FED414.9DDE1C1@ca.ibm.co=
m</A>...</DIV>Hi,<BR><BR>I=20
am writing a plugin which includes a popup menu specific for =
a<BR>graphical=20
editor defined in another dependent plugin. I define =
the<BR>menu=20
like this:<BR><BR> =20
<extension<BR> =20
=
point=3D"org.eclipse.ui.popupMenus"><BR> =
=20
=
<objectContribution<BR>  =
; =20
=
objectClass=3D"com.ibm.example.ObjectA"<BR> =
=20
=
id=3D"com.ibm.myPlugin.AddMarkerAction"><BR> &n=
bsp; =20
=
<action<BR>  =
; =20
label=3D"Add Marker to=20
=
A"<BR> &=
nbsp; =20
=
class=3D"com.ibm.myPlugins.actions.AddMarkerActionDelegate" <BR><BR> =
&=
nbsp;=20
=
enablesFor=3D"1"<BR>  =
; =20
=
id=3D"com.ibm.myPlugins.actions.AddMarkerAction"><BR >  =
; =20
</action><BR> =20
</objectContribution><BR> <-- =
.... more=20
other menu , e.g., RemoveMarkerAction --><BR> =20
</extension><BR><BR>The menu is correctly popped whenever I =
choose an=20
object of class<BR>ObjectA in the graphical editor. My menu is =
added as=20
MB_additions.<BR>My AddATagAction is already implementing=20
IObjectActionDelegate.<BR><BR>However, what I want is the menu be =
enabled and=20
disabled depending on<BR>some situations other than the ObjectA's=20
attributes. For example, I<BR>only want to add a marker if =
there=20
is no marker of a certain marker type<BR>already defined for=20
ObjectA. I have to programatically check this<BR>condition =
rather=20
than specifying it in the plugin.xml. I currently =
do<BR>this by=20
overriding the selectionChanged() method in IActionDelegate to<BR>call =
action.Enabled(true/false).<BR><BR>I find that the first time when I =
bring up=20
the editor (which is not<BR>implemented by me), all my menu would show =
up=20
regardless. After I<BR>choose my menu item, my plugin is=20
loaded. Then from that time onwards,<BR>the menu could be =
enabled=20
or disabled programatically.<BR><BR>How could I fix the problem of all =
menu=20
are showing without calling my<BR>condition code when first brought=20
up?<BR><BR><BR>Thanks,<BR>Grace<BR></BLOCKQUOTE></BODY ></HTML>
------=_NextPart_000_003F_01C46FD3.D832D890--
|
|
|
Re: Dynamic loading plugin when bringup up the popup menu [message #281135 is a reply to message #262961] |
Tue, 15 February 2005 15:31  |
Eclipse User |
|
|
|
Originally posted by: hunter_medney.us.ibm.com
Another option is to designate the plugin with the menu for early startup
instead of being loaded on-demand:
<extension point="org.eclipse.ui.startup" />
Since the plugin will be started, the action delegate will be instantiated
and selectionChanged() will be called every time.
I encountered a similar challenge where I needed a pop-up menu action to
enable/disable based on the object class, and the object classes that would
enable the action were not known until runtime (they were defined in
contributions). Defining the enablement logic in selectionChanged() and
adding the early startup contribution resolved the issue.
"Grace" <gracelo@ca.ibm.com> wrote in message
news:40FED414.9DDE1C1@ca.ibm.com...
> Hi,
>
> I am writing a plugin which includes a popup menu specific for a
> graphical editor defined in another dependent plugin. I define the
> menu like this:
>
> <extension
> point="org.eclipse.ui.popupMenus">
> <objectContribution
> objectClass="com.ibm.example.ObjectA"
> id="com.ibm.myPlugin.AddMarkerAction">
> <action
> label="Add Marker to A"
> class="com.ibm.myPlugins.actions.AddMarkerActionDelegate"
>
> enablesFor="1"
> id="com.ibm.myPlugins.actions.AddMarkerAction">
> </action>
> </objectContribution>
> <-- ... more other menu , e.g., RemoveMarkerAction -->
> </extension>
>
> The menu is correctly popped whenever I choose an object of class
> ObjectA in the graphical editor. My menu is added as MB_additions.
> My AddATagAction is already implementing IObjectActionDelegate.
>
> However, what I want is the menu be enabled and disabled depending on
> some situations other than the ObjectA's attributes. For example, I
> only want to add a marker if there is no marker of a certain marker type
> already defined for ObjectA. I have to programatically check this
> condition rather than specifying it in the plugin.xml. I currently do
> this by overriding the selectionChanged() method in IActionDelegate to
> call action.Enabled(true/false).
>
> I find that the first time when I bring up the editor (which is not
> implemented by me), all my menu would show up regardless. After I
> choose my menu item, my plugin is loaded. Then from that time onwards,
> the menu could be enabled or disabled programatically.
>
> How could I fix the problem of all menu are showing without calling my
> condition code when first brought up?
>
>
> Thanks,
> Grace
>
|
|
|
Powered by
FUDForum. Page generated in 0.03474 seconds