svn changeset:14496/svn branch:6.4tags/6.7.0.beta1
for (int i = 0; i < causes.length; i++) { | for (int i = 0; i < causes.length; i++) { | ||||
final int causeLevel = (causes[i] instanceof ErrorMessage) ? ((ErrorMessage) causes[i]) | final int causeLevel = (causes[i] instanceof ErrorMessage) ? ((ErrorMessage) causes[i]) | ||||
.getErrorLevel() | |||||
: ErrorMessage.ERROR; | |||||
.getErrorLevel() : ErrorMessage.ERROR; | |||||
if (causeLevel > level) { | if (causeLevel > level) { | ||||
level = causeLevel; | level = causeLevel; | ||||
} | } |
import java.io.Serializable; | import java.io.Serializable; | ||||
import com.vaadin.data.Validator.InvalidValueException; | |||||
import com.vaadin.terminal.ErrorMessage; | import com.vaadin.terminal.ErrorMessage; | ||||
import com.vaadin.terminal.PaintException; | import com.vaadin.terminal.PaintException; | ||||
import com.vaadin.terminal.PaintTarget; | import com.vaadin.terminal.PaintTarget; |
import java.util.List; | import java.util.List; | ||||
import com.vaadin.data.Container; | import com.vaadin.data.Container; | ||||
import com.vaadin.data.Container.Sortable; | |||||
import com.vaadin.data.Item; | import com.vaadin.data.Item; | ||||
import com.vaadin.data.Property; | import com.vaadin.data.Property; | ||||
import com.vaadin.data.Container.Sortable; | |||||
/** | /** | ||||
* Provides a default implementation of an ItemSorter. The | * Provides a default implementation of an ItemSorter. The | ||||
* The second item to compare. | * The second item to compare. | ||||
* @return a negative, zero, or positive integer if the property value in | * @return a negative, zero, or positive integer if the property value in | ||||
* the first item is less than, equal to, or greater than the | * the first item is less than, equal to, or greater than the | ||||
* property value in the second item. Negated if {@code | |||||
* sortDirection} is false. | |||||
* property value in the second item. Negated if | |||||
* {@code sortDirection} is false. | |||||
*/ | */ | ||||
protected int compareProperty(Object propertyId, boolean sortDirection, | protected int compareProperty(Object propertyId, boolean sortDirection, | ||||
Item item1, Item item2) { | Item item1, Item item2) { |
@Override | @Override | ||||
public boolean equals(Object obj) { | public boolean equals(Object obj) { | ||||
// Only ones of the objects of the same class can be equal | |||||
// Only ones of the objects of the same class can be equal | |||||
if (!(obj instanceof Filter)) { | if (!(obj instanceof Filter)) { | ||||
return false; | return false; | ||||
} | } | ||||
final Filter o = (Filter) obj; | final Filter o = (Filter) obj; | ||||
// Checks the properties one by one | |||||
// Checks the properties one by one | |||||
if (propertyId != o.propertyId && o.propertyId != null | if (propertyId != o.propertyId && o.propertyId != null | ||||
&& !o.propertyId.equals(propertyId)) { | && !o.propertyId.equals(propertyId)) { | ||||
return false; | return false; |
// Clone the shallow properties | // Clone the shallow properties | ||||
nc.itemIds = itemIds != null ? (ArrayList) itemIds.clone() : null; | nc.itemIds = itemIds != null ? (ArrayList) itemIds.clone() : null; | ||||
nc.itemSetChangeListeners = itemSetChangeListeners != null ? (LinkedList) itemSetChangeListeners | nc.itemSetChangeListeners = itemSetChangeListeners != null ? (LinkedList) itemSetChangeListeners | ||||
.clone() | |||||
: null; | |||||
.clone() : null; | |||||
nc.propertyIds = propertyIds != null ? (ArrayList) propertyIds.clone() | nc.propertyIds = propertyIds != null ? (ArrayList) propertyIds.clone() | ||||
: null; | : null; | ||||
nc.propertySetChangeListeners = propertySetChangeListeners != null ? (LinkedList) propertySetChangeListeners | nc.propertySetChangeListeners = propertySetChangeListeners != null ? (LinkedList) propertySetChangeListeners | ||||
.clone() | |||||
: null; | |||||
.clone() : null; | |||||
nc.propertyValueChangeListeners = propertyValueChangeListeners != null ? (LinkedList) propertyValueChangeListeners | nc.propertyValueChangeListeners = propertyValueChangeListeners != null ? (LinkedList) propertyValueChangeListeners | ||||
.clone() | |||||
: null; | |||||
.clone() : null; | |||||
nc.readOnlyProperties = readOnlyProperties != null ? (HashSet) readOnlyProperties | nc.readOnlyProperties = readOnlyProperties != null ? (HashSet) readOnlyProperties | ||||
.clone() | |||||
: null; | |||||
.clone() : null; | |||||
nc.singlePropertyValueChangeListeners = singlePropertyValueChangeListeners != null ? (Hashtable) singlePropertyValueChangeListeners | nc.singlePropertyValueChangeListeners = singlePropertyValueChangeListeners != null ? (Hashtable) singlePropertyValueChangeListeners | ||||
.clone() | |||||
: null; | |||||
.clone() : null; | |||||
nc.types = types != null ? (Hashtable) types.clone() : null; | nc.types = types != null ? (Hashtable) types.clone() : null; | ||||
npsi.list = list != null ? (LinkedList) list.clone() : null; | npsi.list = list != null ? (LinkedList) list.clone() : null; | ||||
npsi.propertySetChangeListeners = propertySetChangeListeners != null ? (LinkedList) propertySetChangeListeners | npsi.propertySetChangeListeners = propertySetChangeListeners != null ? (LinkedList) propertySetChangeListeners | ||||
.clone() | |||||
: null; | |||||
.clone() : null; | |||||
npsi.map = (HashMap) map.clone(); | npsi.map = (HashMap) map.clone(); | ||||
return npsi; | return npsi; |
final String columnName = metadata.getColumnName(i); | final String columnName = metadata.getColumnName(i); | ||||
list.add(columnName); | list.add(columnName); | ||||
final Property p = getContainerProperty(new Integer(1), columnName); | final Property p = getContainerProperty(new Integer(1), columnName); | ||||
propertyTypes.put(columnName, p == null ? Object.class : p | |||||
.getType()); | |||||
propertyTypes.put(columnName, | |||||
p == null ? Object.class : p.getType()); | |||||
} | } | ||||
propertyIds = Collections.unmodifiableCollection(list); | propertyIds = Collections.unmodifiableCollection(list); | ||||
} | } |
import java.lang.reflect.Method; | import java.lang.reflect.Method; | ||||
import com.vaadin.event.MouseEvents.ClickListener; | |||||
import com.vaadin.terminal.gwt.client.MouseEventDetails; | import com.vaadin.terminal.gwt.client.MouseEventDetails; | ||||
import com.vaadin.tools.ReflectTools; | import com.vaadin.tools.ReflectTools; | ||||
import com.vaadin.ui.Component; | import com.vaadin.ui.Component; |
} | } | ||||
public boolean accept(DragAndDropEvent dragEvent) { | public boolean accept(DragAndDropEvent dragEvent) { | ||||
return dragEvent.getTransferable().getDataFlavors().contains( | |||||
dataFlavorId); | |||||
return dragEvent.getTransferable().getDataFlavors() | |||||
.contains(dataFlavorId); | |||||
} | } | ||||
@Override | @Override |
try { | try { | ||||
// Find out the location of the x-www-browser link from path. | // Find out the location of the x-www-browser link from path. | ||||
Process process = runtime.exec("which x-www-browser"); | Process process = runtime.exec("which x-www-browser"); | ||||
BufferedInputStream ins = new BufferedInputStream(process | |||||
.getInputStream()); | |||||
BufferedInputStream ins = new BufferedInputStream( | |||||
process.getInputStream()); | |||||
BufferedReader bufreader = new BufferedReader( | BufferedReader bufreader = new BufferedReader( | ||||
new InputStreamReader(ins)); | new InputStreamReader(ins)); | ||||
String defaultLinkPath = bufreader.readLine(); | String defaultLinkPath = bufreader.readLine(); |
* @see com.vaadin.terminal.ApplicationResource#getStream() | * @see com.vaadin.terminal.ApplicationResource#getStream() | ||||
*/ | */ | ||||
public DownloadStream getStream() { | public DownloadStream getStream() { | ||||
final DownloadStream ds = new DownloadStream(associatedClass | |||||
.getResourceAsStream(resourceName), getMIMEType(), | |||||
getFilename()); | |||||
final DownloadStream ds = new DownloadStream( | |||||
associatedClass.getResourceAsStream(resourceName), | |||||
getMIMEType(), getFilename()); | |||||
ds.setBufferSize(getBufferSize()); | ds.setBufferSize(getBufferSize()); | ||||
ds.setCacheTime(cacheTime); | ds.setCacheTime(cacheTime); | ||||
return ds; | return ds; |
import com.vaadin.terminal.gwt.client.ui.Field; | import com.vaadin.terminal.gwt.client.ui.Field; | ||||
import com.vaadin.terminal.gwt.client.ui.VContextMenu; | import com.vaadin.terminal.gwt.client.ui.VContextMenu; | ||||
import com.vaadin.terminal.gwt.client.ui.VNotification; | import com.vaadin.terminal.gwt.client.ui.VNotification; | ||||
import com.vaadin.terminal.gwt.client.ui.VView; | |||||
import com.vaadin.terminal.gwt.client.ui.VNotification.HideEvent; | import com.vaadin.terminal.gwt.client.ui.VNotification.HideEvent; | ||||
import com.vaadin.terminal.gwt.client.ui.VView; | |||||
import com.vaadin.terminal.gwt.client.ui.dd.VDragAndDropManager; | import com.vaadin.terminal.gwt.client.ui.dd.VDragAndDropManager; | ||||
import com.vaadin.terminal.gwt.server.AbstractCommunicationManager; | import com.vaadin.terminal.gwt.server.AbstractCommunicationManager; | ||||
handleWhenCSSLoaded(response); | handleWhenCSSLoaded(response); | ||||
} | } | ||||
}).schedule(50); | }).schedule(50); | ||||
console | |||||
.log("Assuming CSS loading is not complete, " | |||||
+ "postponing render phase. " | |||||
+ "(.v-loading-indicator height == 0)"); | |||||
console.log("Assuming CSS loading is not complete, " | |||||
+ "postponing render phase. " | |||||
+ "(.v-loading-indicator height == 0)"); | |||||
cssWaits++; | cssWaits++; | ||||
} else { | } else { | ||||
handleReceivedJSONMessage(response); | handleReceivedJSONMessage(response); | ||||
if (cssWaits >= MAX_CSS_WAITS) { | if (cssWaits >= MAX_CSS_WAITS) { | ||||
console | |||||
.error("CSS files may have not loaded properly."); | |||||
console.error("CSS files may have not loaded properly."); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
private void showCommunicationError(String details) { | private void showCommunicationError(String details) { | ||||
console.error("Communication error: " + details); | console.error("Communication error: " + details); | ||||
showError(details, configuration.getCommunicationErrorCaption(), | showError(details, configuration.getCommunicationErrorCaption(), | ||||
configuration.getCommunicationErrorMessage(), configuration | |||||
.getCommunicationErrorUrl()); | |||||
configuration.getCommunicationErrorMessage(), | |||||
configuration.getCommunicationErrorUrl()); | |||||
} | } | ||||
/** | /** | ||||
private void showAuthenticationError(String details) { | private void showAuthenticationError(String details) { | ||||
console.error("Authentication error: " + details); | console.error("Authentication error: " + details); | ||||
showError(details, configuration.getAuthorizationErrorCaption(), | showError(details, configuration.getAuthorizationErrorCaption(), | ||||
configuration.getAuthorizationErrorMessage(), configuration | |||||
.getAuthorizationErrorUrl()); | |||||
configuration.getAuthorizationErrorMessage(), | |||||
configuration.getAuthorizationErrorUrl()); | |||||
} | } | ||||
/** | /** | ||||
.get(getPid(paintable)); | .get(getPid(paintable)); | ||||
Widget widget = (Widget) paintable; | Widget widget = (Widget) paintable; | ||||
Size oldSize = detail.getOffsetSize(); | Size oldSize = detail.getOffsetSize(); | ||||
Size newSize = new Size(widget.getOffsetWidth(), widget | |||||
.getOffsetHeight()); | |||||
Size newSize = new Size(widget.getOffsetWidth(), | |||||
widget.getOffsetHeight()); | |||||
if (oldSize == null || !oldSize.equals(newSize)) { | if (oldSize == null || !oldSize.equals(newSize)) { | ||||
sizeUpdatedWidgets.add(paintable); | sizeUpdatedWidgets.add(paintable); | ||||
// Parent-less components (like sub-windows) are relative to browser | // Parent-less components (like sub-windows) are relative to browser | ||||
// window. | // window. | ||||
if (parent == null) { | if (parent == null) { | ||||
renderSpace = new RenderSpace(Window.getClientWidth(), Window | |||||
.getClientHeight()); | |||||
renderSpace = new RenderSpace(Window.getClientWidth(), | |||||
Window.getClientHeight()); | |||||
} else { | } else { | ||||
renderSpace = parent.getAllocatedSpace(widget); | renderSpace = parent.getAllocatedSpace(widget); | ||||
} | } | ||||
if (debugSizes) { | if (debugSizes) { | ||||
getConsole() | getConsole() | ||||
.log( | |||||
"Widget " | |||||
+ Util.getSimpleName(widget) | |||||
+ "/" | |||||
+ getPid(widget.getElement()) | |||||
+ " relative height " | |||||
+ relativeSize.getHeight() | |||||
+ "% of " | |||||
+ renderSpace.getHeight() | |||||
+ "px (reported by " | |||||
+ Util.getSimpleName(parent) | |||||
+ "/" | |||||
+ (parent == null ? "?" : parent | |||||
.hashCode()) + ") : " | |||||
+ height + "px"); | |||||
.log("Widget " | |||||
+ Util.getSimpleName(widget) | |||||
+ "/" | |||||
+ getPid(widget.getElement()) | |||||
+ " relative height " | |||||
+ relativeSize.getHeight() | |||||
+ "% of " | |||||
+ renderSpace.getHeight() | |||||
+ "px (reported by " | |||||
+ Util.getSimpleName(parent) | |||||
+ "/" | |||||
+ (parent == null ? "?" : parent.hashCode()) | |||||
+ ") : " + height + "px"); | |||||
} | } | ||||
widget.setHeight(height + "px"); | widget.setHeight(height + "px"); | ||||
} else { | } else { | ||||
if (uidlUri.startsWith("theme://")) { | if (uidlUri.startsWith("theme://")) { | ||||
final String themeUri = configuration.getThemeUri(); | final String themeUri = configuration.getThemeUri(); | ||||
if (themeUri == null) { | if (themeUri == null) { | ||||
console | |||||
.error("Theme not set: ThemeResource will not be found. (" | |||||
+ uidlUri + ")"); | |||||
console.error("Theme not set: ThemeResource will not be found. (" | |||||
+ uidlUri + ")"); | |||||
} | } | ||||
uidlUri = themeUri + uidlUri.substring(7); | uidlUri = themeUri + uidlUri.substring(7); | ||||
} | } |
if (console != null) { | if (console != null) { | ||||
console.error(msg); | console.error(msg); | ||||
// } else { | |||||
// System.err.println(msg); | |||||
// } else { | |||||
// System.err.println(msg); | |||||
} | } | ||||
} | } | ||||
* The {@link #getElementByPath(String)} method can be used for the inverse | * The {@link #getElementByPath(String)} method can be used for the inverse | ||||
* operation, i.e. locating an element based on the return value from this | * operation, i.e. locating an element based on the return value from this | ||||
* method. | * method. | ||||
*<p> | |||||
* <p> | |||||
* Note that getElementByPath(getPathForElement(element)) == element is not | * Note that getElementByPath(getPathForElement(element)) == element is not | ||||
* always true as {@link #getPathForElement(Element)} can return a path to | * always true as {@link #getPathForElement(Element)} can return a path to | ||||
* another element if the widget determines an action on the other element | * another element if the widget determines an action on the other element | ||||
* will give the same result as the action on the target element. | * will give the same result as the action on the target element. | ||||
*</p> | |||||
* </p> | |||||
* | * | ||||
* @since 5.4 | * @since 5.4 | ||||
* @param targetElement | * @param targetElement | ||||
* | * | ||||
* @param targetElement | * @param targetElement | ||||
* @param ancestorWidget | * @param ancestorWidget | ||||
* @return The widget whose root element is a parent of {@code | |||||
* targetElement}. | |||||
* @return The widget whose root element is a parent of | |||||
* {@code targetElement}. | |||||
*/ | */ | ||||
private Widget findParentWidget(Element targetElement, Widget ancestorWidget) { | private Widget findParentWidget(Element targetElement, Widget ancestorWidget) { | ||||
/* | /* |
} | } | ||||
public int getStartWeekDay(Date date) { | public int getStartWeekDay(Date date) { | ||||
final Date dateForFirstOfThisMonth = new Date(date.getYear(), date | |||||
.getMonth(), 1); | |||||
final Date dateForFirstOfThisMonth = new Date(date.getYear(), | |||||
date.getMonth(), 1); | |||||
int firstDay; | int firstDay; | ||||
try { | try { | ||||
firstDay = LocaleService.getFirstDayOfWeek(currentLocale); | firstDay = LocaleService.getFirstDayOfWeek(currentLocale); | ||||
if (date == null) { | if (date == null) { | ||||
return 0; | return 0; | ||||
} | } | ||||
return (int) (date.getTime() - date.getTime() / 1000 * 1000); | return (int) (date.getTime() - date.getTime() / 1000 * 1000); | ||||
} | } | ||||
* @return true if the size has changed since last update | * @return true if the size has changed since last update | ||||
*/ | */ | ||||
public boolean updateSize(Element element) { | public boolean updateSize(Element element) { | ||||
Size newSize = new Size(element.getOffsetWidth(), element | |||||
.getOffsetHeight()); | |||||
Size newSize = new Size(element.getOffsetWidth(), | |||||
element.getOffsetHeight()); | |||||
if (newSize.equals(renderedSize)) { | if (newSize.equals(renderedSize)) { | ||||
return false; | return false; | ||||
} else { | } else { |
setHeight(widget, ""); | setHeight(widget, ""); | ||||
return paddingBorderGuess; | return paddingBorderGuess; | ||||
} else if (height.endsWith("px")) { | } else if (height.endsWith("px")) { | ||||
int pixelHeight = Integer.parseInt(height.substring(0, height | |||||
.length() - 2)); | |||||
int pixelHeight = Integer.parseInt(height.substring(0, | |||||
height.length() - 2)); | |||||
return setHeightExcludingPaddingAndBorder(widget.getElement(), | return setHeightExcludingPaddingAndBorder(widget.getElement(), | ||||
pixelHeight, paddingBorderGuess, false); | pixelHeight, paddingBorderGuess, false); | ||||
} else { | } else { |
} else { | } else { | ||||
ApplicationConnection | ApplicationConnection | ||||
.getConsole() | .getConsole() | ||||
.log( | |||||
"Warning: Icon load event was not propagated because VCaption owner is unknown."); | |||||
.log("Warning: Icon load event was not propagated because VCaption owner is unknown."); | |||||
} | } | ||||
} | } | ||||
} | } |
private void minimize() { | private void minimize() { | ||||
setPixelSize(400, 150); | setPixelSize(400, 150); | ||||
setPopupPosition(Window.getClientWidth() - 410, Window | |||||
.getClientHeight() - 160); | |||||
setPopupPosition(Window.getClientWidth() - 410, | |||||
Window.getClientHeight() - 160); | |||||
} | } | ||||
@Override | @Override | ||||
public void onClick(ClickEvent event) { | public void onClick(ClickEvent event) { | ||||
if (paintable != null) { | if (paintable != null) { | ||||
Element element2 = ((Widget) paintable).getElement(); | Element element2 = ((Widget) paintable).getElement(); | ||||
Widget.setStyleName(element2, "invalidlayout", emphasisInUi | |||||
.getValue()); | |||||
Widget.setStyleName(element2, "invalidlayout", | |||||
emphasisInUi.getValue()); | |||||
} | } | ||||
} | } | ||||
}); | }); |
errorContainer = new VOverlay(); | errorContainer = new VOverlay(); | ||||
errorContainer.setWidget(this); | errorContainer.setWidget(this); | ||||
} | } | ||||
errorContainer.setPopupPosition(DOM.getAbsoluteLeft(indicatorElement) | |||||
+ 2 | |||||
* DOM.getElementPropertyInt(indicatorElement, "offsetHeight"), | |||||
errorContainer.setPopupPosition( | |||||
DOM.getAbsoluteLeft(indicatorElement) | |||||
+ 2 | |||||
* DOM.getElementPropertyInt(indicatorElement, | |||||
"offsetHeight"), | |||||
DOM.getAbsoluteTop(indicatorElement) | DOM.getAbsoluteTop(indicatorElement) | ||||
+ 2 | + 2 | ||||
* DOM.getElementPropertyInt(indicatorElement, | * DOM.getElementPropertyInt(indicatorElement, |
public void handleEventHandlerRegistration(ApplicationConnection client) { | public void handleEventHandlerRegistration(ApplicationConnection client) { | ||||
this.client = client; | this.client = client; | ||||
// Handle registering/unregistering of click handler depending on if | |||||
// server side listeners have been added or removed. | |||||
// Handle registering/unregistering of click handler depending on if | |||||
// server side listeners have been added or removed. | |||||
if (hasEventListener()) { | if (hasEventListener()) { | ||||
if (mouseUpHandlerRegistration == null) { | if (mouseUpHandlerRegistration == null) { | ||||
mouseUpHandlerRegistration = registerHandler(this, MouseUpEvent | |||||
.getType()); | |||||
mouseUpHandlerRegistration = registerHandler(this, | |||||
MouseUpEvent.getType()); | |||||
contextMenuHandlerRegistration = registerHandler(this, | contextMenuHandlerRegistration = registerHandler(this, | ||||
ContextMenuEvent.getType()); | ContextMenuEvent.getType()); | ||||
doubleClickHandlerRegistration = registerHandler(this, | doubleClickHandlerRegistration = registerHandler(this, | ||||
} | } | ||||
} else { | } else { | ||||
if (mouseUpHandlerRegistration != null) { | if (mouseUpHandlerRegistration != null) { | ||||
// Remove existing handlers | |||||
// Remove existing handlers | |||||
doubleClickHandlerRegistration.removeHandler(); | doubleClickHandlerRegistration.removeHandler(); | ||||
mouseUpHandlerRegistration.removeHandler(); | mouseUpHandlerRegistration.removeHandler(); | ||||
contextMenuHandlerRegistration.removeHandler(); | contextMenuHandlerRegistration.removeHandler(); | ||||
public void onContextMenu(ContextMenuEvent event) { | public void onContextMenu(ContextMenuEvent event) { | ||||
if (hasEventListener()) { | if (hasEventListener()) { | ||||
// Prevent showing the browser's context menu when there is a right | |||||
// click listener. | |||||
// Prevent showing the browser's context menu when there is a right | |||||
// click listener. | |||||
event.preventDefault(); | event.preventDefault(); | ||||
} | } | ||||
} | } | ||||
public void onMouseUp(MouseUpEvent event) { | public void onMouseUp(MouseUpEvent event) { | ||||
// TODO For perfect accuracy we should check that a mousedown has | |||||
// occured on this element before this mouseup and that no mouseup | |||||
// has occured anywhere after that. | |||||
// TODO For perfect accuracy we should check that a mousedown has | |||||
// occured on this element before this mouseup and that no mouseup | |||||
// has occured anywhere after that. | |||||
if (hasEventListener()) { | if (hasEventListener()) { | ||||
// "Click" with left, right or middle button | |||||
// "Click" with left, right or middle button | |||||
fireClick(event.getNativeEvent()); | fireClick(event.getNativeEvent()); | ||||
} | } | ||||
} | } |
popup.addPopupListener(this); | popup.addPopupListener(this); | ||||
if (vertical) { | if (vertical) { | ||||
popup.setPopupPosition(item.getAbsoluteLeft() | |||||
+ item.getOffsetWidth(), item.getAbsoluteTop()); | |||||
popup.setPopupPosition( | |||||
item.getAbsoluteLeft() + item.getOffsetWidth(), | |||||
item.getAbsoluteTop()); | |||||
} else { | } else { | ||||
popup.setPopupPosition(item.getAbsoluteLeft(), item | |||||
.getAbsoluteTop() | |||||
+ item.getOffsetHeight()); | |||||
popup.setPopupPosition(item.getAbsoluteLeft(), | |||||
item.getAbsoluteTop() + item.getOffsetHeight()); | |||||
} | } | ||||
shownChildMenu = item.getSubMenu(); | shownChildMenu = item.getSubMenu(); |
modifiers = action.getIntArrayAttribute("mk"); | modifiers = action.getIntArrayAttribute("mk"); | ||||
} | } | ||||
final ShortcutKeyCombination kc = new ShortcutKeyCombination(action | |||||
.getIntAttribute("kc"), modifiers); | |||||
final ShortcutKeyCombination kc = new ShortcutKeyCombination( | |||||
action.getIntAttribute("kc"), modifiers); | |||||
final String key = action.getStringAttribute("key"); | final String key = action.getStringAttribute("key"); | ||||
final String caption = action.getStringAttribute("caption"); | final String caption = action.getStringAttribute("caption"); | ||||
actions.add(new ShortcutAction(key, kc, caption)); | actions.add(new ShortcutAction(key, kc, caption)); |
import java.util.HashSet; | import java.util.HashSet; | ||||
import java.util.Iterator; | import java.util.Iterator; | ||||
import java.util.Map; | import java.util.Map; | ||||
import java.util.Set; | |||||
import java.util.Map.Entry; | import java.util.Map.Entry; | ||||
import java.util.Set; | |||||
import com.google.gwt.dom.client.DivElement; | import com.google.gwt.dom.client.DivElement; | ||||
import com.google.gwt.dom.client.Document; | import com.google.gwt.dom.client.Document; |
if (index != activeTabIndex && !disabled && !readonly | if (index != activeTabIndex && !disabled && !readonly | ||||
&& !disabledTabKeys.contains(tabKeys.get(index))) { | && !disabledTabKeys.contains(tabKeys.get(index))) { | ||||
addStyleDependentName("loading"); | addStyleDependentName("loading"); | ||||
client | |||||
.updateVariable(id, "selected", "" + tabKeys.get(index), | |||||
true); | |||||
client.updateVariable(id, "selected", "" + tabKeys.get(index), true); | |||||
} | } | ||||
} | } | ||||
} else { | } else { | ||||
super.setHeight((height + getCaptionHeight()) + "px"); | super.setHeight((height + getCaptionHeight()) + "px"); | ||||
DOM.setStyleAttribute(content, "height", height + "px"); | DOM.setStyleAttribute(content, "height", height + "px"); | ||||
DOM | |||||
.setStyleAttribute(content, "top", getCaptionHeight() | |||||
+ "px"); | |||||
DOM.setStyleAttribute(content, "top", getCaptionHeight() + "px"); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
int captionWidth = caption.getRequiredWidth(); | int captionWidth = caption.getRequiredWidth(); | ||||
int padding = Util.measureHorizontalPaddingAndBorder(caption | |||||
.getElement(), 18); | |||||
int padding = Util.measureHorizontalPaddingAndBorder( | |||||
caption.getElement(), 18); | |||||
return captionWidth + padding; | return captionWidth + padding; | ||||
} | } | ||||
} | } | ||||
value.setHours(h); | value.setHours(h); | ||||
if (timeChangeListener != null) { | if (timeChangeListener != null) { | ||||
timeChangeListener.changed(h, value.getMinutes(), value | |||||
.getSeconds(), DateTimeService | |||||
.getMilliseconds(value)); | |||||
timeChangeListener.changed(h, value.getMinutes(), | |||||
value.getSeconds(), | |||||
DateTimeService.getMilliseconds(value)); | |||||
} | } | ||||
event.preventDefault(); | event.preventDefault(); | ||||
event.stopPropagation(); | event.stopPropagation(); | ||||
final int m = mins.getSelectedIndex(); | final int m = mins.getSelectedIndex(); | ||||
value.setMinutes(m); | value.setMinutes(m); | ||||
if (timeChangeListener != null) { | if (timeChangeListener != null) { | ||||
timeChangeListener.changed(value.getHours(), m, value | |||||
.getSeconds(), DateTimeService | |||||
.getMilliseconds(value)); | |||||
timeChangeListener.changed(value.getHours(), m, | |||||
value.getSeconds(), | |||||
DateTimeService.getMilliseconds(value)); | |||||
} | } | ||||
event.preventDefault(); | event.preventDefault(); | ||||
event.stopPropagation(); | event.stopPropagation(); | ||||
final int s = sec.getSelectedIndex(); | final int s = sec.getSelectedIndex(); | ||||
value.setSeconds(s); | value.setSeconds(s); | ||||
if (timeChangeListener != null) { | if (timeChangeListener != null) { | ||||
timeChangeListener.changed(value.getHours(), value | |||||
.getMinutes(), s, DateTimeService | |||||
.getMilliseconds(value)); | |||||
timeChangeListener.changed(value.getHours(), | |||||
value.getMinutes(), s, | |||||
DateTimeService.getMilliseconds(value)); | |||||
} | } | ||||
event.preventDefault(); | event.preventDefault(); | ||||
event.stopPropagation(); | event.stopPropagation(); | ||||
final int ms = msec.getSelectedIndex(); | final int ms = msec.getSelectedIndex(); | ||||
DateTimeService.setMilliseconds(value, ms); | DateTimeService.setMilliseconds(value, ms); | ||||
if (timeChangeListener != null) { | if (timeChangeListener != null) { | ||||
timeChangeListener.changed(value.getHours(), value | |||||
.getMinutes(), value.getSeconds(), ms); | |||||
timeChangeListener.changed(value.getHours(), | |||||
value.getMinutes(), value.getSeconds(), ms); | |||||
} | } | ||||
event.preventDefault(); | event.preventDefault(); | ||||
event.stopPropagation(); | event.stopPropagation(); | ||||
+ (ampm.getSelectedIndex() * 12); | + (ampm.getSelectedIndex() * 12); | ||||
value.setHours(h); | value.setHours(h); | ||||
if (timeChangeListener != null) { | if (timeChangeListener != null) { | ||||
timeChangeListener.changed(h, value.getMinutes(), value | |||||
.getSeconds(), DateTimeService | |||||
.getMilliseconds(value)); | |||||
timeChangeListener.changed(h, value.getMinutes(), | |||||
value.getSeconds(), | |||||
DateTimeService.getMilliseconds(value)); | |||||
} | } | ||||
event.preventDefault(); | event.preventDefault(); | ||||
event.stopPropagation(); | event.stopPropagation(); |
} | } | ||||
clickEventHandler.handleEventHandlerRegistration(client); | clickEventHandler.handleEventHandlerRegistration(client); | ||||
final VMarginInfo margins = new VMarginInfo(uidl | |||||
.getIntAttribute("margins")); | |||||
final VMarginInfo margins = new VMarginInfo( | |||||
uidl.getIntAttribute("margins")); | |||||
setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_TOP, | setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_TOP, | ||||
margins.hasTop()); | margins.hasTop()); | ||||
setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_RIGHT, | setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_RIGHT, | ||||
setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_LEFT, | setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_LEFT, | ||||
margins.hasLeft()); | margins.hasLeft()); | ||||
setStyleName(margin, CLASSNAME + "-" + "spacing", uidl | |||||
.hasAttribute("spacing")); | |||||
setStyleName(margin, CLASSNAME + "-" + "spacing", | |||||
uidl.hasAttribute("spacing")); | |||||
panel.updateFromUIDL(uidl, client); | panel.updateFromUIDL(uidl, client); | ||||
rendering = false; | rendering = false; | ||||
} | } | ||||
continue; | continue; | ||||
} else { | } else { | ||||
style.setProperty( | style.setProperty( | ||||
makeCamelCase(rule[0].trim()), rule[1] | |||||
.trim()); | |||||
makeCamelCase(rule[0].trim()), | |||||
rule[1].trim()); | |||||
} | } | ||||
} | } | ||||
} catch (Exception e) { | } catch (Exception e) { |
import com.vaadin.terminal.gwt.client.Container; | import com.vaadin.terminal.gwt.client.Container; | ||||
import com.vaadin.terminal.gwt.client.ContainerResizedListener; | import com.vaadin.terminal.gwt.client.ContainerResizedListener; | ||||
import com.vaadin.terminal.gwt.client.Paintable; | import com.vaadin.terminal.gwt.client.Paintable; | ||||
import com.vaadin.terminal.gwt.client.RenderInformation.FloatSize; | |||||
import com.vaadin.terminal.gwt.client.RenderSpace; | import com.vaadin.terminal.gwt.client.RenderSpace; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.Util; | import com.vaadin.terminal.gwt.client.Util; | ||||
import com.vaadin.terminal.gwt.client.VCaption; | import com.vaadin.terminal.gwt.client.VCaption; | ||||
import com.vaadin.terminal.gwt.client.VCaptionWrapper; | import com.vaadin.terminal.gwt.client.VCaptionWrapper; | ||||
import com.vaadin.terminal.gwt.client.RenderInformation.FloatSize; | |||||
/** | /** | ||||
* Custom Layout implements complex layout defined with HTML template. | * Custom Layout implements complex layout defined with HTML template. | ||||
.getParentElement(); | .getParentElement(); | ||||
FloatSize extra = locationToExtraSize.get(getLocation(child)); | FloatSize extra = locationToExtraSize.get(getLocation(child)); | ||||
return new RenderSpace(pe.getOffsetWidth() - (int) extra.getWidth(), pe | |||||
.getOffsetHeight() | |||||
- (int) extra.getHeight(), Util.mayHaveScrollBars(pe)); | |||||
return new RenderSpace(pe.getOffsetWidth() - (int) extra.getWidth(), | |||||
pe.getOffsetHeight() - (int) extra.getHeight(), | |||||
Util.mayHaveScrollBars(pe)); | |||||
} | } | ||||
@Override | @Override | ||||
|| (relativeHeight && (relativeSize.getHeight() >= 0.0f))) { | || (relativeHeight && (relativeSize.getHeight() >= 0.0f))) { | ||||
relativeSizeWidgets.add(widget); | relativeSizeWidgets.add(widget); | ||||
widget.getElement().getStyle().setProperty("position", | |||||
"absolute"); | |||||
widget.getElement().getStyle() | |||||
.setProperty("position", "absolute"); | |||||
} | } | ||||
} | } | ||||
} | } |
import com.vaadin.terminal.gwt.client.MouseEventDetails; | import com.vaadin.terminal.gwt.client.MouseEventDetails; | ||||
import com.vaadin.terminal.gwt.client.Paintable; | import com.vaadin.terminal.gwt.client.Paintable; | ||||
import com.vaadin.terminal.gwt.client.RenderInformation; | import com.vaadin.terminal.gwt.client.RenderInformation; | ||||
import com.vaadin.terminal.gwt.client.RenderInformation.Size; | |||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.Util; | import com.vaadin.terminal.gwt.client.Util; | ||||
import com.vaadin.terminal.gwt.client.RenderInformation.Size; | |||||
import com.vaadin.terminal.gwt.client.ui.dd.DDUtil; | import com.vaadin.terminal.gwt.client.ui.dd.DDUtil; | ||||
import com.vaadin.terminal.gwt.client.ui.dd.HorizontalDropLocation; | import com.vaadin.terminal.gwt.client.ui.dd.HorizontalDropLocation; | ||||
import com.vaadin.terminal.gwt.client.ui.dd.VAbstractDropHandler; | import com.vaadin.terminal.gwt.client.ui.dd.VAbstractDropHandler; | ||||
import com.vaadin.terminal.gwt.client.ui.dd.VHasDropHandler; | import com.vaadin.terminal.gwt.client.ui.dd.VHasDropHandler; | ||||
import com.vaadin.terminal.gwt.client.ui.dd.VHtml5DragEvent; | import com.vaadin.terminal.gwt.client.ui.dd.VHtml5DragEvent; | ||||
import com.vaadin.terminal.gwt.client.ui.dd.VHtml5File; | import com.vaadin.terminal.gwt.client.ui.dd.VHtml5File; | ||||
import com.vaadin.terminal.gwt.client.ui.dd.VHtml5File.Callback; | |||||
import com.vaadin.terminal.gwt.client.ui.dd.VTransferable; | import com.vaadin.terminal.gwt.client.ui.dd.VTransferable; | ||||
import com.vaadin.terminal.gwt.client.ui.dd.VerticalDropLocation; | import com.vaadin.terminal.gwt.client.ui.dd.VerticalDropLocation; | ||||
import com.vaadin.terminal.gwt.client.ui.dd.VHtml5File.Callback; | |||||
/** | /** | ||||
* | * | ||||
if (dragStarMode == WRAPPER) { | if (dragStarMode == WRAPPER) { | ||||
startDrag.createDragImage(getElement(), true); | startDrag.createDragImage(getElement(), true); | ||||
} else { | } else { | ||||
startDrag.createDragImage(((Widget) paintable) | |||||
.getElement(), true); | |||||
startDrag.createDragImage( | |||||
((Widget) paintable).getElement(), true); | |||||
} | } | ||||
event.preventDefault(); // prevent text selection | event.preventDefault(); // prevent text selection | ||||
+ uidl.getId() + "\"></iframe>"); | + uidl.getId() + "\"></iframe>"); | ||||
browserElement = DOM.getFirstChild(getElement()); | browserElement = DOM.getFirstChild(getElement()); | ||||
} else { | } else { | ||||
DOM.setElementAttribute(browserElement, "src", getSrc(uidl, | |||||
client)); | |||||
DOM.setElementAttribute(browserElement, "src", | |||||
getSrc(uidl, client)); | |||||
} | } | ||||
clearBrowserElement = false; | clearBrowserElement = false; | ||||
} else { | } else { |
if (childUidl != null) { | if (childUidl != null) { | ||||
if (shortcutHandler == null) { | if (shortcutHandler == null) { | ||||
shortcutHandler = new ShortcutActionHandler(id, client); | shortcutHandler = new ShortcutActionHandler(id, client); | ||||
keyDownRegistration = addDomHandler(this, KeyDownEvent | |||||
.getType()); | |||||
keyDownRegistration = addDomHandler(this, | |||||
KeyDownEvent.getType()); | |||||
} | } | ||||
shortcutHandler.updateActionMap(childUidl); | shortcutHandler.updateActionMap(childUidl); | ||||
} | } | ||||
renderInformation.updateSize(getElement()); | renderInformation.updateSize(getElement()); | ||||
renderInformation.setContentAreaHeight(renderInformation | renderInformation.setContentAreaHeight(renderInformation | ||||
.getRenderedSize().getHeight() | |||||
- getSpaceConsumedVertically()); | |||||
.getRenderedSize().getHeight() - getSpaceConsumedVertically()); | |||||
if (BrowserInfo.get().isIE6()) { | if (BrowserInfo.get().isIE6()) { | ||||
getElement().getStyle().setProperty("overflow", "hidden"); | getElement().getStyle().setProperty("overflow", "hidden"); | ||||
} | } | ||||
renderInformation.setContentAreaWidth(renderInformation | renderInformation.setContentAreaWidth(renderInformation | ||||
.getRenderedSize().getWidth() | |||||
- borderPaddingHorizontal); | |||||
.getRenderedSize().getWidth() - borderPaddingHorizontal); | |||||
} | } | ||||
public RenderSpace getAllocatedSpace(Widget child) { | public RenderSpace getAllocatedSpace(Widget child) { |
} | } | ||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
final VMarginInfo margins = new VMarginInfo(uidl | |||||
.getIntAttribute("margins")); | |||||
final VMarginInfo margins = new VMarginInfo( | |||||
uidl.getIntAttribute("margins")); | |||||
Element margin = getElement(); | Element margin = getElement(); | ||||
setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_TOP, | setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_TOP, | ||||
setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_RIGHT, | setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_RIGHT, | ||||
margins.hasRight()); | margins.hasRight()); | ||||
setStyleName(margin, | setStyleName(margin, | ||||
CLASSNAME + "-" + StyleConstants.MARGIN_BOTTOM, margins | |||||
.hasBottom()); | |||||
CLASSNAME + "-" + StyleConstants.MARGIN_BOTTOM, | |||||
margins.hasBottom()); | |||||
setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_LEFT, | setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_LEFT, | ||||
margins.hasLeft()); | margins.hasLeft()); | ||||
setStyleName(margin, CLASSNAME + "-" + "spacing", uidl | |||||
.hasAttribute("spacing")); | |||||
setStyleName(margin, CLASSNAME + "-" + "spacing", | |||||
uidl.hasAttribute("spacing")); | |||||
int i = 0; | int i = 0; | ||||
for (final Iterator it = uidl.getChildIterator(); it.hasNext(); i++) { | for (final Iterator it = uidl.getChildIterator(); it.hasNext(); i++) { | ||||
public void updateCaption(UIDL uidl) { | public void updateCaption(UIDL uidl) { | ||||
setVisible(!uidl.getBooleanAttribute("invisible")); | setVisible(!uidl.getBooleanAttribute("invisible")); | ||||
setStyleName(getElement(), "v-disabled", uidl | |||||
.hasAttribute("disabled")); | |||||
setStyleName(getElement(), "v-disabled", | |||||
uidl.hasAttribute("disabled")); | |||||
boolean isEmpty = true; | boolean isEmpty = true; | ||||
Cell c = column[j]; | Cell c = column[j]; | ||||
if (c != null && c.cc != null | if (c != null && c.cc != null | ||||
&& c.widthCanAffectHeight()) { | && c.widthCanAffectHeight()) { | ||||
c.cc.setContainerSize(c.getAvailableWidth(), c | |||||
.getAvailableHeight()); | |||||
c.cc.setContainerSize(c.getAvailableWidth(), | |||||
c.getAvailableHeight()); | |||||
client.handleComponentRelativeSize(c.cc | client.handleComponentRelativeSize(c.cc | ||||
.getWidget()); | .getWidget()); | ||||
c.cc.updateWidgetSize(); | c.cc.updateWidgetSize(); | ||||
} | } | ||||
private void handleMargins(UIDL uidl) { | private void handleMargins(UIDL uidl) { | ||||
final VMarginInfo margins = new VMarginInfo(uidl | |||||
.getIntAttribute("margins")); | |||||
final VMarginInfo margins = new VMarginInfo( | |||||
uidl.getIntAttribute("margins")); | |||||
String styles = CLASSNAME + "-margin"; | String styles = CLASSNAME + "-margin"; | ||||
if (margins.hasTop()) { | if (margins.hasTop()) { | ||||
componentContainer.setWidget(newComponent); | componentContainer.setWidget(newComponent); | ||||
widgetToComponentContainer.put(newComponent, componentContainer); | widgetToComponentContainer.put(newComponent, componentContainer); | ||||
paintableToCell.put((Paintable) newComponent, paintableToCell | |||||
.get(oldComponent)); | |||||
paintableToCell.put((Paintable) newComponent, | |||||
paintableToCell.get(oldComponent)); | |||||
} | } | ||||
public void updateCaption(Paintable component, UIDL uidl) { | public void updateCaption(Paintable component, UIDL uidl) { |
} | } | ||||
for (final Iterator i = uidl.getChildIterator(); i.hasNext();) { | for (final Iterator i = uidl.getChildIterator(); i.hasNext();) { | ||||
final UIDL optionUidl = (UIDL) i.next(); | final UIDL optionUidl = (UIDL) i.next(); | ||||
select.addItem(optionUidl.getStringAttribute("caption"), optionUidl | |||||
.getStringAttribute("key")); | |||||
select.addItem(optionUidl.getStringAttribute("caption"), | |||||
optionUidl.getStringAttribute("key")); | |||||
if (optionUidl.hasAttribute("selected")) { | if (optionUidl.hasAttribute("selected")) { | ||||
select.setItemSelected(select.getItemCount() - 1, true); | select.setItemSelected(select.getItemCount() - 1, true); | ||||
} | } |
itemHTML.append("<span class=\"" + CLASSNAME | itemHTML.append("<span class=\"" + CLASSNAME | ||||
+ "-menuitem-caption\">"); | + "-menuitem-caption\">"); | ||||
if (item.hasAttribute("icon")) { | if (item.hasAttribute("icon")) { | ||||
itemHTML | |||||
.append("<img src=\"" | |||||
+ client.translateVaadinUri(item | |||||
.getStringAttribute("icon")) | |||||
+ "\" class=\"" + Icon.CLASSNAME | |||||
+ "\" alt=\"\" />"); | |||||
itemHTML.append("<img src=\"" | |||||
+ client.translateVaadinUri(item | |||||
.getStringAttribute("icon")) | |||||
+ "\" class=\"" + Icon.CLASSNAME + "\" alt=\"\" />"); | |||||
} | } | ||||
itemHTML.append(Util.escapeHTML(itemText) + "</span>"); | itemHTML.append(Util.escapeHTML(itemText) + "</span>"); | ||||
if (items.contains(item)) { | if (items.contains(item)) { | ||||
int index = items.indexOf(item); | int index = items.indexOf(item); | ||||
DOM.removeChild(getContainerElement(), DOM.getChild( | |||||
getContainerElement(), index)); | |||||
DOM.removeChild(getContainerElement(), | |||||
DOM.getChild(getContainerElement(), index)); | |||||
items.remove(index); | items.remove(index); | ||||
} | } | ||||
} | } | ||||
popup.show(); | popup.show(); | ||||
if (left + popup.getOffsetWidth() >= RootPanel.getBodyElement() | if (left + popup.getOffsetWidth() >= RootPanel.getBodyElement() | ||||
.getOffsetWidth() | |||||
- shadowSpace) { | |||||
.getOffsetWidth() - shadowSpace) { | |||||
if (subMenu) { | if (subMenu) { | ||||
left = item.getParentMenu().getAbsoluteLeft() | left = item.getParentMenu().getAbsoluteLeft() | ||||
- popup.getOffsetWidth() - shadowSpace; | - popup.getOffsetWidth() - shadowSpace; | ||||
} | } | ||||
if (popup.getElement().getStyle().getProperty("width") == null | if (popup.getElement().getStyle().getProperty("width") == null | ||||
|| popup.getElement().getStyle().getProperty( | |||||
"width") == "") { | |||||
|| popup.getElement().getStyle() | |||||
.getProperty("width") == "") { | |||||
popup.setWidth(popup.getOffsetWidth() + "px"); | popup.setWidth(popup.getOffsetWidth() + "px"); | ||||
} | } | ||||
popup.getElement().getStyle().setProperty("zoom", "1"); | popup.getElement().getStyle().setProperty("zoom", "1"); | ||||
* .gwt.event.dom.client.KeyPressEvent) | * .gwt.event.dom.client.KeyPressEvent) | ||||
*/ | */ | ||||
public void onKeyPress(KeyPressEvent event) { | public void onKeyPress(KeyPressEvent event) { | ||||
if (handleNavigation(event.getNativeEvent().getKeyCode(), event | |||||
.isControlKeyDown() | |||||
|| event.isMetaKeyDown(), event.isShiftKeyDown())) { | |||||
if (handleNavigation(event.getNativeEvent().getKeyCode(), | |||||
event.isControlKeyDown() || event.isMetaKeyDown(), | |||||
event.isShiftKeyDown())) { | |||||
event.preventDefault(); | event.preventDefault(); | ||||
} | } | ||||
} | } | ||||
* .event.dom.client.KeyDownEvent) | * .event.dom.client.KeyDownEvent) | ||||
*/ | */ | ||||
public void onKeyDown(KeyDownEvent event) { | public void onKeyDown(KeyDownEvent event) { | ||||
if (handleNavigation(event.getNativeEvent().getKeyCode(), event | |||||
.isControlKeyDown() | |||||
|| event.isMetaKeyDown(), event.isShiftKeyDown())) { | |||||
if (handleNavigation(event.getNativeEvent().getKeyCode(), | |||||
event.isControlKeyDown() || event.isMetaKeyDown(), | |||||
event.isShiftKeyDown())) { | |||||
event.preventDefault(); | event.preventDefault(); | ||||
} | } | ||||
} | } |
boolean selected = false; | boolean selected = false; | ||||
for (final Iterator i = uidl.getChildIterator(); i.hasNext();) { | for (final Iterator i = uidl.getChildIterator(); i.hasNext();) { | ||||
final UIDL optionUidl = (UIDL) i.next(); | final UIDL optionUidl = (UIDL) i.next(); | ||||
select.addItem(optionUidl.getStringAttribute("caption"), optionUidl | |||||
.getStringAttribute("key")); | |||||
select.addItem(optionUidl.getStringAttribute("caption"), | |||||
optionUidl.getStringAttribute("key")); | |||||
if (optionUidl.hasAttribute("selected")) { | if (optionUidl.hasAttribute("selected")) { | ||||
select.setItemSelected(select.getItemCount() - 1, true); | select.setItemSelected(select.getItemCount() - 1, true); | ||||
selected = true; | selected = true; |
public void onChange(ChangeEvent event) { | public void onChange(ChangeEvent event) { | ||||
if (multiselect) { | if (multiselect) { | ||||
client | |||||
.updateVariable(id, "selected", getSelectedItems(), | |||||
immediate); | |||||
client.updateVariable(id, "selected", getSelectedItems(), immediate); | |||||
} else { | } else { | ||||
client.updateVariable(id, "selected", new String[] { "" | client.updateVariable(id, "selected", new String[] { "" | ||||
+ getSelectedItem() }, immediate); | + getSelectedItem() }, immediate); |
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.BrowserInfo; | import com.vaadin.terminal.gwt.client.BrowserInfo; | ||||
import com.vaadin.terminal.gwt.client.Paintable; | import com.vaadin.terminal.gwt.client.Paintable; | ||||
import com.vaadin.terminal.gwt.client.RenderInformation.FloatSize; | |||||
import com.vaadin.terminal.gwt.client.RenderInformation.Size; | |||||
import com.vaadin.terminal.gwt.client.RenderSpace; | import com.vaadin.terminal.gwt.client.RenderSpace; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.Util; | import com.vaadin.terminal.gwt.client.Util; | ||||
import com.vaadin.terminal.gwt.client.ValueMap; | import com.vaadin.terminal.gwt.client.ValueMap; | ||||
import com.vaadin.terminal.gwt.client.RenderInformation.FloatSize; | |||||
import com.vaadin.terminal.gwt.client.RenderInformation.Size; | |||||
import com.vaadin.terminal.gwt.client.ui.layout.CellBasedLayout; | import com.vaadin.terminal.gwt.client.ui.layout.CellBasedLayout; | ||||
import com.vaadin.terminal.gwt.client.ui.layout.ChildComponentContainer; | import com.vaadin.terminal.gwt.client.ui.layout.ChildComponentContainer; | ||||
private int orientation; | private int orientation; | ||||
// Can be removed once OrderedLayout is removed | |||||
// Can be removed once OrderedLayout is removed | |||||
private boolean allowOrientationUpdate = false; | private boolean allowOrientationUpdate = false; | ||||
/** | /** | ||||
isRendering = true; | isRendering = true; | ||||
super.updateFromUIDL(uidl, client); | super.updateFromUIDL(uidl, client); | ||||
// Only non-cached, visible UIDL:s can introduce changes | |||||
// Only non-cached, visible UIDL:s can introduce changes | |||||
if (uidl.getBooleanAttribute("cached") | if (uidl.getBooleanAttribute("cached") | ||||
|| uidl.getBooleanAttribute("invisible")) { | || uidl.getBooleanAttribute("invisible")) { | ||||
isRendering = false; | isRendering = false; | ||||
handleOrientationUpdate(uidl); | handleOrientationUpdate(uidl); | ||||
} | } | ||||
// IStopWatch w = new IStopWatch("OrderedLayout.updateFromUIDL"); | |||||
// IStopWatch w = new IStopWatch("OrderedLayout.updateFromUIDL"); | |||||
ArrayList<Widget> uidlWidgets = new ArrayList<Widget>(uidl | |||||
.getChildCount()); | |||||
ArrayList<Widget> uidlWidgets = new ArrayList<Widget>( | |||||
uidl.getChildCount()); | |||||
ArrayList<ChildComponentContainer> relativeSizeComponents = new ArrayList<ChildComponentContainer>(); | ArrayList<ChildComponentContainer> relativeSizeComponents = new ArrayList<ChildComponentContainer>(); | ||||
ArrayList<UIDL> relativeSizeComponentUIDL = new ArrayList<UIDL>(); | ArrayList<UIDL> relativeSizeComponentUIDL = new ArrayList<UIDL>(); | ||||
final Paintable child = client.getPaintable(childUIDL); | final Paintable child = client.getPaintable(childUIDL); | ||||
Widget widget = (Widget) child; | Widget widget = (Widget) child; | ||||
// Create container for component | |||||
// Create container for component | |||||
ChildComponentContainer childComponentContainer = getComponentContainer(widget); | ChildComponentContainer childComponentContainer = getComponentContainer(widget); | ||||
if (childComponentContainer == null) { | if (childComponentContainer == null) { | ||||
// This is a new component | |||||
// This is a new component | |||||
childComponentContainer = createChildContainer(widget); | childComponentContainer = createChildContainer(widget); | ||||
} | } | ||||
activeLayoutSize.getWidth()); | activeLayoutSize.getWidth()); | ||||
} | } | ||||
if (sizeHasChangedDuringRendering && Util.isCached(childUIDL)) { | if (sizeHasChangedDuringRendering && Util.isCached(childUIDL)) { | ||||
// notify cached relative sized component about size | |||||
// chance | |||||
// notify cached relative sized component about size | |||||
// chance | |||||
client.handleComponentRelativeSize(childComponentContainer | client.handleComponentRelativeSize(childComponentContainer | ||||
.getWidget()); | .getWidget()); | ||||
} | } | ||||
} | } | ||||
// w.mark("Rendering of " | |||||
// + (uidlWidgets.size() - relativeSizeComponents.size()) | |||||
// + " absolute size components done"); | |||||
// w.mark("Rendering of " | |||||
// + (uidlWidgets.size() - relativeSizeComponents.size()) | |||||
// + " absolute size components done"); | |||||
/* | /* | ||||
* Remove any children after pos. These are the ones that previously | * Remove any children after pos. These are the ones that previously | ||||
*/ | */ | ||||
removeChildrenAfter(pos); | removeChildrenAfter(pos); | ||||
// w.mark("Old children removed"); | |||||
// w.mark("Old children removed"); | |||||
/* Fetch alignments and expand ratio from UIDL */ | /* Fetch alignments and expand ratio from UIDL */ | ||||
updateAlignmentsAndExpandRatios(uidl, uidlWidgets); | updateAlignmentsAndExpandRatios(uidl, uidlWidgets); | ||||
// w.mark("Alignments and expand ratios updated"); | |||||
// w.mark("Alignments and expand ratios updated"); | |||||
/* Fetch widget sizes from rendered components */ | /* Fetch widget sizes from rendered components */ | ||||
updateWidgetSizes(); | updateWidgetSizes(); | ||||
// w.mark("Widget sizes updated"); | |||||
// w.mark("Widget sizes updated"); | |||||
recalculateLayout(); | recalculateLayout(); | ||||
// w.mark("Layout size calculated (" + activeLayoutSize + | |||||
// ") offsetSize: " | |||||
// + getOffsetWidth() + "," + getOffsetHeight()); | |||||
// w.mark("Layout size calculated (" + activeLayoutSize + | |||||
// ") offsetSize: " | |||||
// + getOffsetWidth() + "," + getOffsetHeight()); | |||||
/* Render relative size components */ | /* Render relative size components */ | ||||
for (int i = 0; i < relativeSizeComponents.size(); i++) { | for (int i = 0; i < relativeSizeComponents.size(); i++) { | ||||
.getWidget()); | .getWidget()); | ||||
} | } | ||||
// childComponentContainer.updateWidgetSize(); | |||||
// childComponentContainer.updateWidgetSize(); | |||||
} | } | ||||
// w.mark("Rendering of " + (relativeSizeComponents.size()) | |||||
// + " relative size components done"); | |||||
// w.mark("Rendering of " + (relativeSizeComponents.size()) | |||||
// + " relative size components done"); | |||||
/* Fetch widget sizes for relative size components */ | /* Fetch widget sizes for relative size components */ | ||||
for (ChildComponentContainer childComponentContainer : widgetToComponentContainer | for (ChildComponentContainer childComponentContainer : widgetToComponentContainer | ||||
childComponentContainer.updateWidgetSize(); | childComponentContainer.updateWidgetSize(); | ||||
} | } | ||||
// w.mark("Widget sizes updated"); | |||||
// w.mark("Widget sizes updated"); | |||||
/* | /* | ||||
* Components with relative size in main direction may affect the layout | * Components with relative size in main direction may affect the layout | ||||
|| (isVertical() && isDynamicWidth())) { | || (isVertical() && isDynamicWidth())) { | ||||
layoutSizeMightHaveChanged(); | layoutSizeMightHaveChanged(); | ||||
} | } | ||||
// w.mark("Layout dimensions updated"); | |||||
// w.mark("Layout dimensions updated"); | |||||
/* Update component spacing */ | /* Update component spacing */ | ||||
updateContainerMargins(); | updateContainerMargins(); | ||||
* direction | * direction | ||||
*/ | */ | ||||
if (updateRelativeSizesInNonMainDirection()) { | if (updateRelativeSizesInNonMainDirection()) { | ||||
// Sizes updated - might affect the other dimension so we need to | |||||
// recheck the widget sizes and recalculate layout dimensions | |||||
// Sizes updated - might affect the other dimension so we need to | |||||
// recheck the widget sizes and recalculate layout dimensions | |||||
updateWidgetSizes(); | updateWidgetSizes(); | ||||
layoutSizeMightHaveChanged(); | layoutSizeMightHaveChanged(); | ||||
} | } | ||||
calculateAlignments(); | calculateAlignments(); | ||||
// w.mark("recalculateComponentSizesAndAlignments done"); | |||||
// w.mark("recalculateComponentSizesAndAlignments done"); | |||||
setRootSize(); | setRootSize(); | ||||
root.getStyle().setProperty("zoom", "1"); | root.getStyle().setProperty("zoom", "1"); | ||||
} | } | ||||
// w.mark("runDescendentsLayout done"); | |||||
// w.mark("runDescendentsLayout done"); | |||||
isRendering = false; | isRendering = false; | ||||
sizeHasChangedDuringRendering = false; | sizeHasChangedDuringRendering = false; | ||||
} | } | ||||
private void layoutSizeMightHaveChanged() { | private void layoutSizeMightHaveChanged() { | ||||
Size oldSize = new Size(activeLayoutSize.getWidth(), activeLayoutSize | |||||
.getHeight()); | |||||
Size oldSize = new Size(activeLayoutSize.getWidth(), | |||||
activeLayoutSize.getHeight()); | |||||
calculateLayoutDimensions(); | calculateLayoutDimensions(); | ||||
/* | /* | ||||
if (remaining > 0) { | if (remaining > 0) { | ||||
// Some left-over pixels due to rounding errors | |||||
// Some left-over pixels due to rounding errors | |||||
// Add one pixel to each container until there are no pixels left | |||||
// FIXME extra pixels should be divided among expanded widgets if | |||||
// such a widgets exists | |||||
// Add one pixel to each container until there are no pixels left | |||||
// FIXME extra pixels should be divided among expanded widgets if | |||||
// such a widgets exists | |||||
Iterator<Widget> widgetIterator = iterator(); | Iterator<Widget> widgetIterator = iterator(); | ||||
while (widgetIterator.hasNext() && remaining-- > 0) { | while (widgetIterator.hasNext() && remaining-- > 0) { | ||||
int maxWidgetWidth = 0; | int maxWidgetWidth = 0; | ||||
int maxWidgetHeight = 0; | int maxWidgetHeight = 0; | ||||
// Calculate layout dimensions from component dimensions | |||||
// Calculate layout dimensions from component dimensions | |||||
for (ChildComponentContainer childComponentContainer : widgetToComponentContainer | for (ChildComponentContainer childComponentContainer : widgetToComponentContainer | ||||
.values()) { | .values()) { | ||||
remainingSpace = 0; | remainingSpace = 0; | ||||
} | } | ||||
// ApplicationConnection.getConsole().log( | |||||
// "Layout size: " + activeLayoutSize); | |||||
// ApplicationConnection.getConsole().log( | |||||
// "Layout size: " + activeLayoutSize); | |||||
return remainingSpace; | return remainingSpace; | ||||
} | } | ||||
int h = 0; | int h = 0; | ||||
if (isHorizontal()) { | if (isHorizontal()) { | ||||
// HORIZONTAL | |||||
// HORIZONTAL | |||||
h = activeLayoutSize.getHeight(); | h = activeLayoutSize.getHeight(); | ||||
if (!isDynamicWidth()) { | if (!isDynamicWidth()) { | ||||
w = -1; | w = -1; | ||||
} | } | ||||
} else { | } else { | ||||
// VERTICAL | |||||
// VERTICAL | |||||
w = activeLayoutSize.getWidth(); | w = activeLayoutSize.getWidth(); | ||||
if (!isDynamicHeight()) { | if (!isDynamicHeight()) { | ||||
h = -1; | h = -1; | ||||
.widgetHasSizeSpecified(orientation)) { | .widgetHasSizeSpecified(orientation)) { | ||||
int captionWidth = childComponentContainer | int captionWidth = childComponentContainer | ||||
.getCaptionRequiredWidth(); | .getCaptionRequiredWidth(); | ||||
// ApplicationConnection.getConsole().log( | |||||
// "Component width: " + width | |||||
// + ", caption width: " + captionWidth); | |||||
// ApplicationConnection.getConsole().log( | |||||
// "Component width: " + width | |||||
// + ", caption width: " + captionWidth); | |||||
if (captionWidth > width) { | if (captionWidth > width) { | ||||
width = captionWidth; | width = captionWidth; | ||||
} | } | ||||
* Let the overflowing components overflow. IE has | * Let the overflowing components overflow. IE has | ||||
* problems with zero sizes. | * problems with zero sizes. | ||||
*/ | */ | ||||
// width = 0; | |||||
// height = 0; | |||||
// width = 0; | |||||
// height = 0; | |||||
} else if (width > availableWidth) { | } else if (width > availableWidth) { | ||||
width = availableWidth; | width = availableWidth; | ||||
int activeLayoutWidth = 0; | int activeLayoutWidth = 0; | ||||
int activeLayoutHeight = 0; | int activeLayoutHeight = 0; | ||||
// Update layout dimensions | |||||
// Update layout dimensions | |||||
if (isHorizontal()) { | if (isHorizontal()) { | ||||
// Horizontal | |||||
// Horizontal | |||||
if (isDynamicWidth()) { | if (isDynamicWidth()) { | ||||
activeLayoutWidth = totalComponentWidth; | activeLayoutWidth = totalComponentWidth; | ||||
} | } | ||||
} | } | ||||
} else { | } else { | ||||
// Vertical | |||||
// Vertical | |||||
if (isDynamicWidth()) { | if (isDynamicWidth()) { | ||||
activeLayoutWidth = maxComponentWidth; | activeLayoutWidth = maxComponentWidth; | ||||
} | } | ||||
private ChildComponentContainer createChildContainer(Widget child) { | private ChildComponentContainer createChildContainer(Widget child) { | ||||
// Create a container DIV for the child | |||||
// Create a container DIV for the child | |||||
ChildComponentContainer childComponent = new ChildComponentContainer( | ChildComponentContainer childComponent = new ChildComponentContainer( | ||||
child, orientation); | child, orientation); | ||||
int width = 0; | int width = 0; | ||||
int height = 0; | int height = 0; | ||||
ChildComponentContainer childComponentContainer = getComponentContainer(child); | ChildComponentContainer childComponentContainer = getComponentContainer(child); | ||||
// WIDTH CALCULATION | |||||
// WIDTH CALCULATION | |||||
if (isVertical()) { | if (isVertical()) { | ||||
width = activeLayoutSize.getWidth(); | width = activeLayoutSize.getWidth(); | ||||
width -= childComponentContainer.getCaptionWidthAfterComponent(); | width -= childComponentContainer.getCaptionWidthAfterComponent(); | ||||
} else if (!isDynamicWidth()) { | } else if (!isDynamicWidth()) { | ||||
// HORIZONTAL | |||||
// HORIZONTAL | |||||
width = childComponentContainer.getContSize().getWidth(); | width = childComponentContainer.getContSize().getWidth(); | ||||
width -= childComponentContainer.getCaptionWidthAfterComponent(); | width -= childComponentContainer.getCaptionWidthAfterComponent(); | ||||
} | } | ||||
// HEIGHT CALCULATION | |||||
// HEIGHT CALCULATION | |||||
if (isHorizontal()) { | if (isHorizontal()) { | ||||
height = activeLayoutSize.getHeight(); | height = activeLayoutSize.getHeight(); | ||||
height -= childComponentContainer.getCaptionHeightAboveComponent(); | height -= childComponentContainer.getCaptionHeightAboveComponent(); | ||||
} else if (!isDynamicHeight()) { | } else if (!isDynamicHeight()) { | ||||
// VERTICAL | |||||
// VERTICAL | |||||
height = childComponentContainer.getContSize().getHeight(); | height = childComponentContainer.getContSize().getHeight(); | ||||
height -= childComponentContainer.getCaptionHeightAboveComponent(); | height -= childComponentContainer.getCaptionHeightAboveComponent(); | ||||
} | } | ||||
// ApplicationConnection.getConsole().log( | |||||
// "allocatedSpace for " + Util.getSimpleName(child) + ": " | |||||
// + width + "," + height); | |||||
// ApplicationConnection.getConsole().log( | |||||
// "allocatedSpace for " + Util.getSimpleName(child) + ": " | |||||
// + width + "," + height); | |||||
RenderSpace space = new RenderSpace(width, height); | RenderSpace space = new RenderSpace(width, height); | ||||
return space; | return space; | ||||
} | } | ||||
client.handleComponentRelativeSize(componentContainer | client.handleComponentRelativeSize(componentContainer | ||||
.getWidget()); | .getWidget()); | ||||
// Update widget size from DOM | |||||
// Update widget size from DOM | |||||
componentContainer.updateWidgetSize(); | componentContainer.updateWidgetSize(); | ||||
} | } | ||||
} | } | ||||
for (Paintable p : children) { | for (Paintable p : children) { | ||||
/* Update widget size from DOM */ | /* Update widget size from DOM */ | ||||
ChildComponentContainer componentContainer = getComponentContainer((Widget) p); | ChildComponentContainer componentContainer = getComponentContainer((Widget) p); | ||||
// This should no longer be needed (after #2563) | |||||
// if (isDynamicWidth()) { | |||||
// componentContainer.setUnlimitedContainerWidth(); | |||||
// } else { | |||||
// componentContainer.setLimitedContainerWidth(activeLayoutSize | |||||
// .getWidth()); | |||||
// } | |||||
// This should no longer be needed (after #2563) | |||||
// if (isDynamicWidth()) { | |||||
// componentContainer.setUnlimitedContainerWidth(); | |||||
// } else { | |||||
// componentContainer.setLimitedContainerWidth(activeLayoutSize | |||||
// .getWidth()); | |||||
// } | |||||
componentContainer.updateWidgetSize(); | componentContainer.updateWidgetSize(); | ||||
ChildComponentContainer container = getComponentContainer(widget); | ChildComponentContainer container = getComponentContainer(widget); | ||||
// Calculate alignment info | |||||
// Calculate alignment info | |||||
container.setAlignment(getAlignment(pid)); | container.setAlignment(getAlignment(pid)); | ||||
// Update expand ratio | |||||
// Update expand ratio | |||||
container.setNormalizedExpandRatio(getExpandRatio(pid)); | container.setNormalizedExpandRatio(getExpandRatio(pid)); | ||||
} | } | ||||
} | } | ||||
expandRatioSum += expandRatios.getRawNumber(keyArray.get(i)); | expandRatioSum += expandRatios.getRawNumber(keyArray.get(i)); | ||||
} | } | ||||
if (expandRatioSum == 0) { | if (expandRatioSum == 0) { | ||||
// by default split equally among components | |||||
// by default split equally among components | |||||
defaultExpandRatio = 1.0 / widgetToComponentContainer.size(); | defaultExpandRatio = 1.0 / widgetToComponentContainer.size(); | ||||
} else { | } else { | ||||
defaultExpandRatio = 0; | defaultExpandRatio = 0; |
// Opera fix, part 2 (ticket #2704) | // Opera fix, part 2 (ticket #2704) | ||||
if (BrowserInfo.get().isOpera()) { | if (BrowserInfo.get().isOpera()) { | ||||
// We'll fix the height of all the middle elements | // We'll fix the height of all the middle elements | ||||
DOM.getChild(shadow, 3).getStyle().setPropertyPx("height", | |||||
DOM.getChild(shadow, 3).getOffsetHeight()); | |||||
DOM.getChild(shadow, 4).getStyle().setPropertyPx("height", | |||||
DOM.getChild(shadow, 4).getOffsetHeight()); | |||||
DOM.getChild(shadow, 5).getStyle().setPropertyPx("height", | |||||
DOM.getChild(shadow, 5).getOffsetHeight()); | |||||
DOM.getChild(shadow, 3) | |||||
.getStyle() | |||||
.setPropertyPx("height", | |||||
DOM.getChild(shadow, 3).getOffsetHeight()); | |||||
DOM.getChild(shadow, 4) | |||||
.getStyle() | |||||
.setPropertyPx("height", | |||||
DOM.getChild(shadow, 4).getOffsetHeight()); | |||||
DOM.getChild(shadow, 5) | |||||
.getStyle() | |||||
.setPropertyPx("height", | |||||
DOM.getChild(shadow, 5).getOffsetHeight()); | |||||
} | } | ||||
// Attach to dom if not there already | // Attach to dom if not there already |
if (containerHeight < 0) { | if (containerHeight < 0) { | ||||
containerHeight = 0; | containerHeight = 0; | ||||
} | } | ||||
DOM | |||||
.setStyleAttribute(contentNode, "height", containerHeight | |||||
+ "px"); | |||||
DOM.setStyleAttribute(contentNode, "height", containerHeight + "px"); | |||||
} else { | } else { | ||||
DOM.setStyleAttribute(contentNode, "height", ""); | DOM.setStyleAttribute(contentNode, "height", ""); | ||||
} | } |
popup.setWidth(w + "px"); | popup.setWidth(w + "px"); | ||||
popup.setHeight(h + "px"); | popup.setHeight(h + "px"); | ||||
popup.setPopupPosition(l, t | |||||
+ calendarToggle.getOffsetHeight() + 2); | |||||
popup.setPopupPosition(l, | |||||
t + calendarToggle.getOffsetHeight() + 2); | |||||
Date end = new Date(); | Date end = new Date(); | ||||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.Container; | import com.vaadin.terminal.gwt.client.Container; | ||||
import com.vaadin.terminal.gwt.client.Paintable; | import com.vaadin.terminal.gwt.client.Paintable; | ||||
import com.vaadin.terminal.gwt.client.RenderInformation.Size; | |||||
import com.vaadin.terminal.gwt.client.RenderSpace; | import com.vaadin.terminal.gwt.client.RenderSpace; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.Util; | import com.vaadin.terminal.gwt.client.Util; | ||||
import com.vaadin.terminal.gwt.client.VCaption; | import com.vaadin.terminal.gwt.client.VCaption; | ||||
import com.vaadin.terminal.gwt.client.VCaptionWrapper; | import com.vaadin.terminal.gwt.client.VCaptionWrapper; | ||||
import com.vaadin.terminal.gwt.client.VTooltip; | import com.vaadin.terminal.gwt.client.VTooltip; | ||||
import com.vaadin.terminal.gwt.client.RenderInformation.Size; | |||||
import com.vaadin.terminal.gwt.client.ui.richtextarea.VRichTextArea; | import com.vaadin.terminal.gwt.client.ui.richtextarea.VRichTextArea; | ||||
public class VPopupView extends HTML implements Container, Iterable<Widget> { | public class VPopupView extends HTML implements Container, Iterable<Widget> { |
} | } | ||||
// Send the selected row ranges | // Send the selected row ranges | ||||
client.updateVariable(paintableId, "selectedRanges", ranges | |||||
.toArray(new String[selectedRowRanges.size()]), false); | |||||
client.updateVariable(paintableId, "selectedRanges", | |||||
ranges.toArray(new String[selectedRowRanges.size()]), false); | |||||
} | } | ||||
// Send the selected rows | // Send the selected rows | ||||
client.updateVariable(paintableId, "selected", selectedRowKeys | |||||
.toArray(new String[selectedRowKeys.size()]), immediate); | |||||
client.updateVariable(paintableId, "selected", | |||||
selectedRowKeys.toArray(new String[selectedRowKeys.size()]), | |||||
immediate); | |||||
} | } | ||||
updateFooter(uidl.getStringArrayAttribute("vcolorder")); | updateFooter(uidl.getStringArrayAttribute("vcolorder")); | ||||
if (!recalcWidths && initializedAndAttached) { | if (!recalcWidths && initializedAndAttached) { | ||||
updateBody(rowData, uidl.getIntAttribute("firstrow"), uidl | |||||
.getIntAttribute("rows")); | |||||
updateBody(rowData, uidl.getIntAttribute("firstrow"), | |||||
uidl.getIntAttribute("rows")); | |||||
if (headerChangedDuringUpdate) { | if (headerChangedDuringUpdate) { | ||||
lazyAdjustColumnWidths.schedule(1); | lazyAdjustColumnWidths.schedule(1); | ||||
} else { | } else { | ||||
} | } | ||||
scrollBody = createScrollBody(); | scrollBody = createScrollBody(); | ||||
scrollBody.renderInitialRows(rowData, uidl | |||||
.getIntAttribute("firstrow"), uidl.getIntAttribute("rows")); | |||||
scrollBody.renderInitialRows(rowData, | |||||
uidl.getIntAttribute("firstrow"), | |||||
uidl.getIntAttribute("rows")); | |||||
scrollBodyPanel.add(scrollBody); | scrollBodyPanel.add(scrollBody); | ||||
initialContentReceived = true; | initialContentReceived = true; | ||||
if (isAttached()) { | if (isAttached()) { | ||||
.getChild(floatingCopyOfHeaderCell, 1); | .getChild(floatingCopyOfHeaderCell, 1); | ||||
DOM.setElementProperty(floatingCopyOfHeaderCell, "className", | DOM.setElementProperty(floatingCopyOfHeaderCell, "className", | ||||
CLASSNAME + "-header-drag"); | CLASSNAME + "-header-drag"); | ||||
updateFloatingCopysPosition(DOM.getAbsoluteLeft(td), DOM | |||||
.getAbsoluteTop(td)); | |||||
updateFloatingCopysPosition(DOM.getAbsoluteLeft(td), | |||||
DOM.getAbsoluteTop(td)); | |||||
DOM.appendChild(RootPanel.get().getElement(), | DOM.appendChild(RootPanel.get().getElement(), | ||||
floatingCopyOfHeaderCell); | floatingCopyOfHeaderCell); | ||||
} | } | ||||
if (client.hasEventListeners(VScrollTable.this, | if (client.hasEventListeners(VScrollTable.this, | ||||
HEADER_CLICK_EVENT_ID)) { | HEADER_CLICK_EVENT_ID)) { | ||||
MouseEventDetails details = new MouseEventDetails(event); | MouseEventDetails details = new MouseEventDetails(event); | ||||
client.updateVariable(paintableId, "headerClickEvent", details | |||||
.toString(), false); | |||||
client.updateVariable(paintableId, "headerClickEvent", | |||||
details.toString(), false); | |||||
client.updateVariable(paintableId, "headerClickCID", cid, true); | client.updateVariable(paintableId, "headerClickCID", cid, true); | ||||
} | } | ||||
} | } | ||||
// cols) | // cols) | ||||
final int hw = ((Element) getElement().getLastChild()) | final int hw = ((Element) getElement().getLastChild()) | ||||
.getOffsetWidth() | |||||
+ scrollBody.getCellExtraWidth(); | |||||
.getOffsetWidth() + scrollBody.getCellExtraWidth(); | |||||
if (columnIndex < 0) { | if (columnIndex < 0) { | ||||
columnIndex = 0; | columnIndex = 0; | ||||
for (Iterator<Widget> it = tHead.iterator(); it | for (Iterator<Widget> it = tHead.iterator(); it | ||||
private void focusSlot(int index) { | private void focusSlot(int index) { | ||||
removeSlotFocus(); | removeSlotFocus(); | ||||
if (index > 0) { | if (index > 0) { | ||||
DOM.setElementProperty(DOM.getFirstChild(DOM.getChild(tr, | |||||
index - 1)), "className", CLASSNAME + "-resizer " | |||||
+ CLASSNAME + "-focus-slot-right"); | |||||
DOM.setElementProperty( | |||||
DOM.getFirstChild(DOM.getChild(tr, index - 1)), | |||||
"className", CLASSNAME + "-resizer " + CLASSNAME | |||||
+ "-focus-slot-right"); | |||||
} else { | } else { | ||||
DOM.setElementProperty(DOM.getFirstChild(DOM | |||||
.getChild(tr, index)), "className", CLASSNAME | |||||
+ "-resizer " + CLASSNAME + "-focus-slot-left"); | |||||
DOM.setElementProperty( | |||||
DOM.getFirstChild(DOM.getChild(tr, index)), | |||||
"className", CLASSNAME + "-resizer " + CLASSNAME | |||||
+ "-focus-slot-left"); | |||||
} | } | ||||
focusedSlot = index; | focusedSlot = index; | ||||
} | } | ||||
return; | return; | ||||
} | } | ||||
if (focusedSlot == 0) { | if (focusedSlot == 0) { | ||||
DOM.setElementProperty(DOM.getFirstChild(DOM.getChild(tr, | |||||
focusedSlot)), "className", CLASSNAME + "-resizer"); | |||||
DOM.setElementProperty( | |||||
DOM.getFirstChild(DOM.getChild(tr, focusedSlot)), | |||||
"className", CLASSNAME + "-resizer"); | |||||
} else if (focusedSlot > 0) { | } else if (focusedSlot > 0) { | ||||
DOM.setElementProperty(DOM.getFirstChild(DOM.getChild(tr, | |||||
focusedSlot - 1)), "className", CLASSNAME + "-resizer"); | |||||
DOM.setElementProperty( | |||||
DOM.getFirstChild(DOM.getChild(tr, focusedSlot - 1)), | |||||
"className", CLASSNAME + "-resizer"); | |||||
} | } | ||||
focusedSlot = -1; | focusedSlot = -1; | ||||
} | } | ||||
for (int i = 0; i < cols.length; i++) { | for (int i = 0; i < cols.length; i++) { | ||||
final String cid = (String) cols[i]; | final String cid = (String) cols[i]; | ||||
final HeaderCell c = getHeaderCell(cid); | final HeaderCell c = getHeaderCell(cid); | ||||
final VisibleColumnAction a = new VisibleColumnAction(c | |||||
.getColKey()); | |||||
final VisibleColumnAction a = new VisibleColumnAction( | |||||
c.getColKey()); | |||||
a.setCaption(c.getCaption()); | a.setCaption(c.getCaption()); | ||||
if (!c.isEnabled()) { | if (!c.isEnabled()) { | ||||
a.setCollapsed(true); | a.setCollapsed(true); | ||||
if (client.hasEventListeners(VScrollTable.this, | if (client.hasEventListeners(VScrollTable.this, | ||||
FOOTER_CLICK_EVENT_ID)) { | FOOTER_CLICK_EVENT_ID)) { | ||||
MouseEventDetails details = new MouseEventDetails(event); | MouseEventDetails details = new MouseEventDetails(event); | ||||
client.updateVariable(paintableId, "footerClickEvent", details | |||||
.toString(), false); | |||||
client.updateVariable(paintableId, "footerClickEvent", | |||||
details.toString(), false); | |||||
client.updateVariable(paintableId, "footerClickCID", cid, true); | client.updateVariable(paintableId, "footerClickCID", cid, true); | ||||
} | } | ||||
} | } | ||||
// cols) | // cols) | ||||
final int hw = ((Element) getElement().getLastChild()) | final int hw = ((Element) getElement().getLastChild()) | ||||
.getOffsetWidth() | |||||
+ scrollBody.getCellExtraWidth(); | |||||
.getOffsetWidth() + scrollBody.getCellExtraWidth(); | |||||
if (columnIndex < 0) { | if (columnIndex < 0) { | ||||
columnIndex = 0; | columnIndex = 0; | ||||
for (Iterator<Widget> it = tHead.iterator(); it | for (Iterator<Widget> it = tHead.iterator(); it | ||||
if (row.isSelected()) { | if (row.isSelected()) { | ||||
row.addStyleName("v-selected"); | row.addStyleName("v-selected"); | ||||
} | } | ||||
tBodyElement.insertBefore(row.getElement(), tBodyElement | |||||
.getFirstChild()); | |||||
tBodyElement.insertBefore(row.getElement(), | |||||
tBodyElement.getFirstChild()); | |||||
adopt(row); | adopt(row); | ||||
renderedRows.add(0, row); | renderedRows.add(0, row); | ||||
} | } | ||||
public boolean remove(Widget w) { | public boolean remove(Widget w) { | ||||
if (childWidgets.contains(w)) { | if (childWidgets.contains(w)) { | ||||
orphan(w); | orphan(w); | ||||
DOM.removeChild(DOM.getParent(w.getElement()), w | |||||
.getElement()); | |||||
DOM.removeChild(DOM.getParent(w.getElement()), | |||||
w.getElement()); | |||||
childWidgets.remove(w); | childWidgets.remove(w); | ||||
return true; | return true; | ||||
} else { | } else { | ||||
// select event, even though nullselectionallowed wont let | // select event, even though nullselectionallowed wont let | ||||
// the change trough. Will need to be updated if that is | // the change trough. Will need to be updated if that is | ||||
// changed. | // changed. | ||||
client | |||||
.updateVariable( | |||||
paintableId, | |||||
"clickEvent", | |||||
details.toString(), | |||||
!(event.getButton() == Event.BUTTON_LEFT | |||||
&& !doubleClick | |||||
&& selectMode > Table.SELECT_MODE_NONE && immediate)); | |||||
client.updateVariable( | |||||
paintableId, | |||||
"clickEvent", | |||||
details.toString(), | |||||
!(event.getButton() == Event.BUTTON_LEFT | |||||
&& !doubleClick | |||||
&& selectMode > Table.SELECT_MODE_NONE && immediate)); | |||||
} | } | ||||
} | } | ||||
final Action[] actions = new Action[actionKeys.length]; | final Action[] actions = new Action[actionKeys.length]; | ||||
for (int i = 0; i < actions.length; i++) { | for (int i = 0; i < actions.length; i++) { | ||||
final String actionKey = actionKeys[i]; | final String actionKey = actionKeys[i]; | ||||
final TreeAction a = new TreeAction(this, String | |||||
.valueOf(rowKey), actionKey); | |||||
final TreeAction a = new TreeAction(this, | |||||
String.valueOf(rowKey), actionKey); | |||||
a.setCaption(getActionCaption(actionKey)); | a.setCaption(getActionCaption(actionKey)); | ||||
a.setIconUrl(getActionIcon(actionKey)); | a.setIconUrl(getActionIcon(actionKey)); | ||||
actions[i] = a; | actions[i] = a; | ||||
String s = uidl.getStringAttribute("caption"); | String s = uidl.getStringAttribute("caption"); | ||||
if (uidl.hasAttribute("icon")) { | if (uidl.hasAttribute("icon")) { | ||||
s = "<img src=\"" | s = "<img src=\"" | ||||
+ client | |||||
.translateVaadinUri(uidl.getStringAttribute("icon")) | |||||
+ client.translateVaadinUri(uidl.getStringAttribute("icon")) | |||||
+ "\" alt=\"icon\" class=\"v-icon\">" + s; | + "\" alt=\"icon\" class=\"v-icon\">" + s; | ||||
} | } | ||||
return s; | return s; | ||||
// Down navigation | // Down navigation | ||||
if (selectMode == SELECT_MODE_NONE && keycode == getNavigationDownKey()) { | if (selectMode == SELECT_MODE_NONE && keycode == getNavigationDownKey()) { | ||||
scrollBodyPanel.setScrollPosition(scrollBodyPanel | scrollBodyPanel.setScrollPosition(scrollBodyPanel | ||||
.getScrollPosition() | |||||
+ scrollingVelocity); | |||||
.getScrollPosition() + scrollingVelocity); | |||||
return true; | return true; | ||||
} else if (keycode == getNavigationDownKey()) { | } else if (keycode == getNavigationDownKey()) { | ||||
if (selectMode == SELECT_MODE_MULTI && moveFocusDown()) { | if (selectMode == SELECT_MODE_MULTI && moveFocusDown()) { | ||||
// Up navigation | // Up navigation | ||||
if (selectMode == SELECT_MODE_NONE && keycode == getNavigationUpKey()) { | if (selectMode == SELECT_MODE_NONE && keycode == getNavigationUpKey()) { | ||||
scrollBodyPanel.setScrollPosition(scrollBodyPanel | scrollBodyPanel.setScrollPosition(scrollBodyPanel | ||||
.getScrollPosition() | |||||
- scrollingVelocity); | |||||
.getScrollPosition() - scrollingVelocity); | |||||
return true; | return true; | ||||
} else if (keycode == getNavigationUpKey()) { | } else if (keycode == getNavigationUpKey()) { | ||||
if (selectMode == SELECT_MODE_MULTI && moveFocusUp()) { | if (selectMode == SELECT_MODE_MULTI && moveFocusUp()) { | ||||
if (keycode == getNavigationLeftKey()) { | if (keycode == getNavigationLeftKey()) { | ||||
// Left navigation | // Left navigation | ||||
scrollBodyPanel.setHorizontalScrollPosition(scrollBodyPanel | scrollBodyPanel.setHorizontalScrollPosition(scrollBodyPanel | ||||
.getHorizontalScrollPosition() | |||||
- scrollingVelocity); | |||||
.getHorizontalScrollPosition() - scrollingVelocity); | |||||
return true; | return true; | ||||
} else if (keycode == getNavigationRightKey()) { | } else if (keycode == getNavigationRightKey()) { | ||||
// Right navigation | // Right navigation | ||||
scrollBodyPanel.setHorizontalScrollPosition(scrollBodyPanel | scrollBodyPanel.setHorizontalScrollPosition(scrollBodyPanel | ||||
.getHorizontalScrollPosition() | |||||
+ scrollingVelocity); | |||||
.getHorizontalScrollPosition() + scrollingVelocity); | |||||
return true; | return true; | ||||
} | } | ||||
int rowHeight = (int) scrollBody.getRowHeight(); | int rowHeight = (int) scrollBody.getRowHeight(); | ||||
int offset = pageLength * rowHeight - rowHeight; | int offset = pageLength * rowHeight - rowHeight; | ||||
scrollBodyPanel.setScrollPosition(scrollBodyPanel | scrollBodyPanel.setScrollPosition(scrollBodyPanel | ||||
.getScrollPosition() | |||||
+ offset); | |||||
.getScrollPosition() + offset); | |||||
if (selectMode > SELECT_MODE_NONE) { | if (selectMode > SELECT_MODE_NONE) { | ||||
if (!moveFocusDown(pageLength - 2)) { | if (!moveFocusDown(pageLength - 2)) { | ||||
final int lastRendered = scrollBody.getLastRendered(); | final int lastRendered = scrollBody.getLastRendered(); | ||||
int rowHeight = (int) scrollBody.getRowHeight(); | int rowHeight = (int) scrollBody.getRowHeight(); | ||||
int offset = pageLength * rowHeight - rowHeight; | int offset = pageLength * rowHeight - rowHeight; | ||||
scrollBodyPanel.setScrollPosition(scrollBodyPanel | scrollBodyPanel.setScrollPosition(scrollBodyPanel | ||||
.getScrollPosition() | |||||
- offset); | |||||
.getScrollPosition() - offset); | |||||
if (selectMode > SELECT_MODE_NONE) { | if (selectMode > SELECT_MODE_NONE) { | ||||
if (!moveFocusUp(pageLength - 2)) { | if (!moveFocusUp(pageLength - 2)) { | ||||
final int firstRendered = scrollBody.getFirstRendered(); | final int firstRendered = scrollBody.getFirstRendered(); | ||||
*/ | */ | ||||
public void onKeyPress(KeyPressEvent event) { | public void onKeyPress(KeyPressEvent event) { | ||||
if (hasFocus) { | if (hasFocus) { | ||||
if (handleNavigation(event.getNativeEvent().getKeyCode(), event | |||||
.isControlKeyDown() | |||||
|| event.isMetaKeyDown(), event.isShiftKeyDown())) { | |||||
if (handleNavigation(event.getNativeEvent().getKeyCode(), | |||||
event.isControlKeyDown() || event.isMetaKeyDown(), | |||||
event.isShiftKeyDown())) { | |||||
event.preventDefault(); | event.preventDefault(); | ||||
} | } | ||||
*/ | */ | ||||
public void onKeyDown(KeyDownEvent event) { | public void onKeyDown(KeyDownEvent event) { | ||||
if (hasFocus) { | if (hasFocus) { | ||||
if (handleNavigation(event.getNativeEvent().getKeyCode(), event | |||||
.isControlKeyDown() | |||||
|| event.isMetaKeyDown(), event.isShiftKeyDown())) { | |||||
if (handleNavigation(event.getNativeEvent().getKeyCode(), | |||||
event.isControlKeyDown() || event.isMetaKeyDown(), | |||||
event.isShiftKeyDown())) { | |||||
event.preventDefault(); | event.preventDefault(); | ||||
} | } | ||||
private void updateFeedbackPosition() { | private void updateFeedbackPosition() { | ||||
if (vertical) { | if (vertical) { | ||||
feedbackPopup.setPopupPosition(DOM.getAbsoluteLeft(handle) | |||||
+ handle.getOffsetWidth(), DOM.getAbsoluteTop(handle) | |||||
+ handle.getOffsetHeight() / 2 | |||||
- feedbackPopup.getOffsetHeight() / 2); | |||||
feedbackPopup.setPopupPosition( | |||||
DOM.getAbsoluteLeft(handle) + handle.getOffsetWidth(), | |||||
DOM.getAbsoluteTop(handle) + handle.getOffsetHeight() / 2 | |||||
- feedbackPopup.getOffsetHeight() / 2); | |||||
} else { | } else { | ||||
feedbackPopup.setPopupPosition(DOM.getAbsoluteLeft(handle) | |||||
+ handle.getOffsetWidth() / 2 | |||||
- feedbackPopup.getOffsetWidth() / 2, DOM | |||||
.getAbsoluteTop(handle) | |||||
- feedbackPopup.getOffsetHeight()); | |||||
feedbackPopup.setPopupPosition( | |||||
DOM.getAbsoluteLeft(handle) + handle.getOffsetWidth() / 2 | |||||
- feedbackPopup.getOffsetWidth() / 2, | |||||
DOM.getAbsoluteTop(handle) | |||||
- feedbackPopup.getOffsetHeight()); | |||||
} | } | ||||
} | } | ||||
final int handleSize = Integer.parseInt(DOM.getElementProperty(handle, | final int handleSize = Integer.parseInt(DOM.getElementProperty(handle, | ||||
domProperty)); | domProperty)); | ||||
final int baseSize = Integer.parseInt(DOM.getElementProperty(base, | final int baseSize = Integer.parseInt(DOM.getElementProperty(base, | ||||
domProperty)) | |||||
- (2 * BASE_BORDER_WIDTH); | |||||
domProperty)) - (2 * BASE_BORDER_WIDTH); | |||||
final int range = baseSize - handleSize; | final int range = baseSize - handleSize; | ||||
double v = value.doubleValue(); | double v = value.doubleValue(); | ||||
} else if ((BrowserInfo.get().isGecko() && DOM.eventGetType(event) == Event.ONKEYPRESS) | } else if ((BrowserInfo.get().isGecko() && DOM.eventGetType(event) == Event.ONKEYPRESS) | ||||
|| (!BrowserInfo.get().isGecko() && DOM.eventGetType(event) == Event.ONKEYDOWN)) { | || (!BrowserInfo.get().isGecko() && DOM.eventGetType(event) == Event.ONKEYDOWN)) { | ||||
if (handleNavigation(event.getKeyCode(), event.getCtrlKey(), event | |||||
.getShiftKey())) { | |||||
if (handleNavigation(event.getKeyCode(), event.getCtrlKey(), | |||||
event.getShiftKey())) { | |||||
feedbackPopup.show(); | feedbackPopup.show(); | ||||
final double baseOffset = vertical ? DOM.getAbsoluteTop(base) | final double baseOffset = vertical ? DOM.getAbsoluteTop(base) | ||||
- Window.getScrollTop() - handleSize / 2 : DOM | - Window.getScrollTop() - handleSize / 2 : DOM | ||||
.getAbsoluteLeft(base) | .getAbsoluteLeft(base) | ||||
- Window.getScrollLeft() + handleSize / 2; | |||||
- Window.getScrollLeft() | |||||
+ handleSize | |||||
/ 2; | |||||
if (vertical) { | if (vertical) { | ||||
v = ((baseSize - (coord - baseOffset)) / (baseSize - handleSize)) | v = ((baseSize - (coord - baseOffset)) / (baseSize - handleSize)) |
return; | return; | ||||
} | } | ||||
DOM | |||||
.setStyleAttribute(firstContainer, "width", pixelPosition | |||||
+ "px"); | |||||
DOM.setStyleAttribute(firstContainer, "width", pixelPosition + "px"); | |||||
int secondContainerWidth = (wholeSize - pixelPosition - getSplitterSize()); | int secondContainerWidth = (wholeSize - pixelPosition - getSplitterSize()); | ||||
if (secondContainerWidth < 0) { | if (secondContainerWidth < 0) { | ||||
secondContainerWidth = 0; | secondContainerWidth = 0; |
final UIDL col = (UIDL) it.next(); | final UIDL col = (UIDL) it.next(); | ||||
final String cid = col.getStringAttribute("cid"); | final String cid = col.getStringAttribute("cid"); | ||||
if (!col.hasAttribute("collapsed")) { | if (!col.hasAttribute("collapsed")) { | ||||
tBody.setWidget(0, colIndex, new HeaderCell(cid, col | |||||
.getStringAttribute("caption"))); | |||||
tBody.setWidget(0, colIndex, | |||||
new HeaderCell(cid, col.getStringAttribute("caption"))); | |||||
} | } | ||||
colIndex++; | colIndex++; | ||||
int curRowIndex = 1; | int curRowIndex = 1; | ||||
while (it.hasNext()) { | while (it.hasNext()) { | ||||
final UIDL rowUidl = (UIDL) it.next(); | final UIDL rowUidl = (UIDL) it.next(); | ||||
final TableRow row = new TableRow(curRowIndex, String | |||||
.valueOf(rowUidl.getIntAttribute("key")), rowUidl | |||||
.hasAttribute("selected")); | |||||
final TableRow row = new TableRow(curRowIndex, | |||||
String.valueOf(rowUidl.getIntAttribute("key")), | |||||
rowUidl.hasAttribute("selected")); | |||||
int colIndex = 0; | int colIndex = 0; | ||||
if (rowHeaders) { | if (rowHeaders) { | ||||
tBody.setWidget(curRowIndex, colIndex, new BodyCell(row, | tBody.setWidget(curRowIndex, colIndex, new BodyCell(row, | ||||
selected = sel; | selected = sel; | ||||
if (selected) { | if (selected) { | ||||
selectedRowKeys.add(key); | selectedRowKeys.add(key); | ||||
DOM.setStyleAttribute(tBody.getRowFormatter().getElement( | |||||
rowIndex), "background", "yellow"); | |||||
DOM.setStyleAttribute( | |||||
tBody.getRowFormatter().getElement(rowIndex), | |||||
"background", "yellow"); | |||||
} else { | } else { | ||||
selectedRowKeys.remove(key); | selectedRowKeys.remove(key); | ||||
DOM.setStyleAttribute(tBody.getRowFormatter().getElement( | |||||
rowIndex), "background", "transparent"); | |||||
DOM.setStyleAttribute( | |||||
tBody.getRowFormatter().getElement(rowIndex), | |||||
"background", "transparent"); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
setSelected(true); | setSelected(true); | ||||
} | } | ||||
client.updateVariable(id, "selected", selectedRowKeys | |||||
.toArray(new String[selectedRowKeys.size()]), immediate); | |||||
client.updateVariable( | |||||
id, | |||||
"selected", | |||||
selectedRowKeys.toArray(new String[selectedRowKeys.size()]), | |||||
immediate); | |||||
} | } | ||||
/** | /** |
DeferredCommand.addCommand(new Command() { | DeferredCommand.addCommand(new Command() { | ||||
public void execute() { | public void execute() { | ||||
previousVisibleWidget = tp.getWidget(tp.getVisibleWidget()); | previousVisibleWidget = tp.getWidget(tp.getVisibleWidget()); | ||||
DOM.setStyleAttribute(DOM.getParent(previousVisibleWidget | |||||
.getElement()), "visibility", "hidden"); | |||||
DOM.setStyleAttribute( | |||||
DOM.getParent(previousVisibleWidget.getElement()), | |||||
"visibility", "hidden"); | |||||
client.updateVariable(id, "selected", tabKeys.get(tabIndex) | client.updateVariable(id, "selected", tabKeys.get(tabIndex) | ||||
.toString(), true); | .toString(), true); | ||||
} | } | ||||
addStyleDependentName("loading"); // Indicate initial progress | addStyleDependentName("loading"); // Indicate initial progress | ||||
tb.setStyleName(CLASSNAME + "-tabs"); | tb.setStyleName(CLASSNAME + "-tabs"); | ||||
DOM | |||||
.setElementProperty(contentNode, "className", CLASSNAME | |||||
+ "-content"); | |||||
DOM.setElementProperty(contentNode, "className", CLASSNAME + "-content"); | |||||
DOM.setElementProperty(deco, "className", CLASSNAME + "-deco"); | DOM.setElementProperty(deco, "className", CLASSNAME + "-deco"); | ||||
add(tb, tabs); | add(tb, tabs); | ||||
updateOpenTabSize(); | updateOpenTabSize(); | ||||
VTabsheet.this.removeStyleDependentName("loading"); | VTabsheet.this.removeStyleDependentName("loading"); | ||||
if (previousVisibleWidget != null) { | if (previousVisibleWidget != null) { | ||||
DOM.setStyleAttribute(DOM.getParent(previousVisibleWidget | |||||
.getElement()), "visibility", ""); | |||||
DOM.setStyleAttribute( | |||||
DOM.getParent(previousVisibleWidget.getElement()), | |||||
"visibility", ""); | |||||
previousVisibleWidget = null; | previousVisibleWidget = null; | ||||
} | } | ||||
} | } |
if (date != null) { | if (date != null) { | ||||
// if date value was leniently parsed, normalize text | // if date value was leniently parsed, normalize text | ||||
// presentation | // presentation | ||||
text.setValue(DateTimeFormat.getFormat( | |||||
getFormatString()).format(date), false); | |||||
text.setValue( | |||||
DateTimeFormat.getFormat(getFormatString()) | |||||
.format(date), false); | |||||
} | } | ||||
} else { | } else { | ||||
date = format.parseStrict(text.getText()); | date = format.parseStrict(text.getText()); |
options.setFocus(true); | options.setFocus(true); | ||||
} | } | ||||
client.updateVariable(id, "selected", selectedKeys | |||||
.toArray(new String[selectedKeys.size()]), isImmediate()); | |||||
client.updateVariable(id, "selected", | |||||
selectedKeys.toArray(new String[selectedKeys.size()]), | |||||
isImmediate()); | |||||
} | } | ||||
private void removeItem() { | private void removeItem() { | ||||
selections.setFocus(true); | selections.setFocus(true); | ||||
} | } | ||||
client.updateVariable(id, "selected", selectedKeys | |||||
.toArray(new String[selectedKeys.size()]), isImmediate()); | |||||
client.updateVariable(id, "selected", | |||||
selectedKeys.toArray(new String[selectedKeys.size()]), | |||||
isImmediate()); | |||||
} | } | ||||
@Override | @Override |
if (fu.getFilename().length() == 0 || submitted || !enabled) { | if (fu.getFilename().length() == 0 || submitted || !enabled) { | ||||
ApplicationConnection | ApplicationConnection | ||||
.getConsole() | .getConsole() | ||||
.log( | |||||
"Submit cancelled (disabled, no file or already submitted)"); | |||||
.log("Submit cancelled (disabled, no file or already submitted)"); | |||||
return; | return; | ||||
} | } | ||||
// flush possibly pending variable changes, so they will be handled | // flush possibly pending variable changes, so they will be handled | ||||
public void run() { | public void run() { | ||||
ApplicationConnection | ApplicationConnection | ||||
.getConsole() | .getConsole() | ||||
.log( | |||||
"Visiting server to see if upload started event changed UI."); | |||||
.log("Visiting server to see if upload started event changed UI."); | |||||
client.updateVariable(paintableId, "pollForStart", | client.updateVariable(paintableId, "pollForStart", | ||||
nextUploadId, true); | nextUploadId, true); | ||||
} | } |
} | } | ||||
final String style = notification.hasAttribute("style") ? notification | final String style = notification.hasAttribute("style") ? notification | ||||
.getStringAttribute("style") | |||||
: null; | |||||
.getStringAttribute("style") : null; | |||||
final int position = notification | final int position = notification | ||||
.getIntAttribute("position"); | .getIntAttribute("position"); | ||||
final int delay = notification.getIntAttribute("delay"); | final int delay = notification.getIntAttribute("delay"); | ||||
if (changed) { | if (changed) { | ||||
ApplicationConnection | ApplicationConnection | ||||
.getConsole() | .getConsole() | ||||
.log( | |||||
"Running layout functions due window resize"); | |||||
.log("Running layout functions due window resize"); | |||||
connection.runDescendentsLayout(VView.this); | connection.runDescendentsLayout(VView.this); | ||||
sendClientResized(); | sendClientResized(); |
footer = DOM.createDiv(); | footer = DOM.createDiv(); | ||||
DOM.setElementProperty(footer, "className", CLASSNAME + "-footer"); | DOM.setElementProperty(footer, "className", CLASSNAME + "-footer"); | ||||
resizeBox = DOM.createDiv(); | resizeBox = DOM.createDiv(); | ||||
DOM | |||||
.setElementProperty(resizeBox, "className", CLASSNAME | |||||
+ "-resizebox"); | |||||
DOM.setElementProperty(resizeBox, "className", CLASSNAME + "-resizebox"); | |||||
closeBox = DOM.createDiv(); | closeBox = DOM.createDiv(); | ||||
DOM.setElementProperty(closeBox, "className", CLASSNAME + "-closebox"); | DOM.setElementProperty(closeBox, "className", CLASSNAME + "-closebox"); | ||||
DOM.appendChild(footer, resizeBox); | DOM.appendChild(footer, resizeBox); | ||||
} | } | ||||
if (uidl.hasAttribute("caption")) { | if (uidl.hasAttribute("caption")) { | ||||
setCaption(uidl.getStringAttribute("caption"), uidl | |||||
.getStringAttribute("icon")); | |||||
setCaption(uidl.getStringAttribute("caption"), | |||||
uidl.getStringAttribute("icon")); | |||||
} | } | ||||
boolean showingUrl = false; | boolean showingUrl = false; | ||||
} | } | ||||
final String style = notification.hasAttribute("style") ? notification | final String style = notification.hasAttribute("style") ? notification | ||||
.getStringAttribute("style") | |||||
: null; | |||||
.getStringAttribute("style") : null; | |||||
final int position = notification | final int position = notification | ||||
.getIntAttribute("position"); | .getIntAttribute("position"); | ||||
final int delay = notification.getIntAttribute("delay"); | final int delay = notification.getIntAttribute("delay"); | ||||
private void showModalityCurtain() { | private void showModalityCurtain() { | ||||
if (BrowserInfo.get().isFF2()) { | if (BrowserInfo.get().isFF2()) { | ||||
DOM.setStyleAttribute(modalityCurtain, "height", DOM | |||||
.getElementPropertyInt(RootPanel.getBodyElement(), | |||||
"offsetHeight") | |||||
+ "px"); | |||||
DOM.setStyleAttribute( | |||||
modalityCurtain, | |||||
"height", | |||||
DOM.getElementPropertyInt(RootPanel.getBodyElement(), | |||||
"offsetHeight") + "px"); | |||||
DOM.setStyleAttribute(modalityCurtain, "position", "absolute"); | DOM.setStyleAttribute(modalityCurtain, "position", "absolute"); | ||||
} | } | ||||
DOM.setStyleAttribute(modalityCurtain, "zIndex", "" | |||||
+ (windowOrder.indexOf(this) + Z_INDEX)); | |||||
DOM.setStyleAttribute(modalityCurtain, "zIndex", | |||||
"" + (windowOrder.indexOf(this) + Z_INDEX)); | |||||
DOM.appendChild(RootPanel.getBodyElement(), modalityCurtain); | DOM.appendChild(RootPanel.getBodyElement(), modalityCurtain); | ||||
} | } | ||||
rootPixelWidth = getElement().getOffsetWidth(); | rootPixelWidth = getElement().getOffsetWidth(); | ||||
width = rootPixelWidth + "px"; | width = rootPixelWidth + "px"; | ||||
} else { | } else { | ||||
rootPixelWidth = Integer.parseInt(width.substring(0, width | |||||
.indexOf("px"))); | |||||
rootPixelWidth = Integer.parseInt(width.substring(0, | |||||
width.indexOf("px"))); | |||||
} | } | ||||
// "width" now contains the new width in pixels | // "width" now contains the new width in pixels | ||||
// debug window | // debug window | ||||
Console console = ApplicationConnection.getConsole(); | Console console = ApplicationConnection.getConsole(); | ||||
if (console instanceof VDebugConsole | if (console instanceof VDebugConsole | ||||
&& DOM.isOrHasChild(((VDebugConsole) console) | |||||
.getElement(), target)) { | |||||
&& DOM.isOrHasChild( | |||||
((VDebugConsole) console).getElement(), target)) { | |||||
return true; // allow debug-window clicks | return true; // allow debug-window clicks | ||||
} | } | ||||
return false; | return false; |
import com.google.gwt.event.shared.HandlerRegistration; | import com.google.gwt.event.shared.HandlerRegistration; | ||||
import com.google.gwt.user.client.Command; | import com.google.gwt.user.client.Command; | ||||
import com.google.gwt.user.client.Event; | import com.google.gwt.user.client.Event; | ||||
import com.google.gwt.user.client.Timer; | |||||
import com.google.gwt.user.client.Event.NativePreviewEvent; | import com.google.gwt.user.client.Event.NativePreviewEvent; | ||||
import com.google.gwt.user.client.Event.NativePreviewHandler; | import com.google.gwt.user.client.Event.NativePreviewHandler; | ||||
import com.google.gwt.user.client.Timer; | |||||
import com.google.gwt.user.client.ui.RootPanel; | import com.google.gwt.user.client.ui.RootPanel; | ||||
import com.google.gwt.user.client.ui.Widget; | import com.google.gwt.user.client.ui.Widget; | ||||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
VTransferable transferable = currentDrag.getTransferable(); | VTransferable transferable = currentDrag.getTransferable(); | ||||
client.updateVariable(DD_SERVICE, "component", transferable | |||||
.getDragSource(), false); | |||||
client.updateVariable(DD_SERVICE, "component", | |||||
transferable.getDragSource(), false); | |||||
client.updateVariable(DD_SERVICE, "type", drop.ordinal(), false); | client.updateVariable(DD_SERVICE, "type", drop.ordinal(), false); | ||||
import com.google.gwt.dom.client.Document; | import com.google.gwt.dom.client.Document; | ||||
import com.google.gwt.dom.client.NativeEvent; | import com.google.gwt.dom.client.NativeEvent; | ||||
import com.google.gwt.dom.client.Style.Unit; | |||||
import com.google.gwt.dom.client.TableElement; | import com.google.gwt.dom.client.TableElement; | ||||
import com.google.gwt.dom.client.TableSectionElement; | import com.google.gwt.dom.client.TableSectionElement; | ||||
import com.google.gwt.dom.client.Style.Unit; | |||||
import com.google.gwt.event.dom.client.MouseOverEvent; | import com.google.gwt.event.dom.client.MouseOverEvent; | ||||
import com.google.gwt.user.client.Element; | import com.google.gwt.user.client.Element; | ||||
import com.vaadin.terminal.gwt.client.BrowserInfo; | import com.vaadin.terminal.gwt.client.BrowserInfo; |
static { | static { | ||||
helper = Document.get().createDivElement(); | helper = Document.get().createDivElement(); | ||||
helper | |||||
.setInnerHTML("<div style=\"position:absolute;top:0;left:0;height:0;visibility:hidden;overflow:hidden;\">" | |||||
+ "<div style=\"width:0;height:0;visibility:hidden;overflow:hidden;\">" | |||||
+ "</div></div>" | |||||
+ "<div style=\"position:absolute;height:0;overflow:hidden;\"></div>"); | |||||
helper.setInnerHTML("<div style=\"position:absolute;top:0;left:0;height:0;visibility:hidden;overflow:hidden;\">" | |||||
+ "<div style=\"width:0;height:0;visibility:hidden;overflow:hidden;\">" | |||||
+ "</div></div>" | |||||
+ "<div style=\"position:absolute;height:0;overflow:hidden;\"></div>"); | |||||
NodeList<Node> childNodes = helper.getChildNodes(); | NodeList<Node> childNodes = helper.getChildNodes(); | ||||
measurement = (DivElement) childNodes.getItem(0); | measurement = (DivElement) childNodes.getItem(0); | ||||
measurement2 = (DivElement) measurement.getFirstChildElement(); | measurement2 = (DivElement) measurement.getFirstChildElement(); |
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.BrowserInfo; | import com.vaadin.terminal.gwt.client.BrowserInfo; | ||||
import com.vaadin.terminal.gwt.client.Paintable; | import com.vaadin.terminal.gwt.client.Paintable; | ||||
import com.vaadin.terminal.gwt.client.RenderInformation.FloatSize; | |||||
import com.vaadin.terminal.gwt.client.RenderInformation.Size; | |||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.Util; | import com.vaadin.terminal.gwt.client.Util; | ||||
import com.vaadin.terminal.gwt.client.VCaption; | import com.vaadin.terminal.gwt.client.VCaption; | ||||
import com.vaadin.terminal.gwt.client.RenderInformation.FloatSize; | |||||
import com.vaadin.terminal.gwt.client.RenderInformation.Size; | |||||
import com.vaadin.terminal.gwt.client.ui.AlignmentInfo; | import com.vaadin.terminal.gwt.client.ui.AlignmentInfo; | ||||
public class ChildComponentContainer extends Panel { | public class ChildComponentContainer extends Panel { | ||||
// FF2 chokes on some floats very easily. Measuring size escpecially | // FF2 chokes on some floats very easily. Measuring size escpecially | ||||
// becomes terribly slow | // becomes terribly slow | ||||
TableElement tableEl = Document.get().createTableElement(); | TableElement tableEl = Document.get().createTableElement(); | ||||
tableEl | |||||
.setInnerHTML("<tbody><tr><td><div></div></td></tr></tbody>"); | |||||
tableEl.setInnerHTML("<tbody><tr><td><div></div></td></tr></tbody>"); | |||||
DivElement div = (DivElement) tableEl.getFirstChildElement() | DivElement div = (DivElement) tableEl.getFirstChildElement() | ||||
.getFirstChildElement().getFirstChildElement() | .getFirstChildElement().getFirstChildElement() | ||||
.getFirstChildElement(); | .getFirstChildElement(); | ||||
setMarginTop(containerMarginTop); | setMarginTop(containerMarginTop); | ||||
if (caption != null) { | if (caption != null) { | ||||
caption.getElement().getStyle().setPropertyPx("marginLeft", | |||||
alignmentLeftOffsetForCaption); | |||||
caption.getElement().getStyle() | |||||
.setPropertyPx("marginLeft", alignmentLeftOffsetForCaption); | |||||
} | } | ||||
widgetDIV.getStyle().setPropertyPx("marginLeft", | widgetDIV.getStyle().setPropertyPx("marginLeft", | ||||
alignmentLeftOffsetForWidget); | alignmentLeftOffsetForWidget); | ||||
* Take into account the rare case that the caption on the right | * Take into account the rare case that the caption on the right | ||||
* side of the component AND is higher than the component | * side of the component AND is higher than the component | ||||
*/ | */ | ||||
emptySpace -= Math.max(widgetSize.getHeight(), caption | |||||
.getHeight()); | |||||
emptySpace -= Math.max(widgetSize.getHeight(), | |||||
caption.getHeight()); | |||||
} else { | } else { | ||||
emptySpace -= widgetSize.getHeight(); | emptySpace -= widgetSize.getHeight(); | ||||
emptySpace -= getCaptionHeight(); | emptySpace -= getCaptionHeight(); |
setStyleName("gwt-RichTextToolbar"); | setStyleName("gwt-RichTextToolbar"); | ||||
if (basic != null) { | if (basic != null) { | ||||
topPanel.add(bold = createToggleButton(images.bold(), strings | |||||
.bold())); | |||||
topPanel.add(italic = createToggleButton(images.italic(), strings | |||||
.italic())); | |||||
topPanel.add(bold = createToggleButton(images.bold(), | |||||
strings.bold())); | |||||
topPanel.add(italic = createToggleButton(images.italic(), | |||||
strings.italic())); | |||||
topPanel.add(underline = createToggleButton(images.underline(), | topPanel.add(underline = createToggleButton(images.underline(), | ||||
strings.underline())); | strings.underline())); | ||||
topPanel.add(subscript = createToggleButton(images.subscript(), | topPanel.add(subscript = createToggleButton(images.subscript(), | ||||
strings.superscript())); | strings.superscript())); | ||||
topPanel.add(justifyLeft = createPushButton(images.justifyLeft(), | topPanel.add(justifyLeft = createPushButton(images.justifyLeft(), | ||||
strings.justifyLeft())); | strings.justifyLeft())); | ||||
topPanel.add(justifyCenter = createPushButton(images | |||||
.justifyCenter(), strings.justifyCenter())); | |||||
topPanel.add(justifyCenter = createPushButton( | |||||
images.justifyCenter(), strings.justifyCenter())); | |||||
topPanel.add(justifyRight = createPushButton(images.justifyRight(), | topPanel.add(justifyRight = createPushButton(images.justifyRight(), | ||||
strings.justifyRight())); | strings.justifyRight())); | ||||
} | } | ||||
if (extended != null) { | if (extended != null) { | ||||
topPanel.add(strikethrough = createToggleButton(images | |||||
.strikeThrough(), strings.strikeThrough())); | |||||
topPanel.add(indent = createPushButton(images.indent(), strings | |||||
.indent())); | |||||
topPanel.add(outdent = createPushButton(images.outdent(), strings | |||||
.outdent())); | |||||
topPanel.add(strikethrough = createToggleButton( | |||||
images.strikeThrough(), strings.strikeThrough())); | |||||
topPanel.add(indent = createPushButton(images.indent(), | |||||
strings.indent())); | |||||
topPanel.add(outdent = createPushButton(images.outdent(), | |||||
strings.outdent())); | |||||
topPanel.add(hr = createPushButton(images.hr(), strings.hr())); | topPanel.add(hr = createPushButton(images.hr(), strings.hr())); | ||||
topPanel.add(ol = createPushButton(images.ol(), strings.ol())); | topPanel.add(ol = createPushButton(images.ol(), strings.ol())); | ||||
topPanel.add(ul = createPushButton(images.ul(), strings.ul())); | topPanel.add(ul = createPushButton(images.ul(), strings.ul())); |
for (final Enumeration e = config.getInitParameterNames(); e | for (final Enumeration e = config.getInitParameterNames(); e | ||||
.hasMoreElements();) { | .hasMoreElements();) { | ||||
final String name = (String) e.nextElement(); | final String name = (String) e.nextElement(); | ||||
applicationProperties.setProperty(name, config | |||||
.getInitParameter(name)); | |||||
applicationProperties.setProperty(name, | |||||
config.getInitParameter(name)); | |||||
} | } | ||||
// Overrides with server.xml parameters | // Overrides with server.xml parameters | ||||
for (final Enumeration e = context.getInitParameterNames(); e | for (final Enumeration e = context.getInitParameterNames(); e | ||||
.hasMoreElements();) { | .hasMoreElements();) { | ||||
final String name = (String) e.nextElement(); | final String name = (String) e.nextElement(); | ||||
applicationProperties.setProperty(name, context | |||||
.getInitParameter(name)); | |||||
applicationProperties.setProperty(name, | |||||
context.getInitParameter(name)); | |||||
} | } | ||||
checkProductionMode(); | checkProductionMode(); | ||||
checkCrossSiteProtection(); | checkCrossSiteProtection(); | ||||
pkgName = pkg.getName(); | pkgName = pkg.getName(); | ||||
} else { | } else { | ||||
final String className = getClass().getName(); | final String className = getClass().getName(); | ||||
pkgName = new String(className.toCharArray(), 0, className | |||||
.lastIndexOf('.')); | |||||
pkgName = new String(className.toCharArray(), 0, | |||||
className.lastIndexOf('.')); | |||||
} | } | ||||
val = System.getProperty(pkgName + "." + parameterName); | val = System.getProperty(pkgName + "." + parameterName); | ||||
if (val != null) { | if (val != null) { | ||||
protected String getStaticFilesLocation(PortletRequest request) { | protected String getStaticFilesLocation(PortletRequest request) { | ||||
// TODO allow overriding on portlet level? | // TODO allow overriding on portlet level? | ||||
String staticFileLocation = getPortalProperty( | String staticFileLocation = getPortalProperty( | ||||
Constants.PORTAL_PARAMETER_VAADIN_RESOURCE_PATH, request | |||||
.getPortalContext()); | |||||
Constants.PORTAL_PARAMETER_VAADIN_RESOURCE_PATH, | |||||
request.getPortalContext()); | |||||
if (staticFileLocation != null) { | if (staticFileLocation != null) { | ||||
// remove trailing slash if any | // remove trailing slash if any | ||||
while (staticFileLocation.endsWith(".")) { | while (staticFileLocation.endsWith(".")) { | ||||
private void updateBrowserProperties(WebBrowser browser, | private void updateBrowserProperties(WebBrowser browser, | ||||
PortletRequest request) { | PortletRequest request) { | ||||
String userAgent = getHTTPHeader(request, "user-agent"); | String userAgent = getHTTPHeader(request, "user-agent"); | ||||
browser.updateBrowserProperties(request.getLocale(), null, request | |||||
.isSecure(), userAgent, getHTTPRequestParameter(request, "sw"), | |||||
browser.updateBrowserProperties(request.getLocale(), null, | |||||
request.isSecure(), userAgent, | |||||
getHTTPRequestParameter(request, "sw"), | |||||
getHTTPRequestParameter(request, "sh")); | getHTTPRequestParameter(request, "sh")); | ||||
} | } | ||||
ResourceResponse response) throws IOException { | ResourceResponse response) throws IOException { | ||||
if (stream.getParameter("Location") != null) { | if (stream.getParameter("Location") != null) { | ||||
response.setProperty(ResourceResponse.HTTP_STATUS_CODE, Integer | |||||
.toString(HttpServletResponse.SC_MOVED_TEMPORARILY)); | |||||
response.setProperty(ResourceResponse.HTTP_STATUS_CODE, | |||||
Integer.toString(HttpServletResponse.SC_MOVED_TEMPORARILY)); | |||||
response.setProperty("Location", stream.getParameter("Location")); | response.setProperty("Location", stream.getParameter("Location")); | ||||
return; | return; | ||||
} | } | ||||
} else { | } else { | ||||
System.err.println("Requested resource [" + resourceID | System.err.println("Requested resource [" + resourceID | ||||
+ "] could not be found"); | + "] could not be found"); | ||||
response.setProperty(ResourceResponse.HTTP_STATUS_CODE, Integer | |||||
.toString(HttpServletResponse.SC_NOT_FOUND)); | |||||
response.setProperty(ResourceResponse.HTTP_STATUS_CODE, | |||||
Integer.toString(HttpServletResponse.SC_NOT_FOUND)); | |||||
} | } | ||||
} | } | ||||
widgetset = DEFAULT_WIDGETSET; | widgetset = DEFAULT_WIDGETSET; | ||||
} | } | ||||
String widgetsetURL = getWidgetsetURL(widgetset, request); | String widgetsetURL = getWidgetsetURL(widgetset, request); | ||||
writer | |||||
.write("document.write('<iframe tabIndex=\"-1\" id=\"__gwt_historyFrame\" " | |||||
+ "style=\"width:0;height:0;border:0;overflow:" | |||||
+ "hidden\" src=\"javascript:false\"></iframe>');\n"); | |||||
writer.write("document.write('<iframe tabIndex=\"-1\" id=\"__gwt_historyFrame\" " | |||||
+ "style=\"width:0;height:0;border:0;overflow:" | |||||
+ "hidden\" src=\"javascript:false\"></iframe>');\n"); | |||||
writer.write("document.write(\"<script language='javascript' src='" | writer.write("document.write(\"<script language='javascript' src='" | ||||
+ widgetsetURL + "'><\\/script>\");\n}\n"); | + widgetsetURL + "'><\\/script>\");\n}\n"); | ||||
} | } | ||||
} | } | ||||
writer.write("if(!vaadin.themesLoaded['" + portalTheme + "']) {\n"); | writer.write("if(!vaadin.themesLoaded['" + portalTheme + "']) {\n"); | ||||
writer | |||||
.write("var defaultStylesheet = document.createElement('link');\n"); | |||||
writer.write("var defaultStylesheet = document.createElement('link');\n"); | |||||
writer.write("defaultStylesheet.setAttribute('rel', 'stylesheet');\n"); | writer.write("defaultStylesheet.setAttribute('rel', 'stylesheet');\n"); | ||||
writer.write("defaultStylesheet.setAttribute('type', 'text/css');\n"); | writer.write("defaultStylesheet.setAttribute('type', 'text/css');\n"); | ||||
writer.write("defaultStylesheet.setAttribute('href', '" | writer.write("defaultStylesheet.setAttribute('href', '" | ||||
+ getThemeURI(portalTheme, request) + "/styles.css');\n"); | + getThemeURI(portalTheme, request) + "/styles.css');\n"); | ||||
writer | |||||
.write("document.getElementsByTagName('head')[0].appendChild(defaultStylesheet);\n"); | |||||
writer.write("document.getElementsByTagName('head')[0].appendChild(defaultStylesheet);\n"); | |||||
writer.write("vaadin.themesLoaded['" + portalTheme + "'] = true;\n}\n"); | writer.write("vaadin.themesLoaded['" + portalTheme + "'] = true;\n}\n"); | ||||
if (!portalTheme.equals(themeName)) { | if (!portalTheme.equals(themeName)) { | ||||
writer.write("stylesheet.setAttribute('type', 'text/css');\n"); | writer.write("stylesheet.setAttribute('type', 'text/css');\n"); | ||||
writer.write("stylesheet.setAttribute('href', '" + themeURI | writer.write("stylesheet.setAttribute('href', '" + themeURI | ||||
+ "/styles.css');\n"); | + "/styles.css');\n"); | ||||
writer | |||||
.write("document.getElementsByTagName('head')[0].appendChild(stylesheet);\n"); | |||||
writer.write("document.getElementsByTagName('head')[0].appendChild(stylesheet);\n"); | |||||
writer.write("vaadin.themesLoaded['" + themeName | writer.write("vaadin.themesLoaded['" + themeName | ||||
+ "'] = true;\n}\n"); | + "'] = true;\n}\n"); | ||||
} | } | ||||
if (themeName == null) { | if (themeName == null) { | ||||
// no, is the default theme defined by the portal? | // no, is the default theme defined by the portal? | ||||
themeName = getPortalProperty( | themeName = getPortalProperty( | ||||
Constants.PORTAL_PARAMETER_VAADIN_THEME, request | |||||
.getPortalContext()); | |||||
Constants.PORTAL_PARAMETER_VAADIN_THEME, | |||||
request.getPortalContext()); | |||||
} | } | ||||
if (themeName == null) { | if (themeName == null) { | ||||
// if this was an UIDL request, response UIDL back to client | // if this was an UIDL request, response UIDL back to client | ||||
if (getRequestType(request) == RequestType.UIDL) { | if (getRequestType(request) == RequestType.UIDL) { | ||||
Application.SystemMessages ci = getSystemMessages(); | Application.SystemMessages ci = getSystemMessages(); | ||||
criticalNotification(request, (ResourceResponse) response, ci | |||||
.getInternalErrorCaption(), ci.getInternalErrorMessage(), | |||||
criticalNotification(request, (ResourceResponse) response, | |||||
ci.getInternalErrorCaption(), ci.getInternalErrorMessage(), | |||||
null, ci.getInternalErrorURL()); | null, ci.getInternalErrorURL()); | ||||
if (application != null) { | if (application != null) { | ||||
application.getErrorHandler() | application.getErrorHandler() | ||||
* @return | * @return | ||||
*/ | */ | ||||
protected static String getPortalProperty(String name, PortalContext context) { | protected static String getPortalProperty(String name, PortalContext context) { | ||||
boolean isLifeRay = context.getPortalInfo().toLowerCase().contains( | |||||
"liferay"); | |||||
boolean isLifeRay = context.getPortalInfo().toLowerCase() | |||||
.contains("liferay"); | |||||
// TODO test on non-LifeRay platforms | // TODO test on non-LifeRay platforms | ||||
* read by {@link AbstractApplicationServlet}. | * read by {@link AbstractApplicationServlet}. | ||||
*/ | */ | ||||
public static final String REQUEST_FRAGMENT = ApplicationServlet.class | public static final String REQUEST_FRAGMENT = ApplicationServlet.class | ||||
.getName() | |||||
+ ".fragment"; | |||||
.getName() + ".fragment"; | |||||
/** | /** | ||||
* This request attribute forces widgetsets to be loaded from under the | * This request attribute forces widgetsets to be loaded from under the | ||||
* specified base path; e.g shared widgetset for all portlets in a portal. | * specified base path; e.g shared widgetset for all portlets in a portal. | ||||
* {@link AbstractApplicationServlet}. | * {@link AbstractApplicationServlet}. | ||||
*/ | */ | ||||
public static final String REQUEST_VAADIN_STATIC_FILE_PATH = ApplicationServlet.class | public static final String REQUEST_VAADIN_STATIC_FILE_PATH = ApplicationServlet.class | ||||
.getName() | |||||
+ ".widgetsetPath"; | |||||
.getName() + ".widgetsetPath"; | |||||
/** | /** | ||||
* This request attribute forces widgetset used; e.g for portlets that can | * This request attribute forces widgetset used; e.g for portlets that can | ||||
* not have different widgetsets. | * not have different widgetsets. | ||||
* {@link AbstractApplicationServlet}. | * {@link AbstractApplicationServlet}. | ||||
*/ | */ | ||||
public static final String REQUEST_WIDGETSET = ApplicationServlet.class | public static final String REQUEST_WIDGETSET = ApplicationServlet.class | ||||
.getName() | |||||
+ ".widgetset"; | |||||
.getName() + ".widgetset"; | |||||
/** | /** | ||||
* This request attribute indicates the shared widgetset (e.g. portal-wide | * This request attribute indicates the shared widgetset (e.g. portal-wide | ||||
* default widgetset). | * default widgetset). | ||||
* {@link AbstractApplicationServlet}. | * {@link AbstractApplicationServlet}. | ||||
*/ | */ | ||||
public static final String REQUEST_SHARED_WIDGETSET = ApplicationServlet.class | public static final String REQUEST_SHARED_WIDGETSET = ApplicationServlet.class | ||||
.getName() | |||||
+ ".sharedWidgetset"; | |||||
.getName() + ".sharedWidgetset"; | |||||
/** | /** | ||||
* If set, do not load the default theme but assume that loading it is | * If set, do not load the default theme but assume that loading it is | ||||
* handled e.g. by ApplicationPortlet. | * handled e.g. by ApplicationPortlet. | ||||
* {@link AbstractApplicationServlet}. | * {@link AbstractApplicationServlet}. | ||||
*/ | */ | ||||
public static final String REQUEST_DEFAULT_THEME = ApplicationServlet.class | public static final String REQUEST_DEFAULT_THEME = ApplicationServlet.class | ||||
.getName() | |||||
+ ".defaultThemeUri"; | |||||
.getName() + ".defaultThemeUri"; | |||||
/** | /** | ||||
* This request attribute is used to add styles to the main element. E.g | * This request attribute is used to add styles to the main element. E.g | ||||
* "height:500px" generates a style="height:500px" to the main element, | * "height:500px" generates a style="height:500px" to the main element, | ||||
* {@link AbstractApplicationServlet}. | * {@link AbstractApplicationServlet}. | ||||
*/ | */ | ||||
public static final String REQUEST_APPSTYLE = ApplicationServlet.class | public static final String REQUEST_APPSTYLE = ApplicationServlet.class | ||||
.getName() | |||||
+ ".style"; | |||||
.getName() + ".style"; | |||||
private Properties applicationProperties; | private Properties applicationProperties; | ||||
for (final Enumeration e = servletConfig.getInitParameterNames(); e | for (final Enumeration e = servletConfig.getInitParameterNames(); e | ||||
.hasMoreElements();) { | .hasMoreElements();) { | ||||
final String name = (String) e.nextElement(); | final String name = (String) e.nextElement(); | ||||
applicationProperties.setProperty(name, servletConfig | |||||
.getInitParameter(name)); | |||||
applicationProperties.setProperty(name, | |||||
servletConfig.getInitParameter(name)); | |||||
} | } | ||||
// Overrides with server.xml parameters | // Overrides with server.xml parameters | ||||
for (final Enumeration e = context.getInitParameterNames(); e | for (final Enumeration e = context.getInitParameterNames(); e | ||||
.hasMoreElements();) { | .hasMoreElements();) { | ||||
final String name = (String) e.nextElement(); | final String name = (String) e.nextElement(); | ||||
applicationProperties.setProperty(name, context | |||||
.getInitParameter(name)); | |||||
applicationProperties.setProperty(name, | |||||
context.getInitParameter(name)); | |||||
} | } | ||||
checkProductionMode(); | checkProductionMode(); | ||||
checkCrossSiteProtection(); | checkCrossSiteProtection(); | ||||
pkgName = pkg.getName(); | pkgName = pkg.getName(); | ||||
} else { | } else { | ||||
final String className = getClass().getName(); | final String className = getClass().getName(); | ||||
pkgName = new String(className.toCharArray(), 0, className | |||||
.lastIndexOf('.')); | |||||
pkgName = new String(className.toCharArray(), 0, | |||||
className.lastIndexOf('.')); | |||||
} | } | ||||
val = System.getProperty(pkgName + "." + parameterName); | val = System.getProperty(pkgName + "." + parameterName); | ||||
if (val != null) { | if (val != null) { | ||||
private void updateBrowserProperties(WebBrowser browser, | private void updateBrowserProperties(WebBrowser browser, | ||||
HttpServletRequest request) { | HttpServletRequest request) { | ||||
browser.updateBrowserProperties(request.getLocale(), request | |||||
.getRemoteAddr(), request.isSecure(), request | |||||
.getHeader("user-agent"), request.getParameter("sw"), request | |||||
.getParameter("sh")); | |||||
browser.updateBrowserProperties(request.getLocale(), | |||||
request.getRemoteAddr(), request.isSecure(), | |||||
request.getHeader("user-agent"), request.getParameter("sw"), | |||||
request.getParameter("sh")); | |||||
} | } | ||||
protected ClassLoader getClassLoader() throws ServletException { | protected ClassLoader getClassLoader() throws ServletException { | ||||
// if this was an UIDL request, response UIDL back to client | // if this was an UIDL request, response UIDL back to client | ||||
if (getRequestType(request) == RequestType.UIDL) { | if (getRequestType(request) == RequestType.UIDL) { | ||||
Application.SystemMessages ci = getSystemMessages(); | Application.SystemMessages ci = getSystemMessages(); | ||||
criticalNotification(request, response, ci | |||||
.getInternalErrorCaption(), ci.getInternalErrorMessage(), | |||||
criticalNotification(request, response, | |||||
ci.getInternalErrorCaption(), ci.getInternalErrorMessage(), | |||||
null, ci.getInternalErrorURL()); | null, ci.getInternalErrorURL()); | ||||
if (application != null) { | if (application != null) { | ||||
application.getErrorHandler() | application.getErrorHandler() | ||||
request.getSession().invalidate(); | request.getSession().invalidate(); | ||||
// send uidl redirect | // send uidl redirect | ||||
criticalNotification(request, response, ci | |||||
.getSessionExpiredCaption(), ci | |||||
.getSessionExpiredMessage(), null, ci | |||||
.getSessionExpiredURL()); | |||||
criticalNotification(request, response, | |||||
ci.getSessionExpiredCaption(), | |||||
ci.getSessionExpiredMessage(), null, | |||||
ci.getSessionExpiredURL()); | |||||
} | } | ||||
} catch (SystemMessageException ee) { | } catch (SystemMessageException ee) { | ||||
response.sendRedirect(ci.getCommunicationErrorURL()); | response.sendRedirect(ci.getCommunicationErrorURL()); | ||||
} else { | } else { | ||||
// send uidl redirect | // send uidl redirect | ||||
criticalNotification(request, response, ci | |||||
.getCommunicationErrorCaption(), ci | |||||
.getCommunicationErrorMessage(), | |||||
criticalNotification(request, response, | |||||
ci.getCommunicationErrorCaption(), | |||||
ci.getCommunicationErrorMessage(), | |||||
INVALID_SECURITY_KEY_MSG, ci.getCommunicationErrorURL()); | INVALID_SECURITY_KEY_MSG, ci.getCommunicationErrorURL()); | ||||
/* | /* | ||||
* Invalidate session. Portal integration will fail otherwise | * Invalidate session. Portal integration will fail otherwise | ||||
return true; | return true; | ||||
} else if (request.getRequestURI().startsWith( | } else if (request.getRequestURI().startsWith( | ||||
request.getContextPath() + "/VAADIN/")) { | request.getContextPath() + "/VAADIN/")) { | ||||
serveStaticResourcesInVAADIN(request.getRequestURI().substring( | |||||
request.getContextPath().length()), request, response); | |||||
serveStaticResourcesInVAADIN( | |||||
request.getRequestURI().substring( | |||||
request.getContextPath().length()), request, | |||||
response); | |||||
return true; | return true; | ||||
} | } | ||||
* cache timeout can be configured by setting the resourceCacheTime | * cache timeout can be configured by setting the resourceCacheTime | ||||
* parameter in web.xml | * parameter in web.xml | ||||
*/ | */ | ||||
response.setHeader("Cache-Control", "max-age: " | |||||
+ String.valueOf(resourceCacheTime)); | |||||
response.setHeader("Cache-Control", | |||||
"max-age: " + String.valueOf(resourceCacheTime)); | |||||
} | } | ||||
// Write the resource to the client. | // Write the resource to the client. | ||||
if (!isProductionMode()) { | if (!isProductionMode()) { | ||||
page.write("vaadin.debug = true;\n"); | page.write("vaadin.debug = true;\n"); | ||||
} | } | ||||
page | |||||
.write("document.write('<iframe tabIndex=\"-1\" id=\"__gwt_historyFrame\" " | |||||
+ "style=\"position:absolute;width:0;height:0;border:0;overflow:" | |||||
+ "hidden;\" src=\"javascript:false\"></iframe>');\n"); | |||||
page.write("document.write('<iframe tabIndex=\"-1\" id=\"__gwt_historyFrame\" " | |||||
+ "style=\"position:absolute;width:0;height:0;border:0;overflow:" | |||||
+ "hidden;\" src=\"javascript:false\"></iframe>');\n"); | |||||
page.write("document.write(\"<script language='javascript' src='" | page.write("document.write(\"<script language='javascript' src='" | ||||
+ widgetsetFilePath + "'><\\/script>\");\n}\n"); | + widgetsetFilePath + "'><\\/script>\");\n}\n"); | ||||
page.write("stylesheet.setAttribute('type', 'text/css');\n"); | page.write("stylesheet.setAttribute('type', 'text/css');\n"); | ||||
page.write("stylesheet.setAttribute('href', '" + themeUri | page.write("stylesheet.setAttribute('href', '" + themeUri | ||||
+ "/styles.css');\n"); | + "/styles.css');\n"); | ||||
page | |||||
.write("document.getElementsByTagName('head')[0].appendChild(stylesheet);\n"); | |||||
page.write("document.getElementsByTagName('head')[0].appendChild(stylesheet);\n"); | |||||
page.write("vaadin.themesLoaded['" + themeName + "'] = true;\n}\n"); | page.write("vaadin.themesLoaded['" + themeName + "'] = true;\n}\n"); | ||||
page.write("//]]>\n</script>\n"); | page.write("//]]>\n</script>\n"); | ||||
} | } | ||||
// inactivity | // inactivity | ||||
page.write("<script type=\"text/javascript\">\n"); | page.write("<script type=\"text/javascript\">\n"); | ||||
page.write("//<![CDATA[\n"); | page.write("//<![CDATA[\n"); | ||||
page | |||||
.write("setTimeout('if (typeof " | |||||
+ widgetset.replace('.', '_') | |||||
+ " == \"undefined\") {alert(\"Failed to load the widgetset: " | |||||
+ widgetsetFilePath + "\")};',15000);\n" | |||||
+ "//]]>\n</script>\n"); | |||||
page.write("setTimeout('if (typeof " + widgetset.replace('.', '_') | |||||
+ " == \"undefined\") {alert(\"Failed to load the widgetset: " | |||||
+ widgetsetFilePath + "\")};',15000);\n" + "//]]>\n</script>\n"); | |||||
} | } | ||||
/** | /** | ||||
*/ | */ | ||||
protected void writeAjaxPageHtmlHeader(final BufferedWriter page, | protected void writeAjaxPageHtmlHeader(final BufferedWriter page, | ||||
String title, String themeUri) throws IOException { | String title, String themeUri) throws IOException { | ||||
page | |||||
.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n"); | |||||
page.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n"); | |||||
page.write("<style type=\"text/css\">" | page.write("<style type=\"text/css\">" | ||||
+ "html, body {height:100%;margin:0;}</style>"); | + "html, body {height:100%;margin:0;}</style>"); | ||||
// Add favicon links | // Add favicon links | ||||
page | |||||
.write("<link rel=\"shortcut icon\" type=\"image/vnd.microsoft.icon\" href=\"" | |||||
+ themeUri + "/favicon.ico\" />"); | |||||
page | |||||
.write("<link rel=\"icon\" type=\"image/vnd.microsoft.icon\" href=\"" | |||||
+ themeUri + "/favicon.ico\" />"); | |||||
page.write("<link rel=\"shortcut icon\" type=\"image/vnd.microsoft.icon\" href=\"" | |||||
+ themeUri + "/favicon.ico\" />"); | |||||
page.write("<link rel=\"icon\" type=\"image/vnd.microsoft.icon\" href=\"" | |||||
+ themeUri + "/favicon.ico\" />"); | |||||
page.write("<title>" + title + "</title>"); | page.write("<title>" + title + "</title>"); | ||||
} | } |
import com.vaadin.terminal.PaintException; | import com.vaadin.terminal.PaintException; | ||||
import com.vaadin.terminal.PaintTarget; | import com.vaadin.terminal.PaintTarget; | ||||
import com.vaadin.terminal.Paintable; | import com.vaadin.terminal.Paintable; | ||||
import com.vaadin.terminal.URIHandler; | |||||
import com.vaadin.terminal.UploadStream; | |||||
import com.vaadin.terminal.VariableOwner; | |||||
import com.vaadin.terminal.Paintable.RepaintRequestEvent; | import com.vaadin.terminal.Paintable.RepaintRequestEvent; | ||||
import com.vaadin.terminal.Terminal.ErrorEvent; | import com.vaadin.terminal.Terminal.ErrorEvent; | ||||
import com.vaadin.terminal.Terminal.ErrorListener; | import com.vaadin.terminal.Terminal.ErrorListener; | ||||
import com.vaadin.terminal.URIHandler; | |||||
import com.vaadin.terminal.UploadStream; | |||||
import com.vaadin.terminal.VariableOwner; | |||||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.server.ComponentSizeValidator.InvalidLayout; | import com.vaadin.terminal.gwt.server.ComponentSizeValidator.InvalidLayout; | ||||
import com.vaadin.ui.AbstractField; | import com.vaadin.ui.AbstractField; | ||||
import com.vaadin.ui.Component; | import com.vaadin.ui.Component; | ||||
import com.vaadin.ui.DragAndDropWrapper; | import com.vaadin.ui.DragAndDropWrapper; | ||||
import com.vaadin.ui.Upload; | import com.vaadin.ui.Upload; | ||||
import com.vaadin.ui.Window; | |||||
import com.vaadin.ui.Upload.UploadException; | import com.vaadin.ui.Upload.UploadException; | ||||
import com.vaadin.ui.Window; | |||||
/** | /** | ||||
* This is a common base class for the server-side implementations of the | * This is a common base class for the server-side implementations of the | ||||
// we have more than one value changes in row for | // we have more than one value changes in row for | ||||
// one variable owner, collect em in HashMap | // one variable owner, collect em in HashMap | ||||
m = new HashMap<String, Object>(); | m = new HashMap<String, Object>(); | ||||
m.put(variable[VAR_NAME], convertVariableValue( | |||||
variable[VAR_TYPE].charAt(0), | |||||
variable[VAR_VALUE])); | |||||
m.put(variable[VAR_NAME], | |||||
convertVariableValue( | |||||
variable[VAR_TYPE].charAt(0), | |||||
variable[VAR_VALUE])); | |||||
} else { | } else { | ||||
// use optimized single value map | // use optimized single value map | ||||
m = Collections.singletonMap(variable[VAR_NAME], | |||||
convertVariableValue(variable[VAR_TYPE] | |||||
.charAt(0), variable[VAR_VALUE])); | |||||
m = Collections.singletonMap( | |||||
variable[VAR_NAME], | |||||
convertVariableValue( | |||||
variable[VAR_TYPE].charAt(0), | |||||
variable[VAR_VALUE])); | |||||
} | } | ||||
// collect following variable changes for this owner | // collect following variable changes for this owner | ||||
} else { | } else { | ||||
nextVariable = null; | nextVariable = null; | ||||
} | } | ||||
m.put(variable[VAR_NAME], convertVariableValue( | |||||
variable[VAR_TYPE].charAt(0), | |||||
variable[VAR_VALUE])); | |||||
m.put(variable[VAR_NAME], | |||||
convertVariableValue( | |||||
variable[VAR_TYPE].charAt(0), | |||||
variable[VAR_VALUE])); | |||||
} | } | ||||
try { | try { | ||||
owner.changeVariables(request, m); | owner.changeVariables(request, m); | ||||
URL windowContext; | URL windowContext; | ||||
windowContext = new URL(context, prefix + "/"); | windowContext = new URL(context, prefix + "/"); | ||||
final String windowUri = (uri.length() > prefix.length() + 1) ? uri | final String windowUri = (uri.length() > prefix.length() + 1) ? uri | ||||
.substring(prefix.length() + 1) | |||||
: ""; | |||||
.substring(prefix.length() + 1) : ""; | |||||
return window.handleURI(windowContext, windowUri); | return window.handleURI(windowContext, windowUri); | ||||
} else { | } else { | ||||
return null; | return null; |
} | } | ||||
} | } | ||||
// If any runtime exceptions occurred, throw a combined exception | |||||
// If any runtime exceptions occurred, throw a combined exception | |||||
if (exceptions != null) { | if (exceptions != null) { | ||||
final StringBuffer msg = new StringBuffer(); | final StringBuffer msg = new StringBuffer(); | ||||
for (Exception e : exceptions) { | for (Exception e : exceptions) { | ||||
* @see javax.servlet.http.HttpSessionBindingListener#valueBound(HttpSessionBindingEvent) | * @see javax.servlet.http.HttpSessionBindingListener#valueBound(HttpSessionBindingEvent) | ||||
*/ | */ | ||||
public void valueBound(HttpSessionBindingEvent arg0) { | public void valueBound(HttpSessionBindingEvent arg0) { | ||||
// We are not interested in bindings | |||||
// We are not interested in bindings | |||||
} | } | ||||
/** | /** | ||||
* @see javax.servlet.http.HttpSessionBindingListener#valueUnbound(HttpSessionBindingEvent) | * @see javax.servlet.http.HttpSessionBindingListener#valueUnbound(HttpSessionBindingEvent) | ||||
*/ | */ | ||||
public void valueUnbound(HttpSessionBindingEvent event) { | public void valueUnbound(HttpSessionBindingEvent event) { | ||||
// If we are going to be unbound from the session, the session must be | |||||
// closing | |||||
// If we are going to be unbound from the session, the session must be | |||||
// closing | |||||
try { | try { | ||||
while (!applications.isEmpty()) { | while (!applications.isEmpty()) { | ||||
final Application app = applications.iterator().next(); | final Application app = applications.iterator().next(); | ||||
removeApplication(app); | removeApplication(app); | ||||
} | } | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
// This should never happen but is possible with rare | |||||
// configurations (e.g. robustness tests). If you have one | |||||
// thread doing HTTP socket write and another thread trying to | |||||
// remove same application here. Possible if you got e.g. session | |||||
// lifetime 1 min but socket write may take longer than 1 min. | |||||
// FIXME: Handle exception | |||||
// This should never happen but is possible with rare | |||||
// configurations (e.g. robustness tests). If you have one | |||||
// thread doing HTTP socket write and another thread trying to | |||||
// remove same application here. Possible if you got e.g. session | |||||
// lifetime 1 min but socket write may take longer than 1 min. | |||||
// FIXME: Handle exception | |||||
System.err.println("Could not remove application, leaking memory."); | System.err.println("Could not remove application, leaking memory."); | ||||
e.printStackTrace(); | e.printStackTrace(); | ||||
} | } | ||||
} | } | ||||
public boolean isApplicationResourceURL(URL context, String relativeUri) { | public boolean isApplicationResourceURL(URL context, String relativeUri) { | ||||
// If the relative uri is null, we are ready | |||||
// If the relative uri is null, we are ready | |||||
if (relativeUri == null) { | if (relativeUri == null) { | ||||
return false; | return false; | ||||
} | } | ||||
// Resolves the prefix | |||||
// Resolves the prefix | |||||
String prefix = relativeUri; | String prefix = relativeUri; | ||||
final int index = relativeUri.indexOf('/'); | final int index = relativeUri.indexOf('/'); | ||||
if (index >= 0) { | if (index >= 0) { | ||||
prefix = relativeUri.substring(0, index); | prefix = relativeUri.substring(0, index); | ||||
} | } | ||||
// Handles the resource requests | |||||
// Handles the resource requests | |||||
return (prefix.equals("APP")); | return (prefix.equals("APP")); | ||||
} | } | ||||
*/ | */ | ||||
@SuppressWarnings("serial") | @SuppressWarnings("serial") | ||||
public class ApplicationPortlet implements Portlet, Serializable { | public class ApplicationPortlet implements Portlet, Serializable { | ||||
// portlet configuration parameters | |||||
// portlet configuration parameters | |||||
private static final String PORTLET_PARAMETER_APPLICATION = "application"; | private static final String PORTLET_PARAMETER_APPLICATION = "application"; | ||||
private static final String PORTLET_PARAMETER_STYLE = "style"; | private static final String PORTLET_PARAMETER_STYLE = "style"; | ||||
private static final String PORTLET_PARAMETER_WIDGETSET = "widgetset"; | private static final String PORTLET_PARAMETER_WIDGETSET = "widgetset"; | ||||
// The application to show | |||||
// The application to show | |||||
protected String app = null; | protected String app = null; | ||||
// some applications might require forced height (and, more seldom, width) | |||||
protected String style = null; // e.g "height:500px;" | |||||
// force the portlet to use this widgetset - portlet level setting | |||||
// some applications might require forced height (and, more seldom, width) | |||||
protected String style = null; // e.g "height:500px;" | |||||
// force the portlet to use this widgetset - portlet level setting | |||||
protected String portletWidgetset = null; | protected String portletWidgetset = null; | ||||
public void destroy() { | public void destroy() { | ||||
+ "' init parameter to be the servlet deployment path."); | + "' init parameter to be the servlet deployment path."); | ||||
} | } | ||||
style = config.getInitParameter(PORTLET_PARAMETER_STYLE); | style = config.getInitParameter(PORTLET_PARAMETER_STYLE); | ||||
// enable forcing the selection of the widgetset in portlet | |||||
// configuration for a single portlet (backwards compatibility) | |||||
// enable forcing the selection of the widgetset in portlet | |||||
// configuration for a single portlet (backwards compatibility) | |||||
portletWidgetset = config.getInitParameter(PORTLET_PARAMETER_WIDGETSET); | portletWidgetset = config.getInitParameter(PORTLET_PARAMETER_WIDGETSET); | ||||
} | } | ||||
public void render(RenderRequest request, RenderResponse response) | public void render(RenderRequest request, RenderResponse response) | ||||
throws PortletException, IOException { | throws PortletException, IOException { | ||||
// display the Vaadin application | |||||
// display the Vaadin application | |||||
writeAjaxWindow(request, response); | writeAjaxWindow(request, response); | ||||
} | } | ||||
.getRequestDispatcher("/" + app); | .getRequestDispatcher("/" + app); | ||||
try { | try { | ||||
// portal-wide settings | |||||
// portal-wide settings | |||||
PortalContext portalCtx = request.getPortalContext(); | PortalContext portalCtx = request.getPortalContext(); | ||||
boolean isLifeRay = portalCtx.getPortalInfo().toLowerCase() | boolean isLifeRay = portalCtx.getPortalInfo().toLowerCase() | ||||
request.setAttribute(ApplicationServlet.REQUEST_FRAGMENT, | request.setAttribute(ApplicationServlet.REQUEST_FRAGMENT, | ||||
"true"); | "true"); | ||||
// fixed base theme to use - all portal pages with Vaadin | |||||
// applications will load this exactly once | |||||
// fixed base theme to use - all portal pages with Vaadin | |||||
// applications will load this exactly once | |||||
String portalTheme = getPortalProperty( | String portalTheme = getPortalProperty( | ||||
Constants.PORTAL_PARAMETER_VAADIN_THEME, portalCtx); | Constants.PORTAL_PARAMETER_VAADIN_THEME, portalCtx); | ||||
String portalWidgetset = getPortalProperty( | String portalWidgetset = getPortalProperty( | ||||
Constants.PORTAL_PARAMETER_VAADIN_WIDGETSET, portalCtx); | Constants.PORTAL_PARAMETER_VAADIN_WIDGETSET, portalCtx); | ||||
// location of the widgetset(s) and default theme (to which | |||||
// /VAADIN/widgetsets/... | |||||
// is appended) | |||||
// location of the widgetset(s) and default theme (to which | |||||
// /VAADIN/widgetsets/... | |||||
// is appended) | |||||
String portalResourcePath = getPortalProperty( | String portalResourcePath = getPortalProperty( | ||||
Constants.PORTAL_PARAMETER_VAADIN_RESOURCE_PATH, | Constants.PORTAL_PARAMETER_VAADIN_RESOURCE_PATH, | ||||
portalCtx); | portalCtx); | ||||
if (portalResourcePath != null) { | if (portalResourcePath != null) { | ||||
// if portalResourcePath is defined, set it as a request | |||||
// parameter which will override the default location in | |||||
// servlet | |||||
// if portalResourcePath is defined, set it as a request | |||||
// parameter which will override the default location in | |||||
// servlet | |||||
request.setAttribute( | request.setAttribute( | ||||
ApplicationServlet.REQUEST_VAADIN_STATIC_FILE_PATH, | ApplicationServlet.REQUEST_VAADIN_STATIC_FILE_PATH, | ||||
portalResourcePath); | portalResourcePath); | ||||
} | } | ||||
// - if the user has specified a widgetset for this portlet, use | |||||
// it from the portlet (not fully supported) | |||||
// - otherwise, if specified, use the portal-wide widgetset | |||||
// and widgetset path settings (recommended) | |||||
// - finally, default to use the default widgetset if nothing | |||||
// else is found | |||||
// - if the user has specified a widgetset for this portlet, use | |||||
// it from the portlet (not fully supported) | |||||
// - otherwise, if specified, use the portal-wide widgetset | |||||
// and widgetset path settings (recommended) | |||||
// - finally, default to use the default widgetset if nothing | |||||
// else is found | |||||
if (portletWidgetset != null) { | if (portletWidgetset != null) { | ||||
request.setAttribute(ApplicationServlet.REQUEST_WIDGETSET, | request.setAttribute(ApplicationServlet.REQUEST_WIDGETSET, | ||||
portletWidgetset); | portletWidgetset); | ||||
style); | style); | ||||
} | } | ||||
// portalTheme is only used if the shared portal resource | |||||
// directory is defined | |||||
// portalTheme is only used if the shared portal resource | |||||
// directory is defined | |||||
if (portalTheme != null && portalResourcePath != null) { | if (portalTheme != null && portalResourcePath != null) { | ||||
request.setAttribute( | request.setAttribute( | ||||
ApplicationServlet.REQUEST_DEFAULT_THEME, | ApplicationServlet.REQUEST_DEFAULT_THEME, | ||||
*/ | */ | ||||
OutputStream out = response.getPortletOutputStream(); | OutputStream out = response.getPortletOutputStream(); | ||||
// Using portal-wide theme | |||||
// Using portal-wide theme | |||||
String loadDefaultTheme = ("<script type=\"text/javascript\">\n" | String loadDefaultTheme = ("<script type=\"text/javascript\">\n" | ||||
+ "if(!vaadin) { var vaadin = {} } \n" | + "if(!vaadin) { var vaadin = {} } \n" | ||||
+ "if(!vaadin.themesLoaded) { vaadin.themesLoaded = {} } \n" | + "if(!vaadin.themesLoaded) { vaadin.themesLoaded = {} } \n" | ||||
} | } | ||||
private String getPortalProperty(String name, PortalContext context) { | private String getPortalProperty(String name, PortalContext context) { | ||||
boolean isLifeRay = context.getPortalInfo().toLowerCase().contains( | |||||
"liferay"); | |||||
boolean isLifeRay = context.getPortalInfo().toLowerCase() | |||||
.contains("liferay"); | |||||
// TODO test on non-LifeRay platforms | |||||
// TODO test on non-LifeRay platforms | |||||
String value; | String value; | ||||
if (isLifeRay) { | if (isLifeRay) { |
* context, runner, application classname | * context, runner, application classname | ||||
*/ | */ | ||||
private static URIS getApplicationRunnerURIs(HttpServletRequest request) { | private static URIS getApplicationRunnerURIs(HttpServletRequest request) { | ||||
final String[] urlParts = request.getRequestURI().toString().split( | |||||
"\\/"); | |||||
final String[] urlParts = request.getRequestURI().toString() | |||||
.split("\\/"); | |||||
String context = null; | String context = null; | ||||
String runner = null; | String runner = null; | ||||
URIS uris = new URIS(); | URIS uris = new URIS(); |
import java.util.Map; | import java.util.Map; | ||||
import com.vaadin.ui.Component; | |||||
import com.vaadin.ui.AbstractComponent.ComponentErrorEvent; | import com.vaadin.ui.AbstractComponent.ComponentErrorEvent; | ||||
import com.vaadin.ui.Component; | |||||
@SuppressWarnings("serial") | @SuppressWarnings("serial") | ||||
public class ChangeVariablesErrorEvent implements ComponentErrorEvent { | public class ChangeVariablesErrorEvent implements ComponentErrorEvent { |
public void criticalNotification(Request request, Response response, | public void criticalNotification(Request request, Response response, | ||||
String cap, String msg, String details, String outOfSyncURL) | String cap, String msg, String details, String outOfSyncURL) | ||||
throws IOException { | throws IOException { | ||||
servlet.criticalNotification((HttpServletRequest) request | |||||
.getWrappedRequest(), (HttpServletResponse) response | |||||
.getWrappedResponse(), cap, msg, details, outOfSyncURL); | |||||
servlet.criticalNotification( | |||||
(HttpServletRequest) request.getWrappedRequest(), | |||||
(HttpServletResponse) response.getWrappedResponse(), cap, | |||||
msg, details, outOfSyncURL); | |||||
} | } | ||||
public String getRequestPathInfo(Request request) { | public String getRequestPathInfo(Request request) { |
import com.vaadin.ui.CustomComponent; | import com.vaadin.ui.CustomComponent; | ||||
import com.vaadin.ui.Form; | import com.vaadin.ui.Form; | ||||
import com.vaadin.ui.GridLayout; | import com.vaadin.ui.GridLayout; | ||||
import com.vaadin.ui.GridLayout.Area; | |||||
import com.vaadin.ui.Layout; | import com.vaadin.ui.Layout; | ||||
import com.vaadin.ui.OrderedLayout; | import com.vaadin.ui.OrderedLayout; | ||||
import com.vaadin.ui.Panel; | import com.vaadin.ui.Panel; | ||||
import com.vaadin.ui.TabSheet; | import com.vaadin.ui.TabSheet; | ||||
import com.vaadin.ui.VerticalLayout; | import com.vaadin.ui.VerticalLayout; | ||||
import com.vaadin.ui.Window; | import com.vaadin.ui.Window; | ||||
import com.vaadin.ui.GridLayout.Area; | |||||
@SuppressWarnings("serial") | @SuppressWarnings("serial") | ||||
public class ComponentSizeValidator implements Serializable { | public class ComponentSizeValidator implements Serializable { | ||||
err.append("Layout problem detected: "); | err.append("Layout problem detected: "); | ||||
err.append(msg); | err.append(msg); | ||||
err.append("\n"); | err.append("\n"); | ||||
err | |||||
.append("Relative sizes were replaced by undefined sizes, components may not render as expected.\n"); | |||||
err.append("Relative sizes were replaced by undefined sizes, components may not render as expected.\n"); | |||||
errorStream.println(err); | errorStream.println(err); | ||||
} | } |
import com.google.appengine.api.datastore.DatastoreServiceFactory; | import com.google.appengine.api.datastore.DatastoreServiceFactory; | ||||
import com.google.appengine.api.datastore.Entity; | import com.google.appengine.api.datastore.Entity; | ||||
import com.google.appengine.api.datastore.EntityNotFoundException; | import com.google.appengine.api.datastore.EntityNotFoundException; | ||||
import com.google.appengine.api.datastore.FetchOptions.Builder; | |||||
import com.google.appengine.api.datastore.Key; | import com.google.appengine.api.datastore.Key; | ||||
import com.google.appengine.api.datastore.KeyFactory; | import com.google.appengine.api.datastore.KeyFactory; | ||||
import com.google.appengine.api.datastore.PreparedQuery; | import com.google.appengine.api.datastore.PreparedQuery; | ||||
import com.google.appengine.api.datastore.Query; | import com.google.appengine.api.datastore.Query; | ||||
import com.google.appengine.api.datastore.FetchOptions.Builder; | |||||
import com.google.appengine.api.datastore.Query.FilterOperator; | import com.google.appengine.api.datastore.Query.FilterOperator; | ||||
import com.google.appengine.api.memcache.Expiration; | import com.google.appengine.api.memcache.Expiration; | ||||
import com.google.appengine.api.memcache.MemcacheService; | import com.google.appengine.api.memcache.MemcacheService; | ||||
if (requestType == RequestType.APPLICATION_RESOURCE) { | if (requestType == RequestType.APPLICATION_RESOURCE) { | ||||
// no locking needed, let superclass handle | // no locking needed, let superclass handle | ||||
getApplicationContext(request, MemcacheServiceFactory | |||||
.getMemcacheService()); | |||||
getApplicationContext(request, | |||||
MemcacheServiceFactory.getMemcacheService()); | |||||
super.service(request, response); | super.service(request, response); | ||||
cleanSession(request); | cleanSession(request); | ||||
return; | return; | ||||
try { | try { | ||||
Thread.sleep(RETRY_AFTER_MILLISECONDS); | Thread.sleep(RETRY_AFTER_MILLISECONDS); | ||||
} catch (InterruptedException e) { | } catch (InterruptedException e) { | ||||
log | |||||
.info("Thread.sleep() interrupted while waiting for lock. Trying again. " | |||||
+ e); | |||||
log.info("Thread.sleep() interrupted while waiting for lock. Trying again. " | |||||
+ e); | |||||
} | } | ||||
} | } | ||||
// client to retry | // client to retry | ||||
response.setStatus(HttpServletResponse.SC_SERVICE_UNAVAILABLE); | response.setStatus(HttpServletResponse.SC_SERVICE_UNAVAILABLE); | ||||
// Note: currently interpreting Retry-After as ms, not sec | // Note: currently interpreting Retry-After as ms, not sec | ||||
response | |||||
.setHeader("Retry-After", "" + RETRY_AFTER_MILLISECONDS); | |||||
response.setHeader("Retry-After", "" + RETRY_AFTER_MILLISECONDS); | |||||
return; | return; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
log | |||||
.warning("Exception while cleaning: " | |||||
+ getStackTraceAsString(e)); | |||||
log.warning("Exception while cleaning: " + getStackTraceAsString(e)); | |||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* @author marc | * @author marc | ||||
*/ | */ | ||||
@SuppressWarnings( { "serial", "unchecked" }) | |||||
@SuppressWarnings({ "serial", "unchecked" }) | |||||
public class PortletApplicationContext extends WebApplicationContext implements | public class PortletApplicationContext extends WebApplicationContext implements | ||||
Serializable { | Serializable { | ||||
cx = new PortletApplicationContext(); | cx = new PortletApplicationContext(); | ||||
} | } | ||||
if (!(cx instanceof PortletApplicationContext)) { | if (!(cx instanceof PortletApplicationContext)) { | ||||
// TODO Should we even try this? And should we leave original as-is? | |||||
// TODO Should we even try this? And should we leave original as-is? | |||||
PortletApplicationContext pcx = new PortletApplicationContext(); | PortletApplicationContext pcx = new PortletApplicationContext(); | ||||
pcx.applications.addAll(cx.applications); | pcx.applications.addAll(cx.applications); | ||||
cx.applications.clear(); | cx.applications.clear(); | ||||
.iterator(); it.hasNext();) { | .iterator(); it.hasNext();) { | ||||
Application value = it.next(); | Application value = it.next(); | ||||
if (value == application) { | if (value == application) { | ||||
// values().iterator() is backed by the map | |||||
// values().iterator() is backed by the map | |||||
it.remove(); | it.remove(); | ||||
} | } | ||||
} | } |
.getAttribute(PortletApplicationContext2.class.getName()); | .getAttribute(PortletApplicationContext2.class.getName()); | ||||
if (cx == null) { | if (cx == null) { | ||||
cx = new PortletApplicationContext2(); | cx = new PortletApplicationContext2(); | ||||
session | |||||
.setAttribute(PortletApplicationContext2.class.getName(), | |||||
cx); | |||||
session.setAttribute(PortletApplicationContext2.class.getName(), cx); | |||||
} | } | ||||
if (cx.session == null) { | if (cx.session == null) { | ||||
cx.session = session; | cx.session = session; |
public void criticalNotification(Request request, Response response, | public void criticalNotification(Request request, Response response, | ||||
String cap, String msg, String details, String outOfSyncURL) | String cap, String msg, String details, String outOfSyncURL) | ||||
throws IOException { | throws IOException { | ||||
portlet.criticalNotification((PortletRequest) request | |||||
.getWrappedRequest(), (MimeResponse) response | |||||
.getWrappedResponse(), cap, msg, details, outOfSyncURL); | |||||
portlet.criticalNotification( | |||||
(PortletRequest) request.getWrappedRequest(), | |||||
(MimeResponse) response.getWrappedResponse(), cap, msg, | |||||
details, outOfSyncURL); | |||||
} | } | ||||
public String getRequestPathInfo(Request request) { | public String getRequestPathInfo(Request request) { |
} | } | ||||
public void flushBuffer() throws IOException { | public void flushBuffer() throws IOException { | ||||
// NOP | |||||
// TODO throw? | |||||
// NOP | |||||
// TODO throw? | |||||
} | } | ||||
public int getBufferSize() { | public int getBufferSize() { | ||||
} | } | ||||
public OutputStream getPortletOutputStream() throws IOException { | public OutputStream getPortletOutputStream() throws IOException { | ||||
// write forbidden | |||||
// write forbidden | |||||
return null; | return null; | ||||
} | } | ||||
public PrintWriter getWriter() throws IOException { | public PrintWriter getWriter() throws IOException { | ||||
// write forbidden | |||||
// write forbidden | |||||
return null; | return null; | ||||
} | } | ||||
} | } | ||||
public void reset() { | public void reset() { | ||||
// NOP | |||||
// TODO throw? | |||||
// NOP | |||||
// TODO throw? | |||||
} | } | ||||
public void resetBuffer() { | public void resetBuffer() { | ||||
// NOP | |||||
// TODO throw? | |||||
// NOP | |||||
// TODO throw? | |||||
} | } | ||||
public void setBufferSize(int size) { | public void setBufferSize(int size) { | ||||
// NOP | |||||
// TODO throw? | |||||
// NOP | |||||
// TODO throw? | |||||
} | } | ||||
public void setContentType(String type) { | public void setContentType(String type) { | ||||
// NOP | |||||
// TODO throw? | |||||
// NOP | |||||
// TODO throw? | |||||
} | } | ||||
public void setProperty(String key, String value) { | public void setProperty(String key, String value) { | ||||
} | } | ||||
public void setNextPossiblePortletModes(Collection<PortletMode> portletModes) { | public void setNextPossiblePortletModes(Collection<PortletMode> portletModes) { | ||||
// NOP | |||||
// TODO throw? | |||||
// NOP | |||||
// TODO throw? | |||||
} | } | ||||
public ResourceURL createResourceURL() { | public ResourceURL createResourceURL() { | ||||
} | } | ||||
public void addProperty(Cookie cookie) { | public void addProperty(Cookie cookie) { | ||||
// NOP | |||||
// TODO throw? | |||||
// NOP | |||||
// TODO throw? | |||||
} | } | ||||
public void addProperty(String key, Element element) { | public void addProperty(String key, Element element) { | ||||
// NOP | |||||
// TODO throw? | |||||
// NOP | |||||
// TODO throw? | |||||
} | } | ||||
public Element createElement(String tagName) throws DOMException { | public Element createElement(String tagName) throws DOMException { | ||||
// NOP | |||||
// NOP | |||||
return null; | return null; | ||||
} | } | ||||
} | } |
* @see com.vaadin.service.ApplicationContext#getBaseDirectory() | * @see com.vaadin.service.ApplicationContext#getBaseDirectory() | ||||
*/ | */ | ||||
public File getBaseDirectory() { | public File getBaseDirectory() { | ||||
final String realPath = ApplicationServlet.getResourcePath(session | |||||
.getServletContext(), "/"); | |||||
final String realPath = ApplicationServlet.getResourcePath( | |||||
session.getServletContext(), "/"); | |||||
if (realPath == null) { | if (realPath == null) { | ||||
return null; | return null; | ||||
} | } |
import com.google.gwt.core.ext.Generator; | import com.google.gwt.core.ext.Generator; | ||||
import com.google.gwt.core.ext.GeneratorContext; | import com.google.gwt.core.ext.GeneratorContext; | ||||
import com.google.gwt.core.ext.TreeLogger; | import com.google.gwt.core.ext.TreeLogger; | ||||
import com.google.gwt.core.ext.UnableToCompleteException; | |||||
import com.google.gwt.core.ext.TreeLogger.Type; | import com.google.gwt.core.ext.TreeLogger.Type; | ||||
import com.google.gwt.core.ext.UnableToCompleteException; | |||||
import com.google.gwt.core.ext.typeinfo.JClassType; | import com.google.gwt.core.ext.typeinfo.JClassType; | ||||
import com.google.gwt.core.ext.typeinfo.TypeOracle; | import com.google.gwt.core.ext.typeinfo.TypeOracle; | ||||
import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; | import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; | ||||
ClassSourceFileComposerFactory composer = null; | ClassSourceFileComposerFactory composer = null; | ||||
composer = new ClassSourceFileComposerFactory(packageName, className); | composer = new ClassSourceFileComposerFactory(packageName, className); | ||||
composer.addImport("com.google.gwt.core.client.GWT"); | composer.addImport("com.google.gwt.core.client.GWT"); | ||||
composer | |||||
.setSuperclass("com.vaadin.terminal.gwt.client.ui.dd.VAcceptCriterionFactory"); | |||||
composer.setSuperclass("com.vaadin.terminal.gwt.client.ui.dd.VAcceptCriterionFactory"); | |||||
SourceWriter sourceWriter = composer.createSourceWriter(context, | SourceWriter sourceWriter = composer.createSourceWriter(context, | ||||
printWriter); | printWriter); | ||||
sourceWriter.println("}"); | sourceWriter.println("}"); | ||||
// commit generated class | // commit generated class | ||||
context.commit(logger, printWriter); | context.commit(logger, printWriter); | ||||
logger.log(Type.INFO, "Done. (" | |||||
+ (new Date().getTime() - date.getTime()) / 1000 + "seconds)"); | |||||
logger.log(Type.INFO, | |||||
"Done. (" + (new Date().getTime() - date.getTime()) / 1000 | |||||
+ "seconds)"); | |||||
} | } | ||||
.getCriterion(); | .getCriterion(); | ||||
for (Class<? extends AcceptCriterion> class1 : clientSideVerifiableCriterion) { | for (Class<? extends AcceptCriterion> class1 : clientSideVerifiableCriterion) { | ||||
logger.log(Type.INFO, "creating mapping for " | |||||
+ class1.getCanonicalName()); | |||||
logger.log(Type.INFO, | |||||
"creating mapping for " + class1.getCanonicalName()); | |||||
String canonicalName = class1.getCanonicalName(); | String canonicalName = class1.getCanonicalName(); | ||||
Class<? extends VAcceptCriterion> clientClass = class1 | Class<? extends VAcceptCriterion> clientClass = class1 | ||||
.getAnnotation(ClientCriterion.class).value(); | .getAnnotation(ClientCriterion.class).value(); |
/** | /** | ||||
* Finds server side widgets with {@link ClientWidget} annotation on the | * Finds server side widgets with {@link ClientWidget} annotation on the | ||||
* class path (entries that can contain widgets/widgetsets - see {@link #getRawClasspathEntries()}). | |||||
* class path (entries that can contain widgets/widgetsets - see | |||||
* {@link #getRawClasspathEntries()}). | |||||
* | * | ||||
* As a side effect, also accept criteria are searched under the same class | * As a side effect, also accept criteria are searched under the same class | ||||
* path entries and added into the acceptCriterion collection. | * path entries and added into the acceptCriterion collection. | ||||
String basePath = location.getFile().replaceAll( | String basePath = location.getFile().replaceAll( | ||||
"/" + packagePath + "$", ""); | "/" + packagePath + "$", ""); | ||||
try { | try { | ||||
URL url = new URL(location.getProtocol(), location | |||||
.getHost(), location.getPort(), basePath); | |||||
URL url = new URL(location.getProtocol(), | |||||
location.getHost(), location.getPort(), | |||||
basePath); | |||||
widgetsets.put(classname, url); | widgetsets.put(classname, url); | ||||
} catch (MalformedURLException e) { | } catch (MalformedURLException e) { | ||||
// should never happen as based on an existing URL, | // should never happen as based on an existing URL, | ||||
&& !dirs[i].getPath().contains(File.separator + ".")) { | && !dirs[i].getPath().contains(File.separator + ".")) { | ||||
String key = dirs[i].getCanonicalPath() + "/" + name | String key = dirs[i].getCanonicalPath() + "/" + name | ||||
+ dirs[i].getName(); | + dirs[i].getName(); | ||||
locations.put(key, new URL("file://" | |||||
+ dirs[i].getCanonicalPath())); | |||||
locations.put(key, | |||||
new URL("file://" + dirs[i].getCanonicalPath())); | |||||
} | } | ||||
} catch (Exception ioe) { | } catch (Exception ioe) { | ||||
return; | return; | ||||
String entryname = entry.getName(); | String entryname = entry.getName(); | ||||
if (!entry.isDirectory() | if (!entry.isDirectory() | ||||
&& entryname.endsWith(".class")) { | && entryname.endsWith(".class")) { | ||||
String classname = entryname.substring(0, entryname | |||||
.length() - 6); | |||||
String classname = entryname.substring(0, | |||||
entryname.length() - 6); | |||||
if (classname.startsWith("/")) { | if (classname.startsWith("/")) { | ||||
classname = classname.substring(1); | classname = classname.substring(1); | ||||
} | } |
import com.google.gwt.core.ext.Generator; | import com.google.gwt.core.ext.Generator; | ||||
import com.google.gwt.core.ext.GeneratorContext; | import com.google.gwt.core.ext.GeneratorContext; | ||||
import com.google.gwt.core.ext.TreeLogger; | import com.google.gwt.core.ext.TreeLogger; | ||||
import com.google.gwt.core.ext.UnableToCompleteException; | |||||
import com.google.gwt.core.ext.TreeLogger.Type; | import com.google.gwt.core.ext.TreeLogger.Type; | ||||
import com.google.gwt.core.ext.UnableToCompleteException; | |||||
import com.google.gwt.core.ext.typeinfo.JClassType; | import com.google.gwt.core.ext.typeinfo.JClassType; | ||||
import com.google.gwt.core.ext.typeinfo.TypeOracle; | import com.google.gwt.core.ext.typeinfo.TypeOracle; | ||||
import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; | import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; | ||||
if (printWriter == null) { | if (printWriter == null) { | ||||
return; | return; | ||||
} | } | ||||
logger | |||||
.log(Type.INFO, | |||||
"Detecting Vaadin components in classpath to generate WidgetMapImpl.java ..."); | |||||
logger.log(Type.INFO, | |||||
"Detecting Vaadin components in classpath to generate WidgetMapImpl.java ..."); | |||||
Date date = new Date(); | Date date = new Date(); | ||||
// init composer, set class properties, create source writer | // init composer, set class properties, create source writer | ||||
sourceWriter.println("}"); | sourceWriter.println("}"); | ||||
// commit generated class | // commit generated class | ||||
context.commit(logger, printWriter); | context.commit(logger, printWriter); | ||||
logger.log(Type.INFO, "Done. (" | |||||
+ (new Date().getTime() - date.getTime()) / 1000 + "seconds)"); | |||||
logger.log(Type.INFO, | |||||
"Done. (" + (new Date().getTime() - date.getTime()) / 1000 | |||||
+ "seconds)"); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
logger | |||||
.log(Type.INFO, | |||||
"Widget set will contain implementations for following components: "); | |||||
logger.log(Type.INFO, | |||||
"Widget set will contain implementations for following components: "); | |||||
TreeSet<String> classNames = new TreeSet<String>(); | TreeSet<String> classNames = new TreeSet<String>(); | ||||
for (Class<? extends Paintable> class1 : paintablesHavingWidgetAnnotation) { | for (Class<? extends Paintable> class1 : paintablesHavingWidgetAnnotation) { |
o.println(" 2. Give the widgetsetname (to be created or updated)" | o.println(" 2. Give the widgetsetname (to be created or updated)" | ||||
+ " as first parameter"); | + " as first parameter"); | ||||
o.println(); | o.println(); | ||||
o | |||||
.println("All found vaadin widgetsets will be inherited in given widgetset"); | |||||
o.println("All found vaadin widgetsets will be inherited in given widgetset"); | |||||
} | } | ||||
*/ | */ | ||||
public static void main(final String[] args) { | public static void main(final String[] args) { | ||||
try { | try { | ||||
// run the compiler in a different thread to enable using the | |||||
// user-set stack size | |||||
// run the compiler in a different thread to enable using the | |||||
// user-set stack size | |||||
// on Windows, the default stack size is too small for the main | |||||
// thread and cannot be changed in JRE 1.5 (see | |||||
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6316197) | |||||
// on Windows, the default stack size is too small for the main | |||||
// thread and cannot be changed in JRE 1.5 (see | |||||
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6316197) | |||||
Runnable runCompiler = new Runnable() { | Runnable runCompiler = new Runnable() { | ||||
public void run() { | public void run() { | ||||
try { | try { | ||||
// GWTCompiler.main(args); | |||||
// avoid warnings | |||||
// GWTCompiler.main(args); | |||||
// avoid warnings | |||||
String wsname = args[args.length - 1]; | String wsname = args[args.length - 1]; | ||||
// TODO expecting this is launched via eclipse WTP | |||||
// project | |||||
// TODO expecting this is launched via eclipse WTP | |||||
// project | |||||
System.out | System.out | ||||
.println("Updating GWT module description file..."); | .println("Updating GWT module description file..."); | ||||
WidgetSetBuilder.updateWidgetSet(wsname); | WidgetSetBuilder.updateWidgetSet(wsname); |
* InlineDateField date = new InlineDateField("Datum"); | * InlineDateField date = new InlineDateField("Datum"); | ||||
* | * | ||||
* // German language specified with ISO 639-1 language | * // German language specified with ISO 639-1 language | ||||
* // code and ISO 3166-1 alpha-2 country code. | |||||
* // code and ISO 3166-1 alpha-2 country code. | |||||
* date.setLocale(new Locale("de", "DE")); | * date.setLocale(new Locale("de", "DE")); | ||||
* | * | ||||
* date.setResolution(DateField.RESOLUTION_DAY); | * date.setResolution(DateField.RESOLUTION_DAY); | ||||
} | } | ||||
if (eventIdentifiers != null) { | if (eventIdentifiers != null) { | ||||
target.addAttribute("eventListeners", eventIdentifiers | |||||
.toArray()); | |||||
target.addAttribute("eventListeners", | |||||
eventIdentifiers.toArray()); | |||||
} | } | ||||
paintContent(target); | paintContent(target); |
*/ | */ | ||||
public void setMargin(boolean topEnabled, boolean rightEnabled, | public void setMargin(boolean topEnabled, boolean rightEnabled, | ||||
boolean bottomEnabled, boolean leftEnabled) { | boolean bottomEnabled, boolean leftEnabled) { | ||||
margins | |||||
.setMargins(topEnabled, rightEnabled, bottomEnabled, | |||||
leftEnabled); | |||||
margins.setMargins(topEnabled, rightEnabled, bottomEnabled, leftEnabled); | |||||
requestRepaint(); | requestRepaint(); | ||||
} | } | ||||
* </p> | * </p> | ||||
* | * | ||||
* @param caption | * @param caption | ||||
* the new caption for the component. If the caption is {@code | |||||
* null}, no caption is shown and it does not normally take any | |||||
* space | |||||
* the new caption for the component. If the caption is | |||||
* {@code null}, no caption is shown and it does not normally | |||||
* take any space | |||||
*/ | */ | ||||
public void setCaption(String caption); | public void setCaption(String caption); | ||||
* </p> | * </p> | ||||
* | * | ||||
* <p> | * <p> | ||||
* An icon will be rendered inside an HTML element that has the {@code | |||||
* v-icon} CSS style class. The containing layout may enclose an icon and a | |||||
* caption inside elements related to the caption, such as {@code v-caption} | |||||
* . | |||||
* An icon will be rendered inside an HTML element that has the | |||||
* {@code v-icon} CSS style class. The containing layout may enclose an icon | |||||
* and a caption inside elements related to the caption, such as | |||||
* {@code v-caption} . | |||||
* </p> | * </p> | ||||
* | * | ||||
* This method will trigger a | * This method will trigger a | ||||
* | * | ||||
* username.setTabIndex(1); | * username.setTabIndex(1); | ||||
* password.setTabIndex(2); | * password.setTabIndex(2); | ||||
* remember.setTabIndex(3); // Different than natural place | |||||
* remember.setTabIndex(3); // Different than natural place | |||||
* login.setTabIndex(4); | * login.setTabIndex(4); | ||||
* </pre> | * </pre> | ||||
* | * |
* <li>noticeably faster rendering time in some situations as we rely more on | * <li>noticeably faster rendering time in some situations as we rely more on | ||||
* the browser's rendering engine. | * the browser's rendering engine. | ||||
* </ul> | * </ul> | ||||
*<p> | |||||
* <p> | |||||
* With {@link CustomLayout} one can often achieve similar results (good looking | * With {@link CustomLayout} one can often achieve similar results (good looking | ||||
* layouts with web technologies), but with CustomLayout developer needs to work | * layouts with web technologies), but with CustomLayout developer needs to work | ||||
* with fixed templates. | * with fixed templates. |
throws UploadException { | throws UploadException { | ||||
Html5File file = receivers.get(fileId); | Html5File file = receivers.get(fileId); | ||||
if (file != null && file.receiver != null) { | if (file != null && file.receiver != null) { | ||||
OutputStream receiveUpload = file.receiver.receiveUpload(file | |||||
.getFileName(), "TODO"); | |||||
OutputStream receiveUpload = file.receiver.receiveUpload( | |||||
file.getFileName(), "TODO"); | |||||
InputStream stream = upstream.getStream(); | InputStream stream = upstream.getStream(); | ||||
byte[] buf = new byte[AbstractApplicationServlet.MAX_BUFFER_SIZE]; | byte[] buf = new byte[AbstractApplicationServlet.MAX_BUFFER_SIZE]; |
* @see com.vaadin.data.Item.Viewer#setItemDataSource(Item) | * @see com.vaadin.data.Item.Viewer#setItemDataSource(Item) | ||||
*/ | */ | ||||
public void setItemDataSource(Item newDataSource) { | public void setItemDataSource(Item newDataSource) { | ||||
setItemDataSource(newDataSource, newDataSource != null ? newDataSource | |||||
.getItemPropertyIds() : null); | |||||
setItemDataSource(newDataSource, | |||||
newDataSource != null ? newDataSource.getItemPropertyIds() | |||||
: null); | |||||
} | } | ||||
/** | /** | ||||
Field f = getField(properties[i]); | Field f = getField(properties[i]); | ||||
layout.removeComponent(f); | layout.removeComponent(f); | ||||
if (newLayout instanceof CustomLayout) { | if (newLayout instanceof CustomLayout) { | ||||
((CustomLayout) newLayout).addComponent(f, properties[i] | |||||
.toString()); | |||||
((CustomLayout) newLayout).addComponent(f, | |||||
properties[i].toString()); | |||||
} else { | } else { | ||||
newLayout.addComponent(f); | newLayout.addComponent(f); | ||||
} | } | ||||
+ propertyId.toString() + "' can not be found."); | + propertyId.toString() + "' can not be found."); | ||||
} | } | ||||
final Object value = oldField.getPropertyDataSource() == null ? oldField | final Object value = oldField.getPropertyDataSource() == null ? oldField | ||||
.getValue() | |||||
: oldField.getPropertyDataSource().getValue(); | |||||
.getValue() : oldField.getPropertyDataSource().getValue(); | |||||
// Checks that the value exists and check if the select should | // Checks that the value exists and check if the select should | ||||
// be forced in multiselect mode | // be forced in multiselect mode |
* bottom are by default on. | * bottom are by default on. | ||||
* | * | ||||
*/ | */ | ||||
@SuppressWarnings( { "deprecation", "serial" }) | |||||
@SuppressWarnings({ "deprecation", "serial" }) | |||||
@ClientWidget(VFormLayout.class) | @ClientWidget(VFormLayout.class) | ||||
public class FormLayout extends OrderedLayout { | public class FormLayout extends OrderedLayout { | ||||
import com.vaadin.terminal.PaintTarget; | import com.vaadin.terminal.PaintTarget; | ||||
import com.vaadin.terminal.gwt.client.MouseEventDetails; | import com.vaadin.terminal.gwt.client.MouseEventDetails; | ||||
import com.vaadin.terminal.gwt.client.ui.VGridLayout; | import com.vaadin.terminal.gwt.client.ui.VGridLayout; | ||||
import com.vaadin.ui.GridLayout.OverlapsException; | |||||
/** | /** | ||||
* <p> | * <p> | ||||
addComponent(newComponent); | addComponent(newComponent); | ||||
} else if (newLocation == null) { | } else if (newLocation == null) { | ||||
removeComponent(oldComponent); | removeComponent(oldComponent); | ||||
addComponent(newComponent, oldLocation.getColumn1(), oldLocation | |||||
.getRow1(), oldLocation.getColumn2(), oldLocation.getRow2()); | |||||
addComponent(newComponent, oldLocation.getColumn1(), | |||||
oldLocation.getRow1(), oldLocation.getColumn2(), | |||||
oldLocation.getRow2()); | |||||
} else { | } else { | ||||
oldLocation.setComponent(newComponent); | oldLocation.setComponent(newComponent); | ||||
newLocation.setComponent(oldComponent); | newLocation.setComponent(oldComponent); |
import java.io.Serializable; | import java.io.Serializable; | ||||
import com.vaadin.terminal.gwt.client.ui.VMarginInfo; | |||||
import com.vaadin.terminal.gwt.client.ui.AlignmentInfo.Bits; | import com.vaadin.terminal.gwt.client.ui.AlignmentInfo.Bits; | ||||
import com.vaadin.terminal.gwt.client.ui.VMarginInfo; | |||||
/** | /** | ||||
* Extension to the {@link ComponentContainer} interface which adds the | * Extension to the {@link ComponentContainer} interface which adds the |
import java.util.Map; | import java.util.Map; | ||||
import com.vaadin.event.Action; | import com.vaadin.event.Action; | ||||
import com.vaadin.event.ActionManager; | |||||
import com.vaadin.event.Action.Handler; | import com.vaadin.event.Action.Handler; | ||||
import com.vaadin.event.ActionManager; | |||||
import com.vaadin.event.MouseEvents.ClickEvent; | import com.vaadin.event.MouseEvents.ClickEvent; | ||||
import com.vaadin.event.MouseEvents.ClickListener; | import com.vaadin.event.MouseEvents.ClickListener; | ||||
import com.vaadin.terminal.PaintException; | import com.vaadin.terminal.PaintException; | ||||
// detach old content if present | // detach old content if present | ||||
if (content != null) { | if (content != null) { | ||||
content.setParent(null); | content.setParent(null); | ||||
content | |||||
.removeListener((ComponentContainer.ComponentAttachListener) this); | |||||
content | |||||
.removeListener((ComponentContainer.ComponentDetachListener) this); | |||||
content.removeListener((ComponentContainer.ComponentAttachListener) this); | |||||
content.removeListener((ComponentContainer.ComponentDetachListener) this); | |||||
} | } | ||||
// Sets the panel to be parent for the content | // Sets the panel to be parent for the content |
* {@link PopupView#getComponentIterator()}. | * {@link PopupView#getComponentIterator()}. | ||||
*/ | */ | ||||
private static class SingleComponentIterator implements | private static class SingleComponentIterator implements | ||||
Iterator<Component>, | |||||
Serializable { | |||||
Iterator<Component>, Serializable { | |||||
private final Component component; | private final Component component; | ||||
private boolean first; | private boolean first; |
int index = options.indexOf(selection); | int index = options.indexOf(selection); | ||||
if (index != -1 && (index < first || index >= last)) { | if (index != -1 && (index < first || index >= last)) { | ||||
int newPage = (index + (needNullSelectOption ? 1 | int newPage = (index + (needNullSelectOption ? 1 | ||||
: 0)) | |||||
/ pageLength; | |||||
: 0)) / pageLength; | |||||
currentPage = newPage; | currentPage = newPage; | ||||
return sanitetizeList(options, needNullSelectOption); | return sanitetizeList(options, needNullSelectOption); | ||||
} | } |
* setVolume(d.doubleValue()); | * setVolume(d.doubleValue()); | ||||
* } | * } | ||||
* } | * } | ||||
* | |||||
* | |||||
* </code> | * </code> | ||||
* | * | ||||
* @author IT Mill Ltd. | * @author IT Mill Ltd. | ||||
target.addAttribute("resolution", resolution); | target.addAttribute("resolution", resolution); | ||||
if (resolution > 0) { | if (resolution > 0) { | ||||
target.addVariable(this, "value", ((Double) getValue()) | |||||
.doubleValue()); | |||||
target.addVariable(this, "value", | |||||
((Double) getValue()).doubleValue()); | |||||
} else { | } else { | ||||
target.addVariable(this, "value", ((Double) getValue()).intValue()); | target.addVariable(this, "value", ((Double) getValue()).intValue()); | ||||
} | } |
import com.vaadin.terminal.Resource; | import com.vaadin.terminal.Resource; | ||||
import com.vaadin.terminal.gwt.client.ui.VTabsheet; | import com.vaadin.terminal.gwt.client.ui.VTabsheet; | ||||
import com.vaadin.terminal.gwt.server.CommunicationManager; | import com.vaadin.terminal.gwt.server.CommunicationManager; | ||||
import com.vaadin.ui.TabSheet.CloseHandler; | |||||
import com.vaadin.ui.TabSheet.Tab; | |||||
import com.vaadin.ui.themes.Reindeer; | import com.vaadin.ui.themes.Reindeer; | ||||
import com.vaadin.ui.themes.Runo; | import com.vaadin.ui.themes.Runo; | ||||
import com.vaadin.data.util.ContainerOrderedWrapper; | import com.vaadin.data.util.ContainerOrderedWrapper; | ||||
import com.vaadin.data.util.IndexedContainer; | import com.vaadin.data.util.IndexedContainer; | ||||
import com.vaadin.event.Action; | import com.vaadin.event.Action; | ||||
import com.vaadin.event.Action.Handler; | |||||
import com.vaadin.event.DataBoundTransferable; | import com.vaadin.event.DataBoundTransferable; | ||||
import com.vaadin.event.ItemClickEvent; | import com.vaadin.event.ItemClickEvent; | ||||
import com.vaadin.event.Action.Handler; | |||||
import com.vaadin.event.ItemClickEvent.ItemClickListener; | import com.vaadin.event.ItemClickEvent.ItemClickListener; | ||||
import com.vaadin.event.ItemClickEvent.ItemClickSource; | import com.vaadin.event.ItemClickEvent.ItemClickSource; | ||||
import com.vaadin.event.MouseEvents.ClickEvent; | import com.vaadin.event.MouseEvents.ClickEvent; | ||||
this.columnHeaders.clear(); | this.columnHeaders.clear(); | ||||
int i = 0; | int i = 0; | ||||
for (final Iterator<Object> it = visibleColumns.iterator(); it | for (final Iterator<Object> it = visibleColumns.iterator(); it | ||||
.hasNext() | |||||
&& i < columnHeaders.length; i++) { | |||||
.hasNext() && i < columnHeaders.length; i++) { | |||||
this.columnHeaders.put(it.next(), columnHeaders[i]); | this.columnHeaders.put(it.next(), columnHeaders[i]); | ||||
} | } | ||||
this.columnIcons.clear(); | this.columnIcons.clear(); | ||||
int i = 0; | int i = 0; | ||||
for (final Iterator<Object> it = visibleColumns.iterator(); it | for (final Iterator<Object> it = visibleColumns.iterator(); it | ||||
.hasNext() | |||||
&& i < columnIcons.length; i++) { | |||||
.hasNext() && i < columnIcons.length; i++) { | |||||
this.columnIcons.put(it.next(), columnIcons[i]); | this.columnIcons.put(it.next(), columnIcons[i]); | ||||
} | } | ||||
final HashMap<Object, String> newCA = new HashMap<Object, String>(); | final HashMap<Object, String> newCA = new HashMap<Object, String>(); | ||||
int i = 0; | int i = 0; | ||||
for (final Iterator<Object> it = visibleColumns.iterator(); it | for (final Iterator<Object> it = visibleColumns.iterator(); it | ||||
.hasNext() | |||||
&& i < columnAlignments.length; i++) { | |||||
.hasNext() && i < columnAlignments.length; i++) { | |||||
newCA.put(it.next(), columnAlignments[i]); | newCA.put(it.next(), columnAlignments[i]); | ||||
} | } | ||||
this.columnAlignments = newCA; | this.columnAlignments = newCA; | ||||
* small or very big values. Setting width to -1 (default) means that theme | * small or very big values. Setting width to -1 (default) means that theme | ||||
* will make decision of width. | * will make decision of width. | ||||
* | * | ||||
*<p> | |||||
* <p> | |||||
* Column can either have a fixed width or expand ratio. The latter one set | * Column can either have a fixed width or expand ratio. The latter one set | ||||
* is used. See @link {@link #setColumnExpandRatio(Object, float)}. | * is used. See @link {@link #setColumnExpandRatio(Object, float)}. | ||||
* | * | ||||
// Actions | // Actions | ||||
if (variables.containsKey("action")) { | if (variables.containsKey("action")) { | ||||
final StringTokenizer st = new StringTokenizer((String) variables | |||||
.get("action"), ","); | |||||
final StringTokenizer st = new StringTokenizer( | |||||
(String) variables.get("action"), ","); | |||||
if (st.countTokens() == 2) { | if (st.countTokens() == 2) { | ||||
final Object itemId = itemIdMapper.get(st.nextToken()); | final Object itemId = itemIdMapper.get(st.nextToken()); | ||||
final Action action = (Action) actionMapper.get(st.nextToken()); | final Action action = (Action) actionMapper.get(st.nextToken()); | ||||
final boolean[] iscomponent = new boolean[visibleColumns.size()]; | final boolean[] iscomponent = new boolean[visibleColumns.size()]; | ||||
int iscomponentIndex = 0; | int iscomponentIndex = 0; | ||||
for (final Iterator<Object> it = visibleColumns.iterator(); it | for (final Iterator<Object> it = visibleColumns.iterator(); it | ||||
.hasNext() | |||||
&& iscomponentIndex < iscomponent.length;) { | |||||
.hasNext() && iscomponentIndex < iscomponent.length;) { | |||||
final Object columnId = it.next(); | final Object columnId = it.next(); | ||||
if (columnGenerators.containsKey(columnId)) { | if (columnGenerators.containsKey(columnId)) { | ||||
iscomponent[iscomponentIndex++] = true; | iscomponent[iscomponentIndex++] = true; | ||||
// The select variable is only enabled if selectable | // The select variable is only enabled if selectable | ||||
if (selectable) { | if (selectable) { | ||||
target.addVariable(this, "selected", selectedKeys | |||||
.toArray(new String[selectedKeys.size()])); | |||||
target.addVariable(this, "selected", | |||||
selectedKeys.toArray(new String[selectedKeys.size()])); | |||||
} | } | ||||
// The cursors are only shown on pageable table | // The cursors are only shown on pageable table | ||||
// Sorting | // Sorting | ||||
if (getContainerDataSource() instanceof Container.Sortable) { | if (getContainerDataSource() instanceof Container.Sortable) { | ||||
target.addVariable(this, "sortcolumn", columnIdMap | |||||
.key(sortContainerPropertyId)); | |||||
target.addVariable(this, "sortcolumn", | |||||
columnIdMap.key(sortContainerPropertyId)); | |||||
target.addVariable(this, "sortascending", sortAscending); | target.addVariable(this, "sortascending", sortAscending); | ||||
} | } | ||||
final String[] colorder = new String[visibleColumns.size()]; | final String[] colorder = new String[visibleColumns.size()]; | ||||
int i = 0; | int i = 0; | ||||
for (final Iterator<Object> it = visibleColumns.iterator(); it | for (final Iterator<Object> it = visibleColumns.iterator(); it | ||||
.hasNext() | |||||
&& i < colorder.length;) { | |||||
.hasNext() && i < colorder.length;) { | |||||
colorder[i++] = columnIdMap.key(it.next()); | colorder[i++] = columnIdMap.key(it.next()); | ||||
} | } | ||||
target.addVariable(this, "columnorder", colorder); | target.addVariable(this, "columnorder", colorder); | ||||
final String[] collapsedkeys = new String[ccs.size()]; | final String[] collapsedkeys = new String[ccs.size()]; | ||||
int nextColumn = 0; | int nextColumn = 0; | ||||
for (final Iterator<Object> it = visibleColumns.iterator(); it | for (final Iterator<Object> it = visibleColumns.iterator(); it | ||||
.hasNext() | |||||
&& nextColumn < collapsedkeys.length;) { | |||||
.hasNext() && nextColumn < collapsedkeys.length;) { | |||||
final Object columnId = it.next(); | final Object columnId = it.next(); | ||||
if (isColumnCollapsed(columnId)) { | if (isColumnCollapsed(columnId)) { | ||||
collapsedkeys[nextColumn++] = columnIdMap.key(columnId); | collapsedkeys[nextColumn++] = columnIdMap.key(columnId); | ||||
} | } | ||||
if (columnWidths.containsKey(columnId)) { | if (columnWidths.containsKey(columnId)) { | ||||
if (getColumnWidth(columnId) > -1) { | if (getColumnWidth(columnId) > -1) { | ||||
target.addAttribute("width", String | |||||
.valueOf(getColumnWidth(columnId))); | |||||
target.addAttribute("width", | |||||
String.valueOf(getColumnWidth(columnId))); | |||||
} else { | } else { | ||||
target.addAttribute("er", | target.addAttribute("er", | ||||
getColumnExpandRatio(columnId)); | getColumnExpandRatio(columnId)); | ||||
c.paint(target); | c.paint(target); | ||||
} | } | ||||
} else { | } else { | ||||
target | |||||
.addText((String) cells[CELL_FIRSTCOL + currentColumn][indexInRowbuffer]); | |||||
target.addText((String) cells[CELL_FIRSTCOL + currentColumn][indexInRowbuffer]); | |||||
} | } | ||||
} | } | ||||
paintRowIcon(target, cells, indexInRowbuffer); | paintRowIcon(target, cells, indexInRowbuffer); | ||||
paintRowHeader(target, cells, indexInRowbuffer); | paintRowHeader(target, cells, indexInRowbuffer); | ||||
target.addAttribute("key", Integer | |||||
.parseInt(cells[CELL_KEY][indexInRowbuffer].toString())); | |||||
target.addAttribute("key", | |||||
Integer.parseInt(cells[CELL_KEY][indexInRowbuffer].toString())); | |||||
if (isSelected(itemId)) { | if (isSelected(itemId)) { | ||||
target.addAttribute("selected", true); | target.addAttribute("selected", true); | ||||
AbstractSelectTargetDetails dropTargetData = (AbstractSelectTargetDetails) dragEvent | AbstractSelectTargetDetails dropTargetData = (AbstractSelectTargetDetails) dragEvent | ||||
.getTargetDetails(); | .getTargetDetails(); | ||||
table = (Table) dragEvent.getTargetDetails().getTarget(); | table = (Table) dragEvent.getTargetDetails().getTarget(); | ||||
ArrayList<Object> visibleItemIds = new ArrayList<Object>(table | |||||
.getPageLength()); | |||||
ArrayList<Object> visibleItemIds = new ArrayList<Object>( | |||||
table.getPageLength()); | |||||
visibleItemIds.size(); | visibleItemIds.size(); | ||||
Object id = table.getCurrentPageFirstItemId(); | Object id = table.getCurrentPageFirstItemId(); | ||||
for (int i = 0; i < table.getPageLength() && id != null; i++) { | for (int i = 0; i < table.getPageLength() && id != null; i++) { |
import com.vaadin.event.Action; | import com.vaadin.event.Action; | ||||
import com.vaadin.event.DataBoundTransferable; | import com.vaadin.event.DataBoundTransferable; | ||||
import com.vaadin.event.ItemClickEvent; | import com.vaadin.event.ItemClickEvent; | ||||
import com.vaadin.event.Transferable; | |||||
import com.vaadin.event.ItemClickEvent.ItemClickListener; | import com.vaadin.event.ItemClickEvent.ItemClickListener; | ||||
import com.vaadin.event.ItemClickEvent.ItemClickSource; | import com.vaadin.event.ItemClickEvent.ItemClickSource; | ||||
import com.vaadin.event.Transferable; | |||||
import com.vaadin.event.dd.DragAndDropEvent; | import com.vaadin.event.dd.DragAndDropEvent; | ||||
import com.vaadin.event.dd.DragSource; | import com.vaadin.event.dd.DragSource; | ||||
import com.vaadin.event.dd.DropHandler; | import com.vaadin.event.dd.DropHandler; | ||||
// Actions | // Actions | ||||
if (variables.containsKey("action")) { | if (variables.containsKey("action")) { | ||||
final StringTokenizer st = new StringTokenizer((String) variables | |||||
.get("action"), ","); | |||||
final StringTokenizer st = new StringTokenizer( | |||||
(String) variables.get("action"), ","); | |||||
if (st.countTokens() == 2) { | if (st.countTokens() == 2) { | ||||
final Object itemId = itemIdMapper.get(st.nextToken()); | final Object itemId = itemIdMapper.get(st.nextToken()); | ||||
final Action action = (Action) actionMapper.get(st.nextToken()); | final Action action = (Action) actionMapper.get(st.nextToken()); | ||||
target.addAttribute("selectmode", (isMultiSelect() ? "multi" | target.addAttribute("selectmode", (isMultiSelect() ? "multi" | ||||
: "single")); | : "single")); | ||||
if (isMultiSelect()) { | if (isMultiSelect()) { | ||||
target.addAttribute("multiselectmode", multiSelectMode | |||||
.ordinal()); | |||||
target.addAttribute("multiselectmode", | |||||
multiSelectMode.ordinal()); | |||||
} | } | ||||
} else { | } else { | ||||
target.addAttribute("selectmode", "none"); | target.addAttribute("selectmode", "none"); | ||||
partialUpdate = false; | partialUpdate = false; | ||||
} else { | } else { | ||||
// Selected | // Selected | ||||
target.addVariable(this, "selected", selectedKeys | |||||
.toArray(new String[selectedKeys.size()])); | |||||
target.addVariable(this, "selected", | |||||
selectedKeys.toArray(new String[selectedKeys.size()])); | |||||
// Expand and collapse | // Expand and collapse | ||||
target.addVariable(this, "expand", new String[] {}); | target.addVariable(this, "expand", new String[] {}); |
import com.vaadin.Application; | import com.vaadin.Application; | ||||
import com.vaadin.event.ShortcutAction; | import com.vaadin.event.ShortcutAction; | ||||
import com.vaadin.event.ShortcutListener; | |||||
import com.vaadin.event.ShortcutAction.KeyCode; | import com.vaadin.event.ShortcutAction.KeyCode; | ||||
import com.vaadin.event.ShortcutAction.ModifierKey; | import com.vaadin.event.ShortcutAction.ModifierKey; | ||||
import com.vaadin.event.ShortcutListener; | |||||
import com.vaadin.terminal.DownloadStream; | import com.vaadin.terminal.DownloadStream; | ||||
import com.vaadin.terminal.PaintException; | import com.vaadin.terminal.PaintException; | ||||
import com.vaadin.terminal.PaintTarget; | import com.vaadin.terminal.PaintTarget; | ||||
* <p> | * <p> | ||||
* If the window is a application window or a sub window depends on how it is | * If the window is a application window or a sub window depends on how it is | ||||
* added to the application. Adding a {@code Window} to a {@code Window} using | * added to the application. Adding a {@code Window} to a {@code Window} using | ||||
* {@link Window#addWindow(Window)} makes it a sub window and adding a {@code | |||||
* Window} to the {@code Application} using | |||||
* {@link Window#addWindow(Window)} makes it a sub window and adding a | |||||
* {@code Window} to the {@code Application} using | |||||
* {@link Application#addWindow(Window)} makes it an application window. | * {@link Application#addWindow(Window)} makes it an application window. | ||||
* </p> | * </p> | ||||
* <p> | * <p> | ||||
* <b>Application window only</b>. Handles an URI by passing the URI to all | * <b>Application window only</b>. Handles an URI by passing the URI to all | ||||
* URI handlers defined using {@link #addURIHandler(URIHandler)}. All URI | * URI handlers defined using {@link #addURIHandler(URIHandler)}. All URI | ||||
* handlers are called for each URI but no more than one handler may return | * handlers are called for each URI but no more than one handler may return | ||||
* a {@link DownloadStream}. If more than one stream is returned a {@code | |||||
* RuntimeException} is thrown. | |||||
* a {@link DownloadStream}. If more than one stream is returned a | |||||
* {@code RuntimeException} is thrown. | |||||
* | * | ||||
* @param context | * @param context | ||||
* The URL of the application | * The URL of the application | ||||
/** | /** | ||||
* <b>Application window only</b>. Handles parameters by passing the | * <b>Application window only</b>. Handles parameters by passing the | ||||
* parameters to all {@code ParameterHandler}s defined using | * parameters to all {@code ParameterHandler}s defined using | ||||
* {@link #addParameterHandler(ParameterHandler)}. All {@code | |||||
* ParameterHandler}s are called for each set of parameters. | |||||
* {@link #addParameterHandler(ParameterHandler)}. All | |||||
* {@code ParameterHandler}s are called for each set of parameters. | |||||
* | * | ||||
* @param parameters | * @param parameters | ||||
* a map containing the parameter names and values | * a map containing the parameter names and values | ||||
* name of the window is used to uniquely identify it. | * name of the window is used to uniquely identify it. | ||||
* <p> | * <p> | ||||
* The name also determines the URL that can be used for direct access to a | * The name also determines the URL that can be used for direct access to a | ||||
* window. All windows can be accessed through {@code | |||||
* http://host:port/app/win} where {@code http://host:port/app} is the | |||||
* application URL (as returned by {@link Application#getURL()} and {@code | |||||
* win} is the window name. | |||||
* window. All windows can be accessed through | |||||
* {@code http://host:port/app/win} where {@code http://host:port/app} is | |||||
* the application URL (as returned by {@link Application#getURL()} and | |||||
* {@code win} is the window name. | |||||
* </p> | * </p> | ||||
* <p> | * <p> | ||||
* Note! Portlets do not support direct window access through URLs. | * Note! Portlets do not support direct window access through URLs. | ||||
* application. | * application. | ||||
* <p> | * <p> | ||||
* The name also determines the URL that can be used for direct access to a | * The name also determines the URL that can be used for direct access to a | ||||
* window. All windows can be accessed through {@code | |||||
* http://host:port/app/win} where {@code http://host:port/app} is the | |||||
* application URL (as returned by {@link Application#getURL()} and {@code | |||||
* win} is the window name. | |||||
* window. All windows can be accessed through | |||||
* {@code http://host:port/app/win} where {@code http://host:port/app} is | |||||
* the application URL (as returned by {@link Application#getURL()} and | |||||
* {@code win} is the window name. | |||||
* </p> | * </p> | ||||
* <p> | * <p> | ||||
* This method can only be called before the window is added to an | * This method can only be called before the window is added to an |
package com.vaadin.tests; | package com.vaadin.tests; | ||||
import com.vaadin.ui.Button; | import com.vaadin.ui.Button; | ||||
import com.vaadin.ui.Component.Event; | |||||
import com.vaadin.ui.Component.Listener; | |||||
import com.vaadin.ui.CustomLayout; | import com.vaadin.ui.CustomLayout; | ||||
import com.vaadin.ui.Field; | import com.vaadin.ui.Field; | ||||
import com.vaadin.ui.Label; | import com.vaadin.ui.Label; | ||||
import com.vaadin.ui.TextField; | import com.vaadin.ui.TextField; | ||||
import com.vaadin.ui.Tree; | import com.vaadin.ui.Tree; | ||||
import com.vaadin.ui.Window; | import com.vaadin.ui.Window; | ||||
import com.vaadin.ui.Component.Event; | |||||
import com.vaadin.ui.Component.Listener; | |||||
/** | /** | ||||
* This example demonstrates custom layout. All components created here are | * This example demonstrates custom layout. All components created here are |
import com.vaadin.ui.AbstractSelect; | import com.vaadin.ui.AbstractSelect; | ||||
import com.vaadin.ui.Button; | import com.vaadin.ui.Button; | ||||
import com.vaadin.ui.Button.ClickEvent; | |||||
import com.vaadin.ui.ComboBox; | import com.vaadin.ui.ComboBox; | ||||
import com.vaadin.ui.CustomComponent; | import com.vaadin.ui.CustomComponent; | ||||
import com.vaadin.ui.DateField; | import com.vaadin.ui.DateField; | ||||
import com.vaadin.ui.NativeSelect; | import com.vaadin.ui.NativeSelect; | ||||
import com.vaadin.ui.OptionGroup; | import com.vaadin.ui.OptionGroup; | ||||
import com.vaadin.ui.TextField; | import com.vaadin.ui.TextField; | ||||
import com.vaadin.ui.Button.ClickEvent; | |||||
/** | /** | ||||
* Simple test helper to test Focusable.focus() method. | * Simple test helper to test Focusable.focus() method. |
// Create TabSheet | // Create TabSheet | ||||
// | // | ||||
final TabSheet tabsheet = new TabSheet(); | final TabSheet tabsheet = new TabSheet(); | ||||
tabsheet | |||||
.setCaption("Tabsheet, above layouts are added to this component"); | |||||
tabsheet.setCaption("Tabsheet, above layouts are added to this component"); | |||||
tabsheet.addTab(layoutA, "Horizontal ordered layout", null); | tabsheet.addTab(layoutA, "Horizontal ordered layout", null); | ||||
tabsheet.addTab(layoutB, "Vertical ordered layout", null); | tabsheet.addTab(layoutB, "Vertical ordered layout", null); | ||||
tabsheet.addTab(layoutG, "First grid layout", null); | tabsheet.addTab(layoutG, "First grid layout", null); | ||||
private Component getExampleComponent(String caption) { | private Component getExampleComponent(String caption) { | ||||
final Panel panel = new Panel(); | final Panel panel = new Panel(); | ||||
panel.setCaption("Panel component " + caption); | panel.setCaption("Panel component " + caption); | ||||
panel | |||||
.addComponent(new Label( | |||||
"Panel is a container for other components, by default it draws a frame around it's " | |||||
+ "extremities and may have a caption to clarify the nature of the contained components' purpose." | |||||
+ " Panel contains an layout where the actual contained components are added, " | |||||
+ "this layout may be switched on the fly.", | |||||
Label.CONTENT_XHTML)); | |||||
panel.addComponent(new Label( | |||||
"Panel is a container for other components, by default it draws a frame around it's " | |||||
+ "extremities and may have a caption to clarify the nature of the contained components' purpose." | |||||
+ " Panel contains an layout where the actual contained components are added, " | |||||
+ "this layout may be switched on the fly.", | |||||
Label.CONTENT_XHTML)); | |||||
panel.setWidth(222); | panel.setWidth(222); | ||||
return panel; | return panel; | ||||
} | } |
import java.util.HashMap; | import java.util.HashMap; | ||||
import java.util.Iterator; | import java.util.Iterator; | ||||
import com.vaadin.data.Item; | |||||
import com.vaadin.data.Container.ItemSetChangeEvent; | import com.vaadin.data.Container.ItemSetChangeEvent; | ||||
import com.vaadin.data.Container.ItemSetChangeListener; | import com.vaadin.data.Container.ItemSetChangeListener; | ||||
import com.vaadin.data.Container.PropertySetChangeEvent; | import com.vaadin.data.Container.PropertySetChangeEvent; | ||||
import com.vaadin.data.Container.PropertySetChangeListener; | import com.vaadin.data.Container.PropertySetChangeListener; | ||||
import com.vaadin.data.Item; | |||||
import com.vaadin.data.Property.ValueChangeEvent; | import com.vaadin.data.Property.ValueChangeEvent; | ||||
import com.vaadin.data.Property.ValueChangeListener; | import com.vaadin.data.Property.ValueChangeListener; | ||||
import com.vaadin.ui.Button; | import com.vaadin.ui.Button; | ||||
import com.vaadin.ui.Button.ClickEvent; | |||||
import com.vaadin.ui.Label; | import com.vaadin.ui.Label; | ||||
import com.vaadin.ui.Select; | import com.vaadin.ui.Select; | ||||
import com.vaadin.ui.Window; | import com.vaadin.ui.Window; | ||||
import com.vaadin.ui.Button.ClickEvent; | |||||
public class ListenerOrder extends com.vaadin.Application implements | public class ListenerOrder extends com.vaadin.Application implements | ||||
Button.ClickListener, PropertySetChangeListener, ItemSetChangeListener, | Button.ClickListener, PropertySetChangeListener, ItemSetChangeListener, |
package com.vaadin.tests; | package com.vaadin.tests; | ||||
import com.vaadin.ui.Button; | import com.vaadin.ui.Button; | ||||
import com.vaadin.ui.Button.ClickEvent; | |||||
import com.vaadin.ui.Button.ClickListener; | |||||
import com.vaadin.ui.Label; | import com.vaadin.ui.Label; | ||||
import com.vaadin.ui.TextField; | import com.vaadin.ui.TextField; | ||||
import com.vaadin.ui.Window; | import com.vaadin.ui.Window; | ||||
import com.vaadin.ui.Button.ClickEvent; | |||||
import com.vaadin.ui.Button.ClickListener; | |||||
/** | /** | ||||
* Simple program that demonstrates "modal windows" that block all access other | * Simple program that demonstrates "modal windows" that block all access other |