Search in sources :

Example 1 with UIParameterImpl

use of com.biglybt.pifimpl.local.ui.config.UIParameterImpl in project BiglyBT by BiglySoftware.

the class ConfigSectionPlugins method build.

@Override
public void build() {
    if (!CoreFactory.isCoreRunning()) {
        add(new LabelParameterImpl("core.not.available"));
    }
    String sep = File.separator;
    File fUserPluginDir = FileUtil.getUserFile("plugins");
    String sUserPluginDir;
    try {
        sUserPluginDir = fUserPluginDir.getCanonicalPath();
    } catch (Throwable e) {
        sUserPluginDir = fUserPluginDir.toString();
    }
    if (!sUserPluginDir.endsWith(sep)) {
        sUserPluginDir += sep;
    }
    File fAppPluginDir = FileUtil.getApplicationFile("plugins");
    String sAppPluginDir;
    try {
        sAppPluginDir = fAppPluginDir.getCanonicalPath();
    } catch (Throwable e) {
        sAppPluginDir = fAppPluginDir.toString();
    }
    if (!sAppPluginDir.endsWith(sep)) {
        sAppPluginDir += sep;
    }
    add(new LabelParameterImpl("ConfigView.pluginlist.whereToPut"));
    File dirUserPlugin = FileUtil.newFile(sUserPluginDir);
    if (!(dirUserPlugin.exists() && dirUserPlugin.isDirectory())) {
        dirUserPlugin = dirUserPlugin.getParentFile();
    }
    HyperlinkParameterImpl paramUserPluginDir = new HyperlinkParameterImpl("!" + sUserPluginDir.replaceAll("&", "&&") + "!", dirUserPlugin.getAbsolutePath());
    add(paramUserPluginDir);
    paramUserPluginDir.setIndent(1, false);
    add(new LabelParameterImpl("ConfigView.pluginlist.whereToPutOr"));
    File dirAppPlugin = FileUtil.newFile(sAppPluginDir);
    if (!(dirAppPlugin.exists() && dirAppPlugin.isDirectory())) {
        dirAppPlugin = dirAppPlugin.getParentFile();
    }
    HyperlinkParameterImpl paramAppPluginDir = new HyperlinkParameterImpl("!" + sAppPluginDir.replaceAll("&", "&&") + "!", dirAppPlugin.getAbsolutePath());
    add(paramAppPluginDir);
    paramAppPluginDir.setIndent(1, false);
    if (paramContextPluginList != null) {
        add(new LabelParameterImpl("ConfigView.pluginlist.info"));
        add("PluginList", new UIParameterImpl(paramContextPluginList, null));
    } else {
    // could setup params for each plugin
    }
}
Also used : UIParameterImpl(com.biglybt.pifimpl.local.ui.config.UIParameterImpl) LabelParameterImpl(com.biglybt.pifimpl.local.ui.config.LabelParameterImpl) HyperlinkParameterImpl(com.biglybt.pifimpl.local.ui.config.HyperlinkParameterImpl) File(java.io.File)

Aggregations

HyperlinkParameterImpl (com.biglybt.pifimpl.local.ui.config.HyperlinkParameterImpl)1 LabelParameterImpl (com.biglybt.pifimpl.local.ui.config.LabelParameterImpl)1 UIParameterImpl (com.biglybt.pifimpl.local.ui.config.UIParameterImpl)1 File (java.io.File)1