List of usage examples for com.vaadin.ui Button setIcon
@Override public void setIcon(Resource icon)
From source file:com.fnc.view.ui.AlphaListMainUI.java
Button alphaListButton() { Button button = new Button("ALPHA LIST"); button.setWidth("100%"); button.setIcon(FontAwesome.SPINNER); button.addStyleName(ValoTheme.BUTTON_PRIMARY); button.addStyleName(ValoTheme.BUTTON_SMALL); button.addClickListener((Button.ClickEvent event) -> { status.setValue(" Loading..."); current = 0.0;// w ww . j a v a 2 s. c om dataSize = es.getEmployeeByBranch(getBranchId()).size(); populateDataGrid(); }); return button; }
From source file:com.fnc.view.ui.thirteenth.ThirteenthMonthUI.java
Button button() { Button button = new Button("ALPHA LIST"); button.setWidth("100%"); button.setIcon(FontAwesome.SPINNER); button.addStyleName(ValoTheme.BUTTON_PRIMARY); button.addStyleName(ValoTheme.BUTTON_SMALL); button.addClickListener((Button.ClickEvent event) -> { status.setValue(" Loading..."); current = 0.0;//from w w w . j a va 2 s . c o m // dataSize = es.getEmployeeByBranch(getBranchId()).size(); // populateDataGrid(); }); return button; }
From source file:com.foc.vaadin.gui.components.tableAndTree.FVColGen_FocProperty.java
License:Apache License
private Object getDisplayObject_ForProperty_Editable(FocObject focObject, FProperty property, FVTableColumn column, Object columnId) { Object objReturned = null;/*from w ww . j ava 2s. c o m*/ FField field = property != null ? property.getFocField() : null; if (field instanceof FImageField) { objReturned = (AbstractComponent) getTableTreeDelegate().newGuiComponent(focObject, column, property); FVImageField imageField = (FVImageField) objReturned; imageField.setWidth("60px"); imageField.setHeight("50px"); } else if (field instanceof FCloudStorageField) { FCloudStorageProperty csProp = (FCloudStorageProperty) property; if (csProp != null) { FVImageField imageField = new FVImageField(csProp, column.getAttributes()); if (imageField.getBufferedImage() == null) { Resource resource = imageField.getResourceAndSetIcon(); if (resource != null) { Button docIcon = new Button(); docIcon.setStyleName(Runo.BUTTON_LINK); docIcon.setWidth("-1px"); docIcon.setHeight("-1px"); docIcon.setIcon(resource); objReturned = docIcon; } } else { Image image = imageField.getEmbedded(); if (image != null) { int maxWidth = 150; int maxHeight = 150; imageField.resizeImage(image, maxWidth, maxHeight); } objReturned = imageField; } } } else { objReturned = ""; if (property != null) { AbstractComponent abstractComponent = (AbstractComponent) getTableTreeDelegate() .newGuiComponent(focObject, column, property); if (abstractComponent != null) { objReturned = abstractComponent; abstractComponent.addStyleName("editableStyle"); if (abstractComponent instanceof FVTextField) { // ((FVTextField) abstractComponent).selectAll(); /* * ((FVTextField) abstractComponent).addFocusListener(new * FocusListener() { private boolean updating = false; public void * focus(FocusEvent event) { if(!updating){ updating = true; * ((FVTextField) abstractComponent).selectAll(); updating = false; * } } }); */ // Adding the focus listener on the component to be used in the // formula layout if (getFormulaFocusListener() != null) { ((FVTextField) abstractComponent).addFocusListener(getFormulaFocusListener()); } if (isUseReadOnlyFlag()) { ((FVTextField) abstractComponent).addFocusListener(getReadOnlyFocusListener(true)); ((FVTextField) abstractComponent).addBlurListener(getReadOnlyBlurListener(true)); } } else if (abstractComponent instanceof FVCheckBox) { abstractComponent.setCaption(""); } else if (abstractComponent instanceof FVComboBox) { // Adding the focus listener on the component to be used in the // formula layout if (getFormulaFocusListener() != null) { ((FVComboBox) abstractComponent).addFocusListener(getFormulaFocusListener()); } if (isUseReadOnlyFlag()) { ((FVComboBox) abstractComponent).addFocusListener(getReadOnlyFocusListener(true)); ((FVComboBox) abstractComponent).addBlurListener(getReadOnlyBlurListener(true)); } } else if (abstractComponent instanceof FVObjectPopupView) { // Adding the focus listener on the component to be used in the // formula layout FVObjectPopupView popupView = ((FVObjectPopupView) abstractComponent); if (popupView != null && getFormulaFocusListener() != null) { popupView.addPopupVisibilityListener(new PopupVisibilityListener() { @Override public void popupVisibilityChange(PopupVisibilityEvent event) { if (getTableTreeDelegate() != null && event != null && event.getPopupView() != null && event.getPopupView() instanceof FVObjectPopupView) { FVObjectPopupView popupView = (FVObjectPopupView) event.getPopupView(); getTableTreeDelegate().adjustFormulaLayoutForComponent(popupView); } } }); // popupView.addFocusListener(getFormulaFocusListener()); } // if(isUseReadOnlyFlag()){ // popupView.addFocusListener(getReadOnlyFocusListener(true)); // popupView.addBlurListener(getReadOnlyBlurListener(true)); // } } else if (abstractComponent instanceof FVObjectSelector) { // Adding the focus listener on the component to be used in the // formula layout FVObjectComboBox comboBox = ((FVObjectSelector) abstractComponent).getComboBox(); if (comboBox != null && getFormulaFocusListener() != null) { comboBox.addFocusListener(getFormulaFocusListener()); } if (isUseReadOnlyFlag()) { comboBox.addFocusListener(getReadOnlyFocusListener(true)); comboBox.addBlurListener(getReadOnlyBlurListener(true)); } } else if (abstractComponent instanceof FVObjectComboBox && getFormulaFocusListener() != null) { FVObjectComboBox comboBox = (FVObjectComboBox) abstractComponent; if (comboBox != null) { comboBox.addFocusListener(getFormulaFocusListener()); } if (isUseReadOnlyFlag()) { comboBox.addFocusListener(getReadOnlyFocusListener(true)); comboBox.addBlurListener(getReadOnlyBlurListener(true)); } } else if (abstractComponent instanceof FVMultipleChoiceComboBox && getFormulaFocusListener() != null) { FVMultipleChoiceComboBox comboBox = (FVMultipleChoiceComboBox) abstractComponent; if (comboBox != null) { comboBox.addFocusListener(getFormulaFocusListener()); } if (isUseReadOnlyFlag()) { comboBox.addFocusListener(getReadOnlyFocusListener(true)); comboBox.addBlurListener(getReadOnlyBlurListener(true)); } } // Setting the column and row Ids of component FocXMLGuiComponent focXMLGuiComponent = (FocXMLGuiComponent) abstractComponent; FocXMLGuiComponentDelegate focXMLGuiComponentDelegate = focXMLGuiComponent.getDelegate(); if (focXMLGuiComponentDelegate != null) { focXMLGuiComponentDelegate.setColumnId(columnId); if (focObject != null && focObject.getReference() != null) { focXMLGuiComponentDelegate.setRowId(focObject.getReference().getLong()); } } abstractComponent.setId(column.getDataPath()); abstractComponent.setWidth("100%");// This was added to get the node // name text field in the BKDN // tree big enough to enter or see // the value // If we put 100% in the xml we get a small width extendable. but with // this solution we have a fixed minimum width in the xml + the 100% // allows us to change the width if (isUseReadOnlyFlag()) { abstractComponent.setReadOnly(true); } } } } if (property != null && property.isInherited()) { FProperty inheritedProp = null; try { inheritedProp = property.getFocField().getInheritedPropertyGetter() .getInheritedProperty(property.getFocObject(), property); } catch (Exception e) { Globals.logException(e); } if (inheritedProp != null) { objReturned = inheritedProp; } } return objReturned; }
From source file:com.foc.vaadin.gui.components.tableAndTree.FVColGen_FocProperty.java
License:Apache License
private Object getDisplayObject_ForProperty_NonEditable(FocObject focObject, FProperty property, FVTableColumn column, Object columnId) { Object objReturned = null;//from www . j av a2 s. com FField field = property != null ? property.getFocField() : null; if (property != null) { // Remove the editable component in case the editing status has changed // -------------------------------------------------------------------- String objRef = focObject != null && focObject.getReference() != null ? focObject.getReference().toString() : null; String compName = TableTreeDelegate.newComponentName(getTableName(), objRef, (String) column.getName()); FocXMLLayout focXMLLayout = getFocXMLLayout(); if (focXMLLayout != null) { FocXMLGuiComponent comp = focXMLLayout.removeComponentByName(compName); if (comp != null) { comp.dispose(); } } // -------------------------------------------------------------------- objReturned = property.vaadin_TableDisplayObject(column.getFormat(), column.getCaptionProp()); if (objReturned instanceof Boolean) { if (((Boolean) objReturned).booleanValue()) { objReturned = new Embedded("", new ThemeResource("../runo/icons/16/ok.png")); } else { // objReturned = new Embedded("", new // ThemeResource("../runo/icons/16/cancel.png")); objReturned = FVIconFactory.getInstance().getFVIcon_Embedded(FVIconFactory.ICON_EMPTY, FVIconFactory.SIZE_SMALL); } } else if (field instanceof FCloudStorageField) { FCloudStorageProperty csProp = (FCloudStorageProperty) property; if (csProp != null) { FVImageField imageField = new FVImageField(csProp, column.getAttributes()); if (imageField.getBufferedImage() == null) { Resource resource = imageField.getResourceAndSetIcon(); if (resource != null) { Button docIcon = new Button(); docIcon.setStyleName(Runo.BUTTON_LINK); docIcon.setWidth("-1px"); docIcon.setHeight("-1px"); docIcon.setIcon(resource); objReturned = docIcon; } } else { Image image = imageField.getEmbedded(); if (image != null) { int maxWidth = 150; int maxHeight = 150; imageField.resizeImage(image, maxWidth, maxHeight); } objReturned = imageField; } } } else if (property instanceof FObject || property instanceof FDate || property instanceof FString || property instanceof FDouble || property instanceof FInt || property instanceof FMultipleChoice) { if (property instanceof FMultipleChoice) { objReturned = property.getString(); } FVLabel lbl = null; String styleAttrib = column.getAttributes() != null ? column.getAttributes().getValue(FXML.ATT_STYLE) : null; int maxCharacters = column.getMaxCharacters(); String ttt = null; if (styleAttrib != null && !styleAttrib.isEmpty()) { lbl = new FVLabel((String) objReturned); lbl.parseStyleAttributeValue(styleAttrib); objReturned = lbl; } else if (property instanceof FDouble || (property instanceof FInt && !(property instanceof FMultipleChoice))) { lbl = new FVLabelInTable(property, focObject, column); lbl.copyMemoryToGui(); lbl.addStyleName("foc-text-right"); objReturned = lbl; } if (property instanceof FMultipleChoice) { Object itemObj = ((FMultipleChoice) property).getValue(); if (itemObj != null && itemObj instanceof FMultipleChoiceItem) { FMultipleChoiceItem item = (FMultipleChoiceItem) itemObj; if (lbl == null) { String iconNameInFontAwesome = item != null ? item.getIconFontAwesomeName() : null; if (iconNameInFontAwesome == null) { lbl = new FVLabel(item.getTitle()); // lbl.setIcon(FVIconFactory.getInstance().getFVIcon_Small(path)); } else { FontAwesome icon = FontAwesome.valueOf(iconNameInFontAwesome); lbl = new FVLabel(""); lbl.setCaption(null); lbl.setContentMode(ContentMode.HTML); lbl.setValue(item.getTitle() + " " + icon.getHtml()); } objReturned = lbl; } } } //If RTL I have t put the String in a label to align right if (lbl == null && getFocXMLLayout().isRTL()) { lbl = new FVLabelInTable(property, focObject, column); lbl.copyMemoryToGui(); lbl.addStyleName("foc-text-right"); objReturned = lbl; } //Setting the TTT is necessary //We have 2 conditions: either the objReturned is String or Label. //---------------------------- if (lbl != null) { String originalValue = lbl.getValue(); if (maxCharacters > 0 && originalValue != null && originalValue.length() > maxCharacters) { ttt = originalValue; // lbl.setLocale(); if (getFocXMLLayout().isRTL()) { lbl.addStyleName("foc-cellComment-left"); // lbl.setLocale(new Locale("ar")); StringBuffer buff = new StringBuffer(ttt.substring(0, maxCharacters)); // buff.append("..."); buff.append("..."); lbl.setValue(buff.toString()); } else { lbl.addStyleName("foc-cellComment-right"); lbl.setValue(ttt.substring(0, maxCharacters) + "..."); } } } else if (objReturned instanceof String) { String originalValue = (String) objReturned; if (maxCharacters > 0 && originalValue != null && originalValue.length() > maxCharacters) { ttt = originalValue; if (getFocXMLLayout().isRTL()) { objReturned = ttt.substring(0, maxCharacters) + "..."; } else { objReturned = ttt.substring(0, maxCharacters) + "..."; } } } if (ttt != null && getTableTreeDelegate() != null) { getTableTreeDelegate().addCellTooltipText(focObject.getReference(), columnId, ttt); } //---------------------------- if (lbl != null) { if (getFocXMLLayout().isRTL()) lbl.addStyleName("foc-text-right"); FocXMLGuiComponent focXMLGuiComponent = lbl; FocXMLGuiComponentDelegate componentDelegate = focXMLGuiComponent.getDelegate(); if (componentDelegate != null) { componentDelegate.setColumnId(columnId); if (focObject != null && focObject.getReference() != null) { componentDelegate.setRowId(focObject.getReference().getLong()); } } } if (lbl != null && getFocXMLLayout() != null) getFocXMLLayout().putComponent(compName, lbl); FocXMLAttributes attributes = column.getAttributes(); if (attributes != null && attributes.getValue(FXML.ATT_LINK) != null && attributes.getValue(FXML.ATT_LINK).equals("true")) { HyperLinkButton button = new HyperLinkButton(focObject, objReturned, compName); button.addClickListener(hyperLinkButtonListener); button.addStyleName("focLinkInTable"); objReturned = button; // if(getTableTreeDelegate().getViewContainer_ForOpen() == ITableTree.VIEW_CONTAINER_NEW_BROWSER_TAB){ // BrowserWindowOpener opener = null; // opener = new BrowserWindowOpener(UI.getCurrent().getClass()); // opener.extend(button); // } } } else { objReturned = property; // if((property instanceof FMultipleChoice)){ // FocXMLAttributes attributes = column.getAttributes(); // if(attributes != null && attributes.getValue(FXML.ATT_LINK) != null && attributes.getValue(FXML.ATT_LINK).equals("true")){ // HyperLinkButton button = new HyperLinkButton(focObject, property.getString()); // button.addClickListener(hyperLinkButtonListener); // button.addStyleName("focLinkInTable"); // objReturned = button; // } // } } } // if(objReturned instanceof String){ // objReturned = new Label(objReturned.toString()); // } return objReturned; }
From source file:com.foc.vaadin.gui.layouts.validationLayout.FVValidationLayout.java
License:Apache License
private Button newButton(String iconName) { Button button = new Button(""); if (validationSettings.getDiscardLink() != null && !validationSettings.getDiscardLink().isEmpty()) { button.setCaption(validationSettings.getDiscardLink()); } else {//from w w w . j a v a2 s.co m button.setIcon(FVIconFactory.getInstance().getFVIcon_Big(iconName)); } if (!Globals.isValo()) button.setStyleName(BaseTheme.BUTTON_LINK); return button; }
From source file:com.github.djabry.platform.vaadin.view.BannerView.java
License:Open Source License
private Button buildLogoutButton() { Button logout = new Button("Sign out"); logout.setIcon(FontAwesome.SIGN_OUT); logout.addStyleName(ValoTheme.BUTTON_PRIMARY); logout.addClickListener(new ClickListener() { public void buttonClick(Button.ClickEvent event) { logoutAction.run();/*from w w w . j a v a 2 s .c o m*/ } }); logout.setVisible(false); return logout; }
From source file:com.github.peholmst.springsecuritydemo.ui.MainView.java
License:Apache License
/** * TODO Document me!//from ww w. j a va 2 s. c o m * * @return */ protected Component createTicketBrowser() { final HorizontalLayout toolbar = new HorizontalLayout(); toolbar.setSpacing(true); toolbar.setWidth("100%"); final Button refreshButton = new Button(getApplication().getMessage("tickets.refresh.caption")); refreshButton.setIcon(new ThemeResource("icons/16/refresh.png")); refreshButton.setStyleName("small"); refreshButton.setDescription(getApplication().getMessage("tickets.refresh.descr")); toolbar.addComponent(refreshButton); toolbar.setComponentAlignment(refreshButton, Alignment.MIDDLE_LEFT); final Button addButton = new Button(getApplication().getMessage("tickets.add.caption")); addButton.setIcon(new ThemeResource("icons/16/add.png")); addButton.setStyleName("small"); addButton.setDescription(getApplication().getMessage("tickets.add.descr")); toolbar.addComponent(addButton); toolbar.setComponentAlignment(addButton, Alignment.MIDDLE_RIGHT); final SplitPanel splitPanel = new SplitPanel(); splitPanel.setSizeFull(); final Table ticketsTable = new Table(); ticketsTable.setSizeFull(); splitPanel.addComponent(ticketsTable); splitPanel.addComponent(new Label("The form for editing tickets will show up here")); final VerticalLayout browser = new VerticalLayout(); browser.setSizeFull(); browser.addComponent(toolbar); browser.addComponent(splitPanel); browser.setExpandRatio(splitPanel, 1.0f); return browser; }
From source file:com.hack23.cia.web.impl.ui.application.views.admin.agentoperations.pagemode.AgentOperationsOverviewPageModContentFactoryImpl.java
License:Apache License
@Secured({ "ROLE_ADMIN" }) @Override/*from w w w. j av a 2 s. c o m*/ public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) { final VerticalLayout content = createPanelContent(); getMenuItemFactory().createMainPageMenuBar(menuBar); LabelFactory.createHeader2Label(content, ADMIN_AGENT_OPERATION); final ComboBox targetSelect = new ComboBox(TARGET, Arrays.asList(DataAgentTarget.values())); targetSelect.setId(ViewAction.START_AGENT_BUTTON + TARGET2); content.addComponent(targetSelect); content.setExpandRatio(targetSelect, ContentRatio.SMALL2); final ComboBox operationSelect = new ComboBox(OPERATION, Arrays.asList(DataAgentOperation.values())); operationSelect.setId(ViewAction.START_AGENT_BUTTON + OPERATION2); content.addComponent(operationSelect); content.setExpandRatio(operationSelect, ContentRatio.SMALL2); final Button startAgentButton = new Button(START, new StartAgentClickListener(targetSelect, operationSelect, agentContainer)); startAgentButton.setId(ViewAction.START_AGENT_BUTTON.name()); startAgentButton.setIcon(FontAwesome.CROSSHAIRS); content.addComponent(startAgentButton); content.setExpandRatio(startAgentButton, ContentRatio.SMALL3); content.setSizeFull(); content.setMargin(false); content.setSpacing(true); content.setWidth(100, Unit.PERCENTAGE); content.setHeight(100, Unit.PERCENTAGE); return content; }
From source file:com.hack23.cia.web.impl.ui.application.views.common.formfactory.impl.FormFactoryImpl.java
License:Apache License
@Override public <T extends Serializable> void addRequestInputFormFields(final FormLayout panelContent, final BeanItem<T> item, final Class<T> beanType, final List<String> displayProperties, final String buttonLabel, final ClickListener buttonListener) { final BeanFieldGroup<T> fieldGroup = new BeanFieldGroup<>(beanType); fieldGroup.setItemDataSource(item);/*from www . j av a2 s.co m*/ fieldGroup.setReadOnly(true); for (final String property : displayProperties) { final Field<?> buildAndBind; if (property.contains(HIDDEN_FIELD_NAME)) { buildAndBind = fieldGroup.buildAndBind(property, property, PasswordField.class); } else { buildAndBind = fieldGroup.buildAndBind(property); } buildAndBind.setId(MessageFormat.format("{0}.{1}", buttonLabel, property)); buildAndBind.setReadOnly(false); buildAndBind.setWidth(ContentSize.HALF_SIZE); panelContent.addComponent(buildAndBind); } final Collection<Object> unboundPropertyIds = fieldGroup.getUnboundPropertyIds(); for (final Object property : unboundPropertyIds) { LOGGER.debug(LOG_MSG_PROPERTY, property); } final VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setWidth("50%"); final Button button = new Button(buttonLabel, new CommitFormWrapperClickListener(fieldGroup, buttonListener)); button.setId(buttonLabel); button.setWidth("25%"); button.setIcon(FontAwesome.PAW); verticalLayout.addComponent(button); verticalLayout.setComponentAlignment(button, Alignment.MIDDLE_RIGHT); panelContent.addComponent(verticalLayout); }
From source file:com.hack23.cia.web.impl.ui.application.views.common.menufactory.impl.AbstractMenuItemFactoryImpl.java
License:Apache License
protected final void createButtonLink(final GridLayout panelContent, final String linkText, final Resource icon, final ClickListener command, final String description) { final GridLayout grid = new GridLayout(2, 1); grid.setWidth(100, Unit.PERCENTAGE); grid.setHeight(100, Unit.PERCENTAGE); grid.setColumnExpandRatio(0, 1);// w ww. java2 s .c o m grid.setColumnExpandRatio(1, 2); final Button b = new Button(linkText); b.setStyleName("link"); b.addClickListener(command); b.setWidth(100, Unit.PERCENTAGE); b.setIcon(icon); b.setWidth(100, Unit.PERCENTAGE); grid.addComponent(b, 0, 0); grid.setComponentAlignment(b, Alignment.MIDDLE_LEFT); final Label descriptionLabel = new Label(description); descriptionLabel.setWidth(100, Unit.PERCENTAGE); grid.addComponent(descriptionLabel, 1, 0); grid.setComponentAlignment(descriptionLabel, Alignment.MIDDLE_LEFT); panelContent.addComponent(grid); panelContent.setComponentAlignment(grid, Alignment.MIDDLE_LEFT); }