com.vaadin.ui.Button类的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(15.0k)|赞(0)|评价(0)|浏览(154)

本文整理了Java中com.vaadin.ui.Button类的一些代码示例,展示了Button类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Button类的具体详情如下:
包路径:com.vaadin.ui.Button
类名称:Button

Button介绍

[英]A generic button component.
[中]通用按钮组件。

代码示例

代码示例来源:origin: com.vaadin/vaadin-server

/**
 * Customize the login button. Only for overriding, do not call.
 *
 * @return the login button
 * @since 7.7
 */
protected Button createLoginButton() {
  throwIfInitialized();
  return new Button(getLoginButtonCaption());
}

代码示例来源:origin: com.vaadin/vaadin-server

layout.addComponent(tabs);
VerticalLayout innerContainer = new VerticalLayout();
innerContainer.setWidth("100%");
innerContainer.setHeight(null);
innerContainer.addComponent(history);
resize.addClickListener(this::resizeButtonClick);
resize.setData(false);
resize.setWidth("100%");
resize.setHeight("10px");
resize.setPrimaryStyleName("resize-button");
layout.addComponent(resize);
ok.setWidth("70px");
ok.addClickListener(this::okButtonClick);
cancel.setWidth("70px");
cancel.addClickListener(this::cancelButtonClick);
HorizontalLayout buttons = new HorizontalLayout();
buttons.addComponent(ok);
buttons.addComponent(cancel);
buttons.setWidth("100%");
buttons.setHeight("30px");

代码示例来源:origin: com.vaadin/vaadin-server

@Override
  public void disableOnClick() throws RuntimeException {
    setEnabled(false);
    // Makes sure the enabled=false state is noticed at once - otherwise
    // a following setEnabled(true) call might have no effect. see
    // ticket #10030
    updateDiffstate("enabled", Json.create(false));
  }
};

代码示例来源:origin: com.vaadin/vaadin-server

/**
 * Creates a new push button with the given caption and icon.
 *
 * @param caption
 *            the caption
 * @param icon
 *            the icon
 */
public Button(String caption, Resource icon) {
  this();
  setCaption(caption);
  setIcon(icon);
}

代码示例来源:origin: com.vaadin/vaadin-server

@Override
public void readDesign(Element design, DesignContext designContext) {
  super.readDesign(design, designContext);
  Attributes attr = design.attributes();
  String content;
  // plain-text (default is html)
  Boolean plain = DesignAttributeHandler
      .readAttribute(DESIGN_ATTR_PLAIN_TEXT, attr, Boolean.class);
  if (plain == null || !plain) {
    setCaptionAsHtml(true);
    content = design.html();
  } else {
    // content is not intended to be interpreted as HTML,
    // so html entities need to be decoded
    content = DesignFormatter.decodeFromTextNode(design.html());
  }
  setCaption(content);
  if (attr.hasKey("icon-alt")) {
    setIconAlternateText(DesignAttributeHandler
        .readAttribute("icon-alt", attr, String.class));
  }
  // click-shortcut
  removeClickShortcut();
  ShortcutAction action = DesignAttributeHandler
      .readAttribute("click-shortcut", attr, ShortcutAction.class);
  if (action != null) {
    setClickShortcut(action.getKeyCode(), action.getModifiers());
  }
}

代码示例来源:origin: org.opennms.features/vaadin-snmp-events-and-metrics

addStyleName("dialog");
ueiBase = new TextField("UEI Base");
ueiBase.setNullSettingAllowed(false);
ueiBase.setWidth("100%");
ueiBase.setRequired(true);
ueiBase.setValue(defaultUei);
ueiBase.setRequiredError("UEI Base cannot be null.");
okButton = new Button("Continue");
okButton.addClickListener(this);
cancelButton = new Button("Cancel");
cancelButton.addClickListener(this);
HorizontalLayout toolbar = new HorizontalLayout();
toolbar.addComponent(okButton);
toolbar.addComponent(cancelButton);
VerticalLayout layout = new VerticalLayout();
layout.addComponent(ueiBase);
layout.addComponent(toolbar);
layout.setComponentAlignment(toolbar, Alignment.BOTTOM_RIGHT);
setContent(layout);

代码示例来源:origin: nz.co.senanque/madura-workflow-vaadin

@SuppressWarnings("serial")
private Component getInitialLayout() {
  VerticalLayout ret = new VerticalLayout();
  // Buttons
  Button close = new Button(m_messageSourceAccessor.getMessage("close", "Close"));
  HorizontalLayout actions = new HorizontalLayout();
  actions.setMargin(true);
  actions.setSpacing(true);
  actions.addComponent(close);
  close.addClickListener(new ClickListener(){
    @Override
    public void buttonClick(ClickEvent event) {
      close();
    }});
  ret.addComponent(actions);
  return ret;
}

代码示例来源:origin: nz.co.senanque/madura-vaadin-directed

public OneFieldWindow(RulesPlugin rulesPlugin, FieldMetadata fieldMetadata, MaduraSessionManager maduraSessionManager, final String submitStyle) {
  main = new VerticalLayout();
  setContent(main);
  setModal(true);
  main.setMargin(true);
  main.setSpacing(true);
  main.setWidth("320px");
  
  MaduraPropertyWrapper maduraPropertyWrapper = maduraSessionManager.getMaduraPropertyWrapper(fieldMetadata);
  FieldFactory fieldFactory = maduraSessionManager.getFieldFactory();
  Field<?> field = fieldFactory.createFieldByPropertyType(maduraPropertyWrapper);
  field.setReadOnly(true);
  main.addComponent(field);
  HorizontalLayout buttons = new HorizontalLayout();
  main.addComponent(buttons);
  Button buttonOK = fieldFactory.createButton("OK", new Button.ClickListener(){
    private static final long serialVersionUID = 1L;
    public void buttonClick(ClickEvent event) {
      close();
    }});
  if (submitStyle != null) {
    buttonOK.setClickShortcut(KeyCode.ENTER );
    buttonOK.addStyleName(submitStyle);
  }
  buttons.addComponent(buttonOK);
  
  buttons.setComponentAlignment(buttonOK, Alignment.BOTTOM_RIGHT);
}

代码示例来源:origin: org.eclipse.hawkbit/hawkbit-ui

public GatewaySecurityTokenAuthenticationConfigurationItem(
    final TenantConfigurationManagement tenantConfigurationManagement, final VaadinMessageSource i18n,
    final SecurityTokenGenerator securityTokenGenerator) {
  super(TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_ENABLED, tenantConfigurationManagement,
      i18n);
  this.securityTokenGenerator = securityTokenGenerator;
  super.init("label.configuration.auth.gatewaytoken");
  configurationEnabled = isConfigEnabled();
  detailLayout = new VerticalLayout();
  detailLayout.setImmediate(true);
  final Button gatewaytokenBtn = SPUIComponentProvider.getButton("TODO-ID", "Regenerate Key", "",
      ValoTheme.BUTTON_TINY + " " + "redicon", true, null, SPUIButtonStyleSmall.class);
  gatewaytokenBtn.setImmediate(true);
  gatewaytokenBtn.setIcon(FontAwesome.REFRESH);
  gatewaytokenBtn.addClickListener(event -> generateGatewayToken());
  gatewayTokenkeyLabel = new LabelBuilder().id("gatewaysecuritytokenkey").name("").buildLabel();
  gatewayTokenkeyLabel.addStyleName("gateway-token-label");
  gatewayTokenkeyLabel.setImmediate(true);
  final HorizontalLayout keyGenerationLayout = new HorizontalLayout();
  keyGenerationLayout.setSpacing(true);
  keyGenerationLayout.setImmediate(true);
  keyGenerationLayout.addComponent(gatewayTokenkeyLabel);
  keyGenerationLayout.addComponent(gatewaytokenBtn);
  detailLayout.addComponent(keyGenerationLayout);
  if (isConfigEnabled()) {
    gatewayTokenkeyLabel.setValue(getSecurityTokenKey());
    setDetailVisible(true);
  }
}

代码示例来源:origin: uk.q3c.krail/krail

@Override
public void doBuild(ViewChangeBusMessage event) {
  super.doBuild(event);
  centrePanel = new Panel();
  centrePanel.addStyleName(ChameleonTheme.PANEL_BUBBLE);
  centrePanel.setSizeUndefined();
  VerticalLayout vl = new VerticalLayout();
  centrePanel.setContent(vl);
  vl.setSpacing(true);
  vl.setSizeUndefined();
  label = new Label();
  usernameBox = new TextField();
  passwordBox = new PasswordField();
  Label demoInfoLabel = new Label("for this demo, enter any user name, and a password of 'password'");
  Label demoInfoLabel2 = new Label("In a real application your Shiro Realm implementation defines how to authenticate");
  submitButton = new Button();
  submitButton.addClickListener(this);
  statusMsgLabel = new Label("Please enter your username and password");
  vl.addComponent(label);
  vl.addComponent(demoInfoLabel);
  vl.addComponent(demoInfoLabel2);
  vl.addComponent(usernameBox);
  vl.addComponent(passwordBox);
  vl.addComponent(submitButton);
  vl.addComponent(statusMsgLabel);
  setMiddleCentre(centrePanel);
}

代码示例来源:origin: org.eclipse.hawkbit/hawkbit-ui

private VerticalLayout createSoftModuleLayout(final SoftwareModuleType swModType,
    final DistributionSet distributionSet, final Set<SoftwareModule> alreadyAssignedSwModules) {
  final VerticalLayout verticalLayout = new VerticalLayout();
  for (final SoftwareModule sw : alreadyAssignedSwModules) {
    if (swModType.getKey().equals(sw.getType().getKey())) {
      final HorizontalLayout horizontalLayout = new HorizontalLayout();
      horizontalLayout.setSizeFull();
      final Label softwareModule = HawkbitCommonUtil.getFormatedLabel("");
      final Button reassignSoftModule = SPUIComponentProvider.getButton(sw.getName(), "", "", "", true,
          FontAwesome.TIMES, SPUIButtonStyleNoBorder.class);
      reassignSoftModule
          .addClickListener(event -> unassignSW(event, distributionSet, alreadyAssignedSwModules));
      final String softwareModNameVersion = HawkbitCommonUtil.getFormattedNameVersion(sw.getName(),
          sw.getVersion());
      softwareModule.setValue(softwareModNameVersion);
      softwareModule.setDescription(softwareModNameVersion);
      softwareModule.setId(sw.getName() + "-label");
      horizontalLayout.addComponent(softwareModule);
      horizontalLayout.setExpandRatio(softwareModule, 1F);
      if (isUnassignSoftModAllowed && permissionChecker.hasUpdateRepositoryPermission() && !isTargetAssigned
          && (isSoftModAvaiableForSoftType(alreadyAssignedSwModules, swModType))) {
        horizontalLayout.addComponent(reassignSoftModule);
      }
      verticalLayout.addComponent(horizontalLayout);
    }
  }
  return verticalLayout;
}

代码示例来源:origin: org.activiti/activiti-explorer

protected void addLinkToProcessDefinition(final VerticalLayout verticalLayout, final String labelText, final boolean isSuspendedProcessDefinition) {
 HorizontalLayout  layout = new HorizontalLayout();
 verticalLayout.addComponent(layout);
 
 Label processDefinitionLabel = new Label(labelText);
 processDefinitionLabel.setSizeUndefined();
 layout.addComponent(processDefinitionLabel);
 
 layout.addComponent(new Label("&nbsp;", Label.CONTENT_XHTML));
 
 Button showProcessDefinitionLink = new Button(job.getProcessDefinitionId());
 showProcessDefinitionLink.addStyleName(Reindeer.BUTTON_LINK);
 showProcessDefinitionLink.addListener(new ClickListener() {
  private static final long serialVersionUID = 1L;
  public void buttonClick(ClickEvent event) {
   if (isSuspendedProcessDefinition) {
    ExplorerApp.get().getViewManager().showSuspendedProcessDefinitionsPage(job.getProcessDefinitionId());
   } else {
    ExplorerApp.get().getViewManager().showActiveProcessDefinitionsPage(job.getProcessDefinitionId());
   }
  }
 });
 layout.addComponent(showProcessDefinitionLink);
}

代码示例来源:origin: OpenNMS/opennms

public Object generateCell(Table source, final Object itemId, Object columnId) {
    Button button = new Button("Edit");
    button.setDescription("Edit this Ops Board configuration");
    button.setStyleName("small");
    button.addClickListener(new Button.ClickListener() {
      public void buttonClick(Button.ClickEvent clickEvent) {
        m_wallboardConfigView.openWallboardEditor((Wallboard) itemId);
      }
    });
    return button;
  }
});

代码示例来源:origin: org.aperteworkflow/base-widgets

public ScriptCodeEditor() {
  VerticalLayout compositionRoot = new VerticalLayout();
  setCompositionRoot(compositionRoot);
  code = new TextArea();
  code.setWidth("100%");
  code.setNullRepresentation("");
  compositionRoot.addComponent(code);
  HorizontalLayout hl = new HorizontalLayout();
  Button save = new Button(getLocalizedMessage("script.editor.save"));
  save.addListener(new Button.ClickListener() {
    @Override
    public void buttonClick(Button.ClickEvent event) {
      validateAndSave();
    }
  });
  hl.addComponent(save);
  compositionRoot.addComponent(hl);
}

代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework

@Override
protected Component initContent() {
  addStyleName("linkfield");
  rootLayout.setSizeFull();
  rootLayout.setSpacing(true);
  textField.setWidth(100, Unit.PERCENTAGE);
  textField.addValueChangeListener(event -> {
    // null value means "remove the currently selected link"
    T value = itemResolver.getItemByPath(event.getValue()).orElse(null);
    setValue(value);
  });
  linkLayout.setSizeFull();
  linkLayout.addComponent(textField);
  linkLayout.setExpandRatio(textField, 1);
  if (!textField.isReadOnly()) {
    selectButton.addStyleName("magnoliabutton");
    linkLayout.addComponent(selectButton);
    linkLayout.setExpandRatio(selectButton, 0);
  }
  rootLayout.addComponent(linkLayout);
  addValueChangeListener(event -> updateComponents());
  updateComponents();
  return rootLayout;
}

代码示例来源:origin: org.eclipse.hawkbit/hawkbit-ui

private void createSaveButton() {
  saveButton = SPUIComponentProvider.getButton(UIComponentIdProvider.SAVE_BUTTON,
      i18n.getMessage(UIMessageIdProvider.BUTTON_SAVE), "", "", true, FontAwesome.SAVE,
      SPUIButtonStyleNoBorderWithIcon.class);
  saveButton.setSizeUndefined();
  saveButton.addStyleName("default-color");
  addCloseListenerForSaveButton();
  saveButton.setEnabled(false);
  saveButton.setClickShortcut(KeyCode.ENTER);
  buttonsLayout.addComponent(saveButton);
  buttonsLayout.setComponentAlignment(saveButton, Alignment.MIDDLE_RIGHT);
  buttonsLayout.setExpandRatio(saveButton, 1.0F);
}

代码示例来源:origin: org.activiti/activiti-explorer

protected void initButtons(I18nManager i18nManager) {
 HorizontalLayout buttonLayout = new HorizontalLayout();
 buttonLayout.setSpacing(true);
 buttonLayout.setWidth(100, UNITS_PERCENTAGE);
 addComponent(buttonLayout);
 
 deployButton = new Button(i18nManager.getMessage(Messages.MODEL_DEPLOY_BUTTON_DEPLOY));
 buttonLayout.addComponent(deployButton);
 buttonLayout.setComponentAlignment(deployButton, Alignment.BOTTOM_CENTER);
}

代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework

private EditorView<T> addSubForm(VerticalLayout parent, ItemProviderStrategy<T> itemProvider) {
  // create subform
  MultiFormDefinition<T> multiFormDefinitionClone = MutableWrapper.wrap(definition);
  FormDefinitionMutator.accessMutable(multiFormDefinitionClone.getForm())
      .setName(getSubFormName(multiFormDefinitionClone));
  if (itemProvider == null) {
    itemProvider = () -> multiFormItemProvider.read().map(t -> orderHandler.getOrCreate(t, multiFormDefinitionClone.getForm().getName(), locale));
  }
  EditorView<T> subForm = getViewProvider().create(multiFormDefinitionClone.getForm(), itemProvider);
  forms.put(subForm, itemProvider);
  formOrder.add(subForm);
  // setup buttons, listeners and layout
  VerticalLayout wrapLayout = new VerticalLayout();
  HorizontalLayout buttonLayout = new HorizontalLayout();
  buttonLayout.addComponents(
      new Button(MagnoliaIcons.ARROW2_N, e -> onMove(parent, wrapLayout, MoveDirection.UP)),
      new Button(MagnoliaIcons.ARROW2_S, e -> onMove(parent, wrapLayout, MoveDirection.DOWN)),
      new Button(MagnoliaIcons.TRASH, e -> onDelete(parent, subForm)));
  buttonLayout.forEach(button -> button.addStyleName(ResurfaceTheme.BUTTON_ICON));
  wrapLayout.addComponents(subForm.asVaadinComponent(), buttonLayout);
  parent.addComponent(wrapLayout, parent.getComponentCount() - 1);
  return subForm;
}

代码示例来源:origin: OpenNMS/opennms

public static Button createButton(
    final String buttonCaption,
    final String buttonDescription,
    final Resource icon,
    final ClickListener clickListener) {
  Button button = new Button();
  button.setCaption(buttonCaption);
  button.setIcon(icon);
  if (buttonDescription != null) button.setDescription(buttonDescription);
  if (clickListener != null) button.addClickListener(clickListener);
  return button;
}

代码示例来源:origin: kingbbode/spring-boot-ehcache-monitor

private HorizontalLayout createSearchBox() {
  HorizontalLayout horizontalLayout = new HorizontalLayout();
  this.searchTextField.setWidth("70%");
  horizontalLayout.addComponent(this.searchTextField);
  Button button = new Button(VaadinIcons.SEARCH);
  button.addClickListener(event -> searchAction());
  button.setWidth("30%");
  horizontalLayout.addComponent(button);
  return horizontalLayout;
}

相关文章