Search in sources :

Example 1 with CubaButton

use of com.haulmont.cuba.web.toolkit.ui.CubaButton in project cuba by cuba-platform.

the class WindowBreadCrumbs method update.

public void update() {
    AppUI ui = AppUI.getCurrent();
    boolean isTestMode = ui.isTestMode();
    linksLayout.removeAllComponents();
    btn2win.clear();
    for (Iterator<Window> it = windows.iterator(); it.hasNext(); ) {
        Window window = it.next();
        Button button = new CubaButton(StringUtils.trimToEmpty(window.getCaption()), new BtnClickListener());
        button.setSizeUndefined();
        button.setStyleName(BaseTheme.BUTTON_LINK);
        button.setTabIndex(-1);
        if (isTestMode) {
            button.setCubaId("breadCrubms_Button_" + window.getId());
            button.setId(ui.getTestIdManager().getTestId("breadCrubms_Button_" + window.getId()));
        }
        btn2win.put(button, window);
        if (it.hasNext()) {
            linksLayout.addComponent(button);
            Label separatorLab = new Label("&nbsp;&gt;&nbsp;");
            separatorLab.setStyleName("c-breadcrumbs-separator");
            separatorLab.setSizeUndefined();
            separatorLab.setContentMode(ContentMode.HTML);
            linksLayout.addComponent(separatorLab);
        } else {
            Label captionLabel = new Label(window.getCaption());
            captionLabel.setStyleName("c-breadcrumbs-win-caption");
            captionLabel.setSizeUndefined();
            linksLayout.addComponent(captionLabel);
            this.label = captionLabel;
        }
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) WebWindow(com.haulmont.cuba.web.gui.WebWindow) CubaButton(com.haulmont.cuba.web.toolkit.ui.CubaButton) Button(com.vaadin.ui.Button) CubaButton(com.haulmont.cuba.web.toolkit.ui.CubaButton) Label(com.vaadin.ui.Label) AppUI(com.haulmont.cuba.web.AppUI)

Example 2 with CubaButton

use of com.haulmont.cuba.web.toolkit.ui.CubaButton in project cuba by cuba-platform.

the class LogWindow method initUI.

private void initUI() {
    ClientConfig clientConfig = AppBeans.<Configuration>get(Configuration.NAME).getConfig(ClientConfig.class);
    String closeShortcut = clientConfig.getCloseShortcut();
    KeyCombination closeCombination = KeyCombination.create(closeShortcut);
    com.vaadin.event.ShortcutAction closeShortcutAction = new com.vaadin.event.ShortcutAction("closeShortcutAction", closeCombination.getKey().getCode(), KeyCombination.Modifier.codes(closeCombination.getModifiers()));
    addActionHandler(new com.vaadin.event.Action.Handler() {

        @Override
        public com.vaadin.event.Action[] getActions(Object target, Object sender) {
            return new com.vaadin.event.Action[] { closeShortcutAction };
        }

        @Override
        public void handleAction(com.vaadin.event.Action action, Object sender, Object target) {
            if (Objects.equals(action, closeShortcutAction)) {
                close();
            }
        }
    });
    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setSizeFull();
    setContent(layout);
    Panel scrollablePanel = new Panel();
    scrollablePanel.setSizeFull();
    VerticalLayout scrollContent = new VerticalLayout();
    scrollContent.setSizeUndefined();
    scrollablePanel.setContent(scrollContent);
    final Label label = new Label();
    label.setContentMode(ContentMode.HTML);
    label.setValue(writeLog());
    label.setSizeUndefined();
    label.setStyleName("c-log-content");
    ((Layout) scrollablePanel.getContent()).addComponent(label);
    HorizontalLayout topLayout = new HorizontalLayout();
    topLayout.setWidth("100%");
    topLayout.setHeightUndefined();
    Messages messages = AppBeans.get(Messages.NAME);
    Button refreshBtn = new CubaButton(messages.getMessage(getClass(), "logWindow.refreshBtn"), (Button.ClickListener) event -> label.setValue(writeLog()));
    topLayout.addComponent(refreshBtn);
    layout.addComponent(topLayout);
    layout.addComponent(scrollablePanel);
    layout.setExpandRatio(scrollablePanel, 1.0f);
}
Also used : CubaButton(com.haulmont.cuba.web.toolkit.ui.CubaButton) StringUtils(org.apache.commons.lang.StringUtils) ContentMode(com.vaadin.shared.ui.label.ContentMode) KeyCombination(com.haulmont.cuba.gui.components.KeyCombination) App(com.haulmont.cuba.web.App) Messages(com.haulmont.cuba.core.global.Messages) AppBeans(com.haulmont.cuba.core.global.AppBeans) DateFormatUtils(org.apache.commons.lang.time.DateFormatUtils) Objects(java.util.Objects) List(java.util.List) Configuration(com.haulmont.cuba.core.global.Configuration) CubaWindow(com.haulmont.cuba.web.toolkit.ui.CubaWindow) AppUI(com.haulmont.cuba.web.AppUI) ClientConfig(com.haulmont.cuba.client.ClientConfig) StringEscapeUtils(org.apache.commons.lang.StringEscapeUtils) com.vaadin.ui(com.vaadin.ui) Messages(com.haulmont.cuba.core.global.Messages) KeyCombination(com.haulmont.cuba.gui.components.KeyCombination) CubaButton(com.haulmont.cuba.web.toolkit.ui.CubaButton) CubaButton(com.haulmont.cuba.web.toolkit.ui.CubaButton) ClientConfig(com.haulmont.cuba.client.ClientConfig)

Example 3 with CubaButton

use of com.haulmont.cuba.web.toolkit.ui.CubaButton in project cuba by cuba-platform.

the class PresentationEditor method initLayout.

protected void initLayout() {
    ThemeConstants theme = App.getInstance().getThemeConstants();
    VerticalLayout root = new VerticalLayout();
    root.setWidthUndefined();
    root.setSpacing(true);
    setContent(root);
    messages = AppBeans.get(Messages.class);
    nameField = new TextField(messages.getMainMessage("PresentationsEditor.name"));
    nameField.setWidth(theme.get("cuba.web.PresentationEditor.name.width"));
    nameField.setValue(getPresentationCaption());
    root.addComponent(nameField);
    autoSaveField = new CheckBox();
    autoSaveField.setCaption(messages.getMainMessage("PresentationsEditor.autoSave"));
    autoSaveField.setValue(BooleanUtils.isTrue(presentation.getAutoSave()));
    root.addComponent(autoSaveField);
    defaultField = new CheckBox();
    defaultField.setCaption(messages.getMainMessage("PresentationsEditor.default"));
    defaultField.setValue(presentation.getId().equals(component.getDefaultPresentationId()));
    root.addComponent(defaultField);
    if (allowGlobalPresentations) {
        globalField = new CheckBox();
        globalField.setCaption(messages.getMainMessage("PresentationsEditor.global"));
        globalField.setValue(!isNew && presentation.getUser() == null);
        root.addComponent(globalField);
    }
    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.setWidthUndefined();
    root.addComponent(buttons);
    root.setComponentAlignment(buttons, Alignment.MIDDLE_LEFT);
    Button commitButton = new CubaButton(messages.getMainMessage("PresentationsEditor.save"));
    commitButton.addClickListener(event -> {
        if (validate()) {
            commit();
            close();
        }
    });
    buttons.addComponent(commitButton);
    Button closeButton = new CubaButton(messages.getMainMessage("PresentationsEditor.close"));
    closeButton.addClickListener(event -> {
        close();
    });
    buttons.addComponent(closeButton);
    nameField.focus();
}
Also used : ThemeConstants(com.haulmont.cuba.gui.theme.ThemeConstants) Messages(com.haulmont.cuba.core.global.Messages) CubaButton(com.haulmont.cuba.web.toolkit.ui.CubaButton) CubaButton(com.haulmont.cuba.web.toolkit.ui.CubaButton)

Aggregations

CubaButton (com.haulmont.cuba.web.toolkit.ui.CubaButton)3 Messages (com.haulmont.cuba.core.global.Messages)2 AppUI (com.haulmont.cuba.web.AppUI)2 ClientConfig (com.haulmont.cuba.client.ClientConfig)1 AppBeans (com.haulmont.cuba.core.global.AppBeans)1 Configuration (com.haulmont.cuba.core.global.Configuration)1 KeyCombination (com.haulmont.cuba.gui.components.KeyCombination)1 Window (com.haulmont.cuba.gui.components.Window)1 ThemeConstants (com.haulmont.cuba.gui.theme.ThemeConstants)1 App (com.haulmont.cuba.web.App)1 WebWindow (com.haulmont.cuba.web.gui.WebWindow)1 CubaWindow (com.haulmont.cuba.web.toolkit.ui.CubaWindow)1 ContentMode (com.vaadin.shared.ui.label.ContentMode)1 com.vaadin.ui (com.vaadin.ui)1 Button (com.vaadin.ui.Button)1 Label (com.vaadin.ui.Label)1 List (java.util.List)1 Objects (java.util.Objects)1 StringEscapeUtils (org.apache.commons.lang.StringEscapeUtils)1 StringUtils (org.apache.commons.lang.StringUtils)1