List of usage examples for com.vaadin.ui NativeButton NativeButton
public NativeButton(String caption, ClickListener listener)
From source file:edu.nps.moves.mmowgli.modules.userprofile.InstallImageDialog.java
License:Open Source License
@SuppressWarnings("serial") private InstallImageDialog(String topText, InstallImageResultListener lis, boolean showExisting, String nameFilter) {//from w w w. ja v a 2 s . c o m Object sessKey = HSess.checkInit(); listener = lis; setCaption(showExisting ? "Choose Existing or Upload New Image" : "Upload New Image"); setModal(true); setWidth("350px"); VerticalLayout vl; VerticalLayout vLay = new VerticalLayout(); setContent(vLay); vLay.setMargin(true); vLay.setSpacing(true); if (topText != null && topText.length() > 0) { HtmlLabel lab = new HtmlLabel(topText); lab.setWidth("100%"); vLay.addComponent(lab); } if (showExisting) { // put the existing selector in the dialog Criteria crit = HSess.get().createCriteria(Media.class) .add(Restrictions.eq("source", Media.Source.DATABASE)).addOrder(Order.asc("url")); if (nameFilter != null) crit.add(Restrictions.like("handle", nameFilter, MatchMode.ANYWHERE)); @SuppressWarnings({ "unchecked" }) List<Media> mlis = crit.list(); BeanItemContainer<Media> beanContainer = new BeanItemContainer<Media>(Media.class, mlis); vLay.addComponent(existingCB = new CheckBox("Choose from existing images", true)); vLay.addComponent(vl = new VerticalLayout()); vl.addStyleName("m-greyborder"); vl.addStyleName("m-greybackground"); vl.setMargin(true); vl.setSpacing(true); vl.addComponent(sel = new ListSelect()); sel.setWidth("100%"); sel.setNullSelectionAllowed(false); sel.setContainerDataSource(beanContainer); sel.setItemCaptionPropertyId("url"); vl.addComponent(saveExistingButt = new NativeButton("Return selected image", new ClickListener() { @Override public void buttonClick(ClickEvent event) { HSess.init(); mediaImage = new MediaImage((Media) sel.getValue(), null); doneHereTL(); HSess.close(); } })); vLay.addComponent(newCB = new CheckBox("Upload new image", false)); } // Here for the file chooser vLay.addComponent(vl = new VerticalLayout()); vl.addStyleName("m-greyborder"); vl.addStyleName("m-greybackground"); vl.setSpacing(true); vl.setMargin(true); ImgReceiver rec; uploadFileWidget = new Upload();// "Image name", rec = new ImgReceiver()); uploadFileWidget.setReceiver(rec = new ImgReceiver()); uploadFileWidget.setButtonCaption("Browse"); uploadFileWidget.setImmediate(true); uploadFileWidget.addFailedListener(rec); uploadFileWidget.addFinishedListener(rec); uploadFileWidget.setEnabled(showExisting ? false : true); vl.addComponent(uploadFileWidget); vl.addComponent(fileNameTF = new TextField()); fileNameTF.setWidth("100%"); fileNameTF.setEnabled(showExisting ? false : true); fileNameTFState = false; HorizontalLayout hLay; vl.addComponent(hLay = new HorizontalLayout()); hLay.setSpacing(true); hLay.addComponent(saveImageButt = new NativeButton("Save image with above name", rec)); // hLay.addComponent(savedLab = new HtmlLabel("<i>saved</i>")); saveImageButt.setImmediate(true); saveImageButt.addClickListener(rec); saveImageButt.setEnabled(false); saveImageButtState = false; vLay.addComponent(new NativeButton("Close", new ClickListener() { @Override public void buttonClick(ClickEvent event) { HSess.init(); doneHereTL(); HSess.close(); } })); if (showExisting) { existingCB.addValueChangeListener(new CheckBoxListener(existingCB)); newCB.addValueChangeListener(new CheckBoxListener(newCB)); } HSess.checkClose(sessKey); }
From source file:edu.nps.moves.mmowgli.modules.userprofile.ManageAwardsDialog.java
License:Open Source License
@HibernateSessionThreadLocalConstructor public ManageAwardsDialog(Object uId) { this.uId = uId; User u = User.getTL(uId);/*from ww w. j a v a2 s. c o m*/ setCaption("Manage Awards for " + u.getUserName()); setModal(true); setSizeUndefined(); setWidth("625px"); setHeight("400px"); VerticalLayout vLay = new VerticalLayout(); vLay.setMargin(true); vLay.setSpacing(true); vLay.setSizeFull(); setContent(vLay); Panel p = new Panel("Award Assignments -- a check applies the award to player " + u.getUserName()); p.setWidth("99%"); p.setHeight("99%"); vLay.addComponent(p); vLay.setExpandRatio(p, 1.0f); gridLayout = new GridLayout(); gridLayout.addStyleName("m-headgrid"); gridLayout.setWidth("100%"); p.setContent(gridLayout); fillPanelTL(u); //@HibernateUserRead HorizontalLayout buttPan = new HorizontalLayout(); buttPan.setWidth("100%"); buttPan.setSpacing(true); NativeButton defineButt = new NativeButton("Define Award Types", new DefineListener()); NativeButton saveButt = new NativeButton("Save", new SaveListener()); NativeButton cancelButt = new NativeButton("Cancel", new CancelListener()); buttPan.addComponent(defineButt); Label lab; buttPan.addComponent(lab = new Label()); buttPan.setExpandRatio(lab, 1.0f); buttPan.addComponent(cancelButt); buttPan.addComponent(saveButt); vLay.addComponent(buttPan); }
From source file:fi.jasoft.remoteconnection.ServerExampleUI.java
License:Apache License
private void buildUI() { FormLayout vl = new FormLayout(); setContent(vl);//from ww w. j a v a 2 s. c om // Our id myId = new Label("Connecting..."); myId.setCaption("My id:"); vl.addComponent(myId); // Remote id final TextField remoteId = new TextField(); remoteId.setWidth("100%"); NativeButton connectToRemote = new NativeButton("Connect", new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { final RemoteChannel channel = peer.openChannel(remoteId.getValue()); channel.addConnectedListener(new ConnectedListener() { @Override public void connected(String channelId) { remoteId.setReadOnly(true); event.getButton().setVisible(false); Notification.show("Connected to " + channelId, Type.TRAY_NOTIFICATION); } }); } }); HorizontalLayout hl = new HorizontalLayout(remoteId, connectToRemote); hl.setExpandRatio(remoteId, 1); hl.setWidth("100%"); hl.setCaption("Remote id: "); vl.addComponent(hl); // Message display where messages are displayed messages = new TextArea(); messages.setWidth("100%"); vl.addComponent(messages); // Message field final TextField message = new TextField(); message.setWidth("100%"); NativeButton send = new NativeButton("Send", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { // Show message in message window messages.setValue( messages.getValue() + peer.getConfiguration().getId() + " >> " + message.getValue() + "\n"); // Broadcast the message to all connected peers peer.broadcast(message.getValue()); message.setValue(""); } }); hl = new HorizontalLayout(message, send); hl.setExpandRatio(message, 1); hl.setWidth("100%"); hl.setCaption("Send message: "); vl.addComponent(hl); }
From source file:info.magnolia.messages.app.MessagesViewImpl.java
License:Open Source License
@Inject public MessagesViewImpl(SimpleTranslator i18n) { this.i18n = i18n; // create form and data item final Message message = new Message(); // message POJO BeanItem<Message> messageItem = new BeanItem<Message>(message); final FieldGroup form = new FieldGroup(); form.setItemDataSource(messageItem); Field<String> subjectField = createSubjectTextField(); Field<String> messageBodyField = createMessageBodyTextField(); Field<?> typeField = createTypeSelectionField(); Field<?> scopeField = createScopeSelectionField(); userOrGroupIdField = createUserOrGroupIdTextField(); // disable user/group field if not necessary scopeField.addValueChangeListener(new ValueChangeListener() { @Override//w w w . jav a 2 s .co m public void valueChange(ValueChangeEvent event) { updateUserOrGroupField((String) event.getProperty().getValue()); } }); form.bind(subjectField, "title"); form.bind(messageBodyField, "content"); form.bind(typeField, "type"); form.bind(scopeField, "scope"); form.bind(userOrGroupIdField, "user"); // FieldGroup overrides fields' own enabled property with its own. updateUserOrGroupField(message.getScope()); FormLayout layout = new FormLayout(); layout.addComponent(subjectField); layout.addComponent(messageBodyField); layout.addComponent(typeField); layout.addComponent(scopeField); layout.addComponent(userOrGroupIdField); layout.setSpacing(true); layout.setMargin(false); layout.setWidth("100%"); // send button NativeButton sendButton = new NativeButton(i18n.translate("messages-app.app.button.sendMessage"), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { try { form.commit(); String subject = message.getTitle(); String content = message.getContent(); MessageType type = message.getType(); String scope = message.getScope(); if (MESSAGE_SCOPE_LOCAL.equals(scope)) { listener.handleLocalMessage(type, subject, content); } else if (MESSAGE_SCOPE_GLOBAL.equals(scope)) { listener.handleGlobalMessage(type, subject, content); } else if (MESSAGE_SCOPE_GROUP.equals(scope)) { // message is bound to FieldGroup - hence the group name is to be retrieved from the user field of the message final String groupName = message.getUser(); listener.handleGroupMessage(groupName, type, subject, content); } else { // User... final String userName = message.getUser(); listener.handleUserMessage(userName, type, subject, content); } } catch (CommitException e) { } } }); sendButton.addStyleName("btn-dialog"); sendButton.addStyleName("commit"); // reset button NativeButton resetButton = new NativeButton(i18n.translate("messages-app.app.button.reset"), new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { message.reset(); form.discard(); } }); resetButton.addStyleName("btn-dialog"); resetButton.addStyleName("cancel"); HorizontalLayout buttons = new HorizontalLayout(); buttons.addStyleName("buttons"); buttons.setSpacing(true); buttons.addComponent(sendButton); buttons.addComponent(resetButton); layout.addComponent(buttons); // intro text Label intro = new Label(i18n.translate("messages-app.app.label.intro"), ContentMode.HTML); intro.addStyleName("intro"); CssLayout container = new CssLayout(); container.setSizeFull(); container.addStyleName("small-app-panel"); container.addComponent(layout); CssLayout root = new CssLayout(); root.setSizeFull(); root.setWidth("900px"); root.setStyleName("small-app"); root.addComponent(intro); root.addComponent(container); component = root; }
From source file:info.magnolia.ui.form.field.upload.basic.BasicUploadField.java
License:Open Source License
/** * Create the Cancel Button./* w ww . j ava 2 s. co m*/ * 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.workbench.WorkbenchViewImpl.java
License:Open Source License
private Button buildButton(final String viewType, final String icon) { NativeButton button = new NativeButton(null, new Button.ClickListener() { @Override/*w w w .j a v a 2s .c o m*/ public void buttonClick(Button.ClickEvent event) { fireViewTypeChangedEvent(viewType); } }); button.setStyleName(BaseTheme.BUTTON_LINK); button.setHtmlContentAllowed(true); button.setCaption("<span class=\"" + icon + "\"></span><span class=\"view-type-arrow view-type-arrow-" + viewType + " icon-arrow2_n\"></span>"); return button; }
From source file:module.pandabox.presentation.PandaBox.java
License:Open Source License
public void addTab(final VerticalLayout menu, final Component content, final String caption) { if (content == null || caption == null) { throw new NullPointerException("Arguments may not be null"); }//from w w w .ja v a 2 s . co m final Button button = new NativeButton(caption, tabChangeListener); button.setWidth("100%"); menu.addComponent(button); buttonComponentMap.put(button, content); }
From source file:org.eclipse.emf.ecp.view.group.vaadin.GroupLayoutRendererVaadin.java
License:Open Source License
@Override protected Component getRenderComponent(final AbstractOrderedLayout orderedLayout) { if (GroupType.COLLAPSIBLE.equals(getVElement().getGroupType())) { final VerticalLayout mainLayout = new VerticalLayout(); final NativeButton collapseButton = new NativeButton(StringUtils.EMPTY, new Button.ClickListener() { @Override/*from w w w . j a va2 s. c o m*/ public void buttonClick(ClickEvent event) { final boolean switchVisible = !orderedLayout.isVisible(); setCollapseStyle(event.getButton(), switchVisible); orderedLayout.setVisible(switchVisible); } }); collapseButton.setWidth(100, Unit.PERCENTAGE); mainLayout.addComponent(collapseButton); mainLayout.addComponent(orderedLayout); orderedLayout.setMargin(true); orderedLayout.setSpacing(true); orderedLayout.setVisible(getVElement().isCollapsed()); setCollapseStyle(collapseButton, getVElement().isCollapsed()); mainLayout.addStyleName(GROUP_STYLE_NAME); return mainLayout; } return super.getRenderComponent(orderedLayout); }
From source file:org.eclipse.skalli.view.component.PeopleSearchWindow.java
License:Open Source License
private void createContents() { setModal(true);//from ww w . j a v a 2 s . c o m setCaption("Search people..."); setWidth("310px"); //$NON-NLS-1$ setHeight("400px"); //$NON-NLS-1$ root = new VerticalLayout(); root.setMargin(true); root.setSpacing(true); HorizontalLayout search = new HorizontalLayout(); search.setSpacing(true); searchField = new TextField("Search for:"); searchField.setWidth("20em"); //$NON-NLS-1$ searchField.setImmediate(true); searchField.addListener(new ValueChangeListener() { @Override public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { search((String) searchField.getValue()); list.focus(); } }); search.addComponent(searchField); search.setComponentAlignment(searchField, Alignment.BOTTOM_LEFT); search.setExpandRatio(searchField, 1.0f); Button searchButton = new NativeButton("", new Button.ClickListener() { //$NON-NLS-1$ @Override public void buttonClick(ClickEvent event) { search((String) searchField.getValue()); } }); searchButton.setDescription("Search"); searchButton.setStyleName(STYLE_USER_DOSEARCH); search.addComponent(searchButton); search.setComponentAlignment(searchButton, Alignment.BOTTOM_LEFT); search.setExpandRatio(searchButton, 0); root.addComponent(search); list = new ListSelect("Search results:", dataSource); list.setSizeFull(); list.setMultiSelect(true); list.setImmediate(true); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); Button addButton = new Button("Add"); addButton.setIcon(ICON_BUTTON_ADD_SELECTED); addButton.setDescription("Adds the selected person to the list."); addButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { Set<User> values = (Set<User>) list.getValue(); if (selectHandler != null && values != null) { selectHandler.onPeopleSelected(values); list.removeAllItems(); searchField.setValue(""); //$NON-NLS-1$ searchField.focus(); } } }); buttons.addComponent(addButton); Button addAndCloseButton = new Button("Add & Close"); addAndCloseButton.setIcon(ICON_BUTTON_ADD_SELECTED); addAndCloseButton.setDescription("Adds the selected person to the list and closes the dialog."); addAndCloseButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { Set<User> values = (Set<User>) list.getValue(); if (selectHandler != null && values != null) { selectHandler.onPeopleSelected(values); close(); } } }); buttons.addComponent(addAndCloseButton); root.addComponent(list); root.addComponent(buttons); root.setSizeFull(); root.setExpandRatio(list, 1); // root.setStyleName(STYLE_LAYOUT); setContent(root); searchField.focus(); }
From source file:org.eclipse.skalli.view.component.Tray.java
License:Open Source License
private ComponentContainer createContent(String caption, String description, ThemeResource icon, boolean isRequired) { CssLayout layout = new CssLayout(); layout.setStyleName(STYLE_TRAY);/*from w w w . j ava 2 s. co m*/ layout.setMargin(true); HorizontalLayout header = new HorizontalLayout(); header.setSpacing(true); header.setStyleName(STYLE_TRAY_HEADER); header.setWidth("100%"); this.icon = icon; trayIcon = new Embedded(null, icon); trayIcon.setStyleName(STYLE_TRAY_HEADER_ICON); header.addComponent(trayIcon); header.setComponentAlignment(trayIcon, Alignment.MIDDLE_LEFT); header.setExpandRatio(trayIcon, 0); Label captionLabel = new Label(StringEscapeUtils.escapeHtml(caption), Label.CONTENT_XHTML); captionLabel.setStyleName(STYLE_TRAY_HEADER_LABEL); header.addComponent(captionLabel); header.setExpandRatio(captionLabel, 1); header.setComponentAlignment(captionLabel, Alignment.MIDDLE_LEFT); this.isRequired = isRequired; if (!isRequired) { activator = new NativeButton("", new ToggleEnabledListener()); header.addComponent(activator); header.setExpandRatio(activator, 0); header.setComponentAlignment(activator, Alignment.MIDDLE_RIGHT); } opener = new NativeButton("", new ToggleVisibleListener()); header.addComponent(opener); header.setExpandRatio(opener, 0); header.setComponentAlignment(opener, Alignment.MIDDLE_RIGHT); layout.addComponent(header); CssLayout content = new CssLayout(); Label descriptionLabel = new Label(HtmlUtils.clean(description), Label.CONTENT_XHTML); descriptionLabel.setStyleName(STYLE_TRAY_DESCRIPTION); content.addComponent(descriptionLabel); layout.addComponent(content); setCompositionRoot(layout); return content; }