Example usage for com.vaadin.client UIDL getBooleanAttribute

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

Introduction

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

Prototype

public boolean getBooleanAttribute(String name) 

Source Link

Document

Gets the named attribute as a boolean.

Usage

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

License:Apache License

/**
 * Called whenever an update is received from the server
 *///from  w  w w  . j  a  v a2s  .c  o m
@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();

    try {
        if (uidl.hasAttribute("escapeHTML")) {
            this.escapeHTML = uidl.getBooleanAttribute("escapeHTML");
        }

        UIDL rows = uidl.getChildByTagName("rows");
        if (rows != null) {
            // clear all old table cells
            table.removeAllRows();
            highlighted.clear();
            position2id.clear();

            for (int i = 0; i < rows.getChildCount(); i++) {
                UIDL row = rows.getChildUIDL(i);
                if ("row".equals(row.getTag())) {
                    addRow(row, i);
                }
            }
        } // end if rows not null

        // add end events if necessary to have a nicely aligned regular grid
        int maxCellCount = 0;
        for (int row = 0; row < table.getRowCount(); row++) {
            maxCellCount = Math.max(maxCellCount, getRealColumnCount(row));
        }

        for (int row = 0; row < table.getRowCount(); row++) {
            int isValue = getRealColumnCount(row);

            if (isValue < maxCellCount) {
                int diff = maxCellCount - isValue;
                table.setHTML(row, table.getCellCount(row) + diff - 1, "");
            }
        }

    } catch (Exception ex) {
        VConsole.log(ex);
    }
}

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;//w ww.  j a v a  2s .  c o m
    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:com.eternach.client.RichOptionGroupWidget.java

License:Apache License

@Override
public void buildOptions(final UIDL uidl) {
    panel.clear();//  ww w . j av a  2  s .co m
    optionsEnabled.clear();
    for (final Iterator<?> it = uidl.getChildIterator(); it.hasNext();) {
        boolean iconDisplayed = false;
        final UIDL opUidl = (UIDL) it.next();
        CheckBox op;

        String itemHtml = opUidl.getStringAttribute("caption");
        if (!htmlContentAllowed) {
            itemHtml = Util.escapeHTML(itemHtml);
        }

        final String icon = opUidl.getStringAttribute("icon");
        if (icon != null && icon.length() != 0) {
            final String iconUrl = client.translateVaadinUri(icon);
            itemHtml = "<span style=\"white-space: normal;\">" + itemHtml + "</span><br/><img src=\"" + iconUrl
                    + "\" class=\"" + Icon.CLASSNAME + "\" alt=\"\" />";
            iconDisplayed = true;
        }

        if (isMultiselect()) {
            op = new VCheckBox();
        } else {
            op = new RadioButton(paintableId, null, true);
            op.setStyleName("v-radiobutton");
        }

        op.addStyleName(CLASSNAME_OPTION);
        op.setValue(opUidl.getBooleanAttribute("selected"));
        final boolean optionEnabled = !opUidl
                .getBooleanAttribute(OptionGroupConstants.ATTRIBUTE_OPTION_DISABLED);
        final boolean enabled = optionEnabled && !isReadonly() && isEnabled();
        op.setEnabled(enabled);
        optionsEnabled.add(optionEnabled);
        setStyleName(op.getElement(), ApplicationConnection.DISABLED_CLASSNAME,
                !(optionEnabled && isEnabled()));
        op.addClickHandler(this);
        optionsToKeys.put(op, opUidl.getStringAttribute("key"));
        String description = opUidl.getStringAttribute("description-text");
        if (description == null) {
            description = "";
        }
        if (opUidl.getStringAttribute("description-icon") != null) {
            description += "<br/><img src=\""
                    + client.translateVaadinUri(opUidl.getStringAttribute("description-icon")) + "\"\\>";
        }

        final FocusableFlexTable table = new FocusableFlexTable();
        table.setWidget(0, 0, op);
        table.setHTML(0, 1, itemHtml);
        table.setCellPadding(0);
        table.setCellSpacing(0);
        panel.add(table);

        if (description != null && description.length() != 0) {
            elementsToDescription.put(table.getElement(), description);
        }
        if (iconDisplayed) {
            Util.sinkOnloadForImages(table.getElement());
            table.addHandler(iconLoadHandler, LoadEvent.getType());
        }
    }

}

From source file:com.haulmont.cuba.web.toolkit.ui.client.tree.CubaTreeConnector.java

License:Apache License

@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    super.updateFromUIDL(uidl, client);

    getWidget().setDoubleClickHandling(false);

    getWidget().nodeCaptionsAsHtml = uidl.getBooleanAttribute("nodeCaptionsAsHtml");

    // We may have actions attached to this tree
    if (uidl.getChildCount() > 1) {
        final int cnt = uidl.getChildCount();
        for (int i = 1; i < cnt; i++) {
            UIDL childUidl = uidl.getChildUIDL(i);
            if (childUidl.getTag().equals("shortcuts")) {
                if (getWidget().getShortcutActionHandler() == null) {
                    getWidget().setShortcutActionHandler(new ShortcutActionHandler(uidl.getId(), client));
                }//from  w  ww  .  ja v  a 2  s  .c o m
                getWidget().getShortcutActionHandler().updateActionMap(childUidl);
            }
        }
    }
}

From source file:com.wcs.wcslib.vaadin.widget.multifileupload.client.VMultiUpload.java

License:Apache License

@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    if (client.updateComponent(this, uidl, true)) {
        return;//from   w  ww . j av a2 s.  c  o m
    }
    addStyleName(CLASSNAME + "-immediate");

    this.client = client;
    paintableId = uidl.getId();
    receiverUri = client.translateVaadinUri(uidl.getStringVariable("target"));
    submitButton.setText(uidl.getStringAttribute("buttoncaption"));
    fu.setName(paintableId + "_file");

    if (uidl.hasAttribute("enabled")) {
        if (uidl.getBooleanAttribute("enabled")) {
            enableUpload();
        } else {
            disableUpload();
        }
    }

    if (uidl.hasAttribute("maxFileSize")) {
        maxFileSize = uidl.getLongAttribute("maxFileSize");
    }
    if (uidl.hasAttribute("sizeErrorMsg")) {
        sizeErrorMsg = uidl.getStringAttribute("sizeErrorMsg");
    }
    if (uidl.hasAttribute("mimeTypeErrorMsg")) {
        mimeTypeErrorMsg = uidl.getStringAttribute("mimeTypeErrorMsg");
    }
    if (uidl.hasAttribute("acceptFilter")) {
        getInput().setAccept(uidl.getStringAttribute("acceptFilter"));
    }
    if (uidl.hasAttribute("acceptedMimeTypes")) {
        acceptedMimeTypes = Arrays.asList(uidl.getStringArrayAttribute("acceptedMimeTypes"));
    }
    if (uidl.hasAttribute("interruptedFileIds")) {
        removeFromFileQueue(uidl.getIntArrayAttribute("interruptedFileIds"));
    }
    if (uidl.hasAttribute("ready")) {
        postNextFileFromQueue();
    }
}

From source file:info.magnolia.ui.vaadin.gwt.client.richtext.VMagnoliaRichTextField.java

License:Open Source License

@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {

    // Make sure external plugins are assigned before the loading command.
    if (uidl.hasAttribute(VAR_SERVERPLUGINS)) {
        customPlugins = uidl.getMapAttribute(VAR_SERVERPLUGINS);
    }//from  www  . j a v  a 2s . co m

    // list of plugin events that server is interested of handling.
    if (uidl.hasAttribute(VAR_EVENTNAMES)) {
        pluginEvents = Arrays.asList(uidl.getStringArrayAttribute(VAR_EVENTNAMES));
    }

    if (uidl.hasAttribute(ATTR_IMMEDIATE)) {
        immediate = uidl.getBooleanAttribute(ATTR_IMMEDIATE);
    }

    super.updateFromUIDL(uidl, client);

    // Server wants to send an event to a plugin, we must do this after super value update.
    if (uidl.hasAttribute(VAR_FIRE_PLUGIN_EVENT) && this.editor != null) {
        this.editor.fire(uidl.getStringAttribute(VAR_FIRE_PLUGIN_EVENT),
                uidl.getStringAttribute(VAR_FIRE_PLUGIN_EVENT_VALUE));
    }
}

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 ava  2 s. com
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.semanticsoft.vaadinaddons.boundsinfo.client.ui.VBoundsinfoVerticalLayout.java

License:Open Source License

/**
 * Called whenever an update is received from the server
 *///from   w  w  w  .j a  v  a2  s. co  m
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    super.updateFromUIDL(uidl, 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.client = client;

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

    if (uidl.hasAttribute(VARIABLES)) {
        ValueMap vmap = uidl.getMapAttribute(VARIABLES);
        Set<String> indexes = vmap.getKeySet();
        for (String index : indexes) {
            variables.put(index, vmap.getString(index));
        }
    }

    this.enableBoundsUpdate = uidl.getBooleanAttribute(ENABLE_BOUNDS_UPDATE);
    if (this.enableBoundsUpdate)
        updateManager = new BoundsUpdateManager(this, paintableId, client);
}

From source file:org.vaadin.alump.ckeditor.client.VCKEditorTextField.java

License:Apache License

/**
 * Called whenever an update is received from the server
 *//*ww w  .ja v  a 2s.c o m*/
@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    clientToServer = client;
    paintableId = uidl.getId();
    boolean needsDataUpdate = false;
    boolean needsProtectedBodyUpdate = false;
    boolean readOnlyModeChanged = false;

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

    if (!resizeListenerInPlace) {
        LayoutManager.get(client).addElementResizeListener(getElement(), new ElementResizeListener() {

            @Override
            public void onElementResize(ElementResizeEvent e) {
                doResize();
            }

        });
        resizeListenerInPlace = true;
    }

    if (uidl.hasAttribute(ATTR_IMMEDIATE)) {
        immediate = uidl.getBooleanAttribute(ATTR_IMMEDIATE);
    }
    if (uidl.hasAttribute(ATTR_READONLY)) {
        boolean newReadOnly = uidl.getBooleanAttribute(ATTR_READONLY);
        readOnlyModeChanged = newReadOnly != readOnly;
        readOnly = newReadOnly;
    }
    if (uidl.hasAttribute(ATTR_VIEW_WITHOUT_EDITOR)) {
        viewWithoutEditor = uidl.getBooleanAttribute(ATTR_VIEW_WITHOUT_EDITOR);
    }
    if (uidl.hasAttribute(ATTR_PROTECTED_BODY)) {
        boolean state = uidl.getBooleanAttribute(ATTR_PROTECTED_BODY);
        if (protectedBody != state) {
            protectedBody = state;
            needsProtectedBodyUpdate = true;
        }
    }
    if (uidl.hasVariable(VAR_TEXT)) {
        String data = uidl.getStringVariable(VAR_TEXT);
        if (ckEditor != null)
            dataBeforeEdit = ckEditor.getData();
        needsDataUpdate = !data.equals(dataBeforeEdit);
        dataBeforeEdit = data;
    }

    // Save the client side identifier (paintable id) for the widget
    if (!paintableId.equals(getElement().getId())) {
        getElement().setId(paintableId);
    }

    if (viewWithoutEditor) {
        if (ckEditor != null) {
            // may update the data and change to viewWithoutEditor at the same time 
            if (!needsDataUpdate) {
                dataBeforeEdit = ckEditor.getData();
            }
            ckEditor.destroy(true);
            ckEditorIsReady = false;
            ckEditor = null;
        }
        getElement().setInnerHTML(dataBeforeEdit);
    } else if (ckEditor == null) {
        getElement().setInnerHTML(""); // in case we put contents in there while in viewWithoutEditor mode

        final String inPageConfig = uidl.hasAttribute(ATTR_INPAGECONFIG)
                ? uidl.getStringAttribute(ATTR_INPAGECONFIG)
                : null;

        writerIndentationChars = uidl.hasAttribute(ATTR_WRITER_INDENTATIONCHARS)
                ? uidl.getStringAttribute(ATTR_WRITER_INDENTATIONCHARS)
                : null;

        if (uidl.hasAttribute(ATTR_FOCUS)) {
            setFocus(uidl.getBooleanAttribute(ATTR_FOCUS));
        }

        // See if we have any writer rules
        int i = 0;
        while (true) {
            if (!uidl.hasAttribute(ATTR_WRITERRULES_TAGNAME + i)) {
                break;
            }
            // Save the rules until our instance is ready
            String tagName = uidl.getStringAttribute(ATTR_WRITERRULES_TAGNAME + i);
            String jsRule = uidl.getStringAttribute(ATTR_WRITERRULES_JSRULE + i);
            if (writerRules == null) {
                writerRules = new HashMap<String, String>();
            }
            writerRules.put(tagName, jsRule);
            ++i;
        }

        // See if we have any keystrokes
        i = 0;
        while (true) {
            if (!uidl.hasAttribute(ATTR_KEYSTROKES_KEYSTROKE + i)) {
                break;
            }
            // Save the keystrokes until our instance is ready
            int keystroke = uidl.getIntAttribute(ATTR_KEYSTROKES_KEYSTROKE + i);
            String command = uidl.getStringAttribute(ATTR_KEYSTROKES_COMMAND + i);
            if (keystrokeMappings == null) {
                keystrokeMappings = new HashMap<Integer, String>();
            }
            keystrokeMappings.put(keystroke, command);
            ++i;
        }

        // See if we have any protected source regexs
        i = 0;
        while (true) {
            if (!uidl.hasAttribute(ATTR_PROTECTED_SOURCE + i)) {
                break;
            }
            // Save the regex until our instance is ready
            String regex = uidl.getStringAttribute(ATTR_PROTECTED_SOURCE + i);
            if (protectedSourceList == null) {
                protectedSourceList = new LinkedList<String>();
            }
            protectedSourceList.add(regex);
            ++i;
        }

        ScheduledCommand scE = new ScheduledCommand() {
            @Override
            public void execute() {
                ckEditor = (CKEditor) CKEditorService.loadEditor(paintableId, VCKEditorTextField.this,
                        inPageConfig, VCKEditorTextField.super.getOffsetWidth(),
                        VCKEditorTextField.super.getOffsetHeight());

            }
        };

        CKEditorService.loadLibrary(scE);

        // editor data and some options are set when the instance is ready....
    } else if (ckEditorIsReady) {
        if (needsDataUpdate) {
            ckEditor.setData(dataBeforeEdit);
        }

        if (needsProtectedBodyUpdate) {
            ckEditor.protectBody(protectedBody);
        }

        if (uidl.hasAttribute(ATTR_INSERT_HTML)) {
            ckEditor.insertHtml(uidl.getStringAttribute(ATTR_INSERT_HTML));
        }

        if (uidl.hasAttribute(ATTR_INSERT_TEXT)) {
            ckEditor.insertText(uidl.getStringAttribute(ATTR_INSERT_TEXT));
        }

        if (uidl.hasAttribute(ATTR_FOCUS)) {
            setFocus(uidl.getBooleanAttribute(ATTR_FOCUS));
        }

        if (readOnlyModeChanged) {
            ckEditor.setReadOnly(readOnly);
        }
    }

}

From source file:org.vaadin.ui.client.numberfield.NumberFieldConnector.java

License:Apache License

private void processAttributesFromServer(UIDL uidl) {
    if (uidl.hasAttribute(Constants.ATTRIBUTE_ALLOW_NEGATIVES)) {
        getWidget().attributes//w ww  .ja v a  2  s .co  m
                .setNegativeAllowed(uidl.getBooleanAttribute(Constants.ATTRIBUTE_ALLOW_NEGATIVES));
    }

    if (uidl.hasAttribute(Constants.ATTRIBUTE_DECIMAL_PRECISION)) {
        getWidget().attributes.setDecimalPrecision(uidl.getIntAttribute(Constants.ATTRIBUTE_DECIMAL_PRECISION));
    }

    if (uidl.hasAttribute(Constants.ATTRIBUTE_MIN_VALUE)) {
        getWidget().attributes.setMinValue(uidl.getDoubleAttribute(Constants.ATTRIBUTE_MIN_VALUE));
    }

    if (uidl.hasAttribute(Constants.ATTRIBUTE_MAX_VALUE)) {
        getWidget().attributes.setMaxValue(uidl.getDoubleAttribute(Constants.ATTRIBUTE_MAX_VALUE));
    }

    if (uidl.hasAttribute(Constants.ATTRIBUTE_ALLOW_DECIMALS)) {
        getWidget().attributes.setDecimalAllowed(uidl.getBooleanAttribute(Constants.ATTRIBUTE_ALLOW_DECIMALS));
    }

    if (uidl.hasAttribute(Constants.ATTRIBUTE_DECIMAL_SEPARATOR)) {
        getWidget().attributes
                .setDecimalSeparator((char) uidl.getIntAttribute(Constants.ATTRIBUTE_DECIMAL_SEPARATOR));
    }

    if (uidl.hasAttribute(Constants.ATTRIBUTE_USE_GROUPING)) {
        getWidget().attributes.setGroupingUsed(uidl.getBooleanAttribute(Constants.ATTRIBUTE_USE_GROUPING));
    }

    if (uidl.hasAttribute(Constants.ATTRIBUTE_GROUPING_SEPARATOR)) {
        getWidget().attributes
                .setGroupingSeparator((char) uidl.getIntAttribute(Constants.ATTRIBUTE_GROUPING_SEPARATOR));
    }

    if (uidl.hasAttribute(Constants.ATTRIBUTE_SERVER_FORMATTED_VALUE)) {
        getWidget().setValue(uidl.getStringAttribute(Constants.ATTRIBUTE_SERVER_FORMATTED_VALUE));
    }
}