Example usage for com.vaadin.ui Button setWidth

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

Introduction

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

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

From source file:org.openeos.services.ui.vaadin.internal.abstractform.UIVaadinFormToolkit.java

License:Apache License

@Override
protected AbstractComponent internalBuildField(org.abstractform.core.Field field,
        Map<String, Object> extraObjects) {
    AbstractComponent ret;//from w w  w .j  av a2s  .co m
    if (BFUIButton.TYPE_UI_BUTTON.equals(field.getType())) {
        UIVaadinButtonField button = new UIVaadinButtonField(field.getName(),
                (UIButtonController) field.getExtra(BFUIButton.EXTRA_UI_BUTTON_CONTROLLER),
                (UIApplicationImpl) extraObjects.get(EXTRA_OBJECT_APPLICATION));
        ret = button;
    } else if (BFUITable.TYPE_UITABLE.equals(field.getType())) {
        final Table table = (Table) buildTableField(field, extraObjects);
        HorizontalLayout mainLayout = new HorizontalLayout();
        mainLayout.setSizeFull();
        //mainLayout.setSizeFull();
        mainLayout.setMargin(false);
        mainLayout.setSpacing(true);
        mainLayout.addComponent(table);

        VerticalLayout buttonLayout = new VerticalLayout();
        buttonLayout.setMargin(false);
        buttonLayout.setSpacing(true);
        //buttonLayout.setSizeFull();

        final UITableController controller = (UITableController) field
                .getExtra(BFUITable.EXTRA_TABLE_CONTROLLER);
        final UIApplication application = (UIApplication) extraObjects.get(EXTRA_OBJECT_APPLICATION);

        Button buttonNew = new Button("N", new Button.ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                controller.onNew(application,
                        ((UITableContainer) table.getContainerDataSource()).getFormInstance(),
                        ((TableContainer) table.getContainerDataSource()).getValues());
            }
        });
        buttonNew.setWidth("100%");
        buttonLayout.addComponent(buttonNew);
        Button buttonEdit = new Button("E", new Button.ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                controller.onEdit(application,
                        ((UITableContainer) table.getContainerDataSource()).getFormInstance(),
                        ((TableContainer) table.getContainerDataSource()).getValues(), table.getValue());
            }
        });
        buttonEdit.setWidth("100%");
        buttonLayout.addComponent(buttonEdit);
        Button buttonDelete = new Button("D", new Button.ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                controller.onDelete(application,
                        ((UITableContainer) table.getContainerDataSource()).getFormInstance(),
                        ((TableContainer) table.getContainerDataSource()).getValues(), table.getValue());
            }
        });
        buttonDelete.setWidth("100%");
        buttonLayout.addComponent(buttonDelete);

        buttonLayout.setWidth("50px");

        mainLayout.addComponent(buttonLayout);
        mainLayout.setExpandRatio(table, 1.0f);
        ret = mainLayout;

    } else {
        ret = super.internalBuildField(field, extraObjects);
        if (field.getType().equals(Field.TYPE_NUMERIC)) {
            //TODO This normally can be many types of classes and can be with data conversion in binding tier
            ((TextField) ret).setPropertyDataSource(new ObjectProperty<BigDecimal>(null, BigDecimal.class));
        }
    }
    return ret;
}

From source file:org.openeos.usertask.ui.internal.vaadin.TasksWindow.java

License:Apache License

private ComponentContainer createSummaryButtons(final UserTask task) {

    Button completeButton = new Button("Task completed");
    completeButton.setWidth("100%");
    completeButton.addListener(new Button.ClickListener() {

        @Override/*  ww  w. j av  a  2  s  .c  om*/
        public void buttonClick(ClickEvent event) {
            completeTask(task);
        }
    });

    VerticalLayout buttonsLayout = new VerticalLayout();
    buttonsLayout.addComponent(completeButton);
    buttonsLayout.setWidth(16, VerticalLayout.UNITS_EM);
    return buttonsLayout;

}

From source file:org.s23m.cell.editor.semanticdomain.ui.components.ContainmentTreePanel.java

License:Mozilla Public License

private Panel createSearchPanel() {
    final Panel searchPanel = new Panel();
    final HorizontalLayout searchLayout = new HorizontalLayout();
    searchLayout.setWidth(TAB_SHEET_HEIGHT_RATIO);
    searchLayout.setSpacing(true);//from   www. j  av  a2  s. c  o  m
    searchPanel.addStyleName(Runo.PANEL_LIGHT);
    searchPanel.getLayout().setMargin(true);
    searchPanel.setLayout(searchLayout);

    searchText = new TextField();
    searchText.setWidth(TAB_SHEET_HEIGHT_RATIO);

    final Button searchBtn = new Button();
    searchBtn.setDescription("Search");
    searchBtn.setClickShortcut(KeyCode.ENTER);
    searchBtn.setIcon(EditorIcon.SEARCH.getIconImage());
    searchBtn.setWidth(null);
    searchBtn.addListener(Button.ClickEvent.class, this, INSTANCE_SEARCH_CMD);

    searchPanel.addComponent(searchText);
    searchPanel.addComponent(searchBtn);

    searchLayout.setExpandRatio(searchText, SEARCH_TEXT_EXPANSION_RATIO);

    return searchPanel;
}

From source file:org.s23m.cell.editor.semanticdomain.ui.components.ContainmentTreePanel.java

License:Mozilla Public License

private Panel createOperationsPanel() {
    final Panel operationsPanel = new Panel();
    final HorizontalLayout operationsPanelLayout = new HorizontalLayout();
    operationsPanelLayout.setWidth(TAB_SHEET_HEIGHT_RATIO);
    operationsPanelLayout.setSpacing(true);
    operationsPanel.addStyleName(Runo.PANEL_LIGHT);
    operationsPanel.getLayout().setMargin(true);
    operationsPanel.setLayout(operationsPanelLayout);

    commitButton = new Button();
    commitButton.setDescription("Commit");
    commitButton.setIcon(EditorIcon.PERSIST.getIconImage());
    commitButton.addListener(Button.ClickEvent.class, this, CHANGESET_COMMIT_CMD);

    rollbackButton = new Button();
    rollbackButton.setDescription("Rollback");
    // TODO use a more appropriate icon
    rollbackButton.setIcon(EditorIcon.DELETE.getIconImage());
    rollbackButton.addListener(Button.ClickEvent.class, this, CHANGESET_ROLLBACK_CMD);

    commitButton.setImmediate(true);/*  w w  w.j  av a2 s .  co m*/
    rollbackButton.setImmediate(true);
    commitButton.setEnabled(false);
    rollbackButton.setEnabled(false);

    final Button retrievalBtn = new Button();
    retrievalBtn.setDescription("Retrieve");
    retrievalBtn.setIcon(EditorIcon.RETRIEVE.getIconImage());
    retrievalBtn.setWidth(null);
    retrievalBtn.addListener(Button.ClickEvent.class, this, INSTANCE_RETRIEVAL_CMD);

    operationsPanel.addComponent(retrievalBtn);
    operationsPanel.addComponent(commitButton);
    operationsPanel.addComponent(rollbackButton);

    return operationsPanel;
}

From source file:org.s23m.cell.editor.semanticdomain.ui.components.layout.ImpactAnalysisFormLayout.java

License:Mozilla Public License

private void createPagebar(final List<Set> dependentInstances, final Panel searchResultPanel,
        final int resultSize) {
    int numPages = resultSize / PAGE_SIZE;
    if (resultSize % PAGE_SIZE > 0) {
        numPages++;/*www .j  a va  2 s.  c  o m*/
    }
    final HorizontalLayout hl = new HorizontalLayout();
    for (int n = 0; n < numPages; n++) {
        final Button linkBtn = new Button("" + (n + 1));
        linkBtn.setData(n);
        linkBtn.setStyleName("link");
        linkBtn.setWidth("10px");
        linkBtn.addListener(new Button.ClickListener() {
            public void buttonClick(final Button.ClickEvent event) {
                //reset pageIndex
                pageIndex = (Integer) linkBtn.getData();
                //rebuild page
                rebuildPage(dependentInstances, searchResultPanel, pageIndex);
            }
        });
        hl.addComponent(linkBtn);
    }
    searchResultPanel.addComponent(hl);
}

From source file:org.s23m.cell.editor.semanticdomain.ui.components.MultitabPanel.java

License:Mozilla Public License

private void createPagebar(final Panel searchResultPanel, final int resultSize) {
    int numPages = resultSize / PAGE_SIZE;
    if (resultSize % PAGE_SIZE > 0) {
        numPages++;// w w w  . j  av  a2  s . c  om
    }
    final HorizontalLayout hl = new HorizontalLayout();
    for (int n = 0; n < numPages; n++) {
        final Button linkBtn = new Button("" + (n + 1));
        linkBtn.setData(n);
        linkBtn.setStyleName("link");
        linkBtn.setWidth("15px");
        linkBtn.addListener(new Button.ClickListener() {
            public void buttonClick(final Button.ClickEvent event) {
                //reset pageIndex
                pageIndex = (Integer) linkBtn.getData();
                //rebuild page
                rebuildPage(searchResultPanel, pageIndex);
            }
        });
        hl.addComponent(linkBtn);
    }
    searchResultPanel.addComponent(hl);
}

From source file:org.vaadin.addons.forms.LocationApplication.java

License:Apache License

public void init() {
    Window mainWindow = new Window("Location Form Sample");

    Button button = new Button("Open Location Form");
    button.setWidth("150px");
    button.setHeight("30px");
    button.addListener(new Button.ClickListener() {
        public void buttonClick(Button.ClickEvent event) {
            Window window = new Window("Update Location");
            window.addComponent(new LocationForm());
            window.setModal(true);//from w  ww. ja v  a  2  s . c o m
            window.setResizable(false);
            window.setWidth("510px");
            window.setHeight("370px");
            getMainWindow().addWindow(window);
            window.center();
        }
    });
    mainWindow.addComponent(button);
    setMainWindow(mainWindow);
}

From source file:org.vaadin.addons.serverpush.samples.chat.ChatLayout.java

License:Apache License

public ChatLayout(final User user, final User from) {
    setSizeFull();//from ww w.j a v a 2  s  .c o  m
    Table table = new Table();
    table.setSizeFull();
    table.setContainerDataSource(new MessageContainer(user, from));
    table.addListener(new Container.ItemSetChangeListener() {
        public void containerItemSetChange(Container.ItemSetChangeEvent event) {
            ((Pushable) getApplication()).push();
        }
    });
    table.setVisibleColumns(new String[] { "from", "to", "received", "message" });

    addComponent(table);

    HorizontalLayout hl = new HorizontalLayout();
    hl.setWidth("100%");
    final TextArea textArea = new TextArea();
    textArea.setRows(5);
    textArea.setSizeFull();
    textArea.setWordwrap(true);
    textArea.setValue("");
    hl.addComponent(textArea);

    Button sendButton = new Button("Send");
    sendButton.setWidth("120px");
    sendButton.setImmediate(true);
    sendButton.addListener(new Button.ClickListener() {
        public void buttonClick(Button.ClickEvent event) {
            Message msg = new Message();
            msg.setFrom(from);
            msg.setTo(user);
            msg.setMessage(textArea.getValue().toString());
            MessageManager.getInstance().addMessage(msg);
            textArea.setValue("");
        }
    });
    hl.addComponent(sendButton);
    hl.setComponentAlignment(sendButton, Alignment.BOTTOM_RIGHT);
    hl.setExpandRatio(textArea, 1);
    addComponent(hl);

    setExpandRatio(table, 1);
}

From source file:org.vaadin.alump.vibrate.demo.VibrateDemoUI.java

License:Apache License

@Override
protected void init(VaadinRequest vaadinRequest) {
    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();//w ww . j a v a2s .c  o  m
    setContent(layout);

    notifications = new FancyNotifications();
    layout.addComponent(notifications);

    Label label = new Label("This demo works only with Android Chrome");
    layout.addComponent(label);

    Button singleButton = new Button("Single vibrate");
    singleButton.setWidth("100%");
    layout.addComponent(singleButton);
    singleButton.addClickListener(singleClickListener);

    Button patternButton = new Button("Pattern vibrate");
    patternButton.setWidth("100%");
    layout.addComponent(patternButton);
    patternButton.addClickListener(patternClickListener);

    Button stopButton = new Button("End vibrate");
    stopButton.setWidth("100%");
    layout.addComponent(stopButton);
    stopButton.addClickListener(stopClickListener);

    Button notificationButton = new Button("Delayed notification vibrate");
    notificationButton.setWidth("100%");
    layout.addComponent(notificationButton);
    notificationButton.addClickListener(notificationClickListener);

}

From source file:probe.com.view.body.quantcompare.PieChart.java

public PieChart(String title, double full, double found, final String notfound) {

    this.setWidth(200 + "px");
    this.setHeight(200 + "px");
    defaultKeyColorMap.put("Found", new Color(110, 177, 206));
    defaultKeyColorMap.put("Not found", new Color(219, 169, 1));
    otherSymbols.setGroupingSeparator('.');
    this.setStyleName("click");

    labels = new String[] { "Found", "Not found" };

    double foundPercent = ((found / full) * 100.0);
    df = new DecimalFormat("#.##", otherSymbols);
    valuesMap.put("Found", ((int) found) + " (" + df.format(foundPercent) + "%)");
    values = new Double[] { foundPercent, 100.0 - foundPercent };
    valuesMap.put("Not found", ((int) (full - found)) + " (" + df.format(100.0 - foundPercent) + "%)");

    String defaultImgURL = initPieChart(200, 200, title);
    chartImg.setSource(new ExternalResource(defaultImgURL));
    this.addComponent(chartImg);
    this.addLayoutClickListener(PieChart.this);

    popupLayout = new PopupView(null, popupBody);
    popupLayout.setHideOnMouseOut(false);
    popupBody.setWidth("300px");
    popupBody.setStyleName(Reindeer.LAYOUT_WHITE);
    popupBody.setHeightUndefined();/*from   w  ww . j av a 2 s  .c o  m*/
    this.addComponent(popupLayout);
    this.notfound = notfound.replace(" ", "").replace(",", "/n");

    HorizontalLayout topLayout = new HorizontalLayout();
    topLayout.setWidth("100%");
    topLayout.setHeight("20px");

    Label header = new Label("<b>Not Found (New Proteins)</b>");
    header.setStyleName(Reindeer.LABEL_SMALL);
    topLayout.addComponent(header);
    header.setContentMode(ContentMode.HTML);

    VerticalLayout closeBtn = new VerticalLayout();
    closeBtn.setWidth("10px");
    closeBtn.setHeight("10px");
    closeBtn.setStyleName("closebtn");
    topLayout.addComponent(closeBtn);
    topLayout.setComponentAlignment(closeBtn, Alignment.TOP_RIGHT);
    closeBtn.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {

        @Override
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {
            popupLayout.setPopupVisible(false);
        }
    });
    popupBody.addComponent(topLayout);
    popupBody.addComponent(textArea);
    textArea.setWidth("100%");
    textArea.setHeight("150px");
    textArea.setValue(this.notfound);
    textArea.setReadOnly(true);
    popupBody.setSpacing(true);

    HorizontalLayout bottomLayout = new HorizontalLayout();
    bottomLayout.setWidth("100%");
    bottomLayout.setHeight("40px");
    bottomLayout.setMargin(new MarginInfo(false, true, true, true));
    popupBody.addComponent(bottomLayout);

    Button exportTableBtn = new Button("");
    exportTableBtn.setHeight("24px");
    exportTableBtn.setWidth("24px");
    exportTableBtn.setPrimaryStyleName("exportxslbtn");
    exportTableBtn.setDescription("Export table data");
    exportTableBtn.addClickListener(new Button.ClickListener() {

        private Table table;

        @Override
        public void buttonClick(Button.ClickEvent event) {

            if (table == null) {
                table = new Table();
                table.addContainerProperty("Index", Integer.class, null, "", null, Table.Align.RIGHT);
                table.addContainerProperty("Accession", String.class, Table.Align.CENTER);
                table.setVisible(false);
                addComponent(table);
                int i = 1;
                for (String str : notfound.replace(" ", "").replace(",", "\n").split("\n")) {
                    table.addItem(new Object[] { i, str }, i++);
                }

            }

            ExcelExport csvExport = new ExcelExport(table, "Not found protein accessions (New proteins)");
            //                csvExport.setReportTitle("CSF-PR /  Not found protein accessions (New proteins) ");
            csvExport.setExportFileName("CSF-PR - Not found protein accessions" + ".xls");
            csvExport.setMimeType(CsvExport.EXCEL_MIME_TYPE);
            csvExport.setDisplayTotals(false);
            csvExport.setExcelFormatOfProperty("Index", "#0;[Red] #0");
            csvExport.export();

        }
    });

    bottomLayout.addComponent(exportTableBtn);
    bottomLayout.setComponentAlignment(exportTableBtn, Alignment.MIDDLE_RIGHT);

}