Example usage for com.vaadin.client ComputedStyle getProperty

List of usage examples for com.vaadin.client ComputedStyle getProperty

Introduction

In this page you can find the example usage for com.vaadin.client ComputedStyle getProperty.

Prototype

public final native String getProperty(String name)
;

Source Link

Document

Gets the value of the given property.

Usage

From source file:com.haulmont.cuba.web.toolkit.ui.client.jqueryfileupload.CubaFileUploadProgressWindow.java

License:Apache License

protected void constructDOM() {
    setStyleName(CLASSNAME);//from w  w w .jav  a  2s  .  com

    topTabStop = DOM.createDiv();
    topTabStop.setTabIndex(0);

    header = DOM.createDiv();
    header.setClassName(CLASSNAME + "-outerheader");

    headerText = DOM.createDiv();
    headerText.setClassName(CLASSNAME + "-header");

    contents = DOM.createDiv();
    contents.setClassName(CLASSNAME + "-contents");

    footer = DOM.createDiv();
    footer.setClassName(CLASSNAME + "-footer");

    resizeBox = DOM.createDiv();
    resizeBox.setClassName(CLASSNAME + "-resizebox");

    closeBox = DOM.createDiv();
    closeBox.setClassName(CLASSNAME + "-closebox");
    closeBox.setTabIndex(0);

    DOM.appendChild(footer, resizeBox);

    bottomTabStop = DOM.createDiv();
    bottomTabStop.setTabIndex(0);

    wrapper = DOM.createDiv();
    wrapper.setClassName(CLASSNAME + "-wrap");

    DOM.appendChild(wrapper, topTabStop);
    DOM.appendChild(wrapper, header);
    DOM.appendChild(header, closeBox);
    DOM.appendChild(header, headerText);
    DOM.appendChild(wrapper, contents);
    DOM.appendChild(wrapper, footer);
    DOM.appendChild(wrapper, bottomTabStop);
    DOM.appendChild(super.getContainerElement(), wrapper);

    sinkEvents(Event.ONDBLCLICK | Event.MOUSEEVENTS | Event.TOUCHEVENTS | Event.ONCLICK | Event.ONLOSECAPTURE);

    currentFileLabel = new VLabel();
    currentFileLabel.addStyleName("upload-file-label");
    currentFileLabel.setWidth("100%");

    progressBar = new VProgressBar();
    progressBar.addStyleName("upload-progressbar");
    progressBar.setIndeterminate(false);
    progressBar.setState(0);
    progressBar.setWidth("100%");

    cancelButton = new VButton();
    cancelButton.addStyleName("upload-cancel-button");
    cancelButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            closeWindow();
        }
    });

    contentPanel = new SimpleFocusablePanel();
    contentPanel.setStyleName("content-pane");
    contentPanel.addKeyDownHandler(this);
    contentPanel.addKeyUpHandler(this);

    setWidget(contentPanel);

    final FlowPanel verticalPanel = new FlowPanel();
    verticalPanel.setStyleName("vertical-panel");
    verticalPanel.addStyleName("v-widget");
    verticalPanel.addStyleName("v-has-width");
    verticalPanel.addStyleName("v-has-height");

    verticalPanel.add(currentFileLabel);
    verticalPanel.add(progressBar);
    verticalPanel.add(cancelButton);

    contentPanel.setWidget(verticalPanel);

    // do some calculations for window layout
    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
        @Override
        public void execute() {
            Style contentStyle = contents.getStyle();

            ComputedStyle headerCs = new ComputedStyle(header);
            String headerHeight = headerCs.getProperty("height");
            contentStyle.setProperty("paddingTop", headerHeight);
            contentStyle.setProperty("marginTop", "-" + headerHeight);

            ComputedStyle footerCs = new ComputedStyle(footer);
            String footerHeight = footerCs.getProperty("height");
            contentStyle.setProperty("paddingBottom", footerHeight);
            contentStyle.setProperty("marginBottom", "-" + footerHeight);
        }
    });

    // Make the closebox accessible for assistive devices
    Roles.getButtonRole().set(closeBox);
    Roles.getButtonRole().setAriaLabelProperty(closeBox, "close button");

    // Provide the title to assistive devices
    AriaHelper.ensureHasId(headerText);
    Roles.getDialogRole().setAriaLabelledbyProperty(getElement(), Id.of(headerText));

    // Handlers to Prevent tab to leave the window
    // and backspace to cause browser navigation
    topEventBlocker = new Event.NativePreviewHandler() {
        @Override
        public void onPreviewNativeEvent(Event.NativePreviewEvent event) {
            NativeEvent nativeEvent = event.getNativeEvent();
            if (nativeEvent.getEventTarget().cast() == topTabStop
                    && nativeEvent.getKeyCode() == KeyCodes.KEY_TAB && nativeEvent.getShiftKey()) {
                nativeEvent.preventDefault();
            }
            if (nativeEvent.getEventTarget().cast() == topTabStop
                    && nativeEvent.getKeyCode() == KeyCodes.KEY_BACKSPACE) {
                nativeEvent.preventDefault();
            }
        }
    };

    bottomEventBlocker = new Event.NativePreviewHandler() {
        @Override
        public void onPreviewNativeEvent(Event.NativePreviewEvent event) {
            NativeEvent nativeEvent = event.getNativeEvent();
            if (nativeEvent.getEventTarget().cast() == bottomTabStop
                    && nativeEvent.getKeyCode() == KeyCodes.KEY_TAB && !nativeEvent.getShiftKey()) {
                nativeEvent.preventDefault();
            }
            if (nativeEvent.getEventTarget().cast() == bottomTabStop
                    && nativeEvent.getKeyCode() == KeyCodes.KEY_BACKSPACE) {
                nativeEvent.preventDefault();
            }
        }
    };
}

From source file:com.haulmont.cuba.web.toolkit.ui.client.resizabletextarea.CubaResizableTextAreaWrapperWidget.java

License:Apache License

protected void captureEvents(Event event) {
    event.preventDefault();/*from ww  w  .j  a va  2  s  .  c om*/
    if (isEnabled() && event.getButton() == Event.BUTTON_LEFT) {
        if (!dragDrop) {
            dragDrop = true;
            DOM.setCapture(resizeElement);

            ComputedStyle cs = new ComputedStyle(getElement());
            setWidth(cs.getProperty("width"));
            setHeight(cs.getProperty("height"));

            getTextArea().getStyle().setProperty("width", "100%");
            getTextArea().getStyle().setProperty("height", "100%");
        }
    }
}

From source file:com.haulmont.cuba.web.toolkit.ui.client.resizabletextarea.CubaResizableTextAreaWrapperWidget.java

License:Apache License

protected void releaseCapture(Event event) {
    if (event.getButton() == Event.BUTTON_LEFT && dragDrop) {
        dragDrop = false;/*w  w w  .  ja  v a 2 s . c  om*/
        DOM.releaseCapture(resizeElement);

        if (resizeHandler != null) {
            ComputedStyle cs = new ComputedStyle(getElement());
            resizeHandler.sizeChanged(cs.getProperty("width"), cs.getProperty("height"));
            resizeHandler.textChanged(getText());
        }
    }
}

From source file:com.haulmont.cuba.web.widgets.client.addons.aceeditor.AceEditorConnector.java

License:Apache License

@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    super.onStateChanged(stateChangeEvent);

    setTextChangeEventMode(getState().changeMode);
    setTextChangeTimeout(getState().changeTimeout);

    ClientSideDocDiff.dmp.setDiff_EditCost(getState().diff_editCost);

    // TODO: are these needed?
    //      widget.setHideErrors(getState().hideErrors);
    //      widget.setRequired(getState().required);
    //      widget.setModified(getState().modified);

    boolean firstTime = !getWidget().isInitialized();
    if (firstTime) {
        // To make sure Ace config is applied before the editor is created,
        // we delay the initialization till then first call to onStateChanged,
        // not initializing in createWidget() right away.
        applyConfig(getState().config);/*from w ww .j ava 2s  .  c  om*/
        getWidget().initialize();
    }

    getWidget().setMode(getState().mode);
    getWidget().setTheme(getState().theme);
    listenToSelectionChanges = getState().listenToSelectionChanges;
    listenToFocusChanges = getState().listenToFocusChanges;
    getWidget().setUseWorker(getState().useWorker);
    getWidget().setWordwrap(getState().wordwrap);

    getWidget().setShowGutter(getState().showGutter);
    getWidget().setShowPrintMargin(getState().showPrintMargin);
    getWidget().setHighlightActiveLineEnabled(getState().highlightActiveLine);

    getWidget().setEnabled(getState().enabled);
    //        getWidget().setPropertyReadOnly(getState().propertyReadOnly);
    getWidget().setTabIndex(getState().tabIndex);
    getWidget().setReadOnly(getState().readOnly);

    if (stateChangeEvent.hasPropertyChanged("fontSize")) {
        String fontSize = getState().fontSize;

        if ("auto".equals(fontSize)) {
            // detect font size from CSS
            Element fontSizeMeasureElement = Document.get().createDivElement();
            fontSizeMeasureElement.setClassName("ace_editor");
            fontSizeMeasureElement.getStyle().setPosition(Style.Position.FIXED);
            fontSizeMeasureElement.getStyle().setVisibility(Style.Visibility.HIDDEN);
            getWidget().getElement().appendChild(fontSizeMeasureElement);

            ComputedStyle cs = new ComputedStyle(fontSizeMeasureElement);
            fontSize = cs.getProperty("fontSize");

            getWidget().getElement().removeChild(fontSizeMeasureElement);
        }

        getWidget().setFontSize(fontSize);
    }

    getWidget().setHighlightSelectedWord(getState().highlightSelectedWord);
    getWidget().setShowInvisibles(getState().showInvisibles);
    getWidget().setDisplayIndentGuides(getState().displayIndentGuides);

    getWidget().setUseSoftTabs(getState().softTabs);
    getWidget().setTabSize(getState().tabSize);

    // TODO: How should we deal with immediateness. Since there's already textChangeEventMode...
    //immediate = getState().immediate;

    if (firstTime) {
        shadow = AceDoc.fromTransport(getState().initialValue);
        getWidget().setDoc(shadow);
    }

    if (getState().selection != null) {
        AceRange sel = AceRange.fromTransport(getState().selection);
        if (firstTime) {
            getWidget().setSelection(sel);
        } else {
            selectionAfterApplyingDiff = sel;
        }
    }

    if (getState().scrollToRow != -1) {
        if (firstTime) {
            getWidget().scrollToRow(getState().scrollToRow);
        } else {
            scrollToRowAfterApplyingDiff = getState().scrollToRow;
        }
    }
}