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(float width, Unit unit) 

Source Link

Usage

From source file:me.uni.emuseo.view.login.LoginView.java

License:Open Source License

public LoginView() {
    this.setSizeFull();
    Label titleLabel = new Label("<h1>e<strong>Museo</strong></h1>", ContentMode.HTML);
    loginLayout = new LoginLayout();
    addComponent(titleLabel);//from   www.j  a v  a2 s.  c om
    addComponent(loginLayout);
    titleLabel.setWidth(150, Unit.PIXELS);
    setExpandRatio(titleLabel, 0);
    setExpandRatio(loginLayout, 1);
    setComponentAlignment(titleLabel, Alignment.BOTTOM_CENTER);
    setComponentAlignment(loginLayout, Alignment.TOP_CENTER);
}

From source file:org.activiti.explorer.ui.mainlayout.MainLayout.java

License:Apache License

protected void initFooter() {
    footer = new CssLayout();
    footer.setWidth(100, UNITS_PERCENTAGE);
    footer.addStyleName(ExplorerLayout.STYLE_MAIN_FOOTER);
    addComponent(footer);/*from   www  .j  a  va  2 s . c  o m*/

    Label footerLabel = new Label();
    footerLabel.setContentMode(Label.CONTENT_XHTML);
    footerLabel.setValue(i18nManager.getMessage(Messages.FOOTER_MESSAGE));
    footerLabel.setWidth(100, UNITS_PERCENTAGE);
    footer.addComponent(footerLabel);
}

From source file:org.activiti.explorer.ui.management.db.DatabaseDetailPanel.java

License:Apache License

protected void addTableName() {
    HorizontalLayout header = new HorizontalLayout();
    header.setWidth(100, UNITS_PERCENTAGE);
    header.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK);
    header.setSpacing(true);/*from   w  w w .  j a  va2s .  c om*/

    // TODO: use right image
    Embedded image = new Embedded(null, Images.DATABASE_50);
    header.addComponent(image);
    header.setComponentAlignment(image, Alignment.MIDDLE_LEFT);
    header.setMargin(false, false, true, false);

    Label name = new Label(tableName);
    name.addStyleName(Reindeer.LABEL_H2);
    header.addComponent(name);

    header.setExpandRatio(name, 1.0f);
    header.setComponentAlignment(name, Alignment.MIDDLE_LEFT);
    addDetailComponent(header);

    Label spacer = new Label();
    spacer.setWidth(100, UNITS_PERCENTAGE);
    spacer.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
    addDetailComponent(spacer);
}

From source file:org.activiti.explorer.ui.management.deployment.DeploymentDetailPanel.java

License:Apache License

protected void addProcessDefinitionLinks() {
    List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery()
            .deploymentId(deployment.getId()).orderByProcessDefinitionName().asc().list();

    if (!processDefinitions.isEmpty()) {

        // Header
        Label processDefinitionHeader = new Label(
                i18nManager.getMessage(Messages.DEPLOYMENT_HEADER_DEFINITIONS));
        processDefinitionHeader.addStyleName(ExplorerLayout.STYLE_H3);
        processDefinitionHeader.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
        processDefinitionHeader.setWidth(100, UNITS_PERCENTAGE);
        addDetailComponent(processDefinitionHeader);

        // processes
        VerticalLayout processDefinitionLinksLayout = new VerticalLayout();
        processDefinitionLinksLayout.setSpacing(true);
        processDefinitionLinksLayout.setMargin(true, false, true, false);
        addDetailComponent(processDefinitionLinksLayout);

        for (final ProcessDefinition processDefinition : processDefinitions) {
            Button processDefinitionButton = new Button(getProcessDisplayName(processDefinition));
            processDefinitionButton.addListener(new ClickListener() {
                public void buttonClick(ClickEvent event) {
                    viewManager.showDeployedProcessDefinitionPage(processDefinition.getId());
                }// w w w.ja v a 2 s  . c o m
            });
            processDefinitionButton.addStyleName(Reindeer.BUTTON_LINK);
            processDefinitionLinksLayout.addComponent(processDefinitionButton);
        }
    }
}

From source file:org.activiti.explorer.ui.management.job.JobDetailPanel.java

License:Apache License

protected void addJobState() {
    Label processDefinitionHeader = new Label(i18nManager.getMessage(Messages.JOB_HEADER_EXECUTION));
    processDefinitionHeader.addStyleName(ExplorerLayout.STYLE_H3);
    processDefinitionHeader.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
    processDefinitionHeader.setWidth(100, UNITS_PERCENTAGE);
    addComponent(processDefinitionHeader);

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);//from  w w  w .jav a2s .  c  o m
    layout.setSizeFull();
    layout.setMargin(true, false, true, false);

    addDetailComponent(layout);
    setDetailExpandRatio(layout, 1.0f);

    // Exceptions
    if (job.getExceptionMessage() != null) {
        // Number of retries
        Label retrieslabel = new Label(getRetriesLabel(job));
        layout.addComponent(retrieslabel);

        // Exception
        Label exceptionMessageLabel = new Label(
                i18nManager.getMessage(Messages.JOB_ERROR) + ": " + job.getExceptionMessage());
        exceptionMessageLabel.addStyleName(ExplorerLayout.STYLE_JOB_EXCEPTION_MESSAGE);
        layout.addComponent(exceptionMessageLabel);

        // Add Exception stacktrace
        String stack = managementService.getJobExceptionStacktrace(job.getId());

        Label stackTraceLabel = new Label(stack);
        stackTraceLabel.setContentMode(Label.CONTENT_PREFORMATTED);
        stackTraceLabel.addStyleName(ExplorerLayout.STYLE_JOB_EXCEPTION_TRACE);
        stackTraceLabel.setSizeFull();

        Panel stackPanel = new Panel();
        stackPanel.setWidth(100, UNITS_PERCENTAGE);
        stackPanel.setSizeFull();
        stackPanel.setScrollable(true);
        stackPanel.addComponent(stackTraceLabel);

        layout.addComponent(stackPanel);
        layout.setExpandRatio(stackPanel, 1.0f);
    } else {

        if (job.getProcessDefinitionId() != null) {

            // This is a hack .. need to cleanify this in the engine
            JobEntity jobEntity = (JobEntity) job;
            if (jobEntity.getJobHandlerType().equals(TimerSuspendProcessDefinitionHandler.TYPE)) {
                addLinkToProcessDefinition(layout,
                        i18nManager.getMessage(Messages.JOB_SUSPEND_PROCESSDEFINITION), false);
            } else if (jobEntity.getJobHandlerType().equals(TimerActivateProcessDefinitionHandler.TYPE)) {
                addLinkToProcessDefinition(layout,
                        i18nManager.getMessage(Messages.JOB_ACTIVATE_PROCESSDEFINITION), true);
            } else {
                addNotYetExecutedLabel(layout);
            }

        } else {

            addNotYetExecutedLabel(layout);

        }
    }
}

From source file:org.activiti.explorer.ui.profile.ProfilePanel.java

License:Apache License

protected void initUi() {
    removeAllComponents();//from   w  w w.  j  av  a  2s  . c  om
    addStyleName(Reindeer.PANEL_LIGHT);
    addStyleName(ExplorerLayout.STYLE_PROFILE_LAYOUT);
    setSizeFull();

    // Profile page is a horizontal layout: left we have a panel with the picture, 
    // and one the right there is another panel the about, contact, etc information
    this.profilePanelLayout = new HorizontalLayout();
    profilePanelLayout.setSizeFull();
    setContent(profilePanelLayout);

    // init both panels
    initImagePanel();

    Label emptySpace = new Label("&nbsp;", Label.CONTENT_XHTML);
    emptySpace.setWidth(50, UNITS_PIXELS);
    profilePanelLayout.addComponent(emptySpace);

    initInformationPanel();
}

From source file:org.activiti.explorer.ui.profile.ProfilePanel.java

License:Apache License

protected Label createProfileHeader(VerticalLayout infoLayout, String headerName) {
    Label label = new Label(headerName);
    label.setWidth(100, UNITS_PERCENTAGE);
    label.addStyleName(ExplorerLayout.STYLE_H3);
    return label;
}

From source file:org.bubblecloud.ilves.ui.user.privilege.PrivilegesFlowlet.java

License:Apache License

private void refreshGroupMatrix() {
    final EntityManager entityManager = Site.getCurrent().getSiteContext().getObject(EntityManager.class);
    final Company company = Site.getCurrent().getSiteContext().getObject(Company.class);

    if (groupMatrix != null) {
        matrixLayout.removeComponent(groupMatrix);
    }//from   w w w  .j  av  a 2 s.  co m
    final List<Group> groups = UserDao.getGroups(entityManager, company);

    groupCheckBoxes = new CheckBox[privilegeKeys.length * groups.size()];
    groupMatrix = new GridLayout(privilegeKeys.length + 1, groups.size() + 1);
    matrixLayout.addComponent(groupMatrix);
    for (int i = 0; i < groupCheckBoxes.length; i++) {
        groupCheckBoxes[i] = new CheckBox();
        groupCheckBoxes[i].setImmediate(true);
        groupCheckBoxes[i].addValueChangeListener(new Property.ValueChangeListener() {
            @Override
            public void valueChange(Property.ValueChangeEvent event) {
                dirty = true;
                saveButton.setEnabled(true);
                discardButton.setEnabled(true);
            }
        });
    }

    groupMatrix.addComponent(new Label("<b>" + getSite().localize("label-group") + "</b>", ContentMode.HTML), 0,
            0);

    for (int j = 0; j < groups.size(); j++) {
        final Label label = new Label(groups.get(j).getDescription());
        label.setWidth(200, Unit.PIXELS);
        groupMatrix.addComponent(label, 0, j + 1);
    }

    for (int i = 0; i < privilegeKeys.length; i++) {
        final Label label = new Label("<b>" + getSite().localize("privilege-" + privilegeKeys[i]) + "</b>",
                ContentMode.HTML);
        label.setWidth(50, Unit.PIXELS);
        groupMatrix.addComponent(label, i + 1, 0);
    }

    for (int i = 0; i < privilegeKeys.length; i++) {
        for (int j = 0; j < groups.size(); j++) {
            final int checkBoxIndex = i + j * privilegeKeys.length;
            groupMatrix.addComponent(groupCheckBoxes[checkBoxIndex], i + 1, j + 1);
            groupCheckBoxes[checkBoxIndex].setValue(
                    UserDao.hasGroupPrivilege(entityManager, groups.get(j), privilegeKeys[i], dataId));
        }
    }
    dirty = false;
    saveButton.setEnabled(false);
    discardButton.setEnabled(false);
}

From source file:org.bubblecloud.ilves.ui.user.privilege.PrivilegesFlowlet.java

License:Apache License

private void refreshUserMatrix() {
    final EntityManager entityManager = Site.getCurrent().getSiteContext().getObject(EntityManager.class);
    final Company company = Site.getCurrent().getSiteContext().getObject(Company.class);

    if (userMatrix != null) {
        matrixLayout.removeComponent(userMatrix);
    }//from  w ww  .  ja  v  a2s.  co  m
    final List<User> users = UserDao.getUsers(entityManager, company);

    userCheckBoxes = new CheckBox[privilegeKeys.length * users.size()];
    userMatrix = new GridLayout(privilegeKeys.length + 1, users.size() + 1);
    matrixLayout.addComponent(userMatrix);
    for (int i = 0; i < userCheckBoxes.length; i++) {
        userCheckBoxes[i] = new CheckBox();
        userCheckBoxes[i].setImmediate(true);
        userCheckBoxes[i].addValueChangeListener(new Property.ValueChangeListener() {
            @Override
            public void valueChange(Property.ValueChangeEvent event) {
                dirty = true;
                saveButton.setEnabled(true);
                discardButton.setEnabled(true);
            }
        });
    }

    userMatrix.addComponent(new Label("<b>" + getSite().localize("label-user") + "</b>", ContentMode.HTML), 0,
            0);

    for (int j = 0; j < users.size(); j++) {
        final Label label = new Label(users.get(j).getLastName() + " " + users.get(j).getFirstName());
        label.setWidth(200, Unit.PIXELS);
        userMatrix.addComponent(label, 0, j + 1);
    }

    for (int i = 0; i < privilegeKeys.length; i++) {
        final Label label = new Label("<b>" + getSite().localize("privilege-" + privilegeKeys[i]) + "</b>",
                ContentMode.HTML);
        label.setWidth(50, Unit.PIXELS);
        userMatrix.addComponent(label, i + 1, 0);
    }

    for (int i = 0; i < privilegeKeys.length; i++) {
        for (int j = 0; j < users.size(); j++) {
            final int checkBoxIndex = i + j * privilegeKeys.length;
            userMatrix.addComponent(userCheckBoxes[checkBoxIndex], i + 1, j + 1);
            userCheckBoxes[checkBoxIndex]
                    .setValue(UserDao.hasUserPrivilege(entityManager, users.get(j), privilegeKeys[i], dataId));
        }
    }
    dirty = false;
    saveButton.setEnabled(false);
    discardButton.setEnabled(false);
}

From source file:org.eclipse.skalli.view.ext.impl.internal.infobox.ProjectMavenBox.java

License:Open Source License

@Override
public Component getContent(Project project, ExtensionUtil util) {
    Layout layout = new CssLayout();
    layout.addStyleName(STYLE_MAVEN_INFOBOX);
    layout.setSizeFull();//from w  ww .j ava 2 s  . c  om

    boolean rendered = false;
    String groupId = null;
    MavenReactorProjectExt reactorExt = project.getExtension(MavenReactorProjectExt.class);
    if (reactorExt != null) {
        MavenReactor mavenReactor = reactorExt.getMavenReactor();
        if (mavenReactor != null) {
            MavenCoordinate coordinate = mavenReactor.getCoordinate();
            groupId = coordinate.getGroupId();
            createLabel(layout, "GroupId: <b>" + groupId + "</b>");//$NON-NLS-1$ //$NON-NLS-2$
            createLabel(layout, "ArtifactId: <b>" + coordinate.getArtefactId() + "</b>");//$NON-NLS-1$ //$NON-NLS-2$
            TreeSet<MavenModule> modules = mavenReactor.getModules();
            StringBuilder sb = new StringBuilder();

            if (modules.size() > 0) {
                int lineLength = 0;
                for (MavenModule module : modules) {
                    //create popup with xml snippet
                    sb.append("<dependency>\n");
                    sb.append("    <artifactId>" + module.getArtefactId() + "</artifactId>\n");
                    sb.append("    <groupId>" + module.getGroupId() + "</groupId>\n");
                    String latestVersion = module.getLatestVersion();
                    if (StringUtils.isNotBlank(latestVersion)) {
                        sb.append("    <version>" + latestVersion + "</version>\n");
                    } else {
                        sb.append("    <!--<version>0.0.0</version>-->\n");
                    }
                    String packaging = module.getPackaging();
                    if (StringUtils.isNotBlank(packaging)) {
                        sb.append("    <type>" + packaging + "</type>\n");
                    }
                    sb.append("</dependency>\n");
                    lineLength = calculateLineLength(module, lineLength);
                }

                final Label label = new Label(sb.toString(), Label.CONTENT_PREFORMATTED);
                //add a buffer 10, as we didn't calculate the length of surrounding strings.
                label.setWidth(lineLength + 10, Sizeable.UNITS_EM);

                PopupView.Content content = new PopupView.Content() {
                    private static final long serialVersionUID = -8362267064485433525L;

                    @Override
                    public String getMinimizedValueAsHTML() {
                        return "Modules";
                    }

                    @Override
                    public Component getPopupComponent() {
                        return label;
                    }
                };

                PopupView popup = new PopupView(content);
                popup.setHideOnMouseOut(false);
                popup.addStyleName(STYLE_MODULE_POPUP);
                layout.addComponent(popup);
            }
            rendered = true;
        }
    }
    MavenProjectExt mavenExt = project.getExtension(MavenProjectExt.class);
    if (mavenExt != null) {
        if (groupId == null) {
            groupId = mavenExt.getGroupID();
            if (StringUtils.isNotBlank(groupId)) {
                createLabel(layout, "GroupId: <b>&nbsp;" + groupId + "</b>");//$NON-NLS-1$ //$NON-NLS-2$
                rendered = true;
            }
        }
        DevInfProjectExt devInf = project.getExtension(DevInfProjectExt.class);
        if (devInf != null) {
            String reactorPomUrl = getReactorPomUrl(project, devInf, mavenExt);
            if (reactorPomUrl == null) {
                String reactorPomPath = mavenExt.getReactorPOM();
                String caption = MessageFormat.format("Reactor POM Path: {0} (relative to SCM root location)",
                        StringUtils.isNotBlank(reactorPomPath) ? reactorPomPath : "/");
                createLabel(layout, caption);
            } else {
                createLink(layout, "Reactor POM", reactorPomUrl);
            }
            rendered = true;
        }
        if (StringUtils.isNotBlank(mavenExt.getSiteUrl())) {
            createLink(layout, "Project Site", mavenExt.getSiteUrl());
            rendered = true;
        }
    }
    if (!rendered) {
        createLabel(layout, "Maven extension added but no data maintained.");
    }
    return layout;
}