4,10 → 4,10 |
* Coded by: Group 5, software practice summer 2003 |
* University of Bielefeld, Germany |
* |
* @version $Revision: 1.48 $ |
* @version $Revision: 1.49 $ |
* |
* Last modification: $Date: 2003/07/21 17:55:22 $ |
* $Id: PluginManager.java,v 1.48 2003/07/21 17:55:22 smcsporr Exp $ |
* Last modification: $Date: 2003/07/22 06:31:31 $ |
* $Id: PluginManager.java,v 1.49 2003/07/22 06:31:31 swalkenh Exp $ |
*/ |
|
package src.plugins; |
24,7 → 24,6 |
import java.util.jar.Attributes; |
import java.util.jar.JarFile; |
import java.util.jar.Manifest; |
import javax.swing.JFileChooser; |
import javax.swing.JOptionPane; |
import javax.swing.event.TreeSelectionEvent; |
import javax.swing.event.TreeSelectionListener; |
52,11 → 51,11 |
* This class provides methods for searching and loading plugins. |
* |
* status: to be continued |
* TODO comments, LogInterface ... |
* TODO problem if no active plugin..., comments, LogInterface ... |
* |
* @author Sascha Walkenhorst |
* |
* @version $Revision: 1.48 $ Last modification: $Date: 2003/07/21 17:55:22 $ |
* @version $Revision: 1.49 $ Last modification: $Date: 2003/07/22 06:31:31 $ |
*/ |
public class PluginManager implements TreeSelectionListener, |
PluginManagerInterface, |
262,11 → 261,9 |
* @return The path of the directory the jar-archives of the plugins are |
* located. <code>null</code> if no path has been found. |
* |
* TODO chooser dialog |
* |
* author Sascha Walkenhorst |
* |
* Last Revision: 21-Jul-2003 by Sascha W. |
* Last Revision: 22-Jul-2003 by Sascha W. |
*/ |
private String readPluginsPath(Document config) { |
String candidate = null; |
307,17 → 304,14 |
|
/* case: user must choose a path */ |
if (!candidateIsOK) { |
JFileChooser chooser = new JFileChooser(); |
chooser.setDialogTitle("Choose the directory the plugins are located."); |
chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); |
//Component dummy = new Component(); |
int selection = chooser.showOpenDialog(null); |
if (selection == JFileChooser.APPROVE_OPTION) { |
candidate = chooser.getCurrentDirectory().getPath(); |
|
//testing output |
System.out.println("path of plugins: " + candidate); |
} |
candidate = JOptionPane.showInputDialog( |
+ "\nold value:", |
+ candidate); |
+ |
+ //testing output |
+ System.out.println("selected path of plugins: " + candidate); |
} |
|
return candidate; |
@@ -678,11 +672,9 @@ |
* @return The name of the default plugin. <code>null</code> if wanted plugin |
* is not available. |
* |
- * TODO test selection |
- * |
* author Sascha Walkenhorst |
* |
- * Last Revision: 21-Jul-2003 by Sascha W. |
+ * Last Revision: 22-Jul-2003 by Sascha W. |
*/ |
private String readDefaultPluginName(Document config) { |
String candidate = null; |
@@ -715,8 +707,6 @@ |
) { |
candidate = chooseDefaultPluginName(); |
|
-// ... |
- |
//testing output |
System.out.println("selected default plugin: " + candidate); |
} |
@@ -726,35 +716,28 @@ |
|
|
/** |
- * ... |
+ * Shows a dialog to let the user choose a default plugin. The dialog has |
+ * a list of loaded plugins, made of <code>plugins</code>. |
* |
* @return The chosen plugin. <code>null</code> if none is selected. |
* |
- * TODO improve dialog, comment |
- * |
* author Sascha Walkenhorst |
* |
- * Last revision: 21-Jul-2003 by Sascha W. |
+ * Last revision: 22-Jul-2003 by Sascha W. |
*/ |
private String chooseDefaultPluginName() { |
/* create the available plugins as options for dialog */ |
Object[] options = plugins.keySet().toArray(); |
|
- int selected = JOptionPane.showOptionDialog(null, |
+ String selected = (String) JOptionPane.showInputDialog(null, |
+ "which plugin should act as the default plugin", |
"default plugin selection", |
- "which plugin should act as the default plugin", |
- JOptionPane.CANCEL_OPTION, |
JOptionPane.QUESTION_MESSAGE, |
null, |
options, |
null); |
- |
- /* case: the selection was not aborted */ |
- if (selected != JOptionPane.CANCEL_OPTION) { |
- return (String) options[selected]; |
- } |
|
- return null; |
+ return selected; |
} |
|
|
@@ -778,11 +761,9 @@ |
* |
* @see javax.swing.event.TreeSelectionListener#valueChanged(javax.swing.event.TreeSelectionEvent) |
* |
- * TODO if no plugin is available ... |
- * |
* author Sascha Walkenhorst |
* |
- * Last Revision: 19-Jul-2003 by Matthias D. |
+ * Last Revision: 22-Jul-2003 by Sascha W. |
*/ |
public void valueChanged(TreeSelectionEvent tSE) { |
/* case: a new element has been selected */ |
@@ -820,6 +801,13 @@ |
|
/* get the associated plugin */ |
String associatedPlugin = getAssociatedPlugin(element); |
+ |
+ /* case: no default plugin has been selected -> break up*/ |
+ if (associatedPlugin == null) { |
+ System.out.println("no default plugin has been selected..."); |
+ return; |
+ } |
+ |
//testing output |
//log(LogInterface.TYPE_INFO, "PluginManger: selected element: " + element |
// + ", associated with " + associatedPlugin); |
@@ -901,6 +889,10 @@ |
/* lastUpdatedNode initialised */ |
lastUpdatedNode=null; |
} |
+ /* case: no plugin has been found */ |
+ else { |
+ System.out.println("no plugin has been selected..."); |
+ } |
} |
} |
|