Example usage for com.vaadin.ui Window setWidth

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

Introduction

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

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

From source file:pl.exsio.frameset.vaadin.ui.support.dialog.PromptDialog.java

License:Open Source License

public static void show(final String msg, final Handler handler) {
    final Window window = new Window(t("prompt.title"));
    window.center();//from ww w  .j  a  v a2 s. c o  m
    window.setWidth("450px");
    window.setModal(true);
    window.setResizable(false);
    window.setDraggable(false);

    VerticalLayout vlayout = new VerticalLayout() {
        {
            HorizontalLayout hlayout = new HorizontalLayout();
            hlayout.setSpacing(true);
            hlayout.setMargin(true);

            hlayout.addComponent(new Label(t(msg) + ": "));
            final TextField value = new TextField();
            hlayout.addComponent(value);
            addComponent(hlayout);
            addComponent(getControls(window, handler, value));
        }
    };
    vlayout.setMargin(true);
    vlayout.setSpacing(true);
    window.setContent(vlayout);
    UI.getCurrent().addWindow(window);
    window.focus();
}

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

License:Apache License

@Override
public void handle(ActionContext actionContext) throws Exception {
    Window w = new Window();
    w.setModal(true);/*from   w w  w  . ja  v a 2  s .c  om*/
    OpenGroupsApplication app = actionContext.getApp();
    if (app.getAppConfigManager().isInstancePrivate()) {
        w.setClosable(false);
    }

    OpenGroupsMainWindow mainWindow = actionContext.getWindow();

    UserAction ua = actionContext.getUserAction();
    w.setWidth("600px");
    w.setHeight("300px");
    w.center();
    w.setCaption(getMessage(ua.getActionName() + ".window.caption"));
    mainWindow.addWindow(w);

    ComponentContainer loginView = getLoginView(actionContext);

    w.setContent(loginView);

}

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

License:Apache License

@Override
public void handle(ActionContext actionContext) throws Exception {
    Window w = new Window();
    w.setModal(true);//from  w  w w  . j av  a 2  s . co m
    OpenGroupsApplication app = actionContext.getApp();
    OpenGroupsMainWindow mainWindow = actionContext.getWindow();
    UserAction ua = actionContext.getUserAction();
    w.setWidth("400px");
    w.setHeight("300px");
    w.center();
    w.setCaption(getMessage(ua.getActionName() + ".window.caption"));
    mainWindow.addWindow(w);

    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();
    Form form = getRegisterForm(actionContext.getUserAction(), app, actionContext.getWindow(),
            actionContext.getEntity(), actionContext);
    w.setContent(layout);
    layout.addComponent(form);
    form.setWidth("60%");
    //   form.setHeight("30%");
    layout.setComponentAlignment(form, Alignment.MIDDLE_CENTER);

}

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

License:Apache License

@Override
public void handle(ActionContext actionContext) throws Exception {
    Window w = new Window();
    w.setModal(true);//w  w  w. j  a  va  2s. co  m
    OpenGroupsApplication app = actionContext.getApp();
    OpenGroupsMainWindow mainWindow = actionContext.getWindow();
    UserAction ua = actionContext.getUserAction();
    w.setWidth("400px");
    w.setHeight("300px");
    w.center();
    w.setCaption(getMessage(ua.getActionName() + ".window.caption"));
    mainWindow.addWindow(w);

    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();
    Form form = getForm(actionContext.getUserAction(), app, actionContext);
    w.setContent(layout);
    layout.addComponent(form);
    form.setWidth("60%");
    // form.setHeight("30%");
    layout.setComponentAlignment(form, Alignment.MIDDLE_CENTER);
}

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

License:Apache License

@Override
public void handle(ActionContext actionContext) throws Exception {
    Window w = new Window();
    w.setModal(true);//from w w w .j  a  va2 s  .c  o m
    OpenGroupsApplication app = actionContext.getApp();
    OpenGroupsMainWindow mainWindow = actionContext.getWindow();
    UserAction ua = actionContext.getUserAction();
    w.setWidth("400px");
    w.setHeight("300px");
    w.center();
    w.setCaption(getMessage(ua.getActionName() + ".window.caption"));
    mainWindow.addWindow(w);

    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();
    Form form = getForm(actionContext.getUserAction(), app, actionContext.getParams(), actionContext);
    w.setContent(layout);
    layout.addComponent(form);
    form.setWidth("60%");
    // form.setHeight("30%");
    layout.setComponentAlignment(form, Alignment.MIDDLE_CENTER);

    /* hide the content of the main window */
    mainWindow.setContentVisible(false);

}

From source file:roart.client.MyVaadinUI.java

private Window getLoginWindow() {
    final Window window = new Window("Login");
    window.setWidth("30%");
    window.setHeight("30%");
    window.center();/*from  w  w  w.j a va 2 s .c o  m*/
    final TextField login = new TextField("Username");
    final PasswordField password = new PasswordField("Password");
    Button button = new Button("Login");
    button.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            tryLogin(login.getValue(), password.getValue());
            window.close();
        }
    });
    VerticalLayout vert = new VerticalLayout();
    vert.addComponent(login);
    vert.addComponent(password);
    vert.addComponent(button);
    window.setContent(vert);
    return window;
}

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

License:Mozilla Public License

private void buildLayout(final ShowDiagramComponentParameterObject param) {
    setSizeFull();//from w w  w  .j  a  va  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.supervisor.SupervisorWorkplace.java

License:Mozilla Public License

private void buildListPanel() {
    controlledTasksTable.setHeight("255px");
    controlledTasksTable.setWidth("100%");
    controlledTasksTable.setImmediate(true);
    controlledTasksTable.setSelectable(true);
    controlledTasksTable.setSortDisabled(true);
    controlledTasksTable.addContainerProperty("id", Component.class, null);
    controlledTasksTable.addContainerProperty("dateCreated", String.class, null);
    controlledTasksTable.addContainerProperty("task", String.class, null);
    controlledTasksTable.addContainerProperty("procedure", String.class, null);
    controlledTasksTable.addContainerProperty("declarant", String.class, null);
    controlledTasksTable.addContainerProperty("version", String.class, null);
    controlledTasksTable.addContainerProperty("status", String.class, null);
    controlledTasksTable.addContainerProperty("employee", String.class, null);
    controlledTasksTable.addContainerProperty("priority", String.class, null);
    controlledTasksTable.addContainerProperty("bidDays", String.class, null);
    controlledTasksTable.addContainerProperty("taskDays", String.class, null);
    controlledTasksTable.setVisibleColumns(new Object[] { "id", "dateCreated", "task", "procedure", "declarant",
            "version", "status", "employee", "bidDays", "taskDays" });
    controlledTasksTable.setColumnHeaders(new String[] { "?", "  ?",
            "", "", "?", "??", "?",
            "?", "..", ".?." });
    controlledTasksTable.setColumnExpandRatio("id", 0.05f);
    controlledTasksTable.setColumnExpandRatio("dateCreated", 0.15f);
    controlledTasksTable.setColumnExpandRatio("task", 0.2f);
    controlledTasksTable.setColumnExpandRatio("procedure", 0.25f);
    controlledTasksTable.setColumnExpandRatio("declarant", 0.1f);
    controlledTasksTable.setColumnExpandRatio("version", 0.05f);
    controlledTasksTable.setColumnExpandRatio("status", 0.1f);
    controlledTasksTable.setColumnExpandRatio("employee", 0.1f);
    controlledTasksTable.setCellStyleGenerator(new TaskStylist(controlledTasksTable));
    listPanel.addComponent(controlledTasksTable);
    final Button assignButton = new Button("? ??");
    controlledTasksTable.addListener(new Property.ValueChangeListener() {
        @Override/*w  ww  . jav a  2 s .co  m*/
        public void valueChange(Property.ValueChangeEvent event) {
            Table table = (Table) event.getProperty();
            Item item = table.getItem(table.getValue());

            if (item != null && item.getItemProperty("id") != null) {
                final String taskId = item.getItemProperty("taskId").getValue().toString();
                final Component procedureHistoryPanel = new ProcedureHistoryPanel(taskId);
                procedureHistoryPanel.addListener(new Listener() {
                    @Override
                    public void componentEvent(Event event) {
                        HistoricTaskInstance historicTaskInstance = ((ProcedureHistoryPanel.HistoryStepClickedEvent) event)
                                .getHistoricTaskInstance();
                        Date endDateTime = historicTaskInstance.getEndTime();
                        if (endDateTime == null) {
                            taskIdToAssign = findTaskByHistoricInstance(historicTaskInstance);
                            if (taskIdToAssign == null) {
                                alreadyGone();
                                return;
                            }
                            assignButton.setVisible(true);
                        } else {
                            assignButton.setVisible(false);
                        }
                    }
                });
                ((VerticalLayout) item1).removeAllComponents();
                Task task = Flash.flash().getProcessEngine().getTaskService().createTaskQuery().taskId(taskId)
                        .singleResult();
                Bid bid = Flash.flash().getAdminService().getBidByTask(taskId);
                String executionId = task.getExecutionId();
                final ProcessDefinition def = ActivitiBean.get()
                        .getProcessDefinition(task.getProcessDefinitionId(), Flash.login());
                final ShowDiagramComponentParameterObject param = new ShowDiagramComponentParameterObject();
                param.changer = bidChanger;
                param.processDefinitionId = def.getId();
                param.executionId = executionId;
                param.height = "300px";
                param.width = null;
                param.windowHeader = bid == null ? ""
                        : bid.getProcedure().getName() + " v. " + bid.getVersion();
                Button showDiagram = new Button("");
                showDiagram.addListener(new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        Execution execution = Flash.flash().getProcessEngine().getRuntimeService()
                                .createExecutionQuery().executionId(param.executionId).singleResult();
                        if (execution == null) {
                            alreadyGone();
                            return;
                        }
                        ShowDiagramComponent showDiagramComponent = new ShowDiagramComponent(param);
                        VerticalLayout layout = new VerticalLayout();
                        Button back = new Button("?");
                        back.addListener(new Button.ClickListener() {
                            private static final long serialVersionUID = 4154712522487297925L;

                            @Override
                            public void buttonClick(com.vaadin.ui.Button.ClickEvent event) {
                                bidChanger.back();
                            }
                        });
                        layout.addComponent(back);
                        layout.setSpacing(true);
                        layout.addComponent(showDiagramComponent);
                        bidChanger.set(layout, "showDiagram");
                        bidChanger.change(layout);
                    }
                });

                Button deleteBidButton = new Button(" ?");
                deleteBidButton.addListener(new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        final Window mainWindow = getWindow();
                        final Window rejectWindow = new Window();
                        rejectWindow.setWidth("38%");
                        rejectWindow.center();
                        rejectWindow.setCaption("!");
                        final VerticalLayout verticalLayout = new VerticalLayout();
                        verticalLayout.setSpacing(true);
                        verticalLayout.setMargin(true);
                        final Label messageLabel = new Label(
                                "  ? ?");
                        messageLabel.setStyleName("h2");
                        final TextArea textArea = new TextArea();
                        textArea.setSizeFull();
                        HorizontalLayout buttons = new HorizontalLayout();
                        buttons.setSpacing(true);
                        buttons.setSizeFull();
                        final Button ok = new Button("Ok");
                        Button cancel = new Button("Cancel");

                        buttons.addComponent(ok);
                        buttons.addComponent(cancel);
                        buttons.setExpandRatio(ok, 0.99f);
                        verticalLayout.addComponent(messageLabel);
                        verticalLayout.addComponent(textArea);
                        verticalLayout.addComponent(buttons);
                        verticalLayout.setExpandRatio(textArea, 0.99f);
                        rejectWindow.setContent(verticalLayout);
                        mainWindow.addWindow(rejectWindow);

                        Button.ClickListener ok1 = new Button.ClickListener() {
                            @Override
                            public void buttonClick(Button.ClickEvent event) {
                                ok.setEnabled(false);
                                verticalLayout.removeComponent(messageLabel);
                                verticalLayout.removeComponent(textArea);
                                final byte[] block;
                                final String textAreaValue = (String) textArea.getValue();
                                if (textAreaValue != null) {
                                    block = textAreaValue.getBytes();
                                } else {
                                    block = null;
                                }
                                Label reason = new Label(textAreaValue);
                                reason.setCaption(" :");
                                verticalLayout.addComponent(reason, 0);
                                event.getButton().removeListener(this);

                                SignApplet signApplet = new SignApplet(new SignAppletListener() {

                                    @Override
                                    public void onLoading(SignApplet signApplet) {

                                    }

                                    @Override
                                    public void onNoJcp(SignApplet signApplet) {
                                        verticalLayout.removeComponent(signApplet);
                                        ReadOnly field = new ReadOnly(
                                                "   ?? ?? ?  JCP",
                                                false);
                                        verticalLayout.addComponent(field);

                                    }

                                    @Override
                                    public void onCert(SignApplet signApplet, X509Certificate certificate) {
                                        boolean ok = false;
                                        String errorClause = null;
                                        try {
                                            boolean link = AdminServiceProvider
                                                    .getBoolProperty(CertificateVerifier.LINK_CERTIFICATE);
                                            if (link) {
                                                byte[] x509 = AdminServiceProvider.get()
                                                        .withEmployee(Flash.login(), new CertificateReader());
                                                ok = Arrays.equals(x509, certificate.getEncoded());
                                            } else {
                                                ok = true;
                                            }
                                            CertificateVerifyClientProvider.getInstance()
                                                    .verifyCertificate(certificate);
                                        } catch (CertificateEncodingException e) {
                                        } catch (CertificateInvalid err) {
                                            errorClause = err.getMessage();
                                            ok = false;
                                        }
                                        if (ok) {
                                            signApplet.block(1, 1);
                                        } else {
                                            NameParts subject = X509.getSubjectParts(certificate);
                                            String fieldValue = (errorClause == null)
                                                    ? " " + subject.getShortName()
                                                            + " "
                                                    : errorClause;
                                            ReadOnly field = new ReadOnly(fieldValue, false);
                                            verticalLayout.addComponent(field, 0);
                                        }
                                    }

                                    @Override
                                    public void onBlockAck(SignApplet signApplet, int i) {
                                        logger().fine("AckBlock:" + i);
                                        signApplet.chunk(1, 1, block);
                                    }

                                    @Override
                                    public void onChunkAck(SignApplet signApplet, int i) {
                                        logger().fine("AckChunk:" + i);
                                    }

                                    @Override
                                    public void onSign(SignApplet signApplet, byte[] sign) {
                                        final int i = signApplet.getBlockAck();
                                        logger().fine("done block:" + i);
                                        if (i < 1) {
                                            signApplet.block(i + 1, 1);
                                        } else {
                                            verticalLayout.removeComponent(signApplet);
                                            NameParts subjectParts = X509
                                                    .getSubjectParts(signApplet.getCertificate());
                                            Label field2 = new Label(subjectParts.getShortName());
                                            field2.setCaption("? ?:");
                                            verticalLayout.addComponent(field2, 0);
                                            ok.setEnabled(true);
                                        }
                                    }

                                    private Logger logger() {
                                        return Logger.getLogger(getClass().getName());
                                    }
                                });
                                byte[] x509 = AdminServiceProvider.get().withEmployee(Flash.login(),
                                        new CertificateReader());
                                if (x509 != null) {
                                    signApplet.setSignMode(x509);
                                } else {
                                    signApplet.setUnboundSignMode();
                                }
                                verticalLayout.addComponent(signApplet, 0);

                                ok.addListener(new Button.ClickListener() {
                                    @Override
                                    public void buttonClick(Button.ClickEvent event) {
                                        Task result = Flash.flash().getProcessEngine().getTaskService()
                                                .createTaskQuery().taskId(taskId).singleResult();
                                        if (result == null) {
                                            alreadyGone();
                                            return;
                                        }
                                        ActivitiBean.get().deleteProcessInstance(taskId, textAreaValue);
                                        AdminServiceProvider.get().createLog(Flash.getActor(), "activiti.task",
                                                taskId, "remove", " ?", true);
                                        fireTaskChangedEvent(taskId, SupervisorWorkplace.this);
                                        infoChanger.change(infoComponent);
                                        controlledTasksTable.setValue(null);
                                        controlledTasksTable.refresh();
                                        mainWindow.removeWindow(rejectWindow);
                                    }
                                });
                            }
                        };
                        ok.addListener(ok1);

                        cancel.addListener(new Button.ClickListener() {
                            @Override
                            public void buttonClick(Button.ClickEvent event) {

                                controlledTasksTable.refresh();
                                mainWindow.removeWindow(rejectWindow);
                            }
                        });
                    }
                });

                HorizontalLayout hl = new HorizontalLayout();
                hl.setSizeFull();
                hl.setSpacing(true);
                hl.addComponent(showDiagram);
                hl.addComponent(deleteBidButton);
                hl.setExpandRatio(showDiagram, 0.99f);
                hl.setExpandRatio(deleteBidButton, 0.01f);

                ((VerticalLayout) item1).addComponent(hl);
                ((VerticalLayout) item1).addComponent(procedureHistoryPanel);
                assignButton.setVisible(false);
                assignButton.addListener(new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        ((Layout) item3).removeAllComponents();
                        if (taskIdToAssign != null) {
                            ((Layout) item3).addComponent(createAssignerToTaskComponent(taskIdToAssign,
                                    (ProcedureHistoryPanel) procedureHistoryPanel, controlledTasksTable));
                            bidChanger.change(item3);
                        } else {
                            alreadyGone();
                        }
                    }
                });
                ((VerticalLayout) item1).addComponent(assignButton);
                infoChanger.change(bidComponent);
                bidChanger.change(item1);
            } else {
                ((VerticalLayout) item1).removeAllComponents();
            }
        }
    });
}

From source file:ui.button.ShowAchievementsButton.java

License:Apache License

private void showOnWindow() {
    final Window window = new Window();
    window.setWidth("95%");
    window.setHeight("95%");
    window.center();//from w  ww.ja  va  2 s . c o m
    window.setResizable(true);
    window.setModal(true);
    window.addCloseListener(new Window.CloseListener() {

        @Override
        public void windowClose(Window.CloseEvent e) {
            window.close();
        }
    });
    window.setContent(new UserTabSheet(userId, language));
    getUI().addWindow(window);
    window.setStyleName("window");
}

From source file:uicomponents.MSSampleMultiplicationTable.java

License:Open Source License

protected void createEnzymeSelectionWindow(String row) {
    Window subWindow = new Window(" Enzyme selection");
    subWindow.setWidth("400px");

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);/*from   www.  j a va2s .  c om*/
    layout.setMargin(true);
    EnzymePanel pan = new EnzymePanel(enzymes);
    Button ok = new Button("Okay.");
    ok.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            List<String> enzymes = pan.getEnzymes();
            ComboBox b = parseBoxRow(row, "Enzyme");
            if (enzymes.isEmpty()) {
                Styles.notification("No enzymes selected", "Please select at least one enzyme!",
                        NotificationType.ERROR);
            } else if (enzymes.size() == 1) {
                b.setValue(enzymes.get(0));
                subWindow.close();
            } else {
                b.addItem("Custom");
                b.setValue("Custom");
                enzymeMap.put(row, enzymes);
                subWindow.close();
            }
        }
    });
    layout.addComponent(pan);
    layout.addComponent(ok);

    subWindow.setContent(layout);
    // Center it in the browser window
    subWindow.center();
    subWindow.setModal(true);
    subWindow.setIcon(FontAwesome.FLASK);
    subWindow.setResizable(false);
    ProjectwizardUI ui = (ProjectwizardUI) UI.getCurrent();
    ui.addWindow(subWindow);
}