Example usage for com.vaadin.client UIDL getStringArrayAttribute

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

Introduction

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

Prototype

public String[] getStringArrayAttribute(String name) 

Source Link

Document

Gets the named attribute as an array of Strings.

Usage

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

License:Apache License

private void addStyleForEvent(UIDL event, int rowNumber, int col) {
    String id = event.getStringAttribute("id");

    // style given by the server component
    if (event.hasAttribute("style")) {
        String[] styles = event.getStringArrayAttribute("style");
        for (String s : styles) {
            formatter.addStyleName(rowNumber, col, s);
        }//from  w  w  w . j av  a  2  s .  c  om
    } else {
        formatter.addStyleName(rowNumber, col, "single_event");
    }

    // fill highlight map
    if (event.hasAttribute("highlight")) {
        highlighted.put(id, event.getStringArrayAttribute("highlight"));
    }

    if (event.hasAttribute("startTime")) {
        formatter.addStyleName(rowNumber, col, "speaker");
        startTimes.put(new Position(rowNumber, col), event.getDoubleAttribute("startTime"));
        if (event.hasAttribute("endTime")) {
            endTimes.put(new Position(rowNumber, col), event.getDoubleAttribute("endTime"));
        }
    }

    if (event.hasAttribute("openPDF")) {
        String number = event.getStringAttribute("openPDF");
        formatter.addStyleName(rowNumber, col, "pdf");
        pdfPageNumbers.put(new Position(rowNumber, col), number);
    }
}

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

License:Apache License

@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    if (client.updateComponent(this, uidl, true)) {
        return;/*from  w  w  w.  j  ava2 s .co m*/
    }

    // 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 (media == null) {
        VConsole.error("media not set!!!");
        return;
    }

    if (uidl.hasAttribute(SOURCE_URL)) {
        registerMetadataLoadedEvent(media);

        if (uidl.hasAttribute(MIME_TYPE)) {
            String mimeType = uidl.getStringAttribute(MIME_TYPE);
            VConsole.log(
                    "canPlayType for \"" + mimeType + "\"value is \"" + media.canPlayType(mimeType) + "\"");
            // check for correct mime type
            if (media.canPlayType(uidl.getStringAttribute(MIME_TYPE)).equals(MediaElement.CANNOT_PLAY)) {
                VConsole.log("CANNOT PLAY!!!");

                gClient.updateVariable(paintableId, CANNOT_PLAY, true, true);
            } else if (media.canPlayType(uidl.getStringAttribute(MIME_TYPE))
                    .equals(MediaElement.CAN_PLAY_MAYBE)) {
                gClient.updateVariable(paintableId, MIGHT_NOT_PLAY, true, true);
            }
        }
        media.setSrc(uidl.getStringAttribute(SOURCE_URL));
    }

    if (uidl.hasAttribute(PLAY)) {
        String[] time = uidl.getStringArrayAttribute(PLAY);
        if (time != null && time.length > 0) {
            if (time.length == 1) {
                try {
                    media.setCurrentTime(Double.parseDouble(time[0]));
                } catch (NumberFormatException ex) {
                    VConsole.error(ex);
                }
            } else if (time.length == 2) {
                try {
                    media.setCurrentTime(Double.parseDouble(time[0]));
                    setEndTimeOnce(media, Double.parseDouble(time[1]));
                } catch (NumberFormatException ex) {
                    VConsole.error(ex);
                }
            }
            media.play();
        }
    } else if (uidl.hasAttribute(PAUSE)) {
        media.pause();
    } else if (uidl.hasAttribute(STOP)) {
        media.pause();
        media.setSrc("");
    }
}

From source file:com.haulmont.cuba.web.toolkit.ui.client.table.CubaScrollTableWidget.java

License:Apache License

@Override
public void updateColumnProperties(UIDL uidl) {
    super.updateColumnProperties(uidl);

    if (uidl.hasAttribute("colcubaids") && uidl.hasAttribute("vcolorder")) {
        try {/*from w  ww .jav a  2s  .c o m*/
            String[] vcolorder = uidl.getStringArrayAttribute("vcolorder");
            String[] colcubaids = uidl.getStringArrayAttribute("colcubaids");

            Map<String, HeaderCell> headerCellMap = new HashMap<>();
            for (int i = 0; i < getHead().getVisibleCellCount(); i++) {
                HeaderCell headerCell = getHead().getHeaderCell(i);
                if (headerCell.getColKey() != null) {
                    headerCellMap.put(headerCell.getColKey(), headerCell);
                }
            }

            for (int i = 0; i < vcolorder.length; i++) {
                String key = vcolorder[i];
                HeaderCell headerCell = headerCellMap.get(key);

                if (headerCell != null) {
                    headerCell.getElement().setAttribute("cuba-id", "column_" + colcubaids[i]);
                }
            }
        } catch (Exception e) {
            VConsole.error("Unable to init cuba-ids for columns " + e.getMessage());
        }
    }
}

From source file:com.haulmont.cuba.web.widgets.client.table.CubaScrollTableWidget.java

License:Apache License

@Override
public void updateColumnProperties(UIDL uidl) {
    super.updateColumnProperties(uidl);

    if (uidl.hasAttribute("colcubaids") && uidl.hasAttribute("vcolorder")) {
        try {/*from   www .  j  av a 2  s  . c o  m*/
            String[] vcolorder = uidl.getStringArrayAttribute("vcolorder");
            String[] colcubaids = uidl.getStringArrayAttribute("colcubaids");

            Map<String, HeaderCell> headerCellMap = new HashMap<>();
            for (int i = 0; i < getHead().getVisibleCellCount(); i++) {
                HeaderCell headerCell = getHead().getHeaderCell(i);
                if (headerCell.getColKey() != null) {
                    headerCellMap.put(headerCell.getColKey(), headerCell);
                }
            }

            for (int i = 0; i < vcolorder.length; i++) {
                String key = vcolorder[i];
                HeaderCell headerCell = headerCellMap.get(key);

                if (headerCell != null) {
                    headerCell.getElement().setAttribute("cuba-id", "column_" + colcubaids[i]);
                }
            }
        } catch (Exception e) {
            Logger.getLogger("CubaScrollTableWidget").log(Level.SEVERE,
                    "Unable to init cuba-ids for columns " + e.getMessage());
        }
    }
}

From source file:com.haulmont.cuba.web.widgets.client.treetable.CubaTreeTableWidget.java

License:Apache License

@Override
public void updateColumnProperties(UIDL uidl) {
    super.updateColumnProperties(uidl);

    if (uidl.hasAttribute("colcubaids") && uidl.hasAttribute("vcolorder")) {
        try {/*from w w w  .j a  v  a  2s .  c o  m*/
            String[] vcolorder = uidl.getStringArrayAttribute("vcolorder");
            String[] colcubaids = uidl.getStringArrayAttribute("colcubaids");

            Map<String, HeaderCell> headerCellMap = new HashMap<>();
            for (int i = 0; i < getHead().getVisibleCellCount(); i++) {
                HeaderCell headerCell = getHead().getHeaderCell(i);
                if (headerCell.getColKey() != null) {
                    headerCellMap.put(headerCell.getColKey(), headerCell);
                }
            }

            for (int i = 0; i < vcolorder.length; i++) {
                String key = vcolorder[i];
                HeaderCell headerCell = headerCellMap.get(key);

                if (headerCell != null) {
                    headerCell.getElement().setAttribute("cuba-id", "column_" + colcubaids[i]);
                }
            }
        } catch (Exception e) {
            Logger.getLogger("CubaTreeTableWidget").log(Level.SEVERE,
                    "Unable to init cuba-ids for columns " + e.getMessage());
        }
    }
}

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

License:Apache License

@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    super.updateFromUIDL(uidl, client);
    if (uidl.hasAttribute("maxFileSize")) {
        getWidget().setMaxFileSize(uidl.getLongAttribute("maxFileSize"));
    }//from w w w.j av  a 2  s  .c  o  m
    if (uidl.hasAttribute("sizeErrorMsg")) {
        getWidget().setSizeErrorMsg(uidl.getStringAttribute("sizeErrorMsg"));
    }
    if (uidl.hasAttribute("acceptFilter")) {
        getWidget().setAcceptFilter(uidl.getStringAttribute("acceptFilter"));
    }
    if (uidl.hasAttribute("mimeTypeErrorMsg")) {
        getWidget().setMimeTypeErrorMsg(uidl.getStringAttribute("mimeTypeErrorMsg"));
    }
    if (uidl.hasAttribute("acceptedMimeTypes")) {
        getWidget().setAcceptedMimeTypes(Arrays.asList(uidl.getStringArrayAttribute("acceptedMimeTypes")));
    }
}

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;//  w w w  . ja  v a  2s.  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);
    }/*  w w  w .  j ava 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));
    }
}