List of usage examples for com.vaadin.ui NativeButton addStyleName
@Override public void addStyleName(String style)
From source file:edu.nps.moves.mmowgli.modules.userprofile.UserProfile3Top.java
License:Open Source License
private void displayBadgesAndAwards(Object uid, Session sess) { MediaLocator loc = Mmowgli2UI.getGlobals().getMediaLocator(); ClickListener lis = new BadgeListener(); Game g = Game.get(sess);/*from w w w .j a v a 2 s .co m*/ MSysOut.println(DEBUG_LOGS, "User.get(sess) from UserProfile3Top.displayBadgesAndAwards(sess)"); User u = User.get(uid, sess); Set<Badge> badges = u.getBadges(); badgeLayout.removeAllComponents(); @SuppressWarnings("unchecked") List<Badge> list = (List<Badge>) sess.createCriteria(Badge.class).addOrder(Order.asc("badge_pk")).list(); int nDefinedBadges = list.size(); for (int b = 0; b < nDefinedBadges; b++) { Badge bd = getBadgeById(badges, b + 1); badgeButts[b] = new NativeButton(); badgeButts[b].addStyleName("m-badgeButton"); badgeLayout.addComponent(badgeButts[b]); if (bd != null) { badgeButts[b].setIcon(loc.locate(bd.getMedia())); badgeButts[b].setDescription(getBadgeDescription(g, bd)); // check for undesired action plan mention badgeButts[b].addClickListener(lis); } else { badgeButts[b].setIcon(loc.getEmptyBadgeImage()); if (!((b + 1) == BADGE_EIGHT_ID)) badgeButts[b].setDescription(getBadgeDescription(g, list.get(b))); // check for undesired action plan mention } } List<AwardButton> ablis = getAwardButtons(u, sess); Iterator<AwardButton> bItr = ablis.iterator(); for (int i = 0; i < 4; i++) { NativeButton awb = bItr.hasNext() ? bItr.next() : null; if (awb == null) { awb = new NativeButton(); awb.addStyleName("m-badgeButton"); awb.setDescription("Game-specific awards"); awb.setIcon(loc.getEmptyBadgeImage()); } badgeLayout.addComponent(awb); } }
From source file:edu.nps.moves.mmowgli.modules.userprofile.UserProfileMyIdeasPanel2.java
License:Open Source License
Button makeButt(String s) { NativeButton b = new NativeButton(s); b.setStyleName(BaseTheme.BUTTON_LINK); b.addStyleName("m-link-button"); b.addStyleName("borderless"); b.addClickListener(this); return b;//from w ww . j a v a 2s . com }
From source file:edu.nps.moves.mmowgli.modules.userprofile.UserProfileMyMailPanel.java
License:Open Source License
@Override public void initGui() { super.initGui(); String left = "Players can choose to receive messages in-game or externally (or both or neither).<br/><br/>Player messages are private and" + " actual email identities are hidden.<br/><br/>You can find another player's profile by clicking on their name or using the search" + " feature. Then you may send a message to that player by clicking on the " + "<i>Send player private email</i> link.<br/><br/>If this link is not present or is disabled, then the player has opted " + "to receive neither email nor in-game messages.<br/><br/>"; getLeftLabel().setValue(left);/*w w w. j av a 2 s. co m*/ if (!userIsMe) { User u = User.getTL(uid); if (u.isOkEmail() || u.isOkGameMessages()) { final NativeButton sendEmailButt = new NativeButton("Send private mail to this user"); sendEmailButt.addStyleName(BaseTheme.BUTTON_LINK); sendEmailButt.addStyleName("m-userProfile3-sendmail-button"); Label sp; VerticalLayout vl = getRightLayout(); vl.setSizeUndefined(); vl.setWidth("100%"); vl.addComponent(sp = new Label()); sp.setHeight("50px"); vl.addComponent(sendEmailButt); vl.setComponentAlignment(sendEmailButt, Alignment.MIDDLE_CENTER); vl.addComponent(sp = new Label()); sp.setHeight("1px"); vl.setExpandRatio(sp, 1.0f); sendEmailButt.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override @MmowgliCodeEntry @HibernateOpened @HibernateClosed public void buttonClick(ClickEvent event) { HSess.init(); User u = User.getTL(uid); if (u.isOkEmail() || u.isOkGameMessages()) // redundant here new SendMessageWindow(u, imAdminOrGameMaster); else Notification.show("Sorry", "Player " + u.getUserName() + " does not receive mail.", Notification.Type.WARNING_MESSAGE); HSess.close(); } }); } return; } VerticalLayout rightVL = getRightLayout(); rightVL.setSizeUndefined(); rightVL.setWidth("100%"); getLeftAddedVerticalLayout() .addComponent(showButt = new ToggleLinkButton("View all", "View unhidden only", null)); //,ttArray)); showButt.addOnListener(new ViewAllListener()); showButt.addOffListener(new ViewUnhiddenOnlyListener()); showButt.setToolTips("Temporarily show all messages, including those marked \"hidden\"", "Temporarily hide messages marked \"hidden\""); Label sp; rightVL.addComponent(sp = new Label()); sp.setHeight("10px"); rightVL.addComponent(mailPanel); User me = Mmowgli2UI.getGlobals().getUserTL(); Set<Message> msgs = me.getGameMessages(); if (msgs.size() > 0) { Message[] msgsAr = new Message[msgs.size()]; msgsAr = msgs.toArray(msgsAr); // avoid concurrent mod int num = msgsAr.length;// .size(); int n = num; for (Message m : msgsAr) { addOneMessage(m, n--, num, null); } } }
From source file:fr.amapj.view.samples.test003.SidebarMenu.java
License:Open Source License
public void setSelected(NativeButton b) { updateButtonStyles(); b.addStyleName("selected"); }
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//from w ww .j av a2 s. c o 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; }