Fix: IOrderedLayout now handles component additions in between old components with captions (previously the insertion index was calculated wrong because of the caption elements were included in the index).
Small fixes to TestBench.
svn changeset:4107/svn branch:trunk
initializeClientHooks();
- // TODO remove hardcoded id name
+ // TODO remove hard coded id name
view = new IView("itmill-ajax-window");
makeUidlRequest("repaintAll=1");
* @return translated URI ready for browser
*/
public String translateToolkitUri(String toolkitUri) {
+ if (toolkitUri == null) {
+ return null;
+ }
if (toolkitUri.startsWith("theme://")) {
final String themeUri = getThemeUri();
if (themeUri == null) {
* @return
*/
private String getSrc(UIDL uidl, ApplicationConnection client) {
- return client.translateToolkitUri(uidl.getStringAttribute("src"));
+ String url = client.translateToolkitUri(uidl.getStringAttribute("src"));
+ if (url == null) {
+ return "";
+ }
+ return url;
}
public void setWidth(String width) {
// TODO this might be optimized by moving only container element
// to correct position
removeCaption(child);
- int index = getWidgetIndex(oldChild);
+ int index = getPaintableIndex(oldChild);
if (componentToCaption.containsKey(oldChild)) {
index--;
}
this.insert(child, index);
} else {
// insert new child before old one
- final int index = getWidgetIndex(oldChild);
+ final int index = getPaintableIndex(oldChild); // TODO this returns wrong value if captions are used
insert(child, index);
}
((Paintable) child).updateFromUIDL(childUidl, client);
remove(c);
componentToCaption.remove(c);
}
- final int index = getWidgetIndex(from);
+ final int index = getPaintableIndex(from);
if (index >= 0) {
remove(index);
insert(to, index);
}
public boolean hasChildComponent(Widget component) {
- return getWidgetIndex(component) >= 0;
+ return getPaintableIndex(component) >= 0;
}
public void updateCaption(Paintable component, UIDL uidl) {
if (Caption.isNeeded(uidl)) {
if (c == null) {
- final int index = getWidgetIndex((Widget) component);
+ final int index = getPaintableIndex((Widget) component);
c = new Caption(component, client);
insert(c, index);
componentToCaption.put(component, c);
return getChildren().indexOf(child);
}
+ public int getPaintableCount() {
+ int size = 0;
+ for(Iterator it = getChildren().iterator(); it.hasNext();) {
+ Widget w = (Widget) it.next();
+ if (!(w instanceof Caption)) {
+ size++;
+ }
+ }
+ return size;
+ }
+
+ public int getPaintableIndex(Widget child) {
+ int i = 0;
+ for(Iterator it = getChildren().iterator(); it.hasNext();) {
+ Widget w = (Widget) it.next();
+ if (w == child) {
+ return i;
+ } else if (!(w instanceof Caption)) {
+ i++;
+ }
+ }
+ return -1;
+ }
+
protected void handleMargins(UIDL uidl) {
final MarginInfo margins = new MarginInfo(uidl
.getIntAttribute("margins"));
String[] testablePackages = { "com.itmill.toolkit.tests",
"com.itmill.toolkit.demo", "com.itmill.toolkit.demo.colorpicker",
"com.itmill.toolkit.demo.reservation",
- "com.itmill.toolkit.demo.features" };
+ "com.itmill.toolkit.demo.features",
+ "com.itmill.toolkit.tests.tickets"};
HierarchicalContainer testables = new HierarchicalContainer();
testables.addItem(t);
itemCaptions.put(t, t.getName());
testables.setParent(t, testablePackages[p]);
+ testables.setChildrenAllowed(t, false);
continue;
} catch (final Exception e) {
try {
testables.addItem(t);
itemCaptions.put(t, t.getName());
testables.setParent(t, testablePackages[p]);
+ testables.setChildrenAllowed(t, false);
continue;
} catch (final Exception e1) {
e1.printStackTrace();
Property.ValueChangeListener {
// Add here packages which are used for finding testable classes
- String[] testablePackages = { "com.itmill.toolkit.demo.testbench" };
+ String[] testablePackages = { "com.itmill.toolkit.demo.testbench", "com.itmill.toolkit.tests.tickets" };
HierarchicalContainer testables = new HierarchicalContainer();
testables.addItem(t);
itemCaptions.put(t, t.getName());
testables.setParent(t, testablePackages[p]);
+ testables.setChildrenAllowed(t, false);
continue;
} catch (final Exception e) {
try {
testables.addItem(t);
itemCaptions.put(t, t.getName());
testables.setParent(t, testablePackages[p]);
+ testables.setChildrenAllowed(t, false);
continue;
} catch (final Exception e1) {
e1.printStackTrace();