Java Code Examples for com.vaadin.ui.Button

The following are top voted examples for showing how to use com.vaadin.ui.Button. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: svgexamples   File: SimplyAsAnImageOrIcon.java   Source Code and License 6 votes vote down vote up
public SimplyAsAnImageOrIcon() {
    setCaption("Image and icon");
    addComponent(new MLabel("Following Image component (rendered as IMG element) contains SVG image. Note, that by using SVG in this way, it is treated as a static image. For eample the js changing the color on click is not executed. See the file example to see how to render an interactive SVG.").withFullWidth());
    Image image = new Image(null, new ClassResource("/pull.svg"));
    image.setWidth("300px");
    addComponent(image);
    
    addComponent(new MLabel("Following Button has SVG logo as an icon.").withFullWidth());
    
    Button button = new Button();
    button.setIcon(new ClassResource("/vaadin-logo.svg"));
    button.addStyleNames(ValoTheme.BUTTON_ICON_ONLY, ValoTheme.BUTTON_HUGE);
    addComponent(button);
}
 
Example 2
Project: obog-manager   File: MemberListView.java   Source Code and License 6 votes vote down vote up
@Override
public void enter(ViewChangeListener.ViewChangeEvent event) {
    if (!isLoggedIn()) {
        getUI().getNavigator().navigateTo(LoginView.VIEW_NAME);
        return;
    }
    addComponent(new HeadingLabel("会員名簿", VaadinIcons.BULLETS));

    printAllMembers();

    Button homeButton = new Button("会員メニュー", click -> getUI().getNavigator().navigateTo(MenuView.VIEW_NAME));
    homeButton.setIcon(VaadinIcons.USER);
    addComponent(homeButton);
    setComponentAlignment(homeButton, Alignment.MIDDLE_CENTER);
}
 
Example 3
Project: obog-manager   File: ThanksView.java   Source Code and License 6 votes vote down vote up
@Override
public void enter(ViewChangeListener.ViewChangeEvent event) {
    addComponent(new HeadingLabel("参加登録完了", VaadinIcons.CHECK));
    addComponent(new Label("参加登録が完了し、確認メールを送信しました。"));
    Label addressLabel = new Label("しばらく待ってもメールが来ない場合は、お手数ですが " + appReply + " までご連絡ください。");
    addressLabel.setCaption("お願い");
    addressLabel.setIcon(VaadinIcons.LIGHTBULB);
    addComponent(addressLabel);
    Button homeButton = new Button("ホーム", click -> getUI().getNavigator().navigateTo(FrontView.VIEW_NAME));
    homeButton.setIcon(VaadinIcons.HOME);
    addComponent(homeButton);
    setComponentAlignment(homeButton, Alignment.MIDDLE_CENTER);
}
 
Example 4
Project: obog-manager   File: TokenSentView.java   Source Code and License 6 votes vote down vote up
@Override
public void enter(ViewChangeListener.ViewChangeEvent event) {
    addComponent(new HeadingLabel("パスワードリセット要求送信完了", VaadinIcons.INFO_CIRCLE));
    addComponent(new Label("入力された E-mail アドレスへパスワードリセットの案内メールを送信しました。"));
    Label addressLabel = new Label("しばらく待ってもメールが来ない場合は、お手数ですが " + appReply + " までご連絡ください。");
    addressLabel.setCaption("お願い");
    addressLabel.setIcon(VaadinIcons.LIGHTBULB);
    addComponent(addressLabel);
    Button homeButton = new Button("ホーム", click -> getUI().getNavigator().navigateTo(FrontView.VIEW_NAME));
    homeButton.setIcon(VaadinIcons.HOME);
    addComponent(homeButton);
    setComponentAlignment(homeButton, Alignment.MIDDLE_CENTER);
}
 
Example 5
Project: holon-vaadin7   File: QuestionDialog.java   Source Code and License 6 votes vote down vote up
@Override
protected void buildActions(HorizontalLayout actionsContainer) {
	actionsContainer.setSpacing(true);
	// yes
	final Button btnYes = Components.button().styleName(ValoTheme.BUTTON_PRIMARY)
			.caption(Localizable.builder().message(DEFAULT_YES_BUTTON_MESSAGE)
					.messageCode(DEFAULT_YES_BUTTON_MESSAGE_CODE).build())
			.onClick(e -> onDialogYesButtonClick(e.getButton())).build();
	getYesButtonConfigurator().ifPresent(c -> c.configureDialogButton(Components.configure(btnYes)));
	actionsContainer.addComponent(btnYes);
	actionsContainer.setComponentAlignment(btnYes, Alignment.MIDDLE_LEFT);
	if (getWidth() > -1) {
		btnYes.setWidth("100%");
	}
	// no
	final Button btnNo = Components.button()
			.caption(Localizable.builder().message(DEFAULT_NO_BUTTON_MESSAGE)
					.messageCode(DEFAULT_NO_BUTTON_MESSAGE_CODE).build())
			.onClick(e -> onDialogNoButtonClick(e.getButton())).build();
	getNoButtonConfigurator().ifPresent(c -> c.configureDialogButton(Components.configure(btnNo)));
	actionsContainer.addComponent(btnNo);
	actionsContainer.setComponentAlignment(btnNo, Alignment.MIDDLE_RIGHT);
	if (getWidth() > -1) {
		btnNo.setWidth("100%");
	}
}
 
Example 6
Project: md-stepper   File: HorizontalStepper.java   Source Code and License 6 votes vote down vote up
private void refreshButtonBar(Step step) {
  buttonBar.removeAllComponents();
  buttonBar.setVisible(true);

  if (step == null) {
    return;
  }

  Button backButton = step.getBackButton();
  Button cancelButton = step.getCancelButton();
  Button skipButton = step.getSkipButton();
  Button nextButton = step.getNextButton();

  backButton.setVisible(getStepIterator().hasPrevious());
  cancelButton.setVisible(step.isCancellable());
  skipButton.setVisible(step.isOptional());
  nextButton.setVisible(!isComplete());

  buttonBar.addComponent(backButton);
  Spacer.addToLayout(buttonBar);
  buttonBar.addComponent(cancelButton);
  buttonBar.addComponent(skipButton);
  buttonBar.addComponent(nextButton);
}
 
Example 7
Project: osc-core   File: SslConfigurationLayout.java   Source Code and License 6 votes vote down vote up
@Override
public void buttonClick(Button.ClickEvent event) {
    final String alias = (String) event.getButton().getData();
    log.info("Removing ssl entry with alias: " + alias);
    boolean succeed;

    DeleteSslEntryRequest deleteRequest = new DeleteSslEntryRequest(alias);

    try {
        SslConfigurationLayout.this.deleteSslCertificateService.dispatch(deleteRequest);
        succeed = true;
    } catch (Exception e) {
        succeed = false;
        log.error("Failed to remove SSL alias from truststore", e);
    }

    SslConfigurationLayout.this.buildSslConfigurationTable();
    SslConfigurationLayout.this.deleteWindow.close();

    String outputMessage = (succeed) ? MAINTENANCE_SSLCONFIGURATION_REMOVED : MAINTENANCE_SSLCONFIGURATION_REMOVE_FAILURE;
    ViewUtil.iscNotification(getString(outputMessage, new Date()), null, Notification.Type.TRAY_NOTIFICATION);
}
 
Example 8
Project: osc-core   File: PluginsLayout.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("unchecked")
private void updateItem(Item item, PluginApi plugin) {

    item.getItemProperty(PROP_PLUGIN_STATE).setValue(plugin.getState().toString());
    item.getItemProperty(PROP_PLUGIN_NAME).setValue(plugin.getSymbolicName());
    item.getItemProperty(PROP_PLUGIN_VERSION).setValue(plugin.getVersion());
    item.getItemProperty(PROP_PLUGIN_SERVICES).setValue(plugin.getServiceCount());

    String info;
    if (plugin.getState() == State.ERROR) {
        info = plugin.getError();
    } else {
        info = "";
    }
    item.getItemProperty(PROP_PLUGIN_INFO).setValue(info);

    Button deleteButton = new Button("Delete");
    deleteButton.addClickListener(event -> deletePlugin(plugin));
    item.getItemProperty(PROP_PLUGIN_DELETE).setValue(deleteButton);
}
 
Example 9
Project: osc-core   File: SummaryLayout.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("serial")
private Button createDownloadButton() {
    this.download = new Button(VmidcMessages.getString(VmidcMessages_.SUMMARY_DOWNLOAD_LOG)) {
        @Override
        public void setEnabled(boolean enabled) {
            if (enabled) {
                // because setEnabled(false) calls are ignored and button is disabled
                // on client because of setDisableOnClick(true), by doing this we
                // make sure that the button is actually disabled so that setEnabled(true)
                // has effect
                getUI().getConnectorTracker().getDiffState(this).put("enabled", false);
                super.setEnabled(enabled);
            }
        }
    };
    SummaryLayout.this.download.setDisableOnClick(true);
    if (this.checkbox != null && this.checkbox.getValue()) {
        this.download.setCaption(VmidcMessages.getString(VmidcMessages_.SUMMARY_DOWNLOAD_BUNDLE));
    }
    StreamResource zipStream = getZipStream();
    FileDownloader fileDownloader = new FileDownloader(zipStream);
    fileDownloader.extend(this.download);
    return this.download;
}
 
Example 10
Project: osc-core   File: NetworkLayout.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("serial")
private Button createIPSettingsEditButton() {
    // creating edit button
    this.editIPSettings = new Button("Edit");
    this.editIPSettings.setEnabled(true);
    this.editIPSettings.addStyleName(StyleConstants.BUTTON_TOOLBAR);
    this.editIPSettings.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            try {
                editIPSettingsClicked();
            } catch (Exception e) {
                ViewUtil.showError("Error editing IP settings", e);
            }
        }
    });
    return this.editIPSettings;
}
 
Example 11
Project: osc-core   File: NetworkLayout.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("serial")
private Button createNATEditButton() {
    // creating edit button
    this.editNATSettings = new Button("Edit");
    this.editNATSettings.setEnabled(true);
    this.editNATSettings.addStyleName(StyleConstants.BUTTON_TOOLBAR);
    this.editNATSettings.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            try {
                editNATSettingsClicked();
            } catch (Exception e) {
                ViewUtil.showError("Error editing NAT settings", e);
            }
        }
    });
    return this.editNATSettings;
}
 
Example 12
Project: bootstrap-formgroup   File: FormGroupTextFieldUI.java   Source Code and License 6 votes vote down vote up
@Override
public Component getTestComponent() {

    TextFieldGroup field = new TextFieldGroup();

    field.setCaption("Caption");
    field.setDescription("Description");

    Button action1 = new Button("Change Mode to Danger");
    action1.setId("action1");
    action1.addClickListener(event -> {
        field.setMode(BootstrapMode.DANGER);
    });

    Button action2 = new Button("Remove Mode");
    action2.setId("action2");
    action2.addClickListener(event -> {
        field.removeMode();
    });

    MyCustomLayout layout = new MyCustomLayout(FormGroupHtml.BASIC, action1, action2);
    layout.addComponent(field, "field");

    return layout;
}
 
Example 13
Project: holon-vaadin   File: QuestionDialog.java   Source Code and License 6 votes vote down vote up
@Override
protected void buildActions(HorizontalLayout actionsContainer) {
	actionsContainer.setSpacing(true);
	// yes
	final Button btnYes = Components.button().styleName(ValoTheme.BUTTON_PRIMARY)
			.caption(Localizable.builder().message(DEFAULT_YES_BUTTON_MESSAGE)
					.messageCode(DEFAULT_YES_BUTTON_MESSAGE_CODE).build())
			.onClick(e -> onDialogYesButtonClick(e.getButton())).build();
	getYesButtonConfigurator().ifPresent(c -> c.configureDialogButton(Components.configure(btnYes)));
	actionsContainer.addComponent(btnYes);
	actionsContainer.setComponentAlignment(btnYes, Alignment.MIDDLE_LEFT);
	if (getWidth() > -1) {
		btnYes.setWidth("100%");
	}
	// no
	final Button btnNo = Components.button()
			.caption(Localizable.builder().message(DEFAULT_NO_BUTTON_MESSAGE)
					.messageCode(DEFAULT_NO_BUTTON_MESSAGE_CODE).build())
			.onClick(e -> onDialogNoButtonClick(e.getButton())).build();
	getNoButtonConfigurator().ifPresent(c -> c.configureDialogButton(Components.configure(btnNo)));
	actionsContainer.addComponent(btnNo);
	actionsContainer.setComponentAlignment(btnNo, Alignment.MIDDLE_RIGHT);
	if (getWidth() > -1) {
		btnNo.setWidth("100%");
	}
}
 
Example 14
Project: bootstrap-formgroup   File: FormGroupComboBoxRequiredUI.java   Source Code and License 6 votes vote down vote up
@Override
public Component getTestComponent() {

    ComboBoxGroup<String> field = new ComboBoxGroup<>();

    field.setCaption("Caption");
    field.setDescription("Description");
    field.getField().setItems("1", "2", "3");

    Button action1 = new Button("add required");
    action1.setId("action1");
    action1.addClickListener(event -> {
        field.setRequired(true);
    });

    Button action2 = new Button("remove Required");
    action2.setId("action2");
    action2.addClickListener(event -> {
        field.setRequired(false);
    });

    MyCustomLayout layout = new MyCustomLayout(FormGroupHtml.BASIC, action1, action2);
    layout.addComponent(field, "field");

    return layout;
}
 
Example 15
Project: material-theme-fw8   File: ToggleButtonGroup.java   Source Code and License 6 votes vote down vote up
public void selectToggleButton(Button button) {
    if (!buttons.contains(button)) return;

    if (this.mode == SelectionMode.SINGLE) {
        for (Button b : buttons) {
            b.removeStyleName(ACTIVE);
        }
    }

    if (button.getStyleName().contains(ACTIVE)) {
        button.removeStyleName(ACTIVE);
    } else {
        button.addStyleName(ACTIVE);
    }

    for (Button btn : buttons) {
        if (btn.getStyleName().contains(ACTIVE)) {
            addStyleName("card");
            return;
        }
        removeStyleName("card");
    }
}
 
Example 16
Project: material-theme-fw8   File: SimpleDialog.java   Source Code and License 6 votes vote down vote up
public SimpleDialog(String title, String message, boolean lightTheme) {
    super(title);
    addStyleName(lightTheme ? Styles.Windows.LIGHT : Styles.Windows.DARK);

    label = new Label(message);
    label.setPrimaryStyleName(lightTheme ? Typography.Dark.Subheader.SECONDARY : Typography.Light.Subheader.SECONDARY);
    label.addStyleName(Paddings.Horizontal.LARGE + " " + Paddings.Bottom.LARGE);

    // Footer
    cancel = new Button("Cancel");
    cancel.setPrimaryStyleName(lightTheme ? Styles.Buttons.Flat.LIGHT : Styles.Buttons.Flat.DARK);
    cancel.addClickListener(e -> close());

    ok = new Button("OK");
    ok.setPrimaryStyleName(lightTheme ? Styles.Buttons.Flat.LIGHT : Styles.Buttons.Flat.DARK);
    ok.addClickListener(e -> close());

    footer = new FlexLayout(cancel, ok);
    footer.setJustifyContent(FlexLayout.JustifyContent.FLEX_END);
    footer.addStyleName(Paddings.All.SMALL + " " + Spacings.Right.SMALL + " " + FlexItem.FlexShrink.SHRINK_0);
    footer.setWidth(100, Unit.PERCENTAGE);

    // Content wrapper
    content = new FlexLayout(FlexLayout.FlexDirection.COLUMN, label, footer);
    setContent(content);
}
 
Example 17
Project: material-theme-fw8   File: DatePickerFooter.java   Source Code and License 6 votes vote down vote up
public DatePickerFooter(InlineDateField field, boolean lightTheme) {
    setAlignItems(FlexLayout.AlignItems.CENTER);
    setJustifyContent(FlexLayout.JustifyContent.FLEX_END);
    addStyleName(Paddings.All.SMALL);
    addStyleName(Spacings.Right.SMALL);
    addStyleName(FlexItem.FlexShrink.SHRINK_0);

    cancel = new Button("Cancel");
    cancel.setPrimaryStyleName(lightTheme ? Styles.Buttons.Flat.LIGHT : Styles.Buttons.Flat.DARK);

    ok = new Button("OK");
    ok.setPrimaryStyleName(lightTheme ? Styles.Buttons.Flat.LIGHT : Styles.Buttons.Flat.DARK);
    ok.setEnabled(field.getValue() != null);

    this.field = field;
    this.field.addValueChangeListener(event -> ok.setEnabled(this.field.getValue() != null));

    addComponents(cancel, ok);
}
 
Example 18
Project: bootstrap-formgroup   File: CheckBoxMultiGroupRequiredUI.java   Source Code and License 6 votes vote down vote up
@Override
public Component getTestComponent() {

    CheckBoxMultiGroup<String> field = new CheckBoxMultiGroup<>();

    field.setCaption("Caption");
    field.setDescription("Description");
    field.getField().setItems("1", "2", "3");

    Button action1 = new Button("add required");
    action1.setId("action1");
    action1.addClickListener(event -> {
        field.setRequired(true);
    });

    Button action2 = new Button("remove Required");
    action2.setId("action2");
    action2.addClickListener(event -> {
        field.setRequired(false);
    });

    MyCustomLayout layout = new MyCustomLayout(FormGroupHtml.BASIC, action1, action2);
    layout.addComponent(field, "field");

    return layout;
}
 
Example 19
Project: obog-manager   File: ErrorView.java   Source Code and License 5 votes vote down vote up
@Override
public void enter(ViewChangeListener.ViewChangeEvent event) {
    Label errorLabel = new Label("エラーが発生しました。");
    errorLabel.setStyleName(ValoTheme.LABEL_FAILURE);

    VaadinSession session = VaadinSession.getCurrent();
    String paramMessage = (String) session.getAttribute(PARAM_MESSAGE);
    if (paramMessage != null) {
        addComponent(new Label(paramMessage));
    }
    session.setAttribute(PARAM_MESSAGE, null);
    Throwable paramThrowable = (Throwable) session.getAttribute(PARAM_THROWABLE);
    if (paramThrowable != null) {
        addComponent(new Label(throwable2html(paramThrowable), ContentMode.HTML));
    }
    session.setAttribute(PARAM_THROWABLE, null);
    log.error(paramMessage, paramThrowable);

    if (paramThrowable instanceof AuthenticationException) {
        Button loginButton = new Button("ログイン", click -> getUI().getNavigator().navigateTo(LoginView.VIEW_NAME));
        addComponent(loginButton);
        setComponentAlignment(loginButton, Alignment.MIDDLE_CENTER);
    }

    Button homeButton = new Button("ホーム", click -> getUI().getNavigator().navigateTo(FrontView.VIEW_NAME));
    addComponent(homeButton);
    setComponentAlignment(homeButton, Alignment.MIDDLE_CENTER);
}
 
Example 20
Project: javamagazin-009-microkernel   File: LoginComponent.java   Source Code and License 5 votes vote down vote up
public void postProcess() {
  panel.setId(ID_PANEL_MAIN);
  panel.setCaption(PANEL_CAPTION_MAIN);
  panel.setSizeFull();

  login.setId(ID_TEXTFIELD_LOGIN);
  login.setCaption(TEXTFIELD_CAPTION_LOGIN); //TODO i18n

  password.setId(ID_PASSWORDFIELD_PASSWORD);
  password.setCaption(PASSWORDFIELD_CAPTION_PASSWORD); //TODO i18n

  ok.setCaption(BUTTON_CAPTION_OK);
  ok.setId(ID_BUTTON_OK);
  ok.addClickListener((Button.ClickListener) event -> {
    boolean isValid = loginService.check(login.getValue(), password.getValue());
    clearInputFields();

    if (isValid) {
      UI.getCurrent()
        .getSession()
        .setAttribute(SESSION_ATTRIBUTE_USER, loginService.loadUser(login.getValue()));
    }

    UI.getCurrent()
      .setContent((isValid) ? mainViewSupplier.get() : this);
  });

  cancel.setId(ID_BUTTON_CANCEL);
  cancel.setCaption(BUTTON_CAPTION_CANCEL);
  cancel.addClickListener((Button.ClickListener) event -> clearInputFields());
}
 
Example 21
Project: vaadin-016-helloworld-14   File: LoginComponent.java   Source Code and License 5 votes vote down vote up
public void postProcess() {
    panel.setId(ID_PANEL_MAIN);
    panel.setCaption(PANEL_CAPTION_MAIN);
    panel.setSizeFull();

    login.setId(ID_TEXTFIELD_LOGIN);
    login.setCaption(TEXTFIELD_CAPTION_LOGIN); //TODO i18n

    password.setId(ID_PASSWORDFIELD_PASSWORD);
    password.setCaption(PASSWORDFIELD_CAPTION_PASSWORD); //TODO i18n

    ok.setCaption(BUTTON_CAPTION_OK);
    ok.setId(ID_BUTTON_OK);
    ok.addClickListener((Button.ClickListener) event -> {
      final String loginValue = login.getValue();
      final String passwordValue = password.getValue();
      clearInputFields();
      UI current = UI.getCurrent();
      if (loginService.check(loginValue, passwordValue)) {
//        VaadinService.reinitializeSession(VaadinService.getCurrentRequest());
        current.getSession()
               .setAttribute(SESSION_ATTRIBUTE_USER, userService.loadUser(loginValue));
        current.setContent(mainViewSupplier.get());
      }
      else {
        current.setContent(this);
        current.getSession()
               .setAttribute(SESSION_ATTRIBUTE_USER, null);
      }
    });

    cancel.setId(ID_BUTTON_CANCEL);
    cancel.setCaption(BUTTON_CAPTION_CANCEL);
    cancel.addClickListener((Button.ClickListener) event -> clearInputFields());
  }
 
Example 22
Project: vaadin-016-helloworld-14   File: TestbenchFunctions.java   Source Code and License 5 votes vote down vote up
static Function<Class<? extends AbstractComponent>, Optional<Class<? extends AbstractElement>>> conv() {
  return (componentClass) -> {
    final Predicate<Class<? extends AbstractComponent>> is = componentClass::isAssignableFrom;

    if (is.test(Button.class)) return Optional.of(ButtonElement.class);
    if (is.test(TextField.class)) return Optional.of(TextFieldElement.class);

    return Optional.empty();
  };
}
 
Example 23
Project: osc-core   File: MainUI.java   Source Code and License 5 votes vote down vote up
private Button buildLogout() {
    Button exit = new Button("Logout");
    exit.setDescription("Logout");
    exit.setWidth("100%");
    exit.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            getSession().setAttribute("user", null);
            for (UI ui : getSession().getUIs()) {
                ui.close();
            }
        }
    });
    return exit;
}
 
Example 24
Project: osc-core   File: CRUDBaseView.java   Source Code and License 5 votes vote down vote up
@SuppressWarnings("serial")
private HorizontalLayout createHeader(String title, final boolean isChildTable) {

    HorizontalLayout header = null;
    if (isChildTable) {
        header = ViewUtil.createSubHeader(title, getChildHelpGuid());
    } else {
        header = ViewUtil.createSubHeader(title, getParentHelpGuid());
    }

    Button refresh = new Button();
    refresh.setStyleName(Reindeer.BUTTON_LINK);
    refresh.setDescription("Refresh");
    refresh.setIcon(new ThemeResource("img/Refresh.png"));
    refresh.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (isChildTable) {
                populateChildTable(getParentItem());
            } else {
                populateParentTable();
            }
        }
    });
    header.addComponent(refresh);
    return header;
}
 
Example 25
Project: material-theme-fw8   File: ButtonsView.java   Source Code and License 5 votes vote down vote up
private Component createFlatButtons() {
    Button light = new FlatButton("Flat Light");
    Button lightDisabled = new FlatButton("Flat Light Disabled");
    lightDisabled.setEnabled(false);

    FlexLayout l1 = new FlexLayout(FlexDirection.COLUMN, light, lightDisabled);
    l1.setWidth(320, Unit.PIXELS);
    l1.setAlignItems(AlignItems.CENTER);
    l1.addStyleName(Paddings.All.LARGE);
    l1.addStyleName(Spacings.Bottom.MEDIUM);
    l1.addStyleName(MaterialColor.GREY_50.getBackgroundColorStyle());
    l1.addStyleName("card");

    Button dark = new FlatButton("Flat Dark", false);
    Button darkDisabled = new FlatButton("Flat Dark Disabled", false);
    darkDisabled.setEnabled(false);

    FlexLayout l2 = new FlexLayout(FlexDirection.COLUMN, dark, darkDisabled);
    l2.setWidth(320, Unit.PIXELS);
    l2.setAlignItems(AlignItems.CENTER);
    l2.addStyleName(Paddings.All.LARGE);
    l2.addStyleName(Spacings.Bottom.MEDIUM);
    l2.addStyleName(MaterialColor.GREY_800.getBackgroundColorStyle());
    l2.addStyleName("card");

    FlexLayout row = new FlexLayout(l1, l2);
    row.setAlignItems(AlignItems.BASELINE);
    row.setFlexWrap(FlexWrap.WRAP);
    row.setJustifyContent(JustifyContent.SPACE_BETWEEN);
    row.addStyleName(Spacings.Bottom.LARGE);

    return row;
}
 
Example 26
Project: osc-core   File: ArchiveLayout.java   Source Code and License 5 votes vote down vote up
public ArchiveLayout(ArchiveServiceApi archiveService, GetJobsArchiveServiceApi getJobsArchiveService,
        UpdateJobsArchiveServiceApi updateJobsArchiveService) {
    super();

    VerticalLayout downloadContainer = new VerticalLayout();
    VerticalLayout archiveContainer = new VerticalLayout();

    // Component to Archive Jobs
    JobsArchiverPanel archiveConfigurator = new JobsArchiverPanel(this, archiveService,
            getJobsArchiveService, updateJobsArchiveService);
    archiveConfigurator.setSizeFull();

    archiveContainer.addComponent(ViewUtil.createSubHeader("Archive Jobs/Alerts", null));
    archiveContainer.addComponent(archiveConfigurator);

    downloadContainer.addComponent(ViewUtil.createSubHeader("Download Archive", null));
    // Component to download archive

    this.archiveTable = new Table();
    this.archiveTable.setSizeFull();
    this.archiveTable.setPageLength(5);
    this.archiveTable.setImmediate(true);
    this.archiveTable.addContainerProperty("Name", String.class, null);
    this.archiveTable.addContainerProperty("Date", Date.class, null);
    this.archiveTable.addContainerProperty("Size", Long.class, null);
    this.archiveTable.addContainerProperty("Download", Link.class, null);
    this.archiveTable.addContainerProperty("Delete", Button.class, null);
    buildArchivesTable();

    Panel archiveTablePanel = new Panel();
    archiveTablePanel.setContent(this.archiveTable);

    addComponent(archiveContainer);
    addComponent(archiveTablePanel);
}
 
Example 27
Project: Persephone   File: LogsPage.java   Source Code and License 5 votes vote down vote up
private void updateAutoScrollButtonCaption(Button btn) {
	if(((PersephoneUI)getUI()).getUserData().isTailAutoScrollEnabled()) {
		btn.setCaption("Disable auto scroll");
	} else {
		btn.setCaption("Enable auto scroll");
	}
}
 
Example 28
Project: osc-core   File: InternalCertReplacementUploader.java   Source Code and License 5 votes vote down vote up
@SuppressWarnings("serial")
private void setupCancelClickedListener(final VmidcWindow<OkCancelButtonModel> alertWindow) {
    alertWindow.getComponentModel().setCancelClickedListener(new Button.ClickListener(){
        @Override
        public void buttonClick(ClickEvent event) {
            removeUploadedFile();
            alertWindow.close();
            ViewUtil.iscNotification(getString(KEYPAIR_NOT_REPLACED), Notification.Type.WARNING_MESSAGE);
        }});
}
 
Example 29
Project: vaadin-016-helloworld-14   File: MenuComponent.java   Source Code and License 5 votes vote down vote up
private Pair<String, Button> createMenuButtonForNotification(VaadinIcons icon, String caption, String message) {
  final Button button
      = new Button(caption,
                   (e) -> {
                     UI ui = UI.getCurrent();
                     ConfirmDialog.show(
                         ui,
                         message, // ToDo extract in Executor
                         (ConfirmDialog.Listener) dialog -> {
                           if (dialog.isConfirmed()) {

                             getSubject().logout(); //removes all identifying information and invalidates their session too.

                             VaadinSession vaadinSession = ui.getSession();
                             vaadinSession.setAttribute(SESSION_ATTRIBUTE_USER, null);
                             vaadinSession.close();
                             ui.getPage().setLocation("/");
                           }
                           else {
                             // User did not confirm
                             // CANCEL STUFF
                           }
                         });
                   });

  button.setIcon(icon);
  button.addStyleName(ValoTheme.BUTTON_HUGE);
  button.addStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP);
  button.addStyleName(ValoTheme.BUTTON_BORDERLESS);
  button.addStyleName(ValoTheme.MENU_ITEM);
  button.setWidth("100%");

  button.setId(buttonID().apply(MainView.class, caption));

  return new Pair<>(mapToShiroRole(caption), button);

}
 
Example 30
Project: bootstrap-formgroup   File: FormGroupTextFieldErrorMessageUI.java   Source Code and License 5 votes vote down vote up
@Override
public Component getTestComponent() {

    TextFieldGroup field = new TextFieldGroup();

    field.setCaption("Caption");
    field.setDescription("Description");

    Button action1 = new Button("Add ErrorMessage");
    action1.setId("action1");
    action1.addClickListener(event -> {
        field.getField().setComponentError(new ErrorMessage() {
            @Override
            public ErrorLevel getErrorLevel() {
                return ErrorLevel.ERROR;
            }

            @Override
            public String getFormattedHtmlMessage() {
                return "<strong>ERROR HERE</strong>";
            }
        });
    });

    Button action2 = new Button("Remove ErrorMessage");
    action2.setId("action2");
    action2.addClickListener(event -> {
        field.getField().setComponentError(null);
    });

    MyCustomLayout layout = new MyCustomLayout(FormGroupHtml.BASIC, action1, action2);
    layout.addComponent(field, "field");

    return layout;
}
 
Example 31
Project: osc-core   File: PluginsLayout.java   Source Code and License 5 votes vote down vote up
private Button getDownloadSdkButtonForSdnController() throws URISyntaxException, MalformedURLException {
    SdkUtil sdkUtil = new SdkUtil();
    Button downloadSdk = new Button(VmidcMessages.getString(VmidcMessages_.MAINTENANCE_SDNPLUGIN_DOWNLOAD_SDK));
    URI currentLocation = UI.getCurrent().getPage().getLocation();
    URI downloadLocation = new URI(currentLocation.getScheme(), null, currentLocation.getHost(),
            currentLocation.getPort(), sdkUtil.getSdk(SdkUtil.sdkType.SDN_CONTROLLER), null, null);
    FileDownloader downloader = new FileDownloader(new ExternalResource(downloadLocation.toURL().toString()));
    downloader.extend(downloadSdk);
    return downloadSdk;
}
 
Example 32
Project: osc-core   File: PluginsLayout.java   Source Code and License 5 votes vote down vote up
private Button getDownloadSdkButtonForManager() throws URISyntaxException, MalformedURLException {
    SdkUtil sdkUtil = new SdkUtil();
    Button downloadSdk = new Button(VmidcMessages.getString(VmidcMessages_.MAINTENANCE_MANAGERPLUGIN_DOWNLOAD_SDK));
    URI currentLocation = UI.getCurrent().getPage().getLocation();
    URI downloadLocation = new URI(currentLocation.getScheme(), null, currentLocation.getHost(),
            currentLocation.getPort(), sdkUtil.getSdk(SdkUtil.sdkType.MANAGER), null, null);
    FileDownloader downloader = new FileDownloader(new ExternalResource(downloadLocation.toURL().toString()));
    downloader.extend(downloadSdk);
    return downloadSdk;
}
 
Example 33
Project: osc-core   File: ViewUtil.java   Source Code and License 5 votes vote down vote up
/**
 * @param caption
 *            Caption Text Representing Header
 * @param guid
 *            Help GUID for caller view
 * @return
 *         Horizontal Layout containing Caption text and Help button
 */
public static HorizontalLayout createSubHeader(String caption, String guid) {

    HorizontalLayout subHeader = new HorizontalLayout();
    subHeader.setWidth("100%");
    subHeader.setHeight("35px");
    subHeader.setSpacing(true);
    subHeader.addStyleName("toolbar");
    final Label title = new Label(caption);
    title.setSizeUndefined();
    subHeader.addComponent(title);
    subHeader.setComponentAlignment(title, Alignment.MIDDLE_LEFT);
    subHeader.setExpandRatio(title, 1);

    // create help button if we have some GUID else do not add this button
    if (guid != null) {

        Button helpButton = new Button();
        helpButton.setImmediate(true);
        helpButton.setStyleName(Reindeer.BUTTON_LINK);
        helpButton.setDescription("Help");
        helpButton.setIcon(new ThemeResource("img/Help.png"));
        subHeader.addComponent(helpButton);
        helpButton.addClickListener(new HelpButtonListener(guid));
    }

    return subHeader;
}
 
Example 34
Project: osc-core   File: ViewUtil.java   Source Code and License 5 votes vote down vote up
/**
 *
 * @param enabled
 *            either enable or disable given set of buttons
 * @param layout
 *            Layout these buttons belongs to
 * @param itemsToEnable
 *            List of Buttons which needs to be enabled/disabled
 */
public static void enableToolBarButtons(boolean enabled, HorizontalLayout layout, List<String> itemsToEnable) {
    if (layout != null) {
        Iterator<Component> iterate = layout.iterator();
        while (iterate.hasNext()) {
            Component c = iterate.next();
            if (c instanceof Button && itemsToEnable.contains(c.getId())) {
                c.setEnabled(enabled);
            }
        }
    }
}
 
Example 35
Project: osc-core   File: ViewUtil.java   Source Code and License 5 votes vote down vote up
/**
 *
 *
 *
 * @param layout
 *            Parent layout of the button
 * @param id
 *            String id of the button
 * @return
 *         Returns a Button Object from the ID provided
 */
public static Button getButtonById(HorizontalLayout layout, String id) {
    if (layout != null) {
        Iterator<Component> iterate = layout.iterator();
        while (iterate.hasNext()) {
            Component c = iterate.next();
            if (c instanceof Button && c.getId().equals(id)) {
                return (Button) c;
            }
        }
    }
    return null;
}
 
Example 36
Project: osc-core   File: OkCancelButtonModel.java   Source Code and License 5 votes vote down vote up
public OkCancelButtonModel() {
    //TODO: Future. have a constructor which will enable.disable parent window shortcut listener...
    this.cancelButton = new Button(VmidcMessages.getString(VmidcMessages_.WINDOW_COMMON_BUTTON_CANCEL));
    this.cancelButton.setClickShortcut(KeyCode.ESCAPE, null);

    this.okButton = new Button(VmidcMessages.getString(VmidcMessages_.WINDOW_COMMON_BUTTON_OK));
    this.okButton.setClickShortcut(KeyCode.ENTER, null);
}
 
Example 37
Project: tinypounder   File: TinyPounderMainUI.java   Source Code and License 5 votes vote down vote up
private void stopServer(String stripeName, String serverName, Button stopBT) {
  RunningServer runningServer = runningServers.get(stripeName + "-" + serverName);
  if (runningServer != null) {
    runningServer.stop();
    stopBT.setEnabled(false);
    runningServer.refreshConsole();
  }
}
 
Example 38
Project: tinypounder   File: TinyPounderMainUI.java   Source Code and License 5 votes vote down vote up
private void startServer(String stripeName, String serverName, Button startBT, Button stopBT, Label stateLBL, Label pidLBL) {
  File stripeconfig = tcConfigLocationPerStripe.get(stripeName);
  if (stripeconfig == null) {
    generateXML(false);
    stripeconfig = tcConfigLocationPerStripe.get(stripeName);
  }

  File workDir = new File(settings.getKitPath());
  String key = stripeName + "-" + serverName;
  TextArea console = getConsole(key);

  RunningServer runningServer = new RunningServer(
      workDir, stripeconfig, serverName, console, 500,
      () -> {
        runningServers.remove(key);
        access(() -> {
          stopBT.setEnabled(false);
          startBT.setEnabled(true);
          pidLBL.setValue("");
          stateLBL.setValue("STOPPED");
        });
      },
      newState -> access(() -> stateLBL.setValue("STATE: " + newState)),
      newPID -> access(() -> pidLBL.setValue("PID: " + newPID))
  );

  if (runningServers.put(key, runningServer) != null) {
    Notification.show("ERROR", "Server is running: " + serverName, Notification.Type.ERROR_MESSAGE);
    return;
  }

  consoles.setSelectedTab(console);
  stateLBL.setValue("STARTING");
  runningServer.start();
  startBT.setEnabled(false);
  stopBT.setEnabled(true);
  runningServer.refreshConsole();
}
 
Example 39
Project: md-stepper   File: VerticalStepper.java   Source Code and License 5 votes vote down vote up
public void setActive(boolean active) {
  this.active = active;

  buttonBar.setVisible(active);
  contentContainer.setVisible(active);

  buttonBar.removeAllComponents();
  contentContainer.setContent(null);

  divider.setHeight(isLastStep(step) ? 0 : -1, Unit.PIXELS);

  if (!active) {
    return;
  }

  if (!isLastStep(step)) {
    divider.setHeight(100, Unit.PERCENTAGE);
  }
  contentContainer.setContent(step.getContent());

  Button nextButton = step.getNextButton();
  Button skipButton = step.getSkipButton();
  Button cancelButton = step.getCancelButton();
  Button backButton = step.getBackButton();

  buttonBar.addComponent(nextButton);
  buttonBar.addComponent(skipButton);
  buttonBar.addComponent(cancelButton);
  Spacer.addToLayout(buttonBar);
  buttonBar.addComponent(backButton);

  nextButton.setVisible(!isComplete());
  cancelButton.setVisible(step.isCancellable());
  skipButton.setVisible(step.isOptional());
  backButton.setVisible(getStepIterator().hasPrevious());
}
 
Example 40
Project: material-theme-fw8   File: ToggleButtonGroup.java   Source Code and License 5 votes vote down vote up
public Button addToggleButton(Resource icon) {
    Button button = new Button(icon);
    button.setPrimaryStyleName(Styles.Buttons.Toggle.BUTTON);
    button.addClickListener(event -> selectToggleButton(button));
    buttons.add(button);
    addComponent(button);
    return button;
}