aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheetBase.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheetBase.java')
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheetBase.java110
1 files changed, 34 insertions, 76 deletions
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheetBase.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheetBase.java
index 05a77cfaf2..65e1a1f07e 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheetBase.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheetBase.java
@@ -9,16 +9,16 @@ import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.Widget;
import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
+import com.itmill.toolkit.terminal.gwt.client.Container;
import com.itmill.toolkit.terminal.gwt.client.Paintable;
import com.itmill.toolkit.terminal.gwt.client.UIDL;
-abstract class ITabsheetBase extends ComplexPanel implements Paintable {
+abstract class ITabsheetBase extends ComplexPanel implements Container {
String id;
ApplicationConnection client;
protected final ArrayList tabKeys = new ArrayList();
- protected final ArrayList captions = new ArrayList();
protected int activeTabIndex = 0;
protected boolean disabled;
protected boolean readonly;
@@ -43,73 +43,46 @@ abstract class ITabsheetBase extends ComplexPanel implements Paintable {
// Render content
final UIDL tabs = uidl.getChildUIDL(0);
- if (keepCurrentTabs(uidl)) {
- int index = 0;
- for (final Iterator it = tabs.getChildIterator(); it.hasNext();) {
- final UIDL tab = (UIDL) it.next();
- final boolean selected = tab.getBooleanAttribute("selected");
- if (selected) {
- selectTab(index, tab.getChildUIDL(0));
- } else if (tab.getChildCount() > 0) {
- // updating a drawn child on hidden tab
- Paintable paintable = client.getPaintable(tab
- .getChildUIDL(0));
- // TODO widget may flash on screen
- paintable.updateFromUIDL(tab.getChildUIDL(0), client);
- // Hack #1 in ITabsheetBase: due ITabsheets content has no
- // wrappers for each tab, we need to hide the actual widgets
- ((Widget) paintable).setVisible(false);
- }
- index++;
- }
- } else {
+ ArrayList oldPaintables = new ArrayList();
+ for (Iterator iterator = getPaintableIterator(); iterator.hasNext();) {
+ oldPaintables.add(iterator.next());
+ }
- ArrayList oldPaintables = new ArrayList();
- for (Iterator iterator = getPaintableIterator(); iterator.hasNext();) {
- oldPaintables.add(iterator.next());
- }
+ // Clear previous values
+ tabKeys.clear();
+ disabledTabKeys.clear();
- // Clear previous values
- tabKeys.clear();
- captions.clear();
- disabledTabKeys.clear();
-
- clearPaintables();
-
- int index = 0;
- for (final Iterator it = tabs.getChildIterator(); it.hasNext();) {
- final UIDL tab = (UIDL) it.next();
- final String key = tab.getStringAttribute("key");
- final boolean selected = tab.getBooleanAttribute("selected");
- String caption = tab.getStringAttribute("caption");
- if (caption == null) {
- caption = " ";
- }
+ int index = 0;
+ for (final Iterator it = tabs.getChildIterator(); it.hasNext();) {
+ final UIDL tab = (UIDL) it.next();
+ final String key = tab.getStringAttribute("key");
+ final boolean selected = tab.getBooleanAttribute("selected");
- if (tab.getBooleanAttribute("disabled")) {
- disabledTabKeys.add(key);
- }
+ if (tab.getBooleanAttribute("disabled")) {
+ disabledTabKeys.add(key);
+ }
- captions.add(caption);
- tabKeys.add(key);
+ tabKeys.add(key);
- if (selected) {
- activeTabIndex = index;
- }
- if (tab.getChildCount() > 0) {
- Paintable p = client.getPaintable(tab.getChildUIDL(0));
- oldPaintables.remove(p);
- }
- renderTab(tab, index, selected);
- index++;
+ if (selected) {
+ activeTabIndex = index;
+ }
+ if (tab.getChildCount() > 0) {
+ Paintable p = client.getPaintable(tab.getChildUIDL(0));
+ oldPaintables.remove(p);
}
+ renderTab(tab, index, selected);
+ index++;
+ }
- for (Iterator iterator = oldPaintables.iterator(); iterator
- .hasNext();) {
- Object oldPaintable = iterator.next();
- if (oldPaintable instanceof Paintable) {
- client.unregisterPaintable((Paintable) oldPaintable);
+ for (Iterator iterator = oldPaintables.iterator(); iterator.hasNext();) {
+ Object oldPaintable = iterator.next();
+ if (oldPaintable instanceof Paintable) {
+ Widget w = (Widget) oldPaintable;
+ if (w.isAttached()) {
+ w.removeFromParent();
}
+ client.unregisterPaintable((Paintable) oldPaintable);
}
}
@@ -125,21 +98,6 @@ abstract class ITabsheetBase extends ComplexPanel implements Paintable {
*/
abstract protected void clearPaintables();
- protected boolean keepCurrentTabs(UIDL uidl) {
- final UIDL tabs = uidl.getChildUIDL(0);
- boolean retval = tabKeys.size() == tabs.getNumberOfChildren();
- for (int i = 0; retval && i < tabKeys.size(); i++) {
- String key = (String) tabKeys.get(i);
- UIDL tabUIDL = tabs.getChildUIDL(i);
- retval = key.equals(tabUIDL.getStringAttribute("key"))
- && captions.get(i).equals(
- tabUIDL.getStringAttribute("caption"))
- && (tabUIDL.hasAttribute("disabled") == disabledTabKeys
- .contains(key));
- }
- return retval;
- }
-
/**
* Implement in extending classes. This method should render needed elements
* and set the visibility of the tab according to the 'selected' parameter.