Home » Eclipse Projects » Rich Client Platform (RCP) » Cannot get Menu Items in eclipse 3.4
|
Re: Cannot get Menu Items in eclipse 3.4 [message #481764 is a reply to message #481234] |
Mon, 24 August 2009 09:07 |
|
Hi,
its hard to pinpoint your problem remotely. I suggest that you try the
small examples from the following tutorial and then check the difference
to your code:
http://www.vogella.de/articles/EclipseCommands/article.html
Best regards, Lars
sneha wrote:
> Hi,
>
> I have moved from Target platform eclipse 3.3.2 to 3.4 recently.
> I have developed an RCP application which has some toolbar icons.
> These icons have an initial disabled state. However after running the
> application using eclipse 3.4, the initial state of these icons is
> toggled to "enabled".
> On debugging the code I found that the method getItemCount() of
> org.eclipse.swt.Menu class returns an empty list while retrieving the
> menu items.
> In my code, based on this return value, I am setting the enabled
> /disabled state of the icons.But since we get an empty list, no further
> operation is possible.
> I have not done any code changes in my application. This behavior is
> observed after switching the target platform.
> I have searched on net if this is a side effect of some changes in
> eclipse 3.4 but did not get any solution.
> If anybody has come across this problem, please let me know about the
> solution.
>
> Thanks,
> Sneha
--
http://www.vogella.de/ - Eclipse plugin and Eclipse RCP Tutorials
http://www.twitter.com/vogella - vogella on Twitter
|
|
| |
Re: Cannot get Menu Items in eclipse 3.4 [message #482103 is a reply to message #481234] |
Tue, 25 August 2009 11:52 |
sneha Messages: 25 Registered: July 2009 |
Junior Member |
|
|
Hi,
To enable/ disable action I had used code from following link:
(http://www.eclipsezone.com/eclipse/forums/t90781.rhtml) with some
modification.
Display.getDefault().syncExec(new Runnable() {
public void run() {
IWorkbench workbench = PlatformUI.getWorkbench();
Menu menubar = workbench.getActiveWorkbenchWindow().
getShell().getMenuBar();
if(menubar == null ){
return;
}
MenuItem[] mItems = menubar.getItems();
if(mItems == null){
return;
}
for(int j = 0 ;j < menuItems.length; j++) {
if(mItems .getText().equals("Tools")){
Menu menu = mItems .getMenu();
/**************************************************
for( int i = 0; i < menu.getItemCount(); ++i) {
/**************************************************
**** In the above marked line, menu.getItemCount returns 0 but i can
**** see actions entry (menu item) in main menu and toolbar
**** after this code I am trying to get the menu Item action and
** set its state to enabled.
**** But since the code is returning 0 from above line, I am not able to
****toggle the state of the action Item
SubContributionItem cItem = null;
Object menuItemData = item.getData();
if(menuItemData == null){
continue;
}
if(menuItemData instanceof SubContributionItem){
cItem = (SubContributionItem)menuItemData;
IContributionItem conItems = cItem.getInnerItem();
if(conItems instanceof ActionContributionItem){
ActionContributionItem items = (ActionContributionItem) conItems;
String id = cItem.getId();
if((id != null) && (toolsID.contains(id))){
items.getAction().setEnabled(state);
}
}
}
}
}
}
}
});
In my code, based on this return value, I am setting the enabled
/disabled state of the icons.But since we get an empty list from
menu.getItemCount(), no further operation is possible.
This code is working perfectly fine in eclipse 3.3.2. Same code gives
problem in Eclipse 3.4.
I have not done any code changes in my application. This behavior is
observed after switching the target platform.
I have searched on net if this is a side effect of some changes in
eclipse 3.4 but did not get any solution.
Any pointers would be of great help.
Thanks,
Sneha
Paul Webster wrote:
> What code do you have? Is it that you have a DROP_DOWN action?
>
> PW
>
sneha wrote:
> Hi,
>
> I have moved from Target platform eclipse 3.3.2 to 3.4 recently.
> I have developed an RCP application which has some toolbar icons.
> These icons have an initial disabled state. However after running the
> application using eclipse 3.4, the initial state of these icons is
> toggled to "enabled".
> On debugging the code I found that the method getItemCount() of
> org.eclipse.swt.Menu class returns an empty list while retrieving the
> menu items.
> In my code, based on this return value, I am setting the enabled
> /disabled state of the icons.But since we get an empty list, no further
> operation is possible.
> I have not done any code changes in my application. This behavior is
> observed after switching the target platform.
> I have searched on net if this is a side effect of some changes in
> eclipse 3.4 but did not get any solution.
> If anybody has come across this problem, please let me know about the
> solution.
>
> Thanks,
> Sneha
|
|
|
Re: Cannot get Menu Items in eclipse 3.4 [message #482104 is a reply to message #481764] |
Tue, 25 August 2009 11:55 |
sneha Messages: 25 Registered: July 2009 |
Junior Member |
|
|
Hi,
Thanks for the link. But I am facing this problem after switching from
Eclipse target platform 3.3.2 to 3.4.
please refer to details of my problem in the other mail thread.
Any suggestions would be of great help.
Thanks,
Sneha
Lars Vogel wrote:
> Hi,
>
> its hard to pinpoint your problem remotely. I suggest that you try the
> small examples from the following tutorial and then check the difference
> to your code:
>
> http://www.vogella.de/articles/EclipseCommands/article.html
>
> Best regards, Lars
>
>
>
>
> sneha wrote:
>> Hi,
>>
>> I have moved from Target platform eclipse 3.3.2 to 3.4 recently.
>> I have developed an RCP application which has some toolbar icons.
>> These icons have an initial disabled state. However after running the
>> application using eclipse 3.4, the initial state of these icons is
>> toggled to "enabled".
>> On debugging the code I found that the method getItemCount() of
>> org.eclipse.swt.Menu class returns an empty list while retrieving the
>> menu items.
>> In my code, based on this return value, I am setting the enabled
>> /disabled state of the icons.But since we get an empty list, no
>> further operation is possible.
>> I have not done any code changes in my application. This behavior is
>> observed after switching the target platform.
>> I have searched on net if this is a side effect of some changes in
>> eclipse 3.4 but did not get any solution.
>> If anybody has come across this problem, please let me know about the
>> solution.
>>
>> Thanks,
>> Sneha
>
>
>
>
|
|
| |
Re: Cannot get Menu Items in eclipse 3.4 [message #482562 is a reply to message #482103] |
Thu, 27 August 2009 04:55 |
sneha Messages: 25 Registered: July 2009 |
Junior Member |
|
|
Hi,
I still don't have any solution to this problem. I have not yet found
whether the below mentioned problem is a known issue in Eclipse 3.4 or
whether there is a workaround to my problem.
If anybody has come across this problem, please let me know about the
solution.
Any pointers would be of great help!!
Thanks,
Sneha
sneha wrote:
> Hi,
>
> To enable/ disable action I had used code from following link:
> (http://www.eclipsezone.com/eclipse/forums/t90781.rhtml) with some
> modification.
> Display.getDefault().syncExec(new Runnable() {
> public void run() {
> IWorkbench workbench = PlatformUI.getWorkbench();
> Menu menubar = workbench.getActiveWorkbenchWindow().
> getShell().getMenuBar();
> if(menubar == null ){
> return;
> }
> MenuItem[] mItems = menubar.getItems();
> if(mItems == null){
> return;
> }
> for(int j = 0 ;j < menuItems.length; j++) {
> if(mItems .getText().equals("Tools")){
> Menu menu = mItems .getMenu();
> /**************************************************
> for( int i = 0; i < menu.getItemCount(); ++i) {
> /**************************************************
> **** In the above marked line, menu.getItemCount returns 0 but i can
> **** see actions entry (menu item) in main menu and toolbar
> **** after this code I am trying to get the menu Item action and
> ** set its state to enabled.
> **** But since the code is returning 0 from above line, I am not able to
> ****toggle the state of the action Item
>
> SubContributionItem cItem = null;
> Object menuItemData = item.getData();
> if(menuItemData == null){
> continue;
> }
> if(menuItemData instanceof SubContributionItem){
> cItem = (SubContributionItem)menuItemData;
> IContributionItem conItems = cItem.getInnerItem();
> if(conItems instanceof ActionContributionItem){
> ActionContributionItem items = (ActionContributionItem) conItems;
> String id = cItem.getId();
> if((id != null) && (toolsID.contains(id))){
> items.getAction().setEnabled(state);
> }
> }
> }
> }
> }
> }
> }
> });
>
> In my code, based on this return value, I am setting the enabled
> /disabled state of the icons.But since we get an empty list from
> menu.getItemCount(), no further operation is possible.
> This code is working perfectly fine in eclipse 3.3.2. Same code gives
> problem in Eclipse 3.4.
> I have not done any code changes in my application. This behavior is
> observed after switching the target platform.
> I have searched on net if this is a side effect of some changes in
> eclipse 3.4 but did not get any solution.
>
>
> Any pointers would be of great help.
> Thanks,
> Sneha
>
> Paul Webster wrote:
> > What code do you have? Is it that you have a DROP_DOWN action?
> >
> > PW
> >
>
>
> sneha wrote:
>> Hi,
>>
>> I have moved from Target platform eclipse 3.3.2 to 3.4 recently.
>> I have developed an RCP application which has some toolbar icons.
>> These icons have an initial disabled state. However after running the
>> application using eclipse 3.4, the initial state of these icons is
>> toggled to "enabled".
>> On debugging the code I found that the method getItemCount() of
>> org.eclipse.swt.Menu class returns an empty list while retrieving the
>> menu items.
>> In my code, based on this return value, I am setting the enabled
>> /disabled state of the icons.But since we get an empty list, no
>> further operation is possible.
>> I have not done any code changes in my application. This behavior is
>> observed after switching the target platform.
>> I have searched on net if this is a side effect of some changes in
>> eclipse 3.4 but did not get any solution.
>> If anybody has come across this problem, please let me know about the
>> solution.
>>
>> Thanks,
>> Sneha
|
|
| |
Goto Forum:
Current Time: Fri Jan 24 23:14:49 GMT 2025
Powered by FUDForum. Page generated in 0.05849 seconds
|