Java Code Examples for com.vaadin.client.communication.StateChangeEvent#hasPropertyChanged()

The following examples show how to use com.vaadin.client.communication.StateChangeEvent#hasPropertyChanged() . 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
Source File: CubaScrollBoxLayoutConnector.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    super.onStateChanged(stateChangeEvent);

    if (stateChangeEvent.hasPropertyChanged("scrollTop")) {
        getWidget().setScrollTop(getState().scrollTop);
    }

    if (stateChangeEvent.hasPropertyChanged("scrollLeft")) {
        getWidget().setScrollLeft(getState().scrollLeft);
    }

    if (stateChangeEvent.hasPropertyChanged("scrollChangeMode")) {
        getWidget().setScrollChangeMode(getState().scrollChangeMode);
    }
}
 
Example 2
Source File: CubaHorizontalSplitPanelConnector.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    super.onStateChanged(stateChangeEvent);

    if (stateChangeEvent.hasPropertyChanged("dockable")) {
        getWidget().setDockable(getState().dockable);
    }
    if (stateChangeEvent.hasPropertyChanged("dockMode")) {
        getWidget().setDockMode(getState().dockMode);
    }
    if (stateChangeEvent.hasPropertyChanged("defaultPosition")) {
        getWidget().defaultPosition = getState().defaultPosition;
    }
    if (stateChangeEvent.hasPropertyChanged("beforeDockPosition")) {
        getWidget().beforeDockPosition = getState().beforeDockPosition;
    }

    updateLayout = true;
}
 
Example 3
Source File: SubStepConnector.java    From gantt with Apache License 2.0 6 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    super.onStateChanged(stateChangeEvent);

    if (!(getParent() instanceof StepConnector)) {
        return;
    }

    if (step == null) {
        step = ((StepConnector) getParent()).getWidget();
        getWidget().setOwner(step);
    }

    if (stateChangeEvent.hasPropertyChanged("step")) {
        getWidget().setStep(getState().step);
    }
    if (!getWidget().getElement().hasParentElement()) {
        step.add(getWidget());
        getWidget().getOwner().updateStylesForSubSteps();
    }
    getWidget().updateWidth();
}
 
Example 4
Source File: CubaTimeFieldConnector.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    super.onStateChanged(stateChangeEvent);

    CubaTimeFieldWidget widget = getWidget();

    if (stateChangeEvent.hasPropertyChanged("resolution")) {
        // Remove old stylename that indicates current resolution
        setWidgetStyleName(widget.getStylePrimaryName() + "-"
                + widget.resolutionAsString(), false);

        widget.setResolution(getState().resolution);

        // Add stylename that indicates current resolution
        setWidgetStyleName(widget.getStylePrimaryName() + "-"
                + widget.resolutionAsString(), true);
    }

    if (stateChangeEvent.hasPropertyChanged("timeFormat")) {
        widget.setTimeFormat(getState().timeFormat);
    }
}
 
Example 5
Source File: CubaTokenListLabelConnector.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    super.onStateChanged(stateChangeEvent);

    if (stateChangeEvent.hasPropertyChanged("editable")) {
        getWidget().setEditable(getState().editable);
    }

    if (stateChangeEvent.hasPropertyChanged("canOpen")) {
        getWidget().setCanOpen(getState().canOpen);
    }

    if (stateChangeEvent.hasPropertyChanged("text")) {
        getWidget().setText(getState().text);
    }
}
 
Example 6
Source File: CubaResizableTextAreaWrapperConnector.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    super.onStateChanged(stateChangeEvent);

    if (stateChangeEvent.hasPropertyChanged("resizableDirection")) {
        getWidget().setResizableDirection(getState().resizableDirection);
    }
    if (stateChangeEvent.hasPropertyChanged("enabled")) {
        getWidget().setEnabled(isEnabled());
    }
}
 
Example 7
Source File: CubaTwinColSelectConnector.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    super.onStateChanged(stateChangeEvent);

    if (stateChangeEvent.hasPropertyChanged("addAllBtnEnabled")) {
        getWidget().setAddAllBtnEnabled(getState().addAllBtnEnabled);
    }
    if (stateChangeEvent.hasPropertyChanged("reorderable")) {
        getWidget().setReorderable(getState().reorderable);
    }
}
 
Example 8
Source File: CubaCapsLockIndicatorConnector.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    super.onStateChanged(stateChangeEvent);

    if (stateChangeEvent.hasPropertyChanged("capsLockOnMessage")) {
        getWidget().setCapsLockOnMessage(getState().capsLockOnMessage);
    }

    if (stateChangeEvent.hasPropertyChanged("capsLockOffMessage")) {
        getWidget().setCapsLockOffMessage(getState().capsLockOffMessage);
    }
}
 
Example 9
Source File: CubaMainTabSheetConnector.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    super.onStateChanged(stateChangeEvent);

    getWidget().assignAdditionalCellStyles();

    if (stateChangeEvent.hasPropertyChanged("ddHtmlEnable")) {
        if (getState().ddHtmlEnable) {
            enableDDHtml5();
        } else {
            disableDDHtml5();
        }
    }
}
 
Example 10
Source File: CubaImageConnector.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    super.onStateChanged(stateChangeEvent);

    if (stateChangeEvent.hasPropertyChanged("scaleMode")) {
        getWidget().applyScaling(getState().scaleMode);
    }
}
 
Example 11
Source File: CubaOptionGroupConnector.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    super.onStateChanged(stateChangeEvent);

    if (stateChangeEvent.hasPropertyChanged("orientation")) {
        if (getState().orientation == OptionGroupOrientation.VERTICAL)
            getWidget().removeStyleDependentName("horizontal");
        else
            getWidget().addStyleDependentName(HORIZONTAL_ORIENTATION_STYLE);
    }
}
 
Example 12
Source File: CubaComboBoxConnector.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    super.onStateChanged(stateChangeEvent);

    if (stateChangeEvent.hasPropertyChanged("tabIndex")) {
        getWidget().setTabIndex(getState().tabIndex);
    }
}
 
Example 13
Source File: CubaLinkConnector.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    super.onStateChanged(stateChangeEvent);

    if (stateChangeEvent.hasPropertyChanged("rel")) {
        getWidget().setRel(getState().rel);
    }
}
 
Example 14
Source File: CubaCheckBoxGroupConnector.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    super.onStateChanged(stateChangeEvent);

    if (stateChangeEvent.hasPropertyChanged("orientation")) {
        if (getState().orientation == Orientation.VERTICAL) {
            getWidget().removeStyleDependentName(HORIZONTAL_ORIENTATION_STYLE);
        } else {
            getWidget().addStyleDependentName(HORIZONTAL_ORIENTATION_STYLE);
        }
    }
}
 
Example 15
Source File: CubaCheckBoxConnector.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    getWidget().captionManagedByLayout = getState().captionManagedByLayout;

    super.onStateChanged(stateChangeEvent);

    if (!getWidget().captionManagedByLayout
            && isContextHelpIconEnabled(getState())) {
        if (getWidget().contextHelpIcon == null) {
            getWidget().contextHelpIcon = DOM.createSpan();
            getWidget().contextHelpIcon.setInnerHTML("?");
            getWidget().contextHelpIcon.setClassName(CONTEXT_HELP_CLASSNAME);

            if (hasContextHelpIconListeners(getState())) {
                getWidget().contextHelpIcon.addClassName(CONTEXT_HELP_CLICKABLE_CLASSNAME);
            }

            Roles.getTextboxRole().setAriaHiddenState(getWidget().contextHelpIcon, true);

            getWidget().getElement().appendChild(getWidget().contextHelpIcon);
            DOM.sinkEvents(getWidget().contextHelpIcon, VTooltip.TOOLTIP_EVENTS | Event.ONCLICK);
        } else {
            getWidget().contextHelpIcon.getStyle().clearDisplay();
        }
    } else if (getWidget().contextHelpIcon != null) {
        getWidget().contextHelpIcon.getStyle()
                .setDisplay(Style.Display.NONE);

        getWidget().setAriaInvalid(false);
    }

    if (stateChangeEvent.hasPropertyChanged("readOnly")) {
        getWidget().setReadOnly(getState().readOnly);
    }
}
 
Example 16
Source File: CubaGridConnector.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent event) {
    super.onStateChanged(event);

    if (event.hasPropertyChanged("showEmptyState")) {
        getWidget().showEmptyState(getState().showEmptyState);
        if (getState().showEmptyState) {
            // as emptyState element can be recreated set all messages
            getWidget().getEmptyState().setMessage(getState().emptyStateMessage);
            getWidget().getEmptyState().setLinkMessage(getState().emptyStateLinkMessage);
            getWidget().getEmptyState().setLinkClickHandler(getWidget().emptyStateLinkClickHandler);
        }
    }
    if (event.hasPropertyChanged("emptyStateMessage")) {
        if (getWidget().getEmptyState() != null) {
            getWidget().getEmptyState().setMessage(getState().emptyStateMessage);
        }
    }
    if (event.hasPropertyChanged("emptyStateLinkMessage")) {
        if (getWidget().getEmptyState() != null) {
            getWidget().getEmptyState().setLinkMessage(getState().emptyStateLinkMessage);
        }
    }

    if (event.hasPropertyChanged("selectAllLabel")) {
        getWidget().setSelectAllLabel(getState().selectAllLabel);
    }

    if (event.hasPropertyChanged("deselectAllLabel")) {
        getWidget().setDeselectAllLabel(getState().deselectAllLabel);
    }
}
 
Example 17
Source File: CubaTreeGridConnector.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent event) {
    super.onStateChanged(event);

    if (event.hasPropertyChanged("showEmptyState")) {
        getWidget().showEmptyState(getState().showEmptyState);
        if (getState().showEmptyState) {
            // as emptyState can be recreated set all messages
            getWidget().getEmptyState().setMessage(getState().emptyStateMessage);
            getWidget().getEmptyState().setLinkMessage(getState().emptyStateLinkMessage);
            getWidget().getEmptyState().setLinkClickHandler(getWidget().emptyStateLinkClickHandler);
        }
    }
    if (event.hasPropertyChanged("emptyStateMessage")) {
        if (getWidget().getEmptyState() != null) {
            getWidget().getEmptyState().setMessage(getState().emptyStateMessage);
        }
    }
    if (event.hasPropertyChanged("emptyStateLinkMessage")) {
        if (getWidget().getEmptyState() != null) {
            getWidget().getEmptyState().setLinkMessage(getState().emptyStateLinkMessage);
        }
    }

    if (event.hasPropertyChanged("selectAllLabel")) {
        getWidget().setSelectAllLabel(getState().selectAllLabel);
    }

    if (event.hasPropertyChanged("deselectAllLabel")) {
        getWidget().setDeselectAllLabel(getState().deselectAllLabel);
    }
}
 
Example 18
Source File: CubaBrowserFrameConnector.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    super.onStateChanged(stateChangeEvent);

    CubaBrowserFrameState state = getState();

    if (stateChangeEvent.hasPropertyChanged(SRCDOC)) {
        getWidget().setSrcdoc(state.srcdoc, getConnectorId());
    }

    if (stateChangeEvent.hasPropertyChanged("resources")
            || stateChangeEvent.hasPropertyChanged(SRCDOC)) {
        getWidget().setAttribute(ALLOW, state.allow);
        getWidget().setAttribute(REFERRERPOLICY, state.referrerpolicy);
        getWidget().setAttribute(SANDBOX, state.sandbox);
    }

    if (stateChangeEvent.hasPropertyChanged(ALLOW)) {
        getWidget().setAttribute(ALLOW, state.allow);
    }

    if (stateChangeEvent.hasPropertyChanged(REFERRERPOLICY)) {
        getWidget().setAttribute(REFERRERPOLICY, state.referrerpolicy);
    }

    if (stateChangeEvent.hasPropertyChanged(SANDBOX)) {
        getWidget().setAttribute(SANDBOX, state.sandbox);
    }
}
 
Example 19
Source File: GanttConnector.java    From gantt with Apache License 2.0 4 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    super.onStateChanged(stateChangeEvent);

    locale = getState().locale;
    timeZoneId = getState().timeZoneId;
    if (stateChangeEvent.hasPropertyChanged("locale")) {
        dateTimeService = null;
    }
    if (stateChangeEvent.hasPropertyChanged("timeZoneId")) {
        if (getState().timeZoneJson != null) {
            timeZone = TimeZone.createTimeZone(getState().timeZoneJson);
        } else {
            timeZone = TimeZone.createTimeZone(0);
        }
    }

    final boolean changeHasInpactToSteps = stateChangeEvent.hasPropertyChanged("resolution")
            || stateChangeEvent.hasPropertyChanged("startDate") || stateChangeEvent.hasPropertyChanged("endDate");

    if (stateChangeEvent.hasPropertyChanged("monthRowVisible")
            || stateChangeEvent.hasPropertyChanged("yearRowVisible")
            || stateChangeEvent.hasPropertyChanged("monthFormat")
            || stateChangeEvent.hasPropertyChanged("yearFormat")
            || stateChangeEvent.hasPropertyChanged("weekFormat")
            || stateChangeEvent.hasPropertyChanged("dayFormat")
            || stateChangeEvent.hasPropertyChanged("hourFormat")) {
        notifyHeight = !stateChangeEvent.isInitialStateChange();
        getWidget().setForceUpdateTimeline();
    }
    if (!notifyHeight && stateChangeEvent.hasPropertyChanged("resolution")) {
        notifyHeight = !stateChangeEvent.isInitialStateChange();
    }
    if (stateChangeEvent.hasPropertyChanged("movableSteps")
            || stateChangeEvent.hasPropertyChanged("resizableSteps")) {
        getWidget().resetListeners();
    }

    if (stateChangeEvent.hasPropertyChanged("readOnly")) {
        getWidget().setMovableSteps(!getState().readOnly && getState().movableSteps);
        getWidget().setResizableSteps(!getState().readOnly && getState().resizableSteps);
        for (StepWidget s : getSteps()) {
            s.setReadOnly(getState().readOnly);
        }
    }

    if (stateChangeEvent.hasPropertyChanged("verticalScrollDelegateTarget")) {
        handleVerticalScrollDelegateTargetChange();
    }

    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        @Override
        public void execute() {
            getWidget().update(getSteps());
            if (notifyHeight) {
                getWidget().notifyHeightChanged(previousHeight);
            }
            if (changeHasInpactToSteps) {
                updateAllStepsPredecessors();
            }
            updateVerticalScrollDelegation();
            adjustDelegateTargetHeightLazily();
        }
    });
}
 
Example 20
Source File: AceEditorConnector.java    From cuba with Apache License 2.0 4 votes vote down vote up
@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);
            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;
			}
		}
	}