/**
  * In order for versions older than 3.2.1 to be properly upgraded, the plugin assmebly files that
  * have the form :
  *
  * <pre>
  * <plugin internal name>-assembly.zip
  * </pre>
  *
  * must be copied to the old archive form :
  *
  * <pre>
  * <plugin internal name>.jar
  * </pre>
  *
  * This method loops through all of the plugin assembly archives and copies them to the old
  * format.
  */
 private void copyPluginAssemblies() throws IOException {
   FileWrapper pluginsDir = _fileWrapperFactory.create(releaseDirectory, "plugin");
   String[] pluginsList = pluginsDir.list();
   for (String plugin : pluginsList) {
     String oldFormat = plugin.replace("-assembly", "").replace(".zip", ".jar");
     FileWrapper pluginAssemblyArchiveFile = _fileWrapperFactory.create(pluginsDir, plugin);
     FileWrapper oldFormatArchiveFile = _fileWrapperFactory.create(pluginsDir, oldFormat);
     if (log.isInfoEnabled()) {
       log.info("Copying assembly file ( " + plugin + " ) to old format: " + oldFormat);
     }
     _iou.copyFile(pluginAssemblyArchiveFile, oldFormatArchiveFile);
   }
 }
Example #2
0
  private void createEmptyRequiredUserFiles() {
    _userExtraLAFFolder.mkdirs();

    FileWrapper file =
        fileWrapperFactory.create(_userExtraLAFFolder, ILAFConstants.USER_EXTRA_LAFS_PROPS_FILE);
    try {
      boolean result = file.createNewFile();
      if (!result) {
        s_log.warn("Failed to create empty required user files");
      }
    } catch (IOException ex) {
      s_log.error("Error creating file " + file.getAbsolutePath(), ex);
    }
  }
Example #3
0
  /**
   * Load this plugin.
   *
   * @param app Application API.
   */
  public synchronized void load(IApplication app) throws PluginException {
    super.load(app);

    // Load resources.
    _resources = new LAFPluginResources(this);

    // Folder within plugins folder that belongs to this
    // plugin.
    FileWrapper pluginAppFolder = null;
    try {
      pluginAppFolder = getPluginAppSettingsFolder();
    } catch (IOException ex) {
      throw new PluginException(ex);
    }

    // Folder that stores Look and Feel jars.
    _lafFolder = fileWrapperFactory.create(pluginAppFolder, "lafs");
    if (!_lafFolder.exists()) {
      _lafFolder.mkdir();
    }

    // Folder to store user settings.
    try {
      _userSettingsFolder = getPluginUserSettingsFolder();
    } catch (IOException ex) {
      throw new PluginException(ex);
    }

    // Folder to contain extra LAFs supplied by the user.
    _userExtraLAFFolder =
        fileWrapperFactory.create(_userSettingsFolder, ILAFConstants.USER_EXTRA_LAFS_FOLDER);

    // Create empty required files in user settings directory.
    createEmptyRequiredUserFiles();

    // Load plugin preferences.
    loadPrefs();

    // Create the Look and Feel register.
    _lafRegister = new LAFRegister(app, this);

    // Listen for GUI components being created.
    UIFactory.getInstance().addListener(new UIFactoryListener());

    // Update font used for status bars.
    _lafRegister.updateStatusBarFont();
  }
Example #4
0
  /** Load from preferences file. */
  private void loadPrefs() {
    final FileWrapper oldPrefsFile =
        fileWrapperFactory.create(_userSettingsFolder, OLD_USER_PREFS_FILE_NAME);
    final FileWrapper newPrefsFile =
        fileWrapperFactory.create(_userSettingsFolder, USER_PREFS_FILE_NAME);
    final boolean oldExists = oldPrefsFile.exists();
    final boolean newExists = newPrefsFile.exists();

    try {
      if (oldExists) {
        loadOldPrefs(oldPrefsFile);
        try {
          _settingsCache.add(_lafPrefs);
        } catch (DuplicateObjectException ex) {
          s_log.error("LAFPreferences object already in cache", ex);
        }
        savePrefs(newPrefsFile);
        if (!oldPrefsFile.delete()) {
          s_log.error("Unable to delete old LAF preferences file");
        }

      } else if (newExists) {
        loadNewPrefs(newPrefsFile);
      }
    } catch (IOException ex) {
      s_log.error("Error occured in preferences file", ex);
    } catch (XMLException ex) {
      s_log.error("Error occured in preferences file", ex);
    }

    if (_lafPrefs == null) {
      _lafPrefs = new LAFPreferences(IdentifierFactory.getInstance().createIdentifier());
      _lafPrefs.setLookAndFeelClassName(MetalLookAndFeelController.METAL_LAF_CLASS_NAME);
      try {
        _settingsCache.add(_lafPrefs);
      } catch (DuplicateObjectException ex) {
        s_log.error("LAFPreferences object already in cache", ex);
      }
    }
  }
Example #5
0
 /**
  * Load preferences from the new file format.
  *
  * @param newPerfsFile FileWrapper containing the preferences information.
  * @throws XMLException Thrown if error reading preferences file.
  */
 private void loadNewPrefs(FileWrapper newPrefsFile) throws XMLException {
   try {
     try {
       _settingsCache.load(newPrefsFile.getPath(), getClass().getClassLoader());
     } catch (DuplicateObjectException ex) {
       s_log.error("Cache should have been empty", ex);
     }
     Iterator<LAFPreferences> it = _settingsCache.getAllForClass(LAFPreferences.class);
     if (it.hasNext()) {
       _lafPrefs = it.next();
     } else {
       s_log.error("LAFPreferences object not loaded");
     }
   } catch (FileNotFoundException ignore) {
     // property file not found for user - first time user ran pgm.
   }
 }
Example #6
0
 /**
  * Save preferences to disk.
  *
  * @param prefsFile File to save preferences to.
  */
 private void savePrefs(FileWrapper prefsFile) throws IOException, XMLException {
   _settingsCache.save(prefsFile.getPath());
 }