List of usage examples for com.vaadin.ui Button addStyleName
@Override public void addStyleName(String style)
From source file:info.magnolia.social.config.MediaHubConfigSubAppViewImpl.java
License:Open Source License
protected void build() { Button executeButton = new Button("do something"); executeButton.addStyleName("v-button-smallapp"); executeButton.addStyleName("commit"); executeButton.addClickListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { listener.onActionTriggered(); }//from w w w . ja v a 2s. com }); buttonLayout.addStyleName("v-csslayout-smallapp-actions"); buttonLayout.addComponent(executeButton); inputSection.addComponent(buttonLayout); content.addSection(inputSection); }
From source file:info.magnolia.ui.form.field.MultiField.java
License:Open Source License
/** * Create a single element.<br>//w w w . j ava2 s.co m * This single element is composed of:<br> * - a configured field <br> * - a remove Button<br> */ private Component createEntryComponent(Object propertyId, Property<?> property) { final HorizontalLayout layout = new HorizontalLayout(); layout.setWidth(100, Unit.PERCENTAGE); layout.setHeight(-1, Unit.PIXELS); final Field<?> field = createLocalField(fieldDefinition, property, true); // creates property datasource if given property is null layout.addComponent(field); // bind the field's property to the item if (property == null) { property = field.getPropertyDataSource(); ((PropertysetItem) getPropertyDataSource().getValue()).addItemProperty(propertyId, property); } final Property<?> propertyReference = property; // set layout to full width layout.setWidth(100, Unit.PERCENTAGE); // distribute space in favour of field over delete button layout.setExpandRatio(field, 1); if (definition.isReadOnly()) { return layout; } // move up Button Button moveUpButton = new Button(); moveUpButton.setHtmlContentAllowed(true); moveUpButton.setCaption("<span class=\"" + "icon-arrow2_n" + "\"></span>"); moveUpButton.addStyleName("inline"); moveUpButton.setDescription(buttonCaptionMoveUp); moveUpButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { onMove(layout, propertyReference, true); } }); // move down Button Button moveDownButton = new Button(); moveDownButton.setHtmlContentAllowed(true); moveDownButton.setCaption("<span class=\"" + "icon-arrow2_s" + "\"></span>"); moveDownButton.addStyleName("inline"); moveDownButton.setDescription(buttonCaptionMoveDown); moveDownButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { onMove(layout, propertyReference, false); } }); // Delete Button Button deleteButton = new Button(); deleteButton.setHtmlContentAllowed(true); deleteButton.setCaption("<span class=\"" + "icon-trash" + "\"></span>"); deleteButton.addStyleName("inline"); deleteButton.setDescription(buttonCaptionRemove); deleteButton.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { onDelete(layout, propertyReference); } }); layout.addComponents(moveUpButton, moveDownButton, deleteButton); // make sure button stays aligned with the field and not with the optional field label when used layout.setComponentAlignment(deleteButton, Alignment.BOTTOM_RIGHT); layout.setComponentAlignment(moveUpButton, Alignment.BOTTOM_RIGHT); layout.setComponentAlignment(moveDownButton, Alignment.BOTTOM_RIGHT); return layout; }
From source file:info.magnolia.ui.form.field.upload.basic.BasicUploadField.java
License:Open Source License
/** * Create the Cancel Button./* w ww.j a v a2s. c om*/ * Used to cancel an ongoing Upload. */ private Button createCancelButton() { Button cancelButton = new NativeButton(null, new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { interruptUpload(InterruptionReason.USER); } }); cancelButton.addStyleName("cancel"); return cancelButton; }
From source file:info.magnolia.ui.form.field.upload.basic.BasicUploadField.java
License:Open Source License
/** * Create Delete button.// w w w . ja v a 2 s. c o m */ protected Button createDeleteButton() { Button deleteButton = new Button(); deleteButton.setHtmlContentAllowed(true); deleteButton.setCaption("<span class=\"" + "icon-trash" + "\"></span>"); deleteButton.addStyleName("inline"); deleteButton.setDescription(i18n.translate(deleteCaption)); deleteButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { resetDataSource(); updateDisplay(); } }); return deleteButton; }
From source file:info.magnolia.ui.vaadin.switcher.Switcher.java
License:Open Source License
private void setButtonEnabled(Button button, boolean isEnabled) { if (isEnabled) { button.removeStyleName("disabled"); button.removeStyleName("v-button-disabled"); button.removeStyleName("switcher-back-disabled"); } else {//www. j ava 2s . com button.addStyleName("disabled"); } }
From source file:info.magnolia.ui.workbench.contenttool.search.SearchContentToolViewImpl.java
License:Open Source License
@Inject public SearchContentToolViewImpl(SimpleTranslator i18n) { this.i18n = i18n; Button clearSearchBoxButton = new Button(); clearSearchBoxButton.setStyleName("m-closebutton"); clearSearchBoxButton.addStyleName("icon-delete-search"); clearSearchBoxButton.addStyleName("searchbox-clearbutton"); // Preventing the button to spoil the tab-navigation due to its changing display value. clearSearchBoxButton.setTabIndex(-1); clearSearchBoxButton.addClickListener(new Button.ClickListener() { @Override//from w ww .j a va2 s . com public void buttonClick(Button.ClickEvent event) { searchField.setValue(""); } }); Icon searchIcon = new Icon("search"); searchIcon.addStyleName("searchbox-icon"); Icon searchArrow = new Icon("arrow2_s"); searchArrow.addStyleName("searchbox-arrow"); searchField = buildSearchField(); setVisible(true); addComponent(searchField); addComponent(clearSearchBoxButton); addComponent(searchIcon); addComponent(searchArrow); setStyleName("searchbox"); }
From source file:info.magnolia.vaadin.periscope.Periscope.java
License:Open Source License
private Component createSpeechButton() { final Button startStopButton = new Button(); startStopButton.addStyleName("record-button"); startStopButton.setCaptionAsHtml(true); startStopButton.setCaption("<span class=\"ion-mic-a\"></span>"); startStopButton.setClickShortcut(ShortcutAction.KeyCode.R, ShortcutAction.ModifierKey.SHIFT, ShortcutAction.ModifierKey.ALT); final AtomicBoolean isRecording = new AtomicBoolean(false); speechRecognizer.addSpeechResultListener(transcript -> { input.setValue(transcript);/*from w ww.j a v a2 s . c o m*/ this.consumeQuery(transcript, true); startStopButton.removeStyleName("recording"); isRecording.set(false); }); startStopButton.addClickListener((Button.ClickListener) event -> { if (isRecording.get()) { return; } speechRecognizer.record(); startStopButton.addStyleName("recording"); isRecording.set(true); }); final VerticalLayout speechWrapper = new VerticalLayout(startStopButton, speechRecognizer); speechWrapper.addStyleName("speech-recognition"); return speechWrapper; }
From source file:io.github.jikuja.vaadin_yamapa.ui.views.PoiMap.java
License:Creative Commons License
private void setupCenterCrossHair() { Button helper = new Button(); helper.addStyleName("helper"); helper.setIcon(FontAwesome.CROSSHAIRS); helper.addStyleName(ValoTheme.BUTTON_BORDERLESS); helper.addStyleName(ValoTheme.BUTTON_ICON_ONLY); addComponent(helper);//from w w w .j a v a 2 s .co m }
From source file:io.mateu.ui.vaadin.framework.MyUI.java
License:Apache License
public void setMenuActual(MenuEntry menuActual) { this.menuActual = menuActual; for (MenuEntry e : botonesMenu.keySet()) { Button b = botonesMenu.get(e); if (menuActual == null || !(menuActual.equals(e) || (getApp().getPath(menuActual) != null && getApp().getPath(menuActual).contains(e)))) b.removeStyleName("posicionactual"); if (menuActual != null && (menuActual.equals(e) || (getApp().getPath(menuActual) != null && getApp().getPath(menuActual).contains(e)))) b.addStyleName("posicionactual"); }/*from w w w . j av a2 s .c om*/ }
From source file:io.mateu.ui.vaadin.framework.MyUI.java
License:Apache License
/** * abre una vista. La colocar en el lado derecho * * @param ui// w w w .j ava 2s . c o m * @param view */ public static void addView(MyUI ui, AbstractView view) { if (view == null) { System.out.println("abriendo vista null"); ui.getViewDisplay().removeAllComponents(); } else { System.out.println("abriendo vista " + view.getClass().getName() + "::" + view.getViewId()); ViewLayout v = new ViewLayout(view); if (view instanceof AbstractDialog) { AbstractDialog d = (AbstractDialog) view; // Create a sub-window and set the content Window subWindow = new Window(((AbstractDialog) view).getTitle()); HorizontalLayout footer = new HorizontalLayout(); footer.setWidth("100%"); footer.setSpacing(true); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); Label footerText = new Label(""); footerText.setSizeUndefined(); Button ok; if (d instanceof AbstractAddRecordDialog) { ok = new Button("Add record", e -> { List<String> errors = v.getView().getForm().validate(); if (errors.size() > 0) { io.mateu.ui.core.client.app.MateuUI.notifyErrors(errors); } else { //if (d.isCloseOnOk()) subWindow.close(); ((AbstractAddRecordDialog) view).addAndClean(v.getView().getForm().getData()); } }); } else { ok = new Button(d.getOkText(), e -> { List<String> errors = v.getView().getForm().validate(); if (errors.size() > 0) { io.mateu.ui.core.client.app.MateuUI.notifyErrors(errors); } else { if (d.isCloseOnOk()) subWindow.close(); ((AbstractDialog) view).onOk(v.getView().getForm().getData()); } }); } ok.addStyleName(ValoTheme.BUTTON_PRIMARY); ok.setClickShortcut(ShortcutAction.KeyCode.ENTER); footer.addComponents(footerText); for (AbstractAction a : d.getActions()) { Button b = new Button(a.getName(), e -> { a.run(); }); //b.addStyleName(ValoTheme.BUTTON_); //b.setClickShortcut(ShortcutAction.KeyCode.ENTER); if ("previous".equalsIgnoreCase(a.getName())) { b.setIcon(VaadinIcons.ANGLE_LEFT); } else if ("next".equalsIgnoreCase(a.getName())) { b.setIcon(VaadinIcons.ANGLE_RIGHT); } footer.addComponent(b); } if (d instanceof AbstractListEditorDialog) { AbstractListEditorDialog lv = (AbstractListEditorDialog) d; Property<Integer> pos = new SimpleObjectProperty<>(); pos.setValue(lv.getInitialPos()); Button prev = new Button("Previous", e -> { List<String> errors = v.getView().getForm().validate(); if (errors.size() > 0) { io.mateu.ui.core.client.app.MateuUI.notifyErrors(errors); } else { if (pos.getValue() > 0) { lv.setData(pos.getValue(), view.getForm().getData()); pos.setValue(pos.getValue() - 1); view.getForm().setData(lv.getData(pos.getValue())); } } }); prev.setIcon(VaadinIcons.ANGLE_LEFT); footer.addComponent(prev); Button next = new Button("Next", e -> { List<String> errors = v.getView().getForm().validate(); if (errors.size() > 0) { io.mateu.ui.core.client.app.MateuUI.notifyErrors(errors); } else { if (pos.getValue() < lv.getListSize() - 1) { lv.setData(pos.getValue(), view.getForm().getData()); pos.setValue(pos.getValue() + 1); view.getForm().setData(lv.getData(pos.getValue())); } } }); next.setIcon(VaadinIcons.ANGLE_RIGHT); footer.addComponent(next); pos.addListener(new ChangeListener<Integer>() { @Override public void changed(ObservableValue<? extends Integer> observable, Integer oldValue, Integer newValue) { if (newValue <= 0) { prev.setEnabled(false); } else { prev.setEnabled(true); } if (newValue < lv.getListSize() - 1) { next.setEnabled(true); } else { next.setEnabled(false); } } }); } footer.addComponents(ok); //, cancel); footer.setExpandRatio(footerText, 1); v.addComponent(footer); subWindow.setContent(v); // Center it in the browser window subWindow.center(); subWindow.setModal(true); // Open it in the UI ui.addWindow(subWindow); } else { System.out.println("aadiendo vista al contenedor de vistas"); ui.getViewDisplay().removeAllComponents(); ui.getViewDisplay().addComponent(v); ui.refreshMenu(v.getArea(), v.getMenu()); } } }