com.vaadin.client.UIDL Java Examples

The following examples show how to use com.vaadin.client.UIDL. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ViewComponentClientCriterionTest.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
@Test
@Description("Verifies that drag source is valid for the configured prefix")
public void checkDragSourceWithValidId() {
    final ViewComponentClientCriterion cut = new ViewComponentClientCriterion();

    // prepare drag-event:
    final String prefix = "this";
    final String id = "thisId";
    final VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent(id);

    // prepare configuration:
    final UIDL uidl = GWT.create(UIDL.class);
    when(uidl.getStringAttribute("ds")).thenReturn(prefix);

    // act
    final boolean result = cut.isValidDragSource(dragEvent, uidl);

    // assure that drag source is valid: [thisId startsWith this]
    assertThat(result).as("Expected: [" + id + " startsWith " + prefix + "].").isTrue();
}
 
Example #2
Source File: CubaTextFieldConnector.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    // We may have actions attached to this text field
    if (uidl.getChildCount() > 0) {
        final int cnt = uidl.getChildCount();
        for (int i = 0; i < cnt; i++) {
            UIDL childUidl = uidl.getChildUIDL(i);
            if (childUidl.getTag().equals("actions")) {
                if (getWidget().getShortcutActionHandler() == null) {
                    getWidget().setShortcutActionHandler(new ShortcutActionHandler(uidl.getId(), client));
                }
                getWidget().getShortcutActionHandler().updateActionMap(childUidl);
            }
        }
    }
}
 
Example #3
Source File: CubaMaskedFieldConnector.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    // We may have actions attached to this text field
    if (uidl.getChildCount() > 0) {
        final int cnt = uidl.getChildCount();
        for (int i = 0; i < cnt; i++) {
            UIDL childUidl = uidl.getChildUIDL(i);
            if (childUidl.getTag().equals("actions")) {
                if (getWidget().getShortcutActionHandler() == null) {
                    getWidget().setShortcutActionHandler(new ShortcutActionHandler(uidl.getId(), client));
                }
                getWidget().getShortcutActionHandler().updateActionMap(childUidl);
            }
        }
    }
}
 
Example #4
Source File: CubaComboBoxConnector.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    // We may have actions attached to this text field
    if (uidl.getChildCount() > 0) {
        final int cnt = uidl.getChildCount();
        for (int i = 0; i < cnt; i++) {
            UIDL childUidl = uidl.getChildUIDL(i);
            if (childUidl.getTag().equals("actions")) {
                if (getWidget().getShortcutActionHandler() == null) {
                    getWidget().setShortcutActionHandler(new ShortcutActionHandler(uidl.getId(), client));
                }
                getWidget().getShortcutActionHandler().updateActionMap(childUidl);
            }
        }
    }
}
 
Example #5
Source File: ItemIdClientCriterion.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
@Override
// Exception squid:S1166 - Hide origin exception
// Exception squid:S2221 - This code is trans-coded to JavaScript, hence
// Exception semantics changes
@SuppressWarnings({ "squid:S1166", "squid:S2221" })
protected boolean accept(VDragEvent drag, UIDL configuration) {
    try {

        String component = drag.getTransferable().getDragSource().getWidget().getElement().getId();
        int c = configuration.getIntAttribute(COMPONENT_COUNT);
        String mode = configuration.getStringAttribute(MODE);
        for (int dragSourceIndex = 0; dragSourceIndex < c; dragSourceIndex++) {
            String requiredPid = configuration.getStringAttribute(COMPONENT + dragSourceIndex);
            if ((STRICT_MODE.equals(mode) && component.equals(requiredPid))
                    || (PREFIX_MODE.equals(mode) && component.startsWith(requiredPid))) {
                return true;
            }

        }
    } catch (Exception e) {
        // log and continue
        LOGGER.log(Level.SEVERE, "Error verifying drop target: " + e.getLocalizedMessage());
    }
    return false;
}
 
Example #6
Source File: ViewClientCriterion.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Hides the highlighted drop target hints.
 *
 * @param configuration
 *            for the accept criterion to retrieve the drop target hints.
 */
// Exception squid:S1166 - Hide origin exception
// Exception squid:S2221 - This code is trans-coded to JavaScript, hence
// Exception semantics changes
@SuppressWarnings({ "squid:S1166", "squid:S2221" })
void hideDropTargetHints(final UIDL configuration) {
    final int totalDropTargetHintsCount = configuration.getIntAttribute(DROP_AREA_CONFIG_COUNT);
    for (int dropAreaIndex = 0; dropAreaIndex < totalDropTargetHintsCount; dropAreaIndex++) {
        try {
            final String dropArea = configuration.getStringAttribute(DROP_AREA_CONFIG + dropAreaIndex);
            final Element hideHintFor = Document.get().getElementById(dropArea);
            if (hideHintFor != null) {
                hideHintFor.removeClassName(ViewComponentClientCriterion.HINT_AREA_STYLE);
            }
        } catch (final Exception e) {
            // log and continue
            LOGGER.log(Level.SEVERE, "Error highlighting valid drop targets: " + e.getLocalizedMessage());
        }
    }
}
 
Example #7
Source File: ViewComponentClientCriterion.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Checks if this accept criterion is responsible for the current drag
 * source. Therefore the current drag source id has to start with the drag
 * source id-prefix configured for the criterion.
 *
 * @param drag
 *            the current drag event holding the context.
 * @param configuration
 *            for the accept criterion to retrieve the configured drag
 *            source id-prefix.
 * @return <code>true</code> if the criterion is responsible for the current
 *         drag source, otherwise <code>false</code>.
 */
// Exception squid:S1166 - Hide origin exception
// Exception squid:S2221 - This code is trans-coded to JavaScript, hence
// Exception semantics changes
@SuppressWarnings({ "squid:S1166", "squid:S2221" })
boolean isValidDragSource(final VDragEvent drag, final UIDL configuration) {
    try {
        final String dragSource = drag.getTransferable().getDragSource().getWidget().getElement().getId();
        final String dragSourcePrefix = configuration.getStringAttribute(DRAG_SOURCE);
        if (dragSource.startsWith(dragSourcePrefix)) {
            return true;
        }
    } catch (final Exception e) {
        // log and continue
        LOGGER.log(Level.SEVERE, "Error verifying drag source: " + e.getLocalizedMessage());
    }

    return false;
}
 
Example #8
Source File: ViewComponentClientCriterion.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Highlights the valid drop targets configured for the criterion.
 *
 * @param configuration
 *            for the accept criterion to retrieve the configured drop hint
 *            areas.
 */
// Exception squid:S1166 - Hide origin exception
// Exception squid:S2221 - This code is trans-coded to JavaScript, hence
// Exception semantics changes
// Exception squid:S2629 - not supported by GWT
@SuppressWarnings({ "squid:S1166", "squid:S2221", "squid:S2629" })
void showDropTargetHints(final UIDL configuration) {
    final int dropAreaCount = configuration.getIntAttribute(DROP_AREA_COUNT);
    for (int dropAreaIndex = 0; dropAreaIndex < dropAreaCount; dropAreaIndex++) {
        try {
            final String dropArea = configuration.getStringAttribute(DROP_AREA + dropAreaIndex);
            LOGGER.log(Level.FINE, "Hint Area: " + dropArea);

            final Element showHintFor = Document.get().getElementById(dropArea);
            if (showHintFor != null) {
                showHintFor.addClassName(HINT_AREA_STYLE);
            }
        } catch (final Exception e) {
            // log and continue
            LOGGER.log(Level.SEVERE, "Error highlighting drop targets: " + e.getLocalizedMessage());
        }
    }

}
 
Example #9
Source File: ViewComponentClientCriterion.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Checks if the current drop location is a valid drop target for the
 * criterion. Therefore the current drop location id has to start with one
 * of the drop target id-prefixes configured for the criterion.
 *
 * @param configuration
 *            for the accept criterion to retrieve the configured drop
 *            target id-prefixes.
 * @return <code>true</code> if the current drop location is a valid drop
 *         target for the criterion, otherwise <code>false</code>.
 */
// Exception squid:S1166 - Hide origin exception
// Exception squid:S2221 - This code is trans-coded to JavaScript, hence
// Exception semantics changes
// Exception squid:S2629 - not supported by GWT
@SuppressWarnings({ "squid:S1166", "squid:S2221", "squid:S2629" })
boolean isValidDropTarget(final UIDL configuration) {
    try {
        final String dropTarget = VDragAndDropManager.get().getCurrentDropHandler().getConnector().getWidget()
                .getElement().getId();
        final int dropTargetCount = configuration.getIntAttribute(DROP_TARGET_COUNT);
        for (int dropTargetIndex = 0; dropTargetIndex < dropTargetCount; dropTargetIndex++) {
            final String dropTargetPrefix = configuration.getStringAttribute(DROP_TARGET + dropTargetIndex);
            LOGGER.log(Level.FINE, "Drop Target: " + dropTargetPrefix);
            if (dropTarget.startsWith(dropTargetPrefix)) {
                return true;
            }
        }
    } catch (final Exception e) {
        // log and continue
        LOGGER.log(Level.SEVERE, "Error verifying drop target: " + e.getLocalizedMessage());
    }
    return false;
}
 
Example #10
Source File: ViewComponentClientCriterionTest.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
@Test
@Description("Exception occures when processing serialized data structure for preparing the drop targets to show.")
public void exceptionWhenProcessingDropTargetHintsDataStructure() {
    final ViewComponentClientCriterion cut = new ViewComponentClientCriterion();

    // prepare configuration:
    final Document document = Document.get();
    final UIDL uidl = GWT.create(UIDL.class);
    when(uidl.getIntAttribute("cda")).thenReturn(2);
    when(uidl.getStringAttribute("da0")).thenReturn("no-problem");
    when(uidl.getStringAttribute("da1")).thenReturn("problem-bear");
    doThrow(new RuntimeException()).when(uidl).getStringAttribute("da1");

    // act
    try {
        cut.showDropTargetHints(uidl);
    } catch (final RuntimeException re) {
        fail("Exception is not re-thrown in order to continue with the loop");
    }

    // assure that no-problem was invoked anyway
    verify(document).getElementById("no-problem");

    // cross-check that problem-bear was never invoked
    verify(document, Mockito.times(0)).getElementById("problem-bear");
}
 
Example #11
Source File: CubaUIConnector.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
protected void updateBrowserHistory(UIDL uidl) {
    String lastHistoryOp = uidl.getStringAttribute(CubaUIConstants.LAST_HISTORY_OP);

    History history = Browser.getWindow().getHistory();
    String pageTitle = getState().pageState.title;

    String replace = uidl.getStringAttribute(UIConstants.ATTRIBUTE_REPLACE_STATE);
    String push = uidl.getStringAttribute(UIConstants.ATTRIBUTE_PUSH_STATE);

    if (CubaUIConstants.HISTORY_PUSH_OP.equals(lastHistoryOp)) {
        if (uidl.hasAttribute(UIConstants.ATTRIBUTE_REPLACE_STATE)) {
            history.replaceState(null, pageTitle, replace);
        }
        if (uidl.hasAttribute(UIConstants.ATTRIBUTE_PUSH_STATE)) {
            history.pushState(null, pageTitle, push);
        }
    } else {
        if (uidl.hasAttribute(UIConstants.ATTRIBUTE_PUSH_STATE)) {
            history.pushState(null, pageTitle, push);
        }
        if (uidl.hasAttribute(UIConstants.ATTRIBUTE_REPLACE_STATE)) {
            history.replaceState(null, pageTitle, replace);
        }
    }
}
 
Example #12
Source File: ViewComponentClientCriterionTest.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
@Test
@Description("Verifies that drag source is not valid for the configured prefix")
public void checkDragSourceWithInvalidId() {
    final ViewComponentClientCriterion cut = new ViewComponentClientCriterion();

    // prepare drag-event:
    final String prefix = "this";
    final String id = "notThis";
    final VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent(id);

    // prepare configuration:
    final UIDL uidl = GWT.create(UIDL.class);
    when(uidl.getStringAttribute("ds")).thenReturn(prefix);

    // act
    final boolean result = cut.isValidDragSource(dragEvent, uidl);

    // assure that drag source is valid: [thisId !startsWith this]
    assertThat(result).as("Expected: [" + id + " !startsWith " + prefix + "].").isFalse();
}
 
Example #13
Source File: ViewComponentClientCriterionTest.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
@Test
@Description("Successfully checks if the current drop location is in the list of valid drop targets")
public void successfulCheckValidDropTarget() {
    final ViewComponentClientCriterion cut = new ViewComponentClientCriterion();

    // prepare drag and drop manager:
    final String dtargetid = "dropTarget1Id";
    final VDropHandler dropHandler = CriterionTestHelper.createMockedVDropHandler(dtargetid);
    when(VDragAndDropManager.get().getCurrentDropHandler()).thenReturn(dropHandler);

    // prepare configuration:
    final UIDL uidl = createUidlWithThreeDropTargets();

    // act
    final boolean result = cut.isValidDropTarget(uidl);

    // assure drop target is valid: [dropTarget1Id startsWith dropTarget1]
    assertThat(result).as("Expected: [" + dtargetid + " startsWith dropTarget1].").isTrue();
}
 
Example #14
Source File: ViewComponentClientCriterionTest.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
@Test
@Description("Failed check if the current drop location is in the list of valid drop targets")
public void failedCheckValidDropTarget() {
    final ViewComponentClientCriterion cut = new ViewComponentClientCriterion();

    // prepare drag and drop manager:
    final String dtargetid = "no-hit";
    final VDropHandler dropHandler = CriterionTestHelper.createMockedVDropHandler(dtargetid);
    when(VDragAndDropManager.get().getCurrentDropHandler()).thenReturn(dropHandler);

    // prepare configuration:
    final UIDL uidl = createUidlWithThreeDropTargets();

    // act
    final boolean result = cut.isValidDropTarget(uidl);

    // assure "no-hit" does not match [dropTarget0,dropTarget1,dropTarget2]
    assertThat(result).as("Expected: [" + dtargetid + " does not match one of the list entries].").isFalse();
}
 
Example #15
Source File: ViewComponentClientCriterionTest.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
@Test
@Description("An exception occures while the current drop location is validated against the list of valid drop target prefixes")
public void exceptionWhenCheckingValidDropTarget() {
    final ViewComponentClientCriterion cut = new ViewComponentClientCriterion();

    // prepare drag and drop manager:
    final String dtargetid = "no-hit";
    final VDropHandler dropHandler = CriterionTestHelper.createMockedVDropHandler(dtargetid);
    when(VDragAndDropManager.get().getCurrentDropHandler()).thenReturn(dropHandler);
    doThrow(new RuntimeException()).when(dropHandler).getConnector();

    // prepare configuration:
    final UIDL uidl = createUidlWithThreeDropTargets();

    // act
    Boolean result = null;
    try {
        result = cut.isValidDropTarget(uidl);
    } catch (final Exception ex) {
        fail("Exception is not re-thrown");
    }

    // assure that in case of exception the drop target is declared invalid
    assertThat(result).as("Expected: Invalid drop if exception occures.").isFalse();
}
 
Example #16
Source File: ItemIdClientCriterionTest.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
@Test
@Description("Verifies that drag source is not valid for the configured id (strict mode)")
public void noMatchInStrictMode() {
    final ItemIdClientCriterion cut = new ItemIdClientCriterion();

    // prepare drag-event:
    final String testId = "thisId";
    final VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent(testId);

    // prepare configuration:
    final UIDL uidl = GWT.create(UIDL.class);
    final String configuredId = "component0";
    final String id = "this";
    when(uidl.getStringAttribute(configuredId)).thenReturn(id);
    final String configuredMode = "m";
    final String strictMode = "s";
    when(uidl.getStringAttribute(configuredMode)).thenReturn(strictMode);
    final String count = "c";
    when(uidl.getIntAttribute(count)).thenReturn(1);

    // act
    final boolean result = cut.accept(dragEvent, uidl);

    // verify that in strict mode: [thisId !equals this]
    assertThat(result).as("Expected: [" + id + " !equals " + testId + "].").isFalse();
}
 
Example #17
Source File: ItemIdClientCriterionTest.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
@Test
@Description("Verifies that drag source is valid for the configured id (strict mode)")
public void matchInStrictMode() {
    final ItemIdClientCriterion cut = new ItemIdClientCriterion();

    // prepare drag-event:
    final String testId = "thisId";
    final VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent(testId);

    // prepare configuration:
    final UIDL uidl = GWT.create(UIDL.class);
    final String configuredId = "component0";
    final String id = "thisId";
    when(uidl.getStringAttribute(configuredId)).thenReturn(id);
    final String configuredMode = "m";
    final String strictMode = "s";
    when(uidl.getStringAttribute(configuredMode)).thenReturn(strictMode);
    final String count = "c";
    when(uidl.getIntAttribute(count)).thenReturn(1);

    // act
    final boolean result = cut.accept(dragEvent, uidl);

    // verify that in strict mode: [thisId equals thisId]
    assertThat(result).as("Expected: [" + id + " equals " + testId + "].").isTrue();
}
 
Example #18
Source File: ItemIdClientCriterionTest.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
@Test
@Description("Verifies that drag source is not valid for the configured id (prefix mode)")
public void noMatchInPrefixMode() {
    final ItemIdClientCriterion cut = new ItemIdClientCriterion();

    // prepare drag-event:
    final String testId = "thisId";
    final VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent(testId);

    // prepare configuration:
    final UIDL uidl = GWT.create(UIDL.class);
    final String configuredId = "component0";
    final String prefix = "any";
    when(uidl.getStringAttribute(configuredId)).thenReturn(prefix);
    final String configuredMode = "m";
    final String prefixMode = "p";
    when(uidl.getStringAttribute(configuredMode)).thenReturn(prefixMode);
    final String count = "c";
    when(uidl.getIntAttribute(count)).thenReturn(1);

    // act
    final boolean result = cut.accept(dragEvent, uidl);

    // verify that in strict mode: [thisId !startsWith any]
    assertThat(result).as("Expected: [" + testId + " !startsWith " + prefix + "].").isFalse();
}
 
Example #19
Source File: ItemIdClientCriterionTest.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
@Test
@Description("Verifies that drag source is valid for the configured id (prefix mode)")
public void matchInPrefixMode() {
    final ItemIdClientCriterion cut = new ItemIdClientCriterion();

    // prepare drag-event:
    final String testId = "thisId";
    final VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent(testId);

    // prepare configuration:
    final UIDL uidl = GWT.create(UIDL.class);
    final String configuredId = "component0";
    final String prefix = "this";
    when(uidl.getStringAttribute(configuredId)).thenReturn(prefix);
    final String configuredMode = "m";
    final String prefixMode = "p";
    when(uidl.getStringAttribute(configuredMode)).thenReturn(prefixMode);
    final String count = "c";
    when(uidl.getIntAttribute(count)).thenReturn(1);

    // act
    final boolean result = cut.accept(dragEvent, uidl);

    // verify that in strict mode: [thisId startsWith this]
    assertThat(result).as("Expected: [" + testId + " startsWith " + prefix + "].").isTrue();
}
 
Example #20
Source File: CalendarConnector.java    From calendar-component with Apache License 2.0 6 votes vote down vote up
@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    Iterator<Object> childIterator = uidl.getChildIterator();
    while (childIterator.hasNext()) {
        UIDL child = (UIDL) childIterator.next();
        if (DROPHANDLER_ACCEPT_CRITERIA_PAINT_TAG.equals(child.getTag())) {
            if (getWidget().getDropHandler() == null) {
                getWidget().setDropHandler(showingMonthView()
                        ? new CalendarMonthDropHandler(this)
                        : new CalendarWeekDropHandler(this));
            }
            getWidget().getDropHandler().updateAcceptRules(child);
        } else {
            getWidget().setDropHandler(null);
        }
    }
}
 
Example #21
Source File: CubaGroupTableConnector.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    if (uidl.hasVariable("groupColumns")) {
        getWidget().updateGroupColumns(uidl.getStringArrayVariableAsSet("groupColumns"));
    } else {
        getWidget().updateGroupColumns(null);
    }

    VScrollTable.VScrollTableBody.VScrollTableRow row = getWidget().focusedRow;

    super.updateFromUIDL(uidl, client);

    if (row instanceof CubaGroupTableWidget.CubaGroupTableBody.CubaGroupTableGroupRow) {
        getWidget().setRowFocus(
                getWidget().getRenderedGroupRowByKey(
                        ((CubaGroupTableWidget.CubaGroupTableBody.CubaGroupTableGroupRow) row).getGroupKey()
                )
        );
    }
}
 
Example #22
Source File: ViewComponentClientCriterion.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected boolean accept(final VDragEvent drag, final UIDL configuration) {
    // 1. check if this component is responsible for the drag source:
    if (!isValidDragSource(drag, configuration)) {
        return false;
    }

    // 2. Highlight the valid drop areas
    showDropTargetHints(configuration);

    // 3. Check if the current drop location is a valid drop target
    return isValidDropTarget(configuration);
}
 
Example #23
Source File: CubaTreeTableWidget.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
protected VScrollTableRow createRow(UIDL uidl, char[] aligns2) {
    if (uidl.hasAttribute("gen_html")) {
        // This is a generated row.
        return new VTreeTableGeneratedRow(uidl, aligns2);
    }
    return new CubaTreeTableRow(uidl, aligns2);
}
 
Example #24
Source File: CubaTreeTableWidget.java    From cuba with Apache License 2.0 5 votes vote down vote up
protected void updateAggregationRow(UIDL uidl) {
    if (_delegate.aggregationRow == null) {
        _delegate.aggregationRow = createAggregationRow();
        _delegate.aggregationRow.setTotalAggregationInputHandler(_delegate.totalAggregationInputHandler);
        insert(_delegate.aggregationRow, getWidgetIndex(scrollBodyPanel));
    }
    if (_delegate.isAggregationVisible()) {
        _delegate.aggregationRow.updateFromUIDL(uidl);
        _delegate.aggregationRow.setHorizontalScrollPosition(scrollLeft);

        reassignAggregationColumnWidths();
    }
}
 
Example #25
Source File: CubaOrderedActionsLayoutConnector.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    final int cnt = uidl.getChildCount();
    for (int i = 0; i < cnt; i++) {
        UIDL childUidl = uidl.getChildUIDL(i);
        if (childUidl.getTag().equals("actions")) {
            if (getWidget().getShortcutHandler() == null) {
                getWidget().setShortcutHandler(new ShortcutActionHandler(uidl.getId(), client));
            }
            getWidget().getShortcutHandler().updateActionMap(childUidl);
        }
    }
}
 
Example #26
Source File: CubaGroupTableConnector.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
protected void updateAdditionalRowData(UIDL uidl) {
    super.updateAdditionalRowData(uidl);

    UIDL groupRow = uidl.getChildByTagName("groupRows");
    if (groupRow != null) {
        getWidget().updateGroupRowsWithAggregation(groupRow);
    }
}
 
Example #27
Source File: ViewComponentClientCriterionTest.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
@Test
@Description("Process serialized data structure for preparing the drop targets to show.")
public void processSerializedDropTargetHintsDataStructure() {
    final ViewComponentClientCriterion cut = new ViewComponentClientCriterion();

    // prepare configuration:
    final Document document = Document.get();
    final UIDL uidl = GWT.create(UIDL.class);
    when(uidl.getIntAttribute("cda")).thenReturn(3);
    final Element[] elements = new Element[3];
    for (int i = 0; i < 3; i++) {
        when(uidl.getStringAttribute("da" + String.valueOf(i))).thenReturn("itemId" + String.valueOf(i));
        elements[i] = Mockito.mock(Element.class);
        when(document.getElementById("itemId" + String.valueOf(i))).thenReturn(elements[i]);
    }

    // act
    cut.showDropTargetHints(uidl);

    // assure invocation
    for (int i = 0; i < 3; i++) {
        verify(document).getElementById("itemId" + String.valueOf(i));
        verify(elements[i]).addClassName(ViewComponentClientCriterion.HINT_AREA_STYLE);
    }

    // cross-check
    verify(document, Mockito.times(0)).getElementById("itemId3");

}
 
Example #28
Source File: CubaMainTabSheetConnector.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    VDragDropUtil.updateDropHandlerFromUIDL(uidl, this, new VDDTabsheetDropHandler(this));
    if (getState().ddHtmlEnable) {
        enableDDHtml5();
    }
}
 
Example #29
Source File: ViewComponentClientCriterionTest.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
@Test
@Description("An exception occures while the drag source is validated against the configured prefix")
public void exceptionWhenCheckingDragSource() {

    final ViewComponentClientCriterion cut = new ViewComponentClientCriterion();

    // prepare drag-event:
    final String prefix = "this";
    final String id = "notThis";
    final VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent(id);
    doThrow(new RuntimeException()).when(dragEvent).getTransferable();

    // prepare configuration:
    final UIDL uidl = GWT.create(UIDL.class);
    when(uidl.getStringAttribute("ds")).thenReturn(prefix);

    // act
    Boolean result = null;
    try {
        result = cut.isValidDragSource(dragEvent, uidl);
    } catch (final Exception ex) {
        fail("Exception is not re-thrown");
    }

    // assure that in case of exception the drag source is declared invalid
    assertThat(result).as("Expected: Invalid drag if exception occures.").isFalse();
}
 
Example #30
Source File: CubaMenuBarConnector.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
protected void assignAdditionalMenuStyles(VMenuBar currentMenu, UIDL item) {
    String icon = item.getStringAttribute("icon");
    if (icon != null) {
        currentMenu.addStyleDependentName("has-icons");
    }
}