List of usage examples for com.vaadin.ui Button addStyleName
@Override public void addStyleName(String style)
From source file:com.neatresults.mgnltweaks.neatu2b.ui.form.field.U2BField.java
License:Open Source License
/** * Initialize the field. <br>/*from w ww. j a va 2 s . co m*/ * Create as many configured Field as we have related values already stored. */ @Override protected void initFields(final PropertysetItem newValue) { root.removeAllComponents(); final TextField id = createTextField("Id", newValue); root.addComponent(id); final TextField title = createTextField("Title", newValue); root.addComponent(title); final TextFieldDefinition def = new TextFieldBuilder("description").label("Description").rows(3) .definition(); final TextArea description = (TextArea) createLocalField(def, newValue.getItemProperty(def.getName()), false); newValue.addItemProperty(def.getName(), description.getPropertyDataSource()); description.setNullRepresentation(""); description.setWidth("100%"); description.setNullSettingAllowed(true); root.addComponent(description); HorizontalLayout ddLine = new HorizontalLayout(); final TextField publishedAt = createTextField("Published", newValue); ddLine.addComponent(publishedAt); final TextField duration = createTextField("Duration", newValue); ddLine.addComponent(duration); ddLine.addComponent(createTextField("Definition", newValue)); Button fetchButton = new Button("Fetch metadata"); fetchButton.addStyleName("magnoliabutton"); fetchButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { String idStr = id.getValue(); // extract id from url when whole url is passed if (idStr.startsWith("http")) { idStr = StringUtils.substringBefore(StringUtils.substringAfter(idStr, "?v="), "&"); } U2BService service = null; try { RestEasyClient client = (RestEasyClient) restClientRegistry.getRestClient("youtube"); service = client.getClientService(U2BService.class); } catch (RegistrationException e) { log.error("Failed to get a client for [" + U2BService.class.getName() + "] with: " + e.getMessage(), e); } if (service != null) { String key = u2bModule.getGoogleKey(); JsonNode response = service.meta(idStr, "snippet", key); try { if (response.get("items").getElements().hasNext()) { JsonNode videoItem = response.get("items").getElements().next(); String descriptionStr = videoItem.get("snippet").get("description").getTextValue(); newValue.getItemProperty("description").setValue(descriptionStr); String titleStr = videoItem.get("snippet").get("title").getTextValue(); newValue.getItemProperty("title").setValue(titleStr); Iterator<Entry<String, JsonNode>> thumbs = videoItem.get("snippet").get("thumbnails") .getFields(); while (thumbs.hasNext()) { Entry<String, JsonNode> entry = thumbs.next(); newValue.getItemProperty(entry.getKey() + "Url") .setValue(entry.getValue().get("url").getTextValue()); newValue.getItemProperty(entry.getKey() + "Width") .setValue("" + entry.getValue().get("width").getLongValue()); newValue.getItemProperty(entry.getKey() + "Height") .setValue("" + entry.getValue().get("height").getLongValue()); } String publishedAtStr = videoItem.get("snippet").get("publishedAt").getTextValue(); newValue.getItemProperty("published").setValue(publishedAtStr); } } catch (Exception e) { log.error("Failed to parse the video metadata.", e); } response = service.meta(idStr, "contentDetails", key); try { if (response.get("items").getElements().hasNext()) { JsonNode videoItem = response.get("items").getElements().next(); String durationStr = videoItem.get("contentDetails").get("duration").getTextValue(); newValue.getItemProperty("duration").setValue(durationStr); String definition = videoItem.get("contentDetails").get("definition").getTextValue(); newValue.getItemProperty("definition").setValue(definition); } } catch (Exception e) { log.error("Failed to parse the video duration.", e); } } } }); ddLine.addComponent(fetchButton); ddLine.setWidth(100, Unit.PERCENTAGE); ddLine.setHeight(-1, Unit.PIXELS); ddLine.setComponentAlignment(fetchButton, Alignment.BOTTOM_RIGHT); root.addComponent(ddLine); PropertysetItem item = (PropertysetItem) getPropertyDataSource().getValue(); root.addComponent(createEntryComponent("default", item), root.getComponentCount() - 1); root.addComponent(createEntryComponent("standard", item), root.getComponentCount() - 1); root.addComponent(createEntryComponent("medium", item), root.getComponentCount() - 1); root.addComponent(createEntryComponent("high", item), root.getComponentCount() - 1); root.addComponent(createEntryComponent("maxres", item), root.getComponentCount() - 1); }
From source file:com.neatresults.mgnltweaks.ui.column.ColumnFormatterUtils.java
License:Open Source License
private static Button createButton(final String title, final String appName, final String subAppName, final String path, final Object itemId, final String rootPath, EventBus adminEventBus, EventBus eventBus, NeatTweaks4DevelopersModule module) { Button selectButton = new NativeButton(); selectButton.addStyleName("neatmagnoliabutton"); selectButton.setCaption(title);/* w w w . j a va 2s . com*/ selectButton.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { String workPath = path; if (StringUtils.isNotBlank(rootPath) && !"/".equals(rootPath)) { workPath = StringUtils.removeStart(workPath, rootPath); } if ("browser".equals(subAppName)) { Location location = new BrowserLocation(appName, subAppName, workPath + ":treeview:"); adminEventBus.fireEvent(new LocationChangedEvent(location)); } else { // open app (subapp) Location location = new RerootBrowserLocation(appName, subAppName, workPath, module.isShowSubtreeOnlyInHelper()); adminEventBus.fireEvent(new LocationChangedEvent(location)); // expand selected node try { ContentChangedEvent cce = new ContentChangedEvent( JcrItemUtil.getItemId(RepositoryConstants.CONFIG, path), true); eventBus.fireEvent(cce); } catch (RepositoryException e) { log.error( "Ooops, failed to retrieve node at path {} and open it while trying to open definition with {}", path, e.getMessage(), e); } } } }); return selectButton; }
From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.header.HeaderViewImpl.java
License:Open Source License
private void createButtons() { Button saveDraftButton = new Button("Save Draft", new Button.ClickListener() { @Override//from ww w . ja v a2 s . c o m public void buttonClick(Button.ClickEvent event) { listener.saveDraft(); } }); saveDraftButton.addStyleName("header-button"); saveDraftButton.addStyleName("save-draft-button"); header.addComponent(saveDraftButton); Button livePreviewButton = new Button("Live Preview", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { listener.launchPreview(); } }); livePreviewButton.addStyleName("header-button"); header.addComponent(livePreviewButton); Button publishButton = new Button("Publish Story", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { // TODO implement it } }); publishButton.addStyleName("header-button"); header.addComponent(publishButton); }
From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.umbrellacontent.UmbrellaContentViewImpl.java
License:Open Source License
private HorizontalLayout createSeriesLayout() { HorizontalLayout seriesLayout = new HorizontalLayout(); seriesLayout.setSpacing(true);//from ww w .ja va 2 s .c o m seriesLayout.setCaption("Series"); seriesSelect.addItem("Test"); Button addSeries = new Button("new series"); addSeries.addStyleName("link"); seriesLayout.addComponent(seriesSelect); seriesLayout.addComponent(addSeries); return seriesLayout; }
From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.umbrellacontent.UmbrellaContentViewImpl.java
License:Open Source License
private HorizontalLayout createAuthorsLayout() { HorizontalLayout authorsLayout = new HorizontalLayout(); authorsLayout.setSpacing(true);/* w w w .j a v a 2 s . c o m*/ authorsLayout.setCaption("Author"); authorSelect.addItem("Test"); Button addAuthor = new Button("new author"); addAuthor.addStyleName("link"); /* addAuthor.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { try { String path = Path.getAbsolutePath(parentItem.applyChanges().getPath(), NEW_NODE_NAME); DetailLocation location = new DetailLocation(getDefinition().getAppName(), getDefinition().getSubAppId(), DetailView.ViewType.EDIT, path, ""); locationController.goTo(location); } catch (RepositoryException e) { throw new ActionExecutionException(e); } } }); */ authorsLayout.addComponent(authorSelect); authorsLayout.addComponent(addAuthor); return authorsLayout; }
From source file:com.oodrive.nuage.webui.component.VvrOperationComponent.java
License:Apache License
@Override public final AbstractComponent createComponent(final VvrModel model, final ModelCreator handler) { final HorizontalLayout operationLayout = new HorizontalLayout(); operationLayout.setMargin(true);// w w w. j ava 2s .c om operationLayout.setSpacing(true); operationLayout.setWidth("100%"); // Start and description buttons // START/STOP final Button startStop = new Button(); startStop.setWidth(BUTTON_WIDTH); startStop.addStyleName(Runo.BUTTON_BIG); final Resource iconStartStop; final String description; if (!model.isVvrStarted()) { iconStartStop = WebUiResources.getStartIcon(); description = "Start"; } else { iconStartStop = WebUiResources.getStopIcon(); description = "Stop"; } startStop.setIcon(iconStartStop); startStop.setDescription(description); operationLayout.addComponent(startStop); operationLayout.setExpandRatio(startStop, 1f); operationLayout.setComponentAlignment(startStop, Alignment.MIDDLE_LEFT); final UUID vvrUuid = model.getItemUuid(); startStop.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { final boolean started = model.isVvrStarted(); // Start/Stop are done in background if (!started) { WaitingComponent.executeBackground(model, new Background() { @Override public void processing() { model.startVvr(); } @Override public void postProcessing() { startStop.setIcon(WebUiResources.getStopIcon()); startStop.setDescription("Stop"); Notification.show("VVR started ", vvrUuid.toString(), Notification.Type.TRAY_NOTIFICATION); } }); } else { WaitingComponent.executeBackground(model, new Background() { @Override public void processing() { model.stopVvr(); } @Override public void postProcessing() { startStop.setIcon(WebUiResources.getStartIcon()); startStop.setDescription("Start"); Notification.show("VVR stopped ", vvrUuid.toString(), Notification.Type.TRAY_NOTIFICATION); } }); } } }); // ATTRIBUTES final Button attributes = new Button(); attributes.addStyleName(Runo.BUTTON_BIG); attributes.setWidth(BUTTON_WIDTH); operationLayout.addComponent(attributes); operationLayout.setExpandRatio(attributes, 1f); operationLayout.setComponentAlignment(attributes, Alignment.MIDDLE_LEFT); attributes.setIcon(WebUiResources.getSettingsIcon()); attributes.setDescription("Settings"); attributes.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { try { final VvrAttributesWindow attributesWindow = new VvrAttributesWindow(vvrUuid); attributesWindow.add(model); } catch (final Exception e) { LOGGER.error("Can not get VVR attributes: ", e); final ErrorWindow err = new ErrorWindow("Can not display VVR Attributes: " + e.getMessage()); err.add(model); } } }); // DELETE final Button delete = new Button(); delete.addStyleName(Runo.BUTTON_BIG); delete.setWidth(BUTTON_WIDTH); delete.setIcon(WebUiResources.getTrashIcon()); delete.setDescription("Delete"); operationLayout.addComponent(delete); operationLayout.setExpandRatio(delete, 12f); operationLayout.setComponentAlignment(delete, Alignment.MIDDLE_RIGHT); delete.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { try { final VvrDeleteWindow deleteWindow = new VvrDeleteWindow(vvrUuid); deleteWindow.add(vvrManagerModel); } catch (final Exception e) { LOGGER.error("Can not delete VVR: ", e); final ErrorWindow err = new ErrorWindow("Can not delete VVR: " + e.getMessage()); err.add(model); } } }); return operationLayout; }
From source file:com.peergreen.example.webconsole.extensions.CssContributionExtension.java
License:Open Source License
@PostConstruct public void init() { String css = ".custom_button_style {\n" + " color : red !important;\n" + " border : 1px green dashed !important;\n" + "}"; final TextArea textArea = new TextArea("Css : ", css); textArea.setWidth("500px"); addComponent(textArea);/* w w w. java 2 s . c o m*/ Button button = new Button("Change my style !"); button.setWidth("500px"); button.addStyleName("custom_button_style"); button.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { String newCss = textArea.getValue(); cssInjectorService.inject(newCss); } }); addComponent(button); setExpandRatio(button, 1.5f); }
From source file:com.peergreen.example.webconsole.extensions.DefaultWindowExtension.java
License:Open Source License
public DefaultWindowExtension() { setSizeFull();/*from w w w. j a va2 s .c om*/ setSpacing(true); setMargin(true); Link showCodeSource = new Link("Show code source", new ExternalResource(GitHubClassURL.getURL(DefaultWindowExtension.class))); showCodeSource.setTargetName("_blank"); addComponent(showCodeSource); setComponentAlignment(showCodeSource, Alignment.TOP_RIGHT); Button simpleButton = new Button("Click to open a Window"); simpleButton.setWidth("400px"); simpleButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { final UI ui = clickEvent.getConnector().getUI(); String caption = "Default window"; Label content = new Label("This is a simple window"); Button close = new Button("Close"); close.addStyleName("wide"); close.addStyleName("default"); final DefaultWindow window = new DefaultWindow(caption, content, close); window.center(); ui.addWindow(window); close.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { window.close(); } }); } }); addComponent(simpleButton); setExpandRatio(simpleButton, 1.5f); }
From source file:com.peergreen.webconsole.core.vaadin7.BaseUI.java
License:Open Source License
/** * Build login view/*from w w w.java 2s. c o m*/ * * @param exit */ private void buildLoginView(final boolean exit) { if (exit) { root.removeAllComponents(); } notifierService.closeAll(); addStyleName("login"); VerticalLayout loginLayout = new VerticalLayout(); loginLayout.setId("webconsole_loginlayout_id"); loginLayout.setSizeFull(); loginLayout.addStyleName("login-layout"); root.addComponent(loginLayout); final CssLayout loginPanel = new CssLayout(); loginPanel.addStyleName("login-panel"); HorizontalLayout labels = new HorizontalLayout(); labels.setWidth(MAX_WIDTH); labels.setMargin(true); loginPanel.addComponent(labels); Label welcome = new Label("Welcome"); welcome.addStyleName("h4"); labels.addComponent(welcome); labels.setComponentAlignment(welcome, Alignment.MIDDLE_LEFT); Label title = new Label(consoleName); //title.setSizeUndefined(); title.addStyleName("h2"); title.addStyleName("light"); labels.addComponent(title); labels.setComponentAlignment(title, Alignment.MIDDLE_RIGHT); HorizontalLayout fields = new HorizontalLayout(); fields.setSpacing(true); fields.setMargin(true); fields.addStyleName("fields"); final TextField username = new TextField("Username"); username.focus(); username.setId("webconsole_login_username"); fields.addComponent(username); final PasswordField password = new PasswordField("Password"); password.setId("webconsole_login_password"); fields.addComponent(password); final Button signin = new Button("Sign In"); signin.setId("webconsole_login_signin"); signin.addStyleName("default"); fields.addComponent(signin); fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT); final ShortcutListener enter = new ShortcutListener("Sign In", ShortcutAction.KeyCode.ENTER, null) { @Override public void handleAction(Object sender, Object target) { signin.click(); } }; signin.addShortcutListener(enter); loginPanel.addComponent(fields); HorizontalLayout bottomRow = new HorizontalLayout(); bottomRow.setWidth(MAX_WIDTH); bottomRow.setMargin(new MarginInfo(false, true, false, true)); final CheckBox keepLoggedIn = new CheckBox("Keep me logged in"); bottomRow.addComponent(keepLoggedIn); bottomRow.setComponentAlignment(keepLoggedIn, Alignment.MIDDLE_LEFT); // Add new error message final Label error = new Label("Wrong username or password.", ContentMode.HTML); error.setId("webconsole_login_error"); error.addStyleName("error"); error.setSizeUndefined(); error.addStyleName("light"); // Add animation error.addStyleName("v-animate-reveal"); error.setVisible(false); bottomRow.addComponent(error); bottomRow.setComponentAlignment(error, Alignment.MIDDLE_RIGHT); loginPanel.addComponent(bottomRow); signin.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (authenticate(username.getValue(), password.getValue())) { // if (keepLoggedIn.getValue()) { // //Cookie userCookie = getCookieByName(PEERGREEN_USER_COOKIE_NAME); // if (getCookieByName(PEERGREEN_USER_COOKIE_NAME) == null) { // // Get a token for this user and create a cooki // Page.getCurrent().getJavaScript().execute( String.format("document.cookie = '%s=%s; path=%s'", // PEERGREEN_USER_COOKIE_NAME, token, VaadinService.getCurrentRequest().getContextPath())); // } else { // // update token // userCookie.setValue(token); // userCookie.setPath(VaadinService.getCurrentRequest().getContextPath()); // } // } buildMainView(); } else { error.setVisible(true); } } }); loginLayout.addComponent(loginPanel); loginLayout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER); }
From source file:com.peergreen.webconsole.core.vaadin7.BaseUI.java
License:Open Source License
/** * Add scope button in menu/*from w ww . j a v a 2s .co m*/ * * @param scope scope * @param notify for notifierService to show badge */ private void addScopeButtonInMenu(final Scope scope, boolean notify) { if (menu != null) { final Button b = new NativeButton(scope.getScopeName().toUpperCase()); b.addStyleName(scope.getScopeIconClass()); b.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { //clearMenuSelection(); notifierService.removeBadge(scope.getScopeView()); viewNavigator.navigateTo(scope.getScopeAlias()); } }); sortButtonsInMenu(scope.getScopeAlias(), b); notifierService.addScopeButton(scope.getScopeView(), b, this, notify); scopes.get(scope.getScopeAlias()).setScopeMenuButton(b); if (nbScopesToBind > 0) { Float progressIndicatorValue = progressIndicator.getValue(); progressIndicatorValue += (float) (1.0 / nbScopesToBind); progressIndicator.setValue(progressIndicatorValue); } } }