@Override @Nullable public Action getAction(String id) { for (Action action : actions) { if (Objects.equals(id, action.getId())) { return action; } } return null; }
@Override @Nullable public Action getAction(String id) { for (Action action : actionOrder) { if (id.equals(action.getId())) { return action; } } return null; }
public static int findActionById(List<Action> actionList, String actionId) { int oldIndex = -1; for (int i = 0; i < actionList.size(); i++) { Action a = actionList.get(i); if (Objects.equals(a.getId(), actionId)) { oldIndex = i; break; } } return oldIndex; }
@Nullable @Override public Action getAction(String id) { for (Action action : getActions()) { if (Objects.equals(action.getId(), id)) { return action; } } return null; }
@Override @Nullable public Action getAction(String id) { for (Action action : getActions()) { if (Objects.equals(action.getId(), id)) { return action; } } return null; }
public Action getAction(String id) { for (Action action : getActions()) { if (Objects.equals(action.getId(), id)) { return action; } } return null; }
private void removeShortcut(Action action) { String actionId = action.getId(); if (shortcuts.containsKey(actionId)) { detachShortcut(action, shortcuts.remove(actionId)); } }
@Nullable @Override public Action getAction(String id) { for (Action action : getActions()) { if (Objects.equals(action.getId(), id)) { return action; } } return null; }
@Override public void addAction(Action action) { int index = findActionById(actionList, action.getId()); if (index < 0) { index = actionList.size(); } addAction(action, index); }
@Override public void addAction(Action action) { int index = findActionById(actionOrder, action.getId()); if (index < 0) { index = actionOrder.size(); } addAction(action, index); }
@Override public void addAction(Action action) { int index = findActionById(actionList, action.getId()); if (index < 0) { index = actionList.size(); } addAction(action, index); }
@Override public void addAction(Action action) { int index = findActionById(actionList, action.getId()); if (index < 0) { index = actionList.size(); } addAction(action, index); }
public void addAction(Action action) { int index = findActionById(actionList, action.getId()); if (index < 0) { index = actionList.size(); } addAction(action, index); }
@Override public void addAction(Action action) { int index = findActionById(actions, action.getId()); if (index < 0) { index = actions.size(); } addAction(action, index); }
public void apply(Action action) { if (action instanceof Action.SecuredAction) { if (isHiddenAction(action.getId())) { ((Action.SecuredAction) action).setVisibleByUiPermissions(false); } if (isDisabledAction(action.getId())) { ((Action.SecuredAction) action).setEnabledByUiPermissions(false); } } } }
@Override protected void addAction(Action action) { ActionsHolder actionsHolder = (ActionsHolder) component; List<Action> existingActions = new ArrayList<>(actionsHolder.getActions()); for (Action existingAction : existingActions) { // Comparing the id of an existing action with the full Id (including path) of the action to be added if (Objects.equals(existingAction.getId(), actionId)) { int index = existingActions.indexOf(existingAction); actionsHolder.removeAction(existingAction); actionsHolder.addAction(action, index); break; } } } }
public void addAction(Action action, int index) { int oldIndex = findActionById(actionList, action.getId()); if (oldIndex >= 0) { removeAction(actionList.get(oldIndex)); if (index > oldIndex) { index--; } } if (action.getShortcutCombination() != null) { actions.put(createShortcutAction(action), action); } actionList.add(index, action); action.addPropertyChangeListener(actionPropertyChangeListener); }
@Override public void setDebugId(String id) { super.setDebugId(id); AppUI ui = AppUI.getCurrent(); if (id != null && ui != null && ui.isPerformanceTestMode()) { TestIdManager testIdManager = ui.getTestIdManager(); for (Map.Entry<Action, Button> entry : actionButtons.entrySet()) { Button button = entry.getValue(); Action action = entry.getKey(); button.setId(testIdManager.getTestId(id + "_" + action.getId())); } } }
@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())); } } } }
private void addAlternativeShortcut(KeyCombination kc) { Action alternativeAction = null; for (Action action : getActions()) { // find last action with same shortcut if (kc.equals(action.getShortcutCombination())) { alternativeAction = action; } } if (alternativeAction != null) { addShortcut(alternativeAction.getId(), alternativeAction.getShortcutCombination()); } }