diff options
author | Eric Moffatt <emoffatt@ca.ibm.com> | 2016-06-29 10:19:40 -0400 |
---|---|---|
committer | Eric Moffatt <emoffatt@ca.ibm.com> | 2016-06-29 10:19:40 -0400 |
commit | 6c05991c08f56e769d01f1558f46fecc3b7ac541 (patch) | |
tree | 18fe6b444c7c4ba037c0004a7067eded1830553a | |
parent | cb96bcdc01a77dd9ef1cedd5e3f524aa00ceb816 (diff) | |
download | org.eclipse.orion.client-origin/JSONMenus.zip org.eclipse.orion.client-origin/JSONMenus.tar.gz org.eclipse.orion.client-origin/JSONMenus.tar.bz2 |
Code Edit workorigin/JSONMenus
9 files changed, 116 insertions, 36 deletions
diff --git a/bundles/org.eclipse.orion.client.ui/web/embeddedEditor/builder/buildFrom/emptyGlobalCommands.js b/bundles/org.eclipse.orion.client.ui/web/embeddedEditor/builder/buildFrom/emptyGlobalCommands.js index 15b7eaa..832b3cf 100644 --- a/bundles/org.eclipse.orion.client.ui/web/embeddedEditor/builder/buildFrom/emptyGlobalCommands.js +++ b/bundles/org.eclipse.orion.client.ui/web/embeddedEditor/builder/buildFrom/emptyGlobalCommands.js @@ -9,7 +9,30 @@ * Contributors: IBM Corporation - initial API and implementation
******************************************************************************/
/*eslint-env browser, amd*/
-define([], function() {
+define(['orion/keyAssist', 'orion/commands', 'i18n!orion/nls/messages'], function(mKeyAssist, mCommands, messages) {
+ var keyAssist;
+ function createKeyAssistCommand(commandRegistry) {
+ keyAssist = new mKeyAssist.KeyAssistPanel({
+ commandRegistry: commandRegistry
+ });
+ var keyAssistCommand = new mCommands.Command({
+ name: messages["Show Keys"],
+ tooltip: messages["ShowAllKeyBindings"],
+ id: "orion.keyAssist", //$NON-NLS-0$
+ callback: function () {
+ if (keyAssist.isVisible()) {
+ keyAssist.hide();
+ } else {
+ keyAssist.show();
+ }
+ return true;
+ }
+ });
+ commandRegistry.addCommand(keyAssistCommand);
+ return keyAssistCommand;
+ }
+
return {
+ createKeyAssistCommand: createKeyAssistCommand,
};
});
\ No newline at end of file diff --git a/bundles/org.eclipse.orion.client.ui/web/embeddedEditor/builder/embeddedEditor.js b/bundles/org.eclipse.orion.client.ui/web/embeddedEditor/builder/embeddedEditor.js index 2f05183..0172c6d 100644 --- a/bundles/org.eclipse.orion.client.ui/web/embeddedEditor/builder/embeddedEditor.js +++ b/bundles/org.eclipse.orion.client.ui/web/embeddedEditor/builder/embeddedEditor.js @@ -10,6 +10,7 @@ ******************************************************************************/ /*eslint-env browser, amd*/ define([ + 'orion/globalCommands', 'orion/commandRegistry', 'orion/fileClient', 'orion/contentTypes', @@ -23,6 +24,7 @@ define([ 'orion/defaultEditorPreferences', 'orion/objects' ], function( + mGlobalCommands, mCommandRegistry, mFileClient, mContentTypes, @@ -45,6 +47,36 @@ define([ } var once; objects.mixin(CodeEdit.prototype, { + createContextMenuStructure: function() { + var menuStructure = { + scopeId: "editorContextMenuActions", + pathRoot: "orion.menuBarJSONGroup", + items: [ + { groupId: "json.test.mainGroup", items: [ + {commandId: "orion.keyAssist" }, + {commandId: "open.js.decl" }, + {commandId: "open.js.impl" }, + {commandId: "orion.edit.blame" }, + {commandId: "orion.edit.convert.crlf" }, + {commandId: "orion.edit.convert.lf" }, + {commandId: "orion.edit.diff" }, + {commandId: "orion.edit.find" }, + {commandId: "orion.edit.gotoLine" }, + {commandId: "orion.edit.openFolder" }, + {commandId: "orion.edit.redo" }, + {commandId: "orion.edit.reloadWithEncoding" }, + {commandId: "orion.edit.save" }, + {commandId: "orion.edit.settings" }, + {commandId: "orion.edit.showTooltip" }, + {commandId: "orion.edit.undo" }, + {commandId: "project.js.refs" }, + {commandId: "rename.js.element" }, + ] } + ] + }; + return menuStructure; + }, + _init: function(core) { if(once) { return once; @@ -65,6 +97,7 @@ define([ commandRegistry: this._commandRegistry, fileClient: this._fileClient, toolbarId: this._toolbarId, + editorContextMenuId: "editorContextMenuActions", navToolbarId: this._toolbarId }); this._editorConfig = this._startupOptions && this._startupOptions.editorConfig ? this._startupOptions.editorConfig : {}; @@ -80,6 +113,11 @@ define([ this.serviceRegistry.registerService("orion.page.progress", this._progressService); once = this._editorCommands.createCommands().then(function() { this._editorCommands.registerCommands(); + this._editorCommands.registerContextMenuCommands(); + + // Key assist + mGlobalCommands.createKeyAssistCommand(this._commandRegistry); + this._commandRegistry.loadJSONDefinition(this.createContextMenuStructure()); return new Deferred().resolve(); }.bind(this)); //once.resolve(); @@ -116,6 +154,7 @@ define([ editorCommands: this._editorCommands, editorConfig: this._editorConfig, progressService: this._progressService, + editorContextMenuId: "editorContextMenuActions", toolbarId: this._toolbarId }); return editorHelper.createEditor(options); diff --git a/bundles/org.eclipse.orion.client.ui/web/embeddedEditor/demo/demoCodeEdit.html b/bundles/org.eclipse.orion.client.ui/web/embeddedEditor/demo/demoCodeEdit.html index b6ad8d3..b9344a5 100644 --- a/bundles/org.eclipse.orion.client.ui/web/embeddedEditor/demo/demoCodeEdit.html +++ b/bundles/org.eclipse.orion.client.ui/web/embeddedEditor/demo/demoCodeEdit.html @@ -17,7 +17,15 @@ text: 'requirejs/text', i18n: 'requirejs/i18n', domReady: 'requirejs/domReady', - 'orion/searchAndReplace/textSearcher': '/embeddedEditor/builder/buildFrom/textSearcher' + "orion/globalCommands": "embeddedEditor/builder/buildFrom/emptyGlobalCommands", + 'orion/webui/dialogs/OpenResourceDialog': 'embeddedEditor/builder/buildFrom/OpenResourceDialog', + 'orion/explorers/navigatorRenderer': 'embeddedEditor/builder/buildFrom/navigatorRenderer', + 'examples/editor/textStyler': 'embeddedEditor/builder/buildFrom/emptyTextStyler', + 'orion/widgets/settings/EditorSettings': 'embeddedEditor/builder/buildFrom/EditorSettings', + 'orion/searchAndReplace/textSearcher': 'embeddedEditor/builder/buildFrom/textSearcher', + 'orion/editorPreferences': 'embeddedEditor/builder/buildFrom/editorPreferences', + 'orion/widgets/themes/ThemePreferences': 'embeddedEditor/builder/buildFrom/ThemePreferences', + 'orion/widgets/themes/editor/ThemeData': 'embeddedEditor/builder/buildFrom/ThemeData' } }); require(["embeddedEditor/demo/demoCodeEdit"]); @@ -42,11 +50,13 @@ <div class="embeddedEditorDemoTextParent"> <span id = "progressMessageDiv">Loading language tooling plugins...</span> </div> - <!-- - <div class="embeddedEditorTool" id="__toolbar__"> - <span id = "progressMessageDiv"></span> + <div id="pageContent"> + <div id="pageToolbar"> + <div class="embeddedEditorTool" id="__toolbar__"> + <span id = "progressMessageDiv"></span> + </div> + </div> </div> - --> <div class="embeddedEditorParentOuter" id="embeddedEditor"> </div> <div class="embeddedEditorParentOuter" id="embeddedEditor1"> diff --git a/bundles/org.eclipse.orion.client.ui/web/embeddedEditor/demo/demoCodeEdit.js b/bundles/org.eclipse.orion.client.ui/web/embeddedEditor/demo/demoCodeEdit.js index 3f92d74..a4fa81d 100644 --- a/bundles/org.eclipse.orion.client.ui/web/embeddedEditor/demo/demoCodeEdit.js +++ b/bundles/org.eclipse.orion.client.ui/web/embeddedEditor/demo/demoCodeEdit.js @@ -40,8 +40,8 @@ Deferred) { var embeddedEditor = new mEmbeddedEditor({
_defaultPlugins: defaultPluginURLs,
//defaultPlugins: [],
- editorConfig: {showWhitespaces: true, zoomRuler: true, zoomRulerLocalVisible: true}/*,
- toolbarId: "__toolbar__",
+ editorConfig: {showWhitespaces: true, zoomRuler: true, zoomRulerLocalVisible: true},
+ toolbarId: "__toolbar__"/*,
userPlugins:["editorCommandsPlugin.html"]*/});
var cto = {
id: "foo/bar",
diff --git a/bundles/org.eclipse.orion.client.ui/web/embeddedEditor/embeddedEditor.css b/bundles/org.eclipse.orion.client.ui/web/embeddedEditor/embeddedEditor.css index 0de07c0..2a0c7cf 100644 --- a/bundles/org.eclipse.orion.client.ui/web/embeddedEditor/embeddedEditor.css +++ b/bundles/org.eclipse.orion.client.ui/web/embeddedEditor/embeddedEditor.css @@ -1,5 +1,6 @@ @import "../orion/editor/editor.css"; @import "../css/layout.css"; +@import "../css/controls.css"; @import "../css/theme.css"; @import "./widgetCommon.css"; diff --git a/bundles/org.eclipse.orion.client.ui/web/embeddedEditor/helper/editorSetup.js b/bundles/org.eclipse.orion.client.ui/web/embeddedEditor/helper/editorSetup.js index 809d176..3351189 100644 --- a/bundles/org.eclipse.orion.client.ui/web/embeddedEditor/helper/editorSetup.js +++ b/bundles/org.eclipse.orion.client.ui/web/embeddedEditor/helper/editorSetup.js @@ -92,8 +92,8 @@ define([ setActiveEditorView: function(eView) {
this._editorCommands.updateCommands(eView);
- this._commandRegistry.destroy(this._toolbarId);
- this._commandRegistry.renderCommands(this._toolbarId, this._toolbarId, this._inputManager.getFileMetadata(), eView.editor, "tool"); //$NON-NLS-0$
+// this._commandRegistry.destroy(this._toolbarId);
+// this._commandRegistry.renderCommands(this._toolbarId, "pageToolbar", this._inputManager.getFileMetadata(), eView.editor, "menu"); //$NON-NLS-0$
},
createEditor: function(options, startupOptions) {
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/commandRegistry.js b/bundles/org.eclipse.orion.client.ui/web/orion/commandRegistry.js index 0f92d96..b149da7 100644 --- a/bundles/org.eclipse.orion.client.ui/web/orion/commandRegistry.js +++ b/bundles/org.eclipse.orion.client.ui/web/orion/commandRegistry.js @@ -820,7 +820,7 @@ define([ _createFileMenuStruct: function() { var menuStructure = { - scopeId: "jsonActions", + scopeId: "editorContextMenuActions", pathRoot: "orion.menuBarJSONGroup", items: [ { groupId: "json.newContentGroup", title: "New", items: [ @@ -897,10 +897,10 @@ define([ _createTestMenuStruct: function() { var testStructure = { - scopeId: "jsonActions", + scopeId: "editorContextMenuActions", pathRoot: "orion.menuBarJSONGroup", items: [ - { groupId: "json.test.mainGroup", items: [] } + { groupId: "json.test.mainGroup", items: [ {commandId: "orion.keyAssist" } ] } ] }; @@ -923,9 +923,10 @@ define([ return testStructure; }, - loadJSONDefinition: function(JSONFile) { - var menuStructure = this._createTestMenuStruct(); - this._registerMenuItems(menuStructure. scopeId, menuStructure.pathRoot, menuStructure.items, 0); + loadJSONDefinition: function(menuStructure) { + if (!menuStructure) + menuStructure = this._createTestMenuStruct(); + this._registerMenuItems(menuStructure.scopeId, menuStructure.pathRoot, menuStructure.items, 0); }, /** @@ -1171,8 +1172,8 @@ define([ selectionService.getSelections(function(selections) { self.renderCommands(scopeId, parent, selections, handler, renderType, userData); }); + return; } - return; } if (contributions) { this._render(scopeId, contributions, parent, items, handler, renderType || "button", userData, domNodeWrapperList); //$NON-NLS-0$ diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/editorCommands.js b/bundles/org.eclipse.orion.client.ui/web/orion/editorCommands.js index e0f4f9a..1ce6286 100644 --- a/bundles/org.eclipse.orion.client.ui/web/orion/editorCommands.js +++ b/bundles/org.eclipse.orion.client.ui/web/orion/editorCommands.js @@ -1020,7 +1020,7 @@ define([ if (info.editor && editor.id && info.editor !== editor.id) { return false; } - if (that.inputManager.getReadOnly()) { + if (inputManager.getReadOnly()) { return false; } return !commandVisibleWhen || commandVisibleWhen(items); diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/globalCommands.js b/bundles/org.eclipse.orion.client.ui/web/orion/globalCommands.js index 0243ddd..4d23f8e 100644 --- a/bundles/org.eclipse.orion.client.ui/web/orion/globalCommands.js +++ b/bundles/org.eclipse.orion.client.ui/web/orion/globalCommands.js @@ -555,11 +555,32 @@ define([ return keyAssist; } + function createKeyAssistCommand(commandRegistry) { + keyAssist = new mKeyAssist.KeyAssistPanel({ + commandRegistry: commandRegistry + }); + var keyAssistCommand = new mCommands.Command({ + name: messages["Show Keys"], + tooltip: messages["ShowAllKeyBindings"], + id: "orion.keyAssist", //$NON-NLS-0$ + callback: function () { + if (keyAssist.isVisible()) { + keyAssist.hide(); + } else { + keyAssist.show(); + } + return true; + } + }); + commandRegistry.addCommand(keyAssistCommand); + return keyAssistCommand; + } + var globalEventTarget = new EventTarget(); function getGlobalEventTarget() { return globalEventTarget; } - + /** * Generates the banner at the top of a page. * @@ -828,23 +849,7 @@ define([ commandRegistry.registerCommandContribution("globalActions", "orion.backgroundOperations", 100, null, true, new KeyBinding.KeyBinding('o', true, true)); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$ // Key assist - keyAssist = new mKeyAssist.KeyAssistPanel({ - commandRegistry: commandRegistry - }); - var keyAssistCommand = new mCommands.Command({ - name: messages["Show Keys"], - tooltip: messages["ShowAllKeyBindings"], - id: "orion.keyAssist", //$NON-NLS-0$ - callback: function () { - if (keyAssist.isVisible()) { - keyAssist.hide(); - } else { - keyAssist.show(); - } - return true; - } - }); - commandRegistry.addCommand(keyAssistCommand); + var keyAssistCommand = createKeyAssistCommand(commandRegistry); commandRegistry.registerCommandContribution("globalActions", "orion.keyAssist", 100, null, true, new KeyBinding.KeyBinding(191, false, true)); //$NON-NLS-1$ //$NON-NLS-0$ renderGlobalCommands(commandRegistry); @@ -874,6 +879,7 @@ define([ layoutToolbarElements: layoutToolbarElements, setPageTarget: setPageTarget, setDirtyIndicator: setDirtyIndicator, + createKeyAssistCommand: createKeyAssistCommand, setPageCommandExclusions: setPageCommandExclusions }; }); |