summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorelijahe2013-12-18 17:20:31 (EST)
committer libing wang2013-12-19 12:31:50 (EST)
commit2db5255c73b26dbc4cb055f1e9cd98fed3118f04 (patch)
treecbad617bbd966f18227869d69b6f1201cb59ea9a
parent2fabb95dfcc631111f6bc15bb339165945e6511d (diff)
downloadorg.eclipse.orion.client-2db5255c73b26dbc4cb055f1e9cd98fed3118f04.zip
org.eclipse.orion.client-2db5255c73b26dbc4cb055f1e9cd98fed3118f04.tar.gz
org.eclipse.orion.client-2db5255c73b26dbc4cb055f1e9cd98fed3118f04.tar.bz2
Bug 421482 - UX: No context menu!v20131219-1731
- Moved most common actions to the top level of the context menu - Grouped similar less common actions into three submenus: "Open with...", "Import/Export" and "Extensions". This applies to both the sidebar context menu and the toolbar gear dropdown menu. - Generated sidebarContextMenu node dynamically from within common-nav.js - Added Copy and Paste commands to context menu - Modified name of Raw command to "Web Browser" and grouped it under "Open with..." - Fixed bug where deleted items were remaining in copy/paste buffer - Removed orion.editor contentType essentially making it accept all types of files and added excludedContentTypes attribute which excludes all image types - Removed "prepopulate" and "postpopulate" events from dropdown.js and added a "triggered" event --Signed-off-by: Elijah El-Haddad <elijahe@ca.ibm.com>
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/edit/edit.html1
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/explorers/explorerNavHandler.js5
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/fileCommands.js22
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/navigate/nls/root/messages.js7
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/nls/root/messages.js3
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/webui/dropdown.js3
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/widgets/nav/common-nav.js165
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/plugins/webEditingPlugin.js33
8 files changed, 171 insertions, 68 deletions
diff --git a/bundles/org.eclipse.orion.client.ui/web/edit/edit.html b/bundles/org.eclipse.orion.client.ui/web/edit/edit.html
index 46a8ab0..91bddc3 100644
--- a/bundles/org.eclipse.orion.client.ui/web/edit/edit.html
+++ b/bundles/org.eclipse.orion.client.ui/web/edit/edit.html
@@ -29,7 +29,6 @@
<div class="fixedToolbarHolder">
<div id="sidebarToolbar" class="sidebarToolbar mainToolbar toolComposite toolbarLayout"></div>
<div id="sidebar" class="toolbarTarget dropdownTrigger"></div>
- <ul id="sidebarContextMenu" class="dropdownMenu" role="menu"></ul>
</div>
</div>
<div class="split splitLayout" style="left: 25%;"></div> <!-- 1:3 -->
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/explorers/explorerNavHandler.js b/bundles/org.eclipse.orion.client.ui/web/orion/explorers/explorerNavHandler.js
index 04a94d8..630d263 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/explorers/explorerNavHandler.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/explorers/explorerNavHandler.js
@@ -182,11 +182,11 @@ exports.ExplorerNavHandler = (function() {
return this.explorer.myTree.isExpanded(this.model.getId(model));
},
- refreshSelection: function(noScroll){
+ refreshSelection: function(noScroll, visually){
var that = this;
if(this.explorer.selection){
this.explorer.selection.getSelections(function(selections) {
- that._clearSelection();
+ that._clearSelection(visually);
for (var i = 0; i < selections.length; i++){
that._selections.push(selections[i]);
}
@@ -245,7 +245,6 @@ exports.ExplorerNavHandler = (function() {
}
}
this._selections = [];
- //this._selections.splice(0, this._selections.length);
},
getSelectionPolicy: function() {
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/fileCommands.js b/bundles/org.eclipse.orion.client.ui/web/orion/fileCommands.js
index 731edc3..19c07af 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/fileCommands.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/fileCommands.js
@@ -637,7 +637,6 @@ define(['i18n!orion/navigate/nls/messages', 'require', 'orion/webui/littlelib',
var deleteCommand = new mCommands.Command({
name: messages["Delete"],
- tooltip: messages["Delete the selected files or folders"],
imageClass: "core-sprite-delete", //$NON-NLS-0$
id: "eclipse.deleteFile" + idSuffix, //$NON-NLS-0$
visibleWhen: oneOrMoreFilesOrFolders,
@@ -677,6 +676,10 @@ define(['i18n!orion/navigate/nls/messages', 'require', 'orion/webui/littlelib',
newValue: null,
parent: parent
});
+ // Remove deleted item from copy/paste buffer
+ bufferedSelection = bufferedSelection.filter(function(element){
+ return element.Location !== item.Location;
+ });
dispatchModelEvent({ type: "delete", oldValue: item, newValue: null, parent: parent, count: items.length }); //$NON-NLS-0$
}, errorHandler);
});
@@ -992,22 +995,25 @@ define(['i18n!orion/navigate/nls/messages', 'require', 'orion/webui/littlelib',
commandService.addCommand(moveCommand);
var copyToBufferCommand = new mCommands.Command({
- name: messages["Copy Items"],
- tooltip: messages["Copy the selected items to the copy/paste buffer"],
+ name: messages["Copy"],
id: "eclipse.copySelections" + idSuffix, //$NON-NLS-0$
callback: function() {
explorer.selection.getSelections(function(selections) {
bufferedSelection = selections;
});
- }
+ },
+ visibleWhen: oneOrMoreFilesOrFolders
});
commandService.addCommand(copyToBufferCommand);
-
+
+ var canPaste = function(items){
+ return (bufferedSelection.length > 0) && checkFolderSelection(items);
+ };
+
var pasteFromBufferCommand = new mCommands.Command({
- name: messages["Paste Items"],
- tooltip: messages["Paste items from the copy/paste buffer"],
+ name: messages["Paste"],
id: "eclipse.pasteSelections" + idSuffix, //$NON-NLS-0$
- visibleWhen: checkFolderSelection,
+ visibleWhen: canPaste,
callback: function(data) {
// Check selection service first. If a single folder is selected, that is the target. Otherwise the root is the target.
explorer.selection.getSelections(function(selections) {
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/navigate/nls/root/messages.js b/bundles/org.eclipse.orion.client.ui/web/orion/navigate/nls/root/messages.js
index 1215624..b022cef 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/navigate/nls/root/messages.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/navigate/nls/root/messages.js
@@ -29,7 +29,6 @@ define({
"Compare the selected folder with a specified folder": "Compare the selected folder with a specified folder",
"Delete": "Delete",
"Unknown item": "Unknown item",
- "Delete the selected files or folders": "Delete the selected files or folders",
"Are you sure you want to delete these ${0} items?": "Are you sure you want to delete these ${0} items?",
"Are you sure you want to delete '${0}'?": "Are you sure you want to delete '${0}'?",
"Export as zip": "Export as zip",
@@ -87,11 +86,9 @@ define({
"Creating ${0}": "Creating ${0}",
"Linking to ${0}": "Linking to ${0}",
"Move files and folders to a new location": "Move files and folders to a new location",
- "Copy Items": "Copy Items",
- "Copy the selected items to the copy/paste buffer": "Copy the selected items to the copy/paste buffer",
+ "Copy": "Copy",
"Fetching children of ": "Fetching children of ",
- "Paste Items": "Paste Items",
- "Paste items from the copy/paste buffer": "Paste items from the copy/paste buffer",
+ "Paste": "Paste",
"Cannot paste into the Workspace root": "Cannot paste into the Workspace root",
"Open With": "Open With",
"Loading ": "Loading ",
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/nls/root/messages.js b/bundles/org.eclipse.orion.client.ui/web/orion/nls/root/messages.js
index bcbb6a1..d85c9ad 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/nls/root/messages.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/nls/root/messages.js
@@ -84,8 +84,7 @@ define({
"Generate an HTML5 'Hello World' website, including JavaScript, HTML, and CSS files.": "Generate an HTML5 'Hello World' website, including JavaScript, HTML, and CSS files.",
"Sample Orion Plugin": "Sample Orion Plugin",
"Generate a sample plugin for integrating with Orion.": "Generate a sample plugin for integrating with Orion.",
- "Raw": "Raw",
- "Open the raw file or folder in the browser": "Open the raw file or folder in the browser",
+ "Browser": "Web Browser",
"OutlineProgress": "Getting outline for ${0} from ${1}",
"UnknownError": "An unknown error occurred.",
"UnknownWarning": "An unknown warning occurred.",
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/webui/dropdown.js b/bundles/org.eclipse.orion.client.ui/web/orion/webui/dropdown.js
index 51c465b..7758fa2 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/webui/dropdown.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/webui/dropdown.js
@@ -125,12 +125,11 @@ define(['require', 'orion/webui/littlelib', 'orion/EventTarget'], function(requi
open: function(event /* optional */) {
var actionTaken = false;
if (!this.isVisible()) {
+ this.dispatchEvent({type: "triggered", dropdown: this, event: event}); //$NON-NLS-0$
lib.setFramesEnabled(false);
if (this._populate) {
this.empty();
- this.dispatchEvent({type: "prepopulate", dropdown: this, event: event}); //$NON-NLS-0$
this._populate(this._dropdownNode);
- this.dispatchEvent({type: "postpopulate", dropdown: this, event: event}); //$NON-NLS-0$
}
var items = this.getItems();
if (items.length > 0) {
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/widgets/nav/common-nav.js b/bundles/org.eclipse.orion.client.ui/web/orion/widgets/nav/common-nav.js
index 40f79e9..e21e389 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/widgets/nav/common-nav.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/widgets/nav/common-nav.js
@@ -54,6 +54,16 @@ define([
this.selectionActionsScope = this.toolbarNode.id + "Selection"; //$NON-NLS-0$
this.folderNavActionsScope = this.toolbarNode.id + "Folder"; //$NON-NLS-0$
this.additionalNavActionsScope = this.toolbarNode.id + "Extra"; //$NON-NLS-0$
+
+ this._parentNode = lib.node(this.parentId);
+ this._sidebarContextMenuNode = document.createElement("ul"); //$NON-NLS-0$
+ this._sidebarContextMenuNode.className = "dropdownMenu"; //$NON-NLS-0$
+ this._sidebarContextMenuNode.setAttribute("role", "menu"); //$NON-NLS-1$ //$NON-NLS-0$
+ this._sidebarContextMenuNode.id = this.parentId + "ContextMenu"; //$NON-NLS-0$
+
+ this._parentNode.parentNode.insertBefore(this._sidebarContextMenuNode, this._parentNode);
+
+ this.contextMenuActionsScope = this._sidebarContextMenuNode.id + "commonNavContextMenu"; //$NON-NLS-0$
this.treeRoot = {}; // Needed by FileExplorer.prototype.loadResourceList
var _self = this;
@@ -80,7 +90,6 @@ define([
};
this.selection.addEventListener("selectionChanged", this._selectionListener); //$NON-NLS-0$
this.commandsRegistered = this.registerCommands();
- this._parentNode = lib.node(this.parentId);
this._createContextMenu();
}
@@ -175,6 +184,10 @@ define([
this._contextMenu.destroy();
this._contextMenu = null;
}
+ if (this._sidebarContextMenuNode) {
+ this._parentNode.parentNode.removeChild(this._sidebarContextMenuNode);
+ this._sidebarContextMenuNode = null;
+ }
},
display: function(root, force) {
return this.loadRoot(root, force).then(function(){
@@ -232,9 +245,53 @@ define([
var newActionsScope = this.newActionsScope;
var selectionActionsScope = this.selectionActionsScope;
var folderNavActionsScope = this.folderNavActionsScope;
+ var contextMenuActionsScope = this.contextMenuActionsScope;
commandRegistry.addCommandGroup(newActionsScope, "orion.commonNavNewGroup", 1000, messages["New"], null, null, "core-sprite-addcontent", null, "dropdownSelection"); //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
+
+ // action gear groups
commandRegistry.addCommandGroup(selectionActionsScope, "orion.commonNavSelectionGroup", 100, messages["Actions"], null, null, "core-sprite-gear", null, "dropdownSelection"); //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
+ commandRegistry.addCommandGroup(selectionActionsScope,
+ "orion.importExportGroup", //$NON-NLS-0$
+ 1000,
+ messages["ImportExport"], //$NON-NLS-0$
+ "orion.commonNavSelectionGroup", //$NON-NLS-0$
+ null,
+ null,
+ null,
+ "dropdownSelection"); //$NON-NLS-0$
+
+ // context menu groups
+ commandRegistry.addCommandGroup(contextMenuActionsScope, "orion.commonNavContextMenuSelectionGroup", 100, null, null, null, null, null, "dropdownSelection"); //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
+ commandRegistry.addCommandGroup(contextMenuActionsScope,
+ "orion.OpenWith", //$NON-NLS-0$
+ 1000,
+ messages["OpenWith"], //$NON-NLS-0$
+ "orion.commonNavContextMenuSelectionGroup", //$NON-NLS-0$
+ null,
+ null,
+ null,
+ "dropdownSelection"); //$NON-NLS-0$
+ commandRegistry.addCommandGroup(contextMenuActionsScope,
+ "orion.ImportExportGroup", //$NON-NLS-0$
+ 1000,
+ messages["ImportExport"], //$NON-NLS-0$
+ "orion.commonNavContextMenuSelectionGroup", //$NON-NLS-0$
+ null,
+ null,
+ null,
+ "dropdownSelection"); //$NON-NLS-0$
+ commandRegistry.addCommandGroup(contextMenuActionsScope,
+ "orion.Extensions", //$NON-NLS-0$
+ 1000,
+ messages["Extensions"], //$NON-NLS-0$
+ "orion.commonNavContextMenuSelectionGroup", //$NON-NLS-0$
+ null,
+ null,
+ null,
+ "dropdownSelection"); //$NON-NLS-0$
+
commandRegistry.registerSelectionService(selectionActionsScope, this.selection);
+ commandRegistry.registerSelectionService(contextMenuActionsScope, this.selection);
var renameBinding = new KeyBinding(113); // F2
var delBinding = new KeyBinding(46); // Delete
@@ -245,10 +302,6 @@ define([
downFolder.domScope = upFolder.domScope = pasteSelections.domScope = copySelections.domScope = delBinding.domScope = renameBinding.domScope = "sidebar"; //$NON-NLS-0$
downFolder.scopeName = upFolder.scopeName = pasteSelections.scopeName = copySelections.scopeName = delBinding.scopeName = renameBinding.scopeName = messages.Navigator; //$NON-NLS-0$
- // commands that don't appear but have keybindings
- commandRegistry.registerCommandContribution(newActionsScope, "eclipse.copySelections", 1, null, true, copySelections); //$NON-NLS-0$
- commandRegistry.registerCommandContribution(newActionsScope, "eclipse.pasteSelections", 1, null, true, pasteSelections); //$NON-NLS-0$
-
// New file and new folder (in a group)
commandRegistry.registerCommandContribution(newActionsScope, "eclipse.newFile", 1, "orion.commonNavNewGroup/orion.newContentGroup"); //$NON-NLS-1$ //$NON-NLS-0$
commandRegistry.registerCommandContribution(newActionsScope, "eclipse.newFolder", 2, "orion.commonNavNewGroup/orion.newContentGroup", false, null/*, new mCommandRegistry.URLBinding("newFolder", "name")*/); //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
@@ -270,8 +323,38 @@ define([
commandRegistry.registerCommandContribution(selectionActionsScope, "eclipse.downloadFile", 3, "orion.commonNavSelectionGroup/orion.importExportGroup"); //$NON-NLS-1$ //$NON-NLS-0$
commandRegistry.registerCommandContribution(selectionActionsScope, "orion.importSFTP", 4, "orion.commonNavSelectionGroup/orion.importExportGroup"); //$NON-NLS-1$ //$NON-NLS-0$
commandRegistry.registerCommandContribution(selectionActionsScope, "eclipse.exportSFTPCommand", 5, "orion.commonNavSelectionGroup/orion.importExportGroup"); //$NON-NLS-1$ //$NON-NLS-0$
+
+ // Context menu actions
+ //TODO add cut command
+ commandRegistry.registerCommandContribution(contextMenuActionsScope, "eclipse.copySelections", 1, "orion.commonNavContextMenuSelectionGroup", false, copySelections); //$NON-NLS-1$ //$NON-NLS-0$
+ commandRegistry.registerCommandContribution(contextMenuActionsScope, "eclipse.pasteSelections", 2, "orion.commonNavContextMenuSelectionGroup", false, pasteSelections); //$NON-NLS-1$ //$NON-NLS-0$
+ commandRegistry.registerCommandContribution(contextMenuActionsScope, "eclipse.deleteFile", 3, "orion.commonNavContextMenuSelectionGroup", false, delBinding); //$NON-NLS-1$ //$NON-NLS-0$
+ commandRegistry.registerCommandContribution(contextMenuActionsScope, "eclipse.renameResource", 4, "orion.commonNavContextMenuSelectionGroup", false, renameBinding); //$NON-NLS-1$ //$NON-NLS-0$
+ commandRegistry.registerCommandContribution(contextMenuActionsScope, "eclipse.compareWith", 5, "orion.commonNavContextMenuSelectionGroup"); //$NON-NLS-1$ //$NON-NLS-0$
+ commandRegistry.registerCommandContribution(contextMenuActionsScope, "eclipse.compareWithEachOther", 6, "orion.commonNavContextMenuSelectionGroup"); //$NON-NLS-1$ //$NON-NLS-0$
+
FileCommands.createFileCommands(serviceRegistry, commandRegistry, this, fileClient);
- return ExtensionCommands.createAndPlaceFileCommandsExtension(serviceRegistry, commandRegistry, selectionActionsScope, 0, "orion.commonNavSelectionGroup", true); //$NON-NLS-0$
+ return ExtensionCommands.createAndPlaceFileCommandsExtension(serviceRegistry, commandRegistry, selectionActionsScope, 0, "orion.commonNavSelectionGroup", true).then(function() { //$NON-NLS-0$
+
+ // OpenWith group
+ var openWithCommands = ExtensionCommands.getOpenWithCommands(commandRegistry);
+ openWithCommands.forEach(function(command){
+ commandRegistry.registerCommandContribution(contextMenuActionsScope, command.id, 1, "orion.commonNavContextMenuSelectionGroup/orion.OpenWith"); //$NON-NLS-0$
+ });
+
+ // ImportExportGroup group
+ commandRegistry.registerCommandContribution(contextMenuActionsScope, "orion.importZipURL", 1, "orion.commonNavContextMenuSelectionGroup/orion.ImportExportGroup"); //$NON-NLS-1$ //$NON-NLS-0$
+ commandRegistry.registerCommandContribution(contextMenuActionsScope, "orion.import", 2, "orion.commonNavContextMenuSelectionGroup/orion.ImportExportGroup"); //$NON-NLS-1$ //$NON-NLS-0$
+ commandRegistry.registerCommandContribution(contextMenuActionsScope, "eclipse.downloadFile", 3, "orion.commonNavContextMenuSelectionGroup/orion.ImportExportGroup"); //$NON-NLS-1$ //$NON-NLS-0$
+ commandRegistry.registerCommandContribution(contextMenuActionsScope, "orion.importSFTP", 4, "orion.commonNavContextMenuSelectionGroup/orion.ImportExportGroup"); //$NON-NLS-1$ //$NON-NLS-0$
+ commandRegistry.registerCommandContribution(contextMenuActionsScope, "eclipse.exportSFTPCommand", 5, "orion.commonNavContextMenuSelectionGroup/orion.ImportExportGroup"); //$NON-NLS-1$ //$NON-NLS-0$
+
+ // Extensions group
+ var fileCommandIds = ExtensionCommands.getFileCommandIds();
+ fileCommandIds.forEach(function(commandId){
+ commandRegistry.registerCommandContribution(contextMenuActionsScope, commandId, 1, "orion.commonNavContextMenuSelectionGroup/orion.Extensions"); //$NON-NLS-0$
+ });
+ }); //$NON-NLS-0$
},
updateCommands: function(selections) {
this.createActionSections();
@@ -282,51 +365,69 @@ define([
commandRegistry.destroy(this.additionalNavActionsScope);
commandRegistry.renderCommands(this.folderNavActionsScope, this.folderNavActionsScope, this.treeRoot, this, "tool"); //$NON-NLS-0$
commandRegistry.renderCommands(this.additionalNavActionsScope, this.additionalNavActionsScope, this.treeRoot, this, "tool"); //$NON-NLS-0$
+ if (this._sidebarContextMenuNode) {
+ this._populateContextMenu(this._sidebarContextMenuNode);
+ }
},
+
+ _populateContextMenu: function(contextMenuNode) {
+ var selectionService = this.selection;
+ var selections = selectionService.getSelections();
+ var items = null;
+
+ this.commandRegistry.destroy(contextMenuNode); // remove previous content
+
+ this.commandRegistry.renderCommands(this.newActionsScope, contextMenuNode, this.treeRoot, this, "menu"); //$NON-NLS-0$
+
+ if (!selections || (Array.isArray(selections) && !selections.length)) {
+ //no selections, use this.treeRoot to determine commands
+ items = this.treeRoot;
+ }
+ this.commandRegistry.renderCommands(this.contextMenuActionsScope, contextMenuNode, items, this, "menu"); //$NON-NLS-0$
+ },
+
_createContextMenu: function() {
- //create context menu
- //function called before populating the context menu to set the nav selection properly
- var prePopulateContextMenu = function(eventWrapper) {
+ //function called when the context menu is triggered to set the nav selection properly
+ var contextMenuTriggered = function(eventWrapper) {
var navHandler = this.getNavHandler();
var navDict = this.getNavDict();
var event = eventWrapper.event;
+ var item = null;
+
if (event.target) {
var node = event.target;
while (this._parentNode.contains(node)) {
- if ("TR" === node.nodeName) { //TODO this is brittle, see if a better way exists
+ if ("TR" === node.nodeName) { //$NON-NLS-0$ //TODO this is brittle, see if a better way exists
var rowId = node.id;
- var item = navDict.getValue(rowId);
- navHandler.setSelection(item.model, false, true);
+ item = navDict.getValue(rowId);
break;
}
node = node.parentNode;
}
- }
- }.bind(this);
-
- //function called to populate the context menu before every time it is shown
- var populateContextMenu = function(contextMenu) {
- var selectionService = this.selection;
- var selections = selectionService.getSelections();
-
- this.commandRegistry.renderCommands(this.newActionsScope, contextMenu, this.treeRoot, this, "menu"); //$NON-NLS-0$
-
- if (!selections || (Array.isArray(selections) && !selections.length)) {
- //no selections, use this.treeRoot to determine commands
- this.commandRegistry.renderCommands(this.selectionActionsScope, contextMenu, this.treeRoot, this, "menu"); //$NON-NLS-0$
- } else {
- //there are selections, use default selection service to determine commands
- this.commandRegistry.renderCommands(this.selectionActionsScope, contextMenu, null, this, "menu"); //$NON-NLS-0$
+
+ if (item) {
+ // only modify the selection if the item that the context menu
+ // was triggered on isn't already part of the selection
+ var existingSels = navHandler.getSelection();
+ if (-1 === existingSels.indexOf(item.model)) {
+ navHandler.cursorOn(item.model, true, false, true);
+ navHandler.setSelection(item.model, false, true);
+ }
+ } else {
+ // context menu was triggered on sidebar itself,
+ // clear previous selections
+ this.selection.setSelections(null);
+ navHandler.refreshSelection(true, true);
+ }
}
}.bind(this);
var contextMenu = new mContextMenu.ContextMenu({
- dropdown: lib.node("sidebarContextMenu"),
- triggerNode: this._parentNode,
- populate: populateContextMenu
+ dropdown: this._sidebarContextMenuNode,
+ triggerNode: this._parentNode
});
- contextMenu.addEventListener("prepopulate", prePopulateContextMenu);
+ contextMenu.addEventListener("triggered", contextMenuTriggered); //$NON-NLS-0$
this._contextMenu = contextMenu;
}
diff --git a/bundles/org.eclipse.orion.client.ui/web/plugins/webEditingPlugin.js b/bundles/org.eclipse.orion.client.ui/web/plugins/webEditingPlugin.js
index ea30f37..537af9a 100644
--- a/bundles/org.eclipse.orion.client.ui/web/plugins/webEditingPlugin.js
+++ b/bundles/org.eclipse.orion.client.ui/web/plugins/webEditingPlugin.js
@@ -117,18 +117,6 @@ define([
}]
});
- provider.registerService("orion.navigate.command", {}, {
- id: "orion.view.raw",
- nameKey: "Raw",
- nls: "orion/nls/messages",
- tooltipKey: "Open the raw file or folder in the browser",
- uriTemplate: "{+Location}",
- forceSingleItem: true,
- validationProperties: [{
- source: "!Projects" // Filter out workspace; Raw only applies to regular files and folders.
- }]
- });
-
provider.registerService("orion.edit.editor", {}, {
id: "orion.editor",
nameKey: "Orion Editor",
@@ -136,10 +124,14 @@ define([
uriTemplate: "../edit/edit.html#{,Location,params*}",
orionTemplate: "../edit/edit.html#{,Location,params*}"});
+ // only providing excludedContentTypes for orion.editor because we want
+ // to attempt to open files with unknown content types with it for now
+ // e.g. A text file with no extension is currently of an unknown content
+ // type, we want to use the orion.editor to open it
provider.registerService("orion.navigate.openWith", {}, {
- editor: "orion.editor",
- contentType: ["text/plain", "text/html", "text/css", "application/javascript", "application/json", "application/xml", "text/x-java-source", "text/x-markdown"]});
-
+ editor: "orion.editor",
+ excludedContentTypes: ["image/*"]});
+
provider.registerService("orion.navigate.openWith.default", {}, {
editor: "orion.editor"});
@@ -164,6 +156,17 @@ define([
editor: "orion.imageViewer",
contentType: ["image/gif", "image/jpeg", "image/ico", "image/png", "image/tiff", "image/svg"]});
+ // open file with browser, no associated orion.navigate.openWith command means that any content type is valid
+ provider.registerService("orion.edit.editor", {}, {
+ id: "orion.view.raw",
+ nameKey: "Browser",
+ nls: "orion/nls/messages",
+ uriTemplate: "{+Location}",
+ validationProperties: [{
+ source: "!Projects" // Filter out workspace; Raw only applies to regular files and folders.
+ }]
+ });
+
// Register content assist providers
provider.registerService("orion.edit.contentassist",
new cssContentAssist.CssContentAssistProvider(),