List of usage examples for com.vaadin.ui Button Button
public Button(Resource icon, ClickListener listener)
From source file:com.abien.vaadin.helloapp.HelloApp.java
License:Apache License
@Override public void init() { VerticalLayout layout = new VerticalLayout(); layout.setMargin(true);//w w w .j a v a 2s .c o m Label header = new Label("Vaadin on Java EE"); header.setStyleName("h1"); layout.addComponent(header); final TextField nameField = new TextField("Input something:"); final Label greetingLbl = new Label(); layout.addComponent(nameField); layout.addComponent( new Button("Say slow Hello, clicking this shouldn't stall other users", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { try { Thread.sleep(20 * 1000); } catch (InterruptedException ex) { Logger.getLogger(HelloApp.class.getName()).log(Level.SEVERE, null, ex); } getMainWindow().showNotification("Hello!"); } })); layout.addComponent(new Button("Say Hello", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { greetingLbl.setCaption(greetingService.sayHello(nameField.getValue().toString())); buttonEvents.fire(event); } })); layout.addComponent(greetingLbl); Window mainWindow = new Window("Vaadin 6.8 - Java EE Integration", layout); setMainWindow(mainWindow); }
From source file:com.adonis.ui.menu.Menu.java
public Menu(PersonService personService, VehicleService vehicleService, Navigator navigator) { this.navigator = navigator; setPrimaryStyleName(ValoTheme.MENU_ROOT); menuPart = new CssLayout(); menuPart.addStyleName(ValoTheme.MENU_PART); setPersonsCrudProperties(personService); setVehiclesCrudProperties(vehicleService); // header of the menu final HorizontalLayout top = new HorizontalLayout(); top.addStyleName(ValoTheme.MENU_TITLE); top.setSpacing(true);/* w ww . jav a 2 s . c o m*/ Label title = new Label("Vehicle manager"); title.addStyleName(ValoTheme.LABEL_H1); title.setSizeUndefined(); Image image = new Image(null, new ThemeResource("img/car.png")); image.setStyleName(ValoTheme.MENU_LOGO); top.addComponent(image); top.addComponent(title); menuPart.addComponent(top); // logout menu item // HorizontalLayout logoutLayout = new HorizontalLayout(); // logoutLayout.addStyleName(ValoTheme.MENU_ITEM); // logoutLayout.setSpacing(false); // // MenuBar logoutMenu = new MenuBar(); // logoutMenu.setStyleName(VALO_MENUITEMS); // logoutMenu.addItem("Logout", new MenuBar.Command() { // // @Override // public void menuSelected(MenuBar.MenuItem selectedItem) { // VaadinSession.getCurrent().getSession().invalidate(); // Page.getCurrent().reload(); // } // }); // // logoutMenu.addStyleName("user-menu"); // Image logout = new Image(null, new ThemeResource("img/logout.png")); // logoutLayout.addComponent(logout, 0); // logoutLayout.addComponent(logoutMenu, 1); // menuPart.addComponent(logoutLayout); // button for toggling the visibility of the menu when on a small screen showMenu = new Button("Menu", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { if (menuPart.getStyleName().contains(VALO_MENU_VISIBLE)) { menuPart.removeStyleName(VALO_MENU_VISIBLE); } else { menuPart.addStyleName(VALO_MENU_VISIBLE); } } }); showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY); showMenu.addStyleName(ValoTheme.BUTTON_SMALL); showMenu.addStyleName(VALO_MENU_TOGGLE); // showMenu.setIcon(FontAwesome.NAVICON); menuPart.addComponent(showMenu); // container for the navigation buttons, which are added by addView() menuItemsLayout = new CssLayout(); menuItemsLayout.setPrimaryStyleName(VALO_MENUITEMS); menuPart.addComponent(menuItemsLayout); addComponent(menuPart); addStyleName("backImage"); }
From source file:com.adonis.ui.menu.Menu.java
private void createViewButton(final String name, String caption, com.vaadin.server.Resource icon) { Button button = new Button(caption, new ClickListener() { @Override/*from w w w . java2 s .c o m*/ public void buttonClick(ClickEvent event) { navigator.navigateTo(name); } }); button.setPrimaryStyleName(ValoTheme.MENU_ITEM); button.setIcon(icon); menuItemsLayout.addComponent(button); viewButtons.put(name, button); }
From source file:com.adonis.ui.menu.Menu.java
private void createViewButtonWithEditableImage(final String name, String caption, String nameImage) { Button button = new Button(caption, new ClickListener() { @Override/* www . j a v a 2 s .co m*/ public void buttonClick(ClickEvent event) { navigator.navigateTo(name); } }); button.setPrimaryStyleName(ValoTheme.BUTTON_FRIENDLY); // button.setWidth(50, Unit.PERCENTAGE); image.setWidth(90, Unit.PIXELS); image.setHeight(90, Unit.PIXELS); FileReader.createDirectoriesFromCurrent(getInitialPath()); final Image image = new Image("", new ThemeResource("img/" + nameImage)); try { FileReader.copyFile(VaadinUtils.getResourcePath(nameImage), VaadinUtils.getInitialPath() + File.separator + nameImage); image.setSource(new FileResource(new File(VaadinUtils.getInitialPath() + File.separator + nameImage))); } catch (IOException e) { e.printStackTrace(); image.setSource(new ThemeResource("img/" + nameImage)); } // image.setWidth(50, Unit.PERCENTAGE); image.setWidth(90, Unit.PIXELS); image.setHeight(90, Unit.PIXELS); HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setPrimaryStyleName(ValoTheme.MENU_ITEM); horizontalLayout.addComponents(image, button); image.addClickListener(new MouseEvents.ClickListener() { @Override public void click(MouseEvents.ClickEvent event) { uploadFieldImage = new UploadField(); uploadFieldImage.setAcceptFilter("image/*"); uploadFieldImage.getUpload().addListener(new com.vaadin.v7.ui.Upload.FailedListener() { @Override public void uploadFailed(com.vaadin.v7.ui.Upload.FailedEvent event) { uploadFieldImage.clearDefaulLayout(); horizontalLayout.removeComponent(uploadFieldImage); } private static final long serialVersionUID = 1L; }); horizontalLayout.addComponent(uploadFieldImage, 2); uploadFieldImage.getUpload().addListener(new com.vaadin.v7.ui.Upload.SucceededListener() { @Override public void uploadSucceeded(com.vaadin.v7.ui.Upload.SucceededEvent event) { File file = (File) uploadFieldImage.getValue(); try { showUploadedImage(uploadFieldImage, image, file.getName(), nameImage); } catch (IOException e) { e.printStackTrace(); } uploadFieldImage.clearDefaulLayout(); horizontalLayout.removeComponent(uploadFieldImage); } }); uploadFieldImage.setFieldType(UploadField.FieldType.FILE); horizontalLayout.markAsDirty(); // image.setWidth(50, Unit.PERCENTAGE); image.setWidth(90, Unit.PIXELS); image.setHeight(90, Unit.PIXELS); image.setVisible(false); image.markAsDirty(); horizontalLayout.addComponent(image, 0); } }); button.setVisible(true); image.setVisible(true); menuItemsLayout.addComponents(horizontalLayout); viewButtons.put(name, button); }
From source file:com.arcusys.liferay.vaadinplugin.ControlPanelUI.java
License:Apache License
private Button createRefreshButton() { Button button = new Button("[re-scan]", new Button.ClickListener() { @SuppressWarnings("unchecked") public void buttonClick(Button.ClickEvent event) { selectedAddons = (Set<VaadinAddonInfo>) includeAddonsOptionGroup.getValue(); refreshAddons();//from w w w . j a v a 2 s. c o m } }); button.setStyleName(BaseTheme.BUTTON_LINK); return button; }
From source file:com.arcusys.liferay.vaadinplugin.ControlPanelUI.java
License:Apache License
private Button createAdditionalDependenciesButton() { Button button = new Button("Manage Additional Dependencies", new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { showAdditionalDependenciesWindow(); }/* w w w.j a v a 2s. co m*/ }); button.setStyleName(BaseTheme.BUTTON_LINK); return button; }
From source file:com.arcusys.liferay.vaadinplugin.ControlPanelUI.java
License:Apache License
private Button createCompileWidgetsetButton() { return new Button("Compile Widget Set", new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { setCompilationModeEnabled(true); outputConsole.clear();//from ww w. j a v a2 s.c o m compiler = new WidgetsetCompilationHandler(activeWidgetsetLabel.getValue(), getIncludeAddons(), includedDependencies, outputLog) { @Override public void compilationFinished() { System.out.println("Compilation has been finished successfully"); getUI().getSession().getLockInstance().lock(); outputLog.log("Compilation has been finished successfully"); try { setCompilationModeEnabled(false); } finally { getUI().getSession().getLockInstance().unlock(); } } }; ExecutorService executor = Executors.newSingleThreadExecutor(); executor.execute(compiler); } }); }
From source file:com.arcusys.liferay.vaadinplugin.ControlPanelUI.java
License:Apache License
private Button createTerminateCompilationButton() { Button button = new Button("Cancel", new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { compiler.terminate();//from ww w . j a va 2 s . c o m } }); button.setVisible(false); return button; }
From source file:com.arcusys.liferay.vaadinplugin.ui.AdditionalDependenciesWindow.java
License:Apache License
private Button createCloseButton() { closeButton = new Button("Close", new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { close();// w w w . j ava 2 s . c o m } }); return closeButton; }
From source file:com.cavisson.gui.dashboard.components.calender.CalendarActionsUI.java
License:Apache License
@SuppressWarnings("deprecation") @Override/* w w w. ja v a 2 s. co m*/ protected void init(VaadinRequest request) { GridLayout content = new GridLayout(1, 2); content.setSizeFull(); setContent(content); final Calendar calendar = new Calendar(); calendar.setLocale(new Locale("fi", "FI")); calendar.setSizeFull(); calendar.setStartDate(new Date(100, 1, 1)); calendar.setEndDate(new Date(100, 2, 1)); calendar.addActionHandler(new Action.Handler() { public final Action NEW_EVENT = new Action("Add event"); public final Action EDIT_EVENT = new Action("Edit event"); public final Action REMOVE_EVENT = new Action("Remove event"); /* * (non-Javadoc) * * @see * com.vaadin.event.Action.Handler#handleAction(com.vaadin.event * .Action, java.lang.Object, java.lang.Object) */ @Override public void handleAction(Action action, Object sender, Object target) { Date date = (Date) target; if (action == NEW_EVENT) { BasicEvent event = new BasicEvent("New event", "Hello world", date, date); calendar.addEvent(event); } } /* * (non-Javadoc) * * @see com.vaadin.event.Action.Handler#getActions(java.lang.Object, * java.lang.Object) */ @Override public Action[] getActions(Object target, Object sender) { CalendarDateRange date = (CalendarDateRange) target; java.util.Calendar cal = java.util.Calendar.getInstance(); cal.set(2000, 1, 1, 12, 0, 0); if (date.inRange(cal.getTime())) { return new Action[] { NEW_EVENT, }; } cal.add(java.util.Calendar.DAY_OF_WEEK, 1); if (date.inRange(cal.getTime())) { return new Action[] { REMOVE_EVENT }; } return null; } }); content.addComponent(calendar); content.addComponent(new Button("Set week view", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { calendar.setEndDate(new Date(100, 1, 7)); } })); content.setRowExpandRatio(0, 1); }