Search in sources :

Example 1 with DialogOptions

use of com.haulmont.cuba.gui.DialogOptions in project cuba by cuba-platform.

the class CreditsFrame method init.

@Override
public void init(Map<String, Object> params) {
    DialogOptions dialogOptions = ComponentsHelper.getWindow(this).getDialogOptions();
    if (dialogOptions != null) {
        dialogOptions.setResizable(true);
    }
    StringBuilder acknowledgements = new StringBuilder();
    GridLayout grid = uiComponents.create(GridLayout.class);
    grid.setSpacing(true);
    grid.setMargin(false, true, false, true);
    grid.setColumns(5);
    grid.setFrame(frame);
    List<CreditsItem> items = new CreditsLoader().load().getItems();
    if (items.size() > 0) {
        grid.setRows(items.size());
        for (int i = 0, itemsSize = items.size(); i < itemsSize; i++) {
            final CreditsItem item = items.get(i);
            if (item.getAcknowledgement() != null)
                acknowledgements.append("<p>").append(item.getAcknowledgement());
            Label<String> nameLab = uiComponents.create(Label.NAME);
            nameLab.setValue(item.getName());
            nameLab.setAlignment(Alignment.MIDDLE_LEFT);
            grid.add(nameLab, 0, i);
            Label<String> dash = uiComponents.create(Label.NAME);
            dash.setValue("-");
            dash.setAlignment(Alignment.MIDDLE_LEFT);
            grid.add(dash, 1, i);
            Link webpage = uiComponents.create(Link.class);
            webpage.setCaption(getMessage("webpage"));
            webpage.setUrl(item.getWebPage());
            webpage.setTarget("_blank");
            webpage.setFrame(frame);
            webpage.setAlignment(Alignment.MIDDLE_LEFT);
            grid.add(webpage, 2, i);
            dash = uiComponents.create(Label.NAME);
            dash.setValue("-");
            dash.setAlignment(Alignment.MIDDLE_LEFT);
            grid.add(dash, 3, i);
            LinkButton license = uiComponents.create(LinkButton.class);
            license.setFrame(frame);
            license.setCaption(getMessage("license"));
            license.setAlignment(Alignment.MIDDLE_LEFT);
            license.setAction(new AbstractAction("license") {

                @Override
                public void actionPerform(Component component) {
                    openWindow("thirdpartyLicenseWindow", WindowManager.OpenType.DIALOG, ParamsMap.of("licenseText", item.getLicense()));
                }
            });
            grid.add(license, 4, i);
        }
        scrollBox.add(grid);
        if (acknowledgements.length() > 0) {
            Label<String> ackLab = uiComponents.create(Label.NAME);
            ackLab.setWidth("420px");
            ackLab.setHtmlEnabled(true);
            ackLab.setValue(acknowledgements.toString());
            scrollBox.add(ackLab);
        }
    }
}
Also used : DialogOptions(com.haulmont.cuba.gui.DialogOptions)

Aggregations

DialogOptions (com.haulmont.cuba.gui.DialogOptions)1