当前位置: 首页>>代码示例>>Java>>正文


Java WidgetUtil类代码示例

本文整理汇总了Java中com.vaadin.client.WidgetUtil的典型用法代码示例。如果您正苦于以下问题:Java WidgetUtil类的具体用法?Java WidgetUtil怎么用?Java WidgetUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


WidgetUtil类属于com.vaadin.client包,在下文中一共展示了WidgetUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateCaptions

import com.vaadin.client.WidgetUtil; //导入依赖的package包/类
/**
 * @param bigMode
 *            If false, event is so small that caption must be in time-row
 */
private void updateCaptions(boolean bigMode) {
    String innerHtml;
    String htmlOrText;

    String timeAsText = Strings.format(
            calendarItem.getDateCaptionFormat(),
            calendarItem.getFormattedStartTime(),
            calendarItem.getFormattedEndTime());

    if (dateCell.weekgrid.getCalendar().isItemCaptionAsHtml()) {
        htmlOrText = calendarItem.getCaption();
    } else {
        htmlOrText = WidgetUtil.escapeHTML(calendarItem.getCaption());
    }

    if (bigMode) {
        innerHtml = "<span>" + timeAsText + "</span><br />" + htmlOrText;
    } else {
        innerHtml = "<span>" + timeAsText + "<span></span></span> " + htmlOrText;
    }

    caption.setInnerHTML(innerHtml);
    eventContent.setInnerHTML("");
}
 
开发者ID:blackbluegl,项目名称:calendar-component,代码行数:29,代码来源:DateCellDayItem.java

示例2: isLocationValid

import com.vaadin.client.WidgetUtil; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:blackbluegl,项目名称:calendar-component,代码行数:32,代码来源:CalendarWeekDropHandler.java

示例3: renderCaption

import com.vaadin.client.WidgetUtil; //导入依赖的package包/类
/**
 * Renders the caption in the DIV element
 */
private void renderCaption() {
    StringBuilder html = new StringBuilder();
    String textOrHtml;
    if (calendar.isItemCaptionAsHtml()) {
        textOrHtml = caption;
    } else {
        textOrHtml = WidgetUtil.escapeHTML(caption);
    }

    if (caption != null && time != null) {
        html.append("<span class=\"" + STYLENAME + "-time\">");
        html.append(calendar.getTimeFormat().format(time));
        html.append("</span> ");
        html.append(textOrHtml);
    } else if (caption != null) {
        html.append(textOrHtml);
    } else if (time != null) {
        html.append("<span class=\"" + STYLENAME + "-time\">");
        html.append(calendar.getTimeFormat().format(time));
        html.append("</span>");
    }
    super.setHTML(html.toString());
}
 
开发者ID:blackbluegl,项目名称:calendar-component,代码行数:27,代码来源:MonthItemLabel.java

示例4: setWidthPX

import com.vaadin.client.WidgetUtil; //导入依赖的package包/类
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();
    }
}
 
开发者ID:blackbluegl,项目名称:calendar-component,代码行数:21,代码来源:WeekGrid.java

示例5: getDisplayString

import com.vaadin.client.WidgetUtil; //导入依赖的package包/类
/**
 * 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 = "&nbsp;";
	} else {
		content = WidgetUtil.escapeHTML(this.caption);
	}
	sb.append("<span>" + content + "</span>");
	return sb.toString();
}
 
开发者ID:bonprix,项目名称:vaadin-combobox-multiselect,代码行数:27,代码来源:VComboBoxMultiselect.java

示例6: updateSuggestionPopupMinWidth

import com.vaadin.client.WidgetUtil; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:bonprix,项目名称:vaadin-combobox-multiselect,代码行数:25,代码来源:VComboBoxMultiselect.java

示例7: setVisible

import com.vaadin.client.WidgetUtil; //导入依赖的package包/类
@Override
public void setVisible(boolean visible) {
    /*
     * Visibility with VWindow works differently than with other Paintables
     * in Vaadin. Invisible VWindows are not attached to DOM at all. Flag is
     * used to avoid visibility call from
     * ApplicationConnection.updateComponent();
     */
    if (!visibilityChangesDisabled) {
        super.setVisible(visible);
    }

    if (visible
            && BrowserInfo.get().requiresPositionAbsoluteOverflowAutoFix()) {

        /*
         * Shake up the DOM a bit to make the window shed unnecessary
         * scrollbars and resize correctly afterwards. The version fixing
         * ticket #11994 which was changing the size to 110% was replaced
         * with this due to ticket #12943
         */
        WidgetUtil
                .runWebkitOverflowAutoFix(contents.getFirstChildElement());
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:26,代码来源:CubaFileUploadProgressWindow.java

示例8: getUsedWidth

import com.vaadin.client.WidgetUtil; //导入依赖的package包/类
@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());
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:23,代码来源:CubaFieldGroupLayoutComponentSlot.java

示例9: init

import com.vaadin.client.WidgetUtil; //导入依赖的package包/类
@Override
protected void init() {
    super.init();

    getWidget().tabContextMenuHandler = new CubaTabSheetWidget.TabContextMenuHandler() {
        @Override
        public void onContextMenu(int tabIndex, ContextMenuEvent event) {
            lastContextMenuX = WidgetUtil.getTouchOrMouseClientX(event.getNativeEvent());
            lastContextMenuY = WidgetUtil.getTouchOrMouseClientY(event.getNativeEvent());

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

                event.stopPropagation();
                event.preventDefault();
            }
        }
    };
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:20,代码来源:CubaTabSheetConnector.java

示例10: onBrowserEvent

import com.vaadin.client.WidgetUtil; //导入依赖的package包/类
@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;
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:22,代码来源:CubaSideMenuWidget.java

示例11: init

import com.vaadin.client.WidgetUtil; //导入依赖的package包/类
@Override
protected void init() {
    super.init();

    getWidget().contextMenuHandler = new CubaWindowWidget.ContextMenuHandler() {
        @Override
        public void onContextMenu(Event event) {
            lastContextMenuX = WidgetUtil.getTouchOrMouseClientX(event);
            lastContextMenuY = WidgetUtil.getTouchOrMouseClientY(event);

            if (getState().hasContextActionHandlers) {
                rpc.onWindowContextMenu();

                event.stopPropagation();
                event.preventDefault();
            }
        }
    };
    getWidget().clickOnModalityCurtain = () -> rpc.performCloseAction();
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:21,代码来源:CubaWindowConnector.java

示例12: onPreviewNativeEvent

import com.vaadin.client.WidgetUtil; //导入依赖的package包/类
@Override
protected void onPreviewNativeEvent(Event.NativePreviewEvent event) {
    super.onPreviewNativeEvent(event);

    NativeEvent nativeEvent = event.getNativeEvent();
    Element target = Element.as(nativeEvent.getEventTarget());

    if (Event.ONCLICK == event.getTypeInt()) {
        final Widget hoveredButton = WidgetUtil.findWidget(target, null);
        if (getElement().isOrHasChild(target)) {
            Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
                @Override
                public void execute() {
                    hide();

                    if (BrowserInfo.get().isIE9()) {
                        if (hoveredButton instanceof CubaButtonWidget) {
                            hoveredButton.removeStyleName("ie9-hover");
                        }
                    }
                }
            });
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:26,代码来源:Tools.java

示例13: onKeyDown

import com.vaadin.client.WidgetUtil; //导入依赖的package包/类
@Override
public void onKeyDown(KeyDownEvent keyDownEvent) {

    if (keyDownEvent.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) {

        SimplePanel panel = WidgetUtil.findWidget(WidgetUtil.getFocusedElement(), SimplePanel.class);

        if (panel != null) {
            WidgetUtil.focus(panel.getParent().getElement());

            // prevent further bubbling of the event as it has only
            // navigational purpose if thrown at this depth. A subsequent
            // press of ESC is not stopped, so ESC abort actions of the
            // application should work as soon as the focus is in
            // "navigational mode" on a grid-cell
            keyDownEvent.preventDefault();
            keyDownEvent.stopPropagation();
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:21,代码来源:EscKeyDownHandler.java

示例14: getRenderedWidth

import com.vaadin.client.WidgetUtil; //导入依赖的package包/类
@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;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:23,代码来源:CubaCaptionWidget.java

示例15: ctrlClickSelect

import com.vaadin.client.WidgetUtil; //导入依赖的package包/类
@Override
protected void ctrlClickSelect(SelectionModel<JsonObject> model, CellReference<JsonObject> cell, GridClickEvent e) {
	// Plain control click, or no previously selected.
	if (!e.isShiftKeyDown() || previous < 0) {
		super.ctrlClickSelect(model, cell, e);
		previous = cell.getRowIndex();
		return;
	}

	// Stop selecting text for now.
	WidgetUtil.setTextSelectionEnabled(grid.getElement(), false);
	WidgetUtil.clearTextSelection();

	// This works on the premise that grid fires the data available event to
	// any newly added handlers.
	boolean ctrlOrMeta = e.isControlKeyDown() || e.isMetaKeyDown();
	handler = grid.addDataAvailableHandler(new ShiftSelector(cell, model, ctrlOrMeta));
}
 
开发者ID:tsuoanttila,项目名称:GridExtensionPack,代码行数:19,代码来源:ShiftCtrlClickSelectionHandler.java


注:本文中的com.vaadin.client.WidgetUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。