forked from vaadin/touchkit
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from dve/v7-compatibility
V7 compatibility
- Loading branch information
Showing
52 changed files
with
610 additions
and
685 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
...uchkit/extensions/Html5InputSettings.java → ...kit/v7/extensions/Html5InputSettings.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
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
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
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...ent/vcom/Html5InputSettingsConnector.java → ...ent/vcom/Html5InputSettingsConnector.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
2 changes: 1 addition & 1 deletion
2
.../client/vcom/Html5InputSettingsState.java → .../client/vcom/Html5InputSettingsState.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
90 changes: 90 additions & 0 deletions
90
...src/main/java/org/vaadin/touchkit/v7/gwt/client/vcom/VerticalComponentGroupConnector.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,90 @@ | ||
package org.vaadin.touchkit.v7.gwt.client.vcom; | ||
|
||
import java.util.List; | ||
|
||
import org.vaadin.touchkit.gwt.client.ui.VerticalComponentGroupWidget; | ||
import org.vaadin.touchkit.v7.ui.VerticalComponentGroup; | ||
|
||
import com.google.gwt.core.client.GWT; | ||
import com.google.gwt.user.client.ui.Widget; | ||
import com.vaadin.client.ComponentConnector; | ||
import com.vaadin.client.ConnectorHierarchyChangeEvent; | ||
import com.vaadin.client.communication.StateChangeEvent; | ||
import com.vaadin.client.ui.AbstractLayoutConnector; | ||
import com.vaadin.client.ui.Icon; | ||
import com.vaadin.shared.ComponentConstants; | ||
import com.vaadin.shared.communication.URLReference; | ||
import com.vaadin.shared.ui.ComponentStateUtil; | ||
import com.vaadin.shared.ui.Connect; | ||
import com.vaadin.v7.client.ui.AbstractFieldConnector; | ||
|
||
@SuppressWarnings("serial") | ||
@Connect(VerticalComponentGroup.class) | ||
public class VerticalComponentGroupConnector extends AbstractLayoutConnector { | ||
|
||
@Override | ||
public void onStateChanged(StateChangeEvent stateChangeEvent) { | ||
super.onStateChanged(stateChangeEvent); | ||
} | ||
|
||
@Override | ||
public void onConnectorHierarchyChange( | ||
ConnectorHierarchyChangeEvent event) { | ||
if (getParent() == null) { | ||
// Component is removed, skip stuff to save user from JS exceptions | ||
// and some milliseconds of lost life | ||
return; | ||
} | ||
|
||
List<ComponentConnector> oldChildren = event.getOldChildren(); | ||
|
||
List<ComponentConnector> children = getChildComponents(); | ||
for (int i = 0; i < children.size(); ++i) { | ||
ComponentConnector connector = children.get(i); | ||
Widget widget = connector.getWidget(); | ||
getWidget().addOrMove(widget, i); | ||
oldChildren.remove(connector); | ||
} | ||
|
||
for (ComponentConnector oldChild : event.getOldChildren()) { | ||
if (oldChild.getParent() != this) { | ||
getWidget().remove(oldChild.getWidget()); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
protected VerticalComponentGroupWidget createWidget() { | ||
return GWT.create(VerticalComponentGroupWidget.class); | ||
} | ||
|
||
@Override | ||
public VerticalComponentGroupWidget getWidget() { | ||
return (VerticalComponentGroupWidget) super.getWidget(); | ||
} | ||
|
||
@Override | ||
public void updateCaption(ComponentConnector connector) { | ||
URLReference urlReference = connector.getState().resources | ||
.get(ComponentConstants.ICON_RESOURCE); | ||
Icon icon = null; | ||
if (urlReference != null) { | ||
icon = getConnection().getIcon(urlReference.getURL()); | ||
} | ||
Widget child = connector.getWidget(); | ||
String style = "v-caption"; | ||
if (ComponentStateUtil.hasStyles(connector.getState())) { | ||
for (String customStyle : connector.getState().styles) { | ||
style += " " + "v-caption-" + customStyle; | ||
} | ||
} | ||
if (connector instanceof AbstractFieldConnector) { | ||
AbstractFieldConnector field = (AbstractFieldConnector) connector; | ||
if (field.isRequiredIndicatorVisible()) { | ||
style += " v-caption-required"; | ||
} | ||
} | ||
getWidget().updateCaption(child, connector.getState().caption, icon, | ||
connector.getState().width, style); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
touchkit-compatibility/src/main/java/org/vaadin/touchkit/v7/ui/VerticalComponentGroup.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,62 @@ | ||
package org.vaadin.touchkit.v7.ui; | ||
|
||
import org.vaadin.touchkit.ui.AbstractComponentGroup; | ||
|
||
import com.vaadin.ui.Component; | ||
import com.vaadin.v7.ui.Field; | ||
|
||
/** | ||
* The VerticalComponentGroup is a layout to group controls vertically. Unlike | ||
* with default layouts, Components in a VerticalComponentGroup are visually | ||
* decorated from other parts of the UI. | ||
* <p> | ||
* Captions are rendered on the same row as the component. Relative widths are | ||
* relative to the {@link VerticalComponentGroup} width except if the component | ||
* has a caption, in which case a relative width is relative to the remaining | ||
* available space. | ||
* <p> | ||
* Most commonly {@link Field}s in {@link VerticalComponentGroup} should be full | ||
* width, so {@link VerticalComponentGroup} automatically sets width to 100% | ||
* when {@link Field}s are added to it, unless they have an explicit width | ||
* defined. | ||
*/ | ||
@SuppressWarnings("serial") | ||
public class VerticalComponentGroup extends AbstractComponentGroup { | ||
|
||
/** | ||
* Constructs a vertical component group. | ||
*/ | ||
public VerticalComponentGroup() { | ||
super(null); | ||
} | ||
|
||
/** | ||
* Creates a vertical component group with the provided caption. | ||
* | ||
* @param caption | ||
* the caption. | ||
*/ | ||
public VerticalComponentGroup(String caption) { | ||
super(caption); | ||
} | ||
|
||
/** | ||
* In addition to normal component addition, as a side effect this method | ||
* ensures {@link Field}s have sane width set. | ||
* | ||
* @see org.vaadin.touchkit.ui.AbstractComponentGroup#addComponent(com.vaadin.ui.Component, | ||
* int) | ||
*/ | ||
@Override | ||
public void addComponent(Component component, int index) { | ||
verifySaneFieldWidth(component); | ||
super.addComponent(component, index); | ||
} | ||
|
||
private void verifySaneFieldWidth(Component component) { | ||
if ((component instanceof Field) && component.getWidth() < 0) { | ||
component.setWidth("100%"); | ||
} | ||
} | ||
|
||
} |
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
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
2 changes: 1 addition & 1 deletion
2
...din/touchkit/itest/oldtests/JunkYard.java → .../touchkit/v7/itest/oldtests/JunkYard.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
6 changes: 3 additions & 3 deletions
6
...chkit/itest/oldtests/MeetingRoomView.java → ...it/v7/itest/oldtests/MeetingRoomView.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
4 changes: 2 additions & 2 deletions
4
...adin/touchkit/itest/oldtests/Selects.java → ...n/touchkit/v7/itest/oldtests/Selects.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
2 changes: 1 addition & 1 deletion
2
...touchkit/itest/oldtests/TabsheetTest.java → ...chkit/v7/itest/oldtests/TabsheetTest.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
30 changes: 30 additions & 0 deletions
30
touchkit-compatibility/src/test/java/org/vaadin/touchkit/v7/itest/oldtests/TestUtils.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,30 @@ | ||
package org.vaadin.touchkit.v7.itest.oldtests; | ||
|
||
import org.junit.Ignore; | ||
|
||
import com.vaadin.annotations.JavaScript; | ||
import com.vaadin.server.Page; | ||
import com.vaadin.server.Sizeable; | ||
import com.vaadin.ui.ComponentContainer; | ||
|
||
@Ignore | ||
public class TestUtils { | ||
public static void makeSmallTabletSize(ComponentContainer c) { | ||
c.setWidth(450, Sizeable.UNITS_PIXELS); | ||
c.setHeight(640, Sizeable.UNITS_PIXELS); | ||
} | ||
|
||
public static void injectCss(String cssString) { | ||
String script = "if ('\\v'=='v') /* ie only */ {\n" | ||
+ " document.createStyleSheet().cssText = '" | ||
+ cssString | ||
+ "';\n" | ||
+ " } else {var tag = document.createElement('style'); tag.type = 'text/css';" | ||
+ " document.getElementsByTagName('head')[0].appendChild(tag);tag[ (typeof " | ||
+ "document.body.style.WebkitAppearance=='string') /* webkit only */ ? 'innerText' " | ||
+ ": 'innerHTML'] = '" + cssString + "';}"; | ||
|
||
Page.getCurrent().getJavaScript().execute(script); | ||
} | ||
|
||
} |
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
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
Oops, something went wrong.