This repository has been archived by the owner on Sep 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from adobe/open-file-from-tree
Open file from tree - looks good!
- Loading branch information
Showing
5 changed files
with
143 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2011 Adobe Systems Incorporated. All Rights Reserved. | ||
*/ | ||
|
||
var CommandManager = {}; | ||
|
||
CommandManager._commands = {}; | ||
|
||
/** | ||
* Registers a global command. | ||
* | ||
* @param {string} id The ID of the command. | ||
* @param {function} command The function to call when the command is executed. Any arguments passed to | ||
* execute() (after the id) are passed as arguments to the function. | ||
*/ | ||
CommandManager.register = function(id, command) { | ||
if (CommandManager._commands[id]) { | ||
throw new Error("Attempting to register an already-registered command: " + id); | ||
} | ||
CommandManager._commands[id] = command; | ||
} | ||
|
||
/** | ||
* Runs a global command. Additional arguments are passed to the command. | ||
* | ||
* @param {string} id The ID of the command to run. | ||
*/ | ||
CommandManager.execute = function(id) { | ||
var command = CommandManager._commands[id]; | ||
if (command) { | ||
command.apply(null, Array.prototype.slice.call(arguments, 1)); | ||
} | ||
else { | ||
console.log("Attempted to call unregistered command: " + id); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* Copyright 2011 Adobe Systems Incorporated. All Rights Reserved. | ||
*/ | ||
|
||
/** | ||
* List of constants for global command IDs. | ||
*/ | ||
var Commands = { | ||
FILE_OPEN: "file.open" | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters