GWT vertical menu - java

I need some help with Google web toolkit to make a vertical menu with expanding submenu items.
I want to create a vertical menu that woks like the left menu on the showcase of GWT
I tried this:
VerticalPanel vertpanel = new VerticalPanel();
MenuBar menubar = new MenuBar(true);//set to true so its set to vertical alignment
MenuBar subbar = new MenuBar(true);
MenuBar subbar2 = new MenuBar(true);
subbar.addItem("Fist item of submenu1", new AddEmployeeCommand());
subbar.addItem("Second item of submenu1", new AddEmployeeCommand());
subbar2.addItem("First item of submenu2", new AddEmployeeCommand());
subbar2.addItem("Second item of submenu2", new AddEmployeeCommand());
menubar.addItem("sub 1", subbar);
menubar.addItem("sub 2", subbar2);
vertpanel.add(menubar);
RootPanel.get().add(menubar);
But that doesn't work because the menu items won't expand to show their subitems. Although it works when I make it a horizontal menubar but that's not what I want.

You'll need to use DisclosurePanels in order to achieve that.
Check it out in the GWT showcase.

That's probably using a DosclosurePanel, not a Menu Bar.
http://gwt.google.com/samples/Showcase/Showcase.html#!CwDisclosurePanel

maybe you can have a look to a StackPanel
Gwt Stackpanel showcase

Related

JavaFx Button adds ellipsis when rendered on a E4 ToolControl

I've an E4 application which has a ToolControl, the class that handles the tool control creates a JavaFX button, for some reason the button adds ellipsis and I've no clue why.
Here is the link to the sample application
https://github.com/SDSethia/ColoredButton.git
JavaFX shortens the label automatically, when the size of the control (a button in your case) is too small for the text. This is independent of E4. So if you increase the size of the button, the complete text will show.
I looked at your project and I am wondering why you are using the SWT renderers, although you want to use JavaFX!
If you want to use E4 + JavaFX I recommend to use the e(fx)clipse renderers. This tutorial should get you started: https://wiki.eclipse.org/Efxclipse/Tutorials/Tutorial4
The button needs a layout (I wrapped mine in an HBox) for it to render correctly. Here is the modified code
final FXCanvas canvas = new FXCanvas(parent, SWT.NONE);
button = new Button();
button.setText("FxButton (1)");
button.setStyle("-fx-background-color: #186dee; -fx-text-fill: white;");
final HBox box = new HBox();
box.getChildren().add(button);
final Scene scene = new Scene(box);
canvas.setScene(scene);
This solved the issue.

Using a JScrollPane in a JEditorPane

Hi so I'm struggling to apply a JScrollPanel within a JEditorPane.
I have a main content window (which has a scroll bar) and within that a JEditorPane that I would like to scroll slide horizontal and vertical. So far I have
JEditorPane monApp = new JEditorPane();
and have tried
ScrollablePanel panel = new ScrollablePanel();
panel.setScrollableWidth( ScrollablePanel.ScrollableSizeHint.FIT );
along with a few other things but couldn't seem to get any of them working.

Java plugin pop-up menu

I have a plugin which adds a view. This view contains a table which contains on each row some informations. I would like to have a popup menu when I press the right mouse click.
How can I add the extension org.eclipse.ui.menus and after creating the menuContribution to see it in the view ?
In your ViewPart use this code:
MenuManager contextMenu = new MenuManager();
contextMenu.setRemoveAllWhenShown(true);
getSite().registerContextMenu(contextMenu, viewer);
Control control = viewer.getControl();
Menu menu = contextMenu.createContextMenu(control);
control.setMenu(menu);
where viewer is your TableViewer.
The context menu this creates has the same id as your view so you contribute to it with:
<menuContribution
locationURI="popup:your.view.id">
....
</menuContribution>

Vaadin: How to identify individual tabs in a TabSheet?

In Vaadin, say I have a Tabsheet, with several Tabs.
If I want to add subtabs to any of the Tabs in the Tabsheet, based on which Tab the subtabs have as their "parent" tab , how do I do this?
Tabs are identified by the Component they hold. So, basically addanother TabSheet as a Tab to have subtabs:
TabSheet tabs = new TabSheet();
TabSheet subTabs = new TabSheet();
tabs.addTab(subTabs, "Parent tab",null);
subTabs.addTab(new Label("Subtab content"), "Subtab",null);

Mouse Click event

I am using RCP with eclipse 3.6 and java 6.
The user needs to click with right mouse buttom then opened a menu where he makes a choice.
Which mouse event is that?
How to fill the menu with choices?.
Regards,
Haythem
Have a look at this article about RCP and eclipse 3.6. The section that I've linked to describes how to create a context menu (for a table), that will pop up when right clicking.
What I need is how to create mouseeventlistener from a menu and menuitem
Sectionstop in my code is the composite where the mouselistener will be added
Menu menu = new Menu (parent.getShell(), SWT.POP_UP);
MenuItem item = new MenuItem (menu, SWT.PUSH);
item.setText("Text 1");
MenuItem item2 = new MenuItem (menu, SWT.PUSH);
item2.setText("text 2");
sectionStop.setMenu (menu);
Since you are on your RCP, the basic question is where does the user right clicks. Is it on your view/editor or on an object that you contributed to some viewers? A better If you then you should look into contributing via the proper extension points. Either org.eclipse.ui.popupMenus or org.eclipse.ui.menus with locationURI "popup:org.eclipse.ui.popup.any"

Categories

Resources