implements Indexed, Sortable, Filterable,
return beanItem;
}
-
/**
* Adds the bean to all internal data structures at the given position.
* Fails if the bean is already in the container or is not assignable to the
- * correct type. Returns the new BeanItem if the bean was added successfully.
+ * correct type. Returns the new BeanItem if the bean was added
+ * successfully.
*
*
* Caller should call {@link #filterAll()} after calling this method to
@@ -225,6 +225,7 @@ public class BeanItemContainer implements Indexed, Sortable, Filterable,
return beanItem;
}
+
@SuppressWarnings("unchecked")
public BT getIdByIndex(int index) {
return filteredItems.get(index);
--
cgit v1.2.3
From b4a62c4b8f69cd8f1c15d5983821b51ebc428235 Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Tue, 2 Mar 2010 13:57:28 +0000
Subject: ListSet implementation for #4106 - BeanItemContainer slow in some
instances
svn changeset:11593/svn branch:6.3
---
src/com/vaadin/data/util/ListSet.java | 198 ++++++++++++++++++++++++++++++++++
1 file changed, 198 insertions(+)
create mode 100644 src/com/vaadin/data/util/ListSet.java
(limited to 'src/com')
diff --git a/src/com/vaadin/data/util/ListSet.java b/src/com/vaadin/data/util/ListSet.java
new file mode 100644
index 0000000000..8dc8c6bbfd
--- /dev/null
+++ b/src/com/vaadin/data/util/ListSet.java
@@ -0,0 +1,198 @@
+package com.vaadin.data.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+
+/**
+ * ListSet is an internal Vaadin class which implements a combination of a List
+ * and a Set. The main purpose of this class is to provide a fast
+ * {@link #contains(Object)} method. Each inserted object must by unique (as
+ * specified by {@link #equals(Object)}).
+ *
+ * This class is subject to change and should not be used outside Vaadin core.
+ */
+public class ListSet extends ArrayList {
+ private HashSet itemSet = null;
+
+ public ListSet() {
+ super();
+ itemSet = new HashSet();
+ }
+
+ public ListSet(Collection extends E> c) {
+ super(c);
+ itemSet = new HashSet(c.size());
+ itemSet.addAll(c);
+ }
+
+ public ListSet(int initialCapacity) {
+ super(initialCapacity);
+ itemSet = new HashSet(initialCapacity);
+ }
+
+ // Delegate contains operations to the set
+ @Override
+ public boolean contains(Object o) {
+ return itemSet.contains(o);
+ }
+
+ @Override
+ public boolean containsAll(Collection> c) {
+ return itemSet.containsAll(c);
+ }
+
+ // Methods for updating the set when the list is updated.
+ @Override
+ public boolean add(E e) {
+ if (contains(e)) {
+ // Duplicates are not allowed
+ return false;
+ }
+
+ if (super.add(e)) {
+ itemSet.add(e);
+ return true;
+ } else {
+ return false;
+ }
+ };
+
+ /**
+ * Works as java.util.ArrayList#add(int, java.lang.Object) but returns
+ * immediately if the element is already in the ListSet.
+ */
+ @Override
+ public void add(int index, E element) {
+ if (contains(element)) {
+ // Duplicates are not allowed
+ return;
+ }
+
+ super.add(index, element);
+ itemSet.add(element);
+ }
+
+ @Override
+ public boolean addAll(Collection extends E> c) {
+ boolean modified = false;
+ Iterator extends E> i = c.iterator();
+ while (i.hasNext()) {
+ E e = i.next();
+ if (contains(e)) {
+ continue;
+ }
+
+ if (add(e)) {
+ itemSet.add(e);
+ modified = true;
+ }
+ }
+ return modified;
+ }
+
+ @Override
+ public boolean addAll(int index, Collection extends E> c) {
+ ensureCapacity(size() + c.size());
+
+ boolean modified = false;
+ Iterator extends E> i = c.iterator();
+ while (i.hasNext()) {
+ E e = i.next();
+ if (contains(e)) {
+ continue;
+ }
+
+ add(index++, e);
+ itemSet.add(e);
+ modified = true;
+ }
+
+ return modified;
+ }
+
+ @Override
+ public void clear() {
+ super.clear();
+ itemSet.clear();
+ }
+
+ @Override
+ public int indexOf(Object o) {
+ if (!contains(o)) {
+ return -1;
+ }
+
+ return super.indexOf(o);
+ }
+
+ @Override
+ public int lastIndexOf(Object o) {
+ if (!contains(o)) {
+ return -1;
+ }
+
+ return super.lastIndexOf(o);
+ }
+
+ @Override
+ public E remove(int index) {
+ E e = super.remove(index);
+
+ if (e != null) {
+ itemSet.remove(e);
+ }
+
+ return e;
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ if (super.remove(o)) {
+ itemSet.remove(o);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ protected void removeRange(int fromIndex, int toIndex) {
+ HashSet toRemove = new HashSet();
+ for (int idx = fromIndex; idx < toIndex; idx++) {
+ toRemove.add(get(idx));
+ }
+ super.removeRange(fromIndex, toIndex);
+ itemSet.removeAll(toRemove);
+ }
+
+ @Override
+ public E set(int index, E element) {
+ if (contains(element)) {
+ // Element already exist in the list
+ if (get(index) == element) {
+ // At the same position, nothing to be done
+ return element;
+ } else {
+ // At another position, cannot set
+ return null;
+ }
+ }
+
+ E old = super.set(index, element);
+ itemSet.remove(old);
+ itemSet.add(element);
+
+ return old;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Object clone() {
+ ListSet v = (ListSet) super.clone();
+ v.itemSet = new HashSet(itemSet);
+ return v;
+ }
+
+}
--
cgit v1.2.3
From d959c77523f807aed1f7ed4920d5f584c0f8f831 Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Tue, 2 Mar 2010 14:09:19 +0000
Subject: Corrected copy/paste error
svn changeset:11594/svn branch:6.3
---
src/com/vaadin/Application.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
(limited to 'src/com')
diff --git a/src/com/vaadin/Application.java b/src/com/vaadin/Application.java
index 0d6c5721d9..463d234489 100644
--- a/src/com/vaadin/Application.java
+++ b/src/com/vaadin/Application.java
@@ -1304,9 +1304,9 @@ public abstract class Application implements URIHandler,
* with the server.
* Take note of any unsaved data, and click here to re-sync."
* cookiesDisabledURL = null
- * outOfSyncNotificationEnabled = true
- * outOfSyncCaption = "Cookies disabled"
- * outOfSyncMessage = "This application requires cookies to
+ * cookiesDisabledNotificationEnabled = true
+ * cookiesDisabledCaption = "Cookies disabled"
+ * cookiesDisabledMessage = "This application requires cookies to
* function.
* Please enable cookies in your browser and click here to try again.
*
--
cgit v1.2.3
From c85c13acce3f6ca09c58337b94c3bb72600ea181 Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Tue, 2 Mar 2010 20:06:23 +0000
Subject: Added javadoc explaning that how Container.Filterable and
Container.Hierarchical work together is implementation dependent
svn changeset:11597/svn branch:6.3
---
src/com/vaadin/data/Container.java | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
(limited to 'src/com')
diff --git a/src/com/vaadin/data/Container.java b/src/com/vaadin/data/Container.java
index 5777bf2b05..6dbcfe779f 100644
--- a/src/com/vaadin/data/Container.java
+++ b/src/com/vaadin/data/Container.java
@@ -562,26 +562,34 @@ public interface Container extends Serializable {
}
/**
- * Interface is implemented by containers that allow reducing their visible
- * contents with set of filters.
- *
+ * Interface that is implemented by containers which allow reducing their
+ * visible contents based on a set of filters.
+ *
* When a set of filters are set, only items that match the filters are
* included in the visible contents of the container. Still new items that
* do not match filters can be added to the container. Multiple filters can
* be added and the container remembers the state of the filters. When
* multiple filters are added, all filters must match for an item to be
* 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.
- *
+ *
+ *
+ * How filtering is performed when a {@link Hierarchical} container
+ * implements {@link Filterable} is implementation specific and should be
+ * documented in the implementing class.
+ *
+ *
* 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.
+ *
*
* @since 5.0
*/
--
cgit v1.2.3
From ae106c9b5e64a8ea88965ca850eef78c3e6d109b Mon Sep 17 00:00:00 2001
From: Jouni Koivuviita
Date: Wed, 3 Mar 2010 11:05:31 +0000
Subject: Fixes #3736 "Split up style and type definitions" and #3467 "Button
styles missing?" * Now all built-in themes have an accompanying class file
that describes all provided style names. * Deprecated Button.STYLE_LINK in
favor of BaseTheme.BUTTON_LINK * Deprecated Panel.STYLE_LIGHT in favor of
Reindeer.PANEL_LIGHT and Runo.PANEL_LIGHT
svn changeset:11601/svn branch:6.3
---
src/com/vaadin/ui/Button.java | 8 +-
src/com/vaadin/ui/Panel.java | 12 +++
src/com/vaadin/ui/themes/BaseTheme.java | 44 +++++++++
src/com/vaadin/ui/themes/Reindeer.java | 163 ++++++++++++++++++++++++++++++++
src/com/vaadin/ui/themes/Runo.java | 30 ++++++
5 files changed, 256 insertions(+), 1 deletion(-)
create mode 100644 src/com/vaadin/ui/themes/BaseTheme.java
create mode 100644 src/com/vaadin/ui/themes/Reindeer.java
create mode 100644 src/com/vaadin/ui/themes/Runo.java
(limited to 'src/com')
diff --git a/src/com/vaadin/ui/Button.java b/src/com/vaadin/ui/Button.java
index 3ed50b2d42..65a34a18bb 100644
--- a/src/com/vaadin/ui/Button.java
+++ b/src/com/vaadin/ui/Button.java
@@ -13,6 +13,7 @@ import com.vaadin.data.Property;
import com.vaadin.terminal.PaintException;
import com.vaadin.terminal.PaintTarget;
import com.vaadin.terminal.gwt.client.ui.VButton;
+import com.vaadin.ui.themes.BaseTheme;
/**
* A generic button component.
@@ -239,7 +240,12 @@ public class Button extends AbstractField {
private static final Method BUTTON_CLICK_METHOD;
- /* Button style with no decorations. Looks like a link, acts like a button */
+ /**
+ * Button style with no decorations. Looks like a link, acts like a button
+ *
+ * @deprecated use {@link BaseTheme#BUTTON_LINK} instead.
+ */
+ @Deprecated
public static final String STYLE_LINK = "link";
static {
diff --git a/src/com/vaadin/ui/Panel.java b/src/com/vaadin/ui/Panel.java
index df08c4e62b..f4ce352687 100644
--- a/src/com/vaadin/ui/Panel.java
+++ b/src/com/vaadin/ui/Panel.java
@@ -19,6 +19,8 @@ import com.vaadin.terminal.PaintTarget;
import com.vaadin.terminal.Scrollable;
import com.vaadin.terminal.gwt.client.MouseEventDetails;
import com.vaadin.terminal.gwt.client.ui.VPanel;
+import com.vaadin.ui.themes.Reindeer;
+import com.vaadin.ui.themes.Runo;
/**
* Panel - a simple single component container.
@@ -36,6 +38,16 @@ public class Panel extends AbstractComponentContainer implements Scrollable,
private static final String CLICK_EVENT = VPanel.CLICK_EVENT_IDENTIFIER;
+ /**
+ * Removes extra decorations from the Panel.
+ *
+ * @deprecated this style is no longer part of the core framework and this
+ * component, even though most built-in themes implement this
+ * style. Use the constant specified in the theme class file
+ * that you're using, if it provides one, e.g.
+ * {@link Reindeer#PANEL_LIGHT} or {@link Runo#PANEL_LIGHT} .
+ */
+ @Deprecated
public static final String STYLE_LIGHT = "light";
/**
diff --git a/src/com/vaadin/ui/themes/BaseTheme.java b/src/com/vaadin/ui/themes/BaseTheme.java
new file mode 100644
index 0000000000..48083f5240
--- /dev/null
+++ b/src/com/vaadin/ui/themes/BaseTheme.java
@@ -0,0 +1,44 @@
+package com.vaadin.ui.themes;
+
+/**
+ *
+ * The Base theme is the foundation for all Vaadin themes. Although it is not
+ * necessary to use it as the starting point for all other themes, it is heavily
+ * encouraged, since it abstracts and hides away many necessary style properties
+ * that the Vaadin terminal expects and needs.
+ *
+ *
+ * When creating your own theme, either extend this class and specify the styles
+ * implemented in your theme here, or extend some other theme that has a class
+ * file specified (e.g. Reindeer or Runo).
+ *
+ *
+ * All theme class files should follow the convention of specifying the theme
+ * name as a string constant THEME_NAME
.
+ *
+ * @since 6.3.0
+ *
+ */
+public class BaseTheme {
+
+ public static final String THEME_NAME = "Base";
+
+ /**
+ * Creates a button that looks like a regular hypertext link but still acts
+ * like a normal button.
+ */
+ public static final String BUTTON_LINK = "link";
+
+ /**
+ * Removes extra decorations from the panel.
+ *
+ * @deprecated Base theme does not implement this style, but it is defined
+ * here since it has been a part of the framework before
+ * multiple themes were available. Use the constant provided by
+ * the theme you're using instead, e.g.
+ * {@link Reindeer#PANEL_LIGHT} or {@link Runo#PANEL_LIGHT}.
+ */
+ @Deprecated
+ public static final String PANEL_LIGHT = "light";
+
+}
\ No newline at end of file
diff --git a/src/com/vaadin/ui/themes/Reindeer.java b/src/com/vaadin/ui/themes/Reindeer.java
new file mode 100644
index 0000000000..acbf003151
--- /dev/null
+++ b/src/com/vaadin/ui/themes/Reindeer.java
@@ -0,0 +1,163 @@
+package com.vaadin.ui.themes;
+
+import com.vaadin.ui.CssLayout;
+import com.vaadin.ui.FormLayout;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.VerticalLayout;
+
+public class Reindeer extends BaseTheme {
+
+ public static final String THEME_NAME = "Reindeer";
+
+ /***************************************************************************
+ *
+ * Label styles
+ *
+ **************************************************************************/
+
+ /**
+ * Large font for main application headings
+ */
+ public static final String LABEL_H1 = "h1";
+
+ /**
+ * Large font for different sections in the application
+ */
+ public static final String LABEL_H2 = "h2";
+
+ /**
+ * Small and a little lighter font
+ */
+ public static final String LABEL_SMALL = "light";
+
+ /***************************************************************************
+ *
+ * Button styles
+ *
+ **************************************************************************/
+
+ /**
+ * Default action style for buttons (the button that gets activated when
+ * user presses 'enter' in a form). Use sparingly, only one default button
+ * per screen should be visible.
+ */
+ public static final String BUTTON_DEFAULT = "primary";
+
+ /**
+ * Small sized button, use for context specific actions for example
+ */
+ public static final String BUTTON_SMALL = "small";
+
+ /***************************************************************************
+ *
+ * TextField styles
+ *
+ **************************************************************************/
+
+ /**
+ * Small sized text field with small font
+ */
+ public static final String TEXTFIELD_SMALL = "small";
+
+ /***************************************************************************
+ *
+ * Panel styles
+ *
+ **************************************************************************/
+
+ /**
+ * Removes borders and background color from the panel
+ */
+ public static final String PANEL_LIGHT = "light";
+
+ /***************************************************************************
+ *
+ * SplitPanel styles
+ *
+ **************************************************************************/
+
+ /**
+ * Reduces the split handle to a minimal size (1 pixel)
+ */
+ public static final String SPLITPANEL_SMALL = "small";
+
+ /***************************************************************************
+ *
+ * TabSheet styles
+ *
+ **************************************************************************/
+
+ /**
+ * Removes borders and background color from the tab sheet, and shows the
+ * tabs as a small bar.
+ */
+ public static final String TABSHEET_BAR = "bar";
+
+ /**
+ * Removes borders and background color from the tab sheet. The tabs are
+ * presented with minimal lines indicating the selected tab.
+ */
+ public static final String TABSHEET_MINIMAL = "minimal";
+
+ /***************************************************************************
+ *
+ * Table styles
+ *
+ **************************************************************************/
+
+ /**
+ * Removes borders from the table
+ */
+ public static final String TABLE_BORDERLESS = "borderless";
+
+ /**
+ * Makes the table headers dark and more prominent.
+ */
+ public static final String TABLE_STRONG = "strong";
+
+ /***************************************************************************
+ *
+ * Layout styles
+ *
+ **************************************************************************/
+
+ /**
+ * Changes the background of a layout to a shade of blue. Applies to
+ * {@link VerticalLayout}, {@link HorizontalLayout}, {@link GridLayout},
+ * {@link FormLayout} and {@link CssLayout}.
+ */
+ public static final String LAYOUT_BLUE = "blue";
+
+ /**
+ *
+ * Changes the background of a layout to almost black, and at the same time
+ * transforms contained components to their black style correspondents when
+ * available. At least texts, buttons, text fields, selects, date fields,
+ * tables and a few other component styles should change.
+ *
+ *
+ * Applies to {@link VerticalLayout}, {@link HorizontalLayout},
+ * {@link GridLayout}, {@link FormLayout} and {@link CssLayout}.
+ *
+ *
+ */
+ public static final String LAYOUT_BLACK = "black";
+
+ /***************************************************************************
+ *
+ * Window styles
+ *
+ **************************************************************************/
+
+ /**
+ * Makes the whole window white and increases the font size of the title.
+ */
+ public static final String WINDOW_LIGHT = "light";
+
+ /**
+ * Makes the whole window black, and changes contained components in the
+ * same way as {@link #LAYOUT_BLACK} does.
+ */
+ public static final String WINDOW_BLACK = "black";
+}
diff --git a/src/com/vaadin/ui/themes/Runo.java b/src/com/vaadin/ui/themes/Runo.java
new file mode 100644
index 0000000000..4df6046756
--- /dev/null
+++ b/src/com/vaadin/ui/themes/Runo.java
@@ -0,0 +1,30 @@
+package com.vaadin.ui.themes;
+
+
+public class Runo extends BaseTheme {
+
+ public static final String THEME_NAME = "Runo";
+
+ /***************************************************************************
+ *
+ * Button styles
+ *
+ **************************************************************************/
+
+ /**
+ * Small sized button, use for context specific actions for example
+ */
+ public static final String BUTTON_SMALL = "small";
+
+ /***************************************************************************
+ *
+ * Panel styles
+ *
+ **************************************************************************/
+
+ /**
+ * Removes borders and background color from the panel
+ */
+ public static final String PANEL_LIGHT = "light";
+
+}
--
cgit v1.2.3
From d70fbb818d408555ebadb8d5d06a9529298177fd Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Thu, 4 Mar 2010 09:28:03 +0000
Subject: Fixed typos in [11570] (#4129 Show a message if cookie support is
disabled in the browser)
svn changeset:11629/svn branch:6.3
---
src/com/vaadin/Application.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'src/com')
diff --git a/src/com/vaadin/Application.java b/src/com/vaadin/Application.java
index 463d234489..9a0c180a1d 100644
--- a/src/com/vaadin/Application.java
+++ b/src/com/vaadin/Application.java
@@ -1778,7 +1778,7 @@ public abstract class Application implements URIHandler,
* @param cookiesDisabledCaption
* the caption for the "cookies disabled" notification
*/
- public void setCookiesDisableCaption(String cookiesDisabledCaption) {
+ public void setCookiesDisabledCaption(String cookiesDisabledCaption) {
this.cookiesDisabledCaption = cookiesDisabledCaption;
}
@@ -1790,7 +1790,7 @@ public abstract class Application implements URIHandler,
* @param cookiesDisabledMessage
* the message for the "cookies disabled" notification
*/
- public void setCookiesDisableMessage(String cookiesDisabledMessage) {
+ public void setCookiesDisabledMessage(String cookiesDisabledMessage) {
this.cookiesDisabledMessage = cookiesDisabledMessage;
}
--
cgit v1.2.3
From 2559e674bce8306b3d9919f4e38fecd2e58b7b96 Mon Sep 17 00:00:00 2001
From: Henri Sara
Date: Thu, 4 Mar 2010 14:48:28 +0000
Subject: #4188 PortletListener window parameter and #3921 limited GateIn
support
svn changeset:11646/svn branch:6.3
---
.../gwt/server/AbstractApplicationPortlet.java | 48 +++++++++++-----
.../gwt/server/AbstractApplicationServlet.java | 5 +-
.../gwt/server/AbstractCommunicationManager.java | 66 +++++++++++-----------
.../terminal/gwt/server/CommunicationManager.java | 12 +++-
.../gwt/server/PortletApplicationContext2.java | 26 ++++-----
.../gwt/server/PortletCommunicationManager.java | 48 +++++++++++++++-
6 files changed, 136 insertions(+), 69 deletions(-)
(limited to 'src/com')
diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java
index 522293c00b..5c0e40b38b 100644
--- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java
+++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java
@@ -321,8 +321,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
final PrintWriter outWriter = new PrintWriter(new BufferedWriter(
new OutputStreamWriter(out, "UTF-8")));
outWriter.print("dummy page");
- outWriter.flush();
- out.close();
+ outWriter.close();
} else if (requestType == RequestType.STATIC_FILE) {
serveStaticResources((ResourceRequest) request,
(ResourceResponse) response);
@@ -390,20 +389,43 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
/* Notify listeners */
+ // Finds the window within the application
+ Window window = null;
+ synchronized (application) {
+ if (application.isRunning()) {
+ switch (requestType) {
+ case FILE_UPLOAD:
+ // no window
+ break;
+ case APPLICATION_RESOURCE:
+ // use main window - should not need any window
+ window = application.getMainWindow();
+ break;
+ default:
+ window = applicationManager.getApplicationWindow(
+ request, this, application, null);
+ }
+ // if window not found, not a problem - use null
+ }
+ }
+
// TODO Should this happen before or after the transaction
// starts?
if (request instanceof RenderRequest) {
applicationContext.firePortletRenderRequest(application,
- (RenderRequest) request, (RenderResponse) response);
+ window, (RenderRequest) request,
+ (RenderResponse) response);
} else if (request instanceof ActionRequest) {
applicationContext.firePortletActionRequest(application,
- (ActionRequest) request, (ActionResponse) response);
+ window, (ActionRequest) request,
+ (ActionResponse) response);
} else if (request instanceof EventRequest) {
applicationContext.firePortletEventRequest(application,
- (EventRequest) request, (EventResponse) response);
+ window, (EventRequest) request,
+ (EventResponse) response);
} else if (request instanceof ResourceRequest) {
applicationContext.firePortletResourceRequest(application,
- (ResourceRequest) request,
+ window, (ResourceRequest) request,
(ResourceResponse) response);
}
@@ -416,7 +438,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
// Handles AJAX UIDL requests
applicationManager.handleUidlRequest(
(ResourceRequest) request,
- (ResourceResponse) response, this);
+ (ResourceResponse) response, this, window);
return;
} else {
/*
@@ -428,7 +450,8 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
}
handleOtherRequest(request, response, requestType,
- application, applicationContext, applicationManager);
+ application, window, applicationContext,
+ applicationManager);
}
} catch (final SessionExpiredException e) {
// TODO Figure out a better way to deal with
@@ -485,14 +508,10 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
*/
private void handleOtherRequest(PortletRequest request,
PortletResponse response, RequestType requestType,
- Application application,
+ Application application, Window window,
PortletApplicationContext2 applicationContext,
PortletCommunicationManager applicationManager)
throws PortletException, IOException, MalformedURLException {
- /*
- * Always use the main window when running inside a portlet.
- */
- Window window = application.getMainWindow();
if (window == null) {
throw new PortletException(ERROR_NO_WINDOW_FOUND);
}
@@ -623,6 +642,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
while ((bytesRead = data.read(buffer)) > 0) {
out.write(buffer, 0, bytesRead);
+ // TODO this may cause problems on GateIn
out.flush();
}
out.close();
@@ -1360,9 +1380,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
+ "\"appError\": {" + "\"caption\":" + caption + ","
+ "\"message\" : " + message + "," + "\"url\" : " + url
+ "}}, \"resources\": {}, \"locales\":[]}]");
- outWriter.flush();
outWriter.close();
- out.flush();
}
/**
diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java
index 77e83838c5..8c901ba7e7 100644
--- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java
+++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java
@@ -438,7 +438,10 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements
return;
} else if (requestType == RequestType.UIDL) {
// Handles AJAX UIDL requests
- applicationManager.handleUidlRequest(request, response, this);
+ Window window = applicationManager.getApplicationWindow(
+ request, this, application, null);
+ applicationManager.handleUidlRequest(request, response, this,
+ window);
return;
}
diff --git a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
index 2bc10b4cc0..66b3eb30ca 100644
--- a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
+++ b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
@@ -4,32 +4,6 @@
package com.vaadin.terminal.gwt.server;
-import com.vaadin.Application;
-import com.vaadin.Application.SystemMessages;
-import com.vaadin.external.org.apache.commons.fileupload.FileItemIterator;
-import com.vaadin.external.org.apache.commons.fileupload.FileItemStream;
-import com.vaadin.external.org.apache.commons.fileupload.FileUpload;
-import com.vaadin.external.org.apache.commons.fileupload.FileUploadException;
-import com.vaadin.external.org.apache.commons.fileupload.ProgressListener;
-import com.vaadin.terminal.ApplicationResource;
-import com.vaadin.terminal.DownloadStream;
-import com.vaadin.terminal.PaintException;
-import com.vaadin.terminal.PaintTarget;
-import com.vaadin.terminal.Paintable;
-import com.vaadin.terminal.URIHandler;
-import com.vaadin.terminal.UploadStream;
-import com.vaadin.terminal.VariableOwner;
-import com.vaadin.terminal.Paintable.RepaintRequestEvent;
-import com.vaadin.terminal.Terminal.ErrorEvent;
-import com.vaadin.terminal.Terminal.ErrorListener;
-import com.vaadin.terminal.gwt.client.ApplicationConnection;
-import com.vaadin.terminal.gwt.server.ComponentSizeValidator.InvalidLayout;
-import com.vaadin.ui.AbstractField;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.Upload;
-import com.vaadin.ui.Window;
-import com.vaadin.ui.Upload.UploadException;
-
import java.io.BufferedWriter;
import java.io.CharArrayWriter;
import java.io.IOException;
@@ -66,6 +40,32 @@ import javax.portlet.PortletResponse;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
+import com.vaadin.Application;
+import com.vaadin.Application.SystemMessages;
+import com.vaadin.external.org.apache.commons.fileupload.FileItemIterator;
+import com.vaadin.external.org.apache.commons.fileupload.FileItemStream;
+import com.vaadin.external.org.apache.commons.fileupload.FileUpload;
+import com.vaadin.external.org.apache.commons.fileupload.FileUploadException;
+import com.vaadin.external.org.apache.commons.fileupload.ProgressListener;
+import com.vaadin.terminal.ApplicationResource;
+import com.vaadin.terminal.DownloadStream;
+import com.vaadin.terminal.PaintException;
+import com.vaadin.terminal.PaintTarget;
+import com.vaadin.terminal.Paintable;
+import com.vaadin.terminal.URIHandler;
+import com.vaadin.terminal.UploadStream;
+import com.vaadin.terminal.VariableOwner;
+import com.vaadin.terminal.Paintable.RepaintRequestEvent;
+import com.vaadin.terminal.Terminal.ErrorEvent;
+import com.vaadin.terminal.Terminal.ErrorListener;
+import com.vaadin.terminal.gwt.client.ApplicationConnection;
+import com.vaadin.terminal.gwt.server.ComponentSizeValidator.InvalidLayout;
+import com.vaadin.ui.AbstractField;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Upload;
+import com.vaadin.ui.Window;
+import com.vaadin.ui.Upload.UploadException;
+
/**
* This is a common base class for the server-side implementations of the
* communication system between the client code (compiled with GWT into
@@ -496,11 +496,14 @@ public abstract class AbstractCommunicationManager implements
* @param request
* @param response
* @param callback
+ * @param window
+ * target window for the UIDL request, can be null if target not
+ * found
* @throws IOException
* @throws InvalidUIDLSecurityKeyException
*/
protected void doHandleUidlRequest(Request request, Response response,
- Callback callback) throws IOException,
+ Callback callback, Window window) throws IOException,
InvalidUIDLSecurityKeyException {
// repaint requested or session has timed out and new one is created
@@ -526,10 +529,7 @@ public abstract class AbstractCommunicationManager implements
synchronized (application) {
// Finds the window within the application
- Window window = null;
if (application.isRunning()) {
- window = doGetApplicationWindow(request, callback, application,
- null);
// Returns if no window found
if (window == null) {
// This should not happen, no windows exists but
@@ -586,8 +586,7 @@ public abstract class AbstractCommunicationManager implements
}
}
- // out.flush(); - this line will cause errors when deployed on GateIn.
- out.close();
+ outWriter.close();
}
/**
@@ -941,7 +940,6 @@ public abstract class AbstractCommunicationManager implements
outWriter.print("}]");
}
- outWriter.flush();
outWriter.close();
}
@@ -1846,7 +1844,7 @@ public abstract class AbstractCommunicationManager implements
}
return stream;
} else {
- // Resolve the prefix end inded
+ // Resolve the prefix end index
final int index = uri.indexOf('/');
if (index > 0) {
String prefix = uri.substring(0, index);
diff --git a/src/com/vaadin/terminal/gwt/server/CommunicationManager.java b/src/com/vaadin/terminal/gwt/server/CommunicationManager.java
index 8799e37899..4e6bfbd158 100644
--- a/src/com/vaadin/terminal/gwt/server/CommunicationManager.java
+++ b/src/com/vaadin/terminal/gwt/server/CommunicationManager.java
@@ -238,16 +238,22 @@ public class CommunicationManager extends AbstractCommunicationManager {
*
* @param request
* @param response
+ * @param applicationServlet
+ * @param window
+ * target window of the UIDL request, can be null if window not
+ * found
* @throws IOException
* @throws ServletException
*/
public void handleUidlRequest(HttpServletRequest request,
HttpServletResponse response,
- AbstractApplicationServlet applicationServlet) throws IOException,
- ServletException, InvalidUIDLSecurityKeyException {
+ AbstractApplicationServlet applicationServlet, Window window)
+ throws IOException, ServletException,
+ InvalidUIDLSecurityKeyException {
doHandleUidlRequest(new HttpServletRequestWrapper(request),
new HttpServletResponseWrapper(response),
- new AbstractApplicationServletWrapper(applicationServlet));
+ new AbstractApplicationServletWrapper(applicationServlet),
+ window);
}
/**
diff --git a/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java b/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java
index ab1b1da81f..a6f8d7f204 100644
--- a/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java
+++ b/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java
@@ -139,18 +139,18 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext {
}
}
- public void firePortletRenderRequest(Application app,
+ public void firePortletRenderRequest(Application app, Window window,
RenderRequest request, RenderResponse response) {
Set listeners = portletListeners.get(app);
if (listeners != null) {
for (PortletListener l : listeners) {
l.handleRenderRequest(request, new RestrictedRenderResponse(
- response));
+ response), window);
}
}
}
- public void firePortletActionRequest(Application app,
+ public void firePortletActionRequest(Application app, Window window,
ActionRequest request, ActionResponse response) {
String key = request.getParameter(ActionRequest.ACTION_NAME);
if (eventActionDestinationMap.containsKey(key)) {
@@ -172,28 +172,28 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext {
Set listeners = portletListeners.get(app);
if (listeners != null) {
for (PortletListener l : listeners) {
- l.handleActionRequest(request, response);
+ l.handleActionRequest(request, response, window);
}
}
}
}
- public void firePortletEventRequest(Application app, EventRequest request,
- EventResponse response) {
+ public void firePortletEventRequest(Application app, Window window,
+ EventRequest request, EventResponse response) {
Set listeners = portletListeners.get(app);
if (listeners != null) {
for (PortletListener l : listeners) {
- l.handleEventRequest(request, response);
+ l.handleEventRequest(request, response, window);
}
}
}
- public void firePortletResourceRequest(Application app,
+ public void firePortletResourceRequest(Application app, Window window,
ResourceRequest request, ResourceResponse response) {
Set listeners = portletListeners.get(app);
if (listeners != null) {
for (PortletListener l : listeners) {
- l.handleResourceRequest(request, response);
+ l.handleResourceRequest(request, response, window);
}
}
}
@@ -201,16 +201,16 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext {
public interface PortletListener extends Serializable {
public void handleRenderRequest(RenderRequest request,
- RenderResponse response);
+ RenderResponse response, Window window);
public void handleActionRequest(ActionRequest request,
- ActionResponse response);
+ ActionResponse response, Window window);
public void handleEventRequest(EventRequest request,
- EventResponse response);
+ EventResponse response, Window window);
public void handleResourceRequest(ResourceRequest request,
- ResourceResponse response);
+ ResourceResponse response, Window window);
}
/**
diff --git a/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java b/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java
index 0a3307fbb0..7fe324b1db 100644
--- a/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java
+++ b/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java
@@ -3,6 +3,7 @@ package com.vaadin.terminal.gwt.server;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.lang.reflect.Method;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
@@ -13,6 +14,8 @@ import javax.portlet.PortletResponse;
import javax.portlet.PortletSession;
import javax.portlet.ResourceRequest;
import javax.portlet.ResourceResponse;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequestWrapper;
import com.vaadin.Application;
import com.vaadin.external.org.apache.commons.fileupload.FileItemIterator;
@@ -54,7 +57,20 @@ public class PortletCommunicationManager extends AbstractCommunicationManager {
}
public String getParameter(String name) {
- return request.getParameter(name);
+ String value = request.getParameter(name);
+ if (value == null) {
+ // for GateIn portlet container simple-portal
+ try {
+ Method getRealReq = request.getClass().getMethod(
+ "getRealRequest");
+ HttpServletRequestWrapper origRequest = (HttpServletRequestWrapper) getRealReq
+ .invoke(request);
+ value = origRequest.getParameter(name);
+ } catch (Exception e) {
+ // do nothing - not on GateIn simple-portal
+ }
+ }
+ return value;
}
public String getRequestID() {
@@ -209,11 +225,12 @@ public class PortletCommunicationManager extends AbstractCommunicationManager {
public void handleUidlRequest(ResourceRequest request,
ResourceResponse response,
- AbstractApplicationPortlet applicationPortlet)
+ AbstractApplicationPortlet applicationPortlet, Window window)
throws InvalidUIDLSecurityKeyException, IOException {
doHandleUidlRequest(new PortletRequestWrapper(request),
new PortletResponseWrapper(response),
- new AbstractApplicationPortletWrapper(applicationPortlet));
+ new AbstractApplicationPortletWrapper(applicationPortlet),
+ window);
}
DownloadStream handleURI(Window window, ResourceRequest request,
@@ -224,4 +241,29 @@ public class PortletCommunicationManager extends AbstractCommunicationManager {
new AbstractApplicationPortletWrapper(applicationPortlet));
}
+ /**
+ * Gets the existing application or creates a new one. Get a window within
+ * an application based on the requested URI.
+ *
+ * @param request
+ * the portlet Request.
+ * @param applicationPortlet
+ * @param application
+ * the Application to query for window.
+ * @param assumedWindow
+ * if the window has been already resolved once, this parameter
+ * must contain the window.
+ * @return Window matching the given URI or null if not found.
+ * @throws ServletException
+ * if an exception has occurred that interferes with the
+ * servlet's normal operation.
+ */
+ Window getApplicationWindow(PortletRequest request,
+ AbstractApplicationPortlet applicationPortlet,
+ Application application, Window assumedWindow) {
+ return doGetApplicationWindow(new PortletRequestWrapper(request),
+ new AbstractApplicationPortletWrapper(applicationPortlet),
+ application, assumedWindow);
+ }
+
}
--
cgit v1.2.3
From e8f6aa927673434673c648fd37ddacb40f69f369 Mon Sep 17 00:00:00 2001
From: Henri Sara
Date: Fri, 5 Mar 2010 07:52:34 +0000
Subject: #3921 removed TODO about potential GateIn problem.
svn changeset:11653/svn branch:6.3
---
src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java | 1 -
1 file changed, 1 deletion(-)
(limited to 'src/com')
diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java
index 5c0e40b38b..148474bccc 100644
--- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java
+++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java
@@ -642,7 +642,6 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
while ((bytesRead = data.read(buffer)) > 0) {
out.write(buffer, 0, bytesRead);
- // TODO this may cause problems on GateIn
out.flush();
}
out.close();
--
cgit v1.2.3
From 2b1deeeced6d098a22d6e52b70e94dbb9e96df57 Mon Sep 17 00:00:00 2001
From: Jouni Koivuviita
Date: Fri, 5 Mar 2010 12:09:04 +0000
Subject: Fixes #3322: SplitPanel with split position 100% doesn't resize
correctly * Percentage sizes now remain percentages, even if the end user
drags the split handle to a new position. An rounding to nearest percentage
is done at that point.
svn changeset:11661/svn branch:6.3
---
.../vaadin/terminal/gwt/client/ui/VSplitPanel.java | 71 ++++++++++++++++------
src/com/vaadin/ui/SplitPanel.java | 14 +++--
2 files changed, 63 insertions(+), 22 deletions(-)
(limited to 'src/com')
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java b/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java
index d7a11427fb..101c1e9848 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java
@@ -122,6 +122,9 @@ public class VSplitPanel extends ComplexPanel implements Container,
private boolean rendering = false;
+ /* The current position of the split handle in either percentages or pixels */
+ private String position;
+
public VSplitPanel() {
this(ORIENTATION_HORIZONTAL);
}
@@ -208,7 +211,8 @@ public class VSplitPanel extends ComplexPanel implements Container,
setStylenames();
- setSplitPosition(uidl.getStringAttribute("position"));
+ position = uidl.getStringAttribute("position");
+ setSplitPosition(position);
final Paintable newFirstChild = client.getPaintable(uidl
.getChildUIDL(0));
@@ -257,14 +261,26 @@ public class VSplitPanel extends ComplexPanel implements Container,
}
private void setSplitPosition(String pos) {
+ if (pos == null) {
+ return;
+ }
+
+ // Convert percentage values to pixels
+ if (pos.indexOf("%") > 0) {
+ pos = Float.parseFloat(pos.substring(0, pos.length() - 1))
+ / 100
+ * (orientation == ORIENTATION_HORIZONTAL ? getOffsetWidth()
+ : getOffsetHeight()) + "px";
+ }
+
if (orientation == ORIENTATION_HORIZONTAL) {
DOM.setStyleAttribute(splitter, "left", pos);
} else {
DOM.setStyleAttribute(splitter, "top", pos);
}
+
iLayout();
client.runDescendentsLayout(this);
-
}
/*
@@ -441,9 +457,6 @@ public class VSplitPanel extends ComplexPanel implements Container,
onVerticalMouseMove(y);
break;
}
- iLayout();
- // TODO Check if this is needed
- client.runDescendentsLayout(this);
}
@@ -455,7 +468,18 @@ public class VSplitPanel extends ComplexPanel implements Container,
if (newX + getSplitterSize() > getOffsetWidth()) {
newX = getOffsetWidth() - getSplitterSize();
}
- DOM.setStyleAttribute(splitter, "left", newX + "px");
+
+ if (position.indexOf("%") > 0) {
+ float pos = newX;
+ // 100% needs special handling
+ if (newX + getSplitterSize() >= getOffsetWidth()) {
+ pos = getOffsetWidth();
+ }
+ position = pos / getOffsetWidth() * 100 + "%";
+ }
+
+ setSplitPosition(newX + "px");
+
if (origX != newX) {
resized = true;
}
@@ -470,7 +494,18 @@ public class VSplitPanel extends ComplexPanel implements Container,
if (newY + getSplitterSize() > getOffsetHeight()) {
newY = getOffsetHeight() - getSplitterSize();
}
- DOM.setStyleAttribute(splitter, "top", newY + "px");
+
+ if (position.indexOf("%") > 0) {
+ float pos = newY;
+ // 100% needs special handling
+ if (newY + getSplitterSize() >= getOffsetHeight()) {
+ pos = getOffsetHeight();
+ }
+ position = pos / getOffsetHeight() * 100 + "%";
+ }
+
+ setSplitPosition(newY + "px");
+
if (origY != newY) {
resized = true;
}
@@ -554,9 +589,9 @@ public class VSplitPanel extends ComplexPanel implements Container,
this.height = height;
super.setHeight(height);
+
if (!rendering && client != null) {
- iLayout();
- client.runDescendentsLayout(this);
+ setSplitPosition(position);
}
}
@@ -568,9 +603,9 @@ public class VSplitPanel extends ComplexPanel implements Container,
this.width = width;
super.setWidth(width);
+
if (!rendering && client != null) {
- iLayout();
- client.runDescendentsLayout(this);
+ setSplitPosition(position);
}
}
@@ -627,12 +662,14 @@ public class VSplitPanel extends ComplexPanel implements Container,
* Updates the new split position back to server.
*/
private void updateSplitPositionToServer() {
- // We always send pixel values to server
- final String position = orientation == ORIENTATION_HORIZONTAL ? splitter
- .getStyle().getProperty("left")
- : splitter.getStyle().getProperty("top");
- final int pos = Integer.parseInt(position.substring(0, position
- .length() - 2));
+ int pos = 0;
+ if (position.indexOf("%") > 0) {
+ pos = Float.valueOf(position.substring(0, position.length() - 1))
+ .intValue();
+ } else {
+ pos = Integer
+ .parseInt(position.substring(0, position.length() - 2));
+ }
client.updateVariable(id, "position", pos, immediate);
}
diff --git a/src/com/vaadin/ui/SplitPanel.java b/src/com/vaadin/ui/SplitPanel.java
index 5e67b93369..1a149d7394 100644
--- a/src/com/vaadin/ui/SplitPanel.java
+++ b/src/com/vaadin/ui/SplitPanel.java
@@ -281,10 +281,11 @@ public class SplitPanel extends AbstractLayout {
* Moves the position of the splitter.
*
* @param pos
- * the new size of the first region in percentage
+ * the new size of the first region in the unit that was last
+ * used (default is percentage)
*/
public void setSplitPosition(int pos) {
- setSplitPosition(pos, UNITS_PERCENTAGE, true);
+ setSplitPosition(pos, posUnit, true);
}
/**
@@ -303,7 +304,7 @@ public class SplitPanel extends AbstractLayout {
* Moves the position of the splitter.
*
* @param pos
- * the new size of the first region in percentage
+ * the new size of the first region
* @param unit
* the unit (from {@link Sizeable}) in which the size is given.
* @param repaintNotNeeded
@@ -312,6 +313,10 @@ public class SplitPanel extends AbstractLayout {
* knows the position.
*/
private void setSplitPosition(int pos, int unit, boolean repaintNeeded) {
+ if (unit != UNITS_PERCENTAGE && unit != UNITS_PIXELS) {
+ throw new IllegalArgumentException(
+ "Only percentage and pixel units are allowed");
+ }
this.pos = pos;
posUnit = unit;
if (repaintNeeded) {
@@ -353,8 +358,7 @@ public class SplitPanel extends AbstractLayout {
if (variables.containsKey("position") && !isLocked()) {
Integer newPos = (Integer) variables.get("position");
- // Client always sends pixel values. Repaint is not needed.
- setSplitPosition(newPos, UNITS_PIXELS, false);
+ setSplitPosition(newPos, posUnit, false);
}
if (variables.containsKey(SPLITTER_CLICK_EVENT)) {
--
cgit v1.2.3