use of com.haulmont.cuba.web.widgets.CubaButton in project cuba by cuba-platform.
the class WebPickerField method setDebugId.
@Override
public void setDebugId(String id) {
super.setDebugId(id);
if (id != null) {
String debugId = getDebugId();
TestIdManager testIdManager = AppUI.getCurrent().getTestIdManager();
for (Action action : actions) {
CubaButton button = actionButtons.get(action);
if (button != null && Strings.isNullOrEmpty(button.getId())) {
button.setId(testIdManager.getTestId(debugId + "_" + action.getId()));
}
}
}
}
use of com.haulmont.cuba.web.widgets.CubaButton in project cuba by cuba-platform.
the class WebPickerField method addAction.
@Override
public void addAction(Action action, int index) {
checkNotNullArgument(action, "action must be non null");
int oldIndex = findActionById(actions, action.getId());
if (oldIndex >= 0) {
removeAction(actions.get(oldIndex));
if (index > oldIndex) {
index--;
}
}
actions.add(index, action);
actionHandler.addAction(action, index);
CubaButton vButton = new CubaButton();
setPickerButtonAction(vButton, action);
component.addButton(vButton, index);
actionButtons.put(action, vButton);
if (StringUtils.isNotEmpty(getDebugId())) {
TestIdManager testIdManager = AppUI.getCurrent().getTestIdManager();
// Set debug id
vButton.setId(testIdManager.getTestId(getDebugId() + "_" + action.getId()));
}
if (action instanceof PickerFieldAction) {
PickerFieldAction pickerFieldAction = (PickerFieldAction) action;
pickerFieldAction.setPickerField(this);
if (!isEditable()) {
pickerFieldAction.editableChanged(this, isEditable());
}
}
actionsPermissions.apply(action);
refreshActionsState();
}
use of com.haulmont.cuba.web.widgets.CubaButton in project cuba by cuba-platform.
the class WebPickerField method actionPropertyChanged.
protected void actionPropertyChanged(PropertyChangeEvent evt) {
Action action = (Action) evt.getSource();
CubaButton button = actionButtons.get(action);
if (Action.PROP_ICON.equals(evt.getPropertyName())) {
setPickerButtonIcon(button, action.getIcon());
} 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());
} else if (action instanceof PickerFieldAction && PickerFieldAction.PROP_EDITABLE.equals(evt.getPropertyName())) {
button.setVisible(((PickerFieldAction) action).isEditable());
}
}
use of com.haulmont.cuba.web.widgets.CubaButton in project cuba by cuba-platform.
the class LogWindow method initUI.
protected 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.setMargin(false);
layout.setSizeFull();
setContent(layout);
Panel scrollablePanel = new Panel();
scrollablePanel.setSizeFull();
VerticalLayout scrollContent = new VerticalLayout();
scrollContent.setMargin(false);
scrollContent.setSpacing(false);
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.setMargin(false);
topLayout.setSpacing(false);
topLayout.setWidth("100%");
topLayout.setHeightUndefined();
Messages messages = AppBeans.get(Messages.NAME);
Button refreshBtn = new CubaButton(messages.getMessage(getClass(), "logWindow.refreshBtn"), event -> label.setValue(writeLog()));
topLayout.addComponent(refreshBtn);
layout.addComponent(topLayout);
layout.addComponent(scrollablePanel);
layout.setExpandRatio(scrollablePanel, 1.0f);
}
use of com.haulmont.cuba.web.widgets.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);
root.setMargin(false);
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.setMargin(false);
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();
forceClose();
}
});
buttons.addComponent(commitButton);
Button closeButton = new CubaButton(messages.getMainMessage("PresentationsEditor.close"));
closeButton.addClickListener(event -> forceClose());
buttons.addComponent(closeButton);
nameField.focus();
}
Aggregations