ProjectManager
Import :
const ProjectManager = brackets.getModule("project/ProjectManager")
EVENT_PROJECT_BEFORE_CLOSE : string
Triggered before the project closes.
Kind: global constant
EVENT_PROJECT_CLOSE : string
Triggered when the project has closed.
Kind: global constant
EVENT_PROJECT_OPEN_FAILED : string
Triggered when opening a project file fails.
Kind: global constant
EVENT_PROJECT_OPEN : string
Triggered when a project is opened.
Kind: global constant
EVENT_AFTER_PROJECT_OPEN : string
Triggered after a project is successfully opened.
Kind: global constant
EVENT_AFTER_STARTUP_FILES_LOADED : string
Triggered after startup files (from OS or CLI) are loaded.
Note: This may occur before extensions are loaded, so check isStartupFilesLoaded()
.
Kind: global constant
EVENT_PROJECT_REFRESH : string
Triggered when the project is refreshed.
Kind: global constant
EVENT_CONTENT_CHANGED : string
Triggered when content in the project changes.
Kind: global constant
EVENT_PROJECT_FILE_CHANGED : string
Triggered when any file or folder in the project changes, excluding renames.
Kind: global constant
EVENT_PROJECT_FILE_RENAMED : string
Triggered specifically when a project file is renamed.
Kind: global constant
EVENT_PROJECT_CHANGED_OR_RENAMED_PATH : string
Triggered when paths in the project are changed or renamed.
Kind: global constant
getFileTreeContext() ⇒ File
| Directory
Returns the File or Directory corresponding to the item that was right-clicked on in the file tree menu.
Kind: global function
getSelectedItem() ⇒ File
| Directory
Returns the File or Directory corresponding to the item selected in the sidebar panel, whether in the file tree OR in the working set; or null if no item is selected anywhere in the sidebar. May NOT be identical to the current Document - a folder may be selected in the sidebar, or the sidebar may not have the current document visible in the tree & working set.
Kind: global function
getBaseUrl() ⇒ String
Returns the encoded Base URL of the currently loaded project, or empty string if no project is open (during startup, or running outside of app shell).
Kind: global function
setBaseUrl(projectBaseUrl)
Sets the encoded Base URL of the currently loaded project.
Kind: global function
Param | Type |
---|---|
projectBaseUrl | String |
isWithinProject(absPathOrEntry) ⇒ boolean
Returns true if absPath lies within the project, false otherwise. Does not support paths containing ".."
Kind: global function
Param | Type |
---|---|
absPathOrEntry | string | FileSystemEntry |
filterProjectFiles(absPathOrEntryArray) ⇒ string
| Array.<FileSystemEntry>
Returns an array of files that is within the project from the supplied list of paths.
Kind: global function
Returns: string
| Array.<FileSystemEntry>
- A array that contains only files paths that are in the project
Param | Type | Description |
---|---|---|
absPathOrEntryArray | string | Array.<FileSystemEntry> | array which can be either a string path or FileSystemEntry |
makeProjectRelativeIfPossible(absPath) ⇒ string
If absPath lies within the project, returns a project-relative path. Else returns absPath unmodified. Does not support paths containing ".."
Kind: global function
Param | Type |
---|---|
absPath | string |
getProjectRelativeOrDisplayPath(fullPath) ⇒ string
Gets a generally displayable path that can be shown to the user in most cases. Gets the project relative path if possible. If paths is not in project, then if its a platform path(Eg. in tauri) it will return the full platform path. If not, then it will return a mount relative path for fs access mount folders opened in the bowser. at last, falling back to vfs path. This should only be used for display purposes as this path will be changed by phcode depending on the situation in the future.
Kind: global function
Param |
---|
fullPath |
getProjectRoot() ⇒ Directory
Returns the root folder of the currently loaded project, or null if no project is open (during startup, or running outside of app shell).
Kind: global function
getWelcomeProjectPath(sampleUrl, initialPath) ⇒ string
Returns the full path to the welcome project, which we open on first launch.
Kind: global function
Returns: string
- fullPath reference
Param | Type | Description |
---|---|---|
sampleUrl | string | URL for getting started project |
initialPath | string | Path to Brackets directory (see FileUtils.getNativeBracketsDirectoryPath()) |
getLocalProjectsPath() ⇒ string
The folder where all the system managed projects live
Kind: global function
isWelcomeProjectPath(path) ⇒ boolean
Returns true if the given path is the same as one of the welcome projects we've previously opened, or the one for the current build.
Kind: global function
Returns: boolean
- true if this is a welcome project path
Param | Type | Description |
---|---|---|
path | string | Path to check to see if it's a welcome project path |
updateWelcomeProjectPath()
If the provided path is to an old welcome project, returns the current one instead.
Kind: global function
getStartupProjectPath()
Initial project path is stored in prefs, which defaults to the welcome project on first launch.
Kind: global function
refreshFileTree()
Refresh the project's file tree, maintaining the current selection.
Note that the original implementation of this returned a promise to be resolved when the refresh is complete.
That use is deprecated and refreshFileTree
is now a "fire and forget" kind of function.
Kind: global function
showInTree(entry) ⇒ $.Promise
Expands tree nodes to show the given file or folder and selects it. Silently no-ops if the path lies outside the project, or if it doesn't exist.
Kind: global function
Returns: $.Promise
- Resolved when done; or rejected if not found
Param | Type | Description |
---|---|---|
entry | File | Directory | File or Directory to show |
openProject([path]) ⇒ $.Promise
Open a new project. Currently, Brackets must always have a project open, so this method handles both closing the current project and opening a new project.
Kind: global function
Returns: $.Promise
- A promise object that will be resolved when the
project is loaded and tree is rendered, or rejected if the project path
fails to load.
Param | Type | Description |
---|---|---|
[path] | string | Optional absolute path to the root folder of the project. If path is undefined or null, displays a dialog where the user can choose a folder to load. If the user cancels the dialog, nothing more happens. |
createNewItem(baseDir, initialName, skipRename, isFolder) ⇒ $.Promise
Create a new item in the current project.
Kind: global function
Returns: $.Promise
- A promise object that will be resolved with the File
of the created object, or rejected if the user cancelled or entered an illegal
filename.
Param | Type | Description |
---|---|---|
baseDir | string | Directory | Full path of the directory where the item should go. Defaults to the project root if the entry is not valid or not within the project. |
initialName | string | Initial name for the item |
skipRename | boolean | If true, don't allow the user to rename the item |
isFolder | boolean | If true, create a folder instead of a file |
deleteItem(entry)
Delete file or directore from project
Kind: global function
Param | Type | Description |
---|---|---|
entry | File | Directory | File or Directory to delete |
getLanguageFilter(languageId) ⇒ function
Returns a filter for use with getAllFiles() that filters files based on LanguageManager language id
Kind: global function
Param | Type | Description |
---|---|---|
languageId | string | Array.<string> | a single string of a language id or an array of language ids |
forceFinishRename()
Causes the rename operation that's in progress to complete.
Kind: global function
setProjectBusy(isBusy, message)
Sets or unsets project busy spinner with the specified message as reason.
For Eg., if you want to mark project as busy with reason compiling project:
setProjectBusy(true, "compiling project...")
. The project spinner will be shown with the specified reason.
Once the compilation is complete, call, we need to unset the busy status by calling:
setProjectBusy(false, "compiling project...")
. Make sure to pass in the exact message when
calling set and unset.
Kind: global function
Param | Type | Description |
---|---|---|
isBusy | boolean | true or false to set the project as busy or not |
message | string | The reason why the project is busy. Will be displayed as a hover tooltip on busy spinner. |
getProjectRelativePath(path) ⇒ string
Return the project root relative path of the given path.
Kind: global function
Param | Type |
---|---|
path | string |
getContext()
Gets the filesystem object for the current context in the file tree.
Kind: global function
renameItemInline(entry, [isMoved]) ⇒ $.Promise
Starts a rename operation, completing the current operation if there is one.
The Promise returned is resolved with an object with a newPath
property with the renamed path. If the user cancels the operation, the promise is resolved with the value RENAME_CANCELLED.
Kind: global function
Returns: $.Promise
- a promise resolved when the rename is done.
Param | Type | Description |
---|---|---|
entry | FileSystemEntry | file or directory filesystem object to rename |
[isMoved] | boolean | optional flag which indicates whether the entry is being moved instead of renamed |
getAllFiles(filter, [includeWorkingSet], [sort], options) ⇒ $.Promise
Returns an Array of all files for this project, optionally including files in the working set that are not under the project root. Files are filtered first by ProjectModel.shouldShow(), then by the custom filter argument (if one was provided).
Kind: global function
Returns: $.Promise
- Promise that is resolved with an Array of File objects.
Param | Type | Description |
---|---|---|
filter | function | Optional function to filter the file list (does not filter directory traversal). API matches Array.filter(). |
[includeWorkingSet] | boolean | If true, include files in the working set that are not under the project root (except for untitled documents). |
[sort] | boolean | If true, The files will be sorted by their paths |
options | Object | optional path within project to narrow down the search |
options.scope | File | optional path within project to narrow down the search |
addIconProvider(callback, [priority])
Adds an icon provider. The callback is invoked before each working set item is created, and can return content to prepend to the item if it supports the icon.
Kind: global function
Param | Type | Default | Description |
---|---|---|---|
callback | function | Return a string representing the HTML, a jQuery object or DOM node, or undefined. If undefined, nothing is prepended to the list item and the default or an available icon will be used. | |
[priority] | number | 0 | optional priority. 0 being lowest. The icons with the highest priority wins if there are multiple callback providers attached. icon providers of the same priority first valid response wins. |
addClassesProvider(callback, [priority])
Adds a CSS class provider, invoked before each working set item is created or updated. When called to update an existing item, all previously applied classes have been cleared.
Kind: global function
Param | Type | Description |
---|---|---|
callback | function | Return a string containing space-separated CSS class(es) to add, or undefined to leave CSS unchanged. |
[priority] | number | optional priority. 0 being lowest. The class with the highest priority wins if there are multiple callback classes attached. class providers of the same priority will be appended. |
rerenderTree()
Forces the file tree to rerender. Typically, the tree only rerenders the portions of the tree that have changed data. If an extension that augments the tree has changes that it needs to display, calling rerenderTree will cause the components for the whole tree to be rerendered.
Kind: global function