rickilama54 / smartgwt

Automatically exported from code.google.com/p/smartgwt
0 stars 0 forks source link

MenuBar methods to add Menus have disappeared. No such method errors. #388

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I create a MenuBar and a Menu:

           MenuBar smsMenuBar = new MenuBar();

            Menu smsMenu= new Menu();
            smsMenu.setTitle("SMS")
            smsMenu.setShowShadow(true);
            smsMenu.setShadowDepth(10);

            MenuItem sendSMS = new MenuItem("Send SMS");

            MenuItem smsLog = new MenuItem("View Logs");

            smsMenu.setItems(sendSMS, smsLog);

            smsMenuBar.setMenus(smsMenu);

When it comes to that last line:
            smsMenuBar.setMenus(smsMenu);

Eclipse has an error message "The method setMenus(Menu) is undefined for
the type MenuBar".

I am version 2.0. I have ALSO tried this against the latest nightly build
as well (revision.927). So this is broken on the official 2.0 release as
well as the latest nightly build.

The OS is linux.

Original issue reported on code.google.com by bradley....@gmail.com on 6 Jan 2010 at 3:27

GoogleCodeExporter commented 8 years ago

Original comment by sanjiv.j...@gmail.com on 22 Jan 2010 at 1:37

GoogleCodeExporter commented 8 years ago
These methods have never been removed and exist in Smart GWT 2.0 as well. Check 
you environment again.

See 
http://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/widgets/menu/Men
uBar.html#setMenus(c
om.smartgwt.client.widgets.menu.Menu...)

Original comment by sanjiv.j...@gmail.com on 29 Jan 2010 at 10:53

GoogleCodeExporter commented 8 years ago
Definitely not  there. The link that you give says that addMenus and setMenus 
should
be there as well. They are not.

Original comment by bradley....@gmail.com on 29 Jan 2010 at 3:29

GoogleCodeExporter commented 8 years ago
Just for the record so that others who find this bug will have an alternative, 
I have
a workaround to this bug. This is what I do:

Create a Hlayout:

final HLayout menuBar = new HLayout();

For each of your top level menus, you should have created a Menu  type and 
added the
submenu entries. E.g. For "File" you would have "Open", "Save", "Save As", etc. 
So
now you have top-level menus. But you need them displayed in the HLayout to 
emulate a
menu bar. In this example, we have File and Admin as the top-level entries.

Create menu buttons for each of the main menu items (i.e. the top level menu 
entries
that should be in the menu bar):

            final MenuButton fileButton = new MenuButton("File", fileMenu);
            final MenuButton adminButton = new MenuButton("Admin", adminMenu);

Now add those menu buttons to the HLayout:

            menuBar.addMember(fileButton)
            menuBar.addMember(adminButton)

However, this won't work properly if you have a narrow DIV for the menu bar 
that you
are displaying into. So you have to do this:
            menuBar.setVisible(true);
            menuBar.setKeepInParentRect(false);

and of course, finally you need to add it to a container:
            RootPanel.get("menuPanel").add(menuBar);        

The above will emulate a menu bar until this bug is fixed. Hopefully later 
revisions
of the code will see the functionlity return to the library. And alternative is 
to
use the excellent YUI menu bar but then you don't get the nice GWT programming 
around
it as it's JavaScript.

Original comment by bradley....@gmail.com on 29 Jan 2010 at 3:38

GoogleCodeExporter commented 8 years ago
You're right, it was mistakenly removed from SVN. I'll fix it later today. 
Sorry for 
the inconvenience.

Original comment by sanjiv.j...@gmail.com on 29 Jan 2010 at 3:45

GoogleCodeExporter commented 8 years ago
Okay, so I double checked and these method are indeed present. Check the file 
in SVN :

http://code.google.com/p/smartgwt/source/browse/trunk/main/src/com/smartgwt/clie
nt/widgets/menu/M
enuBar.java

Also I just downloaded SmartGWT 2.0 again and opened the MenuBar.java file in 
the smartgwt.jar and sure 
enough these methods are present. Something does seem dirty in your 
environment. try opening the 
smartgwt.jar file you're using and verify that these methods exist. If they 
don't, then you're not using the 
SmartGWT 2.0 release.

Original comment by sanjiv.j...@gmail.com on 30 Jan 2010 at 1:22

GoogleCodeExporter commented 8 years ago
Hi Sanjiv,

Yes, when I open the jar file and extract the source, I can see that setMenus 
is in
there. But when I am in elipse and I try to use menubar.setMenus(mymenu) it 
says that
setMenus is undefined for type MenuBar.

I am using eclipse Galileo on 64 bit Linux. I wonder if there is some sort of 
build
issue? The really weird thing is that only the MenuBar class has a problem.
Everything else works fine, including the work-around that I posted above. 

Original comment by bradley....@gmail.com on 30 Jan 2010 at 11:38

GoogleCodeExporter commented 8 years ago
Hmmm, I have found the problem. If I fully qualify the class name then is works.
com.smartgwt.client.widgets.menu.ManuBar

So there must be a conflict somewhere. I will try to find it and post here to 
help
others.

Original comment by bradley....@gmail.com on 30 Jan 2010 at 11:39

GoogleCodeExporter commented 8 years ago
Problem solved! The Google (GWT) version of MenuBar had been automatically 
imported
by eclipse and so it was attempting to use the Googe version, not the smartGWT 
version.

Sanjiv, thank you for your help with this. Much appreciated. Keep up the good 
work!

Original comment by bradley....@gmail.com on 30 Jan 2010 at 11:57

GoogleCodeExporter commented 8 years ago
ah, Glad this got resolved.

Original comment by sanjiv.j...@gmail.com on 30 Jan 2010 at 1:06