use of org.jivesoftware.spark.PluginManager in project Spark by igniterealtime.
the class SparkPlugUI method showOperationButton.
public void showOperationButton() {
final PluginManager pluginManager = PluginManager.getInstance();
if (!pluginManager.isInstalled(_plugin)) {
installButton.setIcon(SparkRes.getImageIcon(SparkRes.SMALL_ADD_IMAGE));
} else {
installButton.setIcon(SparkRes.getImageIcon(SparkRes.SMALL_DELETE));
}
installButton.setVisible(true);
}
use of org.jivesoftware.spark.PluginManager in project Spark by igniterealtime.
the class PluginViewer method loadInstalledPlugins.
private void loadInstalledPlugins() {
PluginManager pluginManager = PluginManager.getInstance();
List<PublicPlugin> plugins = pluginManager.getPublicPlugins();
for (Object plugin1 : plugins) {
PublicPlugin plugin = (PublicPlugin) plugin1;
final SparkPlugUI ui = new SparkPlugUI(plugin);
ui.useLocalIcon();
installedPanel.add(ui);
addSparkPlugUIListener(ui);
}
}
use of org.jivesoftware.spark.PluginManager in project Spark by igniterealtime.
the class PluginViewer method loadAvailablePlugins.
private void loadAvailablePlugins() {
availablePanel.removeAll();
availablePanel.invalidate();
availablePanel.validate();
availablePanel.repaint();
JLabel label = new JLabel(Res.getString("message.loading.please.wait"));
availablePanel.add(label);
SwingWorker worker = new SwingWorker() {
Collection<PublicPlugin> pluginList = null;
public Object construct() {
// Prepare HTTP post
final GetMethod post = new GetMethod(retrieveListURL);
// Get HTTP client
Protocol.registerProtocol("https", new Protocol("https", new EasySSLProtocolSocketFactory(), 443));
final HttpClient httpclient = new HttpClient();
if (Default.getBoolean("PLUGIN_REPOSITORY_USE_PROXY")) {
String proxyHost = System.getProperty("http.proxyHost");
String proxyPort = System.getProperty("http.proxyPort");
if (ModelUtil.hasLength(proxyHost) && ModelUtil.hasLength(proxyPort)) {
try {
httpclient.getHostConfiguration().setProxy(proxyHost, Integer.parseInt(proxyPort));
} catch (NumberFormatException e) {
Log.error(e);
}
}
}
try {
int result = httpclient.executeMethod(post);
if (result != 200) {
return null;
}
pluginList = getPluginList(post.getResponseBodyAsStream());
} catch (Exception ex) {
// Nothing to do
}
return "ok";
}
public void finished() {
final PluginManager pluginManager = PluginManager.getInstance();
if (pluginList == null) {
availablePanel.removeAll();
availablePanel.invalidate();
availablePanel.validate();
availablePanel.repaint();
UIManager.put("OptionPane.okButtonText", Res.getString("ok"));
JOptionPane.showMessageDialog(availablePanel, Res.getString("message.plugins.not.available"), Res.getString("title.error"), JOptionPane.ERROR_MESSAGE);
return;
}
Iterator<PublicPlugin> plugs = pluginList.iterator();
availablePanel.removeAll();
while (plugs.hasNext()) {
PublicPlugin plugin = plugs.next();
if (!pluginManager.isInstalled(plugin)) {
SparkPlugUI ui = new SparkPlugUI(plugin);
availablePanel.add(ui);
addSparkPlugUIListener(ui);
}
}
availablePanel.invalidate();
availablePanel.validate();
availablePanel.repaint();
}
};
worker.start();
}
use of org.jivesoftware.spark.PluginManager in project Spark by igniterealtime.
the class Spark method startup.
public void startup() {
if (System.getenv("APPDATA") != null && !System.getenv("APPDATA").equals("")) {
USER_SPARK_HOME = System.getenv("APPDATA") + "/" + getUserConf();
} else {
USER_SPARK_HOME = System.getProperties().getProperty("user.home") + "/" + getUserConf();
}
String current = System.getProperty("java.library.path");
String classPath = System.getProperty("java.class.path");
// Set UIManager properties for JTree
System.setProperty("apple.laf.useScreenMenuBar", "true");
/**
* Update Library Path *
*/
StringBuilder buf = new StringBuilder();
buf.append(current);
buf.append(";");
SparkCompatibility sparkCompat = new SparkCompatibility();
try {
// Absolute paths to a collection of files or directories to skip
Collection<String> skipFiles = new HashSet<>();
skipFiles.add(new File(USER_SPARK_HOME, "plugins").getAbsolutePath());
sparkCompat.transferConfig(USER_SPARK_HOME, skipFiles);
} catch (IOException e) {
// Do nothing
}
RESOURCE_DIRECTORY = initializeDirectory("resources");
BIN_DIRECTORY = initializeDirectory("bin");
LOG_DIRECTORY = initializeDirectory("logs");
File USER_DIRECTORY = initializeDirectory("user");
PLUGIN_DIRECTORY = initializeDirectory("plugins");
File XTRA_DIRECTORY = initializeDirectory("xtra");
SECURITY_DIRECTORY = initializeDirectory("security");
// TODO implement copyEmoticonFiles();
final String workingDirectory = System.getProperty("appdir");
if (workingDirectory == null) {
if (!RESOURCE_DIRECTORY.exists() || !LOG_DIRECTORY.exists() || !USER_DIRECTORY.exists() || !PLUGIN_DIRECTORY.exists() || !XTRA_DIRECTORY.exists() || !SECURITY_DIRECTORY.exists()) {
UIManager.put("OptionPane.okButtonText", Res.getString("ok"));
JOptionPane.showMessageDialog(new JFrame(), "Unable to create directories necessary for runtime.", "Spark Error", JOptionPane.ERROR_MESSAGE);
System.exit(1);
}
} else // This is the Spark.exe or Spark.dmg installed executable.
{
// This is the installed executable.
File workingDir = new File(workingDirectory);
RESOURCE_DIRECTORY = initializeDirectory(workingDir, "resources");
BIN_DIRECTORY = initializeDirectory(workingDir, "bin");
File emoticons = new File(XTRA_DIRECTORY, "emoticons").getAbsoluteFile();
if (!emoticons.exists()) {
// Copy emoticon files from install directory to the spark user home directory
}
SECURITY_DIRECTORY = initializeDirectory(workingDir, "security");
LOG_DIRECTORY = initializeDirectory("logs");
LOG_DIRECTORY = new File(USER_SPARK_HOME, "logs").getAbsoluteFile();
LOG_DIRECTORY.mkdirs();
try {
buf.append(RESOURCE_DIRECTORY.getCanonicalPath()).append(";");
} catch (IOException e) {
e.printStackTrace();
}
}
// Set default language set by the user.
loadLanguage();
/**
* Loads the LookandFeel
*/
LookAndFeelManager.loadPreferredLookAndFeel();
buf.append(classPath);
buf.append(";").append(RESOURCE_DIRECTORY.getAbsolutePath());
// Update System Properties
System.setProperty("java.library.path", buf.toString());
System.setProperty("sun.java2d.noddraw", "true");
System.setProperty("file.encoding", "UTF-8");
SwingUtilities.invokeLater(() -> {
// Start Application
new Spark();
});
// load plugins before Workspace initialization to avoid any UI delays
// during plugin rendering
final PluginManager pluginManager = PluginManager.getInstance();
pluginManager.loadPlugins();
installBaseUIProperties();
if (Default.getBoolean("CHANGE_COLORS_DISABLED")) {
ColorSettingManager.restoreDefault();
}
try {
EventQueue.invokeAndWait(() -> {
final LoginDialog dialog = UIComponentRegistry.createLoginDialog();
dialog.invoke(new JFrame());
});
} catch (Exception ex) {
ex.printStackTrace();
}
}
Aggregations