Beispiel #1
0
 /** Application is shutting down so save preferences. */
 public void unload() {
   try {
     savePrefs(fileWrapperFactory.create(_userSettingsFolder, USER_PREFS_FILE_NAME));
   } catch (IOException ex) {
     s_log.error("Error occured writing to preferences file: " + USER_PREFS_FILE_NAME, ex);
   } catch (XMLException ex) {
     s_log.error("Error occured writing to preferences file: " + USER_PREFS_FILE_NAME, ex);
   }
   super.unload();
 }
Beispiel #2
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();
  }
Beispiel #3
0
  public synchronized void initialize() throws PluginException {
    try {
      super.initialize();
      final IApplication app = getApplication();

      Class<?> com_apple_eawt_Application;
      try {
        com_apple_eawt_Application = Class.forName(COM_APPLE_EAWT_APPLICATION_CLASSNAME);
      } catch (ClassNotFoundException e) {
        s_log.error(
            "MacOSX plugin is loaded, but Apple support class isn't in the Classpath: "
                + e.getMessage(),
            e);
        return;
      }

      Method getApplication = com_apple_eawt_Application.getMethod("getApplication", new Class[0]);

      Object applicationInstance = getApplication.invoke(com_apple_eawt_Application, new Object[0]);

      Class<?> com_apple_eawt_ApplicationListener =
          Class.forName("com.apple.eawt.ApplicationListener");

      ApplicationListenerInvocationHandler handler = new ApplicationListenerInvocationHandler(app);
      Object proxy =
          Proxy.newProxyInstance(
              IApplication.class.getClassLoader(),
              new Class[] {com_apple_eawt_ApplicationListener},
              handler);

      //          com.apple.eawt.ApplicationAdapter applicationAdapter = new
      // com.apple.eawt.ApplicationAdapter()
      //                 {
      //                    public void handleAbout(ApplicationEvent e)
      //                    {
      //                       e.setHandled(true);
      //                       new AboutCommand(app).execute();
      //                    }
      //
      //                    public void handleOpenApplication(ApplicationEvent e)
      //                    {
      //                    }
      //
      //                    public void handleOpenFile(ApplicationEvent e)
      //                    {
      //                    }
      //
      //                    public void handlePreferences(ApplicationEvent e)
      //                    {
      //                       e.setHandled(true);
      //                       new GlobalPreferencesCommand(app).execute();
      //                    }
      //
      //                    public void handlePrintFile(ApplicationEvent e)
      //                    {
      //                    }
      //
      //                    public void handleQuit(ApplicationEvent e)
      //                    {
      //                       e.setHandled(true);
      //                       app.getMainFrame().dispose();
      //                    }
      //                 };

      Method addApplicationListener =
          com_apple_eawt_Application.getMethod(
              "addApplicationListener", new Class[] {com_apple_eawt_ApplicationListener});
      addApplicationListener.invoke(applicationInstance, new Object[] {proxy});

      Method addPreferencesMenuItem =
          com_apple_eawt_Application.getMethod("addPreferencesMenuItem", new Class[0]);
      addPreferencesMenuItem.invoke(applicationInstance, new Object[0]);

      Method setEnabledPreferencesMenu =
          com_apple_eawt_Application.getMethod(
              "setEnabledPreferencesMenu", new Class[] {Boolean.TYPE});
      setEnabledPreferencesMenu.invoke(applicationInstance, new Object[] {Boolean.TRUE});

      //          fApplication.addApplicationListener(applicationAdapter);
      //          fApplication.addPreferencesMenuItem();
      //          fApplication.setEnabledPreferencesMenu(true);
    } catch (Exception e) {
      s_log.error("initialize: encountered exception: " + e.getMessage(), e);
      throw new RuntimeException(e);
    }
  }
Beispiel #4
0
 public synchronized void load(IApplication app) throws PluginException {
   super.load(app);
 }