com.vaadin.copilot.
Class ProjectFileManager
-
Method Summary
Modifier and TypeMethodDescriptionfindModule
(File file) Finds the module where the given resource is located.
findResource
(String resource) Finds the given resource by name, in any resource folder.
findResourceFolder
(File resourceFile) Finds the resource folder where the given resource is located.
findSourceFolder
(File sourceFile) Finds the source folder where the given file is located.
getFileForClass
(Class<?> cls) Returns the Java file for the given class.
getFileForClass
(String cls) Returns the Java file for the given class.
Returns the frontend folder.
Finds the folder where Hilla views should be created for the file system router to pick them up.
static ProjectFileManager
getJavaPackage
(File sourceFile) Gets the java package for the given source file
Returns the java resource folder.
Gets the modules in the project.
getProjectRelativeName
(File projectFile) Returns the name of the file, relative to the project root.
Returns the project base folder.
static String
getRelativeName
(File projectFile, File folder) Returns the name of the file, relative to the given folder.
Returns the resource folders for the project.
getSourceFile
(ComponentTracker.Location location) Returns the Java file for the given component location.
Returns the source folders for the project.
Gets current theme folder
Gets current theme name
static ProjectFileManager
initialize
(ApplicationConfiguration applicationConfiguration) static boolean
isFileInside
(File toCheck, File container) makeAbsolute
(String projectRelativeFilename) makeRelative
(String filename) sanitizeFilename
(String name) Makes a string safe to use as a file name
void
Writes the given content to the given file inside the project.
void
Writes the given content to the given file inside the project.
void
writeFileBase64
(String filename, String undoLabel, String base64Content, boolean renameIfExists)
-
Method Details
-
initialize
-
getInstance
-
readFile
Throws:
-
readFile
Throws:
-
readFile
Throws:
-
readLines
Throws:
-
isFileInside
-
writeFile
Writes the given content to the given file inside the project.
If the filename is absolute, it is used as is. Otherwise, it is resolved relative to the project root.
If the file is outside the project, an exception is thrown
Parameters:
filename
- the filename to write to, absolute or relative to the project rootundoLabel
- the undo label for the changecontent
- the content to writeThrows:
IOException
- if the file cannot be written -
writeFile
Writes the given content to the given file inside the project.
If the filename is absolute, it is used as is. Otherwise, it is resolved relative to the project root.
If the file is outside the project, an exception is thrown
Parameters:
file
- the filename to write to, absolute or relative to the project rootundoLabel
- the undo label for the changecontent
- the content to writeThrows:
IOException
- if the file cannot be written -
writeFile
Throws:
-
writeFileBase64
public File writeFileBase64(String filename, String undoLabel, String base64Content, boolean renameIfExists) throws IOException Throws:
-
makeAbsolute
Throws:
-
makeRelative
Throws:
-
getProjectRelativeName
Returns the name of the file, relative to the project root.
Parameters:
projectFile
- the fileReturns:
the relative name of the file
-
getRelativeName
Returns the name of the file, relative to the given folder.
Parameters:
projectFile
- the filefolder
- the folder to make relative toReturns:
the relative name of the file
-
getFileForClass
Returns the Java file for the given class.
Parameters:
cls
- the classReturns:
the file for the class
-
getFileForClass
Returns the Java file for the given class.
Parameters:
cls
- the classReturns:
the file for the class
-
getSourceFolders
Returns the source folders for the project.
Returns:
the source folders
-
getResourceFolders
Returns the resource folders for the project.
Returns:
the resource folders
-
getSourceFile
Returns the Java file for the given component location.
Parameters:
location
- the component locationReturns:
the file for the class where the component is used
-
getProjectRoot
Returns the project base folder.
The project base folder is the common folder containing all module roots.
Returns:
the project root folder
-
getFrontendFolder
Returns the frontend folder.
Returns:
the frontend folder
-
getJavaResourceFolder
Returns the java resource folder.
Returns:
the java resource folder.
-
getThemeName
Gets current theme name
Returns:
optional theme name
-
getThemeFolder
Gets current theme folder
Returns:
optional theme folder
-
sanitizeFilename
Makes a string safe to use as a file name
Parameters:
name
- the string to processReturns:
the sanitized string
-
getHillaViewsFolder
Finds the folder where Hilla views should be created for the file system router to pick them up.
Returns:
the folder where Hilla views should be created
-
findResource
Finds the given resource by name, in any resource folder.
Parameters:
resource
- the name of the resource to look for -
findResourceFolder
Finds the resource folder where the given resource is located.
Parameters:
resourceFile
- the resource to find the resource folder for -
findModule
Finds the module where the given resource is located.
Parameters:
file
- the file to look up -
findSourceFolder
Finds the source folder where the given file is located.
Parameters:
sourceFile
- the source file to find the source folder for -
getJavaPackage
Gets the java package for the given source file
Parameters:
sourceFile
- the source fileReturns:
the java package for the given source file, or null if the source file is not inside the project
Throws:
IOException
- if something goes wrong -
getModules
Gets the modules in the project.
Returns:
a list of modules in the project
-
getApplicationConfiguration
-