I just started working with GWT Widgets. I am familiar with jQuery and GWT Query is similar and hence I'm comfortable with it.
I need to make a custom widget in GWT which encompasses the functionality I made in GQuery.
I know that GWT widgets need to be contained in a panel, but I have an existing element in GQuery. So I guess I need to convert that element to a widget first. How should I go about it ?
Using last code in GQuery (1.2.1-SNAPSHOT), you should be able to convert any element into a gwt panel using the panel() method.
GQuery myGQueryWidget = $("<div><h1>Hello</h1>World</div>");
Panel myGwtWidget = myGQueryWidget.as(Widgets.Widgets).panel();
Of course you can use this panel as any widget which you can add to any other gwt panel, or even you could add other gwt widgets to it.
You have to be aware about events because if you add gwt events to the panel it will remove events added with gquery
you can use GWTQuerys WidgetsHtmlPanel(http://gwtquery.googlecode.com/svn/trunk/gwtquery-core/javadoc/com/google/gwt/query/client/plugins/widgets/WidgetsHtmlPanel.html ) to convert HTML content to Panel.
This should do the trick.
Related
What is the exact use of ColumnViewerTooltipSupport? I know that it provides tooltip support for ColumnViewers but does it mean that it provides tooltip for treeViewers? How can I use this feature to provide tooltip support individually different tooltips for my each tree item when the mouse hovers over each item? Do I require a MouseListener for this or does the ColumnViewerTooltipSupport class provide it by default? Can someone please help me out here as I'm relatively new to SWT concepts.
My tooltip has multiple lines, How can I wrap the text and display it neatly? It seems like ColumnViewerToolTipSupport class does not wrap the tooltip text if the text is too long. I would like to use a tooltip window with a vertical scroll bar just like the InformationControl Windows in eclipse? If something like eclipse is not possible then just a tooltip window with wrapped up text.
Please show me an example snippet?
ColumnViewerToolTipSupport adds support for individual tooltips to TableViewer and TreeViewer (and other ColumnViewers), you enable this using:
ColumnViewerToolTipSupport.enableFor(viewer);
The support expects that the label provider(s) for the viewer are based on CellLabelProvider (or one of its subclasses).
CellLabelProvider has getToolTipImage, getToolTipText, getToolTipBackgroundColor, getToolTipForegroundColor, getToolTipFont and getToolTipShift methods that you can override to control the tooltips.
Note: All this is JFace code not pure SWT
I have been writing some basic code for an application I am designing. I have learned the basics and gotten some simple database connection working with RPC calls etc. What I need to do now and am completely lost (as I am traditionally a c# developer with windows forms).
In c# if I wanted a new form I would just create it, and then call the show method.
How does one create multiple pages in GWT, and switch between them?
Thanks in advance,
Chris
The simplest way would be to
Make a new java class (GwtHome.java, GwtHelp.java etc)
Extend these classes by using the Composite class
Make the equivalent of a Master Page and add it to the rootPanel as a class with the appropriate headers, menu, footer and Content Placeholder (Could be any of the AbsolutePanel, VerticalPanel, HorizontalPanel objects provided by the GWT Framework)
By clicking on the menu clear the Placeholder and add the appropriate object of GwtHome, GwtHelp etc.
After getting aquanted with the above procedure, you might want to break up the code in many files using a design pattern as suggested by Andrei.
Simply clear the root panel (RootPanel.get().clear()) and add the widget for your new "page", the same way you added your first one.
If you're using LayoutPanels, do RootLayoutPanel.get().clear() instead.
Look at Activities and Places design pattern: https://developers.google.com/web-toolkit/doc/latest/DevGuideMvpActivitiesAndPlaces
I highly recommend it for a multipage GWT app. It explains pretty well how you create different "views", that are driven by their "activities", and tied to specific "places" (pages) that users can navigate.
Typically you use a LayoutPanel as your "page" container that occupies the entire available browser window. You split this LayoutPanel into 2-3 layers (zones), like top menu, side menu, main area. Each area contains one widget, usually a ScrollPanel, FlowPanel, or HtmlPanel. Then you use different widgets or HTML inside each of these widgets to display whatever you need. You may also create your own composite widgets that you can reuse in different pages.
I need to create a JTextField (or any component where I can type something) and it has to offer a list of dynamicaly populated values. When I type a new character, the propositions are updated (Like Ajax does)
One particularity is that the user can only choose a value that was populated. I need that for my users to select an existing city from a database.
What would be the easiest way to make it with Swing ?
Thank you.
You can implements Auto complete ComboBox / JFextField based on standard Java API, there aren't any issues with Focus or Caret nor with performance for largiest Arrays for autocompleted JComboBox and JTextField
I have used the JIDE Common Layer for autocompletion in Java Swing. Take a look at the WebStart demo.
It's free and open source, and if the provided autocompletion options don't quite match what you are trying to do I found it really easy to plug in my own logic.
You can use Swingx.Contains extensions to the Swing GUI toolkit, including new and enhanced components that provide functionality commonly required by rich client applications. Highlights include:
Sorting, filtering, highlighting for tables, trees, and lists
Find/search
Auto-completion
Login/authentication framework
TreeTable component
Collapsible panel component
Date picker component
Tip-of-the-Day component
What is the best way to implement a horizontal navbar in GWT? Using a MenuBar, a TabLayoutPanel, or coding something by hand, that is take a bunch of divs an float them within another div? If played around using TabLayoutPanel but wasn't able to style it to fit my needs.
EDIT
Here's what I intend to do: I have a MasterPage, laid out using a DockLayoutPanel. I have a header, footer, and a content area. After login, the content are should be filled with some sort of navigation and an area showing some panel with some widgets.
The problem with MenuBar (and MenuItems) is its rendering. GWT is rendering everything regarding menus as table and bunch of s and s. This usually messes up the layout of the rest of the page since GWT 2.0+ uses s for most of the widgets.
So, until GWT comes up with the "Layout" version for the MenuBar custom solution is probably the best solution.
A horizontal MenuBar works great for us. Give each MenuItem a Command that triggers your navigation system, or just swap controls in and out of your content area directly.
A MenuBar will be more flexible than using a TabLayoutPanel, but less flexible than a bunch of custom-coded divs.
I need to be able to change the following styles in gwt only through the use of the css file and no java at all.
Font Size of the top tab of decorated panel
Then, the Header of the Stack Panel
The header of the caption panel
This page might be useful for you:
http://code.google.com/intl/sv-SE/webtoolkit/doc/latest/DevGuideUiCss.html
Basically, most of the GWT widgets have a class called gwt-(Classname) (e.g. gwt-StackPanel). Some have multiple ones. This should be described in the API as well, e.g.:
http://asquare.net/gwt/javadoc/1.0.21/com/google/gwt/user/client/ui/StackPanel.html