Browse Source

Integrated filter select features. Fixed #41

svn changeset:393/svn branch:toolkit
tags/6.7.0.beta1
Joonas Lehtinen 17 years ago
parent
commit
645545f63d

+ 44
- 6
src/com/itmill/toolkit/demo/features/FeatureSelect.java View File

@@ -32,6 +32,45 @@ import com.itmill.toolkit.ui.*;

public class FeatureSelect extends Feature {

private static final String[] firstnames =
new String[] {
"John",
"Mary",
"Joe",
"Sarah",
"Jeff",
"Jane",
"Peter",
"Marc",
"Robert",
"Paula",
"Lenny",
"Kenny",
"Nathan",
"Nicole",
"Laura",
"JosŽ",
"Josie",
"Linus" };
private static final String[] lastnames =
new String[] {
"Torvalds",
"Smith",
"Adams",
"Black",
"Wilson",
"Richards",
"Thompson",
"McGoff",
"Halas",
"Jones",
"Beck",
"Sheridan",
"Picard",
"Hill",
"Fielding",
"Einstein" };
public FeatureSelect() {
super();
}
@@ -42,11 +81,10 @@ public class FeatureSelect extends Feature {

// Example panel
Panel show = new Panel("Select component");
Select s = new Select("Select Car");
s.addItem("Audi");
s.addItem("BMW");
s.addItem("Chrysler");
s.addItem("Volvo");
Select s = new Select("Select Person");
for (int i=0; i<1000; i++)
s.addItem(firstnames[(int) (Math.random() * (firstnames.length-1))] + " " +
lastnames[(int) (Math.random() * (lastnames.length-1))]);
show.addComponent(s);
l.addComponent(show);

@@ -62,7 +100,7 @@ public class FeatureSelect extends Feature {
.getItemProperty(themes.getItemCaptionPropertyId())
.setValue("twincol");
l.addComponent(p);
return l;
}


+ 27
- 3
src/com/itmill/toolkit/demo/features/PropertyPanel.java View File

@@ -38,6 +38,7 @@ import java.util.Iterator;
import java.util.LinkedList;

import com.itmill.toolkit.data.*;
import com.itmill.toolkit.data.Property.ValueChangeListener;
import com.itmill.toolkit.data.util.*;
import com.itmill.toolkit.terminal.*;
import com.itmill.toolkit.ui.*;
@@ -300,7 +301,7 @@ public class PropertyPanel
private void addSelectProperties() {
Form set =
createBeanPropertySet(
new String[] { "multiSelect", "newItemsAllowed" });
new String[] { "newItemsAllowed", "lazyLoading" ,"multiSelect"});
addProperties("Select Properties", set);

set.getField("multiSelect").setDescription(
@@ -309,9 +310,19 @@ public class PropertyPanel
"Select component (but not Tree or Table) can allow the user to directly "
+ "add new items to set of options. The new items are constrained to be "
+ "strings and thus feature only applies to simple lists.");
Button ll = (Button) set.getField("lazyLoading");
ll.setDescription("In Ajax rendering mode select supports lazy loading and filtering of options.");
ll.addListener((ValueChangeListener)this);
ll.setImmediate(true);
if (((Boolean)ll.getValue()).booleanValue()) {
set.getField("multiSelect").setVisible(false);
set.getField("newItemsAllowed").setVisible(false);
}
if (objectToConfigure instanceof Tree
|| objectToConfigure instanceof Table)
set.removeItemProperty("newItemsAllowed");
|| objectToConfigure instanceof Table) {
set.removeItemProperty("newItemsAllowed");
set.removeItemProperty("lazyLoading");
}
}

/** Field special properties */
@@ -415,6 +426,19 @@ public class PropertyPanel

addComponent.setValue(null);
}
} else if (event.getProperty() == getField("lazyLoading")) {
boolean newValue = ((Boolean)event.getProperty().getValue()).booleanValue();
Field multiselect = getField("multiSelect");
Field newitems = getField("newItemsAllowed");
if (newValue) {
newitems.setValue(Boolean.FALSE);
newitems.setVisible(false);
multiselect.setValue(Boolean.FALSE);
multiselect.setVisible(false);
} else {
newitems.setVisible(true);
multiselect.setVisible(true);
}
}
}


+ 724
- 401
src/com/itmill/toolkit/ui/Select.java
File diff suppressed because it is too large
View File


+ 10
- 1
src/com/itmill/toolkit/ui/Table.java View File

@@ -61,7 +61,7 @@ import com.itmill.toolkit.terminal.Sizeable;
public class Table extends Select implements Action.Container,
Container.Ordered, Container.Sortable, Sizeable {

private static final int CELL_KEY = 0;
private static final int CELL_KEY = 0;

private static final int CELL_HEADER = 1;

@@ -2247,4 +2247,13 @@ public class Table extends Select implements Action.Container,
requestRepaint();
}

/** Table does not support lazy options loading mode.
* Setting this true will throw UnsupportedOperationException.
*/
public void setLazyLoading(boolean useLazyLoading) {
if (useLazyLoading)
throw new UnsupportedOperationException("Lazy options loading is not supported by Table.");
}


}

+ 9
- 0
src/com/itmill/toolkit/ui/Tree.java View File

@@ -759,5 +759,14 @@ public class Tree extends Select implements Container.Hierarchical, Action.Conta
public void focus() throws UnsupportedOperationException {
throw new UnsupportedOperationException();
}
/** Tree does not support lazy options loading mode.
* Setting this true will throw UnsupportedOperationException.
*/
public void setLazyLoading(boolean useLazyLoading) {
if (useLazyLoading)
throw new UnsupportedOperationException("Lazy options loading is not supported by Tree.");
}


}

Loading…
Cancel
Save