diff options
Diffstat (limited to 'src/com/vaadin')
-rw-r--r-- | src/com/vaadin/data/Container.java | 34 | ||||
-rw-r--r-- | src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java | 5 | ||||
-rw-r--r-- | src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java | 14 | ||||
-rw-r--r-- | src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java | 101 | ||||
-rw-r--r-- | src/com/vaadin/ui/AbstractComponent.java | 1 | ||||
-rw-r--r-- | src/com/vaadin/ui/AbstractSelect.java | 7 | ||||
-rw-r--r-- | src/com/vaadin/ui/Tree.java | 7 |
7 files changed, 132 insertions, 37 deletions
diff --git a/src/com/vaadin/data/Container.java b/src/com/vaadin/data/Container.java index 226a4e0b09..5777bf2b05 100644 --- a/src/com/vaadin/data/Container.java +++ b/src/com/vaadin/data/Container.java @@ -541,6 +541,24 @@ public interface Container extends Serializable { * <code>false</code> if not (is a leaf) */ public boolean hasChildren(Object itemId); + + /** + * <p> + * Removes the Item identified by <code>ItemId</code> from the + * Container. + * </p> + * + * <p> + * Note that this does not remove any children the item might have. + * </p> + * + * @param itemId + * ID of the Item to remove + * @return <code>true</code> if the operation succeeded, + * <code>false</code> if not + */ + public boolean removeItem(Object itemId) + throws UnsupportedOperationException; } /** @@ -555,17 +573,15 @@ public interface Container extends Serializable { * visible in the container. * * When an {@link com.vaadin.data.Ordered} or - * {@link com.vaadin.data.Indexed} container is filtered, all - * operations of these interfaces should only use the filtered contents and - * the filtered indices to the container. + * {@link com.vaadin.data.Indexed} container is filtered, all operations of + * these interfaces should only use the filtered contents and the filtered + * indices to the container. * - * Adding items (if supported) to a filtered - * {@link com.vaadin.data.Ordered} or - * {@link com.vaadin.data.Indexed} container should insert them + * Adding items (if supported) to a filtered {@link com.vaadin.data.Ordered} + * or {@link com.vaadin.data.Indexed} container should insert them * immediately after the indicated visible item. The unfiltered position of - * items added at index 0, at index - * {@link com.vaadin.data.Container#size()} or at an undefined - * position is up to the implementation. + * items added at index 0, at index {@link com.vaadin.data.Container#size()} + * or at an undefined position is up to the implementation. * * @since 5.0 */ diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java b/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java index 4700451543..4ea806e29e 100644 --- a/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java +++ b/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java @@ -158,9 +158,8 @@ public class ApplicationConfiguration { // Something went wrong: multiple widgetsets inited String msg = "Tried to init " + widgetset.getClass().getName() + ", but " + initedWidgetSet.getClass().getName() - + " is already inited."; - System.err.println(msg); - throw new IllegalStateException(msg); + + " was already inited."; + ApplicationConnection.getConsole().log(msg); } initedWidgetSet = widgetset; ArrayList<String> appIds = new ArrayList<String>(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java b/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java index 9cad1fbd91..4e17dcb879 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java @@ -787,7 +787,21 @@ public class VMenuBar extends Widget implements Paintable, paddingWidth = widthBefore - getElement().getClientWidth(); getElement().getStyle().setProperty("padding", ""); } + String overflow = ""; + if (BrowserInfo.get().isIE6()) { + // IE6 cannot measure available width correctly without + // overflow:hidden + overflow = getElement().getStyle().getProperty("overflow"); + getElement().getStyle().setProperty("overflow", "hidden"); + } + int availableWidth = getElement().getClientWidth() - paddingWidth; + + if (BrowserInfo.get().isIE6()) { + // IE6 cannot measure available width correctly without + // overflow:hidden + getElement().getStyle().setProperty("overflow", overflow); + } int diff = availableWidth - getConsumedWidth(); removeItem(moreItem); diff --git a/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java b/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java index e745282605..649a5e129d 100644 --- a/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java +++ b/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java @@ -4,9 +4,15 @@ package com.vaadin.terminal.gwt.server; +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.Serializable; import java.util.Collection; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; @@ -1000,25 +1006,37 @@ public class JsonPaintTarget implements PaintTarget { } } + private static final Map<Class<? extends Paintable>, Class<? extends Paintable>> widgetMappingCache = new HashMap<Class<? extends Paintable>, Class<? extends Paintable>>(); + @SuppressWarnings("unchecked") public String getTag(Paintable paintable) { - /* - * Client widget annotation is searched from component hierarchy to - * detect the component that presumably has client side implementation. - * The server side name is used in the transportation, but encoded into - * integer strings to optimized transferred data. - */ - Class<? extends Paintable> class1 = paintable.getClass(); - while (!hasClientWidgetMapping(class1)) { - Class<?> superclass = class1.getSuperclass(); - if (superclass != null - && Paintable.class.isAssignableFrom(superclass)) { - class1 = (Class<? extends Paintable>) superclass; - } else { - System.out - .append("Warning: no superclass of givent has ClientWidget" - + " annotation. Component will not be mapped correctly on client side."); - break; + Class<? extends Paintable> class1; + synchronized (widgetMappingCache) { + class1 = widgetMappingCache.get(paintable.getClass()); + } + if (class1 == null) { + /* + * Client widget annotation is searched from component hierarchy to + * detect the component that presumably has client side + * implementation. The server side name is used in the + * transportation, but encoded into integer strings to optimized + * transferred data. + */ + class1 = paintable.getClass(); + while (!hasClientWidgetMapping(class1)) { + Class<?> superclass = class1.getSuperclass(); + if (superclass != null + && Paintable.class.isAssignableFrom(superclass)) { + class1 = (Class<? extends Paintable>) superclass; + } else { + System.out + .append("Warning: no superclass of givent has ClientWidget" + + " annotation. Component will not be mapped correctly on client side."); + break; + } + } + synchronized (widgetMappingCache) { + widgetMappingCache.put(paintable.getClass(), class1); } } @@ -1029,15 +1047,58 @@ public class JsonPaintTarget implements PaintTarget { private boolean hasClientWidgetMapping(Class<? extends Paintable> class1) { try { - ClientWidget annotation = class1.getAnnotation(ClientWidget.class); - return annotation != null; + return class1.isAnnotationPresent(ClientWidget.class); } catch (RuntimeException e) { if (e.getStackTrace()[0].getClassName().equals( "org.glassfish.web.loader.WebappClassLoader")) { + // Glassfish 3 is darn eager to load the value class, even // though we just want to check if the annotation exists. // See #3920, remove this hack when fixed in glassfish - return true; + // In some situations (depending on class loading order) it + // would be enough to return true here, but it is safer to check + // the annotation from bytecode + + String name = class1.getName().replace('.', File.separatorChar) + + ".class"; + + try { + InputStream stream = class1.getClassLoader() + .getResourceAsStream(name); + BufferedReader bufferedReader = new BufferedReader( + new InputStreamReader(stream)); + try { + String line; + boolean atSourcefile = false; + while ((line = bufferedReader.readLine()) != null) { + if (line.startsWith("SourceFile")) { + atSourcefile = true; + } + if (atSourcefile) { + if (line.contains("ClientWidget")) { + return true; + } + } + // TODO could optize to quit at the end attribute + } + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } finally { + try { + bufferedReader.close(); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + + } catch (Throwable e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + + return false; } else { // throw exception forward throw e; diff --git a/src/com/vaadin/ui/AbstractComponent.java b/src/com/vaadin/ui/AbstractComponent.java index 4619c2ab8d..0c02792fff 100644 --- a/src/com/vaadin/ui/AbstractComponent.java +++ b/src/com/vaadin/ui/AbstractComponent.java @@ -315,6 +315,7 @@ public abstract class AbstractComponent implements Component, MethodEventSource */ public void setLocale(Locale locale) { this.locale = locale; + requestRepaint(); } /* diff --git a/src/com/vaadin/ui/AbstractSelect.java b/src/com/vaadin/ui/AbstractSelect.java index b8ef6bc206..4b5ef4a0a8 100644 --- a/src/com/vaadin/ui/AbstractSelect.java +++ b/src/com/vaadin/ui/AbstractSelect.java @@ -793,12 +793,9 @@ public abstract class AbstractSelect extends AbstractField implements return retval; } - /** - * Removes the item identified by Id from the container. This functionality - * is optional. If the function is not implemented, the functions allways - * returns false. + /* + * (non-Javadoc) * - * @return True if the operation succeeded. * @see com.vaadin.data.Container#removeItem(java.lang.Object) */ public boolean removeItem(Object itemId) diff --git a/src/com/vaadin/ui/Tree.java b/src/com/vaadin/ui/Tree.java index 509d83a153..28a410fa13 100644 --- a/src/com/vaadin/ui/Tree.java +++ b/src/com/vaadin/ui/Tree.java @@ -1068,4 +1068,11 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, public abstract String getStyle(Object itemId); } + // Overriden so javadoc comes from Container.Hierarchical + @Override + public boolean removeItem(Object itemId) + throws UnsupportedOperationException { + return super.removeItem(itemId); + } + } |