Updating plugin framework.

git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@4722 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Derek DeMoro 2006-07-31 15:48:44 +00:00 committed by derek
parent 2468ef6ea7
commit a73ae60224
4 changed files with 79 additions and 12 deletions

View File

@ -22,8 +22,6 @@ import org.jivesoftware.spark.plugin.PublicPlugin;
import org.jivesoftware.spark.util.URLFileSystem; import org.jivesoftware.spark.util.URLFileSystem;
import org.jivesoftware.spark.util.log.Log; import org.jivesoftware.spark.util.log.Log;
import javax.swing.SwingUtilities;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.FilenameFilter; import java.io.FilenameFilter;
@ -43,6 +41,8 @@ import java.util.jar.JarEntry;
import java.util.jar.JarFile; import java.util.jar.JarFile;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
import javax.swing.SwingUtilities;
/** /**
* This manager is responsible for the loading of all Plugins and Workspaces within Spark environment. * This manager is responsible for the loading of all Plugins and Workspaces within Spark environment.
* *
@ -83,6 +83,18 @@ public class PluginManager implements MainWindowListener {
} }
private PluginManager() { private PluginManager() {
try {
PLUGINS_DIRECTORY = new File(Spark.getBinDirectory().getParentFile(), "plugins").getCanonicalFile();
}
catch (IOException e) {
Log.error(e);
}
// Copy Files over if not on Windows. This is a workaround for installation issues.
if (!Spark.isWindows()) {
copyFiles();
}
SparkManager.getMainWindow().addMainWindowListener(this); SparkManager.getMainWindow().addMainWindowListener(this);
// Create the extension directory if one does not exist. // Create the extension directory if one does not exist.
@ -91,6 +103,30 @@ public class PluginManager implements MainWindowListener {
} }
} }
private void copyFiles() {
// Current Plugin directory
File newPlugins = new File(Spark.getLogDirectory().getParentFile(), "plugins").getAbsoluteFile();
newPlugins.mkdirs();
File[] files = PLUGINS_DIRECTORY.listFiles();
final int no = files != null ? files.length : 0;
for (int i = 0; i < no; i++) {
File file = files[i];
if (file.isFile()) {
// Copy over
File newFile = new File(newPlugins, file.getName());
try {
URLFileSystem.copy(file.toURL(), newFile);
}
catch (IOException e) {
Log.error(e);
}
}
}
PLUGINS_DIRECTORY = newPlugins;
}
/** /**
* Loads all {@link Plugin} from the agent plugins.xml and extension lib. * Loads all {@link Plugin} from the agent plugins.xml and extension lib.
*/ */

View File

@ -63,23 +63,23 @@ public class ChatPreference implements Preference {
public void load() { public void load() {
SwingWorker thread = new SwingWorker() { SwingWorker thread = new SwingWorker() {
LocalPreferences pref; LocalPreferences localPreferences;
public Object construct() { public Object construct() {
pref = SettingsManager.getLocalPreferences(); localPreferences = SettingsManager.getLocalPreferences();
return pref; return localPreferences;
} }
public void finished() { public void finished() {
String nickname = pref.getDefaultNickname(); String nickname = localPreferences.getDefaultNickname();
if (nickname == null) { if (nickname == null) {
nickname = SparkManager.getSessionManager().getUsername(); nickname = SparkManager.getSessionManager().getUsername();
} }
boolean showTime = pref.isTimeDisplayedInChat(); boolean showTime = localPreferences.isTimeDisplayedInChat();
boolean spellCheckerOn = pref.isSpellCheckerEnabled(); boolean spellCheckerOn = localPreferences.isSpellCheckerEnabled();
boolean notificationsOn = pref.isChatRoomNotificationsOn(); boolean notificationsOn = localPreferences.isChatRoomNotificationsOn();
boolean chatHistoryHidden = !pref.isChatHistoryEnabled(); boolean chatHistoryHidden = !localPreferences.isChatHistoryEnabled();
panel.setShowTime(showTime); panel.setShowTime(showTime);
panel.setSpellCheckerOn(spellCheckerOn); panel.setSpellCheckerOn(spellCheckerOn);
panel.setGroupChatNotificationsOn(notificationsOn); panel.setGroupChatNotificationsOn(notificationsOn);

View File

@ -13,6 +13,7 @@ package org.jivesoftware.sparkimpl.preference.chat;
import org.jivesoftware.spark.SparkManager; import org.jivesoftware.spark.SparkManager;
import org.jivesoftware.spark.component.VerticalFlowLayout; import org.jivesoftware.spark.component.VerticalFlowLayout;
import org.jivesoftware.spark.util.ResourceUtils; import org.jivesoftware.spark.util.ResourceUtils;
import org.jivesoftware.spark.util.ModelUtil;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JCheckBox; import javax.swing.JCheckBox;
@ -20,6 +21,7 @@ import javax.swing.JLabel;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JPasswordField; import javax.swing.JPasswordField;
import javax.swing.JTextField;
import java.awt.GridBagConstraints; import java.awt.GridBagConstraints;
import java.awt.GridBagLayout; import java.awt.GridBagLayout;
@ -46,6 +48,9 @@ public class ChatPreferencePanel extends JPanel implements ActionListener {
private JLabel confirmationPasswordLabel = new JLabel(); private JLabel confirmationPasswordLabel = new JLabel();
private JCheckBox hideChatHistory = new JCheckBox(); private JCheckBox hideChatHistory = new JCheckBox();
private JTextField fileTransferTimeoutField = new JTextField();
/** /**
* Constructor invokes UI setup. * Constructor invokes UI setup.
@ -82,6 +87,13 @@ public class ChatPreferencePanel extends JPanel implements ActionListener {
chatWindowPanel.add(hideChatHistory, new GridBagConstraints(0, 3, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); chatWindowPanel.add(hideChatHistory, new GridBagConstraints(0, 3, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
final JLabel label = new JLabel();
ResourceUtils.resLabel(label, fileTransferTimeoutField, "&Transfer Timeout(min):");
chatWindowPanel.add(label, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
chatWindowPanel.add(fileTransferTimeoutField, new GridBagConstraints(1, 4, 1, 1, 0.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 100, 0));
generalPanel.add(passwordLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); generalPanel.add(passwordLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
generalPanel.add(passwordField, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 100, 0)); generalPanel.add(passwordField, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 100, 0));
generalPanel.add(confirmationPasswordLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); generalPanel.add(confirmationPasswordLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
@ -151,6 +163,19 @@ public class ChatPreferencePanel extends JPanel implements ActionListener {
return hideChatHistory.isSelected(); return hideChatHistory.isSelected();
} }
public void setFileTransferTimeout(int timeout){
fileTransferTimeoutField.setText(Integer.toString(timeout));
}
/*
public int getFileTransferTimeout(){
String value = fileTransferTimeoutField.getText();
if(ModelUtil.hasLength(value)){
}
}
*/
public void actionPerformed(ActionEvent actionEvent) { public void actionPerformed(ActionEvent actionEvent) {
if (hideChatHistory.isSelected()) { if (hideChatHistory.isSelected()) {
int ok = JOptionPane.showConfirmDialog(this, "Delete all previous history?", "Delete Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); int ok = JOptionPane.showConfirmDialog(this, "Delete all previous history?", "Delete Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);

View File

@ -394,6 +394,14 @@ public class LocalPreferences {
setBoolean("showEmptyGroups", shown); setBoolean("showEmptyGroups", shown);
} }
public int getFileTransferTimeout() {
return Integer.parseInt(props.getProperty("fileTransferTimeout", "1"));
}
public void setFileTransferTimeout(int minutes) {
props.setProperty("fileTransferTimeout", Integer.toString(minutes));
}
private boolean getBoolean(String property, boolean defaultValue) { private boolean getBoolean(String property, boolean defaultValue) {
return Boolean.parseBoolean(props.getProperty(property, Boolean.toString(defaultValue))); return Boolean.parseBoolean(props.getProperty(property, Boolean.toString(defaultValue)));
} }
@ -401,6 +409,4 @@ public class LocalPreferences {
private void setBoolean(String property, boolean value) { private void setBoolean(String property, boolean value) {
props.setProperty(property, Boolean.toString(value)); props.setProperty(property, Boolean.toString(value));
} }
} }