Sfoglia il codice sorgente

Fixed some component visibility bugs

svn changeset:1736/svn branch:trunk
tags/6.7.0.beta1
Joonas Lehtinen 17 anni fa
parent
commit
e79923f789

+ 1
- 0
src/com/itmill/toolkit/terminal/gwt/client/CaptionWrapper.java Vedi File

else else
caption.setText(c); caption.setText(c);
} }
setVisible(!uidl.getBooleanAttribute("invisible"));
} }
public static boolean isNeeded(UIDL uidl) { public static boolean isNeeded(UIDL uidl) {

+ 48
- 17
src/com/itmill/toolkit/terminal/gwt/client/Client.java Vedi File

import com.google.gwt.json.client.JSONObject; import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONParser; import com.google.gwt.json.client.JSONParser;
import com.google.gwt.json.client.JSONValue; import com.google.gwt.json.client.JSONValue;
import com.google.gwt.user.client.ui.FocusWidget;
import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
import com.itmill.toolkit.terminal.gwt.client.ui.IButton; import com.itmill.toolkit.terminal.gwt.client.ui.IButton;
} }


/** /**
* Ensure that correct implementation is used for the component.
* Update generic component features.
* *
* <h2>Selecting correct implementation</h2>
*
* <p>
* The implementation of a component depends on many properties, including * The implementation of a component depends on many properties, including
* styles, component features, etc. Sometimes the user changes those * styles, component features, etc. Sometimes the user changes those
* properties after the component has been created. Calling this method in * properties after the component has been created. Calling this method in
* the beginning of your updateFromUIDL -method automatically replaces your * the beginning of your updateFromUIDL -method automatically replaces your
* component with more appropriate if the requested implementation changes. * component with more appropriate if the requested implementation changes.
* </p>
*
* <h2>Caption, icon, error messages and description</h2>
*
* <p>
* Component can delegate management of caption, icon, error messages and
* description to parent layout. This is optional an should be decided by
* component author
* </p>
*
* <h2>Component visibility and disabling</h2>
*
* This method will manage component visibility automatically and if
* component is an instanceof FocusWidget, also handle component disabling
* when needed.
* *
* @param currentWidget * @param currentWidget
* Current widget that might need replacement * Current widget that might need replacement
* @param uidl * @param uidl
* UIDL to be painted * UIDL to be painted
* @return Returns true
* @param manageCaption
* True if you want to delegate caption, icon, description and
* error message management to parent.
*
* @return Returns true iff no further painting is needed by caller
*/ */
public boolean updateComponent(Widget component, UIDL uidl, public boolean updateComponent(Widget component, UIDL uidl,
boolean manageCaption) { boolean manageCaption) {


// Switch to correct implementation if neede
if (!widgetFactory.isCorrectImplementation(component, uidl)) {
Layout parent = getParentLayout(component);
if (parent != null) {
Widget w = widgetFactory.createWidget(uidl);
registerPaintable(uidl.getId(), (Paintable) w);
parent.replaceChildComponent(component, w);
((Paintable) w).updateFromUIDL(uidl, this);
return true;
}
}

// Set captions
// TODO Manage Error messages
if (manageCaption) { if (manageCaption) {
Layout parent = getParentLayout(component); Layout parent = getParentLayout(component);
if (parent != null) if (parent != null)
parent.updateCaption(component, uidl); parent.updateCaption(component, uidl);
} }

// Visibility, Disabling and read-only status
if (component instanceof FocusWidget)
((FocusWidget) component).setEnabled(!uidl
.getBooleanAttribute("disabled"));
boolean visible = !uidl.getBooleanAttribute("invisible"); boolean visible = !uidl.getBooleanAttribute("invisible");
component.setVisible(visible); component.setVisible(visible);
if (!visible) return true;
if (widgetFactory.isCorrectImplementation(component, uidl))
return false;
Layout parent = getParentLayout(component);
if (parent == null)
return false;
Widget w = widgetFactory.createWidget(uidl);
registerPaintable(uidl.getId(), (Paintable) w);
parent.replaceChildComponent(component, w);
((Paintable) w).updateFromUIDL(uidl, this);

return true;
}
if (!visible)
return true;


return false;
}


/** /**
* Get either existing or new widget for given UIDL. * Get either existing or new widget for given UIDL.

Loading…
Annulla
Salva