Example usage for com.vaadin.client UIDL getIntAttribute

List of usage examples for com.vaadin.client UIDL getIntAttribute

Introduction

In this page you can find the example usage for com.vaadin.client UIDL getIntAttribute.

Prototype

public int getIntAttribute(String name) 

Source Link

Document

Gets the named attribute as an int.

Usage

From source file:annis.gui.widgets.gwt.client.ui.VAnnotationGrid.java

License:Apache License

private void addRow(UIDL row, int rowNumber) {

    String caption = row.getStringAttribute("caption");
    boolean showNamespace = row.getBooleanAttribute("show-namespace");
    String name;/*from  w  ww.j  a v  a2s  .com*/
    if (showNamespace) {
        name = caption;
    } else {
        String[] captionSplit = caption.split("::");
        name = captionSplit[captionSplit.length - 1];
    }

    boolean showCaption = row.getBooleanAttribute("show-caption");

    int startColumn = 0;

    if (showCaption) {
        table.setHTML(rowNumber, 0, Util.escapeHTML(name));
        formatter.addStyleName(rowNumber, 0, "header");
        startColumn = 1;
    }

    int colspanOffset = 0;

    UIDL events = row.getChildByTagName("events");
    for (int j = 0; j < events.getChildCount(); j++) {
        UIDL event = events.getChildUIDL(j);
        String id = event.getStringAttribute("id");
        int left = event.getIntAttribute("left");
        int right = event.getIntAttribute("right");
        String value = event.getStringAttribute("value");
        if (escapeHTML) {
            value = Util.escapeHTML(value);
        }

        // +1 because we also have a caption column, subtract columns we
        // jumped over by using colspan
        int col = left + startColumn - colspanOffset;

        table.setHTML(rowNumber, col, value);

        if (event.hasAttribute("tooltip")) {
            Element tdElement = table.getCellFormatter().getElement(rowNumber, col);
            tdElement.setTitle(event.getStringAttribute("tooltip"));
        }

        position2id.put(new Position(rowNumber, col), id);

        int colspan = right - left + 1;
        formatter.setColSpan(rowNumber, col, colspan);
        if (colspan > 1) {
            colspanOffset += (colspan - 1);
        }

        addStyleForEvent(event, rowNumber, col);

    }
}

From source file:annis.gui.widgets.gwt.client.ui.VSimpleCanvas.java

License:Apache License

/**
 * Called whenever an update is received from the server 
 *//*from   w  w w.j  a v  a  2 s.  c  om*/
@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {

    // This call should be made first. 
    // It handles sizes, captions, tooltips, etc. automatically.
    if (client.updateComponent(this, uidl, true)) {
        // If client.updateComponent returns true there has been no changes and we
        // do not need to update anything.
        return;
    }

    // Save reference to server connection object to be able to send
    // user interaction later
    //this.gClient = client;

    // Save the client side identifier (paintable id) for the widget
    //paintableId = uidl.getId();

    if (context != null) {
        Iterator<Object> it = uidl.getChildIterator();
        while (it.hasNext()) {
            UIDL child = (UIDL) it.next();

            if ("clear".equals(child.getTag())) {
                context.clearRect(0, 0, context.getCanvas().getWidth(), context.getCanvas().getHeight());
            } else if ("line".equals(child.getTag())) {
                context.setGlobalAlpha(1.0);
                context.setLineWidth(1.0);
                context.setStrokeStyle("black");
                context.beginPath();
                context.moveTo(child.getIntAttribute("from_x"), child.getIntAttribute("from_y"));
                context.lineTo(child.getIntAttribute("to_x"), child.getIntAttribute("to_y"));
                context.closePath();
                context.stroke();
            }
            // todo: more commands :)
        }

    }
}

From source file:com.haulmont.cuba.web.toolkit.ui.client.widgetstree.CubaWidgetsTreeConnector.java

License:Apache License

@Override
protected VTree.TreeNode createNode(UIDL childUidl) {
    if (childUidl.hasAttribute("widgetIndex")) {
        int widgetIndex = childUidl.getIntAttribute("widgetIndex");
        if (widgetIndex < nodeWidgets.size()) {
            ComponentConnector componentConnector = getChildComponents().get(widgetIndex);

            CubaWidgetsTreeWidget.WidgetTreeNode treeNode = getWidget().new WidgetTreeNode();
            treeNode.setNodeWidget(componentConnector.getWidget());
            return treeNode;
        }/*w ww .ja va 2 s. c  o m*/
    }
    // all branches should return instance of same TreeNode class
    return getWidget().new WidgetTreeNode();
}

From source file:it.zero11.vaadin.asyncfiltercombobox.client.AsyncFilterComboBoxConnector.java

License:Apache License

@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    getWidget().filterChangeEventMode = uidl
            .getStringAttribute(AsyncFilterComboBoxConstants.ATTR_FILTERCHANGE_EVENTMODE);
    getWidget().filterChangeEventTimeout = uidl
            .getIntAttribute(AsyncFilterComboBoxConstants.ATTR_FILTERCHANGE_TIMEOUT);
    super.updateFromUIDL(uidl, client);
}

From source file:org.eclipse.hawkbit.ui.dd.client.criteria.ItemIdClientCriterion.java

License:Open Source License

@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 {/*from   www . java  2 s  .c  o m*/

        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;
}

From source file:org.eclipse.hawkbit.ui.dd.client.criteria.ViewClientCriterion.java

License:Open Source License

/**
 * Hides the highlighted drop target hints.
 *
 * @param configuration// w  w w  .  ja  v  a2s .c o  m
 *            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());
        }
    }
}

From source file:org.eclipse.hawkbit.ui.dd.client.criteria.ViewComponentClientCriterion.java

License:Open Source License

/**
 * Highlights the valid drop targets configured for the criterion.
 *
 * @param configuration/*from   w w w  . j ava  2s.c o  m*/
 *            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());
        }
    }

}

From source file:org.eclipse.hawkbit.ui.dd.client.criteria.ViewComponentClientCriterion.java

License:Open Source License

/**
 * 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/* ww  w  .j  a  v  a2  s.c o m*/
 *            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;
}

From source file:org.semanticsoft.vaaclipse.widgets.client.ui.stackwidget.StackWidgetConnector.java

License:Open Source License

/**
 * Called whenever an update is received from the server
 *//*from  w w  w  .  j  a va 2s. c  om*/
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    VStackWidget stackWidget = getWidget();

    stackWidget.id = uidl.getId();
    stackWidget.client = client;

    if (uidl.getIntAttribute("svoi") == 5) {
        int state = uidl.getIntAttribute("vaadock_tabsheet_state");
        VConsole.log("VStackWidget: set initial state = " + state);
        stackWidget.setState(state);
        stackWidget.maximizeEnabled = uidl.getBooleanAttribute("maximize_enabled");
        stackWidget.minimizeEnabled = uidl.getBooleanAttribute("minimize_enabled");

        if (!stackWidget.maximizeEnabled)
            stackWidget.maximizeButton.setAttribute("style", "display: none;");
        if (!stackWidget.minimizeEnabled)
            stackWidget.minimizeButton.setAttribute("style", "display: none;");
    }

    if (isRealUpdate(uidl) && !uidl.hasAttribute("hidden")) {
        UIDL acceptCrit = uidl.getChildByTagName("-ac");
        if (acceptCrit == null) {
            getWidget().setDropHandler(null);
        } else {
            if (getWidget().getDropHandler() == null) {
                getWidget().setDropHandler(new VStackWidgetDropHandler(getWidget(), client));
                VConsole.log("updateFromUIDL: VStackWidgetDropHandler installed");
            }
            getWidget().getDropHandler().updateAcceptRules(acceptCrit);
        }
    }

    super.updateFromUIDL(uidl, client);
}

From source file:org.tepi.filtertable.gwt.client.ui.VFilterTreeTable.java

License:Apache License

@Override
public void addAndRemoveRows(UIDL partialRowAdditions) {
    if (partialRowAdditions == null) {
        return;/*w  ww .  j a v a  2  s.  c  o m*/
    }

    if (animationsEnabled) {
        if (partialRowAdditions.hasAttribute("hide")) {
            scrollBody.unlinkRowsAnimatedAndUpdateCacheWhenFinished(
                    partialRowAdditions.getIntAttribute("firstprowix"),
                    partialRowAdditions.getIntAttribute("numprows"));
        } else {
            scrollBody.insertRowsAnimated(partialRowAdditions,
                    partialRowAdditions.getIntAttribute("firstprowix"),
                    partialRowAdditions.getIntAttribute("numprows"));
            discardRowsOutsideCacheWindow();
        }
    } else {
        super.addAndRemoveRows(partialRowAdditions);
    }
}