use of org.eclipse.che.ide.api.constraints.Constraints in project che by eclipse.
the class EditorAgentImpl method restoreSplit.
private List<Promise<Void>> restoreSplit(JsonObject files, EditorPartStack editorPartStack, Map<EditorPartPresenter, EditorPartStack> activeEditors) {
JsonObject splitFirst = files.getObject("SPLIT_FIRST");
String direction = files.getString("DIRECTION");
double size = files.getNumber("SIZE");
EditorPartStack split = editorMultiPartStack.split(editorPartStack, new Constraints(Direction.valueOf(direction), null), size);
List<Promise<Void>> restoreFirst = restore(splitFirst, editorPartStack, activeEditors);
JsonObject splitSecond = files.getObject("SPLIT_SECOND");
List<Promise<Void>> restoreSecond = restore(splitSecond, split, activeEditors);
List<Promise<Void>> result = new ArrayList<>();
result.addAll(restoreFirst);
result.addAll(restoreSecond);
return result;
}
use of org.eclipse.che.ide.api.constraints.Constraints in project che by eclipse.
the class JavaExtension method prepareActions.
@Inject
private void prepareActions(NewPackageAction newPackageAction, KeyBindingAgent keyBinding, NewJavaSourceFileAction newJavaSourceFileAction, ActionManager actionManager, ProjectClasspathAction projectClasspathAction, MoveAction moveAction, CutJavaSourceAction cutAction, FileStructureAction fileStructureAction, MarkDirAsSourceAction markDirAsSourceAction, UnmarkDirAsSourceAction unmarkDirAsSourceAction, MarkDirectoryAsGroup markDirectoryAsGroup, OrganizeImportsAction organizeImportsAction, RenameRefactoringAction renameRefactoringAction, QuickDocumentationAction quickDocumentationAction, QuickFixAction quickFixAction, OpenDeclarationAction openDeclarationAction, OpenImplementationAction openImplementationAction, FindUsagesAction findUsagesAction, ParametersHintsAction parametersHintsAction) {
DefaultActionGroup newGroup = (DefaultActionGroup) actionManager.getAction(GROUP_FILE_NEW);
actionManager.registerAction("newJavaClass", newJavaSourceFileAction);
newGroup.add(newJavaSourceFileAction, Constraints.FIRST);
actionManager.registerAction("newJavaPackage", newPackageAction);
newGroup.add(newPackageAction, new Constraints(Anchor.AFTER, "newJavaClass"));
DefaultActionGroup refactorGroup = (DefaultActionGroup) actionManager.getAction(GROUP_ASSISTANT_REFACTORING);
if (refactorGroup == null) {
refactorGroup = new DefaultActionGroup("Refactoring", true, actionManager);
actionManager.registerAction(GROUP_ASSISTANT_REFACTORING, refactorGroup);
}
DefaultActionGroup projectGroup = (DefaultActionGroup) actionManager.getAction(GROUP_PROJECT);
actionManager.registerAction("projectProperties", projectClasspathAction);
projectGroup.add(projectClasspathAction, new Constraints(Anchor.LAST, null));
DefaultActionGroup assistantGroup = (DefaultActionGroup) actionManager.getAction(GROUP_ASSISTANT);
refactorGroup.addSeparator();
refactorGroup.add(moveAction);
refactorGroup.add(renameRefactoringAction);
assistantGroup.add(refactorGroup, new Constraints(Anchor.BEFORE, "updateDependency"));
actionManager.registerAction(SHOW_QUICK_DOC, quickDocumentationAction);
actionManager.registerAction(OPEN_JAVA_DECLARATION, openDeclarationAction);
actionManager.registerAction(OPEN_IMPLEMENTATION, openImplementationAction);
actionManager.registerAction(JAVA_RENAME_REFACTORING, renameRefactoringAction);
actionManager.registerAction(JAVA_MOVE_REFACTORING, moveAction);
actionManager.registerAction(JAVA_CUT_REFACTORING, cutAction);
actionManager.registerAction(JAVA_FIND_USAGES, findUsagesAction);
actionManager.registerAction(JAVA_CLASS_STRUCTURE, fileStructureAction);
actionManager.registerAction(ORGANIZE_IMPORTS, organizeImportsAction);
actionManager.registerAction(PARAMETERS_INFO, parametersHintsAction);
actionManager.registerAction(QUICK_FIX, quickFixAction);
assistantGroup.add(quickDocumentationAction, new Constraints(Anchor.BEFORE, GROUP_ASSISTANT_REFACTORING));
assistantGroup.add(quickFixAction, new Constraints(Anchor.BEFORE, GROUP_ASSISTANT_REFACTORING));
assistantGroup.add(openDeclarationAction, new Constraints(Anchor.BEFORE, GROUP_ASSISTANT_REFACTORING));
assistantGroup.add(organizeImportsAction, new Constraints(Anchor.BEFORE, GROUP_ASSISTANT_REFACTORING));
assistantGroup.add(openImplementationAction, new Constraints(Anchor.BEFORE, GROUP_ASSISTANT_REFACTORING));
assistantGroup.add(fileStructureAction, new Constraints(Anchor.BEFORE, GROUP_ASSISTANT_REFACTORING));
assistantGroup.add(findUsagesAction, new Constraints(Anchor.BEFORE, GROUP_ASSISTANT_REFACTORING));
//Configure Build Path action group
actionManager.registerAction("markDirectoryAsSourceGroup", markDirectoryAsGroup);
actionManager.registerAction("markDirectoryAsSource", markDirAsSourceAction);
actionManager.registerAction("unmarkDirectoryAsSource", unmarkDirAsSourceAction);
markDirectoryAsGroup.add(markDirAsSourceAction);
markDirectoryAsGroup.add(unmarkDirAsSourceAction);
markDirectoryAsGroup.add(projectClasspathAction);
DefaultActionGroup mainContextMenuGroup = (DefaultActionGroup) actionManager.getAction("resourceOperation");
mainContextMenuGroup.addSeparator();
mainContextMenuGroup.add(markDirectoryAsGroup);
mainContextMenuGroup.addSeparator();
DefaultActionGroup editorContextMenuGroup = (DefaultActionGroup) actionManager.getAction(IdeActions.GROUP_EDITOR_CONTEXT_MENU);
editorContextMenuGroup.add(quickDocumentationAction, new Constraints(Anchor.AFTER, "format"));
editorContextMenuGroup.add(quickFixAction, new Constraints(Anchor.AFTER, SHOW_QUICK_DOC));
editorContextMenuGroup.add(openDeclarationAction, new Constraints(Anchor.AFTER, QUICK_FIX));
editorContextMenuGroup.add(refactorGroup, new Constraints(Anchor.AFTER, OPEN_JAVA_DECLARATION));
editorContextMenuGroup.add(fileStructureAction, new Constraints(Anchor.AFTER, GROUP_ASSISTANT_REFACTORING));
if (UserAgent.isMac()) {
keyBinding.getGlobal().addKey(new KeyBuilder().alt().control().charCode('b').build(), OPEN_IMPLEMENTATION);
keyBinding.getGlobal().addKey(new KeyBuilder().control().charCode('j').build(), SHOW_QUICK_DOC);
keyBinding.getGlobal().addKey(new KeyBuilder().control().charCode(KeyCodeMap.F12).build(), JAVA_CLASS_STRUCTURE);
keyBinding.getGlobal().addKey(new KeyBuilder().alt().control().charCode('o').build(), ORGANIZE_IMPORTS);
keyBinding.getGlobal().addKey(new KeyBuilder().control().charCode('p').build(), PARAMETERS_INFO);
keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode(KeyCodeMap.ENTER).build(), QUICK_FIX);
} else {
keyBinding.getGlobal().addKey(new KeyBuilder().alt().action().charCode('b').build(), OPEN_IMPLEMENTATION);
keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode('q').build(), SHOW_QUICK_DOC);
keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode(KeyCodeMap.F12).build(), JAVA_CLASS_STRUCTURE);
keyBinding.getGlobal().addKey(new KeyBuilder().alt().action().charCode('o').build(), ORGANIZE_IMPORTS);
keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode('p').build(), PARAMETERS_INFO);
keyBinding.getGlobal().addKey(new KeyBuilder().alt().charCode(KeyCodeMap.ENTER).build(), QUICK_FIX);
}
keyBinding.getGlobal().addKey(new KeyBuilder().none().charCode(KeyCodeMap.F4).build(), OPEN_JAVA_DECLARATION);
keyBinding.getGlobal().addKey(new KeyBuilder().shift().charCode(KeyCodeMap.F6).build(), JAVA_RENAME_REFACTORING);
keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode('x').build(), JAVA_CUT_REFACTORING);
keyBinding.getGlobal().addKey(new KeyBuilder().charCode(KeyCodeMap.F6).build(), JAVA_MOVE_REFACTORING);
keyBinding.getGlobal().addKey(new KeyBuilder().alt().charCode(KeyCodeMap.F7).build(), JAVA_FIND_USAGES);
}
use of org.eclipse.che.ide.api.constraints.Constraints in project che by eclipse.
the class SplitHorizontallyAction method actionPerformed.
/** {@inheritDoc} */
@Override
public void actionPerformed(ActionEvent event) {
final String tabId = getEditorTab(event).getId();
final VirtualFile file = getEditorFile(event);
final Constraints constraints = new Constraints(HORIZONTALLY, tabId);
editorAgent.openEditor(file, constraints);
}
use of org.eclipse.che.ide.api.constraints.Constraints in project che by eclipse.
the class DefaultActionGroupTest method shouldResortAllActionsAfterAddingOne.
@Test
public void shouldResortAllActionsAfterAddingOne() {
// add some actions
defaultActionGroup.add(firstAction);
when(actionManager.getId(eq(firstAction))).thenReturn("firstAction");
defaultActionGroup.add(secondAction, Constraints.FIRST);
when(actionManager.getId(eq(secondAction))).thenReturn("secondAction");
defaultActionGroup.add(thirdAction, new Constraints(AFTER, "fourthAction"));
when(actionManager.getId(eq(thirdAction))).thenReturn("thirdAction");
// verify order
Action[] result = defaultActionGroup.getChildren(mock(ActionEvent.class));
assertThat(Arrays.asList(result)).containsExactly(secondAction, firstAction, thirdAction);
// add other actions
defaultActionGroup.add(fourthAction);
when(actionManager.getId(eq(thirdAction))).thenReturn("thirdAction");
defaultActionGroup.add(fifthAction, Constraints.FIRST);
when(actionManager.getId(eq(fifthAction))).thenReturn("fifthAction");
defaultActionGroup.add(sixthAction, new Constraints(BEFORE, "firstAction"));
when(actionManager.getId(eq(sixthAction))).thenReturn("sixthAction");
// verify that actions have been resorted
Action[] newResult = defaultActionGroup.getChildren(mock(ActionEvent.class));
assertThat(Arrays.asList(newResult)).hasSize(6).containsExactly(fifthAction, secondAction, sixthAction, firstAction, fourthAction, thirdAction);
}
use of org.eclipse.che.ide.api.constraints.Constraints in project che by eclipse.
the class DefaultActionGroupTest method shouldNotAddSameActionTwice.
@Test
public void shouldNotAddSameActionTwice() {
Action action = mock(Action.class);
defaultActionGroup.add(action, new Constraints(AFTER, "someAction"));
defaultActionGroup.add(action, new Constraints(BEFORE, "someAction"));
assertThat(defaultActionGroup.getChildrenCount()).isEqualTo(1);
}
Aggregations