Esempio n. 1
0
 // Load the project data
 public final boolean parse() {
   // Check if the file is null
   if (mProjectFile == null) {
     // Print an error message
     mLogger.failure("Error: Cannot parse editor project from a bad file");
     // Return false at error
     return false;
   }
   // Check if the project directory does exist
   if (!mProjectFile.exists()) {
     // Print an error message
     mLogger.failure("Error: Cannot find editor project directory '" + mProjectFile + "'");
     // Return false at error
     return false;
   }
   // Load the project data
   if (super.parse(mProjectFile) && mEditorConfig.load(mProjectFile)) {
     // Set the initial hash code
     mInitialHash = getHashCode();
     // Return true if project is saved
     return true;
   } else {
     // Return false when saving failed
     return false;
   }
 }
Esempio n. 2
0
 // Save the project data
 public final boolean write() {
   // Check if the file is null
   if (mProjectFile == null) {
     // Print an error message
     mLogger.failure("Error: Cannot write editor project into a bad file");
     // Return false at error
     return false;
   }
   // Check if the project directory does exist
   if (!mProjectFile.exists()) {
     // Print a warning message in this case
     mLogger.warning("Warning: Creating a new editor project directory '" + mProjectFile + "'");
     // Try to create a project base directory
     if (!mProjectFile.mkdir()) {
       // Print an error message
       mLogger.failure(
           "Failure: Cannot create a new editor project directory '" + mProjectFile + "'");
       // Return false at error
       return false;
     }
   }
   // Save the project data
   if (super.write(mProjectFile) && mEditorConfig.save(mProjectFile)) {
     // Reset the initial hash code here
     mInitialHash = getHashCode();
     // Return true when project is saved
     return true;
   } else {
     // Return false when saving failed
     return false;
   }
 }