Java Code Examples for com.vaadin.ui.Button#setIcon()

The following examples show how to use com.vaadin.ui.Button#setIcon() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SPUITagButtonStyle.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Button decorate(final Button button, final String style, final boolean setStyle, final Resource icon) {

    button.setImmediate(true);
    button.addStyleName("generatedColumnPadding button-no-border" + " " + ValoTheme.BUTTON_BORDERLESS + " "
            + "button-tag-no-border");

    // Set Style
    if (null != style) {
        if (setStyle) {
            button.setStyleName(style);
        } else {
            button.addStyleName(style);
        }
    }
    // Set icon
    if (null != icon) {
        button.setIcon(icon);
    }
    return button;
}
 
Example 2
Source File: SPUIButtonStyleTiny.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Button decorate(final Button button, final String style, final boolean setStyle, final Resource icon) {
    button.addStyleName(ValoTheme.BUTTON_TINY);
    // Set Style
    if (null != style) {
        if (setStyle) {
            button.setStyleName(style);
        } else {
            button.addStyleName(style);
        }
    }
    // Set icon
    if (null != icon) {
        button.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
        button.setIcon(icon);
    }
    return button;
}
 
Example 3
Source File: SPUIButtonStyleSmall.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Button decorate(final Button button, final String style, final boolean setStyle, final Resource icon) {
    button.addStyleName(ValoTheme.BUTTON_SMALL);
    if (style != null) {
        if (setStyle) {
            button.setStyleName(style);
        } else {
            button.addStyleName(style);
        }
    }
    if (icon != null) {
        button.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
        button.setIcon(icon);
    }
    return button;
}
 
Example 4
Source File: DistributionTable.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
private Button createPinBtn(final Object itemId) {

        final Item item = getContainerDataSource().getItem(itemId);
        final String name = (String) item.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue();

        final String version = (String) item.getItemProperty(SPUILabelDefinitions.VAR_VERSION).getValue();
        final DistributionSetIdName distributionSetIdName = new DistributionSetIdName((Long) itemId, name, version);

        final Button pinBtn = new Button();
        pinBtn.setIcon(FontAwesome.THUMB_TACK);
        pinBtn.setHeightUndefined();
        pinBtn.addStyleName(getPinStyle());
        pinBtn.setData(distributionSetIdName);
        pinBtn.setId(getPinButtonId(name, version));
        pinBtn.setImmediate(true);
        pinBtn.setDescription(getI18n().getMessage(UIMessageIdProvider.TOOLTIP_DISTRIBUTION_SET_PIN));
        return pinBtn;
    }
 
Example 5
Source File: ToolEditorUI.java    From chipster with MIT License 5 votes vote down vote up
private HorizontalLayout getButtonPanel() {
HorizontalLayout hLayout = new HorizontalLayout();
hLayout.setSpacing(true);

btUpdateTextEditor = new Button();
btUpdateTextEditor.setDescription("Update text area");
btUpdateTextEditor.setIcon(new ThemeResource("images/arrow_down.png"));
btUpdateTextEditor.addClickListener(new CSCToolToTextClickListener(this));
hLayout.addComponent(btUpdateTextEditor);
btUpdateToolEditor = new Button();
btUpdateToolEditor.setDescription("Update tool elements");
btUpdateToolEditor.setIcon(new ThemeResource("images/arrow_up.png"));
btUpdateToolEditor.addClickListener(new CSCTextToToolClickListener(this));
hLayout.addComponent(btUpdateToolEditor);
Button btClearAll = new Button("Clear All");
btClearAll.addClickListener(new ClickListener() {
	private static final long serialVersionUID = 1487893808578560989L;

	@Override
	public void buttonClick(ClickEvent event) {
		
		ToolEditorUI.this.addWindow(new ConfirmClearAll(ToolEditorUI.this));
	}
});
hLayout.addComponent(btClearAll);
return hLayout;

  }
 
Example 6
Source File: AdminUI.java    From sensorhub with Mozilla Public License 2.0 5 votes vote down vote up
protected Component buildToolbar()
{
    HorizontalLayout toolbar = new HorizontalLayout();
    toolbar.setWidth(100.0f, Unit.PERCENTAGE);
    
    // apply changes button
    Button saveButton = new Button("Save Config");
    saveButton.setDescription("Save Config");
    saveButton.setIcon(UIConstants.APPLY_ICON);
    saveButton.addStyleName(UIConstants.STYLE_SMALL);
    saveButton.setWidth(100.0f, Unit.PERCENTAGE);
    
    // apply button action
    saveButton.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 1L;
        public void buttonClick(ClickEvent event)
        {
            try
            {
                SensorHub.getInstance().getModuleRegistry().saveModulesConfiguration();
            }
            catch (Exception e)
            {
                AdminUI.log.error("Error while saving SensorHub configuration", e);
                Notification.show("Error", e.getMessage(), Notification.Type.ERROR_MESSAGE);
            }
        }
    });        

    toolbar.addComponent(saveButton);
    return toolbar;
}
 
Example 7
Source File: DashboardMenu.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private Component buildToggleButton() {
    final Button valoMenuToggleButton = new Button(i18n.getMessage("label.menu"),
            new MenuToggleClickListenerMyClickListener());
    valoMenuToggleButton.setIcon(FontAwesome.LIST);
    valoMenuToggleButton.addStyleName("valo-menu-toggle");
    valoMenuToggleButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    valoMenuToggleButton.addStyleName(ValoTheme.BUTTON_SMALL);
    return valoMenuToggleButton;
}
 
Example 8
Source File: AbstractMenuItemFactoryImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the button link.
 *
 * @param row
 *            the panel content
 * @param linkText
 *            the link text
 * @param icon
 *            the icon
 * @param command
 *            the command
 * @param description
 *            the description
 */
protected final void createButtonLink(final ResponsiveRow row,final String linkText,final Resource icon, final ClickListener command, final String description) {
	final CssLayout layout = new CssLayout();
	layout.addStyleName("v-layout-content-overview-panel-level2");
	Responsive.makeResponsive(layout);
	layout.setSizeUndefined();


	final Button button = new Button(linkText);
	Responsive.makeResponsive(button);
	button.setStyleName(LINK_STYLE_NAME);
	button.addStyleName("title");
	button.addClickListener(command);
	button.setIcon(icon);
	button.setWidth(100, Unit.PERCENTAGE);


	layout.addComponent(button);

	final Label descriptionLabel = new Label(description);
	descriptionLabel.addStyleName("itembox");
	Responsive.makeResponsive(descriptionLabel);
	descriptionLabel.setWidth(100, Unit.PERCENTAGE);
	layout.addComponent(descriptionLabel);

	row.addColumn().withDisplayRules(DISPLAY_SIZE_XS_DEVICE,DISPLAYS_SIZE_XM_DEVICE,DISPLAY_SIZE_MD_DEVICE,DISPLAY_SIZE_LG_DEVICE).withComponent(layout);
}
 
Example 9
Source File: FormFactoryImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
@Override
public <T extends Serializable> void addRequestInputFormFields(final FormLayout panelContent, final T item,
		final Class<T> beanType, final List<String> displayProperties,final String buttonLabel,final ClickListener buttonListener) {
	final BeanValidationBinder<T> binder = new BeanValidationBinder<>(beanType);
	binder.setBean(item);
	binder.setReadOnly(true);

	for (final String property : displayProperties) {

		final AbstractField buildAndBind = createField(property);
		binder.bind(buildAndBind,property);
		buildAndBind.setCaption(property);
		buildAndBind.setId(MessageFormat.format("{0}.{1}", buttonLabel, property));
		buildAndBind.setReadOnly(false);
		buildAndBind.setWidth(ContentSize.HALF_SIZE);

		panelContent.addComponent(buildAndBind);
	}

	final VerticalLayout verticalLayout = new VerticalLayout();
	verticalLayout.setWidth("50%");

	final Button button = new Button(buttonLabel,new CommitFormWrapperClickListener(binder,buttonListener));
	button.setId(buttonLabel);
	button.setWidth("25%");
	button.setIcon(VaadinIcons.BULLSEYE);
	button.setEnabled(false);
	binder.addStatusChangeListener(event -> button.setEnabled(event.getBinder().isValid()));
	
	
	verticalLayout.addComponent(button);
	verticalLayout.setComponentAlignment(button, Alignment.MIDDLE_RIGHT);

	panelContent.addComponent(verticalLayout);
}
 
Example 10
Source File: JobLogTable.java    From chipster with MIT License 5 votes vote down vote up
public Component generateCell(Table source, final Object itemId,
		Object columnId) {

	Property<?> prop = source.getItem(itemId).getItemProperty(JobLogContainer.ERROR_MESSAGE);
	if (prop != null && prop.getType() != null && prop.getType().equals(String.class)) {

		String errorMessage = (String) prop.getValue();

		if (errorMessage != null) {

			Button link = new Button();
			link.setIcon(new ThemeResource("../admin/crystal/agt_update_critical.png"));
			link.setStyleName(BaseTheme.BUTTON_LINK);
			link.setDescription("Show job error message");

			link.addClickListener(new Button.ClickListener() {

				public void buttonClick(ClickEvent event) {

					select(itemId);
					view.showErrorOutput(itemId);
				}
			});

			return link;
		}
	}

	return null;
}
 
Example 11
Source File: WinServerEdit.java    From primecloud-controller with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void attach() {
    setHeight(TAB_HEIGHT);
    setMargin(false, true, false, true);
    setSpacing(false);

    Form form = new Form();
    form.setSizeFull();
    form.addStyleName("win-server-edit-form");

    // サーバ名
    serverNameField = new TextField(ViewProperties.getCaption("field.serverName"));
    form.getLayout().addComponent(serverNameField);

    // ホスト名
    hostNameField = new TextField(ViewProperties.getCaption("field.hostName"));
    hostNameField.setWidth("100%");
    form.getLayout().addComponent(hostNameField);

    // コメント
    commentField = new TextField(ViewProperties.getCaption("field.comment"));
    commentField.setWidth("100%");
    form.getLayout().addComponent(commentField);

    // プラットフォーム
    CssLayout cloudLayout = new CssLayout();
    cloudLayout.setWidth("100%");
    cloudLayout.setCaption(ViewProperties.getCaption("field.cloud"));
    cloudLabel = new Label();
    cloudLayout.addComponent(cloudLabel);
    form.getLayout().addComponent(cloudLayout);

    // サーバ種別
    CssLayout imageLayout = new CssLayout();
    imageLayout.setWidth("100%");
    imageLayout.setCaption(ViewProperties.getCaption("field.image"));
    imageLabel = new Label();
    imageLayout.addComponent(imageLabel);
    form.getLayout().addComponent(imageLayout);

    // OS
    CssLayout osLayout = new CssLayout();
    osLayout.setWidth("100%");
    osLayout.setCaption(ViewProperties.getCaption("field.os"));
    osLabel = new Label();
    osLayout.addComponent(osLabel);
    form.getLayout().addComponent(osLayout);

    // ロードバランサでない場合
    if (BooleanUtils.isNotTrue(instance.getInstance().getLoadBalancer())) {
        // サービスを有効にするかどうか
        String enableService = Config.getProperty("ui.enableService");

        // サービスを有効にする場合
        if (StringUtils.isEmpty(enableService) || BooleanUtils.toBoolean(enableService)) {
            // 利用可能サービス
            Panel panel = new Panel();
            serviceTable = new AvailableServiceTable();
            panel.addComponent(serviceTable);
            form.getLayout().addComponent(panel);
            panel.setSizeFull();

            // サービス選択ボタン
            Button attachServiceButton = new Button(ViewProperties.getCaption("button.serverAttachService"));
            attachServiceButton.setDescription(ViewProperties.getCaption("description.serverAttachService"));
            attachServiceButton.setIcon(Icons.SERVICETAB.resource());
            attachServiceButton.addListener(new Button.ClickListener() {
                @Override
                public void buttonClick(ClickEvent event) {
                    attachServiceButtonClick(event);
                }
            });

            HorizontalLayout layout = new HorizontalLayout();
            layout.setSpacing(true);
            layout.addComponent(attachServiceButton);
            Label label = new Label(ViewProperties.getCaption("label.serverAttachService"));
            layout.addComponent(label);
            layout.setComponentAlignment(label, Alignment.MIDDLE_LEFT);
            form.getLayout().addComponent(layout);
        }
    }

    addComponent(form);
}
 
Example 12
Source File: SideMenu.java    From sidemenu-addon with Apache License 2.0 4 votes vote down vote up
/**
* Constructor for creating a SideMenu component. This method sets up all
* the components and styles needed for the side menu.
   */
  public SideMenu() {
      super();
      setSpacing(false);
      addStyleName(ValoTheme.UI_WITH_MENU);
      Responsive.makeResponsive(this);
      setSizeFull();

      menuArea.setPrimaryStyleName("valo-menu");
      menuArea.addStyleName("sidebar");
      menuArea.addStyleName(ValoTheme.MENU_PART);
      menuArea.addStyleName("no-vertical-drag-hints");
      menuArea.addStyleName("no-horizontal-drag-hints");
      menuArea.setWidth(null);
      menuArea.setHeight("100%");

      logoWrapper = new HorizontalLayout();
      logoWrapper.addStyleName("valo-menu-title");
      menuArea.addComponent(logoWrapper);

      userMenu.addStyleName("user-menu");
      userItem = userMenu.addItem("", null);

      menuArea.addComponent(userMenu);

      Button valoMenuToggleButton = new Button("Menu", event -> {
          if (menuArea.getStyleName().contains(STYLE_VISIBLE)) {
              menuArea.removeStyleName(STYLE_VISIBLE);
          } else {
              menuArea.addStyleName(STYLE_VISIBLE);
          }
      });
      valoMenuToggleButton.setIcon(VaadinIcons.LIST);
      valoMenuToggleButton.addStyleName("valo-menu-toggle");
      valoMenuToggleButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
      valoMenuToggleButton.addStyleName(ValoTheme.BUTTON_SMALL);
      menuArea.addComponent(valoMenuToggleButton);

menuItemsLayout.addStyleName("valo-menuitems");

      treeMenu.setTreeData(treeMenuData);
      treeMenu.asSingleSelect().addValueChangeListener(event -> {
              if ( !event.isUserOriginated()) {
                  return;
              }
              if (null == event.getValue()) {
                  // Workaround to disable deselect
                  treeMenu.select(event.getOldValue());
              } else {
                  Optional.ofNullable(treeMenuItemToClick.get(event.getValue())).ifPresent(MenuClickHandler::click);
              }
          });
      menuArea.addComponent(menuItemsLayout);

      contentArea.setPrimaryStyleName("valo-content");
      contentArea.addStyleName("v-scrollable");
      contentArea.setSizeFull();

      // Remove default margins and spacings
      contentArea.setMargin(false);
      contentArea.setSpacing(false);

      super.addComponent(menuArea);
      super.addComponent(contentArea);
      setExpandRatio(contentArea, 1);
  }
 
Example 13
Source File: ServiceMenu.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
public Button addService(String serviceName, Resource linkIcon, ClickListener listener) {
    Button serviceBtn = new Button(serviceName, listener);
    serviceBtn.setIcon(linkIcon);
    this.with(serviceBtn);
    return serviceBtn;
}
 
Example 14
Source File: SensorAdminPanel.java    From sensorhub with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public void build(final MyBeanItem<ModuleConfig> beanItem, final ISensorModule<?> module)
{
    super.build(beanItem, module);       
    
    // add section label
    final GridLayout form = new GridLayout();
    form.setWidth(100.0f, Unit.PERCENTAGE);
    form.setMargin(false);
    form.setSpacing(true);
    
    // section title
    form.addComponent(new Label(""));
    HorizontalLayout titleBar = new HorizontalLayout();
    titleBar.setSpacing(true);
    Label sectionLabel = new Label("Inputs/Outputs");
    sectionLabel.addStyleName(STYLE_H3);
    sectionLabel.addStyleName(STYLE_COLORED);
    titleBar.addComponent(sectionLabel);
    titleBar.setComponentAlignment(sectionLabel, Alignment.MIDDLE_LEFT);
    
    // refresh button to show latest record
    Button refreshButton = new Button("Refresh");
    refreshButton.setDescription("Load latest data from sensor");
    refreshButton.setIcon(REFRESH_ICON);
    refreshButton.addStyleName(STYLE_QUIET);
    titleBar.addComponent(refreshButton);
    titleBar.setComponentAlignment(refreshButton, Alignment.MIDDLE_LEFT);
    refreshButton.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;
        @Override
        public void buttonClick(ClickEvent event)
        {
            rebuildSwePanels(form, module);
        }
    });
            
    form.addComponent(titleBar);
    
    // add I/O panel
    rebuildSwePanels(form, module);
    addComponent(form);
}
 
Example 15
Source File: DefaultModulePanel.java    From sensorhub with Mozilla Public License 2.0 4 votes vote down vote up
@Override
@SuppressWarnings("serial")
public void build(final MyBeanItem<ModuleConfig> beanItem, final ModuleType module)
{
    setSizeUndefined();
    setWidth(100.0f, Unit.PERCENTAGE);
    setMargin(false);
    setSpacing(true);
    
    // label with module name
    String moduleName = getTitle(beanItem.getBean());
    Label title = new Label(moduleName);
    title.setStyleName(STYLE_H2);
    addComponent(title);
    
    // apply changes button
    Button applyButton = new Button("Apply Changes");
    applyButton.setIcon(APPLY_ICON);
    applyButton.addStyleName("apply-button");
    addComponent(applyButton);
    
    // config form
    final IModuleConfigForm form = getConfigForm(beanItem, module);
    addComponent(form);
    
    // apply button action
    applyButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event)
        {
            try
            {
                form.commit();
                if (module != null)
                    ((IModule<ModuleConfig>)module).updateConfig(beanItem.getBean());
            }
            catch (Exception e)
            {
                String msg = "Error while updating module configuration";
                Page page = AdminUI.getInstance().getPage();
                new Notification("Error", msg + '\n' + e.getMessage(), Notification.Type.ERROR_MESSAGE).show(page);
                //Notification.show("Error", msg + '\n' + e.getMessage(), Notification.Type.ERROR_MESSAGE);
                AdminUI.log.error(msg, e);
            }
        }
    });
}
 
Example 16
Source File: ButtonFactoryImpl.java    From vaadinator with Apache License 2.0 4 votes vote down vote up
@Override
public void initSaveButton(Button saveButton, String caption, String style, ClickListener clickListener) {
	super.initSaveButton(saveButton, caption, style, clickListener);
	saveButton.setIcon(FontAwesome.SAVE);
}
 
Example 17
Source File: ButtonFactoryImpl.java    From vaadinator with Apache License 2.0 4 votes vote down vote up
@Override
public void initNewButton(Button newButton, String caption, String style, ClickListener clickListener) {
	super.initNewButton(newButton, caption, style, clickListener);
	newButton.setIcon(FontAwesome.PLUS);
}
 
Example 18
Source File: VaadinPaginator.java    From jdal with Apache License 2.0 4 votes vote down vote up
private Button createButton(String icon) {
	Button b = nativeButtons ? new NativeButton() : new Button() ;
	b.setIcon(new ThemeResource(icon));

	return b;
}
 
Example 19
Source File: ButtonFactoryImpl.java    From vaadinator with Apache License 2.0 4 votes vote down vote up
@Override
public void initSaveButton(Button saveButton, String caption, String style, ClickListener clickListener) {
	super.initSaveButton(saveButton, caption, style, clickListener);
	saveButton.setIcon(FontAwesome.SAVE);
}
 
Example 20
Source File: SideMenu.java    From sidemenu-addon with Apache License 2.0 3 votes vote down vote up
/**
* Adds a menu entry with given icon. The given handler is called when the
* user clicks the entry.
*
* @param text
*            menu text
* @param icon
*            menu icon
* @param handler
*            menu click handler
   *
   * @return menu registration
   */
  public MenuRegistration addMenuItem(String text, Resource icon, final MenuClickHandler handler) {
      Button button = new Button(text, event -> {
          handler.click();
          menuArea.removeStyleName(STYLE_VISIBLE);
      });
      button.setIcon(icon);
      button.setPrimaryStyleName("valo-menu-item");
      menuItemsLayout.addComponent(button);
      return new MenuRegistrationImpl<>(button, Button::click, menuItemsLayout::removeComponent);
  }