com.vaadin.client.communication.StateChangeEvent Java Examples

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

    HtmlAttributesExtensionState state = getState();

    for (Map.Entry<String, Set<AttributeInfo>> entry : state.attributes.entrySet()) {
        withElement(entry.getKey(), element -> {
            for (AttributeInfo attributeInfo : entry.getValue()) {
                String name = attributeInfo.getName();
                String value = attributeInfo.getValue();
                switch (attributeInfo.getType()) {
                    case DOM:
                        element.setAttribute(name, value);
                        break;
                    case CSS:
                        element.getStyle().setProperty(name, value);
                        break;
                }
            }
        });
    }
}
 
Example #2
Source File: CubaPopupViewConnector.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    super.onStateChanged(stateChangeEvent);

    CubaPopupViewState state = getState();

    if (stateChangeEvent.hasPropertyChanged("popupPosition")) {
        getWidget().setupPopupPosition(state.popupPosition);
    }

    if (stateChangeEvent.hasPropertyChanged("popupPositionTop")) {
        getWidget().setupPopupPositionTop(state.popupPositionTop);
    }

    if (stateChangeEvent.hasPropertyChanged("popupPositionLeft")) {
        getWidget().setupPopupPositionLeft(state.popupPositionLeft);
    }
}
 
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: 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 #5
Source File: CubaPasswordFieldConnector.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    super.onStateChanged(stateChangeEvent);

    getWidget().setAutocomplete(getState().autocomplete);

    if (stateChangeEvent.hasPropertyChanged("capsLockIndicator")) {
        ComponentConnector capsLockIndicator = (ComponentConnector) getState().capsLockIndicator;

        getWidget().setIndicateCapsLock(capsLockIndicator == null ? null : capsLockIndicator.getWidget());
    }

    if (stateChangeEvent.hasPropertyChanged("htmlName")) {
        getWidget().setHtmlName(getState().htmlName);
    }
}
 
Example #6
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 #7
Source File: CubaButtonConnector.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    if (getState().useResponsePending) {
        stopResponsePending();
    }

    super.onStateChanged(stateChangeEvent);

    if (stateChangeEvent.hasPropertyChanged("caption")) {
        String text = getState().caption;
        if (text == null || "".equals(text)) {
            getWidget().addStyleDependentName("empty-caption");
        } else {
            getWidget().removeStyleDependentName("empty-caption");
        }
    }

    if (getIconUri() != null) {
        getWidget().addStyleName(ICON_STYLE);
    } else {
        getWidget().removeStyleName(ICON_STYLE);
    }
}
 
Example #8
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 #9
Source File: CubaRadioButtonGroupConnector.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("orientation")) {
        if (getState().orientation == Orientation.VERTICAL) {
            getWidget().removeStyleDependentName(HORIZONTAL_ORIENTATION_STYLE);
        } else {
            getWidget().addStyleDependentName(HORIZONTAL_ORIENTATION_STYLE);
        }
    }

    if (stateChangeEvent.hasPropertyChanged("readOnly")) {
        getWidget().setReadonly(getState().readOnly);
    }
}
 
Example #10
Source File: GwtLabelImplConnector.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
  super.onStateChanged(stateChangeEvent);

  getWidget().setText(getState().caption);

  switch (getState().myHorizontalAlignment) {
    case LEFT:
      getWidget().setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
      break;
    case CENTER:
      getWidget().setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
      break;
    case RIGHT:
      getWidget().setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
      break;
  }
}
 
Example #11
Source File: CubaVerticalSplitPanelConnector.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 #12
Source File: CubaDateFieldConnector.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    getWidget().getImpl().setMask(getState().dateMask);
    super.onStateChanged(stateChangeEvent);

    if (stateChangeEvent.hasPropertyChanged("tabIndex")) {
        getWidget().updateTabIndex(getState().tabIndex);
    }

    if (stateChangeEvent.hasPropertyChanged("autofill")) {
        getWidget().setAutofill(getState().autofill);
    }

    if (stateChangeEvent.hasPropertyChanged("rangeStart")) {
        getWidget().setDateRangeStart(getState().rangeStart);
    }

    if (stateChangeEvent.hasPropertyChanged("rangeEnd")) {
        getWidget().setDateRangeEnd(getState().rangeEnd);
    }
}
 
Example #13
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 #14
Source File: GanttConnector.java    From gantt with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        @Override
        public void execute() {
            adjustDelegateTargetHeightLazily();
        }
    });
}
 
Example #15
Source File: GwtHyperlinkImplConnector.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
  super.onStateChanged(stateChangeEvent);

  getWidget().getAnchor().setText(getState().caption);
  MultiImageState imageState = getState().myImageState;
  getWidget().setImage(ImageConverter.create(imageState), imageState.myWidth, imageState.myHeight);

  getWidget().rebuild();
}
 
Example #16
Source File: GwtRadionButtonImplConnector.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
  super.onStateChanged(stateChangeEvent);

  getWidget().setValue(getState().myChecked);
  getWidget().setText(getState().caption);
}
 
Example #17
Source File: GwtListBoxImplConnector.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
  super.onStateChanged(stateChangeEvent);

  List<ComboBoxState.Item> items = getState().myItems;
  List<Widget> widgets = new ArrayList<>(items.size());
  for (ComboBoxState.Item item : items) {
    widgets.add(buildItem(item));
  }
  getWidget().setItems(getState().mySelectedIndex, widgets);
}
 
Example #18
Source File: ContextMenuConnector.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    super.onStateChanged(stateChangeEvent);

    contextMenuWidget.clearItems();
    addMenuItemsFromState(contextMenuWidget, getState().menuItems);
}
 
Example #19
Source File: StepConnector.java    From gantt with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    super.onStateChanged(stateChangeEvent);

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

    if (gantt == null) {
        gantt = getGanttConnector().getWidget();
    }

    if (stateChangeEvent.hasPropertyChanged("step")) {
        updatePredecessorWidgetReference();// need to be called before
                                           // setStep
        getWidget().setStep(getState().step);
    }
    if (!getWidget().getElement().hasParentElement()) {
        gantt.addStep(getStepIndex(), getWidget(), true);
    }
    getWidget().updateWidth();

    Scheduler.get().scheduleDeferred(new ScheduledCommand() {
        @Override
        public void execute() {
            getWidget().updatePredecessor();
            GanttConnector ganttConnector = getGanttConnector();
            for (StepWidget stepWidget : ganttConnector.findRelatedSteps(getState().step,
                    ganttConnector.getChildComponents())) {
                stepWidget.updatePredecessor();
            }
        }
    });
}
 
Example #20
Source File: GwtCheckBoxImplConnector.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
  super.onStateChanged(stateChangeEvent);

  getWidget().setValue(getState().myChecked);
  getWidget().setText(getState().caption);
}
 
Example #21
Source File: SliderPanelConnector.java    From vaadin-sliderpanel with MIT License 5 votes vote down vote up
@Override
public void onStateChanged(final StateChangeEvent stateChangeEvent) {
    super.onStateChanged(stateChangeEvent);

    getWidget().configure(getState().mode, getState().flowInContent, getState().tabPosition, getState().pixel);

    if (stateChangeEvent.hasPropertyChanged("animationDuration")) {
        getWidget().setAnimationDuration(getState().animationDuration);
    }
    if (stateChangeEvent.hasPropertyChanged("caption")) {
        getWidget().setCaption(getState().caption, false);
    }
    if (stateChangeEvent.hasPropertyChanged("pixel")) {
        getWidget().setFixedContentSize(getState().pixel);
    }
    if (stateChangeEvent.hasPropertyChanged("autoCollapseSlider")) {
        getWidget().setAutoCollapseSlider(getState().autoCollapseSlider);
    }
    if (stateChangeEvent.hasPropertyChanged("zIndex")) {
        getWidget().setZIndex(getState().zIndex);
    }
    if (stateChangeEvent.hasPropertyChanged("enabled") ||
            stateChangeEvent.hasPropertyChanged("enableToggle")) {
        getWidget().setEnabled(getState().enabled && getState().enableToggle);
    }

    if (ComponentStateUtil.hasStyles(getState())) {
        String extraStyles = "";
        for (String style : getState().styles) {
            extraStyles += " " + style;
        }
        getWidget().setStyles(extraStyles);
    }
}
 
Example #22
Source File: SuggesterConnector.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
	super.onStateChanged(stateChangeEvent);

	this.suggestOnDot = getState().suggestOnDot;
       this.showDescriptions = getState().showDescriptions;
}
 
Example #23
Source File: GwtImageBoxImplConnector.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
  super.onStateChanged(stateChangeEvent);

  SimplePanel widget = getWidget();
  MultiImageState state = getState().myImageState;
  widget.setHeight(state.myHeight + "px");
  widget.setWidth(state.myWidth + "px");

  widget.setWidget(ImageConverter.create(state));
}
 
Example #24
Source File: CalendarConnector.java    From calendar-component with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    super.onStateChanged(stateChangeEvent);

    CalendarState state = getState();
    VCalendar widget = getWidget();

    // Enable or disable the forward and backward navigation buttons
    widget.setForwardNavigationEnabled(hasEventListener(CalendarEventId.FORWARD));
    widget.setBackwardNavigationEnabled(hasEventListener(CalendarEventId.BACKWARD));

    widget.set24HFormat(state.format24H);
    widget.setDayNames(state.dayNames);
    widget.setMonthNames(state.monthNames);
    widget.setFirstDayNumber(state.firstVisibleDayOfWeek);
    widget.setLastDayNumber(state.lastVisibleDayOfWeek);
    widget.setFirstHourOfTheDay(state.firstHourOfDay);
    widget.setLastHourOfTheDay(state.lastHourOfDay);
    widget.setDisabled(!state.enabled);

    widget.setRangeSelectAllowed(hasEventListener(CalendarEventId.RANGESELECT));
    widget.setRangeMoveAllowed(hasEventListener(CalendarEventId.ITEM_MOVE));
    widget.setItemMoveAllowed(hasEventListener(CalendarEventId.ITEM_MOVE));
    widget.setItemResizeAllowed(hasEventListener(CalendarEventId.ITEM_RESIZE));

    widget.setItemCaptionAsHtml(state.itemCaptionAsHtml);

    CalendarState.ItemSortOrder oldOrder = getWidget().getSortOrder();
    if (!SharedUtil.equals(oldOrder, getState().itemSortOrder)) {
        getWidget().setSortOrder(getState().itemSortOrder);
    }

    updateView();

    updateSizes();

    registerEventToolTips(state.items);
    updateActionMap(state.actions);
}
 
Example #25
Source File: GwtThreeComponentSplitLayoutConnector.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
  super.onStateChanged(stateChangeEvent);

  ThreeComponentSplitLayoutState state = getState();
  getWidget().rebuild(GwtUIUtil.connector2Widget(state.myLeftComponent), GwtUIUtil.connector2Widget(state.myRightComponent), GwtUIUtil.connector2Widget(state.myCenterComponent));
}
 
Example #26
Source File: CubaCssActionsLayoutConnector.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    super.onStateChanged(stateChangeEvent);

    getWidget().setMargin(new MarginInfo(getState().marginsBitmask));
    getWidget().setSpacing(getState().spacing);
}
 
Example #27
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 #28
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 #29
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 #30
Source File: GwtHtmlLabelImplConnector.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
  super.onStateChanged(stateChangeEvent);

  final String text = getState().caption;
  getWidget().setHTML(text);
}