Here are the examples of the java api com.vaadin.ui.Button.addClickListener() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
31 Examples
19
Source : BindSecurityGroupWindow.java
with Apache License 2.0
from opensecuritycontroller
with Apache License 2.0
from opensecuritycontroller
@SuppressWarnings("serial")
private Component getServicePanel() throws ActionNotSupportedException {
try {
this.serviceTable = new Table();
this.serviceTable.setCaption("Services:");
this.serviceTable.setPageLength(5);
this.serviceTable.setImmediate(true);
this.serviceTable.setSelectable(true);
this.serviceTable.setMultiSelect(false);
this.serviceTable.setNullSelectionAllowed(false);
this.serviceTable.setNullSelectionItemId(CRUDBaseView.NULL_SELECTION_ITEM_ID);
this.serviceTable.addGeneratedColumn(PROPERTY_ID_ENABLED, new CheckBoxGenerator());
populateServiceTable();
VerticalLayout selectorButtonLayout = new VerticalLayout();
selectorButtonLayout.addStyleName(StyleConstants.SELECTOR_BUTTON_LAYOUT);
Button moveUpButton = new Button(VmidcMessages.getString(VmidcMessages_.ORDER_MOVE_UP_TEXT));
moveUpButton.setHtmlContentAllowed(true);
moveUpButton.setDescription(VmidcMessages.getString(VmidcMessages_.ORDER_MOVE_UP_DESC));
moveUpButton.addStyleName(StyleConstants.SELECTOR_BUTTON);
moveUpButton.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
moveItem(true);
}
});
Button moveDownButton = new Button(VmidcMessages.getString(VmidcMessages_.ORDER_MOVE_DOWN_TEXT));
moveDownButton.setHtmlContentAllowed(true);
moveDownButton.setDescription(VmidcMessages.getString(VmidcMessages_.ORDER_MOVE_DOWN_DESC));
moveDownButton.addStyleName(StyleConstants.SELECTOR_BUTTON);
moveDownButton.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
moveItem(false);
}
});
selectorButtonLayout.addComponent(moveUpButton);
selectorButtonLayout.addComponent(moveDownButton);
HorizontalLayout selectorLayout = new HorizontalLayout();
selectorLayout.addComponent(selectorButtonLayout);
selectorLayout.addComponent(this.serviceTable);
return selectorLayout;
} catch (ActionNotSupportedException actionNotSupportedException) {
throw actionNotSupportedException;
} catch (Exception e) {
ViewUtil.iscNotification(e.getMessage(), Notification.Type.ERROR_MESSAGE);
log.error("Error while creating Services panel", e);
}
return null;
}
19
Source : ViewUtil.java
with Apache License 2.0
from opensecuritycontroller
with Apache License 2.0
from opensecuritycontroller
/**
* @param toolbar
* HorizontalLayout which contains all the action Buttons
* @param toolbarButton
* Which Tool bar button to create (Provided using ENUM constant)
* @param listner
* Click listener called when this button is clicked
* @return
*/
public static Button buildToolbarButton(HorizontalLayout toolbar, ToolbarButtons toolbarButton, ClickListener listner) {
Button button = new Button(toolbarButton.getText());
button.addStyleName(StyleConstants.BUTTON_TOOLBAR);
button.setDescription(toolbarButton.getTooltip());
button.setStyleName(ValoTheme.BUTTON_LINK);
if (StringUtils.isNotEmpty(toolbarButton.getImageLocation())) {
button.setIcon(new ThemeResource(toolbarButton.getImageLocation()), toolbarButton.toString());
}
button.setEnabled(false);
button.setId(toolbarButton.getId());
button.addClickListener(listner);
toolbar.addComponent(button);
return button;
}
19
Source : MainUI.java
with Apache License 2.0
from opensecuritycontroller
with Apache License 2.0
from opensecuritycontroller
private void buildHeader() {
this.header.addStyleName("branding");
this.header.addStyleName("header");
// product name and information
Label product = new Label(this.server.getProductName() + "<br> <span clreplaced='product-version'> Version: " + this.server.getVersionStr() + "</span>", ContentMode.HTML);
product.addStyleName("product-label");
product.setSizeUndefined();
HorizontalLayout brandingLayout = new HorizontalLayout();
brandingLayout.addStyleName("header-content");
brandingLayout.addComponent(new Image(null, new ThemeResource("img/logo.png")));
brandingLayout.addComponent(product);
// creating home help button
Button mainHelpButton = new Button();
mainHelpButton.setImmediate(true);
mainHelpButton.setStyleName(Reindeer.BUTTON_LINK);
mainHelpButton.setDescription("Help");
mainHelpButton.setIcon(new ThemeResource("img/headerHelp.png"));
mainHelpButton.addClickListener(new ClickListener() {
private String guid = "";
@Override
public void buttonClick(ClickEvent event) {
ViewUtil.showHelpBrowserWindow(this.guid);
}
});
HorizontalLayout helpLayout = new HorizontalLayout();
helpLayout.addComponent(mainHelpButton);
helpLayout.addStyleName("homeHelpButton");
// Adding current user to header
Label user = new Label("User: " + getCurrent().getSession().getAttribute("user").toString());
// header banner
HorizontalLayout userlayout = new HorizontalLayout();
userlayout.addStyleName("user");
userlayout.addComponent(user);
// create Logout button next to user
userlayout.addComponent(buildLogout());
// Adding help button to the user layout next to logout button
userlayout.addComponent(helpLayout);
this.header.setWidth("100%");
this.header.setHeight("65px");
this.header.addComponent(brandingLayout);
this.header.addComponent(userlayout);
this.header.setExpandRatio(brandingLayout, 1);
this.root.addComponent(this.header);
}
19
Source : SslConfigurationLayout.java
with Apache License 2.0
from opensecuritycontroller
with Apache License 2.0
from opensecuritycontroller
private Button createDeleteEntry(CertificateBasicInfoModel certificateModel) {
String removeBtnLabel = (certificateModel.isConnected()) ? "Force delete" : "Delete";
final Button deleteArchiveButton = new Button(removeBtnLabel);
deleteArchiveButton.setData(certificateModel);
deleteArchiveButton.addClickListener(this.removeButtonListener);
if (certificateModel.getAlias().contains(getString(KEYPAIR_INTERNAL_DISPLAY_ALIAS))) {
deleteArchiveButton.setEnabled(false);
}
return deleteArchiveButton;
}
19
Source : JobView.java
with Apache License 2.0
from opensecuritycontroller
with Apache License 2.0
from opensecuritycontroller
@SuppressWarnings("serial")
private void buildGraph() {
try {
this.embeddedImage = new Embedded();
this.embeddedImage.setSizeFull();
refreshGraph();
Button refresh = new Button("Refresh");
refresh.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
try {
refreshGraph();
} catch (Exception e) {
ViewUtil.showError("Error while building task graph DOT file.", e);
}
}
});
final HorizontalLayout toolbarLayout = new HorizontalLayout();
toolbarLayout.addComponent(refresh);
toolbarLayout.setSizeFull();
toolbarLayout.setMargin(true);
final VerticalLayout imageLayout = new VerticalLayout();
imageLayout.addComponent(this.embeddedImage);
imageLayout.setComponentAlignment(this.embeddedImage, Alignment.MIDDLE_CENTER);
imageLayout.setSizeUndefined();
final VerticalLayout layout = new VerticalLayout();
layout.addComponent(refresh);
layout.setComponentAlignment(refresh, Alignment.TOP_LEFT);
layout.addComponent(imageLayout);
layout.setSizeUndefined();
final Window window = new Window();
window.setContent(layout);
window.setModal(true);
window.setHeight("80%");
window.setWidth("80%");
window.setClosable(true);
window.setResizable(true);
window.setCaption("Task Graph for Job " + getParenreplacedemId());
window.center();
window.setWindowMode(WindowMode.MAXIMIZED);
window.addCloseShortcut(ShortcutAction.KeyCode.ESCAPE, null);
ViewUtil.addWindow(window);
window.focus();
} catch (Exception e) {
ViewUtil.showError("Error while building task graph DOT file.", e);
}
}
19
Source : CRUDBaseView.java
with Apache License 2.0
from opensecuritycontroller
with Apache License 2.0
from opensecuritycontroller
// returns Header layout with view replacedle
@SuppressWarnings("serial")
private HorizontalLayout createHeader(String replacedle, final boolean isChildTable) {
HorizontalLayout header = null;
if (isChildTable) {
header = ViewUtil.createSubHeader(replacedle, getChildHelpGuid());
} else {
header = ViewUtil.createSubHeader(replacedle, 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(getParenreplacedem());
} else {
populateParentTable();
}
}
});
header.addComponent(refresh);
return header;
}
19
Source : AbstractForm.java
with Apache License 2.0
from ijazfx
with Apache License 2.0
from ijazfx
public void setDeleteButton(final Button deleteButton) {
this.deleteButton = deleteButton;
deleteButton.addClickListener(new Button.ClickListener() {
private static final long serialVersionUID = -2693734056915561664L;
@Override
public void buttonClick(Button.ClickEvent event) {
delete(event);
}
});
}
19
Source : AbstractForm.java
with Apache License 2.0
from ijazfx
with Apache License 2.0
from ijazfx
public void setSaveButton(Button saveButton) {
this.saveButton = saveButton;
saveButton.addClickListener(new Button.ClickListener() {
private static final long serialVersionUID = -2058398434893034442L;
@Override
public void buttonClick(Button.ClickEvent event) {
save(event);
}
});
}
19
Source : SubSetSelector.java
with Apache License 2.0
from ijazfx
with Apache License 2.0
from ijazfx
/**
* Sets a form which can be used to add new items to the selection. A button
* to add new instances is displayed if this method is called.
*
* @param newInstanceForm the form
*/
public void setNewInstanceForm(AbstractForm<ET> newInstanceForm) {
this.newInstanceForm = newInstanceForm;
if (newInstanceForm != null) {
if (newInstanceBtn == null) {
newInstanceBtn = new MButton(FontAwesome.PLUS).withStyleName(ValoTheme.BUTTON_ICON_ONLY);
newInstanceBtn.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent clickEvent) {
addEnreplacedy(null);
}
});
toprow.add(newInstanceBtn);
}
} else if (newInstanceBtn != null) {
toprow.removeComponent(newInstanceBtn);
newInstanceBtn = null;
}
}
19
Source : TRAbstractBaseForm.java
with Apache License 2.0
from ijazfx
with Apache License 2.0
from ijazfx
public void setSaveButton(Button saveButton) {
this.saveButton = saveButton;
saveButton.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
try {
saveButton.setEnabled(false);
busyIndicator.setVisible(true);
UI.getCurrent().push();
save(event);
} finally {
saveButton.setEnabled(true);
busyIndicator.setVisible(false);
UI.getCurrent().push();
}
}
});
}
19
Source : TRAbstractBaseForm.java
with Apache License 2.0
from ijazfx
with Apache License 2.0
from ijazfx
public void setDeleteButton(final Button deleteButton) {
this.deleteButton = deleteButton;
deleteButton.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
delete(event);
}
});
}
19
Source : GxTermForm.java
with Apache License 2.0
from ijazfx
with Apache License 2.0
from ijazfx
@Override
public void setSaveButton(Button saveButton) {
this.saveButton = saveButton;
saveButton.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
try {
saveButton.setEnabled(false);
busyIndicator.setVisible(true);
saveGxTermEnreplacedies();
UI.getCurrent().push();
} finally {
saveButton.setEnabled(true);
busyIndicator.setVisible(false);
UI.getCurrent().push();
}
}
});
super.setSaveButton(saveButton);
}
18
Source : ViewUtil.java
with Apache License 2.0
from opensecuritycontroller
with Apache License 2.0
from opensecuritycontroller
/**
* @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 replacedle = new Label(caption);
replacedle.setSizeUndefined();
subHeader.addComponent(replacedle);
subHeader.setComponentAlignment(replacedle, Alignment.MIDDLE_LEFT);
subHeader.setExpandRatio(replacedle, 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;
}
18
Source : MainUI.java
with Apache License 2.0
from opensecuritycontroller
with Apache License 2.0
from opensecuritycontroller
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;
}
18
Source : PluginsLayout.java
with Apache License 2.0
from opensecuritycontroller
with Apache License 2.0
from opensecuritycontroller
@SuppressWarnings("unchecked")
private void updateItem(Item item, PluginApi plugin) {
item.gereplacedemProperty(PROP_PLUGIN_STATE).setValue(plugin.getState().toString());
item.gereplacedemProperty(PROP_PLUGIN_NAME).setValue(plugin.getSymbolicName());
item.gereplacedemProperty(PROP_PLUGIN_VERSION).setValue(plugin.getVersion());
item.gereplacedemProperty(PROP_PLUGIN_SERVICES).setValue(plugin.getServiceCount());
String info;
if (plugin.getState() == State.ERROR) {
info = plugin.getError();
} else {
info = "";
}
item.gereplacedemProperty(PROP_PLUGIN_INFO).setValue(info);
Button deleteButton = new Button("Delete");
deleteButton.addClickListener(event -> deletePlugin(plugin));
item.gereplacedemProperty(PROP_PLUGIN_DELETE).setValue(deleteButton);
}
18
Source : ArchiveLayout.java
with Apache License 2.0
from opensecuritycontroller
with Apache License 2.0
from opensecuritycontroller
@SuppressWarnings("serial")
private Button createDeleteArchive(File archiveFile) {
final Button deleteArchiveButton = new Button("Delete");
deleteArchiveButton.setData(archiveFile);
deleteArchiveButton.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
final File archiveFile = (File) deleteArchiveButton.getData();
final VmidcWindow<OkCancelButtonModel> deleteWindow = WindowUtil.createAlertWindow("Delete Archive File", "Delete Archive File - " + archiveFile);
deleteWindow.getComponentModel().setOkClickedListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
archiveFile.delete();
buildArchivesTable();
deleteWindow.close();
}
});
ViewUtil.addWindow(deleteWindow);
}
});
return deleteArchiveButton;
}
18
Source : SubSetSelector.java
with Apache License 2.0
from ijazfx
with Apache License 2.0
from ijazfx
/**
* Generates the tool cell content in the listing of selected items. By
* default contains button to remove selection. Overridden implementation
* can add other stuff there as well, like edit button.
*
* @param enreplacedy the enreplacedy for which the cell content is created
* @return the content (String or Component)
*/
protected Object getToolColumnContent(final ET enreplacedy) {
Button button = new Button(FontAwesome.MINUS);
button.setDescription("Removes the selection from the list");
button.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
button.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
removeSelectedOption(enreplacedy);
}
});
button.setStyleName(Reindeer.BUTTON_SMALL);
return button;
}
18
Source : DashboardEdit.java
with Apache License 2.0
from ijazfx
with Apache License 2.0
from ijazfx
private Component buildFooter() {
MHorizontalLayout footer = new MHorizontalLayout();
footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
footer.setWidth(100.0f, Unit.PERCENTAGE);
Button cancel = new Button("Cancel");
cancel.addClickListener(new ClickListener() {
@Override
public void buttonClick(final ClickEvent event) {
close();
}
});
cancel.setClickShortcut(KeyCode.ESCAPE, null);
Button save = new Button("Save");
save.addStyleName(ValoTheme.BUTTON_PRIMARY);
save.addClickListener(new ClickListener() {
@Override
public void buttonClick(final ClickEvent event) {
listener.dashboardNameEdited(nameField.getValue());
close();
}
});
save.setClickShortcut(KeyCode.ENTER, null);
footer.addComponents(cancel, save);
footer.setExpandRatio(cancel, 1);
footer.setComponentAlignment(cancel, Alignment.TOP_RIGHT);
return footer;
}
17
Source : DemoUI.java
with Apache License 2.0
from TatuLund
with Apache License 2.0
from TatuLund
@Override
protected void init(VaadinRequest vaadinRequest) {
final VerticalLayout layout = new VerticalLayout();
layout.setSizeFull();
MessageGrid messageGrid = new MessageGrid();
DemoFastGrid demoGrid = new DemoFastGrid(messageGrid);
Button clearButton = new Button("Clear");
clearButton.addClickListener(e -> {
messageGrid.clear();
});
Button addButton = new Button();
// Add Row
addButton.setIcon(VaadinIcons.PLUS_CIRCLE);
addButton.addClickListener(e -> {
demoGrid.addBlankRow();
});
addButton.setDescription("Add a new row");
Button rowValidationButton = new Button();
rowValidationButton.setIcon(VaadinIcons.CHECK_CIRCLE_O);
rowValidationButton.setStyleName(ValoTheme.BUTTON_QUIET);
rowValidationButton.addClickListener(e -> {
demoGrid.getNavigation().setRowValidation(!demoGrid.getNavigation().getRowValidation());
if (!demoGrid.getNavigation().getRowValidation())
rowValidationButton.setStyleName(ValoTheme.BUTTON_QUIET);
else
rowValidationButton.setStyleName(ValoTheme.BUTTON_FRIENDLY);
});
rowValidationButton.setDescription("Toggle rowValidation");
Button rowOpenClickButton = new Button();
rowOpenClickButton.setIcon(VaadinIcons.FOLDER_OPEN_O);
rowOpenClickButton.setStyleName(ValoTheme.BUTTON_FRIENDLY);
rowOpenClickButton.addClickListener(e -> {
demoGrid.getNavigation().setOpenEditorWithSingleClick(!demoGrid.getNavigation().getOpenEditorWithSingleClick());
if (!demoGrid.getNavigation().getOpenEditorWithSingleClick())
rowOpenClickButton.setStyleName(ValoTheme.BUTTON_QUIET);
else
rowOpenClickButton.setStyleName(ValoTheme.BUTTON_FRIENDLY);
});
rowOpenClickButton.setDescription("Toggle openEditorWithSingleClick");
Button rowOpenByTypingButton = new Button();
rowOpenByTypingButton.setIcon(VaadinIcons.KEYBOARD_O);
rowOpenByTypingButton.setStyleName(ValoTheme.BUTTON_FRIENDLY);
rowOpenByTypingButton.addClickListener(e -> {
demoGrid.getNavigation().setOpenEditorOnTyping(!demoGrid.getNavigation().getOpenEditorOnTyping());
if (!demoGrid.getNavigation().getOpenEditorOnTyping())
rowOpenByTypingButton.setStyleName(ValoTheme.BUTTON_QUIET);
else
rowOpenByTypingButton.setStyleName(ValoTheme.BUTTON_FRIENDLY);
});
rowOpenByTypingButton.setDescription("Toggle openEditorOnTyping");
Button openEditorButton = new Button();
openEditorButton.setIcon(VaadinIcons.INPUT);
openEditorButton.setDescription("Open editor at 1,3");
openEditorButton.setStyleName(ValoTheme.BUTTON_FRIENDLY);
openEditorButton.addClickListener(e -> {
demoGrid.openEditor();
});
Button disableGridEditButton = new Button();
disableGridEditButton.setIcon(VaadinIcons.PENCIL);
disableGridEditButton.setDescription("Toggle Grid Editing");
disableGridEditButton.setStyleName(ValoTheme.BUTTON_FRIENDLY);
disableGridEditButton.addClickListener(e -> {
if (demoGrid.getEditor().isEnabled()) {
if (demoGrid.getEditor().isOpen()) {
demoGrid.getEditor().cancel();
}
demoGrid.getEditor().setEnabled(false);
openEditorButton.setEnabled(false);
disableGridEditButton.setStyleName(ValoTheme.BUTTON_QUIET);
} else {
demoGrid.getEditor().setEnabled(true);
openEditorButton.setEnabled(true);
disableGridEditButton.setStyleName(ValoTheme.BUTTON_FRIENDLY);
}
});
Button moveSelectionButton = new Button();
moveSelectionButton.setIcon(VaadinIcons.BULLSEYE);
moveSelectionButton.setDescription("Toggle select follow");
moveSelectionButton.setStyleName(ValoTheme.BUTTON_QUIET);
moveSelectionButton.addClickListener(e -> {
if (demoGrid.moveSelection) {
demoGrid.moveSelection = false;
demoGrid.deselectAll();
demoGrid.setSelectionMode(SelectionMode.NONE);
moveSelectionButton.setStyleName(ValoTheme.BUTTON_QUIET);
} else {
demoGrid.moveSelection = true;
demoGrid.setSelectionMode(SelectionMode.SINGLE);
moveSelectionButton.setStyleName(ValoTheme.BUTTON_FRIENDLY);
}
});
Button resetFocusButton = new Button();
resetFocusButton.setIcon(VaadinIcons.CORNER_UPPER_LEFT);
resetFocusButton.setDescription("Reset focust to 0,1");
resetFocusButton.setStyleName(ValoTheme.BUTTON_FRIENDLY);
resetFocusButton.addClickListener(e -> {
demoGrid.resetFocus();
});
HorizontalLayout buttons = new HorizontalLayout();
buttons.addComponents(addButton, rowValidationButton, rowOpenClickButton, rowOpenByTypingButton, disableGridEditButton, moveSelectionButton, resetFocusButton, openEditorButton);
layout.setMargin(true);
layout.setSpacing(true);
layout.addComponent(demoGrid);
layout.addComponent(buttons);
layout.addComponent(messageGrid);
layout.addComponent(clearButton);
layout.setSizeFull();
layout.setExpandRatio(demoGrid, 10);
layout.setExpandRatio(buttons, 1);
layout.setExpandRatio(clearButton, 1);
layout.setExpandRatio(messageGrid, 6);
setContent(layout);
}
17
Source : ChatUI.java
with Apache License 2.0
from saturnism
with Apache License 2.0
from saturnism
@Override
protected void init(VaadinRequest vaadinRequest) {
final UI currentUI = getCurrent();
final StreamObserver<Chat.ChatMessage> observer = stub.chat(new StreamObserver<Chat.ChatMessageFromServer>() {
@Override
public void onNext(Chat.ChatMessageFromServer chatMessageFromServer) {
currentUI.access(() -> layout.addComponent(new Label(String.format("%s: %s", chatMessageFromServer.getMessage().getFrom(), chatMessageFromServer.getMessage().getMessage()))));
}
@Override
public void onError(Throwable throwable) {
logger.log(Level.SEVERE, "gRPC Error", throwable);
}
@Override
public void onCompleted() {
logger.info("gRPC Call Completed");
}
});
button.addClickListener(e -> {
final String nameValue = name.getValue();
final String messageValue = message.getValue();
observer.onNext(Chat.ChatMessage.newBuilder().setFrom(nameValue).setMessage(messageValue).build());
});
}
17
Source : PageInformationComponent.java
with Apache License 2.0
from opensecuritycontroller
with Apache License 2.0
from opensecuritycontroller
private Component buildMainLayout() {
// top-level component properties
setWidth("100.0%");
setHeight("-1px");
setStyleName(StyleConstants.PAGE_INFO_COMPONENT_COMMON);
// infoLabel
this.replacedleLabel = new Label();
initializeLabel(this.replacedleLabel);
final Button collapseButton = new Button();
collapseButton.setStyleName(Reindeer.BUTTON_LINK);
collapseButton.setIcon(new ThemeResource(StyleConstants.EXPAND_IMAGE));
collapseButton.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
PageInformationComponent.this.contentLabel.setVisible(!PageInformationComponent.this.contentLabel.isVisible());
if (PageInformationComponent.this.contentLabel.isVisible()) {
collapseButton.setIcon(new ThemeResource(StyleConstants.COLLAPSE_IMAGE));
} else {
collapseButton.setIcon(new ThemeResource(StyleConstants.EXPAND_IMAGE));
}
}
});
HorizontalLayout replacedleLayout = new HorizontalLayout();
initializeLayout(replacedleLayout);
replacedleLayout.setStyleName(StyleConstants.PAGE_INFO_replacedLE_LAYOUT);
replacedleLayout.addComponent(this.replacedleLabel);
replacedleLayout.addComponent(collapseButton);
replacedleLayout.setExpandRatio(this.replacedleLabel, 1.0f);
this.contentLabel = new Label();
initializeLabel(this.contentLabel);
this.contentLabel.setVisible(false);
this.contentLabel.setStyleName(StyleConstants.PAGE_INFO_CONTENT_LABEL);
this.contentLabel.setContentMode(ContentMode.HTML);
VerticalLayout mainLayout = new VerticalLayout();
initializeLayout(mainLayout);
mainLayout.addComponent(replacedleLayout);
mainLayout.addComponent(this.contentLabel);
return mainLayout;
}
17
Source : SslConfigurationLayout.java
with Apache License 2.0
from opensecuritycontroller
with Apache License 2.0
from opensecuritycontroller
private HorizontalLayout createHeaderForSslList() {
HorizontalLayout header = ViewUtil.createSubHeader("List of available certificates", null);
Button refresh = new Button();
refresh.setStyleName(Reindeer.BUTTON_LINK);
refresh.setDescription("Refresh");
refresh.setIcon(new ThemeResource("img/Refresh.png"));
refresh.addClickListener((Button.ClickListener) event -> buildSslConfigurationTable());
header.addComponent(refresh);
return header;
}
17
Source : CRUDBaseSubView.java
with Apache License 2.0
from opensecuritycontroller
with Apache License 2.0
from opensecuritycontroller
// returns Header layout with view replacedle
@SuppressWarnings("serial")
private HorizontalLayout createHeader(String replacedle) {
HorizontalLayout header = ViewUtil.createSubHeader(replacedle, getSubViewHelpGuid());
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) {
populateTable();
}
});
header.addComponent(refresh);
return header;
}
17
Source : InlineTextEditor.java
with Apache License 2.0
from ijazfx
with Apache License 2.0
from ijazfx
private Component buildEditor() {
final RichTextArea rta = new RichTextArea(property);
rta.setWidth(100.0f, Unit.PERCENTAGE);
rta.addAttachListener(new AttachListener() {
@Override
public void attach(final AttachEvent event) {
rta.focus();
rta.selectAll();
}
});
Button save = new Button("Save");
save.setDescription("Edit");
save.addStyleName(ValoTheme.BUTTON_PRIMARY);
save.addStyleName(ValoTheme.BUTTON_SMALL);
save.addClickListener(new ClickListener() {
@Override
public void buttonClick(final ClickEvent event) {
setCompositionRoot(readOnly);
}
});
CssLayout result = new CssLayout(rta, save);
result.addStyleName("edit");
result.setSizeFull();
return result;
}
16
Source : MainUI.java
with Apache License 2.0
from opensecuritycontroller
with Apache License 2.0
from opensecuritycontroller
private void buildLoginForm() {
addStyleName("login");
this.loginLayout = new VerticalLayout();
this.loginLayout.setSizeFull();
this.loginLayout.addStyleName("login-layout");
this.root.addComponent(this.loginLayout);
final CssLayout loginPanel = new CssLayout();
loginPanel.addStyleName("login-panel");
HorizontalLayout labels = new HorizontalLayout();
labels.setWidth("100%");
labels.setMargin(true);
labels.addStyleName("labels");
loginPanel.addComponent(labels);
Label product = new Label(this.server.getProductName());
product.addStyleName("product-label-login");
labels.addComponent(new Image(null, new ThemeResource("img/logo.png")));
labels.addComponent(product);
labels.setComponentAlignment(product, Alignment.MIDDLE_LEFT);
labels.setExpandRatio(product, 1);
HorizontalLayout fields = new HorizontalLayout();
fields.setSpacing(true);
fields.setMargin(true);
fields.addStyleName("fields");
final TextField username = new TextField("Login ID");
username.focus();
username.setImmediate(true);
username.setRequired(true);
username.setRequiredError("Login ID or Preplacedword cannot be empty");
fields.addComponent(username);
final PreplacedwordField preplacedword = new PreplacedwordField("Preplacedword");
preplacedword.setRequired(true);
preplacedword.setImmediate(true);
preplacedword.setRequiredError("Login ID or Preplacedword cannot be empty");
fields.addComponent(preplacedword);
final Button login = new Button("Log In");
login.addStyleName("default");
fields.addComponent(login);
fields.setComponentAlignment(login, Alignment.BOTTOM_LEFT);
final ShortcutListener enter = new ShortcutListener("Login", KeyCode.ENTER, null) {
@Override
public void handleAction(Object sender, Object target) {
login.click();
}
};
login.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
try {
username.validate();
preplacedword.validate();
LoginRequest request = new LoginRequest();
request.setLoginName(username.getValue().trim());
request.setPreplacedword(preplacedword.getValue());
LoginResponse response = MainUI.this.loginService.dispatch(request);
if (response != null) {
login.removeShortcutListener(enter);
if (getSession() != null) {
getSession().setAttribute("user", username.getValue());
}
MainUI.this.root.removeComponent(MainUI.this.loginLayout);
buildMainView();
}
} catch (EmptyValueException e) {
ViewUtil.iscNotification(e.getMessage() + ".", Notification.Type.ERROR_MESSAGE);
username.focus();
} catch (Exception e) {
username.focus();
ViewUtil.iscNotification(e.getMessage(), Notification.Type.ERROR_MESSAGE);
}
}
});
login.addShortcutListener(enter);
loginPanel.addComponent(fields);
this.loginLayout.addComponent(loginPanel);
this.loginLayout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER);
}
16
Source : InlineTextEditor.java
with Apache License 2.0
from ijazfx
with Apache License 2.0
from ijazfx
private Component buildReadOnly() {
final Label text = new Label(property);
text.setContentMode(ContentMode.HTML);
Button editButton = new Button(FontAwesome.EDIT);
editButton.addStyleName(ValoTheme.BUTTON_SMALL);
editButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
editButton.addClickListener(new ClickListener() {
@Override
public void buttonClick(final ClickEvent event) {
setCompositionRoot(editor);
}
});
CssLayout result = new CssLayout(text, editButton);
result.addStyleName("text-editor");
result.setSizeFull();
result.addLayoutClickListener(new LayoutClickListener() {
@Override
public void layoutClick(final LayoutClickEvent event) {
if (event.getChildComponent() == text && event.isDoubleClick()) {
setCompositionRoot(editor);
}
}
});
return result;
}
16
Source : GiftcardUI.java
with Apache License 2.0
from AxonIQ
with Apache License 2.0
from AxonIQ
private Panel bulkIssuePanel() {
TextField number = new TextField("Number");
TextField amount = new TextField("Amount");
Button submit = new Button("Submit");
Panel panel = new Panel("Bulk issue cards");
submit.addClickListener(evt -> {
submit.setEnabled(false);
new BulkIssuer(commandGateway, Integer.parseInt(number.getValue()), Integer.parseInt(amount.getValue()), bulkIssuer -> {
access(() -> {
if (bulkIssuer.getRemaining().get() == 0) {
submit.setEnabled(true);
panel.setCaption("Bulk issue cards");
Notification.show("Bulk issue card completed", Notification.Type.HUMANIZED_MESSAGE).addCloseListener(e -> cardSummaryDataProvider.refreshAll());
} else {
panel.setCaption(String.format("Progress: %d suc, %d fail, %d rem", bulkIssuer.getSuccess().get(), bulkIssuer.getError().get(), bulkIssuer.getRemaining().get()));
cardSummaryDataProvider.refreshAll();
}
});
});
});
FormLayout form = new FormLayout();
form.addComponents(number, amount, submit);
form.setMargin(true);
panel.setContent(form);
return panel;
}
16
Source : GiftcardUI.java
with Apache License 2.0
from AxonIQ
with Apache License 2.0
from AxonIQ
private Panel redeemPanel() {
TextField id = new TextField("Card id");
TextField amount = new TextField("Amount");
Button submit = new Button("Submit");
submit.addClickListener(evt -> {
commandGateway.sendAndWait(new RedeemCmd(id.getValue(), Integer.parseInt(amount.getValue())));
Notification.show("Success", Notification.Type.HUMANIZED_MESSAGE).addCloseListener(e -> cardSummaryDataProvider.refreshAll());
});
FormLayout form = new FormLayout();
form.addComponents(id, amount, submit);
form.setMargin(true);
Panel panel = new Panel("Redeem card");
panel.setContent(form);
return panel;
}
16
Source : GiftcardUI.java
with Apache License 2.0
from AxonIQ
with Apache License 2.0
from AxonIQ
private Panel issuePanel() {
TextField id = new TextField("Card id");
TextField amount = new TextField("Amount");
Button submit = new Button("Submit");
submit.addClickListener(evt -> {
commandGateway.sendAndWait(new IssueCmd(id.getValue(), Integer.parseInt(amount.getValue())));
Notification.show("Success", Notification.Type.HUMANIZED_MESSAGE).addCloseListener(e -> cardSummaryDataProvider.refreshAll());
});
FormLayout form = new FormLayout();
form.addComponents(id, amount, submit);
form.setMargin(true);
Panel panel = new Panel("Issue single card");
panel.setContent(form);
return panel;
}
13
Source : BaseSecurityGroupWindow.java
with Apache License 2.0
from opensecuritycontroller
with Apache License 2.0
from opensecuritycontroller
@SuppressWarnings("serial")
private Component createSelectorTableLayout(final FilterTable table, final BeanContainer<String, SecurityGroupMemberItemDto> tableContainer) {
VerticalLayout layout = new VerticalLayout();
Button allButton = getTableItemsSelectionButton(VmidcMessages.getString(VmidcMessages_.SELECTOR_ALL));
allButton.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
table.setValue(tableContainer.gereplacedemIds());
}
});
Button noneButton = getTableItemsSelectionButton(VmidcMessages.getString(VmidcMessages_.SELECTOR_NONE));
noneButton.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
table.setValue(null);
}
});
Button invertButton = getTableItemsSelectionButton(VmidcMessages.getString(VmidcMessages_.SELECTOR_INVERT));
invertButton.addClickListener(new ClickListener() {
@SuppressWarnings("unchecked")
@Override
public void buttonClick(ClickEvent event) {
Set<String> itemIdsSelected = (Set<String>) table.getValue();
Collection<String> allItems = (Collection<String>) table.gereplacedemIds();
table.setValue(allItems.stream().filter(s -> !itemIdsSelected.contains(s)).collect(Collectors.toSet()));
}
});
HorizontalLayout buttonLayout = new HorizontalLayout(allButton, noneButton, invertButton);
layout.addComponent(table);
layout.addComponent(buttonLayout);
return layout;
}
10
Source : BaseSecurityGroupWindow.java
with Apache License 2.0
from opensecuritycontroller
with Apache License 2.0
from opensecuritycontroller
@SuppressWarnings("serial")
protected Component getSelectionWidget() {
this.selector = new VerticalLayout();
this.selector.addStyleName(StyleConstants.VMIDC_WINDOW_CONTENT_WRAPPER);
this.selector.setSizeFull();
this.itemsTable = createSelectorTable();
this.itemsTable.setCaption(VmidcMessages.getString(VmidcMessages_.SELECTOR_replacedLE));
this.itemsTable.setColumnWidth("name", ITEMS_NAME_COLUMN_WIDTH);
this.itemsContainer = createItemContainer();
this.itemsTable.setContainerDataSource(this.itemsContainer);
this.itemsTable.setVisibleColumns("name");
this.selectedItemsTable = createSelectorTable();
this.selectedItemsTable.setCaption(VmidcMessages.getString(VmidcMessages_.SELECTED_replacedLE));
this.selectedItemsTable.setWidth(SELECTED_TABLE_WIDTH + "px");
this.selectedItemsTable.setColumnWidth("name", SELECTED_ITEMS_NAME_COLUMN_WIDTH);
this.selectedItemsTable.setColumnWidth("region", SELECTED_ITEMS_REGION_COLUMN_WIDTH);
this.selectedItemsTable.setColumnWidth("type", SELECTED_ITEMS_TYPE_COLUMN_WIDTH);
this.selectedItemsContainer = createItemContainer();
this.selectedItemsTable.setContainerDataSource(this.selectedItemsContainer);
this.selectedItemsTable.setVisibleColumns("name", "region", "type", PROTECT_EXTERNAL);
this.selectedItemsTable.setColumnHeader(PROTECT_EXTERNAL, "Protect External");
VerticalLayout selectorButtonLayout = new VerticalLayout();
selectorButtonLayout.addStyleName(StyleConstants.SELECTOR_BUTTON_LAYOUT);
Button addButton = new Button(VmidcMessages.getString(VmidcMessages_.SELECTOR_TO_BUTTON));
addButton.addStyleName(StyleConstants.SELECTOR_BUTTON);
addButton.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
moveItems(BaseSecurityGroupWindow.this.itemsTable, BaseSecurityGroupWindow.this.selectedItemsTable);
}
});
Button removeButton = new Button(VmidcMessages.getString(VmidcMessages_.SELECTOR_FROM_BUTTON));
removeButton.addStyleName(StyleConstants.SELECTOR_BUTTON);
removeButton.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
moveItems(BaseSecurityGroupWindow.this.selectedItemsTable, BaseSecurityGroupWindow.this.itemsTable);
}
});
selectorButtonLayout.addComponent(addButton);
selectorButtonLayout.addComponent(removeButton);
HorizontalLayout selectorLayout = new HorizontalLayout();
selectorLayout.addComponent(createSelectorTableLayout(this.itemsTable, this.itemsContainer));
selectorLayout.addComponent(selectorButtonLayout);
selectorLayout.addComponent(createSelectorTableLayout(this.selectedItemsTable, this.selectedItemsContainer));
this.selector.addComponent(selectorLayout);
return this.selector;
}