Package com.eteks.sweethome3d.model

Examples of com.eteks.sweethome3d.model.RecorderException


        }
      }
     
      Locale.setDefault(defaultLocale);
    } catch (IOException ex) {
      throw new RecorderException("Invalid furniture library file " + furnitureLibraryName, ex);
    } catch (MissingResourceException ex) {
      throw new RecorderException("Invalid furniture library file " + furnitureLibraryName, ex);
    }
  }
View Full Code Here


        copyFile(tmpFile, furnitureLibraryFile);
        tmpFile.delete();
      }
    } catch (IOException ex) {
      throw new RecorderException("Can't save furniture library file " + furnitureLibraryName, ex);
    } finally {
      if (zipOut != null) {
        try {
          zipOut.close();
        } catch (IOException ex) {
          throw new RecorderException("Can't close furniture library file " + furnitureLibraryName, ex);
        }
      }
    }
  }
View Full Code Here

   
    try {
      // Write preferences
      preferences.sync();
    } catch (BackingStoreException ex) {
      throw new RecorderException("Couldn't write preferences", ex);
    }
  }
View Full Code Here

   * @throws RecorderException if no plug-ins folder is associated to this manager.
   */
  public boolean pluginExists(String pluginName) throws RecorderException {
    if (this.pluginFolders == null
        || this.pluginFolders.length == 0) {
      throw new RecorderException("Can't access to plugins folder");
    } else {
      String pluginFileName = new File(pluginName).getName();
      return new File(this.pluginFolders [0], pluginFileName).exists();
    }
  }
View Full Code Here

   */
  public void addPlugin(String pluginName) throws RecorderException {
    try {
      if (this.pluginFolders == null
          || this.pluginFolders.length == 0) {
        throw new RecorderException("Can't access to plugins folder");
      }
      String pluginFileName = new File(pluginName).getName();
      File destinationFile = new File(this.pluginFolders [0], pluginFileName);

      // Copy furnitureCatalogFile to furniture plugin folder
      InputStream tempIn = null;
      OutputStream tempOut = null;
      try {
        tempIn = new BufferedInputStream(new FileInputStream(pluginName));
        this.pluginFolders [0].mkdirs();
        tempOut = new FileOutputStream(destinationFile);         
        byte [] buffer = new byte [8192];
        int size;
        while ((size = tempIn.read(buffer)) != -1) {
          tempOut.write(buffer, 0, size);
        }
      } finally {
        if (tempIn != null) {
          tempIn.close();
        }
        if (tempOut != null) {
          tempOut.close();
        }
      }
    } catch (IOException ex) {
      throw new RecorderException(
          "Can't write " + pluginName +  " in furniture libraries plugin folder", ex);
    }
  }
View Full Code Here

    File autoSavedHomeFile = this.autoSavedFiles.get(home);
    if (autoSavedHomeFile == null) {
      File recoveredFilesFolder = getRecoveryFolder();
      if (!recoveredFilesFolder.exists()) {
        if (!recoveredFilesFolder.mkdirs()) {
          throw new RecorderException("Can't create folder " + recoveredFilesFolder + " to store recovered files");
        }
      }
      // Find a unique file for home in recovered files sub folder
      if (autoSavedHome.getName() != null) {
        String homeFile = new File(autoSavedHome.getName()).getName();
        autoSavedHomeFile = new File(recoveredFilesFolder, homeFile + RECOVERED_FILE_EXTENSION);
        if (autoSavedHomeFile.exists()) {
          autoSavedHomeFile = new File(recoveredFilesFolder,
              UUID.randomUUID() + "-" + homeFile + RECOVERED_FILE_EXTENSION);
        }
      } else {
        autoSavedHomeFile = new File(recoveredFilesFolder,
            UUID.randomUUID() + RECOVERED_FILE_EXTENSION);
      }
    }
    freeLockedFile(autoSavedHomeFile);       
    if (autoSavedHome.isModified()) {
      this.autoSavedFiles.put(home, autoSavedHomeFile);
      try {
        // Save home and lock the saved file to avoid possible auto recovery processes to read it
        homeRecorder.writeHome(autoSavedHome, autoSavedHomeFile.getPath());
       
        FileOutputStream lockedOutputStream = null;
        try {
          lockedOutputStream = new FileOutputStream(autoSavedHomeFile, true);
          lockedOutputStream.getChannel().lock();
          this.lockedOutputStreams.put(autoSavedHomeFile, lockedOutputStream);
        } catch (OverlappingFileLockException ex) {
          // Don't try to race with other processes that acquired a lock on the file
        } catch (IOException ex) {
          if (lockedOutputStream != null) {
            try {
              lockedOutputStream.close();
            } catch (IOException ex1) {
              // Forget it
            }
          }
          throw new RecorderException("Can't lock saved home", ex);           
        }
      } catch (InterruptedRecorderException ex) {
        // Forget exception that probably happen because of shutdown hook management
      }
    } else {
View Full Code Here

      // Close stream and free its associated lock
      try {
        lockedOutputStream.close();
        this.lockedOutputStreams.remove(file);
      } catch (IOException ex) {
        throw new RecorderException("Can't close locked stream", ex);
      }
    }
  }
View Full Code Here

      UserPreferences userPreferences = this.application.getUserPreferences();
      return new File(userPreferences instanceof FileUserPreferences
          ? ((FileUserPreferences)userPreferences).getApplicationFolder()
          : OperatingSystem.getDefaultApplicationFolder(), RECOVERY_SUB_FOLDER);
    } catch (IOException ex) {
      throw new RecorderException("Can't retrieve recovered files folder", ex);
    }
  }
View Full Code Here

              printerJob.print();
              return null;
            } catch (InterruptedPrinterException ex) {
              throw new InterruptedRecorderException("Print interrupted");
            } catch (PrinterException ex) {
              throw new RecorderException("Couldn't print", ex);
            }
          }
        };
    } else {
      return null;
View Full Code Here

          .write(outputStream);
    } catch (InterruptedIOException ex) {
      printInterrupted = true;
      throw new InterruptedRecorderException("Print interrupted");     
    } catch (IOException ex) {
      throw new RecorderException("Couldn't export to PDF", ex);
    } finally {
      try {
        if (outputStream != null) {
          outputStream.close();
        }
        // Delete the file if printing is interrupted
        if (printInterrupted) {
          new File(pdfFile).delete();
        }
      } catch (IOException ex) {
        throw new RecorderException("Couldn't export to PDF", ex);
      }
    }
  }
View Full Code Here

TOP

Related Classes of com.eteks.sweethome3d.model.RecorderException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.