use of com.haulmont.cuba.gui.components.Action in project cuba by cuba-platform.
the class DesktopAbstractTable method createPopupMenu.
protected JPopupMenu createPopupMenu() {
JPopupMenu popup = new JPopupMenu();
JMenuItem menuItem;
for (final Action action : actionList) {
if (StringUtils.isNotBlank(action.getCaption()) && action.isVisible()) {
menuItem = new JMenuItem(action.getCaption());
if (action.getIcon() != null) {
menuItem.setIcon(AppBeans.get(IconResolver.class).getIconResource(action.getIcon()));
}
if (action.getShortcutCombination() != null) {
menuItem.setAccelerator(convertKeyCombination(action.getShortcutCombination()));
}
menuItem.setEnabled(action.isEnabled());
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
action.actionPerform(DesktopAbstractTable.this);
}
});
popup.add(menuItem);
}
}
return popup;
}
use of com.haulmont.cuba.gui.components.Action in project cuba by cuba-platform.
the class DesktopAbstractTable method handleClickAction.
protected void handleClickAction() {
Action action = getItemClickAction();
if (action == null) {
action = getEnterAction();
if (action == null) {
action = getAction("edit");
if (action == null) {
action = getAction("view");
}
}
}
if (action != null && action.isEnabled() && action.isVisible()) {
Window window = ComponentsHelper.getWindow(DesktopAbstractTable.this);
if (window instanceof Window.Wrapper) {
window = ((Window.Wrapper) window).getWrappedWindow();
}
if (!(window instanceof Window.Lookup)) {
action.actionPerform(DesktopAbstractTable.this);
} else {
Window.Lookup lookup = (Window.Lookup) window;
com.haulmont.cuba.gui.components.Component lookupComponent = lookup.getLookupComponent();
if (lookupComponent != this) {
action.actionPerform(DesktopAbstractTable.this);
} else if (action.getId().equals(WindowDelegate.LOOKUP_ITEM_CLICK_ACTION_ID)) {
action.actionPerform(DesktopAbstractTable.this);
}
}
}
}
use of com.haulmont.cuba.gui.components.Action in project cuba by cuba-platform.
the class CopySettings method init.
@Override
public void init(Map<String, Object> params) {
super.init(params);
copyBtn.addClickListener(e -> {
if (usersDs.getItem() == null) {
showNotification(getMessage("selectUser"), NotificationType.HUMANIZED);
} else {
showOptionDialog(getMessage("confirmCopy.title"), getMessage("confirmCopy.msg"), MessageType.CONFIRMATION, new Action[] { new DialogAction(Type.YES).withHandler(event -> copySettings()), new DialogAction(Type.NO, Action.Status.PRIMARY) });
}
});
cancelBtn.addClickListener(e -> close("cancel"));
}
use of com.haulmont.cuba.gui.components.Action in project cuba by cuba-platform.
the class SessionLogBrowser method enableLogging.
public void enableLogging() {
if (globalConfig.getUserSessionLogEnabled()) {
showOptionDialog(getMessage("dialogs.Confirmation"), getMessage("confirmDisable"), MessageType.CONFIRMATION, new Action[] { new DialogAction(DialogAction.Type.YES, true).withHandler(actionPerformedEvent -> {
globalConfig.setUserSessionLogEnabled(false);
enableBtn.setCaption(getMessage("enableLogging"));
}), new DialogAction(DialogAction.Type.NO) });
} else {
globalConfig.setUserSessionLogEnabled(true);
enableBtn.setCaption(getMessage("disableLogging"));
}
}
use of com.haulmont.cuba.gui.components.Action in project cuba by cuba-platform.
the class DesktopTree method createPopupMenu.
protected JPopupMenu createPopupMenu() {
JPopupMenu popup = new JPopupMenu();
JMenuItem menuItem;
for (final com.haulmont.cuba.gui.components.Action action : actionList) {
if (StringUtils.isNotBlank(action.getCaption()) && action.isVisible()) {
menuItem = new JMenuItem(action.getCaption());
if (action.getIcon() != null) {
menuItem.setIcon(AppBeans.get(IconResolver.class).getIconResource(action.getIcon()));
}
if (action.getShortcutCombination() != null) {
menuItem.setAccelerator(DesktopComponentsHelper.convertKeyCombination(action.getShortcutCombination()));
}
menuItem.setEnabled(action.isEnabled());
menuItem.addActionListener(e -> action.actionPerform(DesktopTree.this));
popup.add(menuItem);
}
}
return popup;
}
Aggregations