aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IFilterSelect.java29
-rw-r--r--src/com/itmill/toolkit/ui/AbstractSelect.java4
-rw-r--r--src/com/itmill/toolkit/ui/CustomLayout.java28
3 files changed, 36 insertions, 25 deletions
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IFilterSelect.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IFilterSelect.java
index a0dae7b31f..d2cf5995e3 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IFilterSelect.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IFilterSelect.java
@@ -143,8 +143,9 @@ public class IFilterSelect extends Composite implements Paintable,
private void setPrevButtonActive(boolean b) {
if (b) {
DOM.sinkEvents(up, Event.ONCLICK);
- DOM.setElementProperty(up, "className", CLASSNAME
- + "-prevpage");
+ DOM
+ .setElementProperty(up, "className", CLASSNAME
+ + "-prevpage");
} else {
DOM.sinkEvents(up, 0);
DOM.setElementProperty(up, "className", CLASSNAME
@@ -178,9 +179,11 @@ public class IFilterSelect extends Composite implements Paintable,
public void onBrowserEvent(Event event) {
Element target = DOM.eventGetTarget(event);
- if (DOM.compare(target, up) || DOM.compare(target, DOM.getChild(up, 0))) {
+ if (DOM.compare(target, up)
+ || DOM.compare(target, DOM.getChild(up, 0))) {
filterOptions(currentPage - 1, lastFilter);
- } else if (DOM.compare(target, down) || DOM.compare(target, DOM.getChild(down, 0))) {
+ } else if (DOM.compare(target, down)
+ || DOM.compare(target, DOM.getChild(down, 0))) {
filterOptions(currentPage + 1, lastFilter);
}
tb.setFocus(true);
@@ -225,7 +228,8 @@ public class IFilterSelect extends Composite implements Paintable,
+ "px");
}
if (offsetHeight + getPopupTop() > Window.getClientHeight()) {
- int top = Window.getClientHeight() - offsetHeight - EXTRASPACE/2;
+ int top = Window.getClientHeight() - offsetHeight - EXTRASPACE
+ / 2;
setPopupPosition(getPopupLeft(), top);
}
}
@@ -254,6 +258,11 @@ public class IFilterSelect extends Composite implements Paintable,
MenuItem item = this.getSelectedItem();
if (item != null) {
doItemAction(item, true);
+ } else if (allowNewItem) {
+ String newItemValue = tb.getText();
+ if(!newItemValue.equals("")) {
+ client.updateVariable(paintableId, "newitem", newItemValue, true);
+ }
}
suggestionPopup.hide();
}
@@ -263,7 +272,6 @@ public class IFilterSelect extends Composite implements Paintable,
public static final int FILTERINGMODE_STARTSWITH = 1;
public static final int FILTERINGMODE_CONTAINS = 2;
-
private static final String CLASSNAME = "i-filterselect";
public static final int PAGELENTH = 15;
@@ -302,6 +310,7 @@ public class IFilterSelect extends Composite implements Paintable,
private ArrayList allSuggestions;
private int totalMatches;
+ private boolean allowNewItem;
public IFilterSelect() {
selectedItemIcon.setVisible(false);
@@ -331,7 +340,7 @@ public class IFilterSelect extends Composite implements Paintable,
if (filter.equals(lastFilter) && currentPage == page) {
if (!suggestionPopup.isAttached())
suggestionPopup.showSuggestions(currentSuggestions,
- currentPage, totalSuggestions);
+ currentPage, totalMatches);
return;
}
if (!filter.equals(lastFilter)) {
@@ -380,11 +389,13 @@ public class IFilterSelect extends Composite implements Paintable,
clientSideFiltering = true;
}
+ allowNewItem = uidl.hasAttribute("allownewitem");
+
currentSuggestions.clear();
UIDL options = uidl.getChildUIDL(0);
totalSuggestions = uidl.getIntAttribute("totalitems");
totalMatches = uidl.getIntAttribute("totalMatches");
-
+
String captions = "";
if (clientSideFiltering) {
allSuggestions = new ArrayList();
@@ -410,7 +421,7 @@ public class IFilterSelect extends Composite implements Paintable,
if (filtering && lastFilter.equals(uidl.getStringVariable("filter"))) {
suggestionPopup.showSuggestions(currentSuggestions, currentPage,
- totalSuggestions);
+ totalMatches);
filtering = false;
}
diff --git a/src/com/itmill/toolkit/ui/AbstractSelect.java b/src/com/itmill/toolkit/ui/AbstractSelect.java
index 0d0fa88a4a..156ebc4df6 100644
--- a/src/com/itmill/toolkit/ui/AbstractSelect.java
+++ b/src/com/itmill/toolkit/ui/AbstractSelect.java
@@ -278,8 +278,8 @@ public abstract class AbstractSelect extends AbstractField implements
if (isNewItemsAllowed()) {
target.addAttribute("allownewitem", true);
}
- if (!isNullSelectionAllowed()) {
- target.addAttribute("nullselect", false);
+ if (isNullSelectionAllowed()) {
+ target.addAttribute("nullselect", true);
}
// Constructs selected keys array
diff --git a/src/com/itmill/toolkit/ui/CustomLayout.java b/src/com/itmill/toolkit/ui/CustomLayout.java
index d4c39fc08d..79b5d89c5b 100644
--- a/src/com/itmill/toolkit/ui/CustomLayout.java
+++ b/src/com/itmill/toolkit/ui/CustomLayout.java
@@ -177,16 +177,16 @@ public class CustomLayout extends AbstractComponentContainer implements Layout {
target.addAttribute("template", templateName);
// Adds all items in all the locations
for (Iterator i = slots.keySet().iterator(); i.hasNext();) {
-
// Gets the (location,component)
String location = (String) i.next();
Component c = (Component) slots.get(location);
-
- // Writes the item
- target.startTag("location");
- target.addAttribute("name", location);
- c.paint(target);
- target.endTag("location");
+ if (c != null) {
+ // Writes the item
+ target.startTag("location");
+ target.addAttribute("name", location);
+ c.paint(target);
+ target.endTag("location");
+ }
}
}
@@ -221,24 +221,24 @@ public class CustomLayout extends AbstractComponentContainer implements Layout {
* CustomLayout's template selecting was previously implemented with
* setStyle. Overriding to improve backwards compatibility.
*
- * @param name template name
+ * @param name
+ * template name
*/
public void setStyle(String name) {
setTemplateName(name);
}
-
/** Get the name of the template */
public String getTemplateName() {
return templateName;
}
- /** Set the name of the template used to draw custom layout.
+ /**
+ * Set the name of the template used to draw custom layout.
*
- * With GWT-adapter, the template with name 'templatename' is
- * loaded from ITMILL/themes/themename/layouts/templatename.html.
- * If the theme has not been set (with Application.setTheme()),
- * themename is 'default'.
+ * With GWT-adapter, the template with name 'templatename' is loaded from
+ * ITMILL/themes/themename/layouts/templatename.html. If the theme has not
+ * been set (with Application.setTheme()), themename is 'default'.
*
* @param templateName
*/