use of org.eclipse.che.ide.api.action.Presentation 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();
}
}
use of org.eclipse.che.ide.api.action.Presentation in project che by eclipse.
the class FullTextSearchActionTest method actionShouldBeDisabled.
@Test
public void actionShouldBeDisabled() {
Presentation presentation = Mockito.mock(Presentation.class);
when(actionEvent.getPresentation()).thenReturn(presentation);
when(appContext.getRootProject()).thenReturn(null);
fullTextSearchAction.updateInPerspective(actionEvent);
verify(presentation).setVisible(true);
verify(presentation).setEnabled(false);
}
Aggregations