List of usage examples for com.vaadin.ui Button setEnabled
@Override public void setEnabled(boolean enabled)
From source file:annis.gui.controlpanel.CorpusListPanel.java
License:Apache License
public void initCorpusBrowser(String topLevelCorpusName, final Button l) { AnnisCorpus c = ui.getQueryState().getAvailableCorpora().getItem(topLevelCorpusName).getBean(); MetaDataPanel meta = new MetaDataPanel(c.getName()); CorpusBrowserPanel browse = new CorpusBrowserPanel(c, ui.getQueryController()); GridLayout infoLayout = new GridLayout(2, 2); infoLayout.setSizeFull();//www .j a v a2 s .c om String corpusURL = Helper.generateCorpusLink(Sets.newHashSet(topLevelCorpusName)); Label lblLink = new Label("Link to corpus: <a href=\"" + corpusURL + "\">" + corpusURL + "</a>", ContentMode.HTML); lblLink.setHeight("-1px"); lblLink.setWidth("-1px"); infoLayout.addComponent(meta, 0, 0); infoLayout.addComponent(browse, 1, 0); infoLayout.addComponent(lblLink, 0, 1, 1, 1); infoLayout.setRowExpandRatio(0, 1.0f); infoLayout.setColumnExpandRatio(0, 0.5f); infoLayout.setColumnExpandRatio(1, 0.5f); infoLayout.setComponentAlignment(lblLink, Alignment.MIDDLE_CENTER); Window window = new Window("Corpus information for " + c.getName() + " (ID: " + c.getId() + ")", infoLayout); window.setWidth(70, UNITS_EM); window.setHeight(45, UNITS_EM); window.setResizable(true); window.setModal(false); window.setResizeLazy(true); window.addCloseListener(new Window.CloseListener() { @Override public void windowClose(Window.CloseEvent e) { l.setEnabled(true); } }); UI.getCurrent().addWindow(window); window.center(); }
From source file:annis.visualizers.component.rst.RSTPanel.java
License:Apache License
RSTPanel(VisualizerInput visInput) { String btWidth = "30px"; HorizontalLayout grid = new HorizontalLayout(); final int scrollStep = 200; // the calculation of the output json is done here. final RSTImpl rstView = new RSTImpl(visInput); rstView.setId(UUID.randomUUID().toString()); this.setHeight("-1px"); this.setWidth("100%"); grid.setHeight("-1px"); grid.setWidth("100%"); final Button buttonLeft = new Button(); buttonLeft.setWidth(btWidth);/*from w ww.j av a 2 s.c om*/ buttonLeft.setHeight("100%"); buttonLeft.addStyleName("left-button"); buttonLeft.setEnabled(false); final Button buttonRight = new Button(); buttonRight.setWidth(btWidth); buttonRight.setHeight("100%"); buttonRight.addStyleName("right-button"); buttonLeft.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (rstView.getScrollLeft() < scrollStep) { buttonLeft.setEnabled(false); rstView.setScrollLeft(0); } else { //if the right button was deactivated set it back rstView.setScrollLeft(rstView.getScrollLeft() - scrollStep); } buttonRight.setEnabled(true); } }); buttonRight.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { renderInfo.calculate("#" + rstView.getId() + " canvas"); } }); renderInfo = new CssRenderInfo(new CssRenderInfo.Callback() { @Override public void renderInfoReceived(int width, int height) { if (width - rstView.getScrollLeft() > scrollStep) { buttonLeft.setEnabled(true); rstView.setScrollLeft(rstView.getScrollLeft() + scrollStep); } else { rstView.setScrollLeft(rstView.getScrollLeft() - (width - rstView.getScrollLeft())); buttonLeft.setEnabled(true); buttonRight.setEnabled(false); } } }); rstView.addExtension(renderInfo); grid.addComponent(buttonLeft); grid.addComponent(rstView); grid.addComponent(buttonRight); setContent(grid); grid.setExpandRatio(rstView, 1.0f); }
From source file:at.jku.ce.adaptivetesting.vaadin.ui.topic.accounting.AccountingQuestionManager.java
License:LGPL
public AccountingQuestionManager(String quizName) { super(quizName); Button openKontenplan = new Button("Kontenplan ffnen"); openKontenplan.addClickListener(e -> { openKontenplan.setEnabled(false); // Create Window with layout Window window = new Window("Kontenplan"); GridLayout layout = new GridLayout(1, 1); layout.addComponent(AccountingDataProvider.getInstance().toHtmlTable()); layout.setSizeFull();//from ww w. j a v a2s . c om window.setContent(layout); window.center(); window.setWidth("60%"); window.setHeight("80%"); window.setResizable(false); window.addCloseListener(e1 -> openKontenplan.setEnabled(true)); getUI().addWindow(window); }); addHelpButton(openKontenplan); }
From source file:at.peppol.webgui.app.components.TabInvoiceLine.java
License:Mozilla Public License
private void initElements() { invoiceLineList = parent.getInvoice().getInvoiceLine(); final GridLayout grid = new GridLayout(4, 4); final VerticalLayout outerLayout = new VerticalLayout(); hiddenContent = new VerticalLayout(); hiddenContent.setSpacing(true);//from w ww . j ava 2 s . c o m hiddenContent.setMargin(true); table = new InvoiceLineTable(parent.getInvoice().getInvoiceLine()); table.setSelectable(true); table.setImmediate(true); table.setNullSelectionAllowed(false); table.setHeight(150, UNITS_PIXELS); table.setFooterVisible(false); table.addStyleName("striped strong"); //table.addListener(parent.new LinesTotalAmountListener()); //table.addListener(parent.new TaxExclusiveAmountListener()); final VerticalLayout tableContainer = new VerticalLayout(); tableContainer.addComponent(table); tableContainer.setMargin(false, true, false, false); // buttons Add, Edit, Delete final Button addBtn = new Button("Add new"); final Button editBtn = new Button("Edit selected"); final Button deleteBtn = new Button("Delete Selected"); addBtn.addListener(new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { addBtn.setEnabled(false); editBtn.setEnabled(false); deleteBtn.setEnabled(false); //addMode = true; hiddenContent.removeAllComponents(); invoiceLineItem = createInvoiceLineItem(); final Label formLabel = new Label("<h3>Adding new invoice line</h3>", Label.CONTENT_XHTML); hiddenContent.addComponent(formLabel); final Form form = createInvoiceLineMainForm(); hiddenContent.addComponent(form); HorizontalLayout h1 = new HorizontalLayout(); h1.setSpacing(true); h1.setMargin(true); // Set invoiceLine 0..N cardinality panels //final Panel itemPropertyPanel = new ItemPropertyForm ("Additional", // invoiceLineItem.getInvLineAdditionalItemPropertyList ()); final ItemPropertyForm itemPropertyPanel = new ItemPropertyForm("Additional", invoiceLineItem.getInvLineAdditionalItemPropertyList()); h1.addComponent(itemPropertyPanel); //add the allowance/charge indicator 0..N cardinality final InvoiceLineAllowanceChargeForm lineAllowanceChargePanel = new InvoiceLineAllowanceChargeForm( "", invoiceLineItem.getAllowanceCharge(), parent.getInvoice()); //add the listeners for line extension amount calculation BIIRULE_T10_R018 biirule_t10_r018 = new BIIRULE_T10_R018(invoiceLineItem, form); form.getField("Price Amount").addListener(biirule_t10_r018); form.getField("Base Quantity").addListener(biirule_t10_r018); form.getField("Invoiced Quantity").addListener(biirule_t10_r018); lineAllowanceChargePanel.getTable().addListener((ItemSetChangeListener) biirule_t10_r018); //add the listeners for VAT AE tax total amount EUGEN_T10_R018 eugen_t10_r018 = new EUGEN_T10_R018(form, "Tax Scheme ID", "Tax Category ID", "Tax Total Amount"); form.getField("Tax Scheme ID").addListener(eugen_t10_r018); form.getField("Tax Category ID").addListener(eugen_t10_r018); h1.addComponent(lineAllowanceChargePanel); HorizontalLayout h2 = new HorizontalLayout(); h2.setSpacing(true); h2.setMargin(true); final Panel lineOrderPanel = new InvoiceLineOrderForm("", invoiceLineItem.getInvLineOrderList()); h2.addComponent(lineOrderPanel); final Panel lineCommodityPanel = new InvoiceLineCommodityClassificationForm("", invoiceLineItem.getInvLineCommodityClassificationList()); h2.addComponent(lineCommodityPanel); hiddenContent.addComponent(h1); hiddenContent.addComponent(h2); // Save new line button final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); buttonLayout.addComponent(new Button("Save invoice line", new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { AbstractTextField itemName = (AbstractTextField) form.getField("Item Name"); itemName.setMaxLength(50); if (itemName.getValue().toString().length() > 50) { //itemName.setComponentError(new UserError("Item Name should not be more than 50 characters")); itemName.setValue(itemName.getValue().toString().substring(0, 49)); getWindow().showNotification("Item Name truncated to 50 chars", Notification.TYPE_TRAY_NOTIFICATION); } try { /*Collection<String> props = (Collection<String>) form.getItemPropertyIds(); List<Field> fields = new ArrayList<Field>(); for (String property : props) { fields.add(form.getField(property)); } List<BlurListener> listeners = new ArrayList<BlurListener>(); for (Field f : fields) { if (f instanceof AbstractTextField) { AbstractTextField ff = (AbstractTextField)f; listeners.addAll((Collection<BlurListener>) ff.getListeners(BlurEvent.class)); } } ValidatorsList.validateListenersNotify(listeners); form.validate();*/ Utils.validateFormFields(form); //form.commit(); // update table (and consequently add new item to invoiceList list) table.addLine(invoiceLineItem); //hide form hiddenContent.setVisible(false); //addMode = false; addBtn.setEnabled(true); editBtn.setEnabled(true); deleteBtn.setEnabled(true); //itemName.setComponentError(null); } catch (InvalidValueException e) { getWindow().showNotification("Invoice line has errors", Notification.TYPE_TRAY_NOTIFICATION); } } })); buttonLayout.addComponent(new Button("Cancel", new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { addBtn.setEnabled(true); editBtn.setEnabled(true); deleteBtn.setEnabled(true); hiddenContent.removeAllComponents(); // hide form hiddenContent.setVisible(false); addMode = false; } })); hiddenContent.addComponent(buttonLayout); // hiddenContent.setVisible(!hiddenContent.isVisible()); hiddenContent.setVisible(true); } }); editBtn.addListener(new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { final Object rowId = table.getValue(); // get the selected rows id if (rowId != null) { addBtn.setEnabled(true); editBtn.setEnabled(true); deleteBtn.setEnabled(true); final String sid = (String) table.getContainerProperty(rowId, "ID.value").getValue(); // TODO: PUT THIS IN FUNCTION BEGINS editMode = true; hiddenContent.removeAllComponents(); // get selected item invoiceLineItem = (InvoiceLineAdapter) invoiceLineList.get(table.getIndexFromID(sid)); // clone it to original item originalItem = new InvoiceLineAdapter(); cloneInvoiceLineItem(invoiceLineItem, originalItem); final Label formLabel = new Label("<h3>Editing invoice line</h3>", Label.CONTENT_XHTML); hiddenContent.addComponent(formLabel); final Form form = createInvoiceLineMainForm(); hiddenContent.addComponent(form); HorizontalLayout h1 = new HorizontalLayout(); h1.setSpacing(true); h1.setMargin(true); // Set invoiceLine 0..N cardinality panels final ItemPropertyForm itemPropertyPanel = new ItemPropertyForm("Additional", invoiceLineItem.getInvLineAdditionalItemPropertyList()); h1.addComponent(itemPropertyPanel); //add the allowance/charge indicator 0..N cardinality final InvoiceLineAllowanceChargeForm lineAllowanceChargePanel = new InvoiceLineAllowanceChargeForm( "", invoiceLineItem.getAllowanceCharge(), parent.getInvoice()); //add the listeners for line extension amount calculation BIIRULE_T10_R018 biirule_t10_r018 = new BIIRULE_T10_R018(invoiceLineItem, form); form.getField("Price Amount").addListener(biirule_t10_r018); form.getField("Base Quantity").addListener(biirule_t10_r018); lineAllowanceChargePanel.getTable().addListener((ItemSetChangeListener) biirule_t10_r018); //add the listeners for VAT AE tax total amount EUGEN_T10_R018 eugen_t10_r018 = new EUGEN_T10_R018(form, "Tax Scheme ID", "Tax Category ID", "Tax Total Amount"); form.getField("Tax Scheme ID").addListener(eugen_t10_r018); form.getField("Tax Category ID").addListener(eugen_t10_r018); h1.addComponent(lineAllowanceChargePanel); HorizontalLayout h2 = new HorizontalLayout(); h2.setSpacing(true); h2.setMargin(true); final Panel lineOrderPanel = new InvoiceLineOrderForm("", invoiceLineItem.getInvLineOrderList()); h2.addComponent(lineOrderPanel); final Panel lineCommodityPanel = new InvoiceLineCommodityClassificationForm("", invoiceLineItem.getInvLineCommodityClassificationList()); h2.addComponent(lineCommodityPanel); hiddenContent.addComponent(h1); hiddenContent.addComponent(h2); /*// Set invoiceLine 0..N cardinalily panels final Panel itemPropertyPanel = new ItemPropertyForm ("Additional", invoiceLineItem.getInvLineAdditionalItemPropertyList ()); hiddenContent.addComponent (itemPropertyPanel);*/ // Save new line button final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); buttonLayout.addComponent(new Button("Save changes", new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { // update table (and consequently edit item to allowanceChargeList // list) AbstractTextField itemName = (AbstractTextField) form.getField("Item Name"); itemName.setMaxLength(50); if (itemName.getValue().toString().length() > 50) { //itemName.setComponentError(new UserError("Item Name should not be more than 50 characters")); itemName.setValue(itemName.getValue().toString().substring(0, 49)); getWindow().showNotification("Item Name truncated to 50 chars", Notification.TYPE_TRAY_NOTIFICATION); } try { /*Collection<String> props = (Collection<String>) form.getItemPropertyIds(); List<Field> fields = new ArrayList<Field>(); for (String property : props) { fields.add(form.getField(property)); } List<BlurListener> listeners = new ArrayList<BlurListener>(); for (Field f : fields) { if (f instanceof AbstractTextField) { AbstractTextField ff = (AbstractTextField)f; listeners.addAll((Collection<BlurListener>) ff.getListeners(BlurEvent.class)); } } ValidatorsList.validateListenersNotify(listeners); form.validate();*/ Utils.validateFormFields(form); //table.setInvoiceLine (sid, invoiceLineItem); table.setLine(sid, invoiceLineItem); addBtn.setEnabled(true); editBtn.setEnabled(true); deleteBtn.setEnabled(true); // hide form hiddenContent.setVisible(false); editMode = false; } catch (InvalidValueException e) { getWindow().showNotification("Invoice line has errors", Notification.TYPE_TRAY_NOTIFICATION); } } })); buttonLayout.addComponent(new Button("Cancel editing", new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { hiddenContent.removeAllComponents(); addBtn.setEnabled(true); editBtn.setEnabled(true); deleteBtn.setEnabled(true); //table.setInvoiceLine (sid, originalItem); table.setLine(sid, originalItem); // hide form hiddenContent.setVisible(false); editMode = false; } })); hiddenContent.addComponent(buttonLayout); // hiddenContent.setVisible(!hiddenContent.isVisible()); hiddenContent.setVisible(true); // TODO: PUT THIS IN FUNCTION ENDS } else { parent.getWindow().showNotification("Info", "No table line is selected", Window.Notification.TYPE_HUMANIZED_MESSAGE); } } }); deleteBtn.addListener(new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { final Object rowId = table.getValue(); // get the selected rows id if (rowId != null) { if (table.getContainerProperty(rowId, "ID.value").getValue() != null) { final String sid = (String) table.getContainerProperty(rowId, "ID.value").getValue(); //table.removeInvoiceLine (sid); table.removeLine(sid); } } else { parent.getWindow().showNotification("Info", "No table line is selected", Window.Notification.TYPE_HUMANIZED_MESSAGE); } } }); final VerticalLayout buttonsContainer = new VerticalLayout(); buttonsContainer.setSpacing(true); buttonsContainer.addComponent(addBtn); buttonsContainer.addComponent(editBtn); buttonsContainer.addComponent(deleteBtn); final Panel outerPanel = new Panel("Invoice Line"); grid.addComponent(tableContainer, 0, 0); grid.addComponent(buttonsContainer, 1, 0); outerPanel.addComponent(grid); outerLayout.addComponent(outerPanel); // ---- HIDDEN FORM BEGINS ----- final VerticalLayout formLayout = new VerticalLayout(); formLayout.addComponent(hiddenContent); hiddenContent.setVisible(false); outerLayout.addComponent(formLayout); // ---- HIDDEN FORM ENDS ----- setLayout(outerLayout); grid.setSizeUndefined(); outerPanel.requestRepaintAll(); }
From source file:at.reisisoft.jku.ce.adaptivelearning.vaadin.ui.topic.accounting.AccountingQuestionManager.java
License:LGPL
public AccountingQuestionManager(String quizName) { super(quizName); Button openKontenplan = new Button("Open Kontenplan"); openKontenplan.addClickListener(e -> { openKontenplan.setEnabled(false); // Create Window with layout Window window = new Window("Kontenplan"); GridLayout layout = new GridLayout(1, 1); layout.addComponent(AccountingDataProvider.getInstance().toHtmlTable()); layout.setSizeFull();//www.j av a 2 s .c om window.setContent(layout); window.center(); window.setWidth("60%"); window.setHeight("80%"); window.setResizable(false); window.addCloseListener(e1 -> openKontenplan.setEnabled(true)); getUI().addWindow(window); }); addHelpButton(openKontenplan); }
From source file:com.cavisson.gui.dashboard.components.controls.ButtonsAndLinks.java
License:Apache License
/** * *//*from w w w .jav a 2s .com*/ public ButtonsAndLinks() { setMargin(true); Label h1 = new Label("Buttons"); h1.addStyleName("h1"); addComponent(h1); HorizontalLayout row = new HorizontalLayout(); row.addStyleName("wrapping"); row.setSpacing(true); addComponent(row); Button button = new Button("Normal"); row.addComponent(button); button = new Button("Disabled"); button.setEnabled(false); row.addComponent(button); button = new Button("Primary"); button.addStyleName("primary"); row.addComponent(button); button = new Button("Friendly"); button.addStyleName("friendly"); row.addComponent(button); button = new Button("Danger"); button.addStyleName("danger"); row.addComponent(button); TestIcon testIcon = new TestIcon(10); button = new Button("Small"); button.addStyleName("small"); button.setIcon(testIcon.get()); row.addComponent(button); button = new Button("Large"); button.addStyleName("large"); button.setIcon(testIcon.get()); row.addComponent(button); button = new Button("Top"); button.addStyleName("icon-align-top"); button.setIcon(testIcon.get()); row.addComponent(button); button = new Button("Image icon"); button.setIcon(testIcon.get(true, 16)); row.addComponent(button); button = new Button("Image icon"); button.addStyleName("icon-align-right"); button.setIcon(testIcon.get(true)); row.addComponent(button); button = new Button("Photos"); button.setIcon(testIcon.get()); row.addComponent(button); button = new Button(); button.setIcon(testIcon.get()); button.addStyleName("icon-only"); row.addComponent(button); button = new Button("Borderless"); button.setIcon(testIcon.get()); button.addStyleName("borderless"); row.addComponent(button); button = new Button("Borderless, colored"); button.setIcon(testIcon.get()); button.addStyleName("borderless-colored"); row.addComponent(button); button = new Button("Quiet"); button.setIcon(testIcon.get()); button.addStyleName("quiet"); row.addComponent(button); button = new Button("Link style"); button.setIcon(testIcon.get()); button.addStyleName("link"); row.addComponent(button); button = new Button("Icon on right"); button.setIcon(testIcon.get()); button.addStyleName("icon-align-right"); row.addComponent(button); CssLayout group = new CssLayout(); group.addStyleName("v-component-group"); row.addComponent(group); button = new Button("One"); group.addComponent(button); button = new Button("Two"); group.addComponent(button); button = new Button("Three"); group.addComponent(button); button = new Button("Tiny"); button.addStyleName("tiny"); row.addComponent(button); button = new Button("Huge"); button.addStyleName("huge"); row.addComponent(button); NativeButton nbutton = new NativeButton("Native"); row.addComponent(nbutton); h1 = new Label("Links"); h1.addStyleName("h1"); addComponent(h1); row = new HorizontalLayout(); row.addStyleName("wrapping"); row.setSpacing(true); addComponent(row); Link link = new Link("vaadin.com", new ExternalResource("https://vaadin.com")); row.addComponent(link); link = new Link("Link with icon", new ExternalResource("https://vaadin.com")); link.addStyleName("color3"); link.setIcon(testIcon.get()); row.addComponent(link); link = new Link("Small", new ExternalResource("https://vaadin.com")); link.addStyleName("small"); row.addComponent(link); link = new Link("Large", new ExternalResource("https://vaadin.com")); link.addStyleName("large"); row.addComponent(link); link = new Link(null, new ExternalResource("https://vaadin.com")); link.setIcon(testIcon.get()); link.addStyleName("large"); row.addComponent(link); }
From source file:com.cavisson.gui.dashboard.components.controls.CommonParts.java
License:Apache License
Panel windows() { Panel p = new Panel("Dialogs"); VerticalLayout content = new VerticalLayout() { final Window win = new Window("Window Caption"); String prevHeight = "300px"; boolean footerVisible = true; boolean autoHeight = false; boolean tabsVisible = false; boolean toolbarVisible = false; boolean footerToolbar = false; boolean toolbarLayout = false; String toolbarStyle = null; VerticalLayout windowContent() { VerticalLayout root = new VerticalLayout(); if (toolbarVisible) { MenuBar menuBar = MenuBars.getToolBar(); menuBar.setSizeUndefined(); menuBar.setStyleName(toolbarStyle); Component toolbar = menuBar; if (toolbarLayout) { menuBar.setWidth(null); HorizontalLayout toolbarLayout = new HorizontalLayout(); toolbarLayout.setWidth("100%"); toolbarLayout.setSpacing(true); Label label = new Label("Tools"); label.setSizeUndefined(); toolbarLayout.addComponents(label, menuBar); toolbarLayout.setExpandRatio(menuBar, 1); toolbarLayout.setComponentAlignment(menuBar, Alignment.TOP_RIGHT); toolbar = toolbarLayout; }//from www.j a v a 2 s.c om toolbar.addStyleName("v-window-top-toolbar"); root.addComponent(toolbar); } Component content = null; if (tabsVisible) { TabSheet tabs = new TabSheet(); tabs.setSizeFull(); VerticalLayout l = new VerticalLayout(); l.addComponent(new Label( "<h2>Subtitle</h2><p>Normal type for plain text. Etiam at risus et justo dignissim congue. Phasellus laoreet lorem vel dolor tempus vehicula.</p><p>Quisque ut dolor gravida, placerat libero vel, euismod. Etiam habebis sem dicantur magna mollis euismod. Nihil hic munitissimus habendi senatus locus, nihil horum? Curabitur est gravida et libero vitae dictum. Ullamco laboris nisi ut aliquid ex ea commodi consequat. Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</p>", ContentMode.HTML)); l.setMargin(true); tabs.addTab(l, "Selected"); tabs.addTab(new Label(" ", ContentMode.HTML), "Another"); tabs.addTab(new Label(" ", ContentMode.HTML), "One more"); tabs.addStyleName("padded-tabbar"); tabs.addSelectedTabChangeListener(new SelectedTabChangeListener() { @Override public void selectedTabChange(final SelectedTabChangeEvent event) { try { Thread.sleep(600); } catch (InterruptedException e) { e.printStackTrace(); } } }); content = tabs; } else if (!autoHeight) { Panel p = new Panel(); p.setSizeFull(); p.addStyleName("borderless"); if (!toolbarVisible || !toolbarLayout) { p.addStyleName("scroll-divider"); } VerticalLayout l = new VerticalLayout(); l.addComponent(new Label( "<h2>Subtitle</h2><p>Normal type for plain text. Etiam at risus et justo dignissim congue. Phasellus laoreet lorem vel dolor tempus vehicula.</p><p>Quisque ut dolor gravida, placerat libero vel, euismod. Etiam habebis sem dicantur magna mollis euismod. Nihil hic munitissimus habendi senatus locus, nihil horum? Curabitur est gravida et libero vitae dictum. Ullamco laboris nisi ut aliquid ex ea commodi consequat. Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</p>", ContentMode.HTML)); l.setMargin(true); p.setContent(l); content = p; } else { content = new Label( "<h2>Subtitle</h2><p>Normal type for plain text. Etiam at risus et justo dignissim congue. Phasellus laoreet lorem vel dolor tempus vehicula.</p><p>Quisque ut dolor gravida, placerat libero vel, euismod. Etiam habebis sem dicantur magna mollis euismod. Nihil hic munitissimus habendi senatus locus, nihil horum? Curabitur est gravida et libero vitae dictum. Ullamco laboris nisi ut aliquid ex ea commodi consequat. Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</p>", ContentMode.HTML); root.setMargin(true); } root.addComponent(content); if (footerVisible) { HorizontalLayout footer = new HorizontalLayout(); footer.setWidth("100%"); footer.setSpacing(true); footer.addStyleName("v-window-bottom-toolbar"); Label footerText = new Label("Footer text"); footerText.setSizeUndefined(); Button ok = new Button("OK"); ok.addStyleName("primary"); Button cancel = new Button("Cancel"); footer.addComponents(footerText, ok, cancel); footer.setExpandRatio(footerText, 1); if (footerToolbar) { MenuBar menuBar = MenuBars.getToolBar(); menuBar.setStyleName(toolbarStyle); menuBar.setWidth(null); footer.removeAllComponents(); footer.addComponent(menuBar); } root.addComponent(footer); } if (!autoHeight) { root.setSizeFull(); root.setExpandRatio(content, 1); } return root; } { setSpacing(true); setMargin(true); win.setWidth("380px"); win.setHeight(prevHeight); win.setClosable(false); win.setResizable(false); win.setContent(windowContent()); win.setCloseShortcut(KeyCode.ESCAPE, null); Command optionsCommand = new Command() { @Override public void menuSelected(final MenuItem selectedItem) { if (selectedItem.getText().equals("Footer")) { footerVisible = selectedItem.isChecked(); } if (selectedItem.getText().equals("Auto Height")) { autoHeight = selectedItem.isChecked(); if (!autoHeight) { win.setHeight(prevHeight); } else { prevHeight = win.getHeight() + win.getHeightUnits().toString(); win.setHeight(null); } } if (selectedItem.getText().equals("Tabs")) { tabsVisible = selectedItem.isChecked(); } if (selectedItem.getText().equals("Top")) { toolbarVisible = selectedItem.isChecked(); } if (selectedItem.getText().equals("Footer")) { footerToolbar = selectedItem.isChecked(); } if (selectedItem.getText().equals("Top layout")) { toolbarLayout = selectedItem.isChecked(); } if (selectedItem.getText().equals("Borderless")) { toolbarStyle = selectedItem.isChecked() ? "borderless" : null; } win.setContent(windowContent()); } }; MenuBar options = new MenuBar(); options.setCaption("Content"); options.addItem("Auto Height", optionsCommand).setCheckable(true); options.addItem("Tabs", optionsCommand).setCheckable(true); MenuItem option = options.addItem("Footer", optionsCommand); option.setCheckable(true); option.setChecked(true); options.addStyleName("small"); addComponent(options); options = new MenuBar(); options.setCaption("Toolbars"); options.addItem("Footer", optionsCommand).setCheckable(true); options.addItem("Top", optionsCommand).setCheckable(true); options.addItem("Top layout", optionsCommand).setCheckable(true); options.addItem("Borderless", optionsCommand).setCheckable(true); options.addStyleName("small"); addComponent(options); Command optionsCommand2 = new Command() { @Override public void menuSelected(final MenuItem selectedItem) { if (selectedItem.getText().equals("Caption")) { win.setCaption(selectedItem.isChecked() ? "Window Caption" : null); } else if (selectedItem.getText().equals("Closable")) { win.setClosable(selectedItem.isChecked()); } else if (selectedItem.getText().equals("Resizable")) { win.setResizable(selectedItem.isChecked()); } else if (selectedItem.getText().equals("Modal")) { win.setModal(selectedItem.isChecked()); } } }; options = new MenuBar(); options.setCaption("Options"); MenuItem caption = options.addItem("Caption", optionsCommand2); caption.setCheckable(true); caption.setChecked(true); options.addItem("Closable", optionsCommand2).setCheckable(true); options.addItem("Resizable", optionsCommand2).setCheckable(true); options.addItem("Modal", optionsCommand2).setCheckable(true); options.addStyleName("small"); addComponent(options); final Button show = new Button("Open Window", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { getUI().addWindow(win); win.center(); win.focus(); event.getButton().setEnabled(false); } }); show.addStyleName("primary"); addComponent(show); final CheckBox hidden = new CheckBox("Hidden"); hidden.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { win.setVisible(!hidden.getValue()); } }); addComponent(hidden); win.addCloseListener(new CloseListener() { @Override public void windowClose(final CloseEvent e) { show.setEnabled(true); } }); } }; p.setContent(content); return p; }
From source file:com.cms.component.CustomPageTable.java
public HorizontalLayout createControls(String pageSizeDefault) { this.pageSizeDefault = pageSizeDefault; separatorTotal.setImmediate(true);//ww w. j a v a 2 s . c om Label itemsPerPageLabel = new Label(BundleUtils.getString("common.table.numberRecord")); for (String numberSize : Constants.PAGE_SIZE_LIST) { itemsPerPageSelect.addItem(numberSize); } itemsPerPageSelect.setImmediate(true); itemsPerPageSelect.setNullSelectionAllowed(false); itemsPerPageSelect.setWidth("50px"); itemsPerPageSelect.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = -2255853716069800092L; @Override public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { setPageLength(Integer.valueOf(String.valueOf(event.getProperty().getValue()))); firePagedChangedEvent(); } }); itemsPerPageSelect.select(pageSizeDefault); Label pageLabel = new Label(BundleUtils.getString("common.table.page"), ContentMode.HTML); final TextField currentPageTextField = new TextField(); currentPageTextField.setValue(String.valueOf(getCurrentPage())); currentPageTextField.setConverter(Integer.class); currentPageTextField .addValidator(new IntegerRangeValidator("Wrong page number", 1, getTotalAmountOfPages())); Label separatorLabel = new Label(" / ", ContentMode.HTML); final Label totalPagesLabel = new Label(String.valueOf(getTotalAmountOfPages()), ContentMode.HTML); currentPageTextField.setStyleName(Reindeer.TEXTFIELD_SMALL); currentPageTextField.setImmediate(true); currentPageTextField.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = -2255853716069800092L; @Override public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { currentPageTextField.removeAllValidators(); currentPageTextField .addValidator(new IntegerRangeValidator("Wrong page number", 1, getTotalAmountOfPages())); if (Integer.valueOf(String.valueOf(currentPageTextField.getValue())) <= getTotalAmountOfPages()) { int page = Integer.valueOf(String.valueOf(currentPageTextField.getValue())); setCurrentPage(page); } } }); pageLabel.setWidth(null); currentPageTextField.setWidth("30px"); separatorLabel.setWidth(null); totalPagesLabel.setWidth(null); HorizontalLayout controlBar = new HorizontalLayout(); HorizontalLayout pageSize = new HorizontalLayout(); HorizontalLayout pageManagement = new HorizontalLayout(); final Button first = new Button("<<", new Button.ClickListener() { private static final long serialVersionUID = -355520120491283992L; @Override public void buttonClick(Button.ClickEvent event) { setCurrentPage(0); } }); previous = new Button("<", new Button.ClickListener() { private static final long serialVersionUID = -355520120491283992L; @Override public void buttonClick(Button.ClickEvent event) { previousPage(); } }); final Button next = new Button(">", new Button.ClickListener() { private static final long serialVersionUID = -1927138212640638452L; @Override public void buttonClick(Button.ClickEvent event) { nextPage(); } }); final Button last = new Button(">>", new Button.ClickListener() { private static final long serialVersionUID = -355520120491283992L; @Override public void buttonClick(Button.ClickEvent event) { setCurrentPage(getTotalAmountOfPages()); } }); first.setStyleName(Reindeer.BUTTON_LINK); previous.setStyleName(Reindeer.BUTTON_LINK); next.setStyleName(Reindeer.BUTTON_LINK); last.setStyleName(Reindeer.BUTTON_LINK); itemsPerPageLabel.addStyleName("pagedtable-itemsperpagecaption"); itemsPerPageSelect.addStyleName("pagedtable-itemsperpagecombobox"); pageLabel.addStyleName("pagedtable-pagecaption"); currentPageTextField.addStyleName("pagedtable-pagefield"); separatorLabel.addStyleName("pagedtable-separator"); separatorTotal.addStyleName("pagedtable-separator"); totalPagesLabel.addStyleName("pagedtable-total"); first.addStyleName("pagedtable-first"); previous.addStyleName("pagedtable-previous"); next.addStyleName("pagedtable-next"); last.addStyleName("pagedtable-last"); itemsPerPageLabel.addStyleName("pagedtable-label"); itemsPerPageSelect.addStyleName("pagedtable-combobox"); pageLabel.addStyleName("pagedtable-label"); currentPageTextField.addStyleName("pagedtable-label"); separatorLabel.addStyleName("pagedtable-label"); separatorTotal.addStyleName("pagedtable-label"); totalPagesLabel.addStyleName("pagedtable-label"); first.addStyleName("pagedtable-button"); previous.addStyleName("pagedtable-button"); next.addStyleName("pagedtable-button"); last.addStyleName("pagedtable-button"); pageSize.addComponent(itemsPerPageLabel); pageSize.addComponent(itemsPerPageSelect); Label separator = new Label(" / ", ContentMode.HTML); pageSize.addComponent(separator); pageSize.addComponent(separatorTotal); pageSize.setComponentAlignment(itemsPerPageLabel, Alignment.MIDDLE_LEFT); pageSize.setComponentAlignment(itemsPerPageSelect, Alignment.MIDDLE_LEFT); pageSize.setComponentAlignment(separator, Alignment.MIDDLE_LEFT); pageSize.setComponentAlignment(separatorTotal, Alignment.MIDDLE_LEFT); pageSize.setSpacing(true); pageManagement.addComponent(first); pageManagement.addComponent(previous); pageManagement.addComponent(pageLabel); pageManagement.addComponent(currentPageTextField); pageManagement.addComponent(separatorLabel); pageManagement.addComponent(totalPagesLabel); pageManagement.addComponent(next); pageManagement.addComponent(last); pageManagement.setComponentAlignment(first, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(previous, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(pageLabel, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(currentPageTextField, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(separatorLabel, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(totalPagesLabel, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(next, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(last, Alignment.MIDDLE_LEFT); pageManagement.setWidth(null); pageManagement.setSpacing(true); controlBar.addComponent(pageSize); controlBar.addComponent(pageManagement); controlBar.setComponentAlignment(pageManagement, Alignment.MIDDLE_CENTER); controlBar.setWidth("100%"); controlBar.setExpandRatio(pageSize, 1); addListener(new PageChangeListener() { @Override public void pageChanged(PagedTableChangeEvent event) { int abc = event.getCurrentPage(); first.setEnabled(container.getStartIndex() > 0); previous.setEnabled(container.getStartIndex() > 0); next.setEnabled(container.getStartIndex() < container.getRealSize() - getPageLength()); last.setEnabled(container.getStartIndex() < container.getRealSize() - getPageLength()); currentPageTextField.setValue(String.valueOf(getCurrentPage())); totalPagesLabel.setValue(String.valueOf(getTotalAmountOfPages())); if (resizePage) { int lenght = getPageLength(); int a = lenght % 5; int b = lenght / 5; if (a != 0) { int pageLenght = 5 * (b + 1); itemsPerPageSelect.setValue(pageLenght); } } separatorTotal.setValue(String.valueOf(container.getRealSize())); } }); return controlBar; }
From source file:com.constellio.app.ui.pages.base.MainLayoutImpl.java
private ConstellioMenuButton buildButton(final NavigationItem item) { ComponentState state = presenter.getStateFor(item); Button button = new Button($("MainLayout." + item.getCode())); button.setVisible(state.isVisible()); button.setEnabled(state.isEnabled()); button.addStyleName(item.getCode()); if (item.getFontAwesome() != null) { button.setIcon(item.getFontAwesome()); }/*w w w . j a v a 2 s.c o m*/ button.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { item.activate(navigate()); } }); return new ConstellioMenuButton(item.getViewGroup(), button); }
From source file:com.esofthead.mycollab.mobile.module.project.view.task.TaskListViewImpl.java
License:Open Source License
@Override protected Component createRightComponent() { NavigationBarQuickMenu editBtn = new NavigationBarQuickMenu(); editBtn.setButtonCaption(null);//from w w w .jav a 2 s. c o m editBtn.setStyleName("edit-btn"); ProjectPreviewFormControlsGenerator<SimpleTaskList> controlsGenerator = new ProjectPreviewFormControlsGenerator<>( this); VerticalLayout menuContent = controlsGenerator.createButtonControls(ProjectRolePermissionCollections.TASKS); Button viewTaskList = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_VIEW), new Button.ClickListener() { private static final long serialVersionUID = 150675475815367481L; @Override public void buttonClick(Button.ClickEvent event) { EventBusFactory.getInstance() .post(new TaskEvent.GotoListView(this, currentTaskList.getId())); } }); viewTaskList.setWidth("100%"); viewTaskList.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)); Button addNewTask = new Button(AppContext.getMessage(TaskI18nEnum.BUTTON_NEW_TASK), new Button.ClickListener() { private static final long serialVersionUID = -8074297964143853121L; @Override public void buttonClick(Button.ClickEvent event) { EventBusFactory.getInstance().post(new TaskEvent.GotoAdd(this, currentTaskList.getId())); } }); addNewTask.setWidth("100%"); addNewTask.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)); Button closeBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CLOSE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { currentTaskList.setStatus(StatusI18nEnum.Closed.name()); final ProjectTaskListService taskListService = ApplicationContextUtil .getSpringBean(ProjectTaskListService.class); taskListService.updateWithSession(currentTaskList, AppContext.getUsername()); EventBusFactory.getInstance().post(new ShellEvent.NavigateBack(this, null)); } }); closeBtn.setWidth("100%"); closeBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)); controlsGenerator.insertToControlBlock(closeBtn); controlsGenerator.insertToControlBlock(viewTaskList); controlsGenerator.insertToControlBlock(addNewTask); editBtn.setContent(menuContent); return editBtn; }