Java Code Examples for com.vaadin.ui.Button

The following examples show how to use com.vaadin.ui.Button. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: viritin   Source File: ElementCollectionField.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void setPersisted(ET v, boolean persisted) {
    int row = itemsIdentityIndexOf(v) + 1;
    if (isAllowRemovingItems()) {
        Button c = (Button) layout.getComponent(layout.getColumns() - 1, row);
        if (persisted) {
            c.setDescription(getDeleteElementDescription());
        } else {
            for (int i = 0; i < getVisibleProperties().size(); i++) {
                try {
                    AbstractField f = (AbstractField) layout.
                            getComponent(i,
                                    row);
                    // FIXME
                    //f.setValidationVisible(false);
                } catch (Exception e) {

                }
            }
            c.setDescription(getDisabledDeleteElementDescription());
        }
        c.setEnabled(persisted);
    }
}
 
Example 2
Source Project: cuba   Source File: WebPopupButton.java    License: Apache License 2.0 6 votes vote down vote up
protected void actionPropertyChanged(PropertyChangeEvent evt) {
    Action action = (Action) evt.getSource();
    Button button = actionButtons.get(action);

    if (Action.PROP_ICON.equals(evt.getPropertyName())) {
        if (showActionIcons) {
            setPopupButtonIcon(button, action.getIcon());
        } else {
            setPopupButtonIcon(button, null);
        }
    } else if (Action.PROP_CAPTION.equals(evt.getPropertyName())) {
        button.setCaption(action.getCaption());
    } else if (Action.PROP_DESCRIPTION.equals(evt.getPropertyName())) {
        button.setDescription(action.getDescription());
    } else if (Action.PROP_ENABLED.equals(evt.getPropertyName())) {
        button.setEnabled(action.isEnabled());
    } else if (Action.PROP_VISIBLE.equals(evt.getPropertyName())) {
        button.setVisible(action.isVisible());
    }
}
 
Example 3
@Override
public ConfirmDialog create(String caption, String message, String okCaption, String cancelCaption, String notOkCaption) {
    ConfirmDialog d = super.create(caption, message, okCaption, cancelCaption, notOkCaption);

    d.getContent().setStyleName("custom-dialog");
    d.getContent().setHeightUndefined();
    d.setHeightUndefined();

    Button ok = d.getOkButton();
    ok.setStyleName(WebThemes.BUTTON_ACTION);

    HorizontalLayout buttons = (HorizontalLayout) ok.getParent();
    buttons.setHeightUndefined();

    Button cancelBtn = d.getCancelButton();
    cancelBtn.setStyleName(WebThemes.BUTTON_OPTION);
    cancelBtn.focus();

    return d;
}
 
Example 4
private void deleteButtonClick(Button.ClickEvent event) {
    final ComponentDto component = (ComponentDto) sender.servicePanel.serviceTable.getValue();

    // 確認ダイアログを表示
    String message = ViewMessages.getMessage("IUI-000018", component.getComponent().getComponentName());
    DialogConfirm dialog = new DialogConfirm(ViewProperties.getCaption("dialog.confirm"), message,
            Buttons.OKCancel);
    dialog.setCallback(new DialogConfirm.Callback() {
        @Override
        public void onDialogResult(Result result) {
            if (result != Result.OK) {
                return;
            }

            delete(component.getComponent().getComponentNo());
        }
    });

    getApplication().getMainWindow().addWindow(dialog);
}
 
Example 5
Source Project: viritin   Source File: MButtonClickListeners.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Component getTestComponent() {
    
    MButton b = new MButton("Say hola");
    
    // And the same without lambdas as the project is 1.6 compatible
    b.addClickListener(new MClickListener() {

        @Override
        public void onClick() {
            sayHola();
        }
    });
    b.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 5019806363620874205L;
        
        @Override
        public void buttonClick(ClickEvent event) {
            sayHolaOldSchool(event);
        }
    });
    
    return new MVerticalLayout(b);
}
 
Example 6
private Button createLoadBalancerButton(final LoadBalancerDto loadBalancer) {
    Button button = new Button();
    button.setCaption(loadBalancer.getLoadBalancer().getLoadBalancerName());
    button.setIcon(Icons.LOADBALANCER_TAB.resource());
    button.setData(loadBalancer);
    button.addStyleName("borderless");
    button.addStyleName("loadbalancer-button");
    button.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            // ロードバランサを選択
            sender.loadBalancerPanel.loadBalancerTable.select(loadBalancer);

            // ロードバランサタブに移動
            sender.tab.setSelectedTab(sender.loadBalancerPanel);
        }
    });
    return button;
}
 
Example 7
Source Project: chipster   Source File: JobLogTable.java    License: MIT License 6 votes vote down vote up
public Component generateCell(Table source, final Object itemId,
		Object columnId) {

	Button link = new Button("Output");
	link.setStyleName(BaseTheme.BUTTON_LINK);
	link.setDescription("Show job output");

	link.addClickListener(new Button.ClickListener() {

		public void buttonClick(ClickEvent event) {

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

	return link;
}
 
Example 8
Source Project: hawkbit   Source File: ArtifactDetailsLayout.java    License: Eclipse Public License 1.0 6 votes vote down vote up
private Button getArtifactDownloadButton(final Table table, final Object itemId) {
    final String fileName = (String) table.getContainerDataSource().getItem(itemId)
            .getItemProperty(PROVIDED_FILE_NAME).getValue();
    final Button downloadIcon = SPUIComponentProvider.getButton(
            fileName + "-" + UIComponentIdProvider.ARTIFACT_FILE_DOWNLOAD_ICON, "",
            i18n.getMessage(UIMessageIdProvider.TOOLTIP_ARTIFACT_DOWNLOAD), ValoTheme.BUTTON_TINY + " " + "blueicon", 
            true, FontAwesome.DOWNLOAD, SPUIButtonStyleNoBorder.class);
    downloadIcon.setData(itemId);
    FileDownloader fileDownloader = new FileDownloader(createStreamResource((Long) itemId));
    fileDownloader.extend(downloadIcon);
    fileDownloader.setErrorHandler(new ErrorHandler() {

        /**
         * Error handler for file downloader
         */
        private static final long serialVersionUID = 4030230501114422570L;

        @Override
        public void error(com.vaadin.server.ErrorEvent event) {
            uINotification.displayValidationError(i18n.getMessage(UIMessageIdProvider.ARTIFACT_DOWNLOAD_FAILURE_MSG));
        }
    });
    return downloadIcon;
}
 
Example 9
private void startMonitoringButtonClick(Button.ClickEvent event) {
    final InstanceDto instance = (InstanceDto) sender.serverPanel.serverTable.getValue();

    // 確認ダイアログを表示
    String message = ViewMessages.getMessage("IUI-000121", instance.getInstance().getInstanceName());
    DialogConfirm dialog = new DialogConfirm(ViewProperties.getCaption("dialog.confirm"), message,
            Buttons.OKCancel);
    dialog.setCallback(new DialogConfirm.Callback() {
        @Override
        public void onDialogResult(Result result) {
            if (result != Result.OK) {
                return;
            }

            startMonitoring(instance);
        }
    });

    getApplication().getMainWindow().addWindow(dialog);
}
 
Example 10
Source Project: hawkbit   Source File: DistributionTable.java    License: 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 11
@Override
protected void filterUnClicked(final Button clickedButton) {
    if (clickedButton.getData().equals(SPUIDefinitions.NO_TAG_BUTTON_ID)) {
        if (managementUIState.getTargetTableFilters().isNoTagSelected()) {
            managementUIState.getTargetTableFilters().setNoTagSelected(false);
            eventBus.publish(this, TargetFilterEvent.FILTER_BY_TAG);
        }
    } else {
        if (null != managementUIState.getTargetTableFilters().getClickedTargetTags() && managementUIState
                .getTargetTableFilters().getClickedTargetTags().contains(clickedButton.getId())) {
            managementUIState.getTargetTableFilters().getClickedTargetTags().remove(clickedButton.getId());
            eventBus.publish(this, TargetFilterEvent.FILTER_BY_TAG);
        }

    }
}
 
Example 12
Source Project: serverside-elements   Source File: GoogleMapDemo.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected Component getDemoView() {
    CssLayout wrapper = new CssLayout();
    Root root = ElementIntegration.getRoot(wrapper);

    final Element googleMap = Elements.create("google-map");

    googleMap.setAttribute("style",
            "height: 500px; width: 500px; display: block");
    googleMap.setAttribute("latitude", "60.45235");
    googleMap.setAttribute("longitude", "22.299727");
    googleMap.setAttribute("zoom", "17");

    root.appendChild(googleMap);

    HorizontalLayout buttons = new HorizontalLayout(
            new Button("GWT.create US", event -> {
                googleMap.setAttribute("latitude", "37.414274");
                googleMap.setAttribute("longitude", "-122.077409");
            }), new Button("GWT.create EU", event -> {
                googleMap.setAttribute("latitude", "48.152663");
                googleMap.setAttribute("longitude", "11.598418");
            }));
    buttons.setSpacing(true);

    VerticalLayout layout = new VerticalLayout(buttons, wrapper);
    layout.setSpacing(true);
    return layout;
}
 
Example 13
private HorizontalLayout createTwinColumnLayout() {
    final HorizontalLayout twinColumnLayout = new HorizontalLayout();
    twinColumnLayout.setSizeFull();
    twinColumnLayout.setWidth("400px");

    buildSourceTable();
    buildSelectedTable();

    final VerticalLayout selectButtonLayout = new VerticalLayout();
    final Button selectButton = SPUIComponentProvider.getButton(UIComponentIdProvider.SELECT_DIST_TYPE, "", "",
            "arrow-button", true, FontAwesome.FORWARD, SPUIButtonStyleNoBorder.class);
    selectButton.addClickListener(event -> addSMType());
    final Button unSelectButton = SPUIComponentProvider.getButton("unselect-dist-type", "", "", "arrow-button",
            true, FontAwesome.BACKWARD, SPUIButtonStyleNoBorder.class);
    unSelectButton.addClickListener(event -> removeSMType());
    selectButtonLayout.addComponent(selectButton);
    selectButtonLayout.addComponent(unSelectButton);
    selectButtonLayout.setComponentAlignment(selectButton, Alignment.MIDDLE_CENTER);
    selectButtonLayout.setComponentAlignment(unSelectButton, Alignment.MIDDLE_CENTER);

    twinColumnLayout.addComponent(sourceTable);
    twinColumnLayout.addComponent(selectButtonLayout);
    twinColumnLayout.addComponent(selectedTable);
    twinColumnLayout.setComponentAlignment(sourceTable, Alignment.MIDDLE_LEFT);
    twinColumnLayout.setComponentAlignment(selectButtonLayout, Alignment.MIDDLE_CENTER);
    twinColumnLayout.setComponentAlignment(selectedTable, Alignment.MIDDLE_RIGHT);
    twinColumnLayout.setExpandRatio(sourceTable, 0.45F);
    twinColumnLayout.setExpandRatio(selectButtonLayout, 0.07F);
    twinColumnLayout.setExpandRatio(selectedTable, 0.48F);
    sourceTable.setVisibleColumns(DIST_TYPE_NAME);
    return twinColumnLayout;
}
 
Example 14
Source Project: XACML   Source File: UserManagement.java    License: MIT License 5 votes vote down vote up
@AutoGenerated
private HorizontalLayout buildHorizontalLayoutToolbar() {
	// common part: create layout
	horizontalLayoutToolbar = new HorizontalLayout();
	horizontalLayoutToolbar.setImmediate(false);
	horizontalLayoutToolbar.setWidth("-1px");
	horizontalLayoutToolbar.setHeight("-1px");
	horizontalLayoutToolbar.setMargin(true);
	horizontalLayoutToolbar.setSpacing(true);
	
	// buttonAdd
	buttonAdd = new Button();
	buttonAdd.setCaption("Add User");
	buttonAdd.setImmediate(false);
	buttonAdd.setWidth("-1px");
	buttonAdd.setHeight("-1px");
	horizontalLayoutToolbar.addComponent(buttonAdd);
	
	// buttonRemove
	buttonRemove = new Button();
	buttonRemove.setCaption("Remove User");
	buttonRemove.setImmediate(false);
	buttonRemove.setWidth("-1px");
	buttonRemove.setHeight("-1px");
	horizontalLayoutToolbar.addComponent(buttonRemove);
	
	return horizontalLayoutToolbar;
}
 
Example 15
Source Project: cuba   Source File: WebComponentsHelper.java    License: Apache License 2.0 5 votes vote down vote up
public static void setClickShortcut(Button button, String shortcut) {
    KeyCombination closeCombination = KeyCombination.create(shortcut);
    int[] closeModifiers = Modifier.codes(closeCombination.getModifiers());
    int closeCode = closeCombination.getKey().getCode();

    button.setClickShortcut(closeCode, closeModifiers);
}
 
Example 16
Source Project: hawkbit   Source File: TagListField.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Adds a tag
 * 
 * @param tagName
 * @param tagColor
 */
void addTag(final String tagName, final String tagColor) {
    if (!tagButtons.containsKey(tagName)) {
        removeAllComponents();

        final Button tagButton = createButton(tagName, tagColor);
        tagButtons.put(tagName, tagButton);

        addTagButtonsAsComponents();
    }
}
 
Example 17
private Component generateToken(final SimpleUser user) {
    final Button btn = new Button("", VaadinIcons.CLOSE_SMALL);
    btn.setCaptionAsHtml(true);
    btn.setCaption((new Img("", StorageUtils.getAvatarPath(user.getAvatarid(), 16))).write() + " " + user.getDisplayName());
    btn.addClickListener(clickEvent -> {
        EmailTokenField.this.removeComponent(btn);
        inviteEmails.remove(user.getEmail());
    });
    btn.setStyleName("token-field");
    return btn;
}
 
Example 18
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;
}
 
Example 19
Source Project: jdal   Source File: FormUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Build a new Button from Button Listener
 * @param buttonListener
 * @param native true for native buttons.
 * @return a new Button
 */
public static Button newButton(ButtonListener buttonListener, boolean isNative) {
	if (isNative)
		return newNativeButton(buttonListener);
	
	return newButton(buttonListener);
	
}
 
Example 20
Source Project: hawkbit   Source File: DashboardMenu.java    License: 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 21
Source Project: cuba   Source File: WebPopupButton.java    License: Apache License 2.0 5 votes vote down vote up
protected void setPopupButtonIcon(Button button, String icon) {
    if (!StringUtils.isEmpty(icon)) {
        Resource iconResource = getIconResource(icon);
        button.setIcon(iconResource);
    } else {
        button.setIcon(null);
    }
}
 
Example 22
Source Project: jpa-invoicer   Source File: InvoicesView.java    License: The Unlicense 5 votes vote down vote up
@PostConstruct
public void initComponent() {
    table.setColumnCollapsingAllowed(true);
    table.setColumnWidth("invoiceDate", 105);
    table.setColumnWidth("lastEdited", 105);
    table.setColumnWidth("lastEditor", 110);
    if (session.getUser().getAdministrates().isEmpty()) {
        Notification.show("Add invoicer first!");
        ViewMenuUI.getMenu().navigateTo(MyAccount.class);
        return;
    }
    sender.addMValueChangeListener(e -> listEntities());

    form.setResetHandler(this::reset);
    form.setSavedHandler(this::save);

    table.addMValueChangeListener(e -> {
        if (e.getValue() != null) {
            form.setEntity(e.getValue());
            form.openInModalPopup();
        }
    });

    listEntities();

    Button addButton = new Button("Add", e -> {
        final Invoice invoice = facade.createFor(sender.getValue());
        form.setEntity(invoice);
        form.openInModalPopup();
    });

    add(
            new MHorizontalLayout(addButton, sender).space().add(backup)
            .alignAll(Alignment.MIDDLE_LEFT)
    );
    expand(table);
}
 
Example 23
Source Project: jdal   Source File: FormUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new cancel button
 * @param f form holding the button
 * @return new cancel button
 */
private static Button newCancelButton(final Form f) {
	Button cancel = new Button(StaticMessageSource.getMessage("cancel"));
	cancel.addClickListener(new ClickListener() {
		
		public void buttonClick(ClickEvent event) {
			f.discard();
		}
	});
	
	return cancel;
}
 
Example 24
Source Project: XACML   Source File: VariableDefinitionEditorWindow.java    License: MIT License 5 votes vote down vote up
@AutoGenerated
private VerticalLayout buildMainLayout() {
	// common part: create layout
	mainLayout = new VerticalLayout();
	mainLayout.setImmediate(false);
	mainLayout.setWidth("-1px");
	mainLayout.setHeight("-1px");
	mainLayout.setMargin(true);
	mainLayout.setSpacing(true);
	
	// top-level component properties
	setWidth("-1px");
	setHeight("-1px");
	
	// textFieldID
	textFieldID = new TextField();
	textFieldID.setCaption("Variable ID");
	textFieldID.setImmediate(false);
	textFieldID.setWidth("-1px");
	textFieldID.setHeight("-1px");
	textFieldID.setInvalidAllowed(false);
	textFieldID.setRequired(true);
	textFieldID.setNullRepresentation("");
	mainLayout.addComponent(textFieldID);
	
	// buttonSave
	buttonSave = new Button();
	buttonSave.setCaption("Save and Continue");
	buttonSave.setImmediate(false);
	buttonSave.setWidth("-1px");
	buttonSave.setHeight("-1px");
	mainLayout.addComponent(buttonSave);
	mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
	
	return mainLayout;
}
 
Example 25
Source Project: usergrid   Source File: ChartLayout.java    License: Apache License 2.0 5 votes vote down vote up
private void addChartItems() {

        UIUtil.addLayout( this, chartId, "left: 270px; top: 20px;", "720px", "550px" );

        nextChartButton = new Button( "..." );
        nextChartButton.setWidth( "150px" );
        nextChartButton.setVisible( false );
        nextChartButton.addClickListener( new Button.ClickListener() {
            public void buttonClick( Button.ClickEvent event ) {
                nextChartButtonClicked();
            }
        } );

        addComponent( nextChartButton, "left: 565px; top: 580px;" );
    }
 
Example 26
Source Project: cia   Source File: AbstractMenuItemFactoryImpl.java    License: 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 27
Source Project: XACML   Source File: GitSynchronizeWindow.java    License: MIT License 5 votes vote down vote up
@AutoGenerated
private VerticalLayout buildMainLayout() {
	// common part: create layout
	mainLayout = new VerticalLayout();
	mainLayout.setImmediate(false);
	mainLayout.setWidth("-1px");
	mainLayout.setHeight("-1px");
	mainLayout.setMargin(true);
	mainLayout.setSpacing(true);
	
	// top-level component properties
	setWidth("-1px");
	setHeight("-1px");
	
	// textAreaResults
	textAreaResults = new TextArea();
	textAreaResults.setCaption("Synch Results");
	textAreaResults.setImmediate(false);
	textAreaResults.setWidth("462px");
	textAreaResults.setHeight("222px");
	mainLayout.addComponent(textAreaResults);
	
	// buttonSynchronize
	buttonSynchronize = new Button();
	buttonSynchronize.setCaption("Synchronize");
	buttonSynchronize.setImmediate(true);
	buttonSynchronize.setWidth("-1px");
	buttonSynchronize.setHeight("-1px");
	mainLayout.addComponent(buttonSynchronize);
	mainLayout.setComponentAlignment(buttonSynchronize, new Alignment(24));
	
	return mainLayout;
}
 
Example 28
Source Project: mycollab   Source File: ButtonGroup.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
public ButtonGroup withDefaultButton(Button button) {
    for (Component component : ButtonGroup.this) {
        Button currentBtn = (Button) component;
        if (currentBtn.equals(button)) {
            selectedBtn = button;
            selectedBtn.addStyleName(WebThemes.BTN_ACTIVE);
        } else {
            currentBtn.removeStyleName(WebThemes.BTN_ACTIVE);
        }
    }
    return this;
}
 
Example 29
Source Project: chipster   Source File: ReportDataSource.java    License: MIT License 5 votes vote down vote up
private static void updateCompUI(final ReportView view,
		final List<ServerStatusMessage> statuses, final ReportDataSource reportDataSource) {

	view.updateUI(new Runnable() {
		@Override
		public void run() {
			VerticalLayout layout = view.getCompLayout();

			layout.removeAllComponents();

			Collections.sort(statuses, new Comparator<ServerStatusMessage>() {
				@Override
				public int compare(ServerStatusMessage m1, ServerStatusMessage m2) {
					int hostComparison = m1.getHost().compareTo(m2.getHost());
					int idComparison = m1.getHostId().compareTo(m2.getHostId());
					if (hostComparison != 0) {
						return hostComparison;
					}
					return idComparison;
				}						
			});

			for (ServerStatusMessage serverStatus : statuses) {

				Label title = view.createReportLabel("Comp " + serverStatus.getHost() + " (" + serverStatus.getHostId() + ")" + "    ");
				Button shutdownButton = view.createReportButton("Stop gracefully");

				shutdownButton.addClickListener(new StopClickListener(view, reportDataSource, serverStatus.getHostId()));
				HorizontalLayout titleRow = new HorizontalLayout();						
				titleRow.addComponent(title);
				titleRow.addComponent(shutdownButton);
				Label reportLabel = view.createReportLabel(
						serverStatus.toString());
				layout.addComponent(titleRow);
				layout.addComponent(reportLabel);
			}
		}
	});
}
 
Example 30
public void buttonClick(Button.ClickEvent event) {
    if (getParent() != null) {
        ((Window) getParent()).removeWindow(this);
    }
    if (callback != null) {
        callback.onDialogResult((Result) event.getButton().getData());
    }
}