hi,
I've already posted example on GWT toolkit group, I don't think it was very complicated to use,
anyway, again example implementation for GWT Designer:
Widget:
- Code: Select all
package com.mycompany.project.client;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.HasHTML;
import com.google.gwt.user.client.ui.HasName;
import com.google.gwt.user.client.ui.Widget;
/**
* Basic implementation of raw Anchor <a> widget
*
* @see http://www.w3schools.com/tags/tag_a.asp
* @author Peter Blazejewicz
*
*/
public class HtmlLink extends Widget implements HasHTML, HasName {
public HtmlLink() {
setElement(DOM.createAnchor());
}
public String getHref() {
return DOM.getElementAttribute(getElement(), "href");
}
public String getHTML() {
return DOM.getInnerHTML(getElement());
}
public String getId() {
return DOM.getElementAttribute(getElement(), "id");
}
public String getName() {
return DOM.getElementAttribute(getElement(), "name");
}
public int getTabIndex() {
return $getTabIndex(getElement());
}
public String getTarget() {
return DOM.getElementAttribute(getElement(), "target");
}
public String getText() {
return DOM.getInnerText(getElement());
}
public void setHref(String href) {
DOM.setElementAttribute(getElement(), "href", href == null ? "" : href);
}
public void setHTML(String html) {
DOM.setInnerHTML(getElement(), html == null ? "" : html);
}
public void setId(String id) {
DOM.setElementAttribute(getElement(), "id", id == null ? "" : id);
}
public void setName(String name) {
DOM.setElementAttribute(getElement(), "name", name == null ? "" : name);
}
public void setTabIndex(int index) {
$setTabIndex(getElement(), index);
}
public void setTarget(String target) {
DOM.setElementAttribute(getElement(), "target", target == null ? ""
: target);
}
public void setText(String text) {
DOM.setInnerText(getElement(), text == null ? "" : text);
}
private native int $getTabIndex(Element element)
/*-{
return element.tabIndex;
}-*/;
private native void $setTabIndex(Element element, int index)
/*-{
element.tabIndex = index;
}-*/;
}
use in project (all code generated via D&D then modified using properties window):
entry point:
- Code: Select all
package com.mycompany.project.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.RootPanel;
import com.mycompany.project.client.HtmlLink;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class LinkExample implements EntryPoint {
private HtmlLink solutionsLink;
private HtmlLink forumLink;
private HtmlLink javaLink;
private HtmlLink ajaxLink;
public void onModuleLoad() {
RootPanel rootPanel = RootPanel.get();
final FlowPanel flowPanel = new FlowPanel();
rootPanel.add(flowPanel);
flowPanel.setStyleName("banner-lower");
solutionsLink = new HtmlLink();
flowPanel.add(solutionsLink);
solutionsLink.setTarget("_blank");
solutionsLink.setHref("http://www.instantiations.com/solutions/");
solutionsLink.setStyleName("menuLink");
solutionsLink.setText("Solutions");
javaLink = new HtmlLink();
flowPanel.add(javaLink);
javaLink.setTarget("_blank");
javaLink.setHref("http://www.instantiations.com/prods/docs/java.html");
javaLink.setStyleName("menuLink");
javaLink.setText("Java Products");
ajaxLink = new HtmlLink();
flowPanel.add(ajaxLink);
ajaxLink.setTarget("_blank");
ajaxLink.setHref("http://www.instantiations.com/prods/docs/ajax.html");
ajaxLink.setStyleName("menuLink");
ajaxLink.setText("Ajax Products");
forumLink = new HtmlLink();
flowPanel.add(forumLink);
forumLink.setTarget("_blank");
forumLink.setStyleName("menuLink");
forumLink.setHref("http://www.instantiations.com/forum/viewforum.php?f=11");
forumLink.setText("GWT Designer Forum");
}
}
css:
- Code: Select all
body {
font-family: Helvetica, Arial, sans-serif;
line-height: 1.15;
background-color: #CADCEB;
}
a:link,a:visited {
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.banner-lower {
padding: 10px;
background-color: #6C1F88;
color: white;
font-size: 65%;
display: block
}
.menuLink {
margin: 5px;
background-color: #6C1F88;
color: white;
font-weight: bold;
text-decoration: none;
}
screenshot in design view when working with project:
- project design view (GWT Designer)
- designView.jpg (123.9 KiB) Viewed 2400 times
screenshot of browser mode view:
- project compiled view in browser (Safari/Win)
- browserView.jpg (26.51 KiB) Viewed 2395 times
regards,
Peter