Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support non-AbstractFieldConnector fields with Grid Editor (#19440)
Change-Id: Ib3eaf0b35cfe88391c8ab3b5fcbe668d67c2dd3c
- Loading branch information
Teemu Suo-Anttila
authored and
Vaadin Code Review
committed
Jan 7, 2016
1 parent
bdec494
commit c752035
Showing
3 changed files
with
197 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
154 changes: 154 additions & 0 deletions
154
uitest/src/com/vaadin/tests/components/grid/GridWithLabelEditor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
/* | ||
* Copyright 2000-2014 Vaadin Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package com.vaadin.tests.components.grid; | ||
|
||
import java.util.Collection; | ||
|
||
import com.vaadin.data.Validator; | ||
import com.vaadin.data.Validator.InvalidValueException; | ||
import com.vaadin.server.VaadinRequest; | ||
import com.vaadin.tests.components.AbstractTestUI; | ||
import com.vaadin.ui.Field; | ||
import com.vaadin.ui.Grid; | ||
import com.vaadin.ui.Label; | ||
|
||
public class GridWithLabelEditor extends AbstractTestUI { | ||
|
||
public class LabelEditor extends Label implements Field<String> { | ||
|
||
@Override | ||
public void focus() { | ||
super.focus(); | ||
} | ||
|
||
@Override | ||
public boolean isInvalidCommitted() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void setInvalidCommitted(boolean isCommitted) { | ||
} | ||
|
||
@Override | ||
public void commit() throws SourceException, InvalidValueException { | ||
} | ||
|
||
@Override | ||
public void discard() throws SourceException { | ||
} | ||
|
||
@Override | ||
public void setBuffered(boolean buffered) { | ||
} | ||
|
||
@Override | ||
public boolean isBuffered() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean isModified() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void addValidator(Validator validator) { | ||
} | ||
|
||
@Override | ||
public void removeValidator(Validator validator) { | ||
} | ||
|
||
@Override | ||
public void removeAllValidators() { | ||
} | ||
|
||
@Override | ||
public Collection<Validator> getValidators() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean isValid() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void validate() throws InvalidValueException { | ||
} | ||
|
||
@Override | ||
public boolean isInvalidAllowed() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void setInvalidAllowed(boolean invalidValueAllowed) | ||
throws UnsupportedOperationException { | ||
} | ||
|
||
@Override | ||
public int getTabIndex() { | ||
return -1; | ||
} | ||
|
||
@Override | ||
public void setTabIndex(int tabIndex) { | ||
} | ||
|
||
@Override | ||
public boolean isRequired() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void setRequired(boolean required) { | ||
} | ||
|
||
@Override | ||
public void setRequiredError(String requiredMessage) { | ||
} | ||
|
||
@Override | ||
public String getRequiredError() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean isEmpty() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void clear() { | ||
} | ||
|
||
} | ||
|
||
@Override | ||
protected void setup(VaadinRequest request) { | ||
Grid grid = new Grid(); | ||
addComponent(grid); | ||
|
||
grid.setEditorEnabled(true); | ||
grid.addColumn("Foo", String.class).setEditorField(new LabelEditor()); | ||
grid.addRow("FooFoo"); | ||
|
||
grid.editItem(grid.getContainerDataSource().firstItemId()); | ||
} | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
uitest/src/com/vaadin/tests/components/grid/GridWithLabelEditorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright 2000-2014 Vaadin Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package com.vaadin.tests.components.grid; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.Test; | ||
|
||
import com.vaadin.testbench.elements.GridElement; | ||
import com.vaadin.tests.tb3.SingleBrowserTest; | ||
|
||
public class GridWithLabelEditorTest extends SingleBrowserTest { | ||
|
||
@Test | ||
public void testNoExceptionOnEdit() { | ||
setDebug(true); | ||
openTestURL(); | ||
|
||
assertNoErrorNotifications(); | ||
|
||
assertEquals("LabelEditor content not correct.", "FooFoo", | ||
$(GridElement.class).first().getEditor().getField(0).getText()); | ||
} | ||
} |