Example usage for com.vaadin.ui Label setWidth

List of usage examples for com.vaadin.ui Label setWidth

Introduction

In this page you can find the example usage for com.vaadin.ui Label setWidth.

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

From source file:probe.com.view.core.ToggleBtn.java

public ToggleBtn(String strBtn1Label, String strBtn2Label, String btn1Comment, String btn2Comment, int width) {

    final Label btn1CommentLabel = new Label(btn1Comment);
    btn1CommentLabel.setStyleName(Reindeer.LABEL_SMALL);
    btn1CommentLabel.setWidth("120px");
    final Label btn2CommentLabel = new Label(btn2Comment);
    btn2CommentLabel.setStyleName(Reindeer.LABEL_SMALL);
    btn2CommentLabel.setVisible(false);/* www  . j  a v a2s .  c  o m*/
    btn2CommentLabel.setWidth("120px");

    this.setSpacing(true);
    Label btn1Label = new Label(strBtn1Label);
    btn1Label.setStyleName(Reindeer.LABEL_SMALL);
    Label btn2Label = new Label(strBtn2Label);
    btn2Label.setStyleName(Reindeer.LABEL_SMALL);
    toggleSwichButton = new HorizontalLayout();
    toggleSwichButton.setStyleName("toggleleft");
    toggleSwichButton.setWidth("50px");
    toggleSwichButton.setHeight("15px");
    toggleSwichButton.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {

        @Override
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {
            if (toggleSwichButton.getStyleName().equalsIgnoreCase("toggleleft")) {
                toggleSwichButton.setStyleName("toggleright");
                btn1CommentLabel.setVisible(false);
                btn2CommentLabel.setVisible(true);
            } else {
                toggleSwichButton.setStyleName("toggleleft");
                btn1CommentLabel.setVisible(true);
                btn2CommentLabel.setVisible(false);
            }
        }
    });

    this.addComponent(btn1CommentLabel);//commentLabel
    this.setComponentAlignment(btn1CommentLabel, Alignment.TOP_LEFT);//commentLabel
    this.addComponent(btn2CommentLabel);//commentLabel
    this.setComponentAlignment(btn2CommentLabel, Alignment.TOP_LEFT);//commentLabel
    VerticalLayout spacer = new VerticalLayout();
    width = Math.max((width - 120 - 75 - 75 - 55), 1);
    spacer.setHeight("15px");
    spacer.setWidth(width + "px");
    spacer.setStyleName(Reindeer.LAYOUT_WHITE);
    this.addComponent(spacer);
    this.addComponent(btn1Label);
    this.addComponent(toggleSwichButton);
    this.addComponent(btn2Label);

}

From source file:ro.zg.netcell.vaadin.action.application.OpenSelectedEntityHandler.java

License:Apache License

@Override
public void handle(final ActionContext actionContext) throws Exception {
    final ComponentContainer container = actionContext.getTargetContainer();

    container.removeAllComponents();/*from w w  w  .  j a  va  2s  .  c o  m*/
    // container.setSizeFull();
    // container.setMargin(false);
    final OpenGroupsApplication app = actionContext.getApp();
    final Entity entity = actionContext.getEntity();

    EntityState entityState = entity.getState();
    boolean isOpened = entityState.isOpened();
    String complexEntityType = entity.getComplexType();
    ApplicationConfigManager appConfigManager = app.getAppConfigManager();
    List<String> subtyesList = appConfigManager.getSubtypesForComplexType(complexEntityType);

    // Panel currentContainer = (Panel) container;
    ComponentContainer currentContainer = container;
    entity.setEntityContainer(container);

    CssLayout headerContainer = new CssLayout();
    headerContainer.addStyleName("entity-header-container");
    currentContainer.addComponent(headerContainer);

    // CssLayout titleContainer = new CssLayout();
    // titleContainer.setWidth("80%");
    // titleContainer.addStyleName(OpenGroupsStyles.MIDDLE_LEFT);
    // headerContainer.addComponent(titleContainer);

    // titleContainer.setSizeFull();
    // /* show level */
    // String levelMsg = getMessage("level");
    // Label levelLabel = new Label(levelMsg+" "+entity.getDepth());
    // titleContainer.addComponent(levelLabel);

    /* show entity type */
    if (entity.getState().isEntityTypeVisible()) {
        String entityTypeCaption = getMessage(entity.getComplexType());

        String size = OpenGroupsIconsSet.MEDIUM;
        if (entity.getContent() != null) {
            size = OpenGroupsIconsSet.LARGE;
        }
        // Label typeIcon = new Label();
        // typeIcon.setDescription(entityTypeCaption);
        // typeIcon.setIcon(OpenGroupsResources.getIcon(entity.getComplexType().toLowerCase(),
        // size));
        // typeIcon.setSizeUndefined();
        // typeIcon.addStyleName("top-left right-margin-20");
        // headerContainer.addComponent(typeIcon);
        Embedded eicon = new Embedded(null,
                OpenGroupsResources.getIcon(entity.getComplexType().toLowerCase(), size));
        eicon.setDescription(entityTypeCaption);
        eicon.addStyleName("top-left right-margin-20");

        headerContainer.addComponent(eicon);

        // Embedded eicon2 = new Embedded("",
        // OpenGroupsResources.getIcon(entity.getComplexType().toLowerCase(),
        // size));
        // eicon2.setDescription(entityTypeCaption);
        // eicon2.addStyleName("top-left right-margin-20");
        // headerContainer.addComponent(eicon2);

    }

    // Label test = new Label("test");
    // test.setSizeUndefined();
    // test.addStyleName("top-left");
    // headerContainer.addComponent(test);

    /* add last action for this entity */
    if (entity.getLastActionType() != null) {
        String actionType = entity.getLastActionType();
        String msg = getMessage(actionType);
        // Label actionLabel = new Label();
        // actionLabel.setDescription(msg);
        // actionLabel.setIcon(OpenGroupsResources.getIcon(actionType,
        // OpenGroupsIconsSet.MEDIUM));
        // actionLabel.setSizeUndefined();
        // actionLabel.addStyleName(OpenGroupsStyles.MIDDLE_LEFT);
        // titleContainer.addComponent(actionLabel);
        Embedded actionIcon = new Embedded(null,
                OpenGroupsResources.getIcon(actionType, OpenGroupsIconsSet.MEDIUM));
        actionIcon.setDescription(msg);
        actionIcon.addStyleName("top-left right-margin-20");
        headerContainer.addComponent(actionIcon);

    }

    EntityLink selectedCause = entity.getSelectedCause();
    /* display title */
    /* if the entity is open */
    /* treat leafs like all posts 21.08.2012 */
    if (isOpened /*
                 * || (subtyesList == null && entity.getLastActionType() ==
                 * null)
                 */) {
        Label title = new Label(entity.getTitle());
        if (isOpened) {
            title.addStyleName(OpenGroupsStyles.TITLE_LINK);
        } else {
            title.addStyleName("list-issue-title");
        }
        // title.addStyleName("top-left");
        // title.setSizeFull();
        title.setWidth("80%");
        // title.setHeight("100%");

        headerContainer.addComponent(title);

    } else {
        // Button titleLink = new Button(entity.getTitle());
        // titleLink.setWidth("100%");
        // titleLink.addStyleName(BaseTheme.BUTTON_LINK);
        // titleLink.addStyleName("issue-title");
        // titleLink.setDescription(entity.getContentPreview());
        Label titleLink = null;
        /* treat leafs like all posts 21.08.2012 */
        // if (subtyesList != null) {
        titleLink = OpenGroupsUtil.getLinkForEntity(entity, app);
        titleLink.setDescription(entity.getContentPreview());
        titleLink.addStyleName("list-issue-title");
        // }
        // /* is a leaf entity in the recent activity list */
        // else {
        // String parentTitle = selectedCause.getParentTitle();
        // Entity parentEntity = new Entity(selectedCause.getParentId());
        // parentEntity.setTitle(parentTitle);
        //
        // parentEntity.getState().setDesiredActionsPath(
        // complexEntityType +
        // Defaults.getDefaultActionForEntityType(complexEntityType));
        // titleLink = OpenGroupsUtil.getLinkForEntity(parentEntity, app,
        // entity.getTitle());
        // titleLink.setDescription(entity.getContentPreview());
        // titleLink.addStyleName("list-issue-title");
        //
        // }

        // titleLink.setWidth("75%");
        titleLink.addStyleName("top-left");
        headerContainer.addComponent(titleLink);
        // titleContainer.setExpandRatio(titleLink, 10f);
        // currentContainer.addStyleName("list-item");
    }

    /* add parent link */
    if (selectedCause != null && !isOpened && entity.getContent() == null) {
        // CssLayout parentInfoContainer = new CssLayout();
        // parentInfoContainer.addStyleName(OpenGroupsStyles.TOP_RIGHT);
        // headerContainer.addComponent(parentInfoContainer);
        // headerContainer.setColumnExpandRatio(1, 1f);
        // headerContainer.setComponentAlignment(parentInfoContainer,
        // Alignment.TOP_RIGHT);
        /* if parent entity is the current selected entity, say it */
        Entity mainEntity = actionContext.getMainEntity();
        if (selectedCause.getParentId() == mainEntity.getId()) {
            // String currentMsg = getMessage(mainEntity.getComplexType() +
            // ".current");
            // Label currentEntityLabel = new Label(currentMsg);
            // currentEntityLabel.setSizeUndefined();
            // currentEntityLabel.addStyleName("top-right");
            // headerContainer.addComponent(currentEntityLabel);
            // titleContainer.setExpandRatio(currentEntityLabel, 2f);
        } else {/* add link to the parent entity */
            String parentTitle = selectedCause.getParentTitle();
            final Entity parentEntity = new Entity(selectedCause.getParentId());
            parentEntity.setTitle(parentTitle);

            Label parentLink = OpenGroupsUtil.getLinkForEntityWithImage(parentEntity, app,
                    OpenGroupsResources.getIconPath(OpenGroupsIconsSet.PARENT, OpenGroupsIconsSet.MEDIUM));
            parentLink.setDescription(parentTitle);
            parentLink.setSizeUndefined();
            parentLink.addStyleName(OpenGroupsStyles.TOP_RIGHT);
            // CssLayout imgContainer = new CssLayout();
            // imgContainer.setWidth("24px");
            // imgContainer.setHeight("24px");
            // imgContainer.addStyleName(OpenGroupsStyles.TOP_RIGHT);
            // imgContainer.addComponent(parentLink);
            // parentInfoContainer.addComponent(imgContainer);
            headerContainer.addComponent(parentLink);
        }
    }

    /* display header actions */
    if (isOpened) {
        UserActionList headerActions = getAvailableActions(entity, ActionLocations.HEADER);
        boolean allowRefresh = appConfigManager.getComplexEntityBooleanParam(entity.getComplexType(),
                ComplexEntityParam.ALLOW_REFRESH);
        boolean hasHeaderActions = headerActions != null && headerActions.getActions() != null;
        if (allowRefresh || hasHeaderActions) {
            HorizontalLayout actionsContainer = new HorizontalLayout();
            actionsContainer.addStyleName(OpenGroupsStyles.TOP_RIGHT);
            actionsContainer.setSpacing(true);
            // /* add refresh button */
            // if (allowRefresh) {
            // actionsContainer.addComponent(getRefreshButton(entity, app));
            // }
            // if (hasHeaderActions) {
            // for (final UserAction ha :
            // headerActions.getActions().values()) {
            // Button actButton = getButtonForAction(ha, entity, app);
            // actionsContainer.addComponent(actButton);
            // }
            // }
            headerContainer.addComponent(actionsContainer);
            // headerContainer.setColumnExpandRatio(1, 1f);
            // headerContainer.setComponentAlignment(actionsContainer,
            // Alignment.TOP_RIGHT);
            entity.setHeaderActionLinksContainer(actionsContainer);
            refreshHeaderActionLinks(entity, app, actionContext);
        }

    }

    /* display tags */
    List<Tag> tags = entity.getTags();
    if (tags != null) {
        if (tags.size() > 0) {
            String tagsList = "";
            for (int i = 0; i < tags.size(); i++) {
                Tag tag = tags.get(i);
                tagsList += tag.getTagName();
                if ((tags.size() - i) > 1) {
                    tagsList += ", ";
                }
            }
            String tagsLabelString = app.getMessage("tags.label") + tagsList;
            currentContainer.addComponent(new Label(tagsLabelString));
        }
    }

    CssLayout statusPane = new CssLayout();
    statusPane.addStyleName("entity-status-pane");

    currentContainer.addComponent(statusPane);

    if (appConfigManager.getComplexEntityBooleanParam(complexEntityType, ComplexEntityParam.SHOW_POST_INFO)) {
        String insertDateString = entity.getInsertDate().toString();
        Label insertDate = new Label(app.getMessage("posted") + DateUtil.removeNanos(insertDateString));
        statusPane.addComponent(insertDate);
        // statusPane.setColumnExpandRatio(0, 1f);
    }

    CssLayout statsSummaryPane = new CssLayout();
    statsSummaryPane.addStyleName("entity-stats-summary-pane");
    // statsSummaryPane.setSizeFull();
    // statsSummaryPane.setWidth("100%");

    currentContainer.addComponent(statsSummaryPane);

    /* add votes */
    if (appConfigManager.getComplexEntityBooleanParam(complexEntityType, ComplexEntityParam.ALLOW_VOTING)) {
        // HorizontalLayout votesPane = new HorizontalLayout();
        // votesPane.setMargin(false);
        // votesPane.addStyleName("middle-left");
        // votesPane.addStyleName("margin-right");
        // statsSummaryPane.addComponent(votesPane);
        // statsSummaryPane.setExpandRatio(votesPane, 1f);
        // statsSummaryPane.setComponentAlignment(votesPane,
        // Alignment.MIDDLE_LEFT);

        Label votesLabel = new Label(app.getMessage("votes") + ":&nbsp;");
        votesLabel.setContentMode(Label.CONTENT_XHTML);
        votesLabel.setSizeUndefined();
        votesLabel.addStyleName("middle-left");
        // votesPane.addComponent(votesLabel);
        Label proVotes = FormatingUtils.coloredLabel(entity.getProVotes(), "336633");
        proVotes.addStyleName("middle-left");
        proVotes.setSizeUndefined();
        // votesPane.addComponent(proVotes);
        Label dash = new Label("-");
        dash.addStyleName("middle-left");
        dash.setSizeUndefined();
        // votesPane.addComponent(new Label("-"));
        Label opposedVotes = FormatingUtils.coloredLabel(entity.getOpposedVotes(), "660000");
        // votesPane.addComponent(opposedVotes);
        opposedVotes.addStyleName("middle-left");
        opposedVotes.addStyleName("right-margin-10");
        opposedVotes.setSizeUndefined();

        statsSummaryPane.addComponent(votesLabel);
        statsSummaryPane.addComponent(proVotes);
        statsSummaryPane.addComponent(dash);
        statsSummaryPane.addComponent(opposedVotes);

    }
    List<TypeRelationConfig> subtypes = appConfigManager.getSubtypesForType(entity.getComplexTypeId());
    // if (subtyesList != null) {
    if (subtypes != null) {
        Map<String, Long> firstLevelSubtypesCount = entity.getSubtypeEntitiesCount();
        Map<String, Long> allSubtypesCount = entity.getRecursiveSubtypeEntitiesCount();

        // for (String s : subtyesList) {
        // String subtype = s.toLowerCase();
        for (TypeRelationConfig trc : subtypes) {
            String targetComplexType = trc.getTargetComplexType();
            String subtype = targetComplexType.toLowerCase();
            String displayName = app.getMessage("subtype." + subtype);

            Entity refEntity = new Entity(entity.getId());

            refEntity.getState().setDesiredActionsPath(
                    targetComplexType + Defaults.getDefaultActionForEntityType(targetComplexType));
            Label subtypeLink = OpenGroupsUtil.getLinkForEntity(refEntity, app, displayName);

            String valueString = ": " + firstLevelSubtypesCount.get(subtype);

            // if (getAppConfigManager().getComplexEntityBooleanParam(s,
            // ComplexEntityParam.ALLOW_RECURSIVE_LIST)) {
            if (appConfigManager.getTypeRelationBooleanConfigParam(trc.getId(),
                    TypeRelationConfigParam.ALLOW_RECURSIVE_LIST)) {
                Long recCount = allSubtypesCount.get(subtype);
                if (recCount != null) {
                    valueString += " / " + recCount;
                }
            }
            Label sl = new Label(valueString);
            sl.setWidth(null);
            sl.addStyleName("middle-left");
            sl.addStyleName("right-margin-10");

            subtypeLink.setWidth(null);
            subtypeLink.addStyleName("middle-left");

            statsSummaryPane.addComponent(subtypeLink);
            statsSummaryPane.addComponent(sl);
            // statsSummaryPane.setExpandRatio(sl, 1f);
            // statsSummaryPane.setComponentAlignment(sl,
            // Alignment.MIDDLE_LEFT);
        }
    }

    displaySummaryActions(entity, app, statsSummaryPane, actionContext);

    // statusPane.addComponent(statsSummaryPane, 1, 0);
    // statusPane.setColumnExpandRatio(1, 1.8f);
    // statusPane.setComponentAlignment(statsSummaryPane,
    // Alignment.MIDDLE_RIGHT);

    // summaryLayout.setComponentAlignment(statsSummaryPane,
    // Alignment.MIDDLE_RIGHT);

    /* add the content */
    Object contentObj = entity.getContent();
    if (contentObj != null) {
        // content.setSizeFull();
        Panel contentContainer = new Panel();
        // CssLayout contentContainer = new CssLayout();
        contentContainer.addStyleName("text-content");
        currentContainer.addComponent(contentContainer);

        Label content = new Label(contentObj.toString());
        content.setContentMode(Label.CONTENT_XHTML);
        // content.addStyleName("text-label");
        contentContainer.addComponent(content);

        /* if the content is visible, display footer actions */
        displayFooterActions(entity, app, currentContainer, actionContext);
    }

}

From source file:ro.zg.netcell.vaadin.action.user.RequestPasswordResetHandler.java

License:Apache License

private void displaySuccessfulMessage(Window w, String messageKey) {
    VerticalLayout l = new VerticalLayout();
    l.setSizeFull();//from  w  ww  .j av a 2 s  .c o  m
    Label message = new Label(getMessage(messageKey));
    message.setWidth("60%");
    l.addComponent(message);
    l.setComponentAlignment(message, Alignment.MIDDLE_CENTER);
    w.setContent(l);
}

From source file:ro.zg.netcell.vaadin.action.user.ResetPasswordHandler.java

License:Apache License

private void displaySuccessfulMessage(Window w, String messageKey, final OpenGroupsApplication app) {
    VerticalLayout l = new VerticalLayout();
    l.setSizeFull();/*from   w ww.  j a v  a2 s.c  om*/
    Label message = new Label(getMessage(messageKey));
    message.setWidth("60%");
    l.addComponent(message);
    l.setComponentAlignment(message, Alignment.MIDDLE_CENTER);
    w.setContent(l);

    w.addListener(new CloseListener() {

        @Override
        public void windowClose(CloseEvent e) {
            app.getActiveWindow()
                    .open(new ExternalResource(OpenGroupsUtil.getUrlForEntity(app.getActiveEntity(), app)));
            /* unhide the content of the main window */
            app.getActiveWindow().setContentVisible(true);
        }
    });
}

From source file:ro.zg.opengroups.util.OpenGroupsUtil.java

License:Apache License

public static Label getLinkForEntity(Entity entity, OpenGroupsApplication app, String title) {
    //   String url = "/"+app.getAppContext().getBaseDirectory().getName()+"/";
    String url = app.getBaseAppUrl();
    String fragment = getDesiredFragmentForEntity(entity);
    Label anchor = new Label(OpenGroupsUtil.wrapAsA(url, fragment, title, "_self"), Label.CONTENT_XHTML);
    anchor.setWidth("80%");
    return anchor;
}

From source file:ro.zg.opengroups.util.OpenGroupsUtil.java

License:Apache License

public static Label getLinkForEntityWithImage(Entity entity, OpenGroupsApplication app, String imagePath) {
    String url = app.getBaseAppUrl();
    String fragment = getDesiredFragmentForEntity(entity);
    Label anchor = new Label(OpenGroupsUtil.wrapAsA(url, fragment, wrapAsImage(imagePath, app), "_self"),
            Label.CONTENT_XHTML);
    anchor.setWidth("80%");
    return anchor;
}

From source file:roart.client.MyVaadinUI.java

@Override
protected void init(VaadinRequest request) {
    final VerticalLayout layout = new VerticalLayout();
    VerticalLayout searchTab = null, controlPanelTab = null;

    com.vaadin.server.Page.getCurrent().setTitle("Aether disk search engine by Roar Throns");

    layout.setMargin(true);//from   ww w. java2s  .  co  m
    setContent(layout);

    getSession().setAttribute("addr", request.getRemoteAddr());
    getSession().setAttribute(Constants.USER, Constants.NONE);
    initVars();

    HorizontalLayout topLine = new HorizontalLayout();
    Label topTitle = new Label("Aether disk search engine");
    topTitle.setWidth("90%");
    topLine.addComponent(topTitle);
    topLine.setHeight("10%");
    topLine.setWidth("100%");
    boolean doauthenticate = (boolean) getSession().getAttribute("authenticate");
    statLabel = new Label("", ContentMode.PREFORMATTED);
    statLabel.setWidth("50%");
    topLine.addComponent(statLabel);
    if (doauthenticate) {
        Button login = getLoginButton();
        Button logout = getLogoutButton();
        topLine.addComponent(login);
        topLine.addComponent(logout);
        getSession().setAttribute("login", login);
        getSession().setAttribute("logout", logout);
    }
    layout.addComponent(topLine);

    tabsheet = new TabSheet();
    tabsheet.setHeight("80%");
    layout.addComponent(tabsheet);
    // Create the first tab
    searchTab = getSearchTab();
    getSession().setAttribute("search", searchTab);
    // This tab gets its caption from the component caption
    controlPanelTab = getControlPanelTab();
    getSession().setAttribute("controlpanel", controlPanelTab);

    tabsheet.addTab(searchTab);
    // This tab gets its caption from the component caption
    tabsheet.addTab(controlPanelTab);
    //tabsheet.addTab(statTab);

    /*
    tabsheet.addTab(miscTab);
    tabsheet.addTab(comicsTab);
    tabsheet.addTab(trainingTab);
    */

    HorizontalLayout bottomLine = new HorizontalLayout();
    bottomLine.setHeight("10%");
    bottomLine.setWidth("90%");
    Label nodeLabel = new Label("Node " + ControlService.nodename);
    bottomLine.addComponent(nodeLabel);
    Label dbLabel = new Label("Db type " + roart.util.Prop.getProp().getProperty(ConfigConstants.DB));
    //dbLabel.setWidth("30%");
    bottomLine.addComponent(dbLabel);
    Label idxLabel = new Label("Index type " + roart.util.Prop.getProp().getProperty(ConfigConstants.INDEX));
    //idxLabel.setWidth("30%");
    bottomLine.addComponent(idxLabel);
    Label licenseLabel = new Label("Affero GPL");
    //licenseLabel.setWidth("30%");
    bottomLine.addComponent(licenseLabel);
    //bottomLine.setComponentAlignment(licenseLabel, Alignment.BOTTOM_RIGHT);
    layout.addComponent(bottomLine);
    setVisibilities();
}

From source file:rs.pupin.jpo.esta_ld.EstaLdComponent.java

private void refreshDimensions() {
    // clean everything just in case
    dimLayout.removeAllComponents();/*  ww w.  j a  va  2 s . c o m*/
    geoDimension = null;
    timeDimension = null;
    measures = null;
    btnGeo = null;
    boxGeo = null;
    dimNames = null;
    dimValues = null;

    if (selectDataSet.getValue() == null)
        return;

    //        VerticalLayout lLayout = new VerticalLayout();
    //        lLayout.setSizeUndefined();
    //        lLayout.setSpacing(true);
    //        lLayout.setDebugId("dim-btn-layout");
    //        dimLayout.addComponent(lLayout);
    //        VerticalLayout rLayout = new VerticalLayout();
    //        rLayout.setSizeUndefined();
    //        rLayout.setSpacing(true);
    //        rLayout.setWidth("100%");
    //        dimLayout.addComponent(rLayout);
    //        dimLayout.setExpandRatio(rLayout, 2.0f);

    final DataSet ds = (DataSet) selectDataSet.getValue();
    measures = ds.getStructure().getMeasures();
    StringBuilder builderMeasures = new StringBuilder();
    StringBuilder builderMeasureNames = new StringBuilder();
    for (Measure m : measures) {
        builderMeasures.append(", '");
        builderMeasures.append(m.getUri());
        builderMeasures.append("'");
        if (m.getLabel() != null) {
            builderMeasureNames.append(", '");
            builderMeasureNames.append(m.getLabel());
            builderMeasureNames.append("'");
        } else {
            builderMeasureNames.append(", undefined");
        }
    }
    builderMeasureNames.replace(0, 2, "[").append("]");
    builderMeasures.replace(0, 2, "javaSetMeasures([");
    builderMeasures.append("], ").append(builderMeasureNames.toString()).append(")");
    getWindow().executeJavaScript(builderMeasures.toString());
    measName = new Button("Measure");
    //        measName.setSizeUndefined();
    //        measName.setWidth("100%");
    measName.setHeight(CONTENT_ELEM_HEIGHT);
    measName.setWidth(CONTENT_ELEM_WIDTH);
    measName.addStyleName("dim-name");
    measName.addStyleName("unselectable");
    measValues = new ComboBox(null, measures);
    measValues.setImmediate(true);
    measValues.setSizeUndefined();
    measValues.setWidth("100%");
    measValues.setHeight(CONTENT_ELEM_HEIGHT);
    measValues.addStyleName("dim-value");
    measValues.setNullSelectionAllowed(false);
    measValues.select(measures.iterator().next());
    measValues.addListener(dimListener);
    //        measValues.addListener(new Property.ValueChangeListener() {
    //            public void valueChange(Property.ValueChangeEvent event) {
    //                Measure m = (Measure)event.getProperty().getValue();
    //                // put measure in
    //            }
    //        });
    int rowIndex = 0;
    int columnIndex = 0;
    dimLayout.addComponent(measName, columnIndex, rowIndex);
    columnIndex++;
    //        dimLayout.setExpandRatio(measName, 2.0f);
    dimLayout.addComponent(measValues, columnIndex, rowIndex, columnIndex + 1, rowIndex);
    columnIndex += 2;
    //        dimLayout.setComponentAlignment(measValues, Alignment.BOTTOM_LEFT);
    LinkedList<Dimension> dimsForShow = new LinkedList<Dimension>();
    for (Dimension dim : ds.getStructure().getDimensions()) {
        if (dim.isGeoDimension())
            geoDimension = dim;
        else if (dim.isTimeDimension()) {
            timeDimension = dim;
            dimsForShow.addFirst(dim);
        } else
            dimsForShow.add(dim);
    }
    dimNames = new Button[dimsForShow.size()];
    dimAggregIndicators = new Label[dimsForShow.size()];
    dimValues = new ComboBox[dimsForShow.size()];
    int i = 0;

    StringBuilder builderPossibleValues = new StringBuilder();
    boolean firstPass = true;

    for (Dimension dim : dimsForShow) {
        // add dimension pick
        // first create a button to represent dimension name
        final Button btnName = new Button(dim.toString());
        //            btnName.setSizeUndefined();
        //            btnName.setWidth("100%");
        btnName.setHeight(CONTENT_ELEM_HEIGHT);
        btnName.setWidth(CONTENT_ELEM_WIDTH);
        btnName.setData(dim);
        btnName.addStyleName("dim-name");
        if (firstPass) {
            btnName.addStyleName("selected");
            firstPass = false;
        }
        btnName.addListener(new Button.ClickListener() {
            public void buttonClick(Button.ClickEvent event) {
                if (btnName.getStyleName().contains("selected")) {
                    btnName.removeStyleName("selected");
                } else {
                    btnName.addStyleName("selected");
                }
                freeDimensionsChanged();
            }
        });
        dimNames[i] = btnName;

        final Label btnAggreg = new Label("<span>&Sigma;</span>", Label.CONTENT_XHTML);
        btnAggreg.setWidth("30px");
        btnAggreg.setHeight(CONTENT_ELEM_HEIGHT);
        btnAggreg.setData(dim);
        btnAggreg.addStyleName("dim-name");
        btnAggreg.addStyleName("dim-aggreg");
        // this will have to go to the layout listener
        //            btnAggreg.addListener(new Button.ClickListener() {
        //                public void buttonClick(Button.ClickEvent event) {
        //                    if (btnAggreg.getStyleName().contains("selected")) {
        //                        btnAggreg.removeStyleName("selected");
        //                    } else {
        //                        btnAggreg.addStyleName("selected");
        //                        aggregDimensionsChanged();
        //                    }
        //                }
        //            });
        dimAggregIndicators[i] = btnAggreg;

        // create a combo box for picking dimension value
        Collection<Value> vals = ds.getValuesForDimension(dim);
        Collection<ValueWrapper> valsWrapped = new LinkedList<ValueWrapper>();
        for (Value v : vals)
            valsWrapped.add(new ValueWrapper(v));
        builderPossibleValues.append(",").append(stringifyCollection(vals));
        ComboBox boxValue = new ComboBox(null, valsWrapped);
        boxValue.setImmediate(true);
        boxValue.setNullSelectionAllowed(false);
        if (valsWrapped.iterator().hasNext())
            boxValue.select(valsWrapped.iterator().next());
        else
            boxValue.setEnabled(false);
        boxValue.setSizeUndefined();
        boxValue.setWidth("100%");
        boxValue.setHeight(CONTENT_ELEM_HEIGHT);
        boxValue.addStyleName("dim-value");
        boxValue.addListener(dimListener);
        dimValues[i] = boxValue;

        // put them in a horizontal layout and add to the view
        //            HorizontalLayout layout = new HorizontalLayout();
        //            layout.setSizeUndefined();
        //            layout.setWidth("100%");
        //            layout.setSpacing(true);
        //            dimLayout.addComponent(layout);
        //            dimLayout.setExpandRatio(layout, 2.0f);
        //            layout.addComponent(btnName);
        //            layout.addComponent(boxValue);
        //            layout.setExpandRatio(boxValue, 2.0f);

        //            lLayout.addComponent(btnName);
        //            lLayout.setExpandRatio(btnName, 2.0f);
        //            rLayout.addComponent(boxValue);
        //            rLayout.setComponentAlignment(boxValue, Alignment.BOTTOM_LEFT);
        dimLayout.addComponent(btnName, columnIndex, rowIndex);
        if (++columnIndex == 6) {
            columnIndex = 0;
            rowIndex++;
            dimLayout.setRows(rowIndex + 1);
        }
        dimLayout.addComponent(btnAggreg, columnIndex, rowIndex);
        if (++columnIndex == 6) {
            columnIndex = 0;
            rowIndex++;
            dimLayout.setRows(rowIndex + 1);
        }
        dimLayout.addComponent(boxValue, columnIndex, rowIndex);
        if (++columnIndex == 6) {
            columnIndex = 0;
            rowIndex++;
            dimLayout.setRows(rowIndex + 1);
        }
        i++;
    }

    if (timeDimension != null)
        getWindow().executeJavaScript("javaSetHasTimeDimension(true)");
    else
        getWindow().executeJavaScript("javaSetHasTimeDimension(false)");

    if (geoDimension != null) {
        btnGeo = new Button(geoDimension.toString());
        //            btnGeo.setSizeUndefined();
        //            btnGeo.setWidth("100%");
        btnGeo.setHeight(CONTENT_ELEM_HEIGHT);
        btnGeo.setWidth(CONTENT_ELEM_WIDTH);
        btnGeo.setData(geoDimension);
        btnGeo.addStyleName("dim-name");
        btnGeo.addStyleName("geo-name");
        btnGeo.addListener(new Button.ClickListener() {
            public void buttonClick(Button.ClickEvent event) {
                if (btnGeo.getStyleName().contains("selected")) {
                    btnGeo.removeStyleName("selected");
                } else {
                    btnGeo.addStyleName("selected");
                }
                freeDimensionsChanged();
            }
        });

        btnAggregGeo = new Label("<span>&Sigma;</span>", Label.CONTENT_XHTML);
        btnAggregGeo.setHeight(CONTENT_ELEM_HEIGHT);
        btnAggregGeo.setData(geoDimension);
        btnAggregGeo.addStyleName("dim-name");
        btnAggregGeo.addStyleName("dim-aggreg");

        StringBuilder builder = new StringBuilder();
        Collection<Value> posVals = ds.getValuesForDimension(geoDimension);
        Collection<ValueWrapper> posValsWrapped = new LinkedList<ValueWrapper>();
        for (Value v : posVals)
            posValsWrapped.add(new ValueWrapper(v));
        Value selectedVal = posVals.iterator().next();
        String selectedValString = "";
        if (selectedVal instanceof URI) {
            selectedValString = "<" + selectedVal.stringValue() + ">";
        } else {
            selectedValString = "\"" + selectedVal.stringValue() + "\"";
            URI dataType = ((Literal) selectedVal).getDatatype();
            if (dataType != null && !dataType.stringValue().contains("string")) {
                selectedValString += "^^<" + dataType.stringValue() + ">";
            }
        }
        builder.append("javaSetGeoAll('").append(geoDimension.getUri());
        builder.append("',").append(stringifyCollection(posVals));
        builder.append(",'").append(selectedValString).append("',true)");
        boxGeo = new ComboBox(null, posValsWrapped);
        boxGeo.setData(posVals);
        boxGeo.setImmediate(true);
        boxGeo.setNullSelectionAllowed(false);
        boxGeo.select(posValsWrapped.iterator().next());
        boxGeo.setSizeUndefined();
        boxGeo.setWidth("100%");
        boxGeo.setHeight(CONTENT_ELEM_HEIGHT);
        boxGeo.addStyleName("geo-value");
        boxGeo.addListener(geoListener);
        //            lLayout.addComponent(btnGeo);
        //            lLayout.setExpandRatio(btnGeo, 2.0f);
        //            rLayout.addComponent(boxGeo);
        //            rLayout.setComponentAlignment(boxGeo, Alignment.BOTTOM_LEFT);
        dimLayout.addComponent(btnGeo, columnIndex, rowIndex);
        columnIndex++;
        dimLayout.addComponent(btnAggregGeo, columnIndex, rowIndex);
        columnIndex++;
        dimLayout.addComponent(boxGeo, columnIndex, rowIndex);
        columnIndex++;

        getWindow().executeJavaScript(builder.toString());
    } else {
        getWindow().executeJavaScript("javaSetGeoAll('',[],'',true)");
    }
    // TODO cover the case where there is more than 1 geo dimension

    builderPossibleValues.replace(0, 1, "javaSetPossibleValues([");
    builderPossibleValues.append("])");
    getWindow().executeJavaScript(builderPossibleValues.toString());
    if (dimsForShow.isEmpty()) {
        if (geoDimension != null)
            getWindow().executeJavaScript("javaSetGeoFree(true)");
        else
            getWindow().executeJavaScript("javaSetGeoFree(false)");
        getWindow().executeJavaScript("javaSetFreeDimensions([], true)");
    } else {
        getWindow().executeJavaScript("javaSetGeoFree(false)");
        getWindow().executeJavaScript("javaSetFreeDimensions([0], true)");
    }
    dimListener.valueChange(null);
    getWindow().executeJavaScript("setTimeout(expandDimNameButtons(),200)");
}

From source file:rs.pupin.jpo.validation.gui.constraints.FailedQueryWindow.java

@Override
public void attach() {
    super.attach();
    String message = (query2 == null) ? messageSingleQuery : messageDoubleQuery;
    Label lbl = new Label(message);
    lbl.setWidth("95%");
    layout.addComponent(lbl);//from w  w  w .  j a v a 2 s . c o  m
    layout.setExpandRatio(lbl, 0.0f);

    String textAreaCaption = (query2 != null) ? "First Query" : "Query";
    TextArea textArea = new TextArea(textAreaCaption);
    textArea.setValue(query1);
    textArea.setReadOnly(true);
    textArea.setSizeFull();
    layout.addComponent(textArea);
    layout.setExpandRatio(textArea, 2.0f);

    if (query2 != null) {
        TextArea textArea2 = new TextArea("Second Query");
        textArea2.setValue(query2);
        textArea2.setReadOnly(true);
        textArea2.setSizeFull();
        layout.addComponent(textArea2);
        layout.setExpandRatio(textArea2, 2.0f);
    }

    center();
}

From source file:ru.codeinside.adm.ui.employee.TableEmployee.java

License:Mozilla Public License

public static TextField addTextField(AbstractComponentContainer container, String widthColumn, String content) {
    HorizontalLayout l;// w  w w  . j  a va2  s .c om
    l = new HorizontalLayout();
    Label label = new Label(content);
    label.setWidth(widthColumn);
    l.addComponent(label);
    l.setComponentAlignment(label, Alignment.MIDDLE_LEFT);
    final TextField field = new TextField();
    l.addComponent(field);
    container.addComponent(l);
    return field;
}