use of org.eclipse.che.ide.api.action.DefaultActionGroup in project che by eclipse.
the class NodeJsExtension method prepareActions.
@Inject
private void prepareActions(ActionManager actionManager, NodeJsResources resources, IconRegistry iconRegistry, NewNodeJsFileAction newFileAction) {
DefaultActionGroup newGroup = (DefaultActionGroup) actionManager.getAction(GROUP_FILE_NEW);
actionManager.registerAction("newNodeJsFile", newFileAction);
newGroup.add(newFileAction, Constraints.FIRST);
iconRegistry.registerIcon(new Icon(NODE_JS_CATEGORY + ".samples.category.icon", resources.jsIcon()));
}
use of org.eclipse.che.ide.api.action.DefaultActionGroup in project che by eclipse.
the class CommandProducerActionManager method createActionsForMachine.
/**
* Creates actions for that {@link CommandProducer}s
* which are applicable for the given machine's type.
*/
private void createActionsForMachine(Machine machine) {
for (CommandProducer commandProducer : commandProducers) {
if (commandProducer.getMachineTypes().contains(machine.getConfig().getType())) {
CommandProducerAction machineAction = commandProducerActionFactory.create(machine.getConfig().getName(), commandProducer, machine);
List<Action> actionList = actionsByMachines.get(machine);
if (actionList == null) {
actionList = new ArrayList<>();
actionsByMachines.put(machine, actionList);
}
actionList.add(machineAction);
actionManager.registerAction(machine.getConfig().getName(), machineAction);
DefaultActionGroup actionGroup = producersToActionGroups.get(commandProducer);
if (actionGroup != null) {
actionGroup.add(machineAction);
actionsToActionGroups.put(machineAction, actionGroup);
}
}
}
}
use of org.eclipse.che.ide.api.action.DefaultActionGroup in project che by eclipse.
the class CommandProducerActionManager method createActionsForProducer.
/** Creates actions for the given {@link CommandProducer}. */
private void createActionsForProducer(CommandProducer producer) {
Action action;
if (producer.getMachineTypes().isEmpty()) {
action = commandProducerActionFactory.create(producer.getName(), producer, appContext.getDevMachine().getDescriptor());
actionManager.registerAction(producer.getName(), action);
} else {
action = new DefaultActionGroup(producer.getName(), true, actionManager);
producersToActionGroups.put(producer, (DefaultActionGroup) action);
actionManager.registerAction(producer.getName(), action);
for (Machine machine : machines) {
createActionsForMachine(machine);
}
}
commandActionsPopUpGroup.add(action);
}
use of org.eclipse.che.ide.api.action.DefaultActionGroup in project che by eclipse.
the class EditorTabContextMenu method updateActions.
protected ActionGroup updateActions() {
final ActionGroup mainActionGroup = (ActionGroup) actionManager.getAction(getGroupMenu());
if (mainActionGroup == null) {
return new DefaultActionGroup(actionManager);
}
final Action[] children = mainActionGroup.getChildren(null);
for (final Action action : children) {
final Presentation presentation = presentationFactory.getPresentation(action);
//pass into action properties
presentation.putClientProperty(CURRENT_FILE_PROP, editorTab.getFile());
presentation.putClientProperty(CURRENT_TAB_PROP, editorTab);
presentation.putClientProperty(CURRENT_PANE_PROP, editorPartStack);
}
return super.updateActions();
}
use of org.eclipse.che.ide.api.action.DefaultActionGroup in project che by eclipse.
the class SelectCommandComboBox method updateMachineActions.
private void updateMachineActions() {
machinesActions.removeAll();
final DefaultActionGroup actionList = (DefaultActionGroup) actionManager.getAction(GROUP_MACHINES_LIST);
if (actionList != null) {
machinesActions.addAll(actionList);
}
if (registeredMachineMap.isEmpty()) {
return;
}
final List<Map.Entry<String, Machine>> machineEntryList = new LinkedList(registeredMachineMap.entrySet());
// defined MachineDto Comparator here
Collections.sort(machineEntryList, new MachineListEntryComparator());
String machineCategory = null;
for (Map.Entry<String, Machine> machineEntry : machineEntryList) {
final Machine machine = machineEntry.getValue();
final MachineConfig machineConfig = machine.getConfig();
if (!this.getMachineCategory(machineConfig).equals(machineCategory)) {
machineCategory = this.getMachineCategory(machineConfig);
machinesActions.addSeparator(machineCategory);
}
machinesActions.add(machinesListWidget.createAction(machine.getId(), machineConfig.getName()));
}
machinesListWidget.updatePopup();
if (machinesListWidget.getSelectedName() == null && machinesActions.getChildrenCount() > 0) {
Machine firstMachine = machineEntryList.get(0).getValue();
if (firstMachine == null) {
return;
}
machinesListWidget.selectElement(firstMachine.getId(), firstMachine.getConfig().getName());
}
}
Aggregations