Search in sources :

Example 1 with ActionManagerImpl

use of org.eclipse.che.ide.actions.ActionManagerImpl in project che by eclipse.

the class FindActionPresenter method nameChanged.

@Override
public void nameChanged(String name, boolean checkBoxState) {
    if (name.isEmpty()) {
        view.hideActions();
        return;
    }
    String pattern = convertPattern(name.trim());
    RegExp regExp = RegExp.compile(pattern);
    Map<Action, String> actions = new TreeMap<>(actionComparator);
    if (checkBoxState) {
        Set<String> ids = ((ActionManagerImpl) actionManager).getActionIds();
        for (Action action : actionsMap.keySet()) {
            ids.remove(actionManager.getId(action));
        }
        for (String id : ids) {
            Action action = actionManager.getAction(id);
            Presentation presentation = action.getTemplatePresentation();
            String text = presentation.getText();
            if (text != null && regExp.test(text)) {
                actions.put(action, null);
            }
        }
    }
    List<String> excludedActionIds = getExcludedActionIds(actionManager);
    for (Entry<Action, String> entry : actionsMap.entrySet()) {
        final Action action = entry.getKey();
        final String groupName = entry.getValue();
        if (excludedActionIds.contains(actionManager.getId(action))) {
            continue;
        }
        Presentation presentation = action.getTemplatePresentation();
        String text = presentation.getText();
        if (text != null && regExp.test(text)) {
            actions.put(action, groupName);
        }
    }
    if (!actions.isEmpty()) {
        view.showActions(actions);
    } else {
        view.hideActions();
    }
}
Also used : Action(org.eclipse.che.ide.api.action.Action) RegExp(com.google.gwt.regexp.shared.RegExp) ActionManagerImpl(org.eclipse.che.ide.actions.ActionManagerImpl) TreeMap(java.util.TreeMap) Presentation(org.eclipse.che.ide.api.action.Presentation)

Aggregations

RegExp (com.google.gwt.regexp.shared.RegExp)1 TreeMap (java.util.TreeMap)1 ActionManagerImpl (org.eclipse.che.ide.actions.ActionManagerImpl)1 Action (org.eclipse.che.ide.api.action.Action)1 Presentation (org.eclipse.che.ide.api.action.Presentation)1