diff options
author | Ahmed Ashour <asashour@yahoo.com> | 2017-10-31 18:51:22 +0100 |
---|---|---|
committer | Pekka Maanpää <pekkamaa@vaadin.com> | 2017-10-31 19:51:22 +0200 |
commit | 04905e1e2eb81770d813abda6a516254e541443d (patch) | |
tree | c7b7f1defd8dc908971dfaec0251195707003d22 | |
parent | d44a5e217d1fc2852adb84cc6ce1c0146ac603f2 (diff) | |
download | vaadin-framework-04905e1e2eb81770d813abda6a516254e541443d.tar.gz vaadin-framework-04905e1e2eb81770d813abda6a516254e541443d.zip |
Use local variable for getWidget(). (#10253)
In some places, getWidget() is called many times, and I believe this can
have a litte performance improvement, since in some cases
super.getWidget() is called more than once.
28 files changed, 589 insertions, 566 deletions
diff --git a/client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java b/client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java index 39c5187839..eb7277af54 100644 --- a/client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java +++ b/client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java @@ -207,9 +207,11 @@ public class GridConnector extends AbstractListingConnector updateWidgetStyleNames(); + Grid<JsonObject> grid = getWidget(); + // Remove default headers when initializing Grid widget - while (getWidget().getHeaderRowCount() > 0) { - getWidget().removeHeaderRow(0); + while (grid.getHeaderRowCount() > 0) { + grid.removeHeaderRow(0); } registerRpc(GridClientRpc.class, new GridClientRpc() { @@ -217,12 +219,12 @@ public class GridConnector extends AbstractListingConnector @Override public void scrollToRow(int row, ScrollDestination destination) { Scheduler.get().scheduleFinally( - () -> getWidget().scrollToRow(row, destination)); + () -> grid.scrollToRow(row, destination)); // Add details refresh listener and handle possible detail for // scrolled row. addDetailsRefreshCallback(() -> { if (rowHasDetails(row)) { - getWidget().scrollToRow(row, destination); + grid.scrollToRow(row, destination); } }); } @@ -230,34 +232,34 @@ public class GridConnector extends AbstractListingConnector @Override public void scrollToStart() { Scheduler.get() - .scheduleFinally(() -> getWidget().scrollToStart()); + .scheduleFinally(() -> grid.scrollToStart()); } @Override public void scrollToEnd() { Scheduler.get() - .scheduleFinally(() -> getWidget().scrollToEnd()); + .scheduleFinally(() -> grid.scrollToEnd()); addDetailsRefreshCallback(() -> { - if (rowHasDetails(getWidget().getDataSource().size() - 1)) { - getWidget().scrollToEnd(); + if (rowHasDetails(grid.getDataSource().size() - 1)) { + grid.scrollToEnd(); } }); } @Override public void recalculateColumnWidths() { - getWidget().recalculateColumnWidths(); + grid.recalculateColumnWidths(); } }); - getWidget().addSortHandler(this::handleSortEvent); - getWidget().setRowStyleGenerator(rowRef -> { + grid.addSortHandler(this::handleSortEvent); + grid.setRowStyleGenerator(rowRef -> { JsonObject json = rowRef.getRow(); return json.hasKey(GridState.JSONKEY_ROWSTYLE) ? json.getString(GridState.JSONKEY_ROWSTYLE) : null; }); - getWidget().setCellStyleGenerator(cellRef -> { + grid.setCellStyleGenerator(cellRef -> { JsonObject row = cellRef.getRow(); if (!row.hasKey(GridState.JSONKEY_CELLSTYLES)) { return null; @@ -276,13 +278,13 @@ public class GridConnector extends AbstractListingConnector return null; }); - getWidget().addColumnVisibilityChangeHandler(event -> { + grid.addColumnVisibilityChangeHandler(event -> { if (event.isUserOriginated()) { getRpcProxy(GridServerRpc.class).columnVisibilityChanged( getColumnId(event.getColumn()), event.isHidden()); } }); - getWidget().addColumnReorderHandler(event -> { + grid.addColumnReorderHandler(event -> { if (event.isUserOriginated()) { List<String> newColumnOrder = mapColumnsToIds( event.getNewColumnOrder()); @@ -292,21 +294,21 @@ public class GridConnector extends AbstractListingConnector .columnsReordered(newColumnOrder, oldColumnOrder); } }); - getWidget().addColumnResizeHandler(event -> { + grid.addColumnResizeHandler(event -> { Column<?, JsonObject> column = event.getColumn(); getRpcProxy(GridServerRpc.class).columnResized(getColumnId(column), column.getWidthActual()); }); // Handling row height changes - getWidget().addRowHeightChangedHandler(event -> { + grid.addRowHeightChangedHandler(event -> { getLayoutManager().setNeedsMeasureRecursively(GridConnector.this); getLayoutManager().layoutNow(); }); /* Item click events */ - getWidget().addBodyClickHandler(itemClickHandler); - getWidget().addBodyDoubleClickHandler(itemClickHandler); + grid.addBodyClickHandler(itemClickHandler); + grid.addBodyDoubleClickHandler(itemClickHandler); layout(); } @@ -358,14 +360,15 @@ public class GridConnector extends AbstractListingConnector Scheduler.get().scheduleFinally(() -> { GridState state = getState(); - if (getWidget().isAttached() && rowHeightNeedsReset()) { - getWidget().resetSizesFromDom(); + Grid<JsonObject> grid = getWidget(); + if (grid.isAttached() && rowHeightNeedsReset()) { + grid.resetSizesFromDom(); } - updateContainerRowHeigth(getWidget().getEscalator().getBody(), + updateContainerRowHeigth(grid.getEscalator().getBody(), state.bodyRowHeight); - updateContainerRowHeigth(getWidget().getEscalator().getHeader(), + updateContainerRowHeigth(grid.getEscalator().getHeader(), state.headerRowHeight); - updateContainerRowHeigth(getWidget().getEscalator().getFooter(), + updateContainerRowHeigth(grid.getEscalator().getFooter(), state.footerRowHeight); rowHeightScheduled = false; }); @@ -641,9 +644,8 @@ public class GridConnector extends AbstractListingConnector if (super.hasTooltip()) { return super.getTooltipInfo(element); - } else { - return null; } + return null; } @Override diff --git a/client/src/main/java/com/vaadin/client/ui/AbstractComponentConnector.java b/client/src/main/java/com/vaadin/client/ui/AbstractComponentConnector.java index ec8c005da5..655e184f8c 100644 --- a/client/src/main/java/com/vaadin/client/ui/AbstractComponentConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/AbstractComponentConnector.java @@ -170,13 +170,14 @@ public abstract class AbstractComponentConnector extends AbstractConnector * @since 7.6 */ protected void registerTouchHandlers() { - touchStartHandler = getWidget().addDomHandler(event -> { + Widget widget = getWidget(); + touchStartHandler = widget.addDomHandler(event -> { if (longTouchTimer != null && longTouchTimer.isRunning()) { return; } // Prevent selection for the element while pending long tap. - WidgetUtil.setTextSelectionEnabled(getWidget().getElement(), + WidgetUtil.setTextSelectionEnabled(widget.getElement(), false); if (BrowserInfo.get().isAndroid()) { @@ -192,7 +193,7 @@ public abstract class AbstractComponentConnector extends AbstractConnector final MouseEventDetails mouseEventDetails = MouseEventDetailsBuilder .buildMouseEventDetails(event.getNativeEvent(), - getWidget().getElement()); + widget.getElement()); final EventTarget eventTarget = event.getNativeEvent() .getEventTarget(); @@ -221,7 +222,7 @@ public abstract class AbstractComponentConnector extends AbstractConnector longTouchTimer.schedule(TOUCH_CONTEXT_MENU_TIMEOUT); }, TouchStartEvent.getType()); - touchMoveHandler = getWidget().addDomHandler(new TouchMoveHandler() { + touchMoveHandler = widget.addDomHandler(new TouchMoveHandler() { @Override public void onTouchMove(TouchMoveEvent event) { @@ -230,7 +231,6 @@ public abstract class AbstractComponentConnector extends AbstractConnector // expired, so let the browser handle the event. cancelTouchTimer(); } - } // mostly copy-pasted code from VScrollTable @@ -259,7 +259,7 @@ public abstract class AbstractComponentConnector extends AbstractConnector } }, TouchMoveEvent.getType()); - touchEndHandler = getWidget().addDomHandler(event -> { + touchEndHandler = widget.addDomHandler(event -> { // cancel the timer so the event doesn't fire cancelTouchTimer(); @@ -475,21 +475,22 @@ public abstract class AbstractComponentConnector extends AbstractConnector @OnStateChange({ "errorMessage", "errorLevel" }) private void setErrorLevel() { + Widget widget = getWidget(); // Add or remove the widget's error level style name - ErrorUtil.setErrorLevelStyle(getWidget().getElement(), - getWidget().getStylePrimaryName() + StyleConstants.ERROR_EXT, + ErrorUtil.setErrorLevelStyle(widget.getElement(), + widget.getStylePrimaryName() + StyleConstants.ERROR_EXT, getState().errorLevel); // Add or remove error indicator element - if (getWidget() instanceof HasErrorIndicatorElement) { - HasErrorIndicatorElement widget = (HasErrorIndicatorElement) getWidget(); + if (widget instanceof HasErrorIndicatorElement) { + HasErrorIndicatorElement hasErrorIndicatorElement = (HasErrorIndicatorElement) widget; if (getState().errorMessage != null) { - widget.setErrorIndicatorElementVisible(true); - ErrorUtil.setErrorLevelStyle(widget.getErrorIndicatorElement(), + hasErrorIndicatorElement.setErrorIndicatorElementVisible(true); + ErrorUtil.setErrorLevelStyle(hasErrorIndicatorElement.getErrorIndicatorElement(), StyleConstants.STYLE_NAME_ERROR_INDICATOR, getState().errorLevel); } else { - widget.setErrorIndicatorElementVisible(false); + hasErrorIndicatorElement.setErrorIndicatorElementVisible(false); } } } @@ -878,4 +879,4 @@ public abstract class AbstractComponentConnector extends AbstractConnector public void onDropTargetDetached() { } -} +}
\ No newline at end of file diff --git a/client/src/main/java/com/vaadin/client/ui/accordion/AccordionConnector.java b/client/src/main/java/com/vaadin/client/ui/accordion/AccordionConnector.java index 8014023c7d..1a2c0bad4c 100644 --- a/client/src/main/java/com/vaadin/client/ui/accordion/AccordionConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/accordion/AccordionConnector.java @@ -42,23 +42,24 @@ public class AccordionConnector extends TabsheetBaseConnector public void onStateChanged(StateChangeEvent stateChangeEvent) { super.onStateChanged(stateChangeEvent); + VAccordion widget = getWidget(); /* * Render content after all tabs have been created and we know how large * the content area is */ - if (getWidget().selectedItemIndex >= 0) { - StackItem selectedItem = getWidget() - .getStackItem(getWidget().selectedItemIndex); + if (widget.selectedItemIndex >= 0) { + StackItem selectedItem = widget + .getStackItem(widget.selectedItemIndex); ComponentConnector contentConnector = getChildComponents().get(0); if (contentConnector != null) { selectedItem.setContent(contentConnector.getWidget()); } - getWidget().open(getWidget().selectedItemIndex); + widget.open(widget.selectedItemIndex); - } else if (getWidget().getOpenStackItem() != null) { - getWidget().close(getWidget().getOpenStackItem()); + } else if (widget.getOpenStackItem() != null) { + widget.close(widget.getOpenStackItem()); } getLayoutManager().setNeedsVerticalLayout(this); } diff --git a/client/src/main/java/com/vaadin/client/ui/combobox/ComboBoxConnector.java b/client/src/main/java/com/vaadin/client/ui/combobox/ComboBoxConnector.java index 683776f2f0..dd13e36205 100644 --- a/client/src/main/java/com/vaadin/client/ui/combobox/ComboBoxConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/combobox/ComboBoxConnector.java @@ -67,29 +67,30 @@ public class ComboBoxConnector extends AbstractListingConnector Profiler.enter("ComboBoxConnector.onStateChanged update content"); - getWidget().readonly = isReadOnly(); - getWidget().updateReadOnly(); + VComboBox widget = getWidget(); + widget.readonly = isReadOnly(); + widget.updateReadOnly(); // not a FocusWidget -> needs own tabindex handling - getWidget().tb.setTabIndex(getState().tabIndex); + widget.tb.setTabIndex(getState().tabIndex); - getWidget().suggestionPopup.updateStyleNames(getState()); + widget.suggestionPopup.updateStyleNames(getState()); // TODO if the pop up is opened, the actual item should be removed from // the popup (?) - getWidget().nullSelectionAllowed = getState().emptySelectionAllowed; + widget.nullSelectionAllowed = getState().emptySelectionAllowed; // TODO having this true would mean that the empty selection item comes // from the data source so none needs to be added - currently // unsupported - getWidget().nullSelectItem = false; + widget.nullSelectItem = false; // make sure the input prompt is updated - getWidget().updatePlaceholder(); + widget.updatePlaceholder(); getDataReceivedHandler().serverReplyHandled(); // all updates except options have been done - getWidget().initDone = true; + widget.initDone = true; Profiler.leave("ComboBoxConnector.onStateChanged update content"); } @@ -202,15 +203,15 @@ public class ComboBoxConnector extends AbstractListingConnector // TODO this should be optimized not to try to fetch everything getDataSource().ensureAvailability(0, getDataSource().size()); return; - } else { - page = 0; } + page = 0; } - int adjustment = getWidget().nullSelectionAllowed && filter.isEmpty() + VComboBox widget = getWidget(); + int adjustment = widget.nullSelectionAllowed && filter.isEmpty() ? 1 : 0; int startIndex = Math.max(0, - page * getWidget().pageLength - adjustment); - int pageLength = getWidget().pageLength > 0 ? getWidget().pageLength + page * widget.pageLength - adjustment); + int pageLength = widget.pageLength > 0 ? widget.pageLength : getDataSource().size(); getDataSource().ensureAvailability(startIndex, pageLength); } diff --git a/client/src/main/java/com/vaadin/client/ui/datefield/AbstractInlineDateFieldConnector.java b/client/src/main/java/com/vaadin/client/ui/datefield/AbstractInlineDateFieldConnector.java index e43d7c8075..54294b54ae 100644 --- a/client/src/main/java/com/vaadin/client/ui/datefield/AbstractInlineDateFieldConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/datefield/AbstractInlineDateFieldConnector.java @@ -47,12 +47,13 @@ public abstract class AbstractInlineDateFieldConnector<PANEL extends VAbstractCa * customizing only listeners logic. */ protected void updateListeners() { + VAbstractDateFieldCalendar<PANEL, R> widget = getWidget(); if (isResolutionMonthOrHigher()) { - getWidget().calendarPanel + widget.calendarPanel .setFocusChangeListener(date -> { Date date2 = new Date(); - if (getWidget().calendarPanel.getDate() != null) { - date2.setTime(getWidget().calendarPanel.getDate() + if (widget.calendarPanel.getDate() != null) { + date2.setTime(widget.calendarPanel.getDate() .getTime()); } /* @@ -60,41 +61,40 @@ public abstract class AbstractInlineDateFieldConnector<PANEL extends VAbstractCa */ date2.setYear(date.getYear()); date2.setMonth(date.getMonth()); - getWidget().calendarPanel.setDate(date2); + widget.calendarPanel.setDate(date2); /* * Then update the value from panel to server */ - getWidget().updateValueFromPanel(); + widget.updateValueFromPanel(); }); } else { - getWidget().calendarPanel.setFocusChangeListener(null); + widget.calendarPanel.setFocusChangeListener(null); } } @Override public void onStateChanged(StateChangeEvent stateChangeEvent) { super.onStateChanged(stateChangeEvent); - getWidget().setTabIndex(getState().tabIndex); - getWidget().calendarPanel.setRangeStart(getState().rangeStart); - getWidget().calendarPanel.setRangeEnd(getState().rangeEnd); + VAbstractDateFieldCalendar<PANEL, R> widget = getWidget(); + widget.setTabIndex(getState().tabIndex); + widget.calendarPanel.setRangeStart(getState().rangeStart); + widget.calendarPanel.setRangeEnd(getState().rangeEnd); - getWidget().calendarPanel - .setShowISOWeekNumbers(getWidget().isShowISOWeekNumbers()); - getWidget().calendarPanel - .setDateTimeService(getWidget().getDateTimeService()); - getWidget().calendarPanel - .setResolution(getWidget().getCurrentResolution()); - Date currentDate = getWidget().getCurrentDate(); + widget.calendarPanel + .setShowISOWeekNumbers(widget.isShowISOWeekNumbers()); + widget.calendarPanel.setDateTimeService(widget.getDateTimeService()); + widget.calendarPanel.setResolution(widget.getCurrentResolution()); + Date currentDate = widget.getCurrentDate(); if (currentDate != null) { - getWidget().calendarPanel.setDate(new Date(currentDate.getTime())); + widget.calendarPanel.setDate(new Date(currentDate.getTime())); } else { - getWidget().calendarPanel.setDate(null); + widget.calendarPanel.setDate(null); } updateListeners(); // Update possible changes - getWidget().calendarPanel.renderCalendar(); + widget.calendarPanel.renderCalendar(); } @Override @@ -115,4 +115,4 @@ public abstract class AbstractInlineDateFieldConnector<PANEL extends VAbstractCa */ protected abstract boolean isResolutionMonthOrHigher(); -} +}
\ No newline at end of file diff --git a/client/src/main/java/com/vaadin/client/ui/datefield/DateTimeFieldConnector.java b/client/src/main/java/com/vaadin/client/ui/datefield/DateTimeFieldConnector.java index 18a7f9c0ef..9c3023a8da 100644 --- a/client/src/main/java/com/vaadin/client/ui/datefield/DateTimeFieldConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/datefield/DateTimeFieldConnector.java @@ -54,16 +54,17 @@ public class DateTimeFieldConnector extends @Override protected void updateListeners() { super.updateListeners(); - if (getWidget().getCurrentResolution() + VPopupTimeCalendar widget = getWidget(); + if (widget.getCurrentResolution() .compareTo(DateTimeResolution.DAY) < 0) { - getWidget().calendar + widget.calendar .setTimeChangeListener((hour, min, sec, msec) -> { - Date d = getWidget().getDate(); + Date d = widget.getDate(); if (d == null) { // date currently null, use the value from // calendarPanel // (~ client time at the init of the widget) - d = (Date) getWidget().calendar.getDate().clone(); + d = (Date) widget.calendar.getDate().clone(); } d.setHours(hour); d.setMinutes(min); @@ -71,11 +72,11 @@ public class DateTimeFieldConnector extends DateTimeService.setMilliseconds(d, msec); // Always update time changes to the server - getWidget().updateValue(d); + widget.updateValue(d); // Update text field - getWidget().buildDate(); + widget.buildDate(); }); } } -} +}
\ No newline at end of file diff --git a/client/src/main/java/com/vaadin/client/ui/draganddropwrapper/DragAndDropWrapperConnector.java b/client/src/main/java/com/vaadin/client/ui/draganddropwrapper/DragAndDropWrapperConnector.java index 47fb1ad682..04eec16589 100644 --- a/client/src/main/java/com/vaadin/client/ui/draganddropwrapper/DragAndDropWrapperConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/draganddropwrapper/DragAndDropWrapperConnector.java @@ -54,16 +54,17 @@ public class DragAndDropWrapperConnector extends CustomComponentConnector @Override public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { - getWidget().client = client; + VDragAndDropWrapper widget = getWidget(); + widget.client = client; if (isRealUpdate(uidl) && !uidl.hasAttribute("hidden")) { UIDL acceptCrit = uidl.getChildByTagName("-ac"); if (acceptCrit == null) { - getWidget().dropHandler = null; + widget.dropHandler = null; } else { - if (getWidget().dropHandler == null) { - getWidget().dropHandler = getWidget().new CustomDropHandler(); + if (widget.dropHandler == null) { + widget.dropHandler = widget.new CustomDropHandler(); } - getWidget().dropHandler.updateAcceptRules(acceptCrit); + widget.dropHandler.updateAcceptRules(acceptCrit); } Set<String> variableNames = uidl.getVariableNames(); @@ -71,37 +72,37 @@ public class DragAndDropWrapperConnector extends CustomComponentConnector if (fileId.startsWith("rec-")) { String receiverUrl = uidl.getStringVariable(fileId); fileId = fileId.substring(4); - if (getWidget().fileIdToReceiver == null) { - getWidget().fileIdToReceiver = new HashMap<>(); + if (widget.fileIdToReceiver == null) { + widget.fileIdToReceiver = new HashMap<>(); } if ("".equals(receiverUrl)) { Integer id = Integer.parseInt(fileId); - int indexOf = getWidget().fileIds.indexOf(id); + int indexOf = widget.fileIds.indexOf(id); if (indexOf != -1) { - getWidget().files.remove(indexOf); - getWidget().fileIds.remove(indexOf); + widget.files.remove(indexOf); + widget.fileIds.remove(indexOf); } } else { - if (getWidget().fileIdToReceiver.containsKey(fileId) + if (widget.fileIdToReceiver.containsKey(fileId) && receiverUrl != null && !receiverUrl - .equals(getWidget().fileIdToReceiver + .equals(widget.fileIdToReceiver .get(fileId))) { VConsole.error( "Overwriting file receiver mapping for fileId " + fileId + " . Old receiver URL: " - + getWidget().fileIdToReceiver + + widget.fileIdToReceiver .get(fileId) + " New receiver URL: " + receiverUrl); } - getWidget().fileIdToReceiver.put(fileId, receiverUrl); + widget.fileIdToReceiver.put(fileId, receiverUrl); } } } - getWidget().startNextUpload(); + widget.startNextUpload(); - getWidget().dragStartMode = uidl.getIntAttribute( + widget.dragStartMode = uidl.getIntAttribute( DragAndDropWrapperConstants.DRAG_START_MODE); String dragImageComponentConnectorId = uidl.getStringAttribute( @@ -118,15 +119,15 @@ public class DragAndDropWrapperConnector extends CustomComponentConnector + " connector now found. Make sure the" + " component is attached."); } else { - getWidget().setDragAndDropWidget(connector.getWidget()); + widget.setDragAndDropWidget(connector.getWidget()); } } - getWidget().initDragStartMode(); - getWidget().html5DataFlavors = uidl.getMapAttribute( + widget.initDragStartMode(); + widget.html5DataFlavors = uidl.getMapAttribute( DragAndDropWrapperConstants.HTML5_DATA_FLAVORS); // Used to prevent wrapper from stealing tooltips when not defined - getWidget().hasTooltip = getState().description != null; + widget.hasTooltip = getState().description != null; } } diff --git a/client/src/main/java/com/vaadin/client/ui/embedded/EmbeddedConnector.java b/client/src/main/java/com/vaadin/client/ui/embedded/EmbeddedConnector.java index dbc04941ba..010701c210 100644 --- a/client/src/main/java/com/vaadin/client/ui/embedded/EmbeddedConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/embedded/EmbeddedConnector.java @@ -52,8 +52,9 @@ public class EmbeddedConnector extends AbstractComponentConnector { // if theme has changed the resourceUrl may need to be updated updateResourceIfNecessary(); + VEmbedded widget = getWidget(); // Save details - getWidget().client = getConnection(); + widget.client = getConnection(); boolean clearBrowserElement = true; @@ -62,22 +63,21 @@ public class EmbeddedConnector extends AbstractComponentConnector { final EmbeddedState state = getState(); if (state.type != Embedded.TYPE_OBJECT) { // remove old style name related to type - if (getWidget().type != null) { - getWidget().removeStyleName( - VEmbedded.CLASSNAME + "-" + getWidget().type); + if (widget.type != null) { + widget.removeStyleName(VEmbedded.CLASSNAME + "-" + widget.type); } // remove old style name related to mime type - if (getWidget().mimetype != null) { - getWidget().removeStyleName( - VEmbedded.CLASSNAME + "-" + getWidget().mimetype); + if (widget.mimetype != null) { + widget.removeStyleName( + VEmbedded.CLASSNAME + "-" + widget.mimetype); } - getWidget().type = state.type == Embedded.TYPE_IMAGE ? "image" + widget.type = state.type == Embedded.TYPE_IMAGE ? "image" : "browser"; - if (getWidget().type.equals("image")) { - getWidget().addStyleName(VEmbedded.CLASSNAME + "-image"); + if (widget.type.equals("image")) { + widget.addStyleName(VEmbedded.CLASSNAME + "-image"); Element el = null; boolean created = false; - NodeList<Node> nodes = getWidget().getElement().getChildNodes(); + NodeList<Node> nodes = widget.getElement().getChildNodes(); if (nodes != null && nodes.getLength() == 1) { Node n = nodes.getItem(0); if (n.getNodeType() == Node.ELEMENT_NODE) { @@ -88,7 +88,7 @@ public class EmbeddedConnector extends AbstractComponentConnector { } } if (el == null) { - getWidget().setHTML(""); + widget.setHTML(""); el = DOM.createImg(); created = true; DOM.sinkEvents(el, Event.ONLOAD); @@ -109,56 +109,55 @@ public class EmbeddedConnector extends AbstractComponentConnector { if (created) { // insert in dom late - getWidget().getElement().appendChild(el); + widget.getElement().appendChild(el); } /* * Sink tooltip events so tooltip is displayed when hovering the * image. */ - getWidget().sinkEvents(VTooltip.TOOLTIP_EVENTS); + widget.sinkEvents(VTooltip.TOOLTIP_EVENTS); - } else if (getWidget().type.equals("browser")) { - getWidget().addStyleName(VEmbedded.CLASSNAME + "-browser"); - if (getWidget().browserElement == null) { - getWidget().setHTML( + } else if (widget.type.equals("browser")) { + widget.addStyleName(VEmbedded.CLASSNAME + "-browser"); + if (widget.browserElement == null) { + widget.setHTML( "<iframe width=\"100%\" height=\"100%\" frameborder=\"0\"" + " allowTransparency=\"true\" src=\"\"" + " name=\"" + getConnectorId() + "\"></iframe>"); - getWidget().browserElement = DOM - .getFirstChild(getWidget().getElement()); + widget.browserElement = DOM + .getFirstChild(widget.getElement()); } - resourceElement = getWidget().browserElement; + resourceElement = widget.browserElement; objectElement = null; setResourceUrl(getResourceUrl("src")); clearBrowserElement = false; } else { VConsole.error( - "Unknown Embedded type '" + getWidget().type + "'"); + "Unknown Embedded type '" + widget.type + "'"); } } else if (state.mimeType != null) { // remove old style name related to type - if (getWidget().type != null) { - getWidget().removeStyleName( - VEmbedded.CLASSNAME + "-" + getWidget().type); + if (widget.type != null) { + widget.removeStyleName(VEmbedded.CLASSNAME + "-" + widget.type); } // remove old style name related to mime type - if (getWidget().mimetype != null) { - getWidget().removeStyleName( - VEmbedded.CLASSNAME + "-" + getWidget().mimetype); + if (widget.mimetype != null) { + widget.removeStyleName( + VEmbedded.CLASSNAME + "-" + widget.mimetype); } final String mime = state.mimeType; if (mime.equals("application/x-shockwave-flash")) { - getWidget().mimetype = "flash"; + widget.mimetype = "flash"; // Handle embedding of Flash - getWidget().addStyleName(VEmbedded.CLASSNAME + "-flash"); - getWidget().setHTML(getWidget().createFlashEmbed(state, + widget.addStyleName(VEmbedded.CLASSNAME + "-flash"); + widget.setHTML(widget.createFlashEmbed(state, getResourceUrl("src"))); } else if (mime.equals("image/svg+xml")) { - getWidget().mimetype = "svg"; - getWidget().addStyleName(VEmbedded.CLASSNAME + "-svg"); + widget.mimetype = "svg"; + widget.addStyleName(VEmbedded.CLASSNAME + "-svg"); String data; Map<String, String> parameters = state.parameters; ObjectElement obj = Document.get().createObjectElement(); @@ -172,7 +171,7 @@ public class EmbeddedConnector extends AbstractComponentConnector { data = "data:image/svg+xml," + parameters.get("data"); obj.setData(data); } - getWidget().setHTML(""); + widget.setHTML(""); obj.setType(mime); if (!isUndefinedWidth()) { obj.getStyle().setProperty("width", "100%"); @@ -195,7 +194,7 @@ public class EmbeddedConnector extends AbstractComponentConnector { if (state.standby != null) { obj.setAttribute("standby", state.standby); } - getWidget().getElement().appendChild(obj); + widget.getElement().appendChild(obj); if (state.altText != null) { obj.setInnerText(state.altText); } @@ -207,7 +206,7 @@ public class EmbeddedConnector extends AbstractComponentConnector { } if (clearBrowserElement) { - getWidget().browserElement = null; + widget.browserElement = null; } } diff --git a/client/src/main/java/com/vaadin/client/ui/label/LabelConnector.java b/client/src/main/java/com/vaadin/client/ui/label/LabelConnector.java index 0d66a06941..a72414501e 100644 --- a/client/src/main/java/com/vaadin/client/ui/label/LabelConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/label/LabelConnector.java @@ -40,30 +40,31 @@ public class LabelConnector extends AbstractComponentConnector { super.onStateChanged(stateChangeEvent); boolean sinkOnloads = false; Profiler.enter("LabelConnector.onStateChanged update content"); + VLabel widget = getWidget(); switch (getState().contentMode) { case PREFORMATTED: PreElement preElement = Document.get().createPreElement(); preElement.setInnerText(getState().text); // clear existing content - getWidget().setHTML(""); + widget.setHTML(""); // add preformatted text to dom - getWidget().getElement().appendChild(preElement); + widget.getElement().appendChild(preElement); break; case TEXT: - getWidget().setText(getState().text); + widget.setText(getState().text); break; case HTML: sinkOnloads = true; - getWidget().setHTML(getState().text); + widget.setHTML(getState().text); break; } Profiler.leave("LabelConnector.onStateChanged update content"); if (sinkOnloads) { Profiler.enter("LabelConnector.onStateChanged sinkOnloads"); - WidgetUtil.sinkOnloadForImages(getWidget().getElement()); + WidgetUtil.sinkOnloadForImages(widget.getElement()); Profiler.leave("LabelConnector.onStateChanged sinkOnloads"); } } diff --git a/client/src/main/java/com/vaadin/client/ui/menubar/MenuBarConnector.java b/client/src/main/java/com/vaadin/client/ui/menubar/MenuBarConnector.java index 47d2eb0f35..4b9f9a1bd5 100644 --- a/client/src/main/java/com/vaadin/client/ui/menubar/MenuBarConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/menubar/MenuBarConnector.java @@ -51,21 +51,22 @@ public class MenuBarConnector extends AbstractComponentConnector return; } - getWidget().htmlContentAllowed = uidl + VMenuBar widget = getWidget(); + widget.htmlContentAllowed = uidl .hasAttribute(MenuBarConstants.HTML_CONTENT_ALLOWED); - getWidget().openRootOnHover = uidl + widget.openRootOnHover = uidl .getBooleanAttribute(MenuBarConstants.OPEN_ROOT_MENU_ON_HOWER); - getWidget().enabled = isEnabled(); + widget.enabled = isEnabled(); // For future connections - getWidget().client = client; - getWidget().uidlId = uidl.getId(); + widget.client = client; + widget.uidlId = uidl.getId(); // Empty the menu every time it receives new information - if (!getWidget().getItems().isEmpty()) { - getWidget().clearItems(); + if (!widget.getItems().isEmpty()) { + widget.clearItems(); } UIDL options = uidl.getChildUIDL(0); @@ -89,21 +90,21 @@ public class MenuBarConnector extends AbstractComponentConnector } itemHTML.append(moreItemText); - getWidget().moreItem = GWT.create(VMenuBar.CustomMenuItem.class); - getWidget().moreItem.setHTML(itemHTML.toString()); - getWidget().moreItem.setCommand(VMenuBar.emptyCommand); + widget.moreItem = GWT.create(VMenuBar.CustomMenuItem.class); + widget.moreItem.setHTML(itemHTML.toString()); + widget.moreItem.setCommand(VMenuBar.emptyCommand); - getWidget().collapsedRootItems = new VMenuBar(true, getWidget()); - getWidget().moreItem.setSubMenu(getWidget().collapsedRootItems); - getWidget().moreItem.addStyleName( - getWidget().getStylePrimaryName() + "-more-menuitem"); + widget.collapsedRootItems = new VMenuBar(true, widget); + widget.moreItem.setSubMenu(widget.collapsedRootItems); + widget.moreItem.addStyleName( + widget.getStylePrimaryName() + "-more-menuitem"); } UIDL uidlItems = uidl.getChildUIDL(1); Iterator<Object> itr = uidlItems.iterator(); Stack<Iterator<Object>> iteratorStack = new Stack<>(); Stack<VMenuBar> menuStack = new Stack<>(); - VMenuBar currentMenu = getWidget(); + VMenuBar currentMenu = widget; while (itr.hasNext()) { UIDL item = (UIDL) itr.next(); @@ -115,7 +116,7 @@ public class MenuBarConnector extends AbstractComponentConnector boolean itemIsCheckable = item .hasAttribute(MenuBarConstants.ATTRIBUTE_CHECKED); - String itemHTML = getWidget().buildItemHTML(item); + String itemHTML = widget.buildItemHTML(item); Command cmd = null; if (!item.hasAttribute("separator")) { @@ -125,7 +126,7 @@ public class MenuBarConnector extends AbstractComponentConnector cmd = new Command() { @Override public void execute() { - getWidget().hostReference.onMenuClick(itemId); + widget.hostReference.onMenuClick(itemId); } }; } diff --git a/client/src/main/java/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java b/client/src/main/java/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java index d24a3cc331..7f8ecc13ad 100644 --- a/client/src/main/java/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java @@ -96,10 +96,11 @@ public abstract class AbstractOrderedLayoutConnector // Get all needed element references Element captionElement = event.getElement(); + VAbstractOrderedLayout widget = getWidget(); // Caption position determines if the widget element is the first or // last child inside the caption wrap - CaptionPosition pos = getWidget().getCaptionPositionFromElement( + CaptionPosition pos = widget.getCaptionPositionFromElement( captionElement.getParentElement()); // The default is the last child @@ -115,7 +116,7 @@ public abstract class AbstractOrderedLayoutConnector if (captionElement == widgetElement) { // Caption element already detached - Slot slot = getWidget().getSlot(widgetElement); + Slot slot = widget.getSlot(widgetElement); if (slot != null) { slot.setCaptionResizeListener(null); } @@ -127,16 +128,16 @@ public abstract class AbstractOrderedLayoutConnector if (widgetHeight.endsWith("%") && (pos == CaptionPosition.TOP || pos == CaptionPosition.BOTTOM)) { - getWidget().updateCaptionOffset(captionElement); + widget.updateCaptionOffset(captionElement); } else if (widgetWidth.endsWith("%") && (pos == CaptionPosition.LEFT || pos == CaptionPosition.RIGHT)) { - getWidget().updateCaptionOffset(captionElement); + widget.updateCaptionOffset(captionElement); } updateLayoutHeight(); if (needsExpand()) { - getWidget().updateExpandCompensation(); + widget.updateExpandCompensation(); } }; @@ -280,7 +281,6 @@ public abstract class AbstractOrderedLayoutConnector getWidget().updateCaptionOffset(slot.getCaptionElement()); } } - } /* @@ -429,7 +429,8 @@ public abstract class AbstractOrderedLayoutConnector hasChildrenWithMiddleAlignment = false; - needsExpand = getWidget().vertical ? !isUndefinedHeight() + VAbstractOrderedLayout widget = getWidget(); + needsExpand = widget.vertical ? !isUndefinedHeight() : !isUndefinedWidth(); boolean onlyZeroExpands = true; @@ -446,7 +447,7 @@ public abstract class AbstractOrderedLayoutConnector // First update bookkeeping for all children for (ComponentConnector child : getChildComponents()) { - Slot slot = getWidget().getSlot(child.getWidget()); + Slot slot = widget.getSlot(child.getWidget()); slot.setRelativeWidth(child.isRelativeWidth()); slot.setRelativeHeight(child.isRelativeHeight()); @@ -458,10 +459,10 @@ public abstract class AbstractOrderedLayoutConnector // Update slot style names List<String> childStyles = child.getState().styles; if (childStyles == null) { - getWidget().setSlotStyleNames(child.getWidget(), + widget.setSlotStyleNames(child.getWidget(), (String[]) null); } else { - getWidget().setSlotStyleNames(child.getWidget(), + widget.setSlotStyleNames(child.getWidget(), childStyles.toArray(new String[childStyles.size()])); } @@ -489,10 +490,10 @@ public abstract class AbstractOrderedLayoutConnector if (needsFixedHeight()) { // Add resize listener to ensure the widget itself is measured getLayoutManager().addElementResizeListener( - getWidget().getElement(), childComponentResizeListener); + widget.getElement(), childComponentResizeListener); } else { getLayoutManager().removeElementResizeListener( - getWidget().getElement(), childComponentResizeListener); + widget.getElement(), childComponentResizeListener); } // Then update listeners based on bookkeeping @@ -502,14 +503,14 @@ public abstract class AbstractOrderedLayoutConnector // element resize events updateLayoutHeight(); if (needsExpand()) { - getWidget().updateExpandedSizes(); + widget.updateExpandedSizes(); // updateExpandedSizes causes fixed size components to temporarily // lose their size. updateExpandCompensation must be delayed until // the browser has a chance to measure them. Scheduler.get().scheduleFinally( - () -> getWidget().updateExpandCompensation()); + () -> widget.updateExpandCompensation()); } else { - getWidget().clearExpand(); + widget.clearExpand(); } Profiler.leave("AOLC.updateInternalState"); @@ -693,4 +694,4 @@ public abstract class AbstractOrderedLayoutConnector super.onUnregister(); } -} +}
\ No newline at end of file diff --git a/client/src/main/java/com/vaadin/client/ui/panel/PanelConnector.java b/client/src/main/java/com/vaadin/client/ui/panel/PanelConnector.java index 80b9e16d5b..125ba66aee 100644 --- a/client/src/main/java/com/vaadin/client/ui/panel/PanelConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/panel/PanelConnector.java @@ -85,22 +85,23 @@ public class PanelConnector extends AbstractSingleComponentContainerConnector @Override public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { + VPanel panel = getWidget(); if (isRealUpdate(uidl)) { // Handle caption displaying and style names, prior generics. // Affects size calculations // Restore default stylenames - getWidget().contentNode.setClassName(VPanel.CLASSNAME + "-content"); - getWidget().bottomDecoration + panel.contentNode.setClassName(VPanel.CLASSNAME + "-content"); + panel.bottomDecoration .setClassName(VPanel.CLASSNAME + "-deco"); - getWidget().captionNode.setClassName(VPanel.CLASSNAME + "-caption"); + panel.captionNode.setClassName(VPanel.CLASSNAME + "-caption"); boolean hasCaption = hasCaption(); if (hasCaption) { - getWidget().setCaption(getState().caption); + panel.setCaption(getState().caption); } else { - getWidget().setCaption(""); - getWidget().captionNode + panel.setCaption(""); + panel.captionNode .setClassName(VPanel.CLASSNAME + "-nocaption"); } @@ -120,11 +121,11 @@ public class PanelConnector extends AbstractSingleComponentContainerConnector decoClass += " " + decoBaseClass + "-" + style; } } - getWidget().captionNode.setClassName(captionClass); - getWidget().contentNode.setClassName(contentClass); - getWidget().bottomDecoration.setClassName(decoClass); + panel.captionNode.setClassName(captionClass); + panel.contentNode.setClassName(contentClass); + panel.bottomDecoration.setClassName(decoClass); - getWidget().makeScrollable(); + panel.makeScrollable(); } if (!isRealUpdate(uidl)) { @@ -133,13 +134,13 @@ public class PanelConnector extends AbstractSingleComponentContainerConnector clickEventHandler.handleEventHandlerRegistration(); - getWidget().client = client; - getWidget().id = uidl.getId(); + panel.client = client; + panel.id = uidl.getId(); if (getIconUri() != null) { - getWidget().setIconUri(getIconUri(), client); + panel.setIconUri(getIconUri(), client); } else { - getWidget().setIconUri(null, client); + panel.setIconUri(null, client); } // We may have actions attached to this panel @@ -148,29 +149,29 @@ public class PanelConnector extends AbstractSingleComponentContainerConnector for (int i = 0; i < cnt; i++) { UIDL childUidl = uidl.getChildUIDL(i); if (childUidl.getTag().equals("actions")) { - if (getWidget().shortcutHandler == null) { - getWidget().shortcutHandler = new ShortcutActionHandler( + if (panel.shortcutHandler == null) { + panel.shortcutHandler = new ShortcutActionHandler( getConnectorId(), client); } - getWidget().shortcutHandler.updateActionMap(childUidl); + panel.shortcutHandler.updateActionMap(childUidl); } } } - if (getState().scrollTop != getWidget().scrollTop) { + if (getState().scrollTop != panel.scrollTop) { // Sizes are not yet up to date, so changing the scroll position // is deferred to after the layout phase uidlScrollTop = getState().scrollTop; } - if (getState().scrollLeft != getWidget().scrollLeft) { + if (getState().scrollLeft != panel.scrollLeft) { // Sizes are not yet up to date, so changing the scroll position // is deferred to after the layout phase uidlScrollLeft = getState().scrollLeft; } // And apply tab index - getWidget().contentNode.setTabIndex(getState().tabIndex); + panel.contentNode.setTabIndex(getState().tabIndex); } /** diff --git a/client/src/main/java/com/vaadin/client/ui/popupview/PopupViewConnector.java b/client/src/main/java/com/vaadin/client/ui/popupview/PopupViewConnector.java index 07a1660965..ebf2b101cc 100644 --- a/client/src/main/java/com/vaadin/client/ui/popupview/PopupViewConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/popupview/PopupViewConnector.java @@ -28,6 +28,7 @@ import com.vaadin.client.ui.AbstractHasComponentsConnector; import com.vaadin.client.ui.PostLayoutListener; import com.vaadin.client.ui.VOverlay; import com.vaadin.client.ui.VPopupView; +import com.vaadin.client.ui.VPopupView.CustomPopup; import com.vaadin.shared.ui.ComponentStateUtil; import com.vaadin.shared.ui.Connect; import com.vaadin.shared.ui.popupview.PopupViewServerRpc; @@ -64,19 +65,19 @@ public class PopupViewConnector extends AbstractHasComponentsConnector @Override public void updateCaption(ComponentConnector childConnector) { + CustomPopup popup = getWidget().popup; if (VCaption.isNeeded(childConnector)) { - if (getWidget().popup.captionWrapper != null) { - getWidget().popup.captionWrapper.updateCaption(); + if (popup.captionWrapper != null) { + popup.captionWrapper.updateCaption(); } else { - getWidget().popup.captionWrapper = new VCaptionWrapper( + popup.captionWrapper = new VCaptionWrapper( childConnector, getConnection()); - getWidget().popup.setWidget(getWidget().popup.captionWrapper); - getWidget().popup.captionWrapper.updateCaption(); + popup.setWidget(popup.captionWrapper); + popup.captionWrapper.updateCaption(); } } else { - if (getWidget().popup.captionWrapper != null) { - getWidget().popup - .setWidget(getWidget().popup.popupComponentWidget); + if (popup.captionWrapper != null) { + popup.setWidget(popup.popupComponentWidget); } } } @@ -98,16 +99,18 @@ public class PopupViewConnector extends AbstractHasComponentsConnector public void onConnectorHierarchyChange( ConnectorHierarchyChangeEvent connectorHierarchyChangeEvent) { // Render the popup if visible and show it. + VPopupView widget = getWidget(); + CustomPopup popup = widget.popup; if (!getChildComponents().isEmpty()) { - getWidget().preparePopup(getWidget().popup); - getWidget().popup.setPopupConnector(getChildComponents().get(0)); + widget.preparePopup(popup); + popup.setPopupConnector(getChildComponents().get(0)); final StringBuilder styleBuf = new StringBuilder(); - final String primaryName = getWidget().popup.getStylePrimaryName(); + final String primaryName = popup.getStylePrimaryName(); styleBuf.append(primaryName); // Add "animate-in" class back if already present - boolean isAnimatingIn = getWidget().popup.getStyleName() + boolean isAnimatingIn = popup.getStyleName() .contains(VOverlay.ADDITIONAL_CLASSNAME_ANIMATE_IN); if (isAnimatingIn) { @@ -126,13 +129,13 @@ public class PopupViewConnector extends AbstractHasComponentsConnector } } - getWidget().popup.setStyleName(styleBuf.toString()); - getWidget().showPopup(getWidget().popup); + popup.setStyleName(styleBuf.toString()); + widget.showPopup(popup); centerAfterLayout = true; } else { // The popup shouldn't be visible, try to hide it. - getWidget().popup.hide(); + popup.hide(); } } diff --git a/client/src/main/java/com/vaadin/client/ui/splitpanel/AbstractSplitPanelConnector.java b/client/src/main/java/com/vaadin/client/ui/splitpanel/AbstractSplitPanelConnector.java index 0dd4e38e2c..bdff87a514 100644 --- a/client/src/main/java/com/vaadin/client/ui/splitpanel/AbstractSplitPanelConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/splitpanel/AbstractSplitPanelConnector.java @@ -117,41 +117,42 @@ public abstract class AbstractSplitPanelConnector extends public void onStateChanged(StateChangeEvent stateChangeEvent) { super.onStateChanged(stateChangeEvent); - getWidget().setEnabled(isEnabled()); + VAbstractSplitPanel panel = getWidget(); + panel.setEnabled(isEnabled()); clickEventHandler.handleEventHandlerRegistration(); if (ComponentStateUtil.hasStyles(getState())) { - getWidget().componentStyleNames = getState().styles; + panel.componentStyleNames = getState().styles; } else { - getWidget().componentStyleNames = new LinkedList<>(); + panel.componentStyleNames = new LinkedList<>(); } // Splitter updates SplitterState splitterState = getState().splitterState; - getWidget().setStylenames(); + panel.setStylenames(); - getWidget().minimumPosition = splitterState.minPosition + panel.minimumPosition = splitterState.minPosition + splitterState.minPositionUnit; - getWidget().maximumPosition = splitterState.maxPosition + panel.maximumPosition = splitterState.maxPosition + splitterState.maxPositionUnit; - getWidget().position = splitterState.position + panel.position = splitterState.position + splitterState.positionUnit; - getWidget().setPositionReversed(splitterState.positionReversed); + panel.setPositionReversed(splitterState.positionReversed); - getWidget().setLocked(splitterState.locked); + panel.setLocked(splitterState.locked); // This is needed at least for cases like #3458 to take // appearing/disappearing scrollbars into account. - getConnection().runDescendentsLayout(getWidget()); + getConnection().runDescendentsLayout(panel); getLayoutManager().setNeedsLayout(this); - getWidget().makeScrollable(); + panel.makeScrollable(); handleSingleComponentMove(); } @@ -180,7 +181,6 @@ public abstract class AbstractSplitPanelConnector extends handleHierarchyChange(); } } - } @Override diff --git a/client/src/main/java/com/vaadin/client/ui/tabsheet/TabsheetBaseConnector.java b/client/src/main/java/com/vaadin/client/ui/tabsheet/TabsheetBaseConnector.java index 0176da6a4e..6af505aad1 100644 --- a/client/src/main/java/com/vaadin/client/ui/tabsheet/TabsheetBaseConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/tabsheet/TabsheetBaseConnector.java @@ -53,43 +53,44 @@ public abstract class TabsheetBaseConnector public void onStateChanged(StateChangeEvent stateChangeEvent) { super.onStateChanged(stateChangeEvent); + VTabsheetBase widget = getWidget(); // Update member references - getWidget().setEnabled(isEnabled()); + widget.setEnabled(isEnabled()); // Widgets in the TabSheet before update List<Widget> oldWidgets = new ArrayList<>(); - for (Iterator<Widget> iterator = getWidget() + for (Iterator<Widget> iterator = widget .getWidgetIterator(); iterator.hasNext();) { oldWidgets.add(iterator.next()); } // Clear previous values - getWidget().clearTabKeys(); + widget.clearTabKeys(); int index = 0; for (TabState tab : getState().tabs) { final String key = tab.key; final boolean selected = key.equals(getState().selected); - getWidget().addTabKey(key, !tab.enabled && tab.visible); + widget.addTabKey(key, !tab.enabled && tab.visible); if (selected) { - getWidget().setActiveTabIndex(index); + widget.setActiveTabIndex(index); } - getWidget().renderTab(tab, index); + widget.renderTab(tab, index); if (selected) { - getWidget().selectTab(index); + widget.selectTab(index); } index++; } - int tabCount = getWidget().getTabCount(); + int tabCount = widget.getTabCount(); while (tabCount-- > index) { - getWidget().removeTab(index); + widget.removeTab(index); } - for (int i = 0; i < getWidget().getTabCount(); i++) { - ComponentConnector p = getWidget().getTab(i); + for (int i = 0; i < widget.getTabCount(); i++) { + ComponentConnector p = widget.getTab(i); // null for PlaceHolder widgets if (p != null) { oldWidgets.remove(p.getWidget()); diff --git a/client/src/main/java/com/vaadin/client/ui/ui/UIConnector.java b/client/src/main/java/com/vaadin/client/ui/ui/UIConnector.java index fe288b626b..835c924d47 100644 --- a/client/src/main/java/com/vaadin/client/ui/ui/UIConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/ui/UIConnector.java @@ -259,25 +259,26 @@ public class UIConnector extends AbstractSingleComponentContainerConnector @Override public void updateFromUIDL(final UIDL uidl, ApplicationConnection client) { - getWidget().id = getConnectorId(); - boolean firstPaint = getWidget().connection == null; - getWidget().connection = client; + VUI ui = getWidget(); + ui.id = getConnectorId(); + boolean firstPaint = ui.connection == null; + ui.connection = client; - getWidget().resizeLazy = uidl.hasAttribute(UIConstants.RESIZE_LAZY); + ui.resizeLazy = uidl.hasAttribute(UIConstants.RESIZE_LAZY); // this also implicitly removes old styles String styles = ""; - styles += getWidget().getStylePrimaryName() + " "; + styles += ui.getStylePrimaryName() + " "; if (ComponentStateUtil.hasStyles(getState())) { for (String style : getState().styles) { styles += style + " "; } } if (!client.getConfiguration().isStandalone()) { - styles += getWidget().getStylePrimaryName() + "-embedded"; + styles += ui.getStylePrimaryName() + "-embedded"; } - getWidget().setStyleName(styles.trim()); + ui.setStyleName(styles.trim()); - getWidget().makeScrollable(); + ui.makeScrollable(); clickEventHandler.handleEventHandlerRegistration(); @@ -353,11 +354,10 @@ public class UIConnector extends AbstractSingleComponentContainerConnector while ((childUidl = uidl.getChildUIDL(childIndex++)) != null) { String tag = childUidl.getTag().intern(); if (tag == "actions") { - if (getWidget().actionHandler == null) { - getWidget().actionHandler = new ShortcutActionHandler( - getWidget().id, client); + if (ui.actionHandler == null) { + ui.actionHandler = new ShortcutActionHandler(ui.id, client); } - getWidget().actionHandler.updateActionMap(childUidl); + ui.actionHandler.updateActionMap(childUidl); } else if (tag == "css-injections") { injectCSS(childUidl); } @@ -404,8 +404,8 @@ public class UIConnector extends AbstractSingleComponentContainerConnector // Add window listeners on first paint, to prevent premature // variablechanges if (firstPaint) { - Window.addWindowClosingHandler(getWidget()); - Window.addResizeHandler(getWidget()); + Window.addWindowClosingHandler(ui); + Window.addResizeHandler(ui); } if (uidl.hasAttribute("scrollTo")) { @@ -429,7 +429,7 @@ public class UIConnector extends AbstractSingleComponentContainerConnector // Queue the initial window size to be sent with the following // request. Scheduler.get() - .scheduleDeferred(() -> getWidget().sendClientResized()); + .scheduleDeferred(() -> ui.sendClientResized()); } } @@ -505,7 +505,8 @@ public class UIConnector extends AbstractSingleComponentContainerConnector public void init(String rootPanelId, ApplicationConnection applicationConnection) { - Widget shortcutContextWidget = getWidget(); + VUI ui = getWidget(); + Widget shortcutContextWidget = ui; if (applicationConnection.getConfiguration().isStandalone()) { // Listen to body for standalone apps (#19392) shortcutContextWidget = RootPanel.get(); // document body @@ -515,19 +516,19 @@ public class UIConnector extends AbstractSingleComponentContainerConnector if (VWindow.isModalWindowOpen()) { return; } - if (getWidget().actionHandler != null) { + if (ui.actionHandler != null) { Element target = Element .as(event.getNativeEvent().getEventTarget()); if (target == Document.get().getBody() - || getWidget().getElement().isOrHasChild(target)) { + || ui.getElement().isOrHasChild(target)) { // Only react to body and elements inside the UI - getWidget().actionHandler.handleKeyboardEvent( + ui.actionHandler.handleKeyboardEvent( (Event) event.getNativeEvent().cast()); } } }, KeyDownEvent.getType()); - DOM.sinkEvents(getWidget().getElement(), Event.ONSCROLL); + DOM.sinkEvents(ui.getElement(), Event.ONSCROLL); RootPanel root = RootPanel.get(rootPanelId); @@ -541,18 +542,18 @@ public class UIConnector extends AbstractSingleComponentContainerConnector activeTheme = applicationConnection.getConfiguration().getThemeName(); root.addStyleName(activeTheme); - root.add(getWidget()); + root.add(ui); // Set default tab index before focus call. State change handler // will update this later if needed. - getWidget().setTabIndex(1); + ui.setTabIndex(1); if (applicationConnection.getConfiguration().isStandalone()) { // set focus to iview element by default to listen possible keyboard // shortcuts. For embedded applications this is unacceptable as we // don't want to steal focus from the main page nor we don't want // side-effects from focusing (scrollIntoView). - getWidget().getElement().focus(); + ui.getElement().focus(); } applicationConnection.addHandler( @@ -600,9 +601,8 @@ public class UIConnector extends AbstractSingleComponentContainerConnector // but it's never a content widget if (connector instanceof WindowConnector) { return null; - } else { - return connector; } + return connector; } protected void onChildSizeChange() { @@ -722,7 +722,6 @@ public class UIConnector extends AbstractSingleComponentContainerConnector window.setVisible(false); window.show(); } - } } @@ -1207,4 +1206,4 @@ public class UIConnector extends AbstractSingleComponentContainerConnector conf['dragImageCenterOnTouch'] = true; $wnd.DragDropPolyfill.Initialize(conf); }-*/; -} +}
\ No newline at end of file diff --git a/client/src/main/java/com/vaadin/client/ui/upload/UploadConnector.java b/client/src/main/java/com/vaadin/client/ui/upload/UploadConnector.java index 9c784ae23c..92945427f5 100644 --- a/client/src/main/java/com/vaadin/client/ui/upload/UploadConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/upload/UploadConnector.java @@ -59,36 +59,37 @@ public class UploadConnector extends AbstractComponentConnector if (!isRealUpdate(uidl)) { return; } + VUpload upload = getWidget(); if (uidl.hasAttribute("notStarted")) { - getWidget().t.schedule(400); + upload.t.schedule(400); return; } - getWidget().setImmediateMode(getState().immediateMode); - getWidget().client = client; - getWidget().paintableId = uidl.getId(); - getWidget().nextUploadId = uidl.getIntAttribute("nextid"); + upload.setImmediateMode(getState().immediateMode); + upload.client = client; + upload.paintableId = uidl.getId(); + upload.nextUploadId = uidl.getIntAttribute("nextid"); final String action = client .translateVaadinUri(uidl.getStringVariable("action")); - getWidget().element.setAction(action); + upload.element.setAction(action); if (uidl.hasAttribute("buttoncaption")) { - getWidget().submitButton + upload.submitButton .setText(uidl.getStringAttribute("buttoncaption")); if (uidl.hasAttribute("buttonstylename")) { - getWidget().submitButton + upload.submitButton .setStyleName(uidl.getStringAttribute("buttonstylename")); } - getWidget().submitButton.setVisible(true); + upload.submitButton.setVisible(true); } else { - getWidget().submitButton.setVisible(false); + upload.submitButton.setVisible(false); } - getWidget().fu.setName(getWidget().paintableId + "_file"); + upload.fu.setName(upload.paintableId + "_file"); if (!isEnabled()) { - getWidget().disableUpload(); + upload.disableUpload(); } else if (!uidl.getBooleanAttribute("state")) { // Enable the button only if an upload is not in progress - getWidget().enableUpload(); - getWidget().ensureTargetFrame(); + upload.enableUpload(); + upload.ensureTargetFrame(); } } diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/connectors/GridConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/connectors/GridConnector.java index 57179b678c..06981feac5 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/connectors/GridConnector.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/connectors/GridConnector.java @@ -772,6 +772,7 @@ public class GridConnector extends AbstractHasComponentsConnector protected void init() { super.init(); + Grid<JsonObject> grid = getWidget(); // All scroll RPC calls are executed finally to avoid issues on init registerRpc(GridClientRpc.class, new GridClientRpc() { @Override @@ -783,7 +784,7 @@ public class GridConnector extends AbstractHasComponentsConnector Scheduler.get().scheduleFinally(new ScheduledCommand() { @Override public void execute() { - getWidget().scrollToStart(); + grid.scrollToStart(); } }); } @@ -793,7 +794,7 @@ public class GridConnector extends AbstractHasComponentsConnector Scheduler.get().scheduleFinally(new ScheduledCommand() { @Override public void execute() { - getWidget().scrollToEnd(); + grid.scrollToEnd(); // Scrolls further if details opens. lazyDetailsScroller.scrollToRow(dataSource.size() - 1, ScrollDestination.END); @@ -807,7 +808,7 @@ public class GridConnector extends AbstractHasComponentsConnector Scheduler.get().scheduleFinally(new ScheduledCommand() { @Override public void execute() { - getWidget().scrollToRow(row, destination); + grid.scrollToRow(row, destination); // Scrolls a bit further if details opens. lazyDetailsScroller.scrollToRow(row, destination); } @@ -816,19 +817,19 @@ public class GridConnector extends AbstractHasComponentsConnector @Override public void recalculateColumnWidths() { - getWidget().recalculateColumnWidths(); + grid.recalculateColumnWidths(); } }); /* Item click events */ - getWidget().addBodyClickHandler(itemClickHandler); - getWidget().addBodyDoubleClickHandler(itemClickHandler); + grid.addBodyClickHandler(itemClickHandler); + grid.addBodyDoubleClickHandler(itemClickHandler); /* Style Generators */ - getWidget().setCellStyleGenerator(styleGenerator); - getWidget().setRowStyleGenerator(styleGenerator); + grid.setCellStyleGenerator(styleGenerator); + grid.setRowStyleGenerator(styleGenerator); - getWidget().addSortHandler(new SortHandler<JsonObject>() { + grid.addSortHandler(new SortHandler<JsonObject>() { @Override public void sort(SortEvent<JsonObject> event) { List<SortOrder> order = event.getOrder(); @@ -852,19 +853,19 @@ public class GridConnector extends AbstractHasComponentsConnector } }); - getWidget().setEditorHandler(editorHandler); - getWidget().addColumnReorderHandler(columnReorderHandler); - getWidget().addColumnVisibilityChangeHandler( + grid.setEditorHandler(editorHandler); + grid.addColumnReorderHandler(columnReorderHandler); + grid.addColumnVisibilityChangeHandler( columnVisibilityChangeHandler); - getWidget().addColumnResizeHandler(columnResizeHandler); + grid.addColumnResizeHandler(columnResizeHandler); ConnectorFocusAndBlurHandler.addHandlers(this); - getWidget().setDetailsGenerator(customDetailsGenerator); - getLayoutManager().registerDependency(this, getWidget().getElement()); + grid.setDetailsGenerator(customDetailsGenerator); + getLayoutManager().registerDependency(this, grid.getElement()); // Handling row height changes - getWidget().addRowHeightChangedHandler(new RowHeightChangedHandler() { + grid.addRowHeightChangedHandler(new RowHeightChangedHandler() { @Override public void onRowHeightChanged(RowHeightChangedEvent event) { getLayoutManager() @@ -970,17 +971,18 @@ public class GridConnector extends AbstractHasComponentsConnector } private void updateHeaderFromState(GridStaticSectionState state) { - getWidget().setHeaderVisible(state.visible); + Grid<JsonObject> grid = getWidget(); + grid.setHeaderVisible(state.visible); - while (getWidget().getHeaderRowCount() > 0) { - getWidget().removeHeaderRow(0); + while (grid.getHeaderRowCount() > 0) { + grid.removeHeaderRow(0); } for (RowState rowState : state.rows) { - HeaderRow row = getWidget().appendHeaderRow(); + HeaderRow row = grid.appendHeaderRow(); if (rowState.defaultRow) { - getWidget().setDefaultHeaderRow(row); + grid.setDefaultHeaderRow(row); } for (CellState cellState : rowState.cells) { @@ -1035,14 +1037,15 @@ public class GridConnector extends AbstractHasComponentsConnector } private void updateFooterFromState(GridStaticSectionState state) { - getWidget().setFooterVisible(state.visible); + Grid<JsonObject> grid = getWidget(); + grid.setFooterVisible(state.visible); - while (getWidget().getFooterRowCount() > 0) { - getWidget().removeFooterRow(0); + while (grid.getFooterRowCount() > 0) { + grid.removeFooterRow(0); } for (RowState rowState : state.rows) { - FooterRow row = getWidget().appendFooterRow(); + FooterRow row = grid.appendFooterRow(); for (CellState cellState : rowState.cells) { CustomGridColumn column = columnIdToColumn diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/CalendarConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/CalendarConnector.java index 7c3910c009..a9e5341206 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/CalendarConnector.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/CalendarConnector.java @@ -137,16 +137,17 @@ public class CalendarConnector extends AbstractLegacyComponentConnector * events. */ protected void registerListeners() { - getWidget().setListener(new DateClickListener() { + VCalendar calendar = getWidget(); + calendar.setListener(new DateClickListener() { @Override public void dateClick(String date) { - if (!getWidget().isDisabled() + if (!calendar.isDisabled() && hasEventListener(CalendarEventId.DATECLICK)) { rpc.dateClick(date); } } }); - getWidget().setListener(new ForwardListener() { + calendar.setListener(new ForwardListener() { @Override public void forward() { if (hasEventListener(CalendarEventId.FORWARD)) { @@ -154,7 +155,7 @@ public class CalendarConnector extends AbstractLegacyComponentConnector } } }); - getWidget().setListener(new BackwardListener() { + calendar.setListener(new BackwardListener() { @Override public void backward() { if (hasEventListener(CalendarEventId.BACKWARD)) { @@ -162,7 +163,7 @@ public class CalendarConnector extends AbstractLegacyComponentConnector } } }); - getWidget().setListener(new RangeSelectListener() { + calendar.setListener(new RangeSelectListener() { @Override public void rangeSelected(String value) { if (hasEventListener(CalendarEventId.RANGESELECT)) { @@ -170,16 +171,16 @@ public class CalendarConnector extends AbstractLegacyComponentConnector } } }); - getWidget().setListener(new WeekClickListener() { + calendar.setListener(new WeekClickListener() { @Override public void weekClick(String event) { - if (!getWidget().isDisabled() + if (!calendar.isDisabled() && hasEventListener(CalendarEventId.WEEKCLICK)) { rpc.weekClick(event); } } }); - getWidget().setListener(new EventMovedListener() { + calendar.setListener(new EventMovedListener() { @Override public void eventMoved(CalendarEvent event) { if (hasEventListener(CalendarEventId.EVENTMOVE)) { @@ -192,7 +193,7 @@ public class CalendarConnector extends AbstractLegacyComponentConnector } } }); - getWidget().setListener(new EventResizeListener() { + calendar.setListener(new EventResizeListener() { @Override public void eventResized(CalendarEvent event) { if (hasEventListener(CalendarEventId.EVENTRESIZE)) { @@ -219,14 +220,14 @@ public class CalendarConnector extends AbstractLegacyComponentConnector } } }); - getWidget().setListener(new VCalendar.ScrollListener() { + calendar.setListener(new VCalendar.ScrollListener() { @Override public void scroll(int scrollPosition) { // This call is @Delayed (== non-immediate) rpc.scroll(scrollPosition); } }); - getWidget().setListener(new EventClickListener() { + calendar.setListener(new EventClickListener() { @Override public void eventClick(CalendarEvent event) { if (hasEventListener(CalendarEventId.EVENTCLICK)) { @@ -234,7 +235,7 @@ public class CalendarConnector extends AbstractLegacyComponentConnector } } }); - getWidget().setListener(new MouseEventListener() { + calendar.setListener(new MouseEventListener() { @Override public void contextMenu(ContextMenuEvent event, final Widget widget) { @@ -327,54 +328,56 @@ public class CalendarConnector extends AbstractLegacyComponentConnector super.onStateChanged(stateChangeEvent); CalendarState state = getState(); - VCalendar widget = getWidget(); + VCalendar calendar = getWidget(); // Enable or disable the forward and backward navigation buttons - widget.setForwardNavigationEnabled( + calendar.setForwardNavigationEnabled( hasEventListener(CalendarEventId.FORWARD)); - widget.setBackwardNavigationEnabled( + calendar.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.setReadOnly(state.readOnly); - widget.setDisabled(!state.enabled); - - widget.setRangeSelectAllowed( + calendar.set24HFormat(state.format24H); + calendar.setDayNames(state.dayNames); + calendar.setMonthNames(state.monthNames); + calendar.setFirstDayNumber(state.firstVisibleDayOfWeek); + calendar.setLastDayNumber(state.lastVisibleDayOfWeek); + calendar.setFirstHourOfTheDay(state.firstHourOfDay); + calendar.setLastHourOfTheDay(state.lastHourOfDay); + calendar.setReadOnly(state.readOnly); + calendar.setDisabled(!state.enabled); + + calendar.setRangeSelectAllowed( hasEventListener(CalendarEventId.RANGESELECT)); - widget.setRangeMoveAllowed(hasEventListener(CalendarEventId.EVENTMOVE)); - widget.setEventMoveAllowed(hasEventListener(CalendarEventId.EVENTMOVE)); - widget.setEventResizeAllowed( + calendar.setRangeMoveAllowed( + hasEventListener(CalendarEventId.EVENTMOVE)); + calendar.setEventMoveAllowed( + hasEventListener(CalendarEventId.EVENTMOVE)); + calendar.setEventResizeAllowed( hasEventListener(CalendarEventId.EVENTRESIZE)); - widget.setEventCaptionAsHtml(state.eventCaptionAsHtml); + calendar.setEventCaptionAsHtml(state.eventCaptionAsHtml); - EventSortOrder oldOrder = getWidget().getSortOrder(); + EventSortOrder oldOrder = calendar.getSortOrder(); if (!SharedUtil.equals(oldOrder, getState().eventSortOrder)) { - getWidget().setSortOrder(getState().eventSortOrder); + calendar.setSortOrder(getState().eventSortOrder); } updateEventsInView(); List<CalendarState.Day> days = state.days; List<CalendarState.Event> events = state.events; - CalendarDropHandler dropHandler = getWidget().getDropHandler(); + CalendarDropHandler dropHandler = calendar.getDropHandler(); if (showingMonthView()) { updateMonthView(days, events); if (dropHandler != null && !(dropHandler instanceof CalendarMonthDropHandler)) { - getWidget().setDropHandler(new CalendarMonthDropHandler(this)); + calendar.setDropHandler(new CalendarMonthDropHandler(this)); } } else { updateWeekView(days, events); if (dropHandler != null && !(dropHandler instanceof CalendarWeekDropHandler)) { - getWidget().setDropHandler(new CalendarWeekDropHandler(this)); + calendar.setDropHandler(new CalendarWeekDropHandler(this)); } } diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/combobox/ComboBoxConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/combobox/ComboBoxConnector.java index e064eb9dad..7b5cd4eaf6 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/combobox/ComboBoxConnector.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/combobox/ComboBoxConnector.java @@ -50,12 +50,13 @@ public class ComboBoxConnector extends AbstractFieldConnector */ @Override public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { + VFilterSelect widget = getWidget(); // Save details - getWidget().client = client; - getWidget().paintableId = uidl.getId(); + widget.client = client; + widget.paintableId = uidl.getId(); - getWidget().readonly = isReadOnly(); - getWidget().updateReadOnly(); + widget.readonly = isReadOnly(); + widget.updateReadOnly(); if (!isRealUpdate(uidl)) { return; @@ -67,75 +68,75 @@ public class ComboBoxConnector extends AbstractFieldConnector .hasAttribute(ComboBoxConstants.ATTR_NO_TEXT_INPUT) && uidl.getBooleanAttribute( ComboBoxConstants.ATTR_NO_TEXT_INPUT); - getWidget().setTextInputEnabled(!noTextInput); + widget.setTextInputEnabled(!noTextInput); // not a FocusWidget -> needs own tabindex handling - getWidget().tb.setTabIndex(getState().tabIndex); + widget.tb.setTabIndex(getState().tabIndex); if (uidl.hasAttribute("filteringmode")) { - getWidget().filteringmode = FilteringMode + widget.filteringmode = FilteringMode .valueOf(uidl.getStringAttribute("filteringmode")); } - getWidget().immediate = getState().immediate; + widget.immediate = getState().immediate; - getWidget().nullSelectionAllowed = uidl.hasAttribute("nullselect"); + widget.nullSelectionAllowed = uidl.hasAttribute("nullselect"); - getWidget().nullSelectItem = uidl.hasAttribute("nullselectitem") + widget.nullSelectItem = uidl.hasAttribute("nullselectitem") && uidl.getBooleanAttribute("nullselectitem"); - getWidget().currentPage = uidl.getIntVariable("page"); + widget.currentPage = uidl.getIntVariable("page"); if (uidl.hasAttribute("pagelength")) { - getWidget().pageLength = uidl.getIntAttribute("pagelength"); + widget.pageLength = uidl.getIntAttribute("pagelength"); } if (uidl.hasAttribute(ComboBoxConstants.ATTR_INPUTPROMPT)) { // input prompt changed from server - getWidget().inputPrompt = uidl + widget.inputPrompt = uidl .getStringAttribute(ComboBoxConstants.ATTR_INPUTPROMPT); } else { - getWidget().inputPrompt = ""; + widget.inputPrompt = ""; } if (uidl.hasAttribute("suggestionPopupWidth")) { - getWidget().suggestionPopupWidth = uidl + widget.suggestionPopupWidth = uidl .getStringAttribute("suggestionPopupWidth"); } else { - getWidget().suggestionPopupWidth = null; + widget.suggestionPopupWidth = null; } if (uidl.hasAttribute("suggestionPopupWidth")) { - getWidget().suggestionPopupWidth = uidl + widget.suggestionPopupWidth = uidl .getStringAttribute("suggestionPopupWidth"); } else { - getWidget().suggestionPopupWidth = null; + widget.suggestionPopupWidth = null; } - getWidget().suggestionPopup.updateStyleNames(uidl, getState()); + widget.suggestionPopup.updateStyleNames(uidl, getState()); - getWidget().allowNewItem = uidl.hasAttribute("allownewitem"); - getWidget().lastNewItemString = null; + widget.allowNewItem = uidl.hasAttribute("allownewitem"); + widget.lastNewItemString = null; final UIDL options = uidl.getChildUIDL(0); if (uidl.hasAttribute("totalMatches")) { - getWidget().totalMatches = uidl.getIntAttribute("totalMatches"); + widget.totalMatches = uidl.getIntAttribute("totalMatches"); } else { - getWidget().totalMatches = 0; + widget.totalMatches = 0; } List<FilterSelectSuggestion> newSuggestions = new ArrayList<FilterSelectSuggestion>(); for (final Object child : options) { final UIDL optionUidl = (UIDL) child; - final FilterSelectSuggestion suggestion = getWidget().new FilterSelectSuggestion( + final FilterSelectSuggestion suggestion = widget.new FilterSelectSuggestion( optionUidl); newSuggestions.add(suggestion); } // only close the popup if the suggestions list has actually changed - boolean suggestionsChanged = !getWidget().initDone - || !newSuggestions.equals(getWidget().currentSuggestions); + boolean suggestionsChanged = !widget.initDone + || !newSuggestions.equals(widget.currentSuggestions); // An ItemSetChangeEvent on server side clears the current suggestion // popup. Popup needs to be repopulated with suggestions from UIDL. @@ -145,28 +146,28 @@ public class ComboBoxConnector extends AbstractFieldConnector if (suggestionsChanged) { oldSuggestionTextMatchTheOldSelection = isWidgetsCurrentSelectionTextInTextBox(); - getWidget().currentSuggestions.clear(); + widget.currentSuggestions.clear(); - if (!getWidget().waitingForFilteringResponse) { + if (!widget.waitingForFilteringResponse) { /* * Clear the current suggestions as the server response always * includes the new ones. Exception is when filtering, then we * need to retain the value if the user does not select any of * the options matching the filter. */ - getWidget().currentSuggestion = null; + widget.currentSuggestion = null; /* * Also ensure no old items in menu. Unless cleared the old * values may cause odd effects on blur events. Suggestions in * menu might not necessary exist in select at all anymore. */ - getWidget().suggestionPopup.menu.clearItems(); - popupOpenAndCleared = getWidget().suggestionPopup.isAttached(); + widget.suggestionPopup.menu.clearItems(); + popupOpenAndCleared = widget.suggestionPopup.isAttached(); } for (FilterSelectSuggestion suggestion : newSuggestions) { - getWidget().currentSuggestions.add(suggestion); + widget.currentSuggestions.add(suggestion); } } @@ -175,7 +176,7 @@ public class ComboBoxConnector extends AbstractFieldConnector // In case we're switching page no need to update the selection as the // selection process didn't finish. - // && getWidget().selectPopupItemWhenResponseIsReceived == + // && widget.selectPopupItemWhenResponseIsReceived == // VFilterSelect.Select.NONE // ) { @@ -190,32 +191,31 @@ public class ComboBoxConnector extends AbstractFieldConnector performSelection(selectedKeys[0]); // if selected key is available, assume caption is know based on // it as well and clear selected caption - getWidget().setSelectedCaption(null); + widget.setSelectedCaption(null); - } else if (!getWidget().waitingForFilteringResponse + } else if (!widget.waitingForFilteringResponse && uidl.hasAttribute("selectedCaption")) { // scrolling to correct page is disabled, caption is passed as a // special parameter - getWidget().setSelectedCaption( + widget.setSelectedCaption( uidl.getStringAttribute("selectedCaption")); } else { resetSelection(); } } - if ((getWidget().waitingForFilteringResponse - && getWidget().lastFilter.toLowerCase(Locale.ROOT) + if ((widget.waitingForFilteringResponse + && widget.lastFilter.toLowerCase(Locale.ROOT) .equals(uidl.getStringVariable("filter"))) || popupOpenAndCleared) { - getWidget().suggestionPopup.showSuggestions( - getWidget().currentSuggestions, getWidget().currentPage, - getWidget().totalMatches); + widget.suggestionPopup.showSuggestions(widget.currentSuggestions, + widget.currentPage, widget.totalMatches); - getWidget().waitingForFilteringResponse = false; + widget.waitingForFilteringResponse = false; - if (!getWidget().popupOpenerClicked - && getWidget().selectPopupItemWhenResponseIsReceived != VFilterSelect.Select.NONE) { + if (!widget.popupOpenerClicked + && widget.selectPopupItemWhenResponseIsReceived != VFilterSelect.Select.NONE) { // we're paging w/ arrows Scheduler.get().scheduleDeferred(new ScheduledCommand() { @@ -226,32 +226,32 @@ public class ComboBoxConnector extends AbstractFieldConnector }); } - if (getWidget().updateSelectionWhenReponseIsReceived) { - getWidget().suggestionPopup.menu + if (widget.updateSelectionWhenReponseIsReceived) { + widget.suggestionPopup.menu .doPostFilterSelectedItemAction(); } } // Calculate minimum textarea width - getWidget().updateSuggestionPopupMinWidth(); + widget.updateSuggestionPopupMinWidth(); - getWidget().popupOpenerClicked = false; + widget.popupOpenerClicked = false; /* * if this is our first time we need to recalculate the root width. */ - if (!getWidget().initDone) { + if (!widget.initDone) { - getWidget().updateRootWidth(); + widget.updateRootWidth(); } // Focus dependent style names are lost during the update, so we add // them here back again - if (getWidget().focused) { - getWidget().addStyleDependentName("focus"); + if (widget.focused) { + widget.addStyleDependentName("focus"); } - getWidget().initDone = true; + widget.initDone = true; } /* @@ -277,30 +277,31 @@ public class ComboBoxConnector extends AbstractFieldConnector } private void performSelection(String selectedKey) { + VFilterSelect widget = getWidget(); // some item selected - for (FilterSelectSuggestion suggestion : getWidget().currentSuggestions) { + for (FilterSelectSuggestion suggestion : widget.currentSuggestions) { String suggestionKey = suggestion.getOptionKey(); if (!suggestionKey.equals(selectedKey)) { continue; } - if (!getWidget().waitingForFilteringResponse - || getWidget().popupOpenerClicked) { - if (!suggestionKey.equals(getWidget().selectedOptionKey) + if (!widget.waitingForFilteringResponse + || widget.popupOpenerClicked) { + if (!suggestionKey.equals(widget.selectedOptionKey) || suggestion.getReplacementString() - .equals(getWidget().tb.getText()) + .equals(widget.tb.getText()) || oldSuggestionTextMatchTheOldSelection) { // Update text field if we've got a new // selection // Also update if we've got the same text to // retain old text selection behavior // OR if selected item caption is changed. - getWidget() + widget .setPromptingOff(suggestion.getReplacementString()); - getWidget().selectedOptionKey = suggestionKey; + widget.selectedOptionKey = suggestionKey; } } - getWidget().currentSuggestion = suggestion; - getWidget().setSelectedItemIcon(suggestion.getIconUri()); + widget.currentSuggestion = suggestion; + widget.setSelectedItemIcon(suggestion.getIconUri()); // only a single item can be selected break; } @@ -313,41 +314,39 @@ public class ComboBoxConnector extends AbstractFieldConnector } private void resetSelection() { - if (!getWidget().waitingForFilteringResponse - || getWidget().popupOpenerClicked) { + VFilterSelect widget = getWidget(); + if (!widget.waitingForFilteringResponse || widget.popupOpenerClicked) { // select nulled - if (!getWidget().focused) { + if (!widget.focused) { /* * client.updateComponent overwrites all styles so we must * ALWAYS set the prompting style at this point, even though we * think it has been set already... */ - getWidget().setPromptingOff(""); - if (getWidget().enabled && !getWidget().readonly) { - getWidget().setPromptingOn(); + widget.setPromptingOff(""); + if (widget.enabled && !widget.readonly) { + widget.setPromptingOn(); } } else { // we have focus in field, prompting can't be set on, instead // just clear the input if the value has changed from something // else to null - if (getWidget().selectedOptionKey != null - || (getWidget().allowNewItem - && !getWidget().tb.getValue().isEmpty())) { + if (widget.selectedOptionKey != null || (widget.allowNewItem + && !widget.tb.getValue().isEmpty())) { - boolean openedPopupWithNonScrollingMode = (getWidget().popupOpenerClicked - && getWidget().getSelectedCaption() != null); + boolean openedPopupWithNonScrollingMode = (widget.popupOpenerClicked + && widget.getSelectedCaption() != null); if (!openedPopupWithNonScrollingMode) { - getWidget().tb.setValue(""); + widget.tb.setValue(""); } else { - getWidget().tb - .setValue(getWidget().getSelectedCaption()); - getWidget().tb.selectAll(); + widget.tb.setValue(widget.getSelectedCaption()); + widget.tb.selectAll(); } } } - getWidget().currentSuggestion = null; // #13217 - getWidget().setSelectedItemIcon(null); - getWidget().selectedOptionKey = null; + widget.currentSuggestion = null; // #13217 + widget.setSelectedItemIcon(null); + widget.selectedOptionKey = null; } } diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/datefield/DateFieldConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/datefield/DateFieldConnector.java index 746af3043d..3266c8aa05 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/datefield/DateFieldConnector.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/datefield/DateFieldConnector.java @@ -70,67 +70,66 @@ public class DateFieldConnector extends TextualDateConnector { @SuppressWarnings("deprecation") public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { - String oldLocale = getWidget().getCurrentLocale(); + VPopupCalendar widget = getWidget(); + String oldLocale = widget.getCurrentLocale(); - getWidget().parsable = uidl.getBooleanAttribute("parsable"); + widget.parsable = uidl.getBooleanAttribute("parsable"); super.updateFromUIDL(uidl, client); - getWidget().calendar - .setDateTimeService(getWidget().getDateTimeService()); - getWidget().calendar - .setShowISOWeekNumbers(getWidget().isShowISOWeekNumbers()); - if (getWidget().calendar.getResolution() != getWidget() + widget.calendar.setDateTimeService(widget.getDateTimeService()); + widget.calendar + .setShowISOWeekNumbers(widget.isShowISOWeekNumbers()); + if (widget.calendar.getResolution() != widget .getCurrentResolution()) { boolean hasSelectedDate = false; - getWidget().calendar - .setResolution(getWidget().getCurrentResolution()); - if (getWidget().calendar.getDate() != null - && getWidget().getCurrentDate() != null) { + widget.calendar.setResolution(widget.getCurrentResolution()); + if (widget.calendar.getDate() != null + && widget.getCurrentDate() != null) { hasSelectedDate = true; - getWidget().calendar - .setDate((Date) getWidget().getCurrentDate().clone()); + widget.calendar + .setDate((Date) widget.getCurrentDate().clone()); } // force re-render when changing resolution only - getWidget().calendar.renderCalendar(hasSelectedDate); + widget.calendar.renderCalendar(hasSelectedDate); } // Force re-render of calendar if locale has changed (#12153) - if (!getWidget().getCurrentLocale().equals(oldLocale)) { - getWidget().calendar.renderCalendar(); + if (!widget.getCurrentLocale().equals(oldLocale)) { + widget.calendar.renderCalendar(); } - if (getWidget().getCurrentResolution() + if (widget.getCurrentResolution() .getCalendarField() <= Resolution.MONTH.getCalendarField()) { - getWidget().calendar + widget.calendar .setFocusChangeListener(new FocusChangeListener() { @Override public void focusChanged(Date date) { - getWidget().updateValue(date); - getWidget().buildDate(); - Date date2 = getWidget().calendar.getDate(); + widget.updateValue(date); + widget.buildDate(); + Date date2 = widget.calendar.getDate(); date2.setYear(date.getYear()); date2.setMonth(date.getMonth()); } }); } else { - getWidget().calendar.setFocusChangeListener(null); + widget.calendar.setFocusChangeListener(null); } - if (getWidget().getCurrentResolution() + if (widget.getCurrentResolution() .getCalendarField() > Resolution.DAY.getCalendarField()) { - getWidget().calendar + widget.calendar .setTimeChangeListener(new TimeChangeListener() { @Override public void changed(int hour, int min, int sec, int msec) { - Date d = getWidget().getDate(); + Date d = widget.getDate(); if (d == null) { // date currently null, use the value from // calendarPanel // (~ client time at the init of the widget) - d = (Date) getWidget().calendar.getDate() + d = (Date) widget.calendar.getDate() .clone(); } d.setHours(hour); @@ -139,26 +138,26 @@ public class DateFieldConnector extends TextualDateConnector { DateTimeService.setMilliseconds(d, msec); // Always update time changes to the server - getWidget().updateValue(d); + widget.updateValue(d); // Update text field - getWidget().buildDate(); + widget.buildDate(); } }); } - if (getWidget().isReadonly()) { - getWidget().calendarToggle.addStyleName( + if (widget.isReadonly()) { + widget.calendarToggle.addStyleName( VPopupCalendar.CLASSNAME + "-button-readonly"); } else { - getWidget().calendarToggle.removeStyleName( + widget.calendarToggle.removeStyleName( VPopupCalendar.CLASSNAME + "-button-readonly"); } - getWidget().setDescriptionForAssistiveDevices( + widget.setDescriptionForAssistiveDevices( getState().descriptionForAssistiveDevices); - getWidget().setTextFieldTabIndex(); + widget.setTextFieldTabIndex(); } @Override diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/datefield/InlineDateFieldConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/datefield/InlineDateFieldConnector.java index ddf72a0705..080b3d69fe 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/datefield/InlineDateFieldConnector.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/datefield/InlineDateFieldConnector.java @@ -22,6 +22,7 @@ import com.vaadin.client.DateTimeService; import com.vaadin.client.UIDL; import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.shared.ui.Connect; +import com.vaadin.v7.client.ui.VCalendarPanel; import com.vaadin.v7.client.ui.VCalendarPanel.FocusChangeListener; import com.vaadin.v7.client.ui.VCalendarPanel.TimeChangeListener; import com.vaadin.v7.client.ui.VDateFieldCalendar; @@ -40,32 +41,31 @@ public class InlineDateFieldConnector extends AbstractDateFieldConnector { return; } - getWidget().calendarPanel - .setShowISOWeekNumbers(getWidget().isShowISOWeekNumbers()); - getWidget().calendarPanel - .setDateTimeService(getWidget().getDateTimeService()); - getWidget().calendarPanel - .setResolution(getWidget().getCurrentResolution()); - Date currentDate = getWidget().getCurrentDate(); + VDateFieldCalendar calendar = getWidget(); + VCalendarPanel panel = calendar.calendarPanel; + panel.setShowISOWeekNumbers(calendar.isShowISOWeekNumbers()); + panel.setDateTimeService(calendar.getDateTimeService()); + panel.setResolution(calendar.getCurrentResolution()); + Date currentDate = calendar.getCurrentDate(); if (currentDate != null) { - getWidget().calendarPanel.setDate(new Date(currentDate.getTime())); + panel.setDate(new Date(currentDate.getTime())); } else { - getWidget().calendarPanel.setDate(null); + panel.setDate(null); } - if (getWidget().getCurrentResolution() + if (calendar.getCurrentResolution() .getCalendarField() > Resolution.DAY.getCalendarField()) { - getWidget().calendarPanel + panel .setTimeChangeListener(new TimeChangeListener() { @Override public void changed(int hour, int min, int sec, int msec) { - Date d = getWidget().getDate(); + Date d = calendar.getDate(); if (d == null) { // date currently null, use the value from // calendarPanel // (~ client time at the init of the widget) - d = (Date) getWidget().calendarPanel.getDate() + d = (Date) panel.getDate() .clone(); } d.setHours(hour); @@ -74,21 +74,21 @@ public class InlineDateFieldConnector extends AbstractDateFieldConnector { DateTimeService.setMilliseconds(d, msec); // Always update time changes to the server - getWidget().calendarPanel.setDate(d); - getWidget().updateValueFromPanel(); + panel.setDate(d); + calendar.updateValueFromPanel(); } }); } - if (getWidget().getCurrentResolution() + if (calendar.getCurrentResolution() .getCalendarField() <= Resolution.MONTH.getCalendarField()) { - getWidget().calendarPanel + panel .setFocusChangeListener(new FocusChangeListener() { @Override public void focusChanged(Date date) { Date date2 = new Date(); - if (getWidget().calendarPanel.getDate() != null) { - date2.setTime(getWidget().calendarPanel + if (panel.getDate() != null) { + date2.setTime(panel .getDate().getTime()); } /* @@ -96,19 +96,19 @@ public class InlineDateFieldConnector extends AbstractDateFieldConnector { */ date2.setYear(date.getYear()); date2.setMonth(date.getMonth()); - getWidget().calendarPanel.setDate(date2); + panel.setDate(date2); /* * Then update the value from panel to server */ - getWidget().updateValueFromPanel(); + calendar.updateValueFromPanel(); } }); } else { - getWidget().calendarPanel.setFocusChangeListener(null); + panel.setFocusChangeListener(null); } // Update possible changes - getWidget().calendarPanel.renderCalendar(); + panel.renderCalendar(); } @Override diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/datefield/TextualDateConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/datefield/TextualDateConnector.java index a41fca521f..52a57552c1 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/datefield/TextualDateConnector.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/datefield/TextualDateConnector.java @@ -26,33 +26,33 @@ public class TextualDateConnector extends AbstractDateFieldConnector { @Override public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { - Resolution origRes = getWidget().getCurrentResolution(); - String oldLocale = getWidget().getCurrentLocale(); + VTextualDate date = getWidget(); + Resolution origRes = date.getCurrentResolution(); + String oldLocale = date.getCurrentLocale(); super.updateFromUIDL(uidl, client); - if (origRes != getWidget().getCurrentResolution() - || oldLocale != getWidget().getCurrentLocale()) { + if (origRes != date.getCurrentResolution() + || oldLocale != date.getCurrentLocale()) { // force recreating format string - getWidget().formatStr = null; + date.formatStr = null; } if (uidl.hasAttribute("format")) { - getWidget().formatStr = uidl.getStringAttribute("format"); + date.formatStr = uidl.getStringAttribute("format"); } - getWidget().inputPrompt = uidl + date.inputPrompt = uidl .getStringAttribute(VTextualDate.ATTR_INPUTPROMPT); - getWidget().lenient = !uidl.getBooleanAttribute("strict"); + date.lenient = !uidl.getBooleanAttribute("strict"); - getWidget().buildDate(); + date.buildDate(); // not a FocusWidget -> needs own tabindex handling - getWidget().text.setTabIndex(getState().tabIndex); + date.text.setTabIndex(getState().tabIndex); - if (getWidget().isReadonly()) { - getWidget().text.addStyleDependentName("readonly"); + if (date.isReadonly()) { + date.text.addStyleDependentName("readonly"); } else { - getWidget().text.removeStyleDependentName("readonly"); + date.text.removeStyleDependentName("readonly"); } - } @Override diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/form/FormConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/form/FormConnector.java index ab28118c66..661d729f07 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/form/FormConnector.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/form/FormConnector.java @@ -95,8 +95,9 @@ public class FormConnector extends AbstractComponentContainerConnector @Override public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { - getWidget().client = client; - getWidget().id = uidl.getId(); + VForm form = getWidget(); + form.client = client; + form.id = uidl.getId(); if (!isRealUpdate(uidl)) { return; @@ -104,67 +105,67 @@ public class FormConnector extends AbstractComponentContainerConnector boolean legendEmpty = true; if (getState().caption != null) { - VCaption.setCaptionText(getWidget().caption, getState()); + VCaption.setCaptionText(form.caption, getState()); legendEmpty = false; } else { - getWidget().caption.setInnerText(""); + form.caption.setInnerText(""); } - if (getWidget().icon != null) { - getWidget().legend.removeChild(getWidget().icon.getElement()); + if (form.icon != null) { + form.legend.removeChild(form.icon.getElement()); } if (getIconUri() != null) { - getWidget().icon = client.getIcon(getIconUri()); - getWidget().legend.insertFirst(getWidget().icon.getElement()); + form.icon = client.getIcon(getIconUri()); + form.legend.insertFirst(form.icon.getElement()); legendEmpty = false; } if (legendEmpty) { - getWidget().addStyleDependentName("nocaption"); + form.addStyleDependentName("nocaption"); } else { - getWidget().removeStyleDependentName("nocaption"); + form.removeStyleDependentName("nocaption"); } if (null != getState().errorMessage) { - getWidget().errorMessage.updateMessage(getState().errorMessage); - getWidget().errorMessage.updateErrorLevel(getState().errorLevel); - getWidget().errorMessage.setVisible(true); + form.errorMessage.updateMessage(getState().errorMessage); + form.errorMessage.updateErrorLevel(getState().errorLevel); + form.errorMessage.setVisible(true); } else { - getWidget().errorMessage.setVisible(false); + form.errorMessage.setVisible(false); } if (ComponentStateUtil.hasDescription(getState())) { - getWidget().desc.setInnerHTML(getState().description); - if (getWidget().desc.getParentElement() == null) { - getWidget().fieldSet.insertAfter(getWidget().desc, - getWidget().legend); + form.desc.setInnerHTML(getState().description); + if (form.desc.getParentElement() == null) { + form.fieldSet.insertAfter(form.desc, + form.legend); } } else { - getWidget().desc.setInnerHTML(""); - if (getWidget().desc.getParentElement() != null) { - getWidget().fieldSet.removeChild(getWidget().desc); + form.desc.setInnerHTML(""); + if (form.desc.getParentElement() != null) { + form.fieldSet.removeChild(form.desc); } } // also recalculates size of the footer if undefined size form - see // #3710 - client.runDescendentsLayout(getWidget()); + client.runDescendentsLayout(form); // We may have actions attached if (uidl.getChildCount() >= 1) { UIDL childUidl = uidl.getChildByTagName("actions"); if (childUidl != null) { - if (getWidget().shortcutHandler == null) { - getWidget().shortcutHandler = new ShortcutActionHandler( + if (form.shortcutHandler == null) { + form.shortcutHandler = new ShortcutActionHandler( getConnectorId(), client); - getWidget().keyDownRegistration = getWidget() - .addDomHandler(getWidget(), KeyDownEvent.getType()); + form.keyDownRegistration = form + .addDomHandler(form, KeyDownEvent.getType()); } - getWidget().shortcutHandler.updateActionMap(childUidl); + form.shortcutHandler.updateActionMap(childUidl); } - } else if (getWidget().shortcutHandler != null) { - getWidget().keyDownRegistration.removeHandler(); - getWidget().shortcutHandler = null; - getWidget().keyDownRegistration = null; + } else if (form.shortcutHandler != null) { + form.keyDownRegistration.removeHandler(); + form.shortcutHandler = null; + form.keyDownRegistration = null; } } diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/label/LabelConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/label/LabelConnector.java index 9ef43775bf..0527cbe4fa 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/label/LabelConnector.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/label/LabelConnector.java @@ -40,28 +40,29 @@ public class LabelConnector extends AbstractLegacyComponentConnector { super.onStateChanged(stateChangeEvent); boolean sinkOnloads = false; Profiler.enter("LabelConnector.onStateChanged update content"); + VLabel widget = getWidget(); switch (getState().contentMode) { case PREFORMATTED: PreElement preElement = Document.get().createPreElement(); preElement.setInnerText(getState().text); // clear existing content - getWidget().setHTML(""); + widget.setHTML(""); // add preformatted text to dom - getWidget().getElement().appendChild(preElement); + widget.getElement().appendChild(preElement); break; case TEXT: - getWidget().setText(getState().text); + widget.setText(getState().text); break; case HTML: case RAW: sinkOnloads = true; case XML: - getWidget().setHTML(getState().text); + widget.setHTML(getState().text); break; default: - getWidget().setText(""); + widget.setText(""); break; } @@ -69,7 +70,7 @@ public class LabelConnector extends AbstractLegacyComponentConnector { if (sinkOnloads) { Profiler.enter("LabelConnector.onStateChanged sinkOnloads"); - WidgetUtil.sinkOnloadForImages(getWidget().getElement()); + WidgetUtil.sinkOnloadForImages(widget.getElement()); Profiler.leave("LabelConnector.onStateChanged sinkOnloads"); } } diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/textfield/TextFieldConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/textfield/TextFieldConnector.java index 15037d4b50..480e0f7d0a 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/textfield/TextFieldConnector.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/textfield/TextFieldConnector.java @@ -42,40 +42,41 @@ public class TextFieldConnector extends AbstractFieldConnector @Override public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { + VTextField textField = getWidget(); // Save details - getWidget().client = client; - getWidget().paintableId = uidl.getId(); + textField.client = client; + textField.paintableId = uidl.getId(); if (!isRealUpdate(uidl)) { return; } - getWidget().setReadOnly(isReadOnly()); + textField.setReadOnly(isReadOnly()); - getWidget().setInputPrompt(getState().inputPrompt); - getWidget().setMaxLength(getState().maxLength); - getWidget().setImmediate(getState().immediate); + textField.setInputPrompt(getState().inputPrompt); + textField.setMaxLength(getState().maxLength); + textField.setImmediate(getState().immediate); - getWidget().listenTextChangeEvents = hasEventListener("ie"); - if (getWidget().listenTextChangeEvents) { - getWidget().textChangeEventMode = uidl.getStringAttribute( + textField.listenTextChangeEvents = hasEventListener("ie"); + if (textField.listenTextChangeEvents) { + textField.textChangeEventMode = uidl.getStringAttribute( TextFieldConstants.ATTR_TEXTCHANGE_EVENTMODE); - if (getWidget().textChangeEventMode + if (textField.textChangeEventMode .equals(TextFieldConstants.TEXTCHANGE_MODE_EAGER)) { - getWidget().textChangeEventTimeout = 1; + textField.textChangeEventTimeout = 1; } else { - getWidget().textChangeEventTimeout = uidl.getIntAttribute( + textField.textChangeEventTimeout = uidl.getIntAttribute( TextFieldConstants.ATTR_TEXTCHANGE_TIMEOUT); - if (getWidget().textChangeEventTimeout < 1) { + if (textField.textChangeEventTimeout < 1) { // Sanitize and allow lazy/timeout with timeout set to 0 to // work as eager - getWidget().textChangeEventTimeout = 1; + textField.textChangeEventTimeout = 1; } } - getWidget().sinkEvents(VTextField.TEXTCHANGE_EVENTS); - getWidget().attachCutEventListener(getWidget().getElement()); + textField.sinkEvents(VTextField.TEXTCHANGE_EVENTS); + textField.attachCutEventListener(textField.getElement()); } - getWidget().setColumns(getState().columns); + textField.setColumns(getState().columns); String text = getState().text; if (text == null) { @@ -88,12 +89,12 @@ public class TextFieldConnector extends AbstractFieldConnector * side value). <input> is updated only when it looses focus, so we * force updating if not focused. Lost focus issue appeared in (#15144) */ - if (Util.getFocusedElement() != getWidget().getElement() + if (Util.getFocusedElement() != textField.getElement() || !uidl.getBooleanAttribute( TextFieldConstants.ATTR_NO_VALUE_CHANGE_BETWEEN_PAINTS) - || getWidget().valueBeforeEdit == null - || !text.equals(getWidget().valueBeforeEdit)) { - getWidget().updateFieldContent(text); + || textField.valueBeforeEdit == null + || !text.equals(textField.valueBeforeEdit)) { + textField.updateFieldContent(text); } if (uidl.hasAttribute("selpos")) { @@ -105,7 +106,7 @@ public class TextFieldConnector extends AbstractFieldConnector Scheduler.get().scheduleDeferred(new Command() { @Override public void execute() { - getWidget().setSelectionRange(pos, length); + textField.setSelectionRange(pos, length); } }); } diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/upload/UploadConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/upload/UploadConnector.java index eefbe60a1a..ab09bb69f2 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/upload/UploadConnector.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/upload/UploadConnector.java @@ -63,32 +63,33 @@ public class UploadConnector extends AbstractLegacyComponentConnector if (!isRealUpdate(uidl)) { return; } + VUpload upload = getWidget(); if (uidl.hasAttribute("notStarted")) { - getWidget().t.schedule(400); + upload.t.schedule(400); return; } - getWidget().setImmediate(getState().immediate); - getWidget().client = client; - getWidget().paintableId = uidl.getId(); - getWidget().nextUploadId = uidl.getIntAttribute("nextid"); + upload.setImmediate(getState().immediate); + upload.client = client; + upload.paintableId = uidl.getId(); + upload.nextUploadId = uidl.getIntAttribute("nextid"); final String action = client .translateVaadinUri(uidl.getStringVariable("action")); - getWidget().element.setAction(action); + upload.element.setAction(action); if (uidl.hasAttribute("buttoncaption")) { - getWidget().submitButton + upload.submitButton .setText(uidl.getStringAttribute("buttoncaption")); - getWidget().submitButton.setVisible(true); + upload.submitButton.setVisible(true); } else { - getWidget().submitButton.setVisible(false); + upload.submitButton.setVisible(false); } - getWidget().fu.setName(getWidget().paintableId + "_file"); + upload.fu.setName(upload.paintableId + "_file"); if (!isEnabled() || isReadOnly()) { - getWidget().disableUpload(); + upload.disableUpload(); } else if (!uidl.getBooleanAttribute("state")) { // Enable the button only if an upload is not in progress - getWidget().enableUpload(); - getWidget().ensureTargetFrame(); + upload.enableUpload(); + upload.ensureTargetFrame(); } } diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/ResizeTerrorizerControlConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/ResizeTerrorizerControlConnector.java index 4a4bb58488..068896f323 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/ResizeTerrorizerControlConnector.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/ResizeTerrorizerControlConnector.java @@ -244,17 +244,18 @@ public class ResizeTerrorizerControlConnector extends AbstractComponentConnector @Override public void postLayout() { - if (getWidget().startWidth.getValue() == null) { + ResizeTerrorizerControlPanel panel = getWidget(); + if (panel.startWidth.getValue() == null) { int width = getTarget().getWidget().getElement().getOffsetWidth(); - getWidget().startWidth.setValue(width); - getWidget().endWidth + panel.startWidth.setValue(width); + panel.endWidth .setValue(width + getState().defaultWidthOffset); } - if (getWidget().startHeight.getValue() == null) { + if (panel.startHeight.getValue() == null) { int height = getTarget().getWidget().getElement().getOffsetHeight(); - getWidget().startHeight.setValue(height); - getWidget().endHeight + panel.startHeight.setValue(height); + panel.endHeight .setValue(height + getState().defaultHeightOffset); } } |