Skip to content

Commit

Permalink
Fix some generics warnings in Eclipse
Browse files Browse the repository at this point in the history
  • Loading branch information
asashour authored and hesara committed Mar 8, 2017
1 parent f467f3f commit 1290426
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 26 deletions.
Expand Up @@ -210,9 +210,9 @@ public static class DefaultCollectionFactory implements CollectionFactory {
public Collection<?> createCollection( public Collection<?> createCollection(
Class<? extends Collection> type) { Class<? extends Collection> type) {
if (type.isAssignableFrom(ArrayList.class)) { if (type.isAssignableFrom(ArrayList.class)) {
return new ArrayList(); return new ArrayList<Object>();
} else if (type.isAssignableFrom(HashSet.class)) { } else if (type.isAssignableFrom(HashSet.class)) {
return new HashSet(); return new HashSet<Object>();
} else if (!type.isInterface() } else if (!type.isInterface()
&& !Modifier.isAbstract(type.getModifiers())) { && !Modifier.isAbstract(type.getModifiers())) {
try { try {
Expand All @@ -221,7 +221,7 @@ public Collection<?> createCollection(
} catch (IllegalAccessException ignore) { } catch (IllegalAccessException ignore) {
} }
} }
return new ArrayList(); return new ArrayList<Object>();
} }


} }
Expand Down
7 changes: 4 additions & 3 deletions uitest/src/main/java/com/vaadin/tests/RandomLayoutStress.java
Expand Up @@ -20,6 +20,7 @@
import java.util.Random; import java.util.Random;


import com.vaadin.server.ExternalResource; import com.vaadin.server.ExternalResource;
import com.vaadin.shared.ui.datefield.DateResolution;
import com.vaadin.tests.components.TestDateField; import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.AbstractDateField; import com.vaadin.ui.AbstractDateField;
Expand Down Expand Up @@ -184,14 +185,14 @@ private AbstractComponent getRandomComponent(int caption) {
case 6: case 6:
// Datefield // Datefield
result = new TestDateField(); result = new TestDateField();
((AbstractDateField) result).setStyleName("calendar"); ((AbstractDateField<LocalDate, DateResolution>) result).setStyleName("calendar");
((AbstractDateField) result).setValue(LocalDate.now()); ((AbstractDateField<LocalDate, DateResolution>) result).setValue(LocalDate.now());
result.setCaption("Calendar component " + caption); result.setCaption("Calendar component " + caption);
break; break;
case 7: case 7:
// Datefield // Datefield
result = new TestDateField(); result = new TestDateField();
((AbstractDateField) result).setValue(LocalDate.now()); ((AbstractDateField<LocalDate, DateResolution>) result).setValue(LocalDate.now());
result.setCaption("Calendar component " + caption); result.setCaption("Calendar component " + caption);
break; break;
} }
Expand Down
Expand Up @@ -120,7 +120,7 @@ void populateLayout(Layout layout) {
test(layout, button); test(layout, button);
button.addListener(this); button.addListener(this);


final AbstractDateField df = new TestDateField("DateField " + count++); final AbstractDateField<?, ?> df = new TestDateField("DateField " + count++);
test(layout, df); test(layout, df);


final CheckBox cb = new CheckBox("Checkbox " + count++); final CheckBox cb = new CheckBox("Checkbox " + count++);
Expand Down
10 changes: 5 additions & 5 deletions uitest/src/main/java/com/vaadin/tests/TestDateField.java
Expand Up @@ -34,7 +34,7 @@ public class TestDateField extends CustomComponent {


VerticalLayout main = new VerticalLayout(); VerticalLayout main = new VerticalLayout();


AbstractDateField df; AbstractDateField<?, ?> df;


public TestDateField() { public TestDateField() {
setCompositionRoot(main); setCompositionRoot(main);
Expand All @@ -57,22 +57,22 @@ public void createNewView() {
df.addStyleName("thisShouldBeHarmless"); df.addStyleName("thisShouldBeHarmless");


// Another test: locale // Another test: locale
final AbstractDateField df1 = new com.vaadin.tests.components.TestDateField( final AbstractDateField<?, ?> df1 = new com.vaadin.tests.components.TestDateField(
"US locale"); "US locale");
main.addComponent(df1); main.addComponent(df1);
df1.setLocale(new Locale("en", "US")); df1.setLocale(new Locale("en", "US"));


final AbstractDateField df2 = new com.vaadin.tests.components.TestDateField( final AbstractDateField<?, ?> df2 = new com.vaadin.tests.components.TestDateField(
"DE locale"); "DE locale");
main.addComponent(df2); main.addComponent(df2);
df2.setLocale(new Locale("de", "DE")); df2.setLocale(new Locale("de", "DE"));


final AbstractDateField df3 = new com.vaadin.tests.components.TestDateField( final AbstractDateField<?, ?> df3 = new com.vaadin.tests.components.TestDateField(
"RU locale"); "RU locale");
main.addComponent(df3); main.addComponent(df3);
df3.setLocale(new Locale("ru", "RU")); df3.setLocale(new Locale("ru", "RU"));


final AbstractDateField df4 = new com.vaadin.tests.components.TestDateField( final AbstractDateField<?, ?> df4 = new com.vaadin.tests.components.TestDateField(
"FI locale"); "FI locale");
main.addComponent(df4); main.addComponent(df4);
df4.setLocale(new Locale("fi", "FI")); df4.setLocale(new Locale("fi", "FI"));
Expand Down
4 changes: 2 additions & 2 deletions uitest/src/main/java/com/vaadin/tests/TestForAlignments.java
Expand Up @@ -37,8 +37,8 @@ public TestForAlignments() {
final Button b4 = new Button("Top"); final Button b4 = new Button("Top");
final TextField t1 = new TextField("Right aligned"); final TextField t1 = new TextField("Right aligned");
final TextField t2 = new TextField("Bottom aligned"); final TextField t2 = new TextField("Bottom aligned");
final AbstractDateField d1 = new TestDateField("Center aligned"); final AbstractDateField<?, ?> d1 = new TestDateField("Center aligned");
final AbstractDateField d2 = new TestDateField("Center aligned"); final AbstractDateField<?, ?> d2 = new TestDateField("Center aligned");


final VerticalLayout vert = new VerticalLayout(); final VerticalLayout vert = new VerticalLayout();
vert.addComponent(b1); vert.addComponent(b1);
Expand Down
Expand Up @@ -16,6 +16,7 @@


package com.vaadin.tests; package com.vaadin.tests;


import java.time.LocalDate;
import java.util.Locale; import java.util.Locale;


import com.vaadin.server.Sizeable; import com.vaadin.server.Sizeable;
Expand Down Expand Up @@ -82,7 +83,7 @@ public void buttonClick(ClickEvent event) {
controls.addComponent(click); controls.addComponent(click);
controls.addComponent(click2); controls.addComponent(click2);
reportLayout.addComponent(controls); reportLayout.addComponent(controls);
final AbstractDateField cal = new TestDateField(); final AbstractDateField<LocalDate, DateResolution> cal = new TestDateField();
cal.setResolution(DateResolution.DAY); cal.setResolution(DateResolution.DAY);
cal.setLocale(new Locale("en", "US")); cal.setLocale(new Locale("en", "US"));
reportLayout.addComponent(cal); reportLayout.addComponent(cal);
Expand Down
Expand Up @@ -48,7 +48,7 @@ protected void setup() {
TextField tf = new TextField("TextField"); TextField tf = new TextField("TextField");
l.addComponent(tf); l.addComponent(tf);


AbstractDateField df = new TestDateField("DateField"); AbstractDateField<?, ?> df = new TestDateField("DateField");
l.addComponent(df); l.addComponent(df);


ComboBox cb = new ComboBox("ComboBox"); ComboBox cb = new ComboBox("ComboBox");
Expand Down
Expand Up @@ -95,7 +95,7 @@ protected Integer getTicketNumber() {


@Override @Override
public void valueChange(ValueChangeEvent event) { public void valueChange(ValueChangeEvent event) {
AbstractField field = (AbstractField) event.getProperty(); AbstractField<?> field = (AbstractField<?>) event.getProperty();
// if (field == localeSelect) { // if (field == localeSelect) {
// return; // return;
// } // }
Expand Down
Expand Up @@ -39,7 +39,7 @@ protected void setup(VaadinRequest request) {
gl.setWidth("100%"); gl.setWidth("100%");
panel.setContent(gl); panel.setContent(gl);


final AbstractDateField df = new TestDateField(); final AbstractDateField<?, ?> df = new TestDateField();
df.setWidth("100%"); df.setWidth("100%");
gl.addComponent(df); gl.addComponent(df);


Expand Down
Expand Up @@ -152,7 +152,7 @@ public Object generateCell(Table components, Object o, Object o2) {
table.addGeneratedColumn("First_Name" + 4, new Table.ColumnGenerator() { table.addGeneratedColumn("First_Name" + 4, new Table.ColumnGenerator() {
@Override @Override
public Object generateCell(Table components, Object o, Object o2) { public Object generateCell(Table components, Object o, Object o2) {
AbstractDateField b = new TestDateField("DateField"); AbstractDateField<?, ?> b = new TestDateField("DateField");
b.setWidthUndefined(); b.setWidthUndefined();
return b; return b;
} }
Expand Down
Expand Up @@ -2,6 +2,7 @@


import java.time.LocalDate; import java.time.LocalDate;


import com.vaadin.shared.ui.datefield.DateResolution;
import com.vaadin.tests.components.TestDateField; import com.vaadin.tests.components.TestDateField;
import com.vaadin.tests.components.uitest.TestSampler; import com.vaadin.tests.components.uitest.TestSampler;
import com.vaadin.ui.AbstractDateField; import com.vaadin.ui.AbstractDateField;
Expand All @@ -28,7 +29,7 @@ public DatesCssTest(TestSampler parent) {
createDateFieldWith("Small", ChameleonTheme.DATEFIELD_SMALL, null); createDateFieldWith("Small", ChameleonTheme.DATEFIELD_SMALL, null);
createDateFieldWith("Big", ChameleonTheme.DATEFIELD_BIG, null); createDateFieldWith("Big", ChameleonTheme.DATEFIELD_BIG, null);


AbstractDateField df = new DateField("Popup date field"); AbstractDateField<LocalDate, DateResolution> df = new DateField("Popup date field");
df.setId("datefield" + debugIdCounter++); df.setId("datefield" + debugIdCounter++);
df.setValue(date); df.setValue(date);
addComponent(df); addComponent(df);
Expand All @@ -47,7 +48,7 @@ public DatesCssTest(TestSampler parent) {


private void createDateFieldWith(String caption, String primaryStyleName, private void createDateFieldWith(String caption, String primaryStyleName,
String width) { String width) {
AbstractDateField df = new TestDateField("Date field"); AbstractDateField<LocalDate, DateResolution> df = new TestDateField("Date field");
df.setId("datefield" + debugIdCounter++); df.setId("datefield" + debugIdCounter++);
df.setValue(date); df.setValue(date);


Expand Down
Expand Up @@ -51,7 +51,7 @@ public DateFields() {
row.addStyleName(ValoTheme.LAYOUT_HORIZONTAL_WRAPPING); row.addStyleName(ValoTheme.LAYOUT_HORIZONTAL_WRAPPING);
addComponent(row); addComponent(row);


AbstractDateField date = new TestDateField("Default resolution"); AbstractDateField<LocalDate, DateResolution> date = new TestDateField("Default resolution");
setDate(date); setDate(date);
row.addComponent(date); row.addComponent(date);


Expand Down Expand Up @@ -188,14 +188,14 @@ public void buttonClick(ClickEvent event) {
row.addComponent(form); row.addComponent(form);
} }


private void setDateRange(AbstractDateField date) { private void setDateRange(AbstractDateField<LocalDate, DateResolution> date) {
date.setRangeStart(getDefaultDate()); date.setRangeStart(getDefaultDate());


LocalDate endDate = getDefaultDate(); LocalDate endDate = getDefaultDate();
date.setRangeEnd(endDate.plusMonths(1)); date.setRangeEnd(endDate.plusMonths(1));
} }


private void setDate(AbstractDateField date) { private void setDate(AbstractDateField<LocalDate, DateResolution> date) {
date.setValue(getDefaultDate()); date.setValue(getDefaultDate());
} }


Expand Down
3 changes: 2 additions & 1 deletion uitest/src/main/java/com/vaadin/tests/themes/valo/Forms.java
Expand Up @@ -21,6 +21,7 @@
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.server.UserError; import com.vaadin.server.UserError;
import com.vaadin.shared.ui.MarginInfo; import com.vaadin.shared.ui.MarginInfo;
import com.vaadin.shared.ui.datefield.DateResolution;
import com.vaadin.tests.components.TestDateField; import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField; import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.Alignment; import com.vaadin.ui.Alignment;
Expand Down Expand Up @@ -73,7 +74,7 @@ public Forms() {
name.setWidth("50%"); name.setWidth("50%");
form.addComponent(name); form.addComponent(name);


AbstractDateField birthday = new TestDateField("Birthday"); AbstractDateField<LocalDate, DateResolution> birthday = new TestDateField("Birthday");
birthday.setValue(LocalDate.of(1980, 1, 31)); birthday.setValue(LocalDate.of(1980, 1, 31));
form.addComponent(birthday); form.addComponent(birthday);


Expand Down
Expand Up @@ -199,7 +199,7 @@ public Object generateCell(Table source, Object itemId,
@Override @Override
public Object generateCell(Table source, Object itemId, public Object generateCell(Table source, Object itemId,
Object columnId) { Object columnId) {
AbstractDateField tf = new TestDateField(); AbstractDateField<?, ?> tf = new TestDateField();
tf.addStyleName(ValoTheme.TABLE_COMPACT); tf.addStyleName(ValoTheme.TABLE_COMPACT);
if ((Integer) itemId % 2 == 0) { if ((Integer) itemId % 2 == 0) {
tf.addStyleName(ValoTheme.DATEFIELD_BORDERLESS); tf.addStyleName(ValoTheme.DATEFIELD_BORDERLESS);
Expand Down

0 comments on commit 1290426

Please sign in to comment.