Hello Ray :) Would you take a look at this patch for the 1.6 branch, adding the InlineHyperlink widget?
It adds a protected constructor to Hyperlink, allowing subclasses to pass a wrapper element. If that element is null, it calls setElement with the anchor element. InlineHyperlink then is just a Hyperlink widget with no wrapping div. Associated issue is here: http://code.google.com/p/google-web-toolkit/issues/detail?id=3056 Thanks! -- Alex Rudnick swe, gwt, atl --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/Google-Web-Toolkit-Contributors -~----------~----~----~----~------~----~------~--~---
Index: user/src/com/google/gwt/user/client/ui/InlineHyperlink.java =================================================================== --- user/src/com/google/gwt/user/client/ui/InlineHyperlink.java (revision 0) +++ user/src/com/google/gwt/user/client/ui/InlineHyperlink.java (revision 0) @@ -0,0 +1,69 @@ +/* + * Copyright 2008 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.gwt.user.client.ui; + +/** + * A widget that serves as an "internal" hyperlink. That is, it is a link to + * another state of the running application. It should behave exactly like + * [EMAIL PROTECTED] com.google.gwt.user.client.ui.Hyperlink}, save that it lays out + * as an inline element, not block. + * + * <h3>CSS Style Rules</h3> <ul class='css'> <li>.gwt-InlineHyperlink { }</li> + * </ul> + */ +public class InlineHyperlink extends Hyperlink { + + /** + * Creates an empty hyperlink. + */ + public InlineHyperlink() { + super(null); + + setStyleName("gwt-InlineHyperlink"); + } + + /** + * Creates a hyperlink with its text and target history token specified. + * + * @param text the hyperlink's text + * @param asHTML <code>true</code> to treat the specified text as html + * @param targetHistoryToken the history token to which it will link + * @see #setTargetHistoryToken + */ + public InlineHyperlink(String text, boolean asHTML, String targetHistoryToken) { + this(); + + if (asHTML) { + setHTML(text); + } else { + setText(text); + } + setTargetHistoryToken(targetHistoryToken); + } + + /** + * Creates a hyperlink with its text and target history token specified. + * + * @param text the hyperlink's text + * @param targetHistoryToken the history token to which it will link + */ + public InlineHyperlink(String text, String targetHistoryToken) { + this(); + setText(text); + setTargetHistoryToken(targetHistoryToken); + } +} Property changes on: user/src/com/google/gwt/user/client/ui/InlineHyperlink.java ___________________________________________________________________ Name: svn:mime-type + text/x-java Name: svn:eol-style + native Index: user/src/com/google/gwt/user/client/ui/Hyperlink.java =================================================================== --- user/src/com/google/gwt/user/client/ui/Hyperlink.java (revision 4235) +++ user/src/com/google/gwt/user/client/ui/Hyperlink.java (working copy) @@ -42,10 +42,7 @@ * <img class='gallery' src='Hyperlink.png'/> * </p> * - * <h3>CSS Style Rules</h3> - * <ul class='css'> - * <li>.gwt-Hyperlink { }</li> - * </ul> + * <h3>CSS Style Rules</h3> <ul class='css'> <li>.gwt-Hyperlink { }</li> </ul> * * <p> * <h3>Example</h3> [EMAIL PROTECTED] com.google.gwt.examples.HistoryExample} @@ -55,7 +52,7 @@ HasClickHandlers { private static HyperlinkImpl impl = GWT.create(HyperlinkImpl.class); - + private Element anchorElem; private String targetHistoryToken; @@ -63,10 +60,7 @@ * Creates an empty hyperlink. */ public Hyperlink() { - setElement(DOM.createDiv()); - DOM.appendChild(getElement(), anchorElem = DOM.createAnchor()); - sinkEvents(Event.ONCLICK); - setStyleName("gwt-Hyperlink"); + this(DOM.createDiv()); } /** @@ -99,6 +93,20 @@ setTargetHistoryToken(targetHistoryToken); } + protected Hyperlink(Element elem) { + anchorElem = DOM.createAnchor(); + + if (elem == null) { + setElement(anchorElem); + } else { + setElement(elem); + DOM.appendChild(getElement(), anchorElem); + } + + sinkEvents(Event.ONCLICK); + setStyleName("gwt-Hyperlink"); + } + public HandlerRegistration addClickHandler(ClickHandler handler) { return addHandler(handler, ClickEvent.getType()); } @@ -130,7 +138,7 @@ public void onBrowserEvent(Event event) { if (DOM.eventGetType(event) == Event.ONCLICK) { super.onBrowserEvent(event); - + if (impl.handleAsClick(event)) { History.newItem(getTargetHistoryToken()); DOM.eventPreventDefault(event);
