Displaying only one panel at once - gwt

I'd like to have the effect of one of two panels visible at given time in the same place on the screen. Perhaps I could use the DeckPanel but then in the designer I wouldn't be able to edit the hidden one. Maybe you could recommend a technique?
I've found a solution which works but is not pretty IMHO. Ie. in the code I insert the panel which I want to be visible and remove the panel which I don't want to be visible (from the containing panel).

Just put both panel within another panel and then set their visibility.
Panel mainPanel = new Panel();
Panel subPanel1 = new Panel();
Panel subPanel2 = new Panel();
mainPanel.add(subPanel1);
mainPanel.add(subPanel2);
subPanel1.setVisible(true);
subPanel2.setVisible(false);
And then when you want to see panel 2 you just do this:
subPanel1.setVisible(false);
subPanel2.setVisible(true);

If you want to do this the "right" way, I'd suggest looking into the MVP pattern that GWT team in is suggesting for maintaining large-ish GWT application.
Take a look at possible implementations: mvp4g or gwt-platform. They will take care for you of switching views, as well as maintaining history (the back/forward buttons will work as they should) and many more.

You can go for Tablayoutpanel Need not to maintain your own code .

Related

How do I force the eclipse Outline View to request a new ContentOutlinePage?

I have an editor which can supply two different ContentOutlinePages to the outline, depending on the user's choice.
However, when I change the ContentOutlinePage to be displayed, I have to close and reopen the Outline View to see any changes. I understand that the Outline View requests a new ContentOutlinePage when the editor is activated, but is there a way to force it to request a new page at any other time?
I tried just calling
activePage.activate(editor);
where activePage is the active workbench page and editor ist the editor that is currently being displayed, but that didn't work.
Rather than have two content pages you could have one page that can show both of your outlines. To do this you cannot extend the normal ContentOutlinePage, instead you need a class like this:
public class MyContentOutlinePage extends Page
implements IContentOutlinePage, ISelectionChangedListener
The amount of code in the standard ContentOutlinePage is quite small so it is not much extra work to implement a page which meets your needs.
Update:
You would have one top level control containing the SashForm and TreeViewer and always return the top control in getControl(). You would hide either the SashForm or TreeViewer depending on which you want to show.
The top level control could be something like PageBook or a Composite using StackLayout.

Gwt, the Dilemma of TabPanel, TabLayoutPanel & Custom Tab using TabBar +DeckLayoutPanel

My app has a need to store many Panel dynamically. So TabPanel is the suitable choice. However, TabPanel only works in Quirks Mode, it can also work in Standards Mode but with some Quirks, ex, when u click a link put inside a TabPanel then there is a small shaking appeared. But TabPanel is pretty simple, not heavy & easy to code.
I am not sure if i put link into a HTMLpanel & then put that HTMLPanel into that TabPanel then the shaking problem will be solved or not?
Some others say do not use TabPanel cos its behavor is unpredictable in many different webbrowsers since it support only Quirks Mode. They prefers to use TabLayoutPanel. Ok, TabLayoutPanel is very stable solid, but it is quite complicated, it must be put into the RootLayoutPanel. If I don't put it into RootLayoutPanel, then i have to set its fixed width & height (ex: 600px 300px) to be able to see it in Non-root presenters. But I want its height + width to stretch out to 100%. Some peopl have problems with TabLayoutPanel so they have to switch to TabPanel but TabPanel may be deprecated in the future.
So, some suggest me to use custom TabPanel using TabBar + DeckLayoutPanel, but i couldn't find any UiBinder guide for how to use TabBar + DeckLayoutPanel to make custom TabPanel.
If u have to use Tab in ur app (in respect to the above constraints, ie run smoothly in standards mode & not put into RootPanel) then which solution will u choose?
What approach is the best?
I use the TabLayoutPanel where possible.
When I need a tab panel that does not use the entire window or I want the tab contents to take just the side needed for the selected tab then I use a custom made TabPanel. That one is using the TabLayoutPanel for showing the tabs but the contents are put outside in a FlowPanel.

JavaFX 2 custom popup pane

The JavaFX 2 colour picker has a button that pops up a colour chooser pane like so:
I'd like to do something similar, in that I'd like a custom pane to pop up when the button is clicked on and disappear when something else is clicked (in my case, a few image thumbnails). What would be the best way of achieving this? Should I use a ContextMenu and add a pane to a MenuItem somehow, or is there something else I should look at?
It's kind of difficult to do well with the current JavaFX 2.2 API.
Here are some options.
Use a MenuButton with a graphic set in it's MenuItem
This is the approach taken in Button with popup showed below's executable sample code.
Use a PopupControl
Take a look at how the ColorPicker does this in it's code.
ColorPicker extends PopupControl. You could do this, but not all of the API required to build your own PopupControl is currently public. So, for JavaFX 2.2, you would have to rely on internal com.sun classes which are deprecated and will be replaced by public javafx.scene.control classes in JDK8.
Use a ContextMenu
So, I think your idea to "use a ContextMenu and add a pane to a MenuItem" is probably the best approach for now. You should be able to do this by using a CustomMenuItem or setting a graphic on a normal MenuItem. The ContextMenu has nice relative positioning logic. A ContextMenu can also be triggered by a MenuButton.
Use a Custom Dialog
To do this, display a transparent stage at a location relative to the node.
There is some sample code to get you started which I have temporarily linked here.
The sample code does relative positioning to the sides of the main window, but you could update it to perform positioning relative to the sides of a given node (like the ContextMenu's show method).
Use a Glass Pane
To do this, create a StackPane as your root of your main window. Place your main content pane as the first node in the StackPane and then create a Group as the second node in the stackpane, so that it will layer over the top of the main content. Normally, the top group contains nothing, but when you want to show your popup, place it in the top group and translate it to a location relative to the appropriate node in your main content.
You could look at how the anchor nodes in this demo are used to see how this might be adaptable to your context.
Is there a relevant update for this for JavaFX8?
There is not much difference of relevance for Java 8, in general the options are as outlined in this post based on Java 2.2 functionality. Java 8 does add Dialog and Alert functionality, but those are more targeted at use of dialogs with borders, titles and buttons rather than the kind of functionality desired in the question. Perhaps you might be able to start from the Dialog class and heavily customize it to get something close to what is needed, but you are probably better off starting from a blank stage or PopupControl instead.

How to disable hover effect to highlight menu items in GWT MenuBar?

I am making a vertical Menu using GWT MenuBar and selection of particular MenuItem shows content on the right, I am trying to make something similar to TabPanel, but with Tabs on left instead of being on top. Now, since I've got the Menu items and actions in place, I want to remove the effect of hovering over and changing color, and keep that menu item selected which was clicked last and whose content is loaded on the right.
I am open to any comments, if you have a better solution to implement this, using some other components(with-in) GWT, please drop in a comment with your suggestions, I'll really appreciate that.
Or if you can just tell me how can I disable this effect, of hovering and sticking to only that selection, That would be awesome too..
Thanks to everyone, taking time to read this and suggesting a solution.
It's all defined in the CSS of your GWT's theme (probably the default one), so it's a matter of overriding those styles - make sure it's not the other way around :) Inspect the code with a tool like Firebug to see what's exactly being set and change that.

Moveable Panels in GWT?

I need some panels in GWT that have moveable functionality. This is so that if you have a series of event-driven panels that have to be displayed on screen, they aren't all directly on top of each other. This can cause problems when you want to compare two different panels or want to close panels in your own order.
I'm currently using PopupPanels which as far as I'm aware, don't have this functionality.
I think what you want is a DialogBox. This class is a movable PopupPanel and has a constructor argument to create it as non modal, meaning if set to non modal mouse/keyboard events outside the panel are not ignored, but passed to the underlying widgets. This allows to open multiple DialogBox at once and being able to click on them or what's under it.
However, these panels can be moved inside the whole browser window and it's not possible to limit the movable area in the browser window. If you want such functionality you might want to look at the http://code.google.com/p/gwt-dnd/ library, which makes it possible to create movable panels inside a specific area.
Does your DialogBox refuse to be moved/dragged around? Make sure you DO NOT add() it into your RootPanel. Just create a new dialog and call show() on it.