use of org.eclipse.che.ide.api.action.DefaultActionGroup in project che by eclipse.
the class SelectCommandComboBox method setCommands.
/**
* Sets commands to the widget.
*
* @param commands
* commands to set
* @param commandToSelect
* command that should be selected or {@code null} if none
*/
private void setCommands(List<CommandImpl> commands, @Nullable CommandImpl commandToSelect) {
this.commands.clear();
commandActions.removeAll();
final DefaultActionGroup commandsList = (DefaultActionGroup) actionManager.getAction(GROUP_COMMANDS_LIST);
if (commandsList != null) {
commandActions.addAll(commandsList);
}
Collections.sort(commands, new Comparator<CommandImpl>() {
@Override
public int compare(CommandImpl o1, CommandImpl o2) {
return o1.getType().compareTo(o2.getType());
}
});
CommandImpl prevCommand = null;
for (CommandImpl command : commands) {
if (prevCommand == null || !command.getType().equals(prevCommand.getType())) {
CommandType commandType = commandTypeRegistry.getCommandTypeById(command.getType());
commandActions.addSeparator(commandType.getDisplayName());
}
commandActions.add(commandsListWidget.createAction(command.getName(), command.getName()));
prevCommand = command;
}
this.commands.addAll(commands);
if (commandToSelect != null) {
setSelectedCommand(commandToSelect);
} else {
selectLastUsedCommand();
}
}
use of org.eclipse.che.ide.api.action.DefaultActionGroup in project che by eclipse.
the class WebExtension method prepareActions.
@Inject
private void prepareActions(WebExtensionResource resources, ActionManager actionManager, NewCssFileAction newCssFileAction, NewLessFileAction newLessFileAction, NewHtmlFileAction newHtmlFileAction, NewJavaScriptFileAction newJavaScriptFileAction, PreviewAction previewAction) {
// register actions
actionManager.registerAction("newCssFile", newCssFileAction);
actionManager.registerAction("newLessFile", newLessFileAction);
actionManager.registerAction("newHtmlFile", newHtmlFileAction);
actionManager.registerAction("newJavaScriptFile", newJavaScriptFileAction);
actionManager.registerAction("previewHTML", previewAction);
// set icons
newCssFileAction.getTemplatePresentation().setSVGResource(resources.cssFile());
newLessFileAction.getTemplatePresentation().setSVGResource(resources.lessFile());
newHtmlFileAction.getTemplatePresentation().setSVGResource(resources.htmlFile());
newJavaScriptFileAction.getTemplatePresentation().setSVGResource(resources.jsFile());
// add actions in main menu
DefaultActionGroup newGroup = (DefaultActionGroup) actionManager.getAction(GROUP_FILE_NEW);
newGroup.add(newCssFileAction);
newGroup.add(newLessFileAction);
newGroup.add(newHtmlFileAction);
newGroup.add(newJavaScriptFileAction);
// add actions in context menu
DefaultActionGroup mainContextMenuGroup = (DefaultActionGroup) actionManager.getAction(GROUP_MAIN_CONTEXT_MENU);
mainContextMenuGroup.add(previewAction);
// add actions in Assistant main menu
DefaultActionGroup assistantMainMenuGroup = (DefaultActionGroup) actionManager.getAction(GROUP_ASSISTANT);
assistantMainMenuGroup.add(previewAction);
}
use of org.eclipse.che.ide.api.action.DefaultActionGroup in project che by eclipse.
the class MyFileTypeExtension method MyFileTypeExtension.
@Inject
public void MyFileTypeExtension(final ActionManager actionManager, final CreateMyFileAction createMyFileAction, final FileTypeRegistry fileTypeRegistry, @Named("MyFileType") final FileType myFileType) {
actionManager.registerAction("createMyFileAction", createMyFileAction);
DefaultActionGroup mainContextMenu = (DefaultActionGroup) actionManager.getAction(GROUP_MAIN_CONTEXT_MENU);
mainContextMenu.add(createMyFileAction);
fileTypeRegistry.registerFileType(myFileType);
}
use of org.eclipse.che.ide.api.action.DefaultActionGroup in project che by eclipse.
the class ActionManagerTest method shouldUnregister.
@Test
public void shouldUnregister() {
DefaultActionGroup defaultActionGroup = new DefaultActionGroup(actionManager);
actionManager.registerAction(IdeActions.GROUP_MAIN_MENU, defaultActionGroup);
actionManager.unregisterAction(IdeActions.GROUP_MAIN_MENU);
Action action = actionManager.getAction(IdeActions.GROUP_MAIN_MENU);
assertNull(action);
}
use of org.eclipse.che.ide.api.action.DefaultActionGroup in project che by eclipse.
the class CppExtension method prepareActions.
@Inject
private void prepareActions(CreateCSourceFileAction newCSourceFileAction, CreateCppSourceFileAction newCppSourceFileAction, CreateHeaderSourceFileAction newHeadSourceFileAction, ActionManager actionManager, CppResources resources, IconRegistry iconRegistry) {
DefaultActionGroup newGroup = (DefaultActionGroup) actionManager.getAction(GROUP_FILE_NEW);
actionManager.registerAction("newCFile", newCSourceFileAction);
actionManager.registerAction("newCppFile", newCppSourceFileAction);
actionManager.registerAction("newHFile", newHeadSourceFileAction);
newGroup.add(newCSourceFileAction, Constraints.FIRST);
newGroup.add(newHeadSourceFileAction, Constraints.FIRST);
newGroup.add(newCppSourceFileAction, Constraints.FIRST);
iconRegistry.registerIcon(new Icon(C_CATEGORY + ".samples.category.icon", resources.category()));
}
Aggregations