コード例 #1
0
  /**
   * Constructor.
   *
   * @param app The GUI application.
   */
  public HeapIndicatorPlugin(AbstractPluggableGUIApplication app) {

    msg = ResourceBundle.getBundle(BUNDLE_NAME);

    HeapIndicatorPrefs prefs = loadPrefs();

    this.app = app;
    heapIcon = new HeapIcon(this);
    setLayout(new BorderLayout());
    setBorder(BorderFactory.createEmptyBorder(2, 2, 4, 2));
    add(new JLabel(heapIcon));

    setUseSystemColors(prefs.useSystemColors);
    setIconForeground(prefs.iconForeground);
    setIconBorderColor(prefs.iconBorderColor);
    setVisible(prefs.visible);

    getData();
    setRefreshInterval(prefs.refreshInterval); // Must be called!

    ToolTipManager.sharedInstance().registerComponent(this);

    try {
      URL res = getClass().getResource("indicator.png");
      pluginIcon = new ImageIcon(ImageIO.read(res));
    } catch (IOException ioe) { // Never happens
      app.displayException(ioe);
    }
  }
コード例 #2
0
 /**
  * Loads saved preferences into the <code>prefs</code> member. If this is the first time through,
  * default values will be returned.
  *
  * @return The preferences.
  */
 private HeapIndicatorPrefs loadPrefs() {
   HeapIndicatorPrefs prefs = new HeapIndicatorPrefs();
   File prefsFile = getPrefsFile();
   if (prefsFile.isFile()) {
     try {
       prefs.load(prefsFile);
     } catch (IOException ioe) {
       app.displayException(ioe);
       // (Some) defaults will be used
     }
   }
   return prefs;
 }
コード例 #3
0
 /** {@inheritDoc} */
 public void savePreferences() {
   HeapIndicatorPrefs prefs = new HeapIndicatorPrefs();
   prefs.visible = isVisible();
   prefs.refreshInterval = getRefreshInterval();
   prefs.useSystemColors = getUseSystemColors();
   prefs.iconForeground = getIconForeground();
   prefs.iconBorderColor = getIconBorderColor();
   File prefsFile = getPrefsFile();
   try {
     prefs.save(prefsFile);
   } catch (IOException ioe) {
     app.displayException(ioe);
   }
 }
コード例 #4
0
  /**
   * Constructor.
   *
   * @param app The parent RText application.
   */
  public MacroPlugin(AbstractPluggableGUIApplication app) {

    URL url = getClass().getResource("cog.png");
    if (url != null) { // Should always be true
      try {
        icon = new ImageIcon(ImageIO.read(url));
      } catch (IOException ioe) {
        app.displayException(ioe);
      }
    }

    MacroPrefs prefs = loadPrefs();

    RText rtext = (RText) app;
    this.app = rtext;
    StandardAction a = new NewMacroAction(this, rtext, msg);
    a.setAccelerator(prefs.newMacroAccelerator);
    rtext.addAction(NEW_MACRO_ACTION, a);

    a = new EditMacrosAction(rtext, msg);
    a.setAccelerator(prefs.editMacrosAccelerator);
    rtext.addAction(EDIT_MACROS_ACTION, a);
  }