use of io.jmix.ui.widget.JmixButton in project jmix by jmix-framework.
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);
nameField = new TextField(messages.getMessage("PresentationsEditor.name"));
nameField.setWidth(theme.get("jmix.ui.PresentationEditor.name.width"));
nameField.setValue(getPresentationCaption());
root.addComponent(nameField);
autoSaveField = new CheckBox();
autoSaveField.setCaption(messages.getMessage("PresentationsEditor.autoSave"));
autoSaveField.setValue(BooleanUtils.isTrue(presentation.getAutoSave()));
root.addComponent(autoSaveField);
defaultField = new CheckBox();
defaultField.setCaption(messages.getMessage("PresentationsEditor.default"));
defaultField.setValue(Objects.equals(EntityValues.<UUID>getId(presentation), (component.getDefaultPresentationId())));
root.addComponent(defaultField);
if (allowGlobalPresentations) {
globalField = new CheckBox();
globalField.setCaption(messages.getMessage("PresentationsEditor.global"));
globalField.setValue(!isNew && presentation.getUsername() == 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 JmixButton(messages.getMessage("PresentationsEditor.save"));
commitButton.addClickListener(event -> {
if (validate()) {
commit();
forceClose();
}
});
buttons.addComponent(commitButton);
Button closeButton = new JmixButton(messages.getMessage("PresentationsEditor.close"));
closeButton.addClickListener(event -> forceClose());
buttons.addComponent(closeButton);
nameField.focus();
}
use of io.jmix.ui.widget.JmixButton in project jmix by jmix-framework.
the class AbstractActionsHolderComponent method addAction.
@Override
public void addAction(Action action, int index) {
checkNotNullArgument(action, "action must be non null");
int oldIndex = findActionById(actionList, action.getId());
if (oldIndex >= 0) {
removeAction(actionList.get(oldIndex));
if (index > oldIndex) {
index--;
}
}
if (StringUtils.isNotEmpty(action.getCaption())) {
JmixButton contextMenuButton = createContextMenuButton();
initContextMenuButton(contextMenuButton, action);
int visibleActionsIndex = 0;
int i = 0;
while (i < index && i < actionList.size()) {
Action componentAction = actionList.get(i);
if (StringUtils.isNotEmpty(componentAction.getCaption()) && actionButtons.containsKey(componentAction)) {
visibleActionsIndex++;
}
i++;
}
contextMenuPopup.addComponent(contextMenuButton, visibleActionsIndex);
actionButtons.put(action, contextMenuButton);
}
actionList.add(index, action);
shortcutsDelegate.addAction(null, action);
attachAction(action);
actionsPermissions.apply(action);
}
use of io.jmix.ui.widget.JmixButton in project jmix by jmix-framework.
the class ValuePickerImpl method removeAction.
@Override
public void removeAction(Action action) {
if (actions.remove(action)) {
actionHandler.removeAction(action);
JmixButton button = actionButtons.remove(action);
component.removeButton(button);
action.removePropertyChangeListener(actionPropertyChangeListener);
if (action instanceof ValuePickerAction) {
((ValuePickerAction) action).setPicker(null);
}
}
}
use of io.jmix.ui.widget.JmixButton in project jmix by jmix-framework.
the class ValuePickerImpl 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);
JmixButton vButton = new JmixButton();
setupButtonAction(vButton, action);
action.addPropertyChangeListener(actionPropertyChangeListener);
component.addButton(vButton, index);
actionButtons.put(action, vButton);
if (StringUtils.isNotEmpty(getDebugId()) && AppUI.getCurrent() != null) {
TestIdManager testIdManager = AppUI.getCurrent().getTestIdManager();
// Set debug id
vButton.setId(testIdManager.getTestId(getDebugId() + "_" + action.getId()));
}
if (action instanceof ValuePickerAction) {
ValuePickerAction pickerAction = (ValuePickerAction) action;
pickerAction.setPicker(this);
if (!isEditable()) {
pickerAction.editableChanged(isEditable());
}
}
actionsPermissions.apply(action);
refreshActionsState();
}
use of io.jmix.ui.widget.JmixButton in project jmix by jmix-framework.
the class PaletteComponentsFactoryImpl method createCommonButton.
protected PaletteButton createCommonButton() {
PaletteButton button = factory.create(PaletteButton.class);
button.setWidth("100%");
button.setHeight("50px");
button.setStyleName(DashboardStyleConstants.DASHBOARD_BUTTON);
DragSourceExtension<JmixButton> dragSourceExtension = new DragSourceExtension<>(button.unwrap(JmixButton.class));
dragSourceExtension.setEffectAllowed(EffectAllowed.COPY);
dragSourceExtension.addDragStartListener(e -> dragSourceExtension.setDragData(button.getLayout()));
dragSourceExtension.addDragEndListener(e -> dragSourceExtension.setDragData(null));
return button;
}
Aggregations