Example #1
0
  /**
   * Returns the language-dependent label with the given key. The search order is to look first in
   * the extension's <code>label</code> files and if the requested label is not found in the BlueJ
   * system <code>label</code> files. Extensions' labels are stored in a Property format and must be
   * jarred together with the extension. The path searched is equivalent to the bluej/lib/[language]
   * style used for the BlueJ system labels. E.g. to create a set of labels which can be used by
   * English, Italian and German users of an extension, the following files would need to be present
   * in the extension's Jar file:
   *
   * <pre>
   * lib/english/label
   * lib/italian/label
   * lib/german/label
   * </pre>
   *
   * The files named <code>label</code> would contain the actual label key/value pairs.
   *
   * @param key Description of the Parameter
   * @return The label value
   */
  public String getLabel(String key) {
    if (!myWrapper.isValid()) throw new ExtensionUnloadedException();

    // If there are no label for this extension I can only return the system ones.
    if (localLabels == null) return Config.getString(key, key);

    // In theory there are label for this extension let me try to get them
    String aLabel = localLabels.getProperty(key, null);

    // Found what I wanted, job done.
    if (aLabel != null) return aLabel;

    // ok, the only hope is to get it from the system
    return Config.getString(key, key);
  }
Example #2
0
  /**
   * Sets a property associated with this extension into the standard BlueJ property repository. The
   * property name does not need to be fully qualified since a prefix will be prepended to it.
   *
   * @param property The name of the required global property
   * @param value the required value of that property.
   */
  public void setExtensionPropertyString(String property, String value) {
    if (!myWrapper.isValid()) throw new ExtensionUnloadedException();

    String thisKey = myWrapper.getSettingsString(property);
    Config.putPropString(thisKey, value);
  }
Example #3
0
  /**
   * Return a property associated with this extension from the standard BlueJ property repository.
   * You must use the setExtensionPropertyString to write any property that you want stored. You can
   * then come back and retrieve it using this function.
   *
   * @param property The name of the required global property.
   * @param def The default value to use if the property cannot be found.
   * @return the value of that property.
   */
  public String getExtensionPropertyString(String property, String def) {
    if (!myWrapper.isValid()) throw new ExtensionUnloadedException();

    String thisKey = myWrapper.getSettingsString(property);
    return Config.getPropString(thisKey, def);
  }
Example #4
0
  /**
   * Returns a property from BlueJ's properties, or the given default value if the property is not
   * currently set.
   *
   * @param property The name of the required global property
   * @param def The default value to use if the property cannot be found.
   * @return the value of the property.
   */
  public String getBlueJPropertyString(String property, String def) {
    if (!myWrapper.isValid()) throw new ExtensionUnloadedException();

    return Config.getPropString(property, def);
  }
Example #5
0
  /**
   * Returns the path of the user configuration directory. This can be used to locate user dependent
   * information. Having the directory you can then locate a file within it.
   *
   * @return The userConfigDir value
   */
  public File getUserConfigDir() {
    if (!myWrapper.isValid()) throw new ExtensionUnloadedException();

    return Config.getUserConfigDir();
  }
Example #6
0
  /**
   * Returns the path of the <code>&lt;BLUEJ_HOME&gt;/lib</code> system directory. This can be used
   * to locate systemwide configuration files. Having the directory you can then locate a file
   * within it.
   *
   * @return The systemLibDir value
   */
  public File getSystemLibDir() {
    if (!myWrapper.isValid()) throw new ExtensionUnloadedException();

    return Config.getBlueJLibDir();
  }