Java Code Examples for com.vaadin.client.WidgetUtil

The following examples show how to use com.vaadin.client.WidgetUtil. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * Checks if the location is a valid drop location
 *
 * @param elementOver
 *            The element to check
 * @return
 */
private boolean isLocationValid(Element elementOver) {
    Element weekGridElement = calendarConnector.getWidget().getWeekGrid()
            .getElement();
    Element timeBarElement = calendarConnector.getWidget().getWeekGrid()
            .getTimeBar().getElement();

    Element todayBarElement = null;
    if (calendarConnector.getWidget().getWeekGrid().hasToday()) {
        todayBarElement = calendarConnector.getWidget().getWeekGrid()
                .getDateCellOfToday().getTodaybarElement();
    }

    // drops are not allowed in:
    // - weekday header
    // - allday event list
    // - todaybar
    // - timebar
    // - items
    return DOM.isOrHasChild(weekGridElement, elementOver)
            && !DOM.isOrHasChild(timeBarElement, elementOver)
            && todayBarElement != elementOver
            && (WidgetUtil.findWidget(elementOver,
                    DateCellDayItem.class) == null);
}
 
Example 2
Source Project: calendar-component   Source File: WeekGrid.java    License: Apache License 2.0 6 votes vote down vote up
public void setWidthPX(int width) {
    if (isHorizontalScrollable()) {
        updateCellWidths();

        // Otherwise the scroll wrapper is somehow too narrow = horizontal
        // scroll
        wrapper.setWidth(content.getOffsetWidth() + WidgetUtil.getNativeScrollbarSize() + "px");

        this.width = content.getOffsetWidth() - timebar.getOffsetWidth();

    } else {
        this.width = (width == -1) ? width
                : width - timebar.getOffsetWidth();

        if (isVerticalScrollable() && width != -1) {
            this.width = this.width - WidgetUtil.getNativeScrollbarSize();
        }
        updateCellWidths();
    }
}
 
Example 3
/**
 * Gets the visible row in the popup as a HTML string. The string
 * contains an image tag with the rows icon (if an icon has been
 * specified) and the caption of the item
 */

@Override
public String getDisplayString() {
	final StringBuilder sb = new StringBuilder();
	ApplicationConnection client = VComboBoxMultiselect.this.connector.getConnection();
	final Icon icon = client.getIcon(client.translateVaadinUri(this.untranslatedIconUri));
	if (icon != null) {
		sb.append(icon.getElement()
			.getString());
	}
	String content;
	if ("".equals(this.caption)) {
		// Ensure that empty options use the same height as other
		// options and are not collapsed (#7506)
		content = " ";
	} else {
		content = WidgetUtil.escapeHTML(this.caption);
	}
	sb.append("<span>" + content + "</span>");
	return sb.toString();
}
 
Example 4
Source Project: flow   Source File: GwtPolymerModelTest.java    License: Apache License 2.0 6 votes vote down vote up
public void testUpdateModelProperty_propertyIsNotUpdatable_propertyIsNotSync() {
    emulatePolymerNotLoaded();
    addMockMethods(element);

    String propertyName = "black";
    String propertyValue = "coffee";

    setModelProperty(node, propertyName, propertyValue);

    Binder.bind(node, element);
    Reactive.flush();
    assertEquals(
            "Expected to have property with name " + propertyName
                    + " defined after initial binding",
            propertyValue, WidgetUtil.getJsProperty(element, propertyName));

    emulatePolymerPropertyChange(element, propertyName, "doesNotMatter");
    Reactive.flush();
    assertEquals(
            "Expected the property with name " + propertyName
                    + " not to be updated since it's not updatable",
            propertyValue, WidgetUtil.getJsProperty(element, propertyName));
}
 
Example 5
Source Project: cuba   Source File: CubaPopupButtonConnector.java    License: Apache License 2.0 6 votes vote down vote up
protected void handleMouseOver(@SuppressWarnings("unused") Event.NativePreviewEvent event, Element target) {
    if (!getState().customLayout && getWidget().popupHasChild(target)) {
        Widget widget = WidgetUtil.findWidget(target, null);
        if ((widget instanceof VButton
                || widget instanceof VUpload
                || widget instanceof CubaFileUploadWidget)) {

            VButton button;
            if (widget instanceof VButton) {
                button = (VButton) widget;
            } else if (widget instanceof CubaFileUploadWidget) {
                button = ((CubaFileUploadWidget) widget).getSubmitButton();
            } else {
                button = ((VUpload) widget).submitButton;
            }
            if (!button.getStyleName().contains(SELECTED_ITEM_STYLE)) {
                getWidget().childWidgetFocused(button);
                button.setFocus(true);
            }
        }
    }
}
 
Example 6
Source Project: cuba   Source File: CubaFieldGroupLayoutComponentSlot.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public int getUsedWidth() {
    if (!isCaptionInline()) {
        return super.getUsedWidth();
    }

    int widgetWidth = getWidgetWidth();
    if (getCaption() == null) {
        return widgetWidth;
    } else if (getCaption().shouldBePlacedAfterComponent() || isCaptionInline()) {
        widgetWidth += getCaptionWidth();
        if (rightCaption != null) {
            widgetWidth += WidgetUtil.getRequiredWidth(rightCaption);
        }
        return widgetWidth;
    } else {
        if (rightCaption != null) {
            widgetWidth += WidgetUtil.getRequiredWidth(rightCaption);
        }
        return Math.max(widgetWidth, getCaptionWidth());
    }
}
 
Example 7
Source Project: flow   Source File: SimpleElementBindingStrategy.java    License: Apache License 2.0 6 votes vote down vote up
private void updateProperty(MapProperty mapProperty, Element element) {
    String name = mapProperty.getName();
    if (mapProperty.hasValue()) {
        Object treeValue = mapProperty.getValue();
        Object domValue = WidgetUtil.getJsProperty(element, name);
        // We compare with the current property to avoid setting properties
        // which are updated on the client side, e.g. when synchronizing
        // properties to the server (won't work for readonly properties).
        if (WidgetUtil.isUndefined(domValue)
                || !Objects.equals(domValue, treeValue)) {
            Reactive.runWithComputation(null,
                    () -> WidgetUtil.setJsProperty(element, name,
                            PolymerUtils.createModelTree(treeValue)));
        }
    } else if (WidgetUtil.hasOwnJsProperty(element, name)) {
        WidgetUtil.deleteJsProperty(element, name);
    } else {
        // Can't delete inherited property, so instead just clear
        // the value
        WidgetUtil.setJsProperty(element, name, null);
    }
}
 
Example 8
Source Project: cuba   Source File: CubaMainTabSheetConnector.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void init() {
    super.init();

    getWidget().tabContextMenuHandler = (tabIndex, event) -> {
        lastContextMenuX = WidgetUtil.getTouchOrMouseClientX(event.getNativeEvent());
        lastContextMenuY = WidgetUtil.getTouchOrMouseClientY(event.getNativeEvent());

        if (getState().hasActionsHandlers) {
            rpc.onTabContextMenu(tabIndex);

            event.stopPropagation();
            event.preventDefault();
        }
    };
}
 
Example 9
Source Project: cuba   Source File: CubaSideMenuWidget.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
    super.onBrowserEvent(event);

    if (isEnabled()) {
        switch (DOM.eventGetType(event)) {
            case Event.ONMOUSEOVER:
                Element targetElement = DOM.eventGetTarget(event);
                Object targetWidget = WidgetUtil.findWidget(targetElement, null);
                if (targetWidget instanceof MenuItemWidget) {
                    setFocusedItem((MenuItemWidget) targetWidget);
                }
                break;
            case Event.ONMOUSEOUT:
                if (!focused) {
                    setFocusedItem(null);
                }
                break;
        }
    }
}
 
Example 10
Source Project: flow   Source File: GwtMultipleBindingTest.java    License: Apache License 2.0 6 votes vote down vote up
public void testBindModelPropertiesDoubleBind() {
    String name = "custom-div";
    Element element = Browser.getDocument().createElement(name);
    WidgetUtil.setJsProperty(element, "localName", name);
    initPolymer(element);

    NativeFunction function = NativeFunction.create("");
    WidgetUtil.setJsProperty(element, "set", function);

    Binder.bind(node, element);

    node.getMap(NodeFeatures.ELEMENT_PROPERTIES).getProperty("foo")
            .setValue("bar");

    Reactive.flush();

    node.setBound();
    Binder.bind(node, element);
}
 
Example 11
Source Project: cuba   Source File: CubaCaptionWidget.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public int getRenderedWidth() {
    int width = 0;

    if (icon != null) {
        width += WidgetUtil.getRequiredWidth(icon.getElement());
    }

    if (captionText != null) {
        width += WidgetUtil.getRequiredWidth(captionText);
    }
    if (requiredFieldIndicator != null && requiredFieldIndicator.getParentElement() == getElement()) {
        width += WidgetUtil.getRequiredWidth(requiredFieldIndicator);
    }
    if (errorIndicatorElement != null && errorIndicatorElement.getParentElement() == getElement()) {
        width += WidgetUtil.getRequiredWidth(errorIndicatorElement);
    }
    if (contextHelpIndicatorElement != null && contextHelpIndicatorElement.getParentElement() == getElement()) {
        width += WidgetUtil.getRequiredWidth(contextHelpIndicatorElement);
    }
    return width;
}
 
Example 12
Source Project: flow   Source File: ClientJsonCodec.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Helper for encoding any "primitive" value that is directly supported in
 * JSON. Supported values types are {@link String}, {@link Number},
 * {@link Boolean}, {@link JsonValue}. <code>null</code> is also supported.
 *
 * @param value
 *            the value to encode
 * @return the value encoded as JSON
 */
public static JsonValue encodeWithoutTypeInfo(Object value) {
    if (value == null) {
        // undefined shouln't go as undefined, it should be encoded as null
        return Json.createNull();
    } else if (GWT.isScript()) {
        return WidgetUtil.crazyJsoCast(value);
    } else {
        if (value instanceof String) {
            return Json.create((String) value);
        } else if (value instanceof Number) {
            return Json.create(((Number) value).doubleValue());
        } else if (value instanceof Boolean) {
            return Json.create(((Boolean) value).booleanValue());
        } else if (value instanceof JsonValue) {
            return (JsonValue) value;
        }
        throw new IllegalArgumentException(
                "Can't encode" + value.getClass() + " to json");
    }
}
 
Example 13
Source Project: cuba   Source File: VDDPanel.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Updates the drop details while dragging. This is needed to ensure client
 * side criterias can validate the drop location.
 * 
 * @param event
 *            The drag event
 */
protected void updateDragDetails(VDragEvent event) {
    Element over = event.getElementOver();

    Widget content = WidgetUtil.findWidget(over, null);

    if (content != null && content != this) {
        event.getDropDetails().put(Constants.DROP_DETAIL_OVER_CLASS,
                content.getClass().getName());
    } else {
        event.getDropDetails().put(Constants.DROP_DETAIL_OVER_CLASS,
                this.getClass().getName());
    }

    // Add mouse event details
    MouseEventDetails details = MouseEventDetailsBuilder
            .buildMouseEventDetails(event.getCurrentGwtEvent(),
                    getElement());
    event.getDropDetails().put(Constants.DROP_DETAIL_MOUSE_EVENT,
            details.serialize());
}
 
Example 14
Source Project: cuba   Source File: VDDAccordion.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Updates the drop details while dragging. This is needed to ensure client
 * side criterias can validate the drop location.
 * 
 * @param event
 *            The drag event
 */
protected void updateDragDetails(VDragEvent event) {
    if (event.getElementOver() == null) {
        return;
    }

    StackItem tab = WidgetUtil.findWidget(event.getElementOver(),
            StackItem.class);

    if (tab != null && getElement().isOrHasChild(tab.getElement())) {
        Map<String, Object> dropDetails = event.getDropDetails();

        int index = getTabPosition(tab);
        dropDetails.put(Constants.DROP_DETAIL_TO, index);

        VerticalDropLocation location = getDropLocation(tab, event);
        dropDetails.put(Constants.DROP_DETAIL_VERTICAL_DROP_LOCATION,
                location);

        MouseEventDetails details = MouseEventDetailsBuilder
                .buildMouseEventDetails(event.getCurrentGwtEvent(),
                        getElement());
        dropDetails.put(Constants.DROP_DETAIL_MOUSE_EVENT,
                details.serialize());
    }
}
 
Example 15
Source Project: flow   Source File: XhrConnection.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Sends an asynchronous UIDL request to the server using the given URI.
 *
 * @param payload
 *            The URI to use for the request. May includes GET parameters
 */
public void send(JsonObject payload) {
    XhrResponseHandler responseHandler = createResponseHandler();
    responseHandler.setPayload(payload);
    responseHandler.setRequestStartTime(Profiler.getRelativeTimeMillis());

    String payloadJson = WidgetUtil.stringify(payload);
    XMLHttpRequest xhr = Xhr.post(getUri(), payloadJson,
            JsonConstants.JSON_CONTENT_TYPE, responseHandler);

    Console.log("Sending xhr message to server: " + payloadJson);

    if (webkitMaybeIgnoringRequests && BrowserInfo.get().isWebkit()) {
        final int retryTimeout = 250;
        new Timer() {
            @Override
            public void run() {
                // Use native js to access private field in Request
                if (resendRequest(xhr) && webkitMaybeIgnoringRequests) {
                    // Schedule retry if still needed
                    schedule(retryTimeout);
                }
            }
        }.schedule(retryTimeout);
    }
}
 
Example 16
/**
 * Update minimum width for combo box textarea based on input prompt and
 * suggestions.
 * <p>
 * For internal use only. May be removed or replaced in the future.
 */
public void updateSuggestionPopupMinWidth() {
	debug("VComboBoxMultiselect: updateSuggestionPopupMinWidth()");

	// used only to calculate minimum width
	String captions = WidgetUtil.escapeHTML(this.inputPrompt);

	for (ComboBoxMultiselectSuggestion suggestion : this.currentSuggestions) {
		// Collect captions so we can calculate minimum width for
		// textarea
		if (captions.length() > 0) {
			captions += "|";
		}
		captions += WidgetUtil.escapeHTML(suggestion.getReplacementString());
	}

	// Calculate minimum textarea width
	this.suggestionPopupMinWidth = minWidth(captions);
}
 
Example 17
Source Project: flow   Source File: NodeMap.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public JsonValue getDebugJson() {
    JsonObject json = WidgetUtil.createJsonObject();

    properties.forEach((p, n) -> {
        if (p.hasValue()) {
            json.put(n, getAsDebugJson(p.getValue()));
        }
    });

    if (json.keys().length == 0) {
        return null;
    }

    return json;
}
 
Example 18
Source Project: flow   Source File: NodeMap.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public JsonValue convert(Function<Object, JsonValue> converter) {
    JsonObject json = WidgetUtil.createJsonObject();

    properties.forEach((property, name) -> {
        if (property.hasValue()) {
            // Crazy cast since otherwise SDM fails for string values since
            // String is not a JSO
            JsonValue jsonValue = WidgetUtil
                    .crazyJsoCast(converter.apply(property.getValue()));
            json.put(name, jsonValue);
        }
    });

    return json;
}
 
Example 19
Source Project: flow   Source File: SimpleElementBindingStrategy.java    License: Apache License 2.0 6 votes vote down vote up
private void handlePropertiesChanged(
        JavaScriptObject changedPropertyPathsToValues, StateNode node) {
    String[] keys = WidgetUtil.getKeys(changedPropertyPathsToValues);

    Runnable runnable = () -> {
        for (String propertyName : keys) {
            handlePropertyChange(propertyName,
                    () -> WidgetUtil.getJsProperty(
                            changedPropertyPathsToValues, propertyName),
                    node);
        }
    };

    InitialPropertyUpdate initialUpdate = node
            .getNodeData(InitialPropertyUpdate.class);
    if (initialUpdate == null) {
        runnable.run();
    } else {
        initialUpdate.setCommand(runnable);
    }
}
 
Example 20
Source Project: flow   Source File: GwtJsArrayTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Tests that it's possible to cast an instance to its own type.
 *
 * Most of the JS produced by GWT does not make any assertions about types,
 * but explicit casts and some use of generics leads to code that might do a
 * JavaScript instanceof check for @JsType classes, thus failing if the type
 * defined in the annotation doesn't match the runtime type.
 */
public void testCanCast() {
    // Ok if this doesn't throw ClassCastException
    JsArray<Object> array = WidgetUtil.crazyJsCast(JsCollections.array());
    assertNotNull(array);
    // Ok if this doesn't throw ClassCastException
    JsArray<Object> array2 = WidgetUtil
            .crazyJsCast(JsCollections.array("a", "b"));
    assertNotNull(array2);
}
 
Example 21
Source Project: flow   Source File: GwtPolymerModelTest.java    License: Apache License 2.0 5 votes vote down vote up
public void testUpdateSubProperty() {
    Binder.bind(node, element);

    String subProperty = "subProp";
    String value = "foo";
    setModelProperty(modelNode, subProperty, value, true);

    String newValue = "bar";
    setModelProperty(modelNode, subProperty, newValue, true);

    assertEquals(newValue,
            WidgetUtil.getJsProperty(
                    WidgetUtil.getJsProperty(element, MODEL_PROPERTY_NAME),
                    subProperty));
}
 
Example 22
@Override
public void onDataAvailable(DataAvailableEvent event) {

	// Perform shift selection

	int current = cell.getRowIndex();
	int min = Math.min(current, previous);
	int max = Math.max(current, previous);

	// TODO: Fix batching.

	if (!ctrlOrMeta) {
		model.deselectAll();
	}

	Range dataAvailable = event.getAvailableRows();

	Range selected = Range.between(min, max + 1);
	Range[] partition = selected.partitionWith(dataAvailable);

	for (int i = partition[1].getStart(); i < partition[1].getEnd(); ++i) {
		model.select(grid.getDataSource().getRow(i));
	}

	// TODO: Batch end

	rpc.selectRange(partition[0].getStart(), partition[0].length());
	rpc.selectRange(partition[2].getStart(), partition[2].length());

	if (handler != null) {
		handler.removeHandler();
	}

	WidgetUtil.setTextSelectionEnabled(grid.getElement(), true);
}
 
Example 23
@Override
protected void dragAccepted(VDragEvent drag) {
    deEmphasis();
    currentTargetElement = drag.getElementOver();
    currentTargetDay = WidgetUtil.findWidget(currentTargetElement,
            SimpleDayCell.class);
    emphasis();
}
 
Example 24
Source Project: flow   Source File: GwtEventHandlerTest.java    License: Apache License 2.0 5 votes vote down vote up
private JsArray<String> getPublishedServerMethods(Element element) {
    ServerEventObject serverEventObject = WidgetUtil
            .crazyJsoCast(WidgetUtil.getJsProperty(element, "$server"));
    if (serverEventObject == null) {
        return JsCollections.array();
    } else {
        return serverEventObject.getMethods();
    }
}
 
Example 25
/**
 * Adds in-line CSS rules to the DOM according to the
 * suggestionPopupWidth field
 *
 * @param desiredWidth
 * @param naturalMenuWidth
 */
private void updateMenuWidth(final int desiredWidth, int naturalMenuWidth) {
	/**
	 * Three different width modes for the suggestion pop-up:
	 *
	 * 1. Legacy "null"-mode: width is determined by the longest item
	 * caption for each page while still maintaining minimum width of
	 * (desiredWidth - popupOuterPadding)
	 *
	 * 2. relative to the component itself
	 *
	 * 3. fixed width
	 */
	String width = "auto";
	if (VComboBoxMultiselect.this.suggestionPopupWidth == null) {
		if (naturalMenuWidth < desiredWidth) {
			naturalMenuWidth = desiredWidth - this.popupOuterPadding;
			width = desiredWidth - this.popupOuterPadding + "px";
		}
	} else if (isrelativeUnits(VComboBoxMultiselect.this.suggestionPopupWidth)) {
		float mainComponentWidth = desiredWidth - this.popupOuterPadding;
		// convert percentage value to fraction
		int widthInPx = Math
			.round(mainComponentWidth * asFraction(VComboBoxMultiselect.this.suggestionPopupWidth));
		width = widthInPx + "px";
	} else {
		// use as fixed width CSS definition
		width = WidgetUtil.escapeAttribute(VComboBoxMultiselect.this.suggestionPopupWidth);
	}
	this.menu.setWidth(width);
}
 
Example 26
/**
 * Overridden to avoid selecting text when text input is disabled
 */
@Override
public void setSelectionRange(int pos, int length) {
	if (VComboBoxMultiselect.this.textInputEnabled) {
		/*
		 * set selection range with a backwards direction: anchor at the
		 * back, focus at the front. This means that items that are too
		 * long to display will display from the start and not the end
		 * even on Firefox.
		 *
		 * We need the JSNI function to set selection range so that we
		 * can use the optional direction attribute to set the anchor to
		 * the end and the focus to the start. This makes Firefox work
		 * the same way as other browsers (#13477)
		 */
		WidgetUtil.setSelectionRange(getElement(), pos, length, "backward");

	} else {
		/*
		 * Setting the selectionrange for an uneditable textbox leads to
		 * unwanted behaviour when the width of the textbox is narrower
		 * than the width of the entry: the end of the entry is shown
		 * instead of the beginning. (see #13477)
		 *
		 * To avoid this, we set the caret to the beginning of the line.
		 */

		super.setSelectionRange(0, 0);
	}
}
 
Example 27
Source Project: flow   Source File: GwtPolymerModelTest.java    License: Apache License 2.0 5 votes vote down vote up
private Element createHtmlElement() {
    String name = "custom-div";
    Element element = Browser.getDocument().createElement(name);
    WidgetUtil.setJsProperty(element, "localName", name);
    setupSetMethod(element);
    setupMockSpliceMethod(element);
    WidgetUtil.setJsProperty(element, "removeAttribute",
            new NativeFunction(""));
    WidgetUtil.setJsProperty(element, "getAttribute",
            new NativeFunction("return false;"));
    WidgetUtil.setJsProperty(element, "setAttribute",
            new NativeFunction(""));
    return element;
}
 
Example 28
Source Project: flow   Source File: GwtPolymerModelTest.java    License: Apache License 2.0 5 votes vote down vote up
public void testUpdateModelSubProperty_subpropertyIsUpdatableAndIsNotSetFromServer_subpropertyIsSync() {
    addMockMethods(element);
    setModelProperty(node, "bar", modelNode);

    node.setNodeData(
            new UpdatableModelProperties(JsCollections.array("bar.foo")));

    Binder.bind(node, element);
    Reactive.flush();

    String newSubPropertyValue = "baz";
    PolymerUtils.setProperty(element, "bar.foo", "baz");
    emulatePolymerPropertyChange(element, "bar.foo", "baz");
    Reactive.flush();

    assertEquals(
            "Expected to have an object 'bar' with a property named 'foo'"
                    + " updated from client side",
            newSubPropertyValue, WidgetUtil.getJsProperty(
                    WidgetUtil.getJsProperty(element, "bar"), "foo"));

    MapProperty property = modelNode.getMap(NodeFeatures.ELEMENT_PROPERTIES)
            .getProperty("foo");
    assertEquals(newSubPropertyValue, property.getValue());

    assertEquals(newSubPropertyValue,
            tree.synchronizedProperties.get(modelNode).get("foo"));
}
 
Example 29
Source Project: cuba   Source File: CubaFileUploadProgressWindow.java    License: Apache License 2.0 5 votes vote down vote up
public void setCaption(String c, boolean asHtml) {
    String html;
    if (asHtml) {
        html = c == null ? "" : c;
    } else {
        html = WidgetUtil.escapeHTML(c);
    }

    headerText.setInnerHTML(html);
}
 
Example 30
Source Project: cuba   Source File: CubaFileUploadProgressWindow.java    License: Apache License 2.0 5 votes vote down vote up
private void setSize(Event event) {
    if (!cursorInsideBrowserContentArea(event)) {
        // Only drag while cursor is inside the browser client area
        return;
    }

    int w = WidgetUtil.getTouchOrMouseClientX(event) - startX + origW;
    int h = WidgetUtil.getTouchOrMouseClientY(event) - startY + origH;

    w = Math.max(w, getMinWidth());
    h = Math.max(h, getMinHeight());

    setWidth(w + "px");
    setHeight(h + "px");
}