Java Code Examples for com.vaadin.client.UIDL#getIntAttribute()

The following examples show how to use com.vaadin.client.UIDL#getIntAttribute() . 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: 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 2
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 3
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 4
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;
}