use of org.eclipse.che.ide.api.parts.Perspective in project che by eclipse.
the class WorkspacePresenter method loadState.
@Override
public void loadState(JsonObject state) {
if (state.hasKey("perspectives")) {
JsonObject perspectives = state.getObject("perspectives");
Map<String, Perspective> perspectiveMap = perspectiveManagerProvider.get().getPerspectives();
for (String key : perspectives.keys()) {
if (perspectiveMap.containsKey(key)) {
perspectiveMap.get(key).loadState(perspectives.getObject(key));
}
}
}
}
use of org.eclipse.che.ide.api.parts.Perspective in project che by eclipse.
the class WorkspacePresenter method getState.
@Override
public JsonObject getState() {
JsonObject state = Json.createObject();
JsonObject perspectivesJs = Json.createObject();
state.put("perspectives", perspectivesJs);
Map<String, Perspective> perspectives = perspectiveManagerProvider.get().getPerspectives();
for (Map.Entry<String, Perspective> entry : perspectives.entrySet()) {
//store only default perspective
if (entry.getKey().equals(defaultPerspectiveId)) {
perspectivesJs.put(entry.getKey(), entry.getValue().getState());
}
}
return state;
}
use of org.eclipse.che.ide.api.parts.Perspective in project che by eclipse.
the class PerspectiveManagerTest method defaultPerspectiveShouldBeReturned.
@Test
public void defaultPerspectiveShouldBeReturned() {
Perspective perspective = manager.getActivePerspective();
assertThat(perspective, sameInstance(projectPerspective));
}
use of org.eclipse.che.ide.api.parts.Perspective in project che by eclipse.
the class PerspectiveManagerTest method setUp.
@Before
public void setUp() {
Map<String, Perspective> perspectives = new HashMap<>();
perspectives.put("Machine Perspective", machinePerspective);
perspectives.put("Project Perspective", projectPerspective);
manager = new PerspectiveManager(perspectives, "Project Perspective");
}
use of org.eclipse.che.ide.api.parts.Perspective in project che by eclipse.
the class StandardComponentInitializer method initialize.
public void initialize() {
messageLoaderResources.Css().ensureInjected();
editorResources.editorCss().ensureInjected();
popupResources.popupStyle().ensureInjected();
fileTypeRegistry.registerFileType(xmlFile);
fileTypeRegistry.registerFileType(txtFile);
fileTypeRegistry.registerFileType(jsonFile);
fileTypeRegistry.registerFileType(mdFile);
fileTypeRegistry.registerFileType(pngFile);
editorRegistry.registerDefaultEditor(pngFile, imageViewerProvider);
fileTypeRegistry.registerFileType(bmpFile);
editorRegistry.registerDefaultEditor(bmpFile, imageViewerProvider);
fileTypeRegistry.registerFileType(gifFile);
editorRegistry.registerDefaultEditor(gifFile, imageViewerProvider);
fileTypeRegistry.registerFileType(iconFile);
editorRegistry.registerDefaultEditor(iconFile, imageViewerProvider);
fileTypeRegistry.registerFileType(svgFile);
editorRegistry.registerDefaultEditor(svgFile, imageViewerProvider);
fileTypeRegistry.registerFileType(jpeFile);
editorRegistry.registerDefaultEditor(jpeFile, imageViewerProvider);
fileTypeRegistry.registerFileType(jpegFile);
editorRegistry.registerDefaultEditor(jpegFile, imageViewerProvider);
fileTypeRegistry.registerFileType(jpgFile);
editorRegistry.registerDefaultEditor(jpgFile, imageViewerProvider);
// Workspace (New Menu)
DefaultActionGroup workspaceGroup = (DefaultActionGroup) actionManager.getAction(GROUP_WORKSPACE);
actionManager.registerAction(IMPORT_PROJECT, importProjectAction);
workspaceGroup.add(importProjectAction);
actionManager.registerAction(CREATE_PROJECT, createProjectAction);
workspaceGroup.add(createProjectAction);
actionManager.registerAction("downloadWsAsZipAction", downloadWsAction);
workspaceGroup.add(downloadWsAction);
workspaceGroup.addSeparator();
// Project (New Menu)
DefaultActionGroup projectGroup = (DefaultActionGroup) actionManager.getAction(GROUP_PROJECT);
DefaultActionGroup newGroup = new DefaultActionGroup("New", true, actionManager);
newGroup.getTemplatePresentation().setDescription("Create...");
newGroup.getTemplatePresentation().setSVGResource(resources.newResource());
actionManager.registerAction(GROUP_FILE_NEW, newGroup);
projectGroup.add(newGroup);
newGroup.addSeparator();
actionManager.registerAction(NEW_FILE, newFileAction);
newGroup.addAction(newFileAction);
actionManager.registerAction("newFolder", newFolderAction);
newGroup.addAction(newFolderAction);
newGroup.addSeparator();
actionManager.registerAction("newXmlFile", newXmlFileAction);
newXmlFileAction.getTemplatePresentation().setSVGResource(xmlFile.getImage());
newGroup.addAction(newXmlFileAction);
actionManager.registerAction("uploadFile", uploadFileAction);
projectGroup.add(uploadFileAction);
actionManager.registerAction("uploadFolder", uploadFolderAction);
projectGroup.add(uploadFolderAction);
actionManager.registerAction("convertFolderToProject", convertFolderToProjectAction);
projectGroup.add(convertFolderToProjectAction);
actionManager.registerAction("downloadAsZipAction", downloadProjectAction);
projectGroup.add(downloadProjectAction);
actionManager.registerAction("showHideHiddenFiles", showHiddenFilesAction);
projectGroup.add(showHiddenFilesAction);
projectGroup.addSeparator();
actionManager.registerAction("projectConfiguration", projectConfigurationAction);
projectGroup.add(projectConfigurationAction);
// Edit (New Menu)
DefaultActionGroup editGroup = (DefaultActionGroup) actionManager.getAction(GROUP_EDIT);
DefaultActionGroup recentGroup = new DefaultActionGroup(RECENT_GROUP_ID, true, actionManager);
actionManager.registerAction(GROUP_RECENT_FILES, recentGroup);
actionManager.registerAction("clearRecentList", clearRecentFilesAction);
recentGroup.addSeparator();
recentGroup.add(clearRecentFilesAction, LAST);
editGroup.add(recentGroup);
actionManager.registerAction(OPEN_RECENT_FILES, openRecentFilesAction);
editGroup.add(openRecentFilesAction);
editGroup.addSeparator();
actionManager.registerAction(CLOSE_ACTIVE_EDITOR, closeActiveEditorAction);
editGroup.add(closeActiveEditorAction);
actionManager.registerAction(FORMAT, formatterAction);
editGroup.add(formatterAction);
actionManager.registerAction("undo", undoAction);
editGroup.add(undoAction);
actionManager.registerAction("redo", redoAction);
editGroup.add(redoAction);
actionManager.registerAction(CUT, cutResourceAction);
editGroup.add(cutResourceAction);
actionManager.registerAction(COPY, copyResourceAction);
editGroup.add(copyResourceAction);
actionManager.registerAction(PASTE, pasteResourceAction);
editGroup.add(pasteResourceAction);
actionManager.registerAction(RENAME, renameItemAction);
editGroup.add(renameItemAction);
actionManager.registerAction(DELETE_ITEM, deleteResourceAction);
editGroup.add(deleteResourceAction);
actionManager.registerAction(FULL_TEXT_SEARCH, fullTextSearchAction);
editGroup.add(fullTextSearchAction);
editGroup.addSeparator();
editGroup.add(switchPreviousEditorAction);
editGroup.add(switchNextEditorAction);
editGroup.addSeparator();
editGroup.add(revealResourceAction);
// Assistant (New Menu)
DefaultActionGroup assistantGroup = (DefaultActionGroup) actionManager.getAction(GROUP_ASSISTANT);
actionManager.registerAction(FIND_ACTION, findActionAction);
assistantGroup.add(findActionAction);
actionManager.registerAction("hotKeysList", hotKeysListAction);
assistantGroup.add(hotKeysListAction);
assistantGroup.addSeparator();
actionManager.registerAction("callCompletion", completeAction);
assistantGroup.add(completeAction);
actionManager.registerAction("downloadItemAction", downloadResourceAction);
actionManager.registerAction(NAVIGATE_TO_FILE, navigateToFileAction);
assistantGroup.add(navigateToFileAction);
// Compose Save group
DefaultActionGroup saveGroup = new DefaultActionGroup(actionManager);
actionManager.registerAction("saveGroup", saveGroup);
actionManager.registerAction("save", saveAction);
actionManager.registerAction("saveAll", saveAllAction);
saveGroup.addSeparator();
saveGroup.add(saveAction);
saveGroup.add(saveAllAction);
//Compose Profile menu
DefaultActionGroup profileGroup = (DefaultActionGroup) actionManager.getAction(GROUP_PROFILE);
actionManager.registerAction("showPreferences", showPreferencesAction);
profileGroup.add(showPreferencesAction);
// Compose Help menu
DefaultActionGroup helpGroup = (DefaultActionGroup) actionManager.getAction(GROUP_HELP);
helpGroup.addSeparator();
// Compose main context menu
DefaultActionGroup resourceOperation = new DefaultActionGroup(actionManager);
actionManager.registerAction("resourceOperation", resourceOperation);
actionManager.registerAction("refreshPathAction", refreshPathAction);
actionManager.registerAction("linkWithEditor", linkWithEditorAction);
resourceOperation.addSeparator();
resourceOperation.add(showReferenceAction);
resourceOperation.add(goIntoAction);
resourceOperation.add(editFileAction);
resourceOperation.add(cutResourceAction);
resourceOperation.add(copyResourceAction);
resourceOperation.add(pasteResourceAction);
resourceOperation.add(renameItemAction);
resourceOperation.add(deleteResourceAction);
resourceOperation.addSeparator();
resourceOperation.add(downloadResourceAction);
resourceOperation.add(refreshPathAction);
resourceOperation.add(linkWithEditorAction);
resourceOperation.addSeparator();
resourceOperation.add(convertFolderToProjectAction);
resourceOperation.addSeparator();
DefaultActionGroup mainContextMenuGroup = (DefaultActionGroup) actionManager.getAction(GROUP_MAIN_CONTEXT_MENU);
mainContextMenuGroup.add(newGroup, Constraints.FIRST);
mainContextMenuGroup.addSeparator();
mainContextMenuGroup.add(resourceOperation);
DefaultActionGroup partMenuGroup = (DefaultActionGroup) actionManager.getAction(GROUP_PART_MENU);
partMenuGroup.add(maximizePartAction);
partMenuGroup.add(minimizePartAction);
partMenuGroup.add(restorePartAction);
actionManager.registerAction("expandEditor", expandEditorAction);
DefaultActionGroup rightMenuGroup = (DefaultActionGroup) actionManager.getAction(GROUP_RIGHT_MAIN_MENU);
rightMenuGroup.add(expandEditorAction, FIRST);
// Compose main toolbar
DefaultActionGroup changeResourceGroup = new DefaultActionGroup(actionManager);
actionManager.registerAction("changeResourceGroup", changeResourceGroup);
actionManager.registerAction("editFile", editFileAction);
actionManager.registerAction("goInto", goIntoAction);
actionManager.registerAction(SHOW_REFERENCE, showReferenceAction);
actionManager.registerAction("collapseAll", collapseAllAction);
actionManager.registerAction("openFile", openFileAction);
actionManager.registerAction(SWITCH_LEFT_TAB, switchPreviousEditorAction);
actionManager.registerAction(SWITCH_RIGHT_TAB, switchNextEditorAction);
actionManager.registerAction("scrollFromSource", revealResourceAction);
changeResourceGroup.add(cutResourceAction);
changeResourceGroup.add(copyResourceAction);
changeResourceGroup.add(pasteResourceAction);
changeResourceGroup.add(deleteResourceAction);
DefaultActionGroup mainToolbarGroup = (DefaultActionGroup) actionManager.getAction(GROUP_MAIN_TOOLBAR);
mainToolbarGroup.add(newGroup);
mainToolbarGroup.add(changeResourceGroup);
toolbarPresenter.bindMainGroup(mainToolbarGroup);
DefaultActionGroup centerToolbarGroup = (DefaultActionGroup) actionManager.getAction(GROUP_CENTER_TOOLBAR);
toolbarPresenter.bindCenterGroup(centerToolbarGroup);
DefaultActionGroup rightToolbarGroup = (DefaultActionGroup) actionManager.getAction(GROUP_RIGHT_TOOLBAR);
toolbarPresenter.bindRightGroup(rightToolbarGroup);
//Editor context menu group
DefaultActionGroup editorTabContextMenu = (DefaultActionGroup) actionManager.getAction(GROUP_EDITOR_TAB_CONTEXT_MENU);
editorTabContextMenu.add(closeAction);
actionManager.registerAction(CLOSE, closeAction);
editorTabContextMenu.add(closeAllAction);
actionManager.registerAction(CLOSE_ALL, closeAllAction);
editorTabContextMenu.add(closeOtherAction);
actionManager.registerAction(CLOSE_OTHER, closeOtherAction);
editorTabContextMenu.add(closeAllExceptPinnedAction);
actionManager.registerAction(CLOSE_ALL_EXCEPT_PINNED, closeAllExceptPinnedAction);
editorTabContextMenu.addSeparator();
editorTabContextMenu.add(reopenClosedFileAction);
actionManager.registerAction(REOPEN_CLOSED, reopenClosedFileAction);
editorTabContextMenu.add(pinEditorTabAction);
actionManager.registerAction(PIN_TAB, pinEditorTabAction);
editorTabContextMenu.addSeparator();
actionManager.registerAction(SPLIT_HORIZONTALLY, splitHorizontallyAction);
editorTabContextMenu.add(splitHorizontallyAction);
actionManager.registerAction(SPLIT_VERTICALLY, splitVerticallyAction);
editorTabContextMenu.add(splitVerticallyAction);
actionManager.registerAction(SIGNATURE_HELP, signatureHelpAction);
DefaultActionGroup editorContextMenuGroup = new DefaultActionGroup(actionManager);
actionManager.registerAction(GROUP_EDITOR_CONTEXT_MENU, editorContextMenuGroup);
editorContextMenuGroup.add(undoAction);
editorContextMenuGroup.add(redoAction);
editorContextMenuGroup.addSeparator();
editorContextMenuGroup.add(formatterAction);
editorContextMenuGroup.addSeparator();
editorContextMenuGroup.add(fullTextSearchAction);
editorContextMenuGroup.add(closeActiveEditorAction);
// Define hot-keys
keyBinding.getGlobal().addKey(new KeyBuilder().action().alt().charCode('n').build(), NAVIGATE_TO_FILE);
keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode('F').build(), FULL_TEXT_SEARCH);
keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode('A').build(), FIND_ACTION);
keyBinding.getGlobal().addKey(new KeyBuilder().alt().charCode('L').build(), FORMAT);
keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode('c').build(), COPY);
keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode('x').build(), CUT);
keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode('v').build(), PASTE);
keyBinding.getGlobal().addKey(new KeyBuilder().shift().charCode(KeyCodeMap.F6).build(), RENAME);
keyBinding.getGlobal().addKey(new KeyBuilder().shift().charCode(KeyCodeMap.F7).build(), SHOW_REFERENCE);
keyBinding.getGlobal().addKey(new KeyBuilder().alt().charCode(KeyCodeMap.ARROW_LEFT).build(), SWITCH_LEFT_TAB);
keyBinding.getGlobal().addKey(new KeyBuilder().alt().charCode(KeyCodeMap.ARROW_RIGHT).build(), SWITCH_RIGHT_TAB);
keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode('e').build(), OPEN_RECENT_FILES);
keyBinding.getGlobal().addKey(new KeyBuilder().charCode(KeyCodeMap.DELETE).build(), DELETE_ITEM);
keyBinding.getGlobal().addKey(new KeyBuilder().alt().charCode('N').build(), NEW_FILE);
keyBinding.getGlobal().addKey(new KeyBuilder().alt().charCode('x').build(), CREATE_PROJECT);
keyBinding.getGlobal().addKey(new KeyBuilder().alt().charCode('A').build(), IMPORT_PROJECT);
if (UserAgent.isMac()) {
keyBinding.getGlobal().addKey(new KeyBuilder().control().charCode('w').build(), CLOSE_ACTIVE_EDITOR);
keyBinding.getGlobal().addKey(new KeyBuilder().control().charCode('p').build(), SIGNATURE_HELP);
} else {
keyBinding.getGlobal().addKey(new KeyBuilder().alt().charCode('w').build(), CLOSE_ACTIVE_EDITOR);
keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode('p').build(), SIGNATURE_HELP);
}
final Map<String, Perspective> perspectives = perspectiveManager.getPerspectives();
if (perspectives.size() > 1) {
//if registered perspectives will be more then 2 Main Menu -> Window
// will appears and contains all of them as sub-menu
final DefaultActionGroup windowMenu = new DefaultActionGroup("Window", true, actionManager);
actionManager.registerAction("Window", windowMenu);
final DefaultActionGroup mainMenu = (DefaultActionGroup) actionManager.getAction(GROUP_MAIN_MENU);
mainMenu.add(windowMenu);
for (Perspective perspective : perspectives.values()) {
final Action action = new Action(perspective.getPerspectiveName()) {
@Override
public void actionPerformed(ActionEvent e) {
perspectiveManager.setPerspectiveId(perspective.getPerspectiveId());
}
};
actionManager.registerAction(perspective.getPerspectiveId(), action);
windowMenu.add(action);
}
}
}
Aggregations