use of com.haulmont.cuba.web.widgets.CubaButton in project cuba by cuba-platform.
the class WebDialogs method createButton.
public CubaButton createButton(Action action) {
CubaButton button = new CubaButton();
if (action instanceof DialogAction) {
DialogAction.Type type = ((DialogAction) action).getType();
button.setCaption(messages.getMainMessage(type.getMsgKey()));
String iconPath = icons.get(type.getIconKey());
button.setIcon(iconResolver.getIconResource(iconPath));
}
button.setEnabled(action.isEnabled());
if (StringUtils.isNotEmpty(action.getCaption())) {
button.setCaption(action.getCaption());
}
if (StringUtils.isNotEmpty(action.getDescription())) {
button.setDescription(action.getDescription());
}
if (StringUtils.isNotEmpty(action.getIcon())) {
button.setIcon(iconResolver.getIconResource(action.getIcon()));
}
return button;
}
use of com.haulmont.cuba.web.widgets.CubaButton in project cuba by cuba-platform.
the class WebPopupButton method createActionButton.
protected CubaButton createActionButton(Action action) {
CubaButton button = new CubaButton();
button.setWidth(100, Sizeable.Unit.PERCENTAGE);
button.setPrimaryStyleName(CONTEXT_MENU_BUTTON_STYLENAME);
setPopupButtonAction(button, action);
AppUI ui = AppUI.getCurrent();
if (ui != null) {
if (ui.isTestMode()) {
button.setCubaId(action.getId());
}
if (ui.isPerformanceTestMode()) {
String debugId = getDebugId();
if (debugId != null) {
TestIdManager testIdManager = ui.getTestIdManager();
button.setId(testIdManager.getTestId(debugId + "_" + action.getId()));
}
}
}
return button;
}
use of com.haulmont.cuba.web.widgets.CubaButton in project cuba by cuba-platform.
the class WebPickerField method removeAction.
@Override
public void removeAction(@Nullable Action action) {
if (actions.remove(action)) {
actionHandler.removeAction(action);
if (action != null) {
CubaButton button = actionButtons.remove(action);
component.removeButton(button);
action.removePropertyChangeListener(actionPropertyChangeListener);
}
if (action instanceof PickerFieldAction) {
((PickerFieldAction) action).setPickerField(null);
}
}
}
use of com.haulmont.cuba.web.widgets.CubaButton in project cuba by cuba-platform.
the class TablePresentations method createActionButton.
protected CubaButton createActionButton(Action action) {
CubaButton actionBtn = new CubaButton();
actionBtn.setWidth("100%");
actionBtn.setPrimaryStyleName(CONTEXT_MENU_BUTTON_STYLENAME);
setPopupButtonAction(actionBtn, action);
AppUI ui = AppUI.getCurrent();
if (ui != null) {
if (ui.isTestMode()) {
actionBtn.setCubaId(action.getId());
}
if (ui.isPerformanceTestMode()) {
String debugId = getDebugId();
if (debugId != null) {
TestIdManager testIdManager = ui.getTestIdManager();
actionBtn.setId(testIdManager.getTestId(debugId + "_" + action.getId()));
}
}
}
return actionBtn;
}
use of com.haulmont.cuba.web.widgets.CubaButton in project cuba by cuba-platform.
the class WebAbstractActionsHolderComponent 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())) {
CubaButton 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);
}
Aggregations