Example usage for com.vaadin.ui Panel setCaption

List of usage examples for com.vaadin.ui Panel setCaption

Introduction

In this page you can find the example usage for com.vaadin.ui Panel setCaption.

Prototype

@Override
    public void setCaption(String caption) 

Source Link

Usage

From source file:org.semanticsoft.vaaclipse.presentation.renderers.WorkbenchWindowRenderer.java

License:Open Source License

@Override
public void createWidget(MUIElement element, MElementContainer<MUIElement> parent) {
    if (element instanceof MWindow) {
        final MWindow mWindow = (MWindow) element;
        Component currentMainWindow = vaadinUI.getContent();
        if (element.getTags().contains(Tags.MAIN_WINDOW)) {
            Panel window = new Panel();
            window.setContent(new TrimmedWindowContent());
            vaadinUI.getPage().setTitle(mWindow.getLocalizedLabel());
            element.setWidget(window);/*from   w w w  .jav  a 2  s.  c o  m*/
            ((MWindow) element).getContext().set(Panel.class, window);
            window.setSizeFull();

            vaadinUI.setContent(window);

            app.setSelectedElement(mWindow);
            mWindow.getContext().activate();
        } else {// case child windows
            if (currentMainWindow != null) {
                Window window = new Window();
                window.setContent(new TrimmedWindowContent());
                window.setImmediate(true);
                window.setPositionX(mWindow.getX());
                window.setPositionY(mWindow.getY());
                window.setWidth(mWindow.getWidth(), Unit.PIXELS);
                window.setHeight(mWindow.getHeight(), Unit.PIXELS);
                window.setCaption(mWindow.getLocalizedLabel());
                element.setWidget(window);
                ((MWindow) element).getContext().set(Panel.class, window);
                vaadinUI.addWindow(window);
            } else {
                throw new IllegalStateException(
                        "Can not add child window because application has not main window");
            }
        }

        IEclipseContext localContext = getContext(element);
        localContext.set(ISaveHandler.class, new ISaveHandler() {
            public Save promptToSave(MPart dirtyPart) {
                // Object[] elements =
                // promptForSave(Collections.singleton(dirtyPart));
                // if (elements == null) {
                // return Save.CANCEL;
                // }
                // return elements.length == 0 ? Save.NO : Save.YES;

                if (saveCandidate == null) {
                    saveCandidate = dirtyPart;

                    PartRenderer partRenderer = (PartRenderer) saveCandidate.getRenderer();
                    SavePromptSetup setup = partRenderer.getSavePromptSetup(saveCandidate);
                    String caption = setup.getCaption() != null ? setup.getCaption() : "Save";
                    String msg = setup.getMessage() != null ? setup.getMessage()
                            : String.format("%s has been modified. Save changes?",
                                    saveCandidate instanceof MInputPart
                                            ? ((MInputPart) saveCandidate).getInputURI()
                                            : "Data");

                    OptionDialog.show(vaadinUI, caption, msg, new String[] { "Yes", "No", "Cancel" }, 400, 80,
                            Component.UNITS_PIXELS, new OptionDialog.OptionListener() {

                                @Override
                                public void optionSelected(OptionDialog dlg, int optionId) {
                                    switch (optionId) {
                                    case 0:
                                        s = Save.YES;
                                        break;
                                    case 1:
                                        s = Save.NO;
                                        break;
                                    case 2:
                                        s = Save.CANCEL;
                                        break;

                                    default:
                                        s = null;
                                    }

                                    if (partService.savePart(saveCandidate, true)) {
                                        partService.hidePart(saveCandidate);
                                    }
                                    saveCandidate = null;
                                    dlg.close();
                                }
                            });

                    return Save.CANCEL;
                } else {
                    return s;
                }

            }

            public Save[] promptToSave(Collection<MPart> dirtyParts) {
                // List<MPart> parts = new ArrayList<MPart>(dirtyParts);
                //
                // Save[] response = new Save[dirtyParts.size()];
                // Object[] elements = promptForSave(parts);
                // if (elements == null) {
                // Arrays.fill(response, Save.CANCEL);
                // } else {
                // Arrays.fill(response, Save.NO);
                // for (int i = 0; i < elements.length; i++) {
                // response[parts.indexOf(elements[i])] = Save.YES;
                // }
                // }
                // return response;

                throw new RuntimeException("Multiple saving is not implemented yet");
            }
        });
    }
}

From source file:org.sensorhub.ui.SWECommonFormBuilder.java

License:Mozilla Public License

protected Component buildWidget(DataComponent dataComponent) {
    if (dataComponent instanceof DataRecord) {
        DataRecord dataRecord = (DataRecord) dataComponent;
        FormLayout layout = new FormLayout();

        for (int i = 0; i < dataRecord.getComponentCount(); i++) {
            DataComponent c = dataRecord.getComponent(i);
            Component w = buildWidget(c);
            if (w != null)
                layout.addComponent(w);/*from   w  w w.j a v a2  s . c  o m*/
        }

        Panel panel = new Panel();
        panel.setCaption(getPrettyName(dataComponent));
        panel.setContent(layout);
        return panel;
    }

    else if (dataComponent instanceof DataArray) {
        DataArray dataArray = (DataArray) dataComponent;
        VerticalLayout layout = new VerticalLayout();
        layout.addComponent(new Label(getPrettyName(dataArray)));
        layout.addComponent(buildWidget(dataArray.getElementType()));
        return layout;
    }

    else if (dataComponent instanceof DataChoice) {

    }

    else if (dataComponent instanceof Quantity) {
        Label c = new Label();
        c.setCaption(getPrettyName(dataComponent));
        c.setDescription(dataComponent.getDescription());
        return c;
    }

    return null;
}

From source file:org.vaadin.addons.sitekit.viewlet.anonymous.login.LoginFlowlet.java

License:Apache License

@SuppressWarnings("serial")
@Override/*from   w w  w.j  a  va2  s .  co  m*/
public void initialize() {

    final VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);

    final Company company = getSite().getSiteContext().getObject(Company.class);
    if (company.isOpenIdLogin()) {
        final Panel openIdPanel = new Panel();
        openIdPanel.setStyleName(Reindeer.PANEL_LIGHT);
        openIdPanel.setCaption("OpenID Login");
        layout.addComponent(openIdPanel);
        final HorizontalLayout openIdLayout = new HorizontalLayout();
        openIdPanel.setContent(openIdLayout);
        openIdLayout.setMargin(new MarginInfo(false, false, true, false));
        openIdLayout.setSpacing(true);
        final String returnViewName = "openidlogin";
        final Map<String, String> urlIconMap = OpenIdUtil.getOpenIdProviderUrlIconMap();
        for (final String url : urlIconMap.keySet()) {
            openIdLayout.addComponent(OpenIdUtil.getLoginButton(url, urlIconMap.get(url), returnViewName));
        }
    }

    loginForm = new LoginForm() {
        @Override
        public String getLoginHTML() {
            return super.getLoginHTML().replace("<input class='v-textfield v-widget' style='display:block;'",
                    "<input class='v-textfield v-widget' style='margin-bottom:10px; display:block;'");
        }
    };

    loginForm.setLoginButtonCaption(getSite().localize("button-login"));
    loginForm.setUsernameCaption(getSite().localize("input-user-name"));
    loginForm.setPasswordCaption(getSite().localize("input-user-password"));
    loginForm.addListener(this);

    layout.addComponent(loginForm);

    final Button registerButton = new Button(getSite().localize("button-register") + " >>");
    registerButton.addListener(new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            getFlow().forward(RegisterFlowlet.class);
        }
    });
    layout.addComponent(registerButton);

    if (company.isEmailPasswordReset()) {
        final Button forgotPasswordButton = new Button(getSite().localize("button-forgot-password") + " >>");
        forgotPasswordButton.addListener(new ClickListener() {
            @Override
            public void buttonClick(final ClickEvent event) {
                getFlow().forward(ForgotPasswordFlowlet.class);
            }
        });
        layout.addComponent(forgotPasswordButton);
    }

    setViewContent(layout);

}

From source file:org.vaadin.addons.sitekit.viewlet.user.AccountFlowlet.java

License:Apache License

@Override
public void initialize() {
    final List<FieldDescriptor> fieldDefinitions = SiteFields.getFieldDescriptors(Customer.class);

    final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>();
    filterDefinitions.add(new FilterDescriptor("companyName", "companyName", "Company Name", new TextField(),
            101, "=", String.class, ""));
    filterDefinitions.add(new FilterDescriptor("lastName", "lastName", "Last Name", new TextField(), 101, "=",
            String.class, ""));

    final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class);
    entityContainer = new EntityContainer<Customer>(entityManager, true, false, false, Customer.class, 1000,
            new String[] { "companyName", "lastName" }, new boolean[] { false, false }, "customerId");

    for (final FieldDescriptor fieldDefinition : fieldDefinitions) {
        entityContainer.addContainerProperty(fieldDefinition.getId(), fieldDefinition.getValueType(),
                fieldDefinition.getDefaultValue(), fieldDefinition.isReadOnly(), fieldDefinition.isSortable());
    }/*w  w  w .j a v  a2s  .c o m*/

    final GridLayout gridLayout = new GridLayout(1, 6);
    gridLayout.setRowExpandRatio(0, 0.0f);
    gridLayout.setRowExpandRatio(1, 0.0f);
    gridLayout.setRowExpandRatio(2, 0.0f);
    gridLayout.setRowExpandRatio(3, 0.0f);
    gridLayout.setRowExpandRatio(4, 0.0f);
    gridLayout.setRowExpandRatio(5, 1.0f);

    gridLayout.setSizeFull();
    gridLayout.setMargin(false);
    gridLayout.setSpacing(true);
    gridLayout.setRowExpandRatio(4, 1f);
    setViewContent(gridLayout);

    final HorizontalLayout userAccountTitle = new HorizontalLayout();
    userAccountTitle.setMargin(new MarginInfo(false, false, false, false));
    userAccountTitle.setSpacing(true);
    final Embedded userAccountTitleIcon = new Embedded(null, getSite().getIcon("view-icon-user"));
    userAccountTitleIcon.setWidth(32, UNITS_PIXELS);
    userAccountTitleIcon.setHeight(32, UNITS_PIXELS);
    userAccountTitle.addComponent(userAccountTitleIcon);
    final Label userAccountTitleLabel = new Label("<h2>User Account</h2>", Label.CONTENT_XHTML);
    userAccountTitle.addComponent(userAccountTitleLabel);
    gridLayout.addComponent(userAccountTitle, 0, 0);

    final HorizontalLayout titleLayout = new HorizontalLayout();
    titleLayout.setMargin(new MarginInfo(true, false, false, false));
    titleLayout.setSpacing(true);
    final Embedded titleIcon = new Embedded(null, getSite().getIcon("view-icon-customer"));
    titleIcon.setWidth(32, UNITS_PIXELS);
    titleIcon.setHeight(32, UNITS_PIXELS);
    titleLayout.addComponent(titleIcon);
    final Label titleLabel = new Label("<h2>Customer Accounts</h2>", Label.CONTENT_XHTML);
    titleLayout.addComponent(titleLabel);
    gridLayout.addComponent(titleLayout, 0, 3);

    final Table table = new Table();
    table.setPageLength(10);
    entityGrid = new Grid(table, entityContainer);
    entityGrid.setFields(fieldDefinitions);
    entityGrid.setFilters(filterDefinitions);
    //entityGrid.setFixedWhereCriteria("e.owner.companyId=:companyId");

    table.setColumnCollapsed("created", true);
    table.setColumnCollapsed("modified", true);
    table.setColumnCollapsed("company", true);
    gridLayout.addComponent(entityGrid, 0, 5);

    final Button editUserButton = new Button("Edit User Account");
    editUserButton.setIcon(getSite().getIcon("button-icon-edit"));
    gridLayout.addComponent(editUserButton, 0, 2);
    editUserButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final User entity = ((SecurityProviderSessionImpl) getSite().getSecurityProvider())
                    .getUserFromSession();
            final UserAccountFlowlet customerView = getFlow().getFlowlet(UserAccountFlowlet.class);
            customerView.edit(entity, false);
            getFlow().forward(UserAccountFlowlet.class);
        }
    });

    final Company company = getSite().getSiteContext().getObject(Company.class);
    if (company.isOpenIdLogin()) {
        final Panel openIdPanel = new Panel();
        openIdPanel.setStyleName(Reindeer.PANEL_LIGHT);
        openIdPanel.setCaption("Choose OpenID Provider:");
        gridLayout.addComponent(openIdPanel, 0, 1);
        final HorizontalLayout openIdLayout = new HorizontalLayout();
        openIdPanel.setContent(openIdLayout);
        openIdLayout.setMargin(new MarginInfo(false, false, true, false));
        openIdLayout.setSpacing(true);
        final String returnViewName = "openidlink";
        final Map<String, String> urlIconMap = OpenIdUtil.getOpenIdProviderUrlIconMap();
        for (final String url : urlIconMap.keySet()) {
            openIdLayout.addComponent(OpenIdUtil.getLoginButton(url, urlIconMap.get(url), returnViewName));
        }
    }

    final HorizontalLayout customerButtonsLayout = new HorizontalLayout();
    gridLayout.addComponent(customerButtonsLayout, 0, 4);
    customerButtonsLayout.setMargin(false);
    customerButtonsLayout.setSpacing(true);

    final Button editCustomerDetailsButton = new Button("Edit Customer Details");
    customerButtonsLayout.addComponent(editCustomerDetailsButton);
    editCustomerDetailsButton.setEnabled(false);
    editCustomerDetailsButton.setIcon(getSite().getIcon("button-icon-edit"));
    editCustomerDetailsButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final Customer entity = entityContainer.getEntity(entityGrid.getSelectedItemId());
            final CustomerFlowlet customerView = getFlow().forward(CustomerFlowlet.class);
            customerView.edit(entity, false);
        }
    });

    final Button editCustomerMembersButton = new Button("Edit Customer Members");
    customerButtonsLayout.addComponent(editCustomerMembersButton);
    editCustomerMembersButton.setEnabled(false);
    editCustomerMembersButton.setIcon(getSite().getIcon("button-icon-edit"));
    editCustomerMembersButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final Customer entity = entityContainer.getEntity(entityGrid.getSelectedItemId());
            final GroupFlowlet view = getFlow().forward(GroupFlowlet.class);
            view.edit(entity.getMemberGroup(), false);
        }
    });

    final Button editCustomerAdminsButton = new Button("Edit Customer Admins");
    customerButtonsLayout.addComponent(editCustomerAdminsButton);
    editCustomerAdminsButton.setEnabled(false);
    editCustomerAdminsButton.setIcon(getSite().getIcon("button-icon-edit"));
    editCustomerAdminsButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final Customer entity = entityContainer.getEntity(entityGrid.getSelectedItemId());
            final GroupFlowlet view = getFlow().forward(GroupFlowlet.class);
            view.edit(entity.getAdminGroup(), false);
        }
    });

    table.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(final Property.ValueChangeEvent event) {
            editCustomerDetailsButton.setEnabled(table.getValue() != null);
            editCustomerMembersButton.setEnabled(table.getValue() != null);
            editCustomerAdminsButton.setEnabled(table.getValue() != null);
        }
    });

}

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

License:Mozilla Public License

public CertificateBlock(UserItem userItem) {
    this.x509 = userItem.getX509();
    Component root = new HorizontalLayout();
    if (x509 != null) {
        X509Certificate x509Certificate = X509.decode(x509);
        if (x509Certificate != null) {
            HorizontalLayout h = new HorizontalLayout();
            h.setSpacing(true);//from ww w .  j  a  v a2 s .  c o m
            h.setMargin(true);
            h.setSizeUndefined();

            NameParts subjectParts = X509.getSubjectParts(x509Certificate);

            Label certLabel = new Label(subjectParts.getShortName());
            h.addComponent(certLabel);
            h.setComponentAlignment(certLabel, Alignment.MIDDLE_CENTER);

            Button remove = new Button("? ?  ?");
            remove.setStyleName(Reindeer.BUTTON_SMALL);
            h.addComponent(remove);
            h.setComponentAlignment(remove, Alignment.MIDDLE_CENTER);

            remove.addListener((Button.ClickListener) new CertificateCleaner(remove, certLabel));

            Panel panel = new Panel();
            panel.setCaption("? ?:");
            panel.setContent(h);
            panel.setSizeUndefined();
            root = panel;
        } else {
            certificateWasRemoved = true;
        }
    }
    setCompositionRoot(root);
    setSizeUndefined();
}

From source file:ru.codeinside.gses.webui.components.ShowDiagramComponent.java

License:Mozilla Public License

private void buildLayout(final ShowDiagramComponentParameterObject param) {
    setSizeFull();/*from   w ww.j a v a  2s  .c  o  m*/
    setSpacing(true);
    final Panel panel = new Panel();
    panel.getContent().setSizeUndefined();
    panel.setCaption(param.caption);
    TaskGraph tg = new TaskGraph(param.processDefinitionId, param.executionId);
    if (param.height != null) {
        tg.setHeight(param.height);
    }
    if (param.width != null) {
        tg.setWidth(param.width);
    }
    tg.setStyleName("scheme-image");
    final TaskGraph bigGraph = new TaskGraph(param.processDefinitionId, param.executionId);
    tg.addListener(new MouseEvents.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void click(MouseEvents.ClickEvent event) {
            final Window schemeWindow = new Window(param.windowHeader);
            getWindow().addWindow(schemeWindow);
            schemeWindow.addComponent(bigGraph);
            schemeWindow.setWidth("90%");
            schemeWindow.setHeight("90%");
            schemeWindow.center();
            schemeWindow.focus();
            schemeWindow.setCloseShortcut(ShortcutAction.KeyCode.ESCAPE, 0);
            bigGraph.addListener(new MouseEvents.ClickListener() {
                @Override
                public void click(MouseEvents.ClickEvent event) {
                    getWindow().removeWindow(schemeWindow);
                }
            });
        }
    });
    panel.addComponent(tg);
    addComponent(panel);
}

From source file:ru.codeinside.gses.webui.manager.DirectoryPanel.java

License:Mozilla Public License

static Component createDirectoryPanel() {
    HorizontalSplitPanel horSplit = new HorizontalSplitPanel();
    horSplit.setSizeFull();//from   w  w w.  ja  v  a  2 s.  co m
    horSplit.setMargin(true);

    Panel panel00 = new Panel();
    Panel panel01 = new Panel();

    Panel panel10 = new Panel();

    horSplit.setFirstComponent(panel00);

    VerticalLayout vl = new VerticalLayout();
    horSplit.setSecondComponent(vl);

    vl.addComponent(panel01);
    vl.addComponent(panel10);

    vl.setSpacing(true);

    horSplit.setWidth("100%");
    vl.setHeight("100%");

    panel00.setHeight("100%");
    panel00.setWidth("100%");

    panel01.setWidth("100%");
    panel01.setHeight("100%");
    panel10.setHeight("100%");
    horSplit.setSplitPosition(35);
    vl.setExpandRatio(panel01, 0.25f);
    vl.setExpandRatio(panel10, 0.75f);

    final Table dirMapTable = ManagerWorkplace.createDirectoryMapTable();
    final FilterTable directoryTable = ManagerWorkplace.createDirectoryTable();
    dirMapTable.setVisible(false);

    final Form createFieldForm = new Form();
    createFieldForm.setCaption(" ?  ?");

    final TextField keyField = new TextField("");
    keyField.setRequired(true);
    keyField.setMaxLength(254);
    createFieldForm.addField("key", keyField);

    final TextField valField = new TextField("");
    valField.setRequired(true);
    valField.setMaxLength(1022);
    createFieldForm.addField("val", valField);
    createFieldForm.setVisible(false);

    Button addButton = new Button("",
            new AddTupleButtonListener(createFieldForm, directoryTable, keyField, valField, dirMapTable));
    createFieldForm.addField("submit", addButton);

    directoryTable.addListener(new DirectoryTableChangeListener(createFieldForm, directoryTable, dirMapTable));

    ManagerWorkplace.buildContainer(directoryTable, createFieldForm, dirMapTable);
    directoryTable.setColumnHeaders(new String[] { "?", "", "" });

    final Form createDirectory = new Form();
    createDirectory.setCaption(" ?");
    final TextField field = new TextField("?");
    field.setRequired(true);
    field.setMaxLength(255);
    field.setRequiredError("  ?");
    createDirectory.addField("name", field);
    Button createButton = new Button("",
            new CreateDirectoryButtonListener(field, createDirectory, directoryTable));
    createDirectory.addField("submit", createButton);

    Panel loadPanel = new Panel();
    loadPanel.setCaption(" ?");

    UploadDirectory events = new UploadDirectory(directoryTable, dirMapTable);

    Upload c = new Upload("", events);
    c.addListener(events);

    c.setButtonCaption("");
    loadPanel.addComponent(c);

    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setSizeFull();
    verticalLayout.setSpacing(true);
    verticalLayout.addComponent(loadPanel);
    verticalLayout.addComponent(createDirectory);
    verticalLayout.addComponent(directoryTable);

    panel00.addComponent(verticalLayout);

    panel01.addComponent(createFieldForm);

    dirMapTable.setSizeFull();
    dirMapTable.setPageLength(13);
    panel10.addComponent(dirMapTable);

    return horSplit;
}