import com.google.gwt.dom.client.NodeList;
import com.google.gwt.dom.client.OptionElement;
import com.google.gwt.dom.client.SelectElement;
-import com.google.gwt.dom.client.Style;
import com.google.gwt.dom.client.TextAreaElement;
import com.google.gwt.dom.client.Style.Display;
import com.google.gwt.query.client.css.CssProperty;
public interface LazyGQuery<T> extends LazyBase<T>{
- /**
- * Add elements to the set of matched elements if they are not included yet.
- */
- LazyGQuery<T> add(String selector);
-
/**
* Adds the specified classes to each matched element. Add elements to the set
* of matched elements if they are not included yet.
*/
LazyGQuery<T> add(GQuery previousObject);
+ /**
+ * Add elements to the set of matched elements if they are not included yet.
+ */
+ LazyGQuery<T> add(String selector);
+
/**
* Adds the specified classes to each matched element.
*/
* already be inserted into the document (you can't insert an element after
* another if it's not in the page).
*/
- LazyGQuery<T> after(Node n);
+ LazyGQuery<T> after(GQuery query);
/**
* Insert content after each of the matched elements. The elements must
* already be inserted into the document (you can't insert an element after
* another if it's not in the page).
*/
- LazyGQuery<T> after(String html);
+ LazyGQuery<T> after(Node n);
/**
* Insert content after each of the matched elements. The elements must
* already be inserted into the document (you can't insert an element after
* another if it's not in the page).
*/
- LazyGQuery<T> after(GQuery query);
+ LazyGQuery<T> after(String html);
/**
* Add the previous selection to the current selection. Useful for traversing
* similar to doing an appendChild to all the specified elements, adding them
* into the document.
*/
- LazyGQuery<T> append(String html);
+ LazyGQuery<T> append(GQuery query);
/**
* Append content to the inside of every matched element. This operation is
* similar to doing an appendChild to all the specified elements, adding them
* into the document.
*/
- LazyGQuery<T> append(GQuery query);
+ LazyGQuery<T> append(String html);
/**
* Append all of the matched elements to another, specified, set of elements.
*/
<T extends GQuery> T as(Class<T> plugin);
+ /**
+ * Set a key/value object as properties to all matched elements.
+ *
+ * Image'"))
+ */
+ LazyGQuery<T> attr(Properties properties);
+
/**
* Access a property on the first matched element. This method makes it easy
* to retrieve a property value from the first matched element. If the element
String attr(String name);
/**
- * Set a single property to a value, on all matched elements.
- */
- LazyGQuery<T> attr(String key, String value);
-
- /**
- * Set a key/value object as properties to all matched elements.
- *
- * Image'"))
+ * Set a single property to a computed value, on all matched elements.
*/
- LazyGQuery<T> attr(Properties properties);
+ LazyGQuery<T> attr(String key, Function closure);
/**
- * Set a single property to a computed value, on all matched elements.
+ * Set a single property to a value, on all matched elements.
*/
- LazyGQuery<T> attr(String key, Function closure);
+ LazyGQuery<T> attr(String key, String value);
/**
* Insert content before each of the matched elements. The elements must
* already be inserted into the document (you can't insert an element before
* another if it's not in the page).
*/
- LazyGQuery<T> before(Node n);
+ LazyGQuery<T> before(GQuery query);
/**
* Insert content before each of the matched elements. The elements must
* already be inserted into the document (you can't insert an element before
* another if it's not in the page).
*/
- LazyGQuery<T> before(GQuery query);
+ LazyGQuery<T> before(Node n);
/**
* Insert content before each of the matched elements. The elements must
*/
LazyGQuery<T> change(Function...f);
- /**
- * Get a set of elements containing all of the unique children of each of the
- * matched set of elements. This set is filtered with the expressions that
- * will cause only elements matching any of the selectors to be collected.
- */
- LazyGQuery<T> children(String... filters);
-
/**
* Get a set of elements containing all of the unique immediate children of
* each of the matched set of elements. Also note: while parents() will look
*/
LazyGQuery<T> children();
+ /**
+ * Get a set of elements containing all of the unique children of each of the
+ * matched set of elements. This set is filtered with the expressions that
+ * will cause only elements matching any of the selectors to be collected.
+ */
+ LazyGQuery<T> children(String... filters);
+
/**
* Bind a set of functions to the click event of each matched element.
* Or trigger the event if no functions are provided.
*/
LazyGQuery<T> click(Function...f);
+ /**
+ * Returns the inner height of the first matched element, including padding
+ * but not the vertical scrollbar height, border, or margin.
+ */
+ int clientHeight();
+
+ /**
+ * Returns the inner width of the first matched element, including padding
+ * but not the vertical scrollbar width, border, or margin.
+ */
+ int clientWidth();
+
/**
* Clone matched DOM Elements and select the clones. This is useful for moving
* copies of the elements to another location in the DOM.
LazyGQuery<T> contents();
/**
- * Set CSS property on every matched element using type-safe enumerations.
+ * Set a key/value object as style properties to all matched elements. This
+ * serves as the best way to set a large number of style properties on all
+ * matched elements.
+ *
+ * Example: $(".item").css(Properties.create("color: 'red', background:
+ * 'blue'"))
*/
- <S, T extends CssProperty<S>> LazyGQuery<T> css(T cssProperty, S value);
+ LazyGQuery<T> css(Properties properties);
/**
- * Set CSS property on every matched element using type-safe enumerations.
+ * Return a style property on the first matched element.
*/
- LazyGQuery<T> css(TakesLength cssProperty, Length value);
+ String css(String name);
/**
- * Set CSS property on every matched element using type-safe enumerations.
+ * Return a style property on the first matched element.
+ *
+ * The parameter force has a special meaning here:
+ * - When force is false, returns the value of the css property defined
+ * in the style attribute of the element.
+ * - Otherwise it returns the real computed value.
+ *
+ * For instance if you define 'display=none' not in the element style
+ * but in the css stylesheet, it returns an empty string unless you
+ * pass the parameter force=true.
*/
- LazyGQuery<T> css(TakesPercentage cssProperty, Percentage value);
+ String css(String name, boolean force);
/**
- * Return a style property on the first matched element.
+ * Set a single style property to a value, on all matched elements.
*/
- String css(String name);
+ LazyGQuery<T> css(String prop, String val);
/**
- * Set a key/value object as style properties to all matched elements. This
- * serves as the best way to set a large number of style properties on all
- * matched elements.
- *
- * Example: $(".item").css(Properties.create("color: 'red', background:
- * 'blue'"))
+ * Set CSS property on every matched element using type-safe enumerations.
*/
- LazyGQuery<T> css(Properties properties);
+ <S, T extends CssProperty<S>> LazyGQuery<T> css(T cssProperty, S value);
/**
- * Set a single style property to a value, on all matched elements.
+ * Set CSS property on every matched element using type-safe enumerations.
*/
- LazyGQuery<T> css(String prop, String val);
+ LazyGQuery<T> css(TakesLength cssProperty, Length value);
+
+ /**
+ * Set CSS property on every matched element using type-safe enumerations.
+ */
+ LazyGQuery<T> css(TakesPercentage cssProperty, Percentage value);
/**
* Returns value at named data store for the element, as set by data(name,
*/
LazyGQuery<T> error(Function... f);
- /**
- * Fade in all matched elements by adjusting their opacity.
- */
- LazyGQuery<T> fadeIn(int millisecs, Function... f);
-
/**
* Fade in all matched elements by adjusting their opacity. The effect will
* take 1000 milliseconds to complete
LazyGQuery<T> fadeIn(Function... f);
/**
- * Fade out all matched elements by adjusting their opacity.
+ * Fade in all matched elements by adjusting their opacity.
*/
- LazyGQuery<T> fadeOut(int millisecs, Function... f);
+ LazyGQuery<T> fadeIn(int millisecs, Function... f);
/**
* Fade out all matched elements by adjusting their opacity. The effect will
*/
LazyGQuery<T> fadeOut(Function... f);
+ /**
+ * Fade out all matched elements by adjusting their opacity.
+ */
+ LazyGQuery<T> fadeOut(int millisecs, Function... f);
+
/**
* Removes all elements from the set of matched elements that do not match the
* specified function. The function is called with a context equal to the
*/
boolean hasClass(String... classes);
- /**
- * Set the height of every element in the matched set.
- */
- LazyGQuery<T> height(int height);
-
- /**
- * Set the height style property of every matched element. It's useful for
- * using 'percent' or 'em' units Example: $(".a").width("100%")
- */
- LazyGQuery<T> height(String height);
-
/**
* Get the current computed, pixel, height of the first matched element.
*/
int height();
/**
- * Returns the inner height of the first matched element, including padding
- * but not the vertical scrollbar height, border, or margin.
+ * Set the height of every element in the matched set.
*/
- int clientHeight();
+ LazyGQuery<T> height(int height);
/**
- * Returns the inner width of the first matched element, including padding
- * but not the vertical scrollbar width, border, or margin.
+ * Set the height style property of every matched element. It's useful for
+ * using 'percent' or 'em' units Example: $(".a").width("100%")
*/
- int clientWidth();
+ LazyGQuery<T> height(String height);
/**
* Make invisible all matched elements.
* Insert all of the matched elements after another, specified, set of
* elements.
*/
- LazyGQuery<T> insertAfter(String selector);
+ LazyGQuery<T> insertAfter(Element elem);
/**
* Insert all of the matched elements after another, specified, set of
* elements.
*/
- LazyGQuery<T> insertAfter(Element elem);
+ LazyGQuery<T> insertAfter(GQuery query);
/**
* Insert all of the matched elements after another, specified, set of
* elements.
*/
- LazyGQuery<T> insertAfter(GQuery query);
+ LazyGQuery<T> insertAfter(String selector);
/**
* Insert all of the matched elements before another, specified, set of
/**
* Get a set of elements containing the unique ancestors of the matched set of
- * elements (except for the root element). The matched elements are filtered,
- * returning those that match any of the filters.
+ * elements (except for the root element).
*/
- LazyGQuery<T> parents(String... filters);
+ LazyGQuery<T> parents();
/**
* Get a set of elements containing the unique ancestors of the matched set of
- * elements (except for the root element).
+ * elements (except for the root element). The matched elements are filtered,
+ * returning those that match any of the filters.
*/
- LazyGQuery<T> parents();
+ LazyGQuery<T> parents(String... filters);
/**
* Gets the top and left position of an element relative to its offset parent.
* the best way to insert elements inside, at the beginning, of all matched
* elements.
*/
- LazyGQuery<T> prepend(String html);
+ LazyGQuery<T> prepend(GQuery query);
/**
* Prepend content to the inside of every matched element. This operation is
* the best way to insert elements inside, at the beginning, of all matched
* elements.
*/
- LazyGQuery<T> prepend(GQuery query);
+ LazyGQuery<T> prepend(Node n);
/**
* Prepend content to the inside of every matched element. This operation is
* the best way to insert elements inside, at the beginning, of all matched
* elements.
*/
- LazyGQuery<T> prepend(Node n);
+ LazyGQuery<T> prepend(String html);
/**
* Prepend all of the matched elements to another, specified, set of elements.
* elements. This function is the complement to replaceWith() which does the
* same task with the parameters reversed.
*/
- LazyGQuery<T> replaceAll(GQuery query);
+ LazyGQuery<T> replaceAll(Element elem);
/**
* Replaces the elements matched by the specified selector with the matched
* elements. This function is the complement to replaceWith() which does the
* same task with the parameters reversed.
*/
- LazyGQuery<T> replaceAll(String html);
+ LazyGQuery<T> replaceAll(GQuery query);
/**
* Replaces the elements matched by the specified selector with the matched
* elements. This function is the complement to replaceWith() which does the
* same task with the parameters reversed.
*/
- LazyGQuery<T> replaceAll(Element elem);
+ LazyGQuery<T> replaceAll(String html);
/**
* Replaces all matched elements with the specified HTML or DOM elements. This
* returns the GQuery element that was just replaced, which has been removed
* from the DOM.
*/
- LazyGQuery<T> replaceWith(GQuery query);
+ LazyGQuery<T> replaceWith(Element elem);
/**
* Replaces all matched elements with the specified HTML or DOM elements. This
* returns the GQuery element that was just replaced, which has been removed
* from the DOM.
*/
- LazyGQuery<T> replaceWith(String html);
+ LazyGQuery<T> replaceWith(GQuery query);
/**
* Replaces all matched elements with the specified HTML or DOM elements. This
* returns the GQuery element that was just replaced, which has been removed
* from the DOM.
*/
- LazyGQuery<T> replaceWith(Element elem);
+ LazyGQuery<T> replaceWith(String html);
+
+ /**
+ * Save a set of Css properties of every matched element.
+ */
+ void restoreCssAttrs(String... cssProps);
+
+ /**
+ * Restore a set of previously saved Css properties in every matched element.
+ */
+ void saveCssAttrs(String... cssProps);
/**
* Bind a set of functions to the scroll event of each matched element.
*/
LazyGQuery<T> scroll(Function...f);
+ /**
+ * Gets the scroll left offset of the first matched element. This method works
+ * for both visible and hidden elements.
+ */
+ int scrollLeft();
+
/**
* When a value is passed in, the scroll left offset is set to that value on
* all matched elements. This method works for both visible and hidden
LazyGQuery<T> scrollLeft(int left);
/**
- * Gets the scroll left offset of the first matched element. This method works
+ * Gets the scroll top offset of the first matched element. This method works
* for both visible and hidden elements.
*/
- int scrollLeft();
+ int scrollTop();
/**
* When a value is passed in, the scroll top offset is set to that value on
*/
LazyGQuery<T> scrollTop(int top);
- /**
- * Gets the scroll top offset of the first matched element. This method works
- * for both visible and hidden elements.
- */
- int scrollTop();
-
LazyGQuery<T> select();
/**
boolean visible();
/**
- * Set the width of every matched element.
+ * Get the current computed, pixel, width of the first matched element.
*/
- LazyGQuery<T> width(int width);
+ int width();
/**
- * Get the current computed, pixel, width of the first matched element.
+ * Set the width of every matched element.
*/
- int width();
+ LazyGQuery<T> width(int width);
/**
* Wrap each matched element with the specified HTML content. This wrapping
* within its structure -- it is that element that will enwrap everything
* else.
*/
- LazyGQuery<T> wrap(GQuery query);
+ LazyGQuery<T> wrap(Element elem);
/**
* Wrap each matched element with the specified HTML content. This wrapping
* within its structure -- it is that element that will enwrap everything
* else.
*/
- LazyGQuery<T> wrap(Element elem);
+ LazyGQuery<T> wrap(GQuery query);
/**
* Wrap each matched element with the specified HTML content. This wrapping
* element within its structure -- it is that element that will enwrap
* everything else.
*/
- LazyGQuery<T> wrapAll(String html);
+ LazyGQuery<T> wrapAll(Element elem);
/**
* Wrap all the elements in the matched set into a single wrapper element.
* element within its structure -- it is that element that will enwrap
* everything else.
*/
- LazyGQuery<T> wrapAll(Element elem);
+ LazyGQuery<T> wrapAll(GQuery query);
/**
* Wrap all the elements in the matched set into a single wrapper element.
* element within its structure -- it is that element that will enwrap
* everything else.
*/
- LazyGQuery<T> wrapAll(GQuery query);
+ LazyGQuery<T> wrapAll(String html);
/**
* Wrap the inner child contents of each matched element (including text
* HTML) and finds the deepest ancestor element within its structure -- it is
* that element that will enwrap everything else.
*/
- LazyGQuery<T> wrapInner(GQuery query);
+ LazyGQuery<T> wrapInner(Element elem);
/**
* Wrap the inner child contents of each matched element (including text
* HTML) and finds the deepest ancestor element within its structure -- it is
* that element that will enwrap everything else.
*/
- LazyGQuery<T> wrapInner(String html);
+ LazyGQuery<T> wrapInner(GQuery query);
/**
* Wrap the inner child contents of each matched element (including text
* HTML) and finds the deepest ancestor element within its structure -- it is
* that element that will enwrap everything else.
*/
- LazyGQuery<T> wrapInner(Element elem);
-
- /**
- * Save a set of Css properties of every matched element.
- */
- void restoreCssAttrs(String[] cssProps);
-
- /**
- * Restore a set of previously saved Css properties in every matched element.
- */
- void saveCssAttrs(String[] cssProps);
+ LazyGQuery<T> wrapInner(String html);
}
*/
package com.google.gwt.query.client;
+import java.util.Hashtable;
+
+import javax.naming.Binding;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.Name;
+import javax.naming.NameClassPair;
+import javax.naming.NameParser;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.spi.InitialContextFactory;
+
import com.google.gwt.junit.client.GWTTestCase;
/**
public String getModuleName() {
return null;
}
-
+
public void testAssertHtmlEquals() {
- GQueryCoreTest.assertHtmlEquals("<span>hello</span>","<span $h=\"5\">hello</span>");
- GQueryCoreTest.assertHtmlEquals("<p class=\"abc\">whatever</p> "," <p class=abc added=\"null\">Whatever</p>");
+ GQueryCoreTest.assertHtmlEquals("<span>hello</span>",
+ "<span $h=\"5\">hello</span>");
+ GQueryCoreTest.assertHtmlEquals("<p class=\"abc\">whatever</p> ",
+ " <p class=abc added=\"null\">Whatever</p>");
}
public void testWrapPropertiesString() {
- assertEquals("({border:'1px solid black'})", Properties.wrapPropertiesString("border:'1px solid black'"));
- assertEquals("({border:'1px solid black'})", Properties.wrapPropertiesString("(border:'1px solid black')"));
- assertEquals("({border:'1px solid black'})", Properties.wrapPropertiesString("{border:'1px solid black'}"));
- assertEquals("({border:'1px solid black'})", Properties.wrapPropertiesString("{border:'1px solid black'}"));
- assertEquals("({border:'1px solid black'})", Properties.wrapPropertiesString("(border:'1px solid black')"));
- assertEquals("({border:'1px solid black'})", Properties.wrapPropertiesString("{(border:'1px solid black')}"));
- assertEquals("({border:'1px solid black'})", Properties.wrapPropertiesString("({border:'1px solid black'})"));
+ assertEquals("({border:'1px solid black'})", Properties
+ .wrapPropertiesString("border:'1px solid black'"));
+ assertEquals("({border:'1px solid black'})", Properties
+ .wrapPropertiesString("(border:'1px solid black')"));
+ assertEquals("({border:'1px solid black'})", Properties
+ .wrapPropertiesString("{border:'1px solid black'}"));
+ assertEquals("({border:'1px solid black'})", Properties
+ .wrapPropertiesString("{border:'1px solid black'}"));
+ assertEquals("({border:'1px solid black'})", Properties
+ .wrapPropertiesString("(border:'1px solid black')"));
+ assertEquals("({border:'1px solid black'})", Properties
+ .wrapPropertiesString("{(border:'1px solid black')}"));
+ assertEquals("({border:'1px solid black'})", Properties
+ .wrapPropertiesString("({border:'1px solid black'})"));
+ }
+ public void test() throws NamingException {
+ System.out.println( MockInitialContextFactory.class.getName());
+ System.setProperty("java.naming.factory.initial", MockInitialContextFactory.class.getName());
+ Context mockCtx = new MockContext();
+// UserTransaction mockTrans = createMock(UserTransaction.class);
+// expect(mockCtx.lookup("UserTransaction")).andReturn(mockTrans);
+// replay(mockCtx);
+ MockInitialContextFactory.setMockContext(mockCtx);
+
+ Context ctx = new InitialContext();
+ ctx.lookup("whatever");
+
+ }
+ public static class MockInitialContextFactory implements
+ InitialContextFactory {
+ private static Context mockCtx = null;
+
+ public static void setMockContext(Context ctx) {
+ mockCtx = ctx;
+ }
+
+ public Context getInitialContext(java.util.Hashtable<?, ?> environment)
+ throws NamingException {
+ if (mockCtx == null) {
+ throw new IllegalStateException("mock context was not set.");
+ }
+ return mockCtx;
+ }
}
+ public static class MockContext implements Context {
+
+ public Object addToEnvironment(String propName, Object propVal)
+ throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void bind(Name name, Object obj) throws NamingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void bind(String name, Object obj) throws NamingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void close() throws NamingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Name composeName(Name name, Name prefix) throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String composeName(String name, String prefix)
+ throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Context createSubcontext(Name name) throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Context createSubcontext(String name) throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void destroySubcontext(Name name) throws NamingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void destroySubcontext(String name) throws NamingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Hashtable<?, ?> getEnvironment() throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getNameInNamespace() throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public NameParser getNameParser(Name name) throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public NameParser getNameParser(String name) throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public NamingEnumeration<NameClassPair> list(Name name)
+ throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public NamingEnumeration<NameClassPair> list(String name)
+ throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public NamingEnumeration<Binding> listBindings(Name name)
+ throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public NamingEnumeration<Binding> listBindings(String name)
+ throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object lookup(Name name) throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object lookup(String name) throws NamingException {
+ System.out.println("lookup " + name);
+ return null;
+ }
+
+ public Object lookupLink(Name name) throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object lookupLink(String name) throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void rebind(Name name, Object obj) throws NamingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void rebind(String name, Object obj) throws NamingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Object removeFromEnvironment(String propName) throws NamingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void rename(Name oldName, Name newName) throws NamingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void rename(String oldName, String newName) throws NamingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void unbind(Name name) throws NamingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void unbind(String name) throws NamingException {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+
}