\r
}\r
\r
+ @SuppressWarnings("unchecked")\r
public void handleRenderRequest(RenderRequest request,\r
RenderResponse response) {\r
// Portlet up-and-running, enable stuff\r
import com.vaadin.ui.Window;
import com.vaadin.ui.Button.ClickEvent;
+@SuppressWarnings("serial")
public class SimpleAddressBook extends Application {
private static String[] fields = { "First Name", "Last Name", "Company",
"Mobile Phone", "Work Phone", "Home Phone", "Work Email",
"Home Email", "Street", "Zip", "City", "State", "Country" };
- private static String[] visibleCols = new String[] { "Last Name", "First Name",
- "Company" };
+ private static String[] visibleCols = new String[] { "Last Name",
+ "First Name", "Company" };
private Table contactList = new Table();
private Form contactEditor = new Form();
private Button contactRemovalButton;
private IndexedContainer addressBookData = createDummyData();
+ @Override
public void init() {
initLayout();
initContactAddRemoveButtons();
contactEditor.setImmediate(true);
bottomLeftCorner.setWidth("100%");
left.addComponent(bottomLeftCorner);
- }
+ }
private void initContactAddRemoveButtons() {
// New item button
- bottomLeftCorner.addComponent(new Button("+", new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- Object id = contactList.addItem();
- contactList.setValue(id);
- }
- }));
+ bottomLeftCorner.addComponent(new Button("+",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ Object id = contactList.addItem();
+ contactList.setValue(id);
+ }
+ }));
// Remove item button
contactRemovalButton = new Button("-", new Button.ClickListener() {
sf.addListener(new Property.ValueChangeListener() {
public void valueChange(ValueChangeEvent event) {
addressBookData.removeContainerFilters(pn);
- if (sf.toString().length() > 0 && !pn.equals(sf.toString()))
+ if (sf.toString().length() > 0 && !pn.equals(sf.toString())) {
addressBookData.addContainerFilter(pn, sf.toString(),
true, false);
+ }
getMainWindow().showNotification(
"" + addressBookData.size() + " matches found");
}
});
}
}
+
private static IndexedContainer createDummyData() {
String[] fnames = { "Peter", "Alice", "Joshua", "Mike", "Olivia",
IndexedContainer ic = new IndexedContainer();
- for (String p : fields)
+ for (String p : fields) {
ic.addContainerProperty(p, String.class, "");
+ }
for (int i = 0; i < 1000; i++) {
Object id = ic.addItem();
*/
// Main (browser) window, needed in all Vaadin applications
- final Window root = new Window("VaadinTunes");
+ VerticalLayout rootLayout = new VerticalLayout();
+ final Window root = new Window("VaadinTunes", rootLayout);
/*
* We'll attach the window to the browser view already here, so we won't
"This is an example of how you can do layouts in Vaadin.<br/>It is not a working sound player.",
Notification.TYPE_HUMANIZED_MESSAGE);
- // Our root window contains one VerticalLayout by default, let's make
+ // Our root window contains one VerticalLayout, let's make
// sure it's 100% sized, and remove unwanted margins
- root.getContent().setSizeFull();
- root.getLayout().setMargin(false);
+ rootLayout.setSizeFull();
+ rootLayout.setMargin(false);
// Top area, containing playback and volume controls, play status, view
// modes and search
/** The property value of the field is a String. */
@Override
- public Class getType() {
+ public Class<?> getType() {
return String.class;
}
}
/** Deserialize changes received from client. */
+ @SuppressWarnings("unchecked")
@Override
public void changeVariables(Object source, Map variables) {
// Sets the currently selected color
public class ColorPickerWidgetSet extends DefaultWidgetSet {\r
/** Resolves UIDL tag name to widget class. */\r
@Override\r
- protected Class resolveWidgetType(UIDL uidl) {\r
+ protected Class<?> resolveWidgetType(UIDL uidl) {\r
final String tag = uidl.getTag();\r
if ("colorpicker".equals(tag)) {\r
return VColorPicker.class;\r
/** Creates a widget instance according to its class object. */\r
@Override\r
public Paintable createWidget(UIDL uidl) {\r
- final Class type = resolveWidgetType(uidl);\r
+ final Class<?> type = resolveWidgetType(uidl);\r
if (VColorPicker.class == type) {\r
return new VColorPicker();\r
}\r
import com.vaadin.terminal.PaintTarget;
import com.vaadin.ui.AbstractSelect;
-@SuppressWarnings("serial")
+@SuppressWarnings( { "serial", "unchecked" })
public class Coverflow extends AbstractSelect {
private String backgroundGradientStart = "FFFFFF";
/** Creates a widget according to its class name. */
@Override
public Paintable createWidget(UIDL uidl) {
- final Class classType = resolveWidgetType(uidl);
+ final Class<?> classType = resolveWidgetType(uidl);
if (VCoverflow.class == classType) {
return new VCoverflow();
}
/** Resolves UIDL tag name to class . */
@Override
- protected Class resolveWidgetType(UIDL uidl) {
+ protected Class<?> resolveWidgetType(UIDL uidl) {
final String tag = uidl.getTag();
if ("cover".equals(tag)) {
return VCoverflow.class;
public class VCoverflow extends Composite implements Paintable {
private String uidlId;
protected ApplicationConnection client;
- private ArrayList coverList = new ArrayList();
+ private ArrayList<HashMap<String, String>> coverList = new ArrayList<HashMap<String, String>>();
private Object _selected;
private boolean flashInited = false;
private String backgroundGradientEnd;
private boolean colorChanged = false;
private boolean sbVisibilityChanged = false;
- private HashMap keyMap = new HashMap();
+ private HashMap<String, String> keyMap = new HashMap<String, String>();
/**
* Constructor
// should
// be deleted.
- ArrayList newList = new ArrayList();
+ ArrayList<HashMap<String, String>> newList = new ArrayList<HashMap<String, String>>();
// Iterate through all option elements
- for (final Iterator i = images.getChildIterator(); i.hasNext();) {
+ for (final Iterator<Object> i = images.getChildIterator(); i.hasNext();) {
final UIDL imgUidl = (UIDL) i.next();
// Make sure all required attributes exist
if (imgUidl.hasAttribute("caption") && imgUidl.hasAttribute("key")
&& imgUidl.hasAttribute("icon")) {
- HashMap set = new HashMap();
+ HashMap<String, String> set = new HashMap<String, String>();
// Update the key map
keyMap.put(imgUidl.getStringAttribute("caption"), imgUidl
}
// Deleted items
- ArrayList intersectList = new ArrayList();
+ ArrayList<HashMap<String, String>> intersectList = new ArrayList<HashMap<String, String>>();
intersectList.addAll(coverList);
intersectList.removeAll(newList);
if (flashInited) {
for (int i = 0; i < intersectList.size(); i++) {
- HashMap cover = (HashMap) intersectList.get(i);
- removeCover(uidlId, cover.get("caption").toString());
+ HashMap<String, String> cover = intersectList.get(i);
+ removeCover(uidlId, cover.get("caption"));
}
}
// Added items
- intersectList = new ArrayList();
+ intersectList = new ArrayList<HashMap<String, String>>();
intersectList.addAll(newList);
intersectList.removeAll(coverList);
if (flashInited) {
for (int i = 0; i < intersectList.size(); i++) {
- HashMap cover = (HashMap) intersectList.get(i);
- addCover(uidlId, cover.get("caption").toString(), cover.get(
- "icon").toString());
+ HashMap<String, String> cover = intersectList.get(i);
+ addCover(uidlId, cover.get("caption"), cover.get("icon"));
}
}
return;
}
- client.updateVariable(uidlId, "selected", new String[] { keyMap.get(
- coverId).toString() }, true);
+ client.updateVariable(uidlId, "selected", new String[] { keyMap
+ .get(coverId) }, true);
}
/**
* id
*/
public native void initializeMethods(String id) /*-{
- var app = this;
-
- if($wnd.vaadin.coverflow == null)
- var coverflow = [];
- else
- var coverflow = $wnd.vaadin.coverflow;
-
- coverflow['getCovers_' + id] = function() {
- app.@com.vaadin.demo.coverflow.gwt.client.ui.VCoverflow::getCovers()();
- };
-
- coverflow['setCurrent_' + id] = function(selected) {
- app.@com.vaadin.demo.coverflow.gwt.client.ui.VCoverflow::setCover(Ljava/lang/String;)(selected);
- };
-
- $wnd.vaadin.coverflow = coverflow;
- }-*/;
+ var app = this;
+
+ if($wnd.vaadin.coverflow == null)
+ var coverflow = [];
+ else
+ var coverflow = $wnd.vaadin.coverflow;
+
+ coverflow['getCovers_' + id] = function() {
+ app.@com.vaadin.demo.coverflow.gwt.client.ui.VCoverflow::getCovers()();
+ };
+
+ coverflow['setCurrent_' + id] = function(selected) {
+ app.@com.vaadin.demo.coverflow.gwt.client.ui.VCoverflow::setCover(Ljava/lang/String;)(selected);
+ };
+
+ $wnd.vaadin.coverflow = coverflow;
+ }-*/;
/**
* This function sends all covers to the flash. We cannot do this directly
* it's ready.
*/
public void getCovers() {
- // Loop through all stored coves
+ // Loop through all stored covers
for (int i = 0; i < coverList.size(); i++) {
- HashMap set = (HashMap) coverList.get(i);
+ HashMap<String, String> set = coverList.get(i);
try {
// Add the cover
- addCover(uidlId, set.get("caption").toString(), set.get("icon")
- .toString());
+ addCover(uidlId, set.get("caption"), set.get("icon"));
} catch (Exception e) {
// Do not add covers lacking obligatory data
}
* @param icon
*/
public native void addCover(String id, String caption, String icon) /*-{
- try {
- $doc['fxcoverflow' + id].addCover(caption.toString(), icon.toString());
- }
- catch(e) {
- $wnd.alert(e.message);
- }
-
- }-*/;
+ try {
+ $doc['fxcoverflow' + id].addCover(caption.toString(), icon.toString());
+ }
+ catch(e) {
+ $wnd.alert(e.message);
+ }
+
+ }-*/;
/**
* This function tells the flash which cover should be selected.
* @param key
*/
public native void selectCover(String id, String key) /*-{
- $doc["fxcoverflow" + id].selectCover(key.toString());
- }-*/;
+ $doc["fxcoverflow" + id].selectCover(key.toString());
+ }-*/;
public native void setBackgroundColor(String id, String startGradient,
String endGradient) /*-{
- $doc["fxcoverflow" + id].setBackgroundColor("0x" + startGradient.toString(), "0x" + endGradient.toString());
- }-*/;
+ $doc["fxcoverflow" + id].setBackgroundColor("0x" + startGradient.toString(), "0x" + endGradient.toString());
+ }-*/;
public native void toggleScrollbarVisibility(String id, boolean visibility) /*-{
- $doc["fxcoverflow" + id].toggleScrollbarVisibility(visibility);
- }-*/;
+ $doc["fxcoverflow" + id].toggleScrollbarVisibility(visibility);
+ }-*/;
public native void removeCover(String id, String key) /*-{
- $doc["fxcoverflow" + id].removeCover(key);
- }-*/;
+ $doc["fxcoverflow" + id].removeCover(key);
+ }-*/;
/**
* Set the HTML coding of the flash movie. This isn't done until the
import java.util.Date;\r
import java.util.Iterator;\r
import java.util.LinkedList;\r
-import java.util.List;\r
\r
import com.vaadin.Application;\r
import com.vaadin.data.Container;\r
this, "selectedResourcesChanged");\r
reservationTab.addComponent(resourcePanel);\r
\r
+ HorizontalLayout reservationLayout = new HorizontalLayout();\r
final Panel reservationPanel = new Panel("Reservation",\r
- new HorizontalLayout());\r
+ reservationLayout);\r
reservationPanel.addStyleName(Panel.STYLE_LIGHT);\r
- reservationPanel.getLayout().setMargin(true);\r
+ reservationLayout.setMargin(true);\r
reservationTab.addComponent(reservationPanel);\r
\r
final VerticalLayout infoLayout = new VerticalLayout();\r
}\r
\r
private Item getActiveResource() throws ResourceNotAvailableException {\r
- final List rids = resourcePanel.getSelectedResources();\r
+ final LinkedList<Item> rids = resourcePanel.getSelectedResources();\r
if (rids != null && rids.size() > 0) {\r
- for (final Iterator it = rids.iterator(); it.hasNext();) {\r
- final Item resource = (Item) it.next();\r
+ for (final Iterator<Item> it = rids.iterator(); it.hasNext();) {\r
+ final Item resource = it.next();\r
final int id = ((Integer) resource.getItemProperty(\r
SampleDB.Resource.PROPERTY_ID_ID).getValue())\r
.intValue();\r
resourceName.setCaption(name);\r
resourceName.setValue(desc);\r
// Put all resources on map (may be many if category was selected)\r
- final LinkedList srs = resourcePanel.getSelectedResources();\r
- for (final Iterator it = srs.iterator(); it.hasNext();) {\r
- resource = (Item) it.next();\r
+ final LinkedList<Item> srs = resourcePanel.getSelectedResources();\r
+ for (final Iterator<Item> it = srs.iterator(); it.hasNext();) {\r
+ resource = it.next();\r
name = (String) resource.getItemProperty(\r
SampleDB.Resource.PROPERTY_ID_NAME).getValue();\r
desc = (String) resource.getItemProperty(\r
import com.vaadin.ui.VerticalLayout;\r
import com.vaadin.ui.Button.ClickEvent;\r
\r
-@SuppressWarnings( { "serial", "unchecked" })\r
+@SuppressWarnings("serial")\r
public class ResourceSelectorPanel extends Panel implements\r
Button.ClickListener {\r
- private final HashMap categoryLayouts = new HashMap();\r
- private final HashMap categoryResources = new HashMap();\r
+ private final HashMap<String, Layout> categoryLayouts = new HashMap<String, Layout>();\r
+ private final HashMap<String, LinkedList<Item>> categoryResources = new HashMap<String, LinkedList<Item>>();\r
\r
// private Container allResources;\r
- private LinkedList selectedResources = null;\r
+ private LinkedList<Item> selectedResources = null;\r
\r
public ResourceSelectorPanel(String caption) {\r
super(caption, new HorizontalLayout());\r
categoryLayouts.clear();\r
categoryResources.clear();\r
if (resources != null && resources.size() > 0) {\r
- for (final Iterator it = resources.getItemIds().iterator(); it\r
+ for (final Iterator<?> it = resources.getItemIds().iterator(); it\r
.hasNext();) {\r
final Item resource = resources.getItem(it.next());\r
// final Integer id = (Integer) resource.getItemProperty(\r
rButton.setStyleName("link");\r
rButton.setDescription(description);\r
rButton.setData(resource);\r
- Layout resourceLayout = (Layout) categoryLayouts.get(category);\r
- LinkedList resourceList = (LinkedList) categoryResources\r
- .get(category);\r
+ Layout resourceLayout = categoryLayouts.get(category);\r
+ LinkedList<Item> resourceList = categoryResources.get(category);\r
if (resourceLayout == null) {\r
resourceLayout = new VerticalLayout();\r
resourceLayout.setSizeUndefined();\r
resourceLayout.setMargin(true);\r
addComponent(resourceLayout);\r
categoryLayouts.put(category, resourceLayout);\r
- resourceList = new LinkedList();\r
+ resourceList = new LinkedList<Item>();\r
categoryResources.put(category, resourceList);\r
final Button cButton = new Button(category + " (any)", this);\r
cButton.setStyleName("important-link");\r
}\r
}\r
\r
- // Selects one initial categore, inpractice randomly\r
+ // Selects one initial category, in practice randomly\r
public void selectFirstCategory() {\r
try {\r
- final Object catId = categoryResources.keySet().iterator().next();\r
- final LinkedList res = (LinkedList) categoryResources.get(catId);\r
- final Layout l = (Layout) categoryLayouts.get(catId);\r
+ final String catId = categoryResources.keySet().iterator().next();\r
+ final LinkedList<Item> res = categoryResources.get(catId);\r
+ final Layout l = categoryLayouts.get(catId);\r
final Button catB = (Button) l.getComponentIterator().next();\r
setSelectedResources(res);\r
catB.setStyleName("selected-link");\r
}\r
}\r
\r
- private void setSelectedResources(LinkedList resources) {\r
+ private void setSelectedResources(LinkedList<Item> resources) {\r
selectedResources = resources;\r
fireEvent(new SelectedResourcesChangedEvent());\r
}\r
\r
- public LinkedList getSelectedResources() {\r
+ public LinkedList<Item> getSelectedResources() {\r
return selectedResources;\r
}\r
\r
final Object data = ((Button) source).getData();\r
resetStyles();\r
if (data instanceof Item) {\r
- final LinkedList rlist = new LinkedList();\r
- rlist.add(data);\r
+ final LinkedList<Item> rlist = new LinkedList<Item>();\r
+ rlist.add((Item) data);\r
setSelectedResources(rlist);\r
} else {\r
final String category = (String) data;\r
- final LinkedList resources = (LinkedList) categoryResources\r
+ final LinkedList<Item> resources = categoryResources\r
.get(category);\r
setSelectedResources(resources);\r
}\r
}\r
\r
private void resetStyles() {\r
- for (final Iterator it = categoryLayouts.values().iterator(); it\r
+ for (final Iterator<Layout> it = categoryLayouts.values().iterator(); it\r
.hasNext();) {\r
- final Layout lo = (Layout) it.next();\r
- for (final Iterator bit = lo.getComponentIterator(); bit.hasNext();) {\r
+ final Layout lo = it.next();\r
+ for (final Iterator<?> bit = lo.getComponentIterator(); bit\r
+ .hasNext();) {\r
final Button b = (Button) bit.next();\r
if (b.getData() instanceof Item) {\r
b.setStyleName("link");\r
public class ReservationWidgetSet extends DefaultWidgetSet {\r
@Override\r
public Paintable createWidget(UIDL uidl) {\r
- final Class type = resolveWidgetType(uidl);\r
+ final Class<?> type = resolveWidgetType(uidl);\r
if (VGoogleMap.class == type) {\r
return new VGoogleMap();\r
} else if (VCalendarField.class == type) {\r
}\r
\r
@Override\r
- protected Class resolveWidgetType(UIDL uidl) {\r
+ protected Class<?> resolveWidgetType(UIDL uidl) {\r
final String tag = uidl.getTag();\r
if ("googlemap".equals(tag)) {\r
return VGoogleMap.class;\r
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
widget.clearOverlays();\r
LatLng pos = null;\r
- for (final Iterator it = uidl.getChildIterator(); it.hasNext();) {\r
+ for (final Iterator<Object> it = uidl.getChildIterator(); it.hasNext();) {\r
final UIDL u = (UIDL) it.next();\r
if (u.getTag().equals("markers")) {\r
\r
- for (final Iterator m = u.getChildIterator(); m.hasNext();) {\r
+ for (final Iterator<Object> m = u.getChildIterator(); m\r
+ .hasNext();) {\r
final UIDL umarker = (UIDL) m.next();\r
final String html = "<span>"\r
+ umarker.getStringAttribute("html") + "</span>";\r
import com.vaadin.terminal.gwt.server.PortletApplicationContext.PortletListener;
import com.vaadin.ui.Button;
import com.vaadin.ui.ComponentContainer;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
@Override
public void init() {
- final Window w = new Window("Simple Reserver");
+ VerticalLayout rootLayout = new VerticalLayout();
+ final Window w = new Window("Simple Reserver", rootLayout);
w.addStyleName("simplereserver");
if (getContext() instanceof PortletApplicationContext) {
});
w.setTheme("liferay");
// portal will deal outer margins
- w.getLayout().setMargin(false);
+ rootLayout.setMargin(false);
} else {
w.setTheme("reservr");
}
add.setEnabled(false);
reservations.setEnabled(false);
} else {
- List resource = new LinkedList();
+ List<Item> resource = new LinkedList<Item>();
resource.add(resources.getItem(resources.getValue()));
final Container res = application.getDb().getReservations(resource);
reservations.setContainerDataSource(res);
import com.vaadin.ui.Component;
import com.vaadin.ui.Link;
import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
@SuppressWarnings("serial")
public class ActiveLink extends Link {
private static final Method LINK_FOLLOWED_METHOD;
- private HashSet listeners = new HashSet();
+ private HashSet<LinkActivatedListener> listeners = new HashSet<LinkActivatedListener>();
public ActiveLink() {
super();
* @param listener
* the Listener to be removed.
*/
- public void removeListener(ClickListener listener) {
+ public void removeListener(LinkActivatedListener listener) {
listeners.remove(listener);
removeListener(ClickEvent.class, listener, LINK_FOLLOWED_METHOD);
if (listeners.size() == 0) {
}
}
+ @SuppressWarnings("unchecked")
@Override
public void changeVariables(Object source, Map variables) {
super.changeVariables(source, variables);
addComponent(left);
setExpandRatio(left, 1);
- right = new Panel();
- right.getLayout().setMargin(true, false, false, false);
+ VerticalLayout rightLayout = new VerticalLayout();
+ right = new Panel(rightLayout);
+ rightLayout.setMargin(true, false, false, false);
right.setStyleName(Panel.STYLE_LIGHT);
right.addStyleName("feature-info");
right.setWidth("369px");
caption.setWidth("100%");
rel.addComponent(caption);
rel.setMargin(false, false, true, false);
- for (Class c : features) {
+ for (Class<? extends Feature> c : features) {
final Feature f = SamplerApplication.getFeatureFor(c);
if (f != null) {
String path = SamplerApplication.getPathFor(f);
@Override
public Paintable createWidget(UIDL uidl) {
- final Class classType = resolveWidgetType(uidl);
+ final Class<?> classType = resolveWidgetType(uidl);
if (VGoogleAnalytics.class == classType) {
return new VGoogleAnalytics();
} else if (VCodeLabel.class == classType) {
}
@Override
- protected Class resolveWidgetType(UIDL uidl) {
+ protected Class<?> resolveWidgetType(UIDL uidl) {
final String tag = uidl.getTag();
if ("googleanalytics".equals(tag)) {
return VGoogleAnalytics.class;