List of usage examples for com.vaadin.ui Button addStyleName
@Override public void addStyleName(String style)
From source file:com.esspl.datagen.ui.TableDataView.java
License:Open Source License
public TableDataView(final JdbcTable table, final Connection connection, final DataGenApplication dataApp) { log.debug("TableDataView - constructor start"); setCaption("Data"); dataGenApplication = dataApp;/*from www. j a va 2 s . c om*/ VerticalLayout vl = new VerticalLayout(); vl.setSizeFull(); setCompositionRoot(vl); HorizontalLayout hBar = new HorizontalLayout(); hBar.setWidth("98%"); hBar.setHeight("40px"); rows = new TextField(); rows.setWidth("50px"); rows.setImmediate(true); rows.addValidator(new IntegerValidator("Rows must be an Integer")); Label lbl = new Label("Generate "); content = new HorizontalLayout(); content.setHeight("40px"); content.setMargin(false, false, false, true); content.setSpacing(true); content.addComponent(lbl); content.setComponentAlignment(lbl, Alignment.MIDDLE_CENTER); content.addComponent(rows); content.setComponentAlignment(rows, Alignment.MIDDLE_CENTER); Button addDataButton = new Button("Row(S) Data", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { log.debug("TableDataView - Generate Data Button clicked"); populateGenerator(table); } }); addDataButton.addStyleName("small"); addDataButton.setIcon(DataGenConstant.ADD_SMALL); content.addComponent(addDataButton); content.setComponentAlignment(addDataButton, Alignment.MIDDLE_CENTER); Button refreshButton = new Button("Refresh", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { log.debug("TableDataView - Refresh Button clicked"); refreshDataView(table, connection); } }); refreshButton.addStyleName("small"); refreshButton.setIcon(DataGenConstant.RESET); content.addComponent(refreshButton); content.setComponentAlignment(refreshButton, Alignment.MIDDLE_CENTER); //Tapas:10/08/2012 - Export feature implementation started HorizontalLayout expContainer = new HorizontalLayout(); expContainer.setSpacing(true); PopupButton exportButton = new PopupButton("Export"); exportButton.setComponent(new DataExportView()); exportButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { //dataApp.getMainWindow().showNotification("Export Button clicked!"); } }); exportButton.setIcon(DataGenConstant.DATAEXPORT_ICON); expContainer.addComponent(exportButton); expContainer.setComponentAlignment(exportButton, Alignment.MIDDLE_LEFT); //Tapas:10/08/2012 - Import feature implementation started PopupButton importButton = new PopupButton("Import"); importButton.setComponent(new DataImportView()); importButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { //dataApp.getMainWindow().showNotification("Import Button clicked!"); } }); importButton.setIcon(DataGenConstant.DATAIMPORT_ICON); expContainer.addComponent(importButton); expContainer.setComponentAlignment(importButton, Alignment.MIDDLE_RIGHT); tableContainer = new VerticalLayout(); tableContainer.setSizeFull(); hBar.addComponent(content); hBar.setComponentAlignment(content, Alignment.MIDDLE_LEFT); hBar.addComponent(expContainer); hBar.setComponentAlignment(expContainer, Alignment.MIDDLE_RIGHT); vl.addComponent(hBar); vl.addComponent(tableContainer); vl.setExpandRatio(tableContainer, 1f); refreshDataView(table, connection); log.debug("TableDataView - constructor end"); }
From source file:com.etest.valo.CommonParts.java
License:Apache License
Panel loadingIndicators() { Panel p = new Panel("Loading Indicator"); final VerticalLayout content = new VerticalLayout(); p.setContent(content);/*w w w . j a v a 2s . c o m*/ content.setSpacing(true); content.setMargin(true); content.addComponent(new Label("You can test the loading indicator by pressing the buttons.")); CssLayout group = new CssLayout(); group.setCaption("Show the loading indicator for"); group.addStyleName("v-component-group"); content.addComponent(group); Button loading = new Button("0.8"); loading.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { try { Thread.sleep(800); } catch (InterruptedException e) { } } }); group.addComponent(loading); Button delay = new Button("3"); delay.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { try { Thread.sleep(3000); } catch (InterruptedException e) { } } }); group.addComponent(delay); Button wait = new Button("15"); wait.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { try { Thread.sleep(15000); } catch (InterruptedException e) { } } }); wait.addStyleName("last"); group.addComponent(wait); Label label = new Label(" seconds", ContentMode.HTML); label.setSizeUndefined(); group.addComponent(label); Label spinnerDesc = new Label( "The theme also provides a mixin that you can use to include a spinner anywhere in your application. The button below reveals a Label with a custom style name, for which the spinner mixin is added."); spinnerDesc.addStyleName("small"); spinnerDesc.setCaption("Spinner"); content.addComponent(spinnerDesc); if (!MainUI.isTestMode()) { final Label spinner = new Label(); spinner.addStyleName("spinner"); Button showSpinnerButton = new Button("Show spinner", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { content.replaceComponent(event.getComponent(), spinner); } }); content.addComponent(showSpinnerButton); } return p; }
From source file:com.etest.valo.Tables.java
License:Apache License
static void configure(Table table, boolean footer, boolean sized, boolean expandRatios, boolean stripes, boolean verticalLines, boolean horizontalLines, boolean borderless, boolean headers, boolean compact, boolean small, boolean rowIndex, boolean rowCaption, boolean rowIcon, boolean componentsInRows) { table.setSelectable(true);//w w w. j a v a 2s . c o m table.setMultiSelect(true); table.setSortEnabled(true); table.setColumnCollapsingAllowed(true); table.setColumnReorderingAllowed(true); table.setPageLength(6); table.addActionHandler(MainUI.getActionHandler()); table.setDragMode(TableDragMode.MULTIROW); table.setDropHandler(new DropHandler() { @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } @Override public void drop(DragAndDropEvent event) { Notification.show(event.getTransferable().toString()); } }); table.setColumnAlignment(MainUI.DESCRIPTION_PROPERTY, Align.RIGHT); table.setColumnAlignment(MainUI.INDEX_PROPERTY, Align.CENTER); table.removeContainerProperty("textfield"); table.removeGeneratedColumn("textfield"); table.removeContainerProperty("button"); table.removeGeneratedColumn("button"); table.removeContainerProperty("label"); table.removeGeneratedColumn("label"); table.removeContainerProperty("checkbox"); table.removeGeneratedColumn("checkbox"); table.removeContainerProperty("datefield"); table.removeGeneratedColumn("datefield"); table.removeContainerProperty("combobox"); table.removeGeneratedColumn("combobox"); table.removeContainerProperty("optiongroup"); table.removeGeneratedColumn("optiongroup"); table.removeContainerProperty("slider"); table.removeGeneratedColumn("slider"); table.removeContainerProperty("progress"); table.removeGeneratedColumn("progress"); if (componentsInRows) { table.addContainerProperty("textfield", TextField.class, null); table.addGeneratedColumn("textfield", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { TextField tf = new TextField(); tf.setInputPrompt("Type here"); // tf.addStyleName("compact"); if ((Integer) itemId % 2 == 0) { tf.addStyleName("borderless"); } return tf; } }); table.addContainerProperty("datefield", TextField.class, null); table.addGeneratedColumn("datefield", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { DateField tf = new DateField(); tf.addStyleName("compact"); if ((Integer) itemId % 2 == 0) { tf.addStyleName("borderless"); } return tf; } }); table.addContainerProperty("combobox", TextField.class, null); table.addGeneratedColumn("combobox", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { ComboBox tf = new ComboBox(); tf.setInputPrompt("Select"); tf.addStyleName("compact"); if ((Integer) itemId % 2 == 0) { tf.addStyleName("borderless"); } return tf; } }); table.addContainerProperty("button", Button.class, null); table.addGeneratedColumn("button", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { Button b = new Button("Button"); b.addStyleName("small"); return b; } }); table.addContainerProperty("label", TextField.class, null); table.addGeneratedColumn("label", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { Label label = new Label("Label component"); label.setSizeUndefined(); label.addStyleName("bold"); return label; } }); table.addContainerProperty("checkbox", TextField.class, null); table.addGeneratedColumn("checkbox", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { CheckBox cb = new CheckBox(null, true); return cb; } }); table.addContainerProperty("optiongroup", TextField.class, null); table.addGeneratedColumn("optiongroup", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { OptionGroup op = new OptionGroup(); op.addItem("Male"); op.addItem("Female"); op.addStyleName("horizontal"); return op; } }); table.addContainerProperty("slider", TextField.class, null); table.addGeneratedColumn("slider", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { Slider s = new Slider(); s.setValue(30.0); return s; } }); table.addContainerProperty("progress", TextField.class, null); table.addGeneratedColumn("progress", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { ProgressBar bar = new ProgressBar(); bar.setValue(0.7f); return bar; } }); } table.setFooterVisible(footer); if (footer) { table.setColumnFooter(MainUI.CAPTION_PROPERTY, "caption"); table.setColumnFooter(MainUI.DESCRIPTION_PROPERTY, "description"); table.setColumnFooter(MainUI.ICON_PROPERTY, "icon"); table.setColumnFooter(MainUI.INDEX_PROPERTY, "index"); } if (sized) { table.setWidth("400px"); table.setHeight("300px"); } else { table.setSizeUndefined(); } if (expandRatios) { if (!sized) { table.setWidth("100%"); } } table.setColumnExpandRatio(MainUI.CAPTION_PROPERTY, expandRatios ? 1.0f : 0); table.setColumnExpandRatio(MainUI.DESCRIPTION_PROPERTY, expandRatios ? 1.0f : 0); if (!stripes) { table.addStyleName("no-stripes"); } else { table.removeStyleName("no-stripes"); } if (!verticalLines) { table.addStyleName("no-vertical-lines"); } else { table.removeStyleName("no-vertical-lines"); } if (!horizontalLines) { table.addStyleName("no-horizontal-lines"); } else { table.removeStyleName("no-horizontal-lines"); } if (borderless) { table.addStyleName("borderless"); } else { table.removeStyleName("borderless"); } if (!headers) { table.addStyleName("no-header"); } else { table.removeStyleName("no-header"); } if (compact) { table.addStyleName("compact"); } else { table.removeStyleName("compact"); } if (small) { table.addStyleName("small"); } else { table.removeStyleName("small"); } if (!rowIndex && !rowCaption && rowIcon) { table.setRowHeaderMode(RowHeaderMode.HIDDEN); } if (rowIndex) { table.setRowHeaderMode(RowHeaderMode.INDEX); } if (rowCaption) { table.setRowHeaderMode(RowHeaderMode.PROPERTY); table.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY); } else { table.setItemCaptionPropertyId(null); } if (rowIcon) { table.setRowHeaderMode(RowHeaderMode.ICON_ONLY); table.setItemIconPropertyId(MainUI.ICON_PROPERTY); } else { table.setItemIconPropertyId(null); } }
From source file:com.etest.view.notification.NotificationMainUI.java
public NotificationMainUI() { setSizeFull();/*from www .j a va 2s. co m*/ setSpacing(true); if (VaadinSession.getCurrent().getAttribute("userId") == null) { Page.getCurrent().setLocation("http://localhost:8080/"); } else { addComponent(populateNoficationTable()); } HorizontalLayout h = new HorizontalLayout(); h.setWidth("950px"); Button sendMsgBtn = new Button("Send Message"); sendMsgBtn.setWidthUndefined(); sendMsgBtn.addStyleName(ValoTheme.BUTTON_SMALL); sendMsgBtn.addStyleName(ValoTheme.BUTTON_PRIMARY); sendMsgBtn.addClickListener((Button.ClickEvent event) -> { Notification.show("Send Message!"); }); h.addComponent(sendMsgBtn); h.setComponentAlignment(sendMsgBtn, Alignment.MIDDLE_RIGHT); addComponent(h); }
From source file:com.etest.view.notification.NotificationMainUI.java
Table populateNoficationTable() { notificationTable.removeAllItems();/*ww w . ja v a 2 s . c om*/ int i = 0; for (EtestNotification en : ns.getAllNotificationByUser( CommonUtilities.convertStringToInt(VaadinSession.getCurrent().getAttribute("userId").toString()))) { VerticalLayout v = new VerticalLayout(); v.setWidth("100%"); Button read = new Button(); read.setWidthUndefined(); read.setCaption((en.getStatus() == 0) ? "unread" : "read"); read.setData(en.getNotificationId()); read.setIcon(FontAwesome.VIDEO_CAMERA); read.addStyleName(ValoTheme.BUTTON_LINK); read.addStyleName(ValoTheme.BUTTON_TINY); read.addStyleName(ValoTheme.BUTTON_QUIET); read.addStyleName("button-container"); read.addClickListener(buttonClickListener); v.addComponent(read); v.setComponentAlignment(read, Alignment.MIDDLE_LEFT); message.setContentMode(ContentMode.HTML); String[] split = en.getNotice().split(" "); int cellCaseId; if (split[0].equals("CellCaseID")) { message.setCaption(en.getRemarks() + en.getNotice()); cellCaseId = CommonUtilities.convertStringToInt(split[1].replace("#", "")); } else { cellCaseId = cis.getCellItemById(CommonUtilities.convertStringToInt(split[1].replace("#", ""))) .getCellCaseId(); message.setCaption(en.getRemarks() + en.getNotice() + " from CellCaseID #" + cellCaseId); } Button approve = new Button("status"); approve.setSizeFull(); approve.addStyleName(ValoTheme.BUTTON_LINK); approve.addStyleName(ValoTheme.BUTTON_TINY); approve.addStyleName(ValoTheme.BUTTON_QUIET); approve.addStyleName("button-container"); v.addComponent(approve); v.setComponentAlignment(approve, Alignment.MIDDLE_LEFT); if (ccs.getCellCaseById(cellCaseId).getApprovalStatus() == 0) { approve.setIcon(FontAwesome.THUMBS_DOWN); } else { approve.setIcon(FontAwesome.THUMBS_UP); } notificationTable.addItem(new Object[] { message.getCaption().toString(), ss.getUsernameById(en.getSenderId()), en.getNoteDate(), v }, i); i++; } notificationTable.setPageLength(0); notificationTable.setHeight("100%"); return notificationTable; }
From source file:com.etest.view.notification.ViewCaseNotificationWindow.java
VerticalLayout buildForms() { VerticalLayout v = new VerticalLayout(); v.setWidth("700px"); v.setMargin(true);/*from w ww . ja v a 2s . c o m*/ v.setSpacing(true); Label cellCase = new Label(); cellCase.setValue("<b>Case</b>: " + ccs.getCellCaseById(getCellCaseId()).getCaseTopic()); cellCase.setContentMode(ContentMode.HTML); v.addComponent(cellCase); Label cellItem = new Label(); cellItem.setContentMode(ContentMode.HTML); Button approvalBtn = new Button(); approvalBtn.setCaption("Approve CASE"); approvalBtn.setWidthUndefined(); approvalBtn.addStyleName(ValoTheme.BUTTON_TINY); approvalBtn.addStyleName(ValoTheme.BUTTON_PRIMARY); approvalBtn.addClickListener(buttonClickListener); if (ccs.getCellCaseById(getCellCaseId()).getApprovalStatus() == 0) { approvalBtn.setVisible(true); } else { approvalBtn.setVisible(false); } v.addComponent(approvalBtn); HorizontalLayout h1 = new HorizontalLayout(); h1.setWidth("100%"); approvalItemBtn.setVisible(false); approvalItemBtn.setWidthUndefined(); approvalItemBtn.addStyleName(ValoTheme.BUTTON_TINY); approvalItemBtn.addStyleName(ValoTheme.BUTTON_PRIMARY); if (getCellItemId() != 0) { approvalBtn.setCaption("Approve ITEM"); CellItem ci = cis.getCellItemById(getCellItemId()); keyList = k.getAllItemKey(getCellItemId()); keyIndexSize = keyList.size(); if (keyList.isEmpty()) { ShowErrorNotification.error("No Item Key was found for STEM: \n" + ci.getItem()); return null; } stem = ci.getItem().replace("{key}", "<u>" + keyList.get(getKeyIndex()) + "</u>"); cellItem.setValue("<b>STEM</b>: " + getStem()); OptionGroup options = new OptionGroup(); options.addItems(cis.getCellItemById(getCellItemId()).getOptionA(), cis.getCellItemById(getCellItemId()).getOptionB(), cis.getCellItemById(getCellItemId()).getOptionC(), cis.getCellItemById(getCellItemId()).getOptionD()); h1.addComponent(options); h1.setComponentAlignment(options, Alignment.MIDDLE_CENTER); if (cis.getCellItemById(getCellItemId()).getCellItemStatus() == 0) { approvalItemBtn.setVisible(true); } else { approvalItemBtn.setVisible(false); } approvalItemBtn.addClickListener(buttonClickListener); approvalItemBtn.setVisible(true); } v.addComponent(approvalBtn); v.addComponent(cellItem); v.addComponent(h1); v.addComponent(approvalItemBtn); Label separator = new Label("<HR>"); separator.setContentMode(ContentMode.HTML); v.addComponent(separator); return v; }
From source file:com.etest.view.systemadministration.curriculum.CurriculumFormWindow.java
FormLayout buildForms() { FormLayout form = new FormLayout(); form.setMargin(true);/*from ww w . ja va 2s . c om*/ yearLevel.setWidth("75%"); form.addComponent(yearLevel); subjectField.setWidth("75%"); form.addComponent(subjectField); normCourseOffering.setWidth("75%"); form.addComponent(normCourseOffering); descriptiveTitleField.setWidth("100%"); descriptiveTitleField.setRows(3); descriptiveTitleField.setInputPrompt("Descriptive Title.."); form.addComponent(descriptiveTitleField); Button save = new Button("SAVE"); save.setWidth("100%"); save.setIcon(FontAwesome.SAVE); save.addStyleName(ValoTheme.BUTTON_PRIMARY); save.addStyleName(ValoTheme.BUTTON_SMALL); save.addClickListener(buttonClickListener); Button update = new Button("UPDATE"); update.setWidth("100%"); update.setIcon(FontAwesome.ADJUST); update.addStyleName(ValoTheme.BUTTON_PRIMARY); update.addStyleName(ValoTheme.BUTTON_SMALL); update.addClickListener(buttonClickListener); Button delete = new Button("DELETE"); delete.setWidth("100%"); delete.setIcon(FontAwesome.ERASER); delete.addStyleName(ValoTheme.BUTTON_PRIMARY); delete.addStyleName(ValoTheme.BUTTON_SMALL); delete.addClickListener(buttonClickListener); HorizontalLayout hlayout = new HorizontalLayout(); hlayout.setWidth("100%"); hlayout.setSpacing(true); if (getCurriculumId() != 0) { hlayout.addComponent(update); hlayout.addComponent(delete); Curriculum c = cs.getCurriculumById(getCurriculumId()); yearLevel.setValue(c.getYearLevel()); subjectField.setValue(c.getSubject()); normCourseOffering.setValue(c.getNormCourseOffering()); descriptiveTitleField.setValue(c.getDescriptiveTitle()); if (getButtonCaption().equals("edit")) { delete.setVisible(false); } else { update.setVisible(false); } } else { hlayout.addComponent(save); } form.addComponent(hlayout); return form; }
From source file:com.etest.view.systemadministration.CurriculumMainUI.java
public CurriculumMainUI() { setSizeFull();/*from ww w .j ava2s . c o m*/ setMargin(true); setSpacing(true); // addComponent(buildForms()); // populateDataGrid(); Button newBtn = new Button("ADD NEW CURRICULUM"); newBtn.setWidth("220px"); newBtn.setIcon(FontAwesome.OPENID); newBtn.addStyleName(ValoTheme.BUTTON_LINK); newBtn.addStyleName(ValoTheme.BUTTON_SMALL); newBtn.addClickListener(buttonClickListener); addComponent(newBtn); addComponent(dataGridPanel()); }
From source file:com.etest.view.systemadministration.CurriculumMainUI.java
Table populateDataTable() { table.removeAllItems();/*from ww w . j a va 2 s. com*/ int i = 0; for (Curriculum c : cs.getAllCurriculum()) { HorizontalLayout h = new HorizontalLayout(); h.setWidth("100%"); Button edit = new Button("edit"); edit.setSizeFull(); edit.setIcon(FontAwesome.PENCIL); edit.setData(c.getCurriculumId()); edit.addStyleName(ValoTheme.BUTTON_LINK); edit.addStyleName(ValoTheme.BUTTON_TINY); edit.addStyleName("button-container"); edit.addClickListener(buttonClickListener); h.addComponent(edit); Button delete = new Button("del"); delete.setSizeFull(); delete.setIcon(FontAwesome.TRASH_O); delete.setData(c.getCurriculumId()); delete.addStyleName(ValoTheme.BUTTON_LINK); delete.addStyleName(ValoTheme.BUTTON_TINY); delete.addStyleName("button-container"); delete.addClickListener(buttonClickListener); h.addComponent(delete); table.addItem(new Object[] { // c.getCurriculumId(), CommonVariableMap.getYearLevel(c.getYearLevel()), c.getSubject(), c.getDescriptiveTitle(), CommonVariableMap.getNormCourseOffering(c.getNormCourseOffering()), h }, i); i++; } table.setPageLength(table.size()); // table.getListeners(ItemClickEvent.class).stream().forEach((listener) -> { // table.removeListener(ItemClickEvent.class, listener); // }); // // table.addItemClickListener((ItemClickEvent event) -> { // Property itemProperty = event.getItem().getItemProperty("id"); // // Window sub = new CurriculumFormWindow(CommonUtilities.convertStringToInt(itemProperty.getValue().toString())); // if(sub.getParent() == null){ // UI.getCurrent().addWindow(sub); // } // sub.addCloseListener((Window.CloseEvent e) -> { // populateDataTable(); // }); // }); return table; }
From source file:com.etest.view.systemadministration.FacultyMainUI.java
public FacultyMainUI() { setSizeFull();/*from w w w . j a v a2 s .co m*/ setSpacing(true); setMargin(true); Button formBtn = new Button("NEW FACULTY FORM"); formBtn.setWidth("230px"); formBtn.setIcon(FontAwesome.OPENID); formBtn.addStyleName(ValoTheme.BUTTON_LINK); formBtn.addStyleName(ValoTheme.BUTTON_SMALL); formBtn.addClickListener(formBtnClickListener); addComponent(formBtn); addComponent(getDataTablePanel()); }