private TabSheet ts;
// Example "cache"
- private final HashMap exampleInstances = new HashMap();
+ private final HashMap<Class<?>, Component> exampleInstances = new HashMap<Class<?>, Component>();
private String section;
// List of examples
final SplitPanel split = new SplitPanel(
SplitPanel.ORIENTATION_HORIZONTAL);
split.setSplitPosition(200, SplitPanel.UNITS_PIXELS);
- main.setLayout(split);
+ main.setContent(split);
- final HashMap sectionIds = new HashMap();
+ final HashMap<String, Object> sectionIds = new HashMap<String, Object>();
final HierarchicalContainer container = createContainer();
final Object rootId = container.addItem();
Item item = container.getItem(rootId);
public void buttonClick(ClickEvent event) {
Component component = (Component) ts.getComponentIterator()
.next();
- String caption = ts.getTabCaption(component);
+ String caption = ts.getTab(component).getCaption();
try {
component = component.getClass().newInstance();
} catch (Exception e) {
Window w = new Window(caption);
w.setWidth("640px");
if (Layout.class.isAssignableFrom(component.getClass())) {
- w.setLayout((Layout) component);
+ w.setContent((Layout) component);
} else {
// w.getLayout().getSize().setSizeFull();
w.addComponent(component);
public void buttonClick(ClickEvent event) {
Component component = (Component) ts.getComponentIterator()
.next();
- final String caption = ts.getTabCaption(component);
+ final String caption = ts.getTab(component).getCaption();
Window w = getWindow(caption);
if (w == null) {
try {
w = new Window(caption);
w.setName(caption);
if (Layout.class.isAssignableFrom(component.getClass())) {
- w.setLayout((Layout) component);
+ w.setContent((Layout) component);
} else {
// w.getLayout().getSize().setSizeFull();
w.addComponent(component);
return null;
}
}
- return (Component) exampleInstances.get(componentClass);
+ return exampleInstances.get(componentClass);
}
}
// Our root window contains one VerticalLayout by default, let's make
// sure it's 100% sized, and remove unwanted margins
- root.getLayout().setSizeFull();
+ root.getContent().setSizeFull();
root.getLayout().setMargin(false);
// Top area, containing playback and volume controls, play status, view
// The splitpanel is by default 100% x 100%, but we'll need to adjust
// our main window layout to accomodate the height
- ((VerticalLayout) root.getLayout()).setExpandRatio(bottom, 1.0F);
+ ((VerticalLayout) root.getContent()).setExpandRatio(bottom, 1.0F);
// Give the sidebar less space than the listing
bottom.setSplitPosition(200, SplitPanel.UNITS_PIXELS);
setValue(new String("white"));
}
- /** The property value of the field is an Integer. */
+ /** The property value of the field is a String. */
@Override
public Class getType() {
return String.class;
private TabSheet ts;
// Example "cache"
- private final HashMap exampleInstances = new HashMap();
+ private final HashMap<Class<?>, Component> exampleInstances = new HashMap<Class<?>, Component>();
private String section;
// List of examples
split.setSplitPosition(200, SplitPanel.UNITS_PIXELS);
main.setContent(split);
- final HashMap sectionIds = new HashMap();
+ final HashMap<String, Object> sectionIds = new HashMap<String, Object>();
final HierarchicalContainer container = createContainer();
final Object rootId = container.addItem();
Item item = container.getItem(rootId);
tree.addListener(this);
tree.setImmediate(true);
tree.expandItemsRecursively(rootId);
- for (Iterator i = container.getItemIds().iterator(); i.hasNext();) {
+ for (Iterator<?> i = container.getItemIds().iterator(); i.hasNext();) {
Object id = i.next();
if (container.getChildren(id) == null) {
tree.setChildrenAllowed(id, false);
public void buttonClick(ClickEvent event) {
Component component = (Component) ts.getComponentIterator()
.next();
- String caption = ts.getTabCaption(component);
+ String caption = ts.getTab(component).getCaption();
try {
component = component.getClass().newInstance();
} catch (Exception e) {
public void buttonClick(ClickEvent event) {
Component component = (Component) ts.getComponentIterator()
.next();
- final String caption = ts.getTabCaption(component);
+ final String caption = ts.getTab(component).getCaption();
Window w = getWindow(caption);
if (w == null) {
try {
tree.setValue(table.getValue());
table.addListener(this);
final Item item = table.getItem(table.getValue());
- final Class c = (Class) item.getItemProperty(PROPERTY_ID_CLASS)
- .getValue();
+ final Class<?> c = (Class<?>) item.getItemProperty(
+ PROPERTY_ID_CLASS).getValue();
final Component component = getComponent(c);
if (component != null) {
final String caption = (String) item.getItemProperty(
}
- private Component getComponent(Class componentClass) {
+ private Component getComponent(Class<?> componentClass) {
if (!exampleInstances.containsKey(componentClass)) {
try {
final Component c = (Component) componentClass.newInstance();
return null;
}
}
- return (Component) exampleInstances.get(componentClass);
+ return exampleInstances.get(componentClass);
}
}
package com.vaadin.demo.featurebrowser;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.GregorianCalendar;
-import java.util.Vector;
import com.vaadin.data.Container;
import com.vaadin.data.Item;
import com.vaadin.data.Container.Indexed;
import com.vaadin.data.util.BeanItem;
import com.vaadin.ui.AbstractField;
-import com.vaadin.ui.BaseFieldFactory;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.Component;
import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.DefaultFieldFactory;
import com.vaadin.ui.Field;
import com.vaadin.ui.Label;
import com.vaadin.ui.Table;
* implementations, as they are not needed in this example.
*/
public class MySimpleIndexedContainer implements Container, Indexed {
- Vector items;
+ ArrayList<BeanItem> items;
Object itemtemplate;
public MySimpleIndexedContainer(Object itemtemplate) {
this.itemtemplate = itemtemplate;
- items = new Vector(); // Yeah this is just a test
+ items = new ArrayList<BeanItem>(); // Yeah this is just a test
}
- public boolean addContainerProperty(Object propertyId, Class type,
+ public boolean addContainerProperty(Object propertyId, Class<?> type,
Object defaultValue) throws UnsupportedOperationException {
throw new UnsupportedOperationException();
}
if (itemId instanceof Integer) {
int pos = ((Integer) itemId).intValue();
if (pos >= 0 && pos < items.size()) {
- Item item = (Item) items.get(pos);
+ Item item = items.get(pos);
// The BeanItem provides the property objects for the items.
return item.getItemProperty(propertyId);
}
/** Table calls this to get the column names. */
- public Collection getContainerPropertyIds() {
+ public Collection<?> getContainerPropertyIds() {
Item item = new BeanItem(itemtemplate);
// The BeanItem knows how to get the property names from the bean.
if (itemId instanceof Integer) {
int pos = ((Integer) itemId).intValue();
if (pos >= 0 && pos < items.size()) {
- return (Item) items.get(pos);
+ return items.get(pos);
}
}
return null;
}
- public Collection getItemIds() {
- Vector ids = new Vector(items.size());
+ public Collection<?> getItemIds() {
+ ArrayList<Integer> ids = new ArrayList<Integer>(items.size());
for (int i = 0; i < items.size(); i++) {
ids.add(Integer.valueOf(i));
}
return ids;
}
- public Class getType(Object propertyId) {
+ public Class<?> getType(Object propertyId) {
return BeanItem.class;
}
/**
* Custom field factory that sets the fields as immediate.
*/
- public class ImmediateFieldFactory extends BaseFieldFactory {
+ public class ImmediateFieldFactory extends DefaultFieldFactory {
@Override
- public Field createField(Class type, Component uiContext) {
- // Let the BaseFieldFactory create the fields
- Field field = super.createField(type, uiContext);
+ public Field createField(Container container, Object itemId,
+ Object propertyId, Component uiContext) {
+ // Let the DefaultFieldFactory create the fields
+ Field field = super.createField(container, itemId, propertyId,
+ uiContext);
// ...and just set them as immediate
((AbstractField) field).setImmediate(true);
// Use a custom field factory to set the edit fields as immediate.
// This is used when the table is in editable mode.
- table.setFieldFactory(new ImmediateFieldFactory());
+ table.setTableFieldFactory(new ImmediateFieldFactory());
// Setting the table itself as immediate has no relevance in this
// example,
}\r
}\r
\r
+ @SuppressWarnings("unchecked")\r
public void buttonClick(ClickEvent event) {\r
final Button b = event.getButton();\r
if (b == deselect) {\r
\r
// Check old propertyIds\r
if (itemEndPropertyId != null) {\r
- final Class c = dataSource.getType(itemEndPropertyId);\r
+ final Class<?> c = dataSource.getType(itemEndPropertyId);\r
if (!Date.class.isAssignableFrom(c)) {\r
itemEndPropertyId = null;\r
}\r
}\r
if (itemNotimePropertyId != null) {\r
- final Class c = dataSource.getType(itemNotimePropertyId);\r
+ final Class<?> c = dataSource.getType(itemNotimePropertyId);\r
if (!Boolean.class.isAssignableFrom(c)) {\r
itemNotimePropertyId = null;\r
}\r
}\r
if (itemStartPropertyId != null) {\r
- final Class c = dataSource.getType(itemStartPropertyId);\r
+ final Class<?> c = dataSource.getType(itemStartPropertyId);\r
if (Date.class.isAssignableFrom(c)) {\r
// All we _really_ need is one date\r
return true;\r
}\r
}\r
// We need at least one Date\r
- final Collection ids = dataSource.getContainerPropertyIds();\r
- for (final Iterator it = ids.iterator(); it.hasNext();) {\r
+ final Collection<?> ids = dataSource.getContainerPropertyIds();\r
+ for (final Iterator<?> it = ids.iterator(); it.hasNext();) {\r
final Object id = it.next();\r
- final Class c = dataSource.getType(id);\r
+ final Class<?> c = dataSource.getType(id);\r
if (Date.class.isAssignableFrom(c)) {\r
itemStartPropertyId = id;\r
return true;\r
month = ((Date) value).getMonth();\r
}\r
\r
- for (final Iterator it = dataSource.getItemIds().iterator(); it\r
+ for (final Iterator<?> it = dataSource.getItemIds().iterator(); it\r
.hasNext();) {\r
final Object itemId = it.next();\r
final Item item = dataSource.getItem(itemId);\r
\r
if (dataSource != null) {\r
target.startTag(TAG_MARKERS);\r
- final Collection itemIds = dataSource.getItemIds();\r
- for (final Iterator it = itemIds.iterator(); it.hasNext();) {\r
+ final Collection<?> itemIds = dataSource.getItemIds();\r
+ for (final Iterator<?> it = itemIds.iterator(); it.hasNext();) {\r
final Object itemId = it.next();\r
final Item item = dataSource.getItem(itemId);\r
Property p = item.getItemProperty(getItemMarkerXPropertyId());\r
import com.vaadin.ui.VerticalLayout;\r
import com.vaadin.ui.Button.ClickEvent;\r
\r
-@SuppressWarnings("serial")\r
+@SuppressWarnings( { "serial", "unchecked" })\r
public class ResourceSelectorPanel extends Panel implements\r
Button.ClickListener {\r
private final HashMap categoryLayouts = new HashMap();\r
}
- public Container getReservations(List resources) {
+ public Container getReservations(List<?> resources) {
// TODO where reserved_by=?
// TODO where from=?
// TODO where to=?
+ Resource.PROPERTY_ID_ID;
if (resources != null && resources.size() > 0) {
final StringBuffer s = new StringBuffer();
- for (final Iterator it = resources.iterator(); it.hasNext();) {
+ for (final Iterator<?> it = resources.iterator(); it.hasNext();) {
if (s.length() > 0) {
s.append(",");
}
"Customer meeting", "Guests arriving at harbour",
"Moving furniture", "Taking guests to see town" };
final Container cat = getCategories();
- final Collection cIds = cat.getItemIds();
- for (final Iterator it = cIds.iterator(); it.hasNext();) {
+ final Collection<?> cIds = cat.getItemIds();
+ for (final Iterator<?> it = cIds.iterator(); it.hasNext();) {
final Object id = it.next();
final Item ci = cat.getItem(id);
final String c = (String) ci.getItemProperty(
Resource.PROPERTY_ID_CATEGORY).getValue();
final Container resources = getResources(c);
- final Collection rIds = resources.getItemIds();
+ final Collection<?> rIds = resources.getItemIds();
final Calendar cal = Calendar.getInstance();
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
// cal.add(Calendar.DAY_OF_MONTH, -days);
for (int i = 0; i < days; i++) {
int r = 3;
- for (final Iterator rit = rIds.iterator(); rit.hasNext()
+ for (final Iterator<?> rit = rIds.iterator(); rit.hasNext()
&& r > 0; r--) {
final Object rid = rit.next();
final Item resource = resources.getItem(rid);
import com.vaadin.terminal.gwt.client.ui.VCalendarPanel;\r
import com.vaadin.terminal.gwt.client.ui.VDateField;\r
\r
+@SuppressWarnings( { "deprecation", "unchecked" })\r
public class VCalendarField extends VDateField {\r
\r
private final VCalendarPanel calPanel;\r
buildDayView(date);\r
}\r
\r
- @SuppressWarnings("deprecation")\r
protected void buildDayView(Date date) {\r
if (hourPanel == null) {\r
hourPanel = new SimplePanel();\r
\r
private final HashMap dates = new HashMap();\r
\r
- @SuppressWarnings("deprecation")\r
public void addItem(UIDL item) {\r
final String styleName = item.getStringAttribute("styleName");\r
// final Integer id = new Integer(item.getIntAttribute("id"));\r
}\r
}\r
\r
- @SuppressWarnings("deprecation")\r
public List getEntries(Date date, int resolution) {\r
final ArrayList res = new ArrayList();\r
if (date == null) {\r
private void addMarkerPopup(Marker marker, final String html) {\r
marker.addMarkerClickHandler(new MarkerClickHandler() {\r
\r
+ @SuppressWarnings("deprecation")\r
public void onClick(MarkerClickEvent event) {\r
widget.getInfoWindow().open(event.getSender().getPoint(),\r
new InfoWindowContent(html));\r
public void buttonClick(ClickEvent event) {
if (editedItem == null) {
// save
- int addResource = application.getDb().addResource(
- name.getValue().toString(),
+ application.getDb().addResource(name.getValue().toString(),
desc.getValue().toString());
} else {
// update
}
- public Container getReservations(List resources) {
+ public Container getReservations(List<?> resources) {
// TODO where reserved_by=?
// TODO where from=?
// TODO where to=?
+ Resource.PROPERTY_ID_ID;
if (resources != null && resources.size() > 0) {
final StringBuffer s = new StringBuffer();
- for (final Iterator it = resources.iterator(); it.hasNext();) {
+ for (final Iterator<?> it = resources.iterator(); it.hasNext();) {
if (s.length() > 0) {
s.append(",");
}
"Customer meeting", "Guests arriving at harbour",
"Moving furniture", "Taking guests to see town" };
final Container cat = getCategories();
- final Collection cIds = cat.getItemIds();
- for (final Iterator it = cIds.iterator(); it.hasNext();) {
+ final Collection<?> cIds = cat.getItemIds();
+ for (final Iterator<?> it = cIds.iterator(); it.hasNext();) {
final Object id = it.next();
final Item ci = cat.getItem(id);
final String c = (String) ci.getItemProperty(
Resource.PROPERTY_ID_CATEGORY).getValue();
final Container resources = getResources(c);
- final Collection rIds = resources.getItemIds();
+ final Collection<?> rIds = resources.getItemIds();
final Calendar cal = Calendar.getInstance();
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
// cal.add(Calendar.DAY_OF_MONTH, -days);
for (int i = 0; i < days; i++) {
int r = 3;
- for (final Iterator rit = rIds.iterator(); rit.hasNext()
+ for (final Iterator<?> rit = rIds.iterator(); rit.hasNext()
&& r > 0; r--) {
final Object rid = rit.next();
final Item resource = resources.getItem(rid);
private static final String SERVLET_BASE = "http://java.sun.com/products/servlet/2.5/docs/servlet-2_5-mr2";
private static final String PORTLET_BASE = "http://developers.sun.com/docs/jscreator/apis/portlet";
- public APIResource(Class clazz) {
+ public APIResource(Class<?> clazz) {
this(resolveBaseUrl(clazz), clazz);
}
- public APIResource(String baseUrl, Class clazz) {
+ public APIResource(String baseUrl, Class<?> clazz) {
super(resolveName(clazz), getJavadocUrl(baseUrl, clazz));
}
- private static String getJavadocUrl(String baseUrl, Class clazz) {
+ private static String getJavadocUrl(String baseUrl, Class<?> clazz) {
if (!baseUrl.endsWith("/")) {
baseUrl += "/";
}
* @param clazz
* @return
*/
- private static String resolveBaseUrl(Class clazz) {
+ private static String resolveBaseUrl(Class<?> clazz) {
String name = clazz.getName();
if (name.startsWith("javax.servlet.")) {
return SERVLET_BASE;
return VAADIN_BASE;
}
- private static String resolveName(Class clazz) {
- Class ec = clazz.getEnclosingClass();
+ private static String resolveName(Class<?> clazz) {
+ Class<?> ec = clazz.getEnclosingClass();
return (ec != null ? ec.getSimpleName() + "." : "")
+ clazz.getSimpleName();
}
updateStyles();
}
+ @SuppressWarnings("unchecked")
private void updateStyles() {
boolean first = true;
- for (Iterator it = layout.getComponentIterator(); it.hasNext();) {
- Button b = (Button) it.next();
+ for (Iterator<Button> it = layout.getComponentIterator(); it.hasNext();) {
+ Button b = it.next();
String isOn = (b.getData() == mode ? "-on" : "");
if (first) {
first = false;
* @param clazz
* @return
*/
+ @SuppressWarnings("unchecked")
public static Feature getFeatureFor(Class clazz) {
- for (Iterator it = allFeatures.getItemIds().iterator(); it.hasNext();) {
- Feature f = (Feature) it.next();
+ for (Iterator<Feature> it = allFeatures.getItemIds().iterator(); it
+ .hasNext();) {
+ Feature f = it.next();
if (f.getClass() == clazz) {
return f;
}
SamplerWindow() {
// Main top/expanded-bottom layout
VerticalLayout mainExpand = new VerticalLayout();
- setLayout(mainExpand);
+ setContent(mainExpand);
setSizeFull();
mainExpand.setSizeFull();
setCaption("Vaadin Sampler");
search.setNullSelectionAllowed(true);
search.setImmediate(true);
search.setContainerDataSource(allFeatures);
- for (Iterator it = allFeatures.getItemIds().iterator(); it
+ for (Iterator<?> it = allFeatures.getItemIds().iterator(); it
.hasNext();) {
Object id = it.next();
if (id instanceof FeatureSet) {
FeatureGrid() {
setSizeFull();
- setLayout(grid);
+ setContent(grid);
grid.setSizeUndefined();
grid.setSpacing(true);
setStyleName(Panel.STYLE_LIGHT);
}
+ @SuppressWarnings("unchecked")
public void setFeatureContainer(HierarchicalContainer c) {
grid.removeAllComponents();
- Collection features = c.getItemIds();
- for (Iterator it = features.iterator(); it.hasNext();) {
- final Feature f = (Feature) it.next();
+ Collection<Feature> features = c.getItemIds();
+ for (Iterator<Feature> it = features.iterator(); it.hasNext();) {
+ final Feature f = it.next();
if (f instanceof FeatureSet) {
grid.newLine();
Label title = new Label(f.getName());
private Label l1;\r
private Label l2;\r
private Label l3;\r
+ @SuppressWarnings("unused")\r
private Tab t1;\r
private Tab t2;\r
private Tab t3;\r
import com.vaadin.ui.Accordion;\r
import com.vaadin.ui.HorizontalLayout;\r
import com.vaadin.ui.Label;\r
+import com.vaadin.ui.TabSheet;\r
import com.vaadin.ui.TabSheet.SelectedTabChangeEvent;\r
+import com.vaadin.ui.TabSheet.Tab;\r
\r
@SuppressWarnings("serial")\r
public class AccordionIconsExample extends HorizontalLayout implements\r
}\r
\r
public void selectedTabChange(SelectedTabChangeEvent event) {\r
- String c = a.getTabCaption(event.getTabSheet().getSelectedTab());\r
- getWindow().showNotification("Selected tab: " + c);\r
+ TabSheet tabsheet = event.getTabSheet();\r
+ Tab tab = tabsheet.getTab(tabsheet.getSelectedTab());\r
+ if (tab != null) {\r
+ getWindow().showNotification("Selected tab: " + tab.getCaption());\r
+ }\r
}\r
}\r
@SuppressWarnings("serial")
public class ValidationExample extends VerticalLayout {
- HashSet usernames = new HashSet();
+ HashSet<String> usernames = new HashSet<String>();
public ValidationExample() {
setSpacing(true);
public void valueChange(ValueChangeEvent event) {
TextField tf = (TextField) event.getProperty();
tf.validate();
- usernames.add(tf.getValue());
- addComponent(new Label("Added " + tf.getValue()
- + " to usernames"));
+ if (tf.getValue() != null) {
+ usernames.add(tf.getValue().toString());
+ addComponent(new Label("Added " + tf.getValue()
+ + " to usernames"));
+ }
}
});
public PersonFieldFactory() {
countries.setWidth("30em");
- countries.setContainerDataSource(ExampleUtil
- .getStaticISO3166Container());
+ countries.setContainerDataSource(ExampleUtil.getISO3166Container());
countries
.setItemCaptionPropertyId(ExampleUtil.iso3166_PROPERTY_NAME);
countries.setItemIconPropertyId(ExampleUtil.iso3166_PROPERTY_FLAG);
Tree tree = new Tree();\r
tree.setContainerDataSource(ExampleUtil.getHardwareContainer());\r
tree.setItemCaptionPropertyId(ExampleUtil.hw_PROPERTY_NAME);\r
- for (Iterator it = tree.rootItemIds().iterator(); it.hasNext();) {\r
+ for (Iterator<?> it = tree.rootItemIds().iterator(); it.hasNext();) {\r
tree.expandItemsRecursively(it.next());\r
}\r
treePanel.addComponent(tree);\r
Tree tree = new Tree();\r
tree.setContainerDataSource(ExampleUtil.getHardwareContainer());\r
tree.setItemCaptionPropertyId(ExampleUtil.hw_PROPERTY_NAME);\r
- for (Iterator it = tree.rootItemIds().iterator(); it.hasNext();) {\r
+ for (Iterator<?> it = tree.rootItemIds().iterator(); it.hasNext();) {\r
tree.expandItemsRecursively(it.next());\r
}\r
addComponent(tree);\r
panel.setHeight("200px"); // we want scrollbars\r
\r
// let's adjust the panels default layout (a VerticalLayout)\r
- VerticalLayout layout = (VerticalLayout) panel.getLayout();\r
+ VerticalLayout layout = (VerticalLayout) panel.getContent();\r
layout.setMargin(true); // we want a margin\r
layout.setSpacing(true); // and spacing between components\r
addComponent(panel);\r
panel.setHeight("200px"); // we want scrollbars\r
\r
// let's adjust the panels default layout (a VerticalLayout)\r
- VerticalLayout layout = (VerticalLayout) panel.getLayout();\r
+ VerticalLayout layout = (VerticalLayout) panel.getContent();\r
layout.setMargin(true); // we want a margin\r
layout.setSpacing(true); // and spacing between components\r
addComponent(panel);\r
\r
// Creates a new combobox using an existing container\r
ComboBox l = new ComboBox("Please select your country", ExampleUtil\r
- .getStaticISO3166Container());\r
+ .getISO3166Container());\r
\r
// Sets the combobox to show a certain property as the item caption\r
l.setItemCaptionPropertyId(ExampleUtil.iso3166_PROPERTY_NAME);\r
* Shows a notification when a selection is made.\r
*/\r
public void valueChange(ValueChangeEvent event) {\r
- Property selected = ExampleUtil.getStaticISO3166Container()\r
+ Property selected = ExampleUtil.getISO3166Container()\r
.getContainerProperty(event.getProperty().toString(), "name");\r
getWindow().showNotification("Selected country: " + selected);\r
}\r
\r
// Creates a new combobox using an existing container\r
ComboBox l = new ComboBox("Please select your country", ExampleUtil\r
- .getStaticISO3166Container());\r
+ .getISO3166Container());\r
\r
// Sets the combobox to show a certain property as the item caption\r
l.setItemCaptionPropertyId(ExampleUtil.iso3166_PROPERTY_NAME);\r
* Shows a notification when a selection is made.\r
*/\r
public void valueChange(ValueChangeEvent event) {\r
- Property selected = ExampleUtil.getStaticISO3166Container()\r
+ Property selected = ExampleUtil.getISO3166Container()\r
.getContainerProperty(event.getProperty().toString(), "name");\r
getWindow().showNotification("Selected country: " + selected);\r
}\r
public class ListSelectSingleExample extends VerticalLayout implements\r
Property.ValueChangeListener {\r
\r
- private static final List cities = Arrays.asList(new String[] { "Berlin",\r
- "Brussels", "Helsinki", "Madrid", "Oslo", "Paris", "Stockholm" });\r
+ private static final List<String> cities = Arrays.asList(new String[] {\r
+ "Berlin", "Brussels", "Helsinki", "Madrid", "Oslo", "Paris",\r
+ "Stockholm" });\r
\r
public ListSelectSingleExample() {\r
setSpacing(true);\r
public void valueChange(ValueChangeEvent event) {
// in multiselect mode, a Set of itemIds is returned,
// in singleselect mode the itemId is returned directly
- Set value = (Set) event.getProperty().getValue();
+ Set<?> value = (Set<?>) event.getProperty().getValue();
if (null == value || value.size() == 0) {
selected.setValue("No selection");
} else {
private VerticalLayout l1;\r
private VerticalLayout l2;\r
private VerticalLayout l3;\r
+ @SuppressWarnings("unused")\r
private Tab t1, t2, t3;\r
\r
public TabSheetDisabledExample() {\r
import com.vaadin.ui.TabSheet;\r
import com.vaadin.ui.VerticalLayout;\r
import com.vaadin.ui.TabSheet.SelectedTabChangeEvent;\r
+import com.vaadin.ui.TabSheet.Tab;\r
\r
@SuppressWarnings("serial")\r
public class TabSheetIconsExample extends VerticalLayout implements\r
}\r
\r
public void selectedTabChange(SelectedTabChangeEvent event) {\r
- String c = t.getTabCaption(event.getTabSheet().getSelectedTab());\r
- getWindow().showNotification("Selected tab: " + c);\r
+ TabSheet tabsheet = event.getTabSheet();\r
+ Tab tab = tabsheet.getTab(tabsheet.getSelectedTab());\r
+ if (tab != null) {\r
+ getWindow().showNotification("Selected tab: " + tab.getCaption());\r
+ }\r
}\r
}\r
import com.vaadin.ui.TabSheet;\r
import com.vaadin.ui.VerticalLayout;\r
import com.vaadin.ui.TabSheet.SelectedTabChangeEvent;\r
+import com.vaadin.ui.TabSheet.Tab;\r
\r
@SuppressWarnings("serial")\r
public class TabSheetScrollingExample extends VerticalLayout implements\r
}\r
\r
public void selectedTabChange(SelectedTabChangeEvent event) {\r
- String c = t.getTabCaption(event.getTabSheet().getSelectedTab());\r
- getWindow().showNotification("Selected tab: " + c);\r
+ TabSheet tabsheet = event.getTabSheet();\r
+ Tab tab = tabsheet.getTab(tabsheet.getSelectedTab());\r
+ if (tab != null) {\r
+ getWindow().showNotification("Selected tab: " + tab.getCaption());\r
+ }\r
}\r
}\r
Tree t = (Tree) event.getProperty();\r
// enable if something is selected, returns a set\r
deleteButton.setEnabled(t.getValue() != null\r
- && ((Set) t.getValue()).size() > 0);\r
+ && ((Set<?>) t.getValue()).size() > 0);\r
}\r
});\r
\r
tree.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY);\r
\r
// Expand whole tree\r
- for (Iterator it = tree.rootItemIds().iterator(); it.hasNext();) {\r
+ for (Iterator<?> it = tree.rootItemIds().iterator(); it.hasNext();) {\r
tree.expandItemsRecursively(it.next());\r
}\r
\r
// Create the 'delete button', inline click-listener\r
deleteButton = new Button("Delete", new Button.ClickListener() {\r
+ @SuppressWarnings("unchecked")\r
public void buttonClick(ClickEvent event) {\r
// Delete all the selected objects\r
Object[] toDelete = ((Set<Object>) tree.getValue()).toArray();\r
class NativeWindow extends Window {\r
NativeWindow() {\r
// Configure the layout\r
- VerticalLayout layout = (VerticalLayout) getLayout();\r
+ VerticalLayout layout = (VerticalLayout) getContent();\r
layout.setMargin(true);\r
layout.setSpacing(true);\r
\r
subwindow = new Window("Automatically sized subwindow");\r
\r
// Configure the windws layout; by default a VerticalLayout\r
- VerticalLayout layout = (VerticalLayout) subwindow.getLayout();\r
+ VerticalLayout layout = (VerticalLayout) subwindow.getContent();\r
layout.setMargin(true);\r
layout.setSpacing(true);\r
// make it undefined for auto-sizing window\r
});\r
\r
// Configure the windws layout; by default a VerticalLayout\r
- VerticalLayout layout = (VerticalLayout) subwindow.getLayout();\r
+ VerticalLayout layout = (VerticalLayout) subwindow.getContent();\r
layout.setMargin(true);\r
layout.setSpacing(true);\r
\r
subwindow = new Window("A subwindow");\r
\r
// Configure the windws layout; by default a VerticalLayout\r
- VerticalLayout layout = (VerticalLayout) subwindow.getLayout();\r
+ VerticalLayout layout = (VerticalLayout) subwindow.getContent();\r
layout.setMargin(true);\r
layout.setSpacing(true);\r
\r
subwindow.setModal(true);\r
\r
// Configure the windws layout; by default a VerticalLayout\r
- VerticalLayout layout = (VerticalLayout) subwindow.getLayout();\r
+ VerticalLayout layout = (VerticalLayout) subwindow.getContent();\r
layout.setMargin(true);\r
layout.setSpacing(true);\r
\r
subwindow.setHeight("200px");\r
\r
// Configure the windws layout; by default a VerticalLayout\r
- VerticalLayout layout = (VerticalLayout) subwindow.getLayout();\r
+ VerticalLayout layout = (VerticalLayout) subwindow.getContent();\r
layout.setMargin(true);\r
layout.setSpacing(true);\r
// make it fill the whole window\r
subwindow.setHeight("80%");\r
\r
// Configure the windws layout; by default a VerticalLayout\r
- VerticalLayout layout = (VerticalLayout) subwindow.getLayout();\r
+ VerticalLayout layout = (VerticalLayout) subwindow.getContent();\r
layout.setMargin(true);\r
layout.setSpacing(true);\r
// make it fill the whole window\r