From: <jen...@us...> - 2008-09-15 13:18:02
|
Revision: 1212 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1212&view=rev Author: jenslehmann Date: 2008-09-15 13:17:51 +0000 (Mon, 15 Sep 2008) Log Message: ----------- large number of GUI fixes and improvements Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/cli/Start.java trunk/src/dl-learner/org/dllearner/gui/ComponentPanel.java trunk/src/dl-learner/org/dllearner/gui/Config.java trunk/src/dl-learner/org/dllearner/gui/TutorialWindow.java trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelBoolean.java trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelDouble.java trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelInteger.java trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelString.java trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelStringSet.java trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelStringTupleList.java trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelURL.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/gui/tutorial.html Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-09-15 11:53:03 UTC (rev 1211) +++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-09-15 13:17:51 UTC (rev 1212) @@ -328,7 +328,7 @@ * this way the CLI will automatically support any configuration options * supported by the component */ - public static void configureComponent(ComponentManager cm, Component component, + private static void configureComponent(ComponentManager cm, Component component, ConfParser parser) { String prefix = confMapper.getComponentString(component.getClass()); if (prefix != null) Modified: trunk/src/dl-learner/org/dllearner/gui/ComponentPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ComponentPanel.java 2008-09-15 11:53:03 UTC (rev 1211) +++ trunk/src/dl-learner/org/dllearner/gui/ComponentPanel.java 2008-09-15 13:17:51 UTC (rev 1212) @@ -28,7 +28,7 @@ private static final long serialVersionUID = -7678275020058043937L; private Config config; -// private StartGUI startGUI; + private StartGUI startGUI; private List<Class<? extends Component>> selectableComponents; private OptionPanel optionPanel; private Class<? extends Component> panelClass; @@ -46,7 +46,7 @@ super(new BorderLayout()); this.config = config; -// this.startGUI = startGUI; + this.startGUI = startGUI; this.panelClass = panelClass; // get all classes of the correct type @@ -99,11 +99,14 @@ public void actionPerformed(ActionEvent e) { if(e.getSource() == comboBox) { - System.out.println("TESTzz"); // change component and update option panel Class<? extends Component> c = selectableComponents.get(comboBox.getSelectedIndex()); currentComponent = changeInstance(c); updateOptionPanel(); + // if the component does not have mandatory values, we can + // enable the following tabs + config.enableComponentsIfPossible(); + startGUI.updateTabs(); } else if (e.getSource() == clearButton) { // clearing everything corresponds to changing to an unconfigured // component of the same type Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-09-15 11:53:03 UTC (rev 1211) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-09-15 13:17:51 UTC (rev 1212) @@ -40,6 +40,7 @@ import org.dllearner.core.config.ConfigOption; import org.dllearner.kb.KBFile; import org.dllearner.kb.OWLFile; +import org.dllearner.kb.sparql.SparqlKnowledgeSource; import org.dllearner.learningproblems.PosNegLP; /** @@ -530,7 +531,7 @@ cm.applyConfigEntry(component, entry); // enable tabs if setting the value completed mandatory settings - enableTabsIfPossible(); + enableComponentsIfPossible(); // invalidate components if(component instanceof KnowledgeSource) { needsInit[0] = true; @@ -563,22 +564,49 @@ gui.updateTabs(); } - private void enableTabsIfPossible() { - if(mandatoryOptionsSpecified(source)) { - isEnabled[0] = true; - } - if(mandatoryOptionsSpecified(reasoner) && isEnabled[0]) { - isEnabled[1] = true; - } - if(mandatoryOptionsSpecified(lp) && isEnabled[1]) { - isEnabled[2] = true; - } - if(mandatoryOptionsSpecified(la) && isEnabled[1] && isEnabled[2]) { - isEnabled[3] = true; + // note it can also happend that components become + // disabled if mandatory fields are cleared + public void enableComponentsIfPossible() { + // 0: reasoner + // 1: problem + // 2: algorithm + // 3: run + + isEnabled[0] = mandatoryOptionsSpecified(source); + isEnabled[1] = isEnabled[0] && mandatoryOptionsSpecified(reasoner); + isEnabled[2] = isEnabled[0] && isEnabled[1] && mandatoryOptionsSpecified(lp); + isEnabled[3] = isEnabled[0] && isEnabled[1] && isEnabled[2] && mandatoryOptionsSpecified(la); + + + /* + // enable reasoner iff source has all options + isEnabled[0] = mandatoryOptionsSpecified(source); + + // enable problem if reasoner has all options + if(isEnabled[0]) { + isEnabled[1] = mandatoryOptionsSpecified(reasoner); + } else { + isEnabled[1] = false; } + + // enable algorithm if reasoner enabled and problem + // has all options + if(isEnabled[0]) { + isEnabled[2] = mandatoryOptionsSpecified(lp); + } else { + isEnabled[2] = false; + } + + // enable run panel if al + isEnabled[3] = mandatoryOptionsSpecified(la); + + if(isEnabled[1] && isEnabled[2]) { + isEnabled[3] = mandatoryOptionsSpecified(la); + }*/ } // TODO use specification of mandatory variables + @SuppressWarnings("unchecked") public boolean mandatoryOptionsSpecified(Component component) { // System.out.println("check mandatory options for " + component.getClass().getName()); if(component instanceof OWLFile) { @@ -590,10 +618,17 @@ return false; } } else if(component instanceof PosNegLP) { - if(cm.getConfigOptionValue(component, "positiveExamples")==null || cm.getConfigOptionValue(component, "negativeExamples") == null) { + if(cm.getConfigOptionValue(component, "positiveExamples")==null || cm.getConfigOptionValue(component, "negativeExamples") == null + || ((Set<String>)cm.getConfigOptionValue(component, "positiveExamples")).size()==0 + || ((Set<String>)cm.getConfigOptionValue(component, "negativeExamples")).size()==0) { return false; } + } else if(component instanceof SparqlKnowledgeSource) { + if(cm.getConfigOptionValue(component, "instances")==null || ((Set<String>)cm.getConfigOptionValue(component, "instances")).size()==0) { + return false; + } } + return true; } Modified: trunk/src/dl-learner/org/dllearner/gui/TutorialWindow.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/TutorialWindow.java 2008-09-15 11:53:03 UTC (rev 1211) +++ trunk/src/dl-learner/org/dllearner/gui/TutorialWindow.java 2008-09-15 13:17:51 UTC (rev 1212) @@ -19,16 +19,20 @@ */ package org.dllearner.gui; -import java.awt.Dimension; +import java.awt.BorderLayout; +import java.net.URL; import javax.swing.JFrame; import javax.swing.JLabel; +import javax.swing.JScrollPane; +import javax.swing.JTextPane; +import javax.swing.SwingWorker; /** * Window displaying a tutorial for the DL-Learner GUI. * * @author Jens Lehmann - * + * */ public class TutorialWindow extends JFrame { @@ -39,35 +43,74 @@ setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setLocationByPlatform(true); setSize(300, 600); + setVisible(true); + + getContentPane().setLayout(new BorderLayout()); + final JLabel label = new JLabel("Loading HTML help page."); + add(label, BorderLayout.NORTH); + final JTextPane tp = new JTextPane(); + JScrollPane js = new JScrollPane(); + js.getViewport().add(tp); + add(js, BorderLayout.CENTER); + + SwingWorker<Boolean, Boolean> worker = new SwingWorker<Boolean, Boolean>() { + @Override + public Boolean doInBackground() { + + try { + URL url = getClass().getResource("tutorial.html"); + tp.setPage(url); + } catch (Exception e) { + e.printStackTrace(); + } + +// label.setText("Displaying tutorial.html."); + remove(label); + repaint(); + + return true; + } + }; + worker.execute(); + // display tutorial text - String text = "<html><h2>Quick Tutorial</h2><p align=\"justify\">DL-Learner has a component" + - " based design to make it easier to extend and use. There are four " + - "components corresponding to the tabs you see: knowledge source, " + - "reasoner, learning problem, and learning algorithm. There are various " + - "components available of each type (selectable at the top of each tab). " + - "Each component has configuration options associated with it (middle of the" + - " tab, scrollable), which you can use to specify the settings for the component.</p>" + - "<br /><p align=\"justify\">In order to create a learning problem, " + - "you have to choose and configure all four types of components." + - " The run tab plays a special role: It is used to start the learning algorithm" + - " and display statistical information.</p>" + - "<br /><p><i>Tab color explanation:</i> <br />gray = cannot be configured yet (mandatory configuration values missing)<br />" + - "red = needs to be initialised<br />black = component has been initialised</p>" + - "<br /><p><i>Further references:</i><br />" + - "Homepage: <a href=\"http://dl-learner.org\">http://dl-learner.org</a><br />" + - "DL-Learner Architecture: <a href=\"http://dl-learner.org/wiki/Architecture\">http://dl-learner.org/wiki/Architecture</a>" + - "</p><br /><p>Please send questions to le...@in....</p></html>"; - JLabel label = new JLabel(text); - label.setMaximumSize(new Dimension(300,500)); - add(label); -// JScrollPane scrollPane = new JScrollPane(label); -// scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); -// scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); -// scrollPane.setPreferredSize(new Dimension(300,500)); -// add(scrollPane); - - setVisible(true); - } - + // String text = "<html><h2>Quick Tutorial</h2><p + // align=\"justify\">DL-Learner has a component" + + // " based design to make it easier to extend and use. There are four " + // + + // "components corresponding to the tabs you see: knowledge source, " + + // "reasoner, learning problem, and learning algorithm. There are + // various " + + // "components available of each type (selectable at the top of each + // tab). " + + // "Each component has configuration options associated with it (middle + // of the" + + // " tab, scrollable), which you can use to specify the settings for the + // component.</p>" + + // "<br /><p align=\"justify\">In order to create a learning problem, " + // + + // "you have to choose and configure all four types of components." + + // " The run tab plays a special role: It is used to start the learning + // algorithm" + + // " and display statistical information.</p>" + + // "<br /><p><i>Tab color explanation:</i> <br />gray = cannot be + // configured yet (mandatory configuration values missing)<br />" + + // "red = needs to be initialised<br />black = component has been + // initialised</p>" + + // "<br /><p><i>Further references:</i><br />" + + // "Homepage: <a + // href=\"http://dl-learner.org\">http://dl-learner.org</a><br />" + + // "DL-Learner Architecture: <a + // href=\"http://dl-learner.org/wiki/Architecture\">http://dl-learner.org/wiki/Architecture</a>" + // + + // "</p><br /><p>Please send questions to + // le...@in....</p></html>"; + // JLabel label = new JLabel(text); + // label.setMaximumSize(new Dimension(300,500)); + // add(label); + + // setVisible(true); + } + } Added: trunk/src/dl-learner/org/dllearner/gui/tutorial.html =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/tutorial.html (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/tutorial.html 2008-09-15 13:17:51 UTC (rev 1212) @@ -0,0 +1,42 @@ +<html> + <head> + <title>Quick Tutorial for DL-Learner GUI</title> + </head> + <body style="font-family: Verdana"> + +<h2>Quick Tutorial</h2> + +<p align=\"justify\"> +DL-Learner has a component based design to make it easier to +extend and use. There are four components corresponding to the +tabs you see: knowledge source, reasoner, learning problem, and +learning algorithm. There are various components available of +each type (selectable at the top of each tab). Each component +has configuration options associated with it (middle of the tab, +scrollable), which you can use to specify the settings for the +component. +</p><br /> + +<p align=\"justify\"> +In order to create a learning problem, you have to choose and +configure all four types of components. The run tab plays a +special role: It is used to start the learning algorithm +and display statistical information. +</p><br /> + +<p> +<i>Tab heads explanation:</i><br /> +gray/disabled = cannot be configured yet (mandatory configuration values missing)<br /> +red = needs to be initialised<br /> +black = component has been initialised +</p><br /> + +<p><i>Further references:</i><br /> +Homepage: <a href="http://dl-learner.org">http://dl-learner.org</a><br /> +DL-Learner Architecture: <a href="http://dl-learner.org/wiki/Architecture">http://dl-learner.org/wiki/Architecture</a> +</p><br /> + +<p>Please send questions to le...@in....</p> + + </body> +</html> \ No newline at end of file Modified: trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelBoolean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelBoolean.java 2008-09-15 11:53:03 UTC (rev 1211) +++ trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelBoolean.java 2008-09-15 13:17:51 UTC (rev 1212) @@ -26,8 +26,6 @@ import org.dllearner.core.Component; import org.dllearner.core.config.BooleanConfigOption; -import org.dllearner.core.config.ConfigEntry; -import org.dllearner.core.config.InvalidConfigOptionValueException; import org.dllearner.gui.Config; /** @@ -55,39 +53,10 @@ else value = true; - BooleanConfigOption specialOption; - specialOption = (BooleanConfigOption) config.getComponentManager().getConfigOption( - component.getClass(), configOption.getName()); - if (specialOption.isValidValue(value)) { - try { - ConfigEntry<Boolean> specialEntry = new ConfigEntry<Boolean>(specialOption, value); - config.getComponentManager().applyConfigEntry(component, specialEntry); - // System.out.println("set Boolean: " + configOption.getName() + - // " = " + value); - } catch (InvalidConfigOptionValueException s) { - s.printStackTrace(); - } - } else - System.out.println("Boolean: not valid value"); + fireValueChanged(value); + } - public void setEntry() { - BooleanConfigOption specialOption; - specialOption = (BooleanConfigOption) config.getComponentManager().getConfigOption( - component.getClass(), configOption.getName()); - if (specialOption.isValidValue(value)) { - try { - ConfigEntry<Boolean> specialEntry = new ConfigEntry<Boolean>(specialOption, value); - config.getComponentManager().applyConfigEntry(component, specialEntry); - // System.out.println("set Boolean: " + configOption.getName() + - // " = " + value); - } catch (InvalidConfigOptionValueException s) { - s.printStackTrace(); - } - } else - System.out.println("Boolean: not valid value"); - } - @Override public void buildWidgetPanel() { add(getLabel()); @@ -96,8 +65,8 @@ if (value == null) value = false; - else - setEntry(); +// else +// setEntry(); // set cb-index String[] kbBoxItems = { "false", "true" }; Modified: trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelDouble.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelDouble.java 2008-09-15 11:53:03 UTC (rev 1211) +++ trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelDouble.java 2008-09-15 13:17:51 UTC (rev 1212) @@ -20,16 +20,16 @@ * */ +import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; +import javax.swing.JLabel; import javax.swing.JTextField; import org.dllearner.core.Component; -import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.DoubleConfigOption; -import org.dllearner.core.config.InvalidConfigOptionValueException; import org.dllearner.gui.Config; /** @@ -44,6 +44,7 @@ private static final long serialVersionUID = 5238903690721116289L; private JButton setButton = new JButton("Set"); + private JLabel problemLabel; // private Class<? extends Component> componentOption; @@ -56,31 +57,23 @@ public void actionPerformed(ActionEvent e) { if (e.getSource() == setButton) { - setEntry(); + // TODO need better way for double parsing than throwing an + // exception + try { + double value = Integer.valueOf(doubleField.getText()); + fireValueChanged(value); + problemLabel.setText(""); + } catch(NumberFormatException e1) { + problemLabel.setText("Please enter a valid double value."); + } } } - public void setEntry() { - DoubleConfigOption specialOption; - value = Double.parseDouble(doubleField.getText()); // get from input - specialOption = (DoubleConfigOption) config.getComponentManager().getConfigOption( - component.getClass(), configOption.getName()); - if (specialOption.isValidValue(value)) { - try { - ConfigEntry<Double> specialEntry = new ConfigEntry<Double>(specialOption, value); - config.getComponentManager().applyConfigEntry(component, specialEntry); - // System.out.println("set Double: " + configOption.getName() + - // " = " + value); - } catch (InvalidConfigOptionValueException s) { - s.printStackTrace(); - } - } else - System.out.println("Double: not valid value"); - } - @Override public void buildWidgetPanel() { add(getLabel()); + problemLabel = new JLabel(); + problemLabel.setForeground(Color.RED); value = config.getConfigOptionValue(component, configOption); @@ -90,7 +83,7 @@ value = 0.0; else { doubleField.setText(value.toString()); - setEntry(); +// setEntry(); } doubleField.setText(value.toString()); Modified: trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelInteger.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelInteger.java 2008-09-15 11:53:03 UTC (rev 1211) +++ trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelInteger.java 2008-09-15 13:17:51 UTC (rev 1212) @@ -20,16 +20,16 @@ * */ +import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; +import javax.swing.JLabel; import javax.swing.JTextField; import org.dllearner.core.Component; -import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.IntegerConfigOption; -import org.dllearner.core.config.InvalidConfigOptionValueException; import org.dllearner.gui.Config; /** @@ -37,16 +37,18 @@ * org.dllearner.core.config.IntegerConfigOption. * * @author Tilo Hielscher + * @author Jens Lehmann * */ public class WidgetPanelInteger extends AbstractWidgetPanel<Integer> implements ActionListener { private static final long serialVersionUID = -1802111225835164644L; - private JButton setButton = new JButton("Set"); + private JButton setButton; // = new JButton("Set"); + private JLabel problemLabel ; //= new JLabel(); private Integer value; - private JTextField integerField = new JTextField(3); + private JTextField integerField; // = new JTextField(3); public WidgetPanelInteger(Config config, Component component, IntegerConfigOption configOption) { super(config, component, configOption); @@ -54,31 +56,24 @@ public void actionPerformed(ActionEvent e) { if (e.getSource() == setButton) { - setEntry(); - } - } - public void setEntry() { - IntegerConfigOption specialOption; - value = Integer.parseInt(integerField.getText()); // get from input - specialOption = (IntegerConfigOption) config.getComponentManager().getConfigOption( - component.getClass(), configOption.getName()); - if (specialOption.isValidValue(value)) { + // TODO need better way for integer parsing than throwing an + // exception try { - ConfigEntry<Integer> specialEntry = new ConfigEntry<Integer>(specialOption, value); - config.getComponentManager().applyConfigEntry(component, specialEntry); - // System.out.println("set Integer: " + configOption.getName() + - // " = " + value); - } catch (InvalidConfigOptionValueException s) { - s.printStackTrace(); + int value = Integer.valueOf(integerField.getText()); + fireValueChanged(value); + problemLabel.setText(""); + } catch(NumberFormatException e1) { + problemLabel.setText("Please enter a valid integer value."); } - } else - System.out.println("Integer: not valid value"); + } } @Override public void buildWidgetPanel() { add(getLabel()); + problemLabel = new JLabel(); + problemLabel.setForeground(Color.RED); value = config.getConfigOptionValue(component, configOption); @@ -88,13 +83,14 @@ value = 0; else { integerField.setText(value.toString()); - setEntry(); +// setEntry(); } integerField.setText(value.toString()); integerField.setToolTipText(configOption.getAllowedValuesDescription()); setButton.addActionListener(this); add(integerField); - add(setButton); + add(setButton); + add(problemLabel); } } Modified: trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelString.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelString.java 2008-09-15 11:53:03 UTC (rev 1211) +++ trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelString.java 2008-09-15 13:17:51 UTC (rev 1212) @@ -23,14 +23,11 @@ import java.awt.event.ActionListener; import javax.swing.JButton; -import javax.swing.JFileChooser; import javax.swing.JTextField; import org.dllearner.core.Component; import org.dllearner.core.config.StringConfigOption; import org.dllearner.gui.Config; -import org.dllearner.gui.ExampleFileChooser; -import org.dllearner.kb.OWLFile; /** * Panel for option String, defined in @@ -44,11 +41,10 @@ private static final long serialVersionUID = -2169739820989891226L; -// private JPanel widgetPanel = new JPanel(); - private JButton setButton; // = new JButton("Set"); + private JButton setButton; private String value; - private JTextField stringField; // = new JTextField(35); + private JTextField stringField; public WidgetPanelString(Config config, Component component, StringConfigOption configOption) { super(config, component, configOption); @@ -56,49 +52,12 @@ public void actionPerformed(ActionEvent e) { if (e.getSource() == setButton) { - if (configOption.getName().equals("filename") || configOption.getName().equals("url")) { - JFileChooser fc; - if(component instanceof OWLFile) { - fc = new ExampleFileChooser("owl"); - } else { - fc = new ExampleFileChooser("kb"); - } - - int returnVal = fc.showOpenDialog(this); - if (returnVal == JFileChooser.APPROVE_OPTION) { - value = fc.getSelectedFile().toString(); - stringField.setText(value); - } - } + // fire value changed event value = stringField.getText(); fireValueChanged(value); -// setEntry(); - // if url and value not "" - // necessary for init knowledge source - if (configOption.getName().equalsIgnoreCase("url") && !value.equalsIgnoreCase("")) { - } } } - /* - public void setEntry() { - StringConfigOption specialOption; - value = stringField.getText(); // get from input - specialOption = (StringConfigOption) config.getComponentManager().getConfigOption( - componentOption, configOption.getName()); - if (specialOption.isValidValue(value)) { - try { - ConfigEntry<String> specialEntry = new ConfigEntry<String>(specialOption, value); - config.getComponentManager().applyConfigEntry(component, specialEntry); - // System.out.println("set String: " + configOption.getName() + - // " = " + value); - } catch (InvalidConfigOptionValueException s) { - s.printStackTrace(); - } - } else - System.out.println("String: not valid value"); - }*/ - @Override public void buildWidgetPanel() { add(getLabel()); @@ -108,24 +67,25 @@ // default values can be null, so we interpret this as empty string if (value == null) { value = ""; - } - + } + // text field for strings stringField = new JTextField(35); stringField.setText(value); stringField.setToolTipText(configOption.getAllowedValuesDescription()); - - // set button (value is only updated when this button is pressed => would better without set) + + // set button (value is only updated when this button is pressed => + // would better without set) setButton = new JButton("Set"); setButton.addActionListener(this); - + add(stringField); add(setButton); - + // special handling for filename option if (configOption.getName().equals("filename")) setButton.setText("choose local file"); - + } } Modified: trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelStringSet.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelStringSet.java 2008-09-15 11:53:03 UTC (rev 1211) +++ trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelStringSet.java 2008-09-15 13:17:51 UTC (rev 1212) @@ -38,8 +38,6 @@ import javax.swing.JTextField; import org.dllearner.core.Component; -import org.dllearner.core.config.ConfigEntry; -import org.dllearner.core.config.InvalidConfigOptionValueException; import org.dllearner.core.config.StringSetConfigOption; import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.NamedClass; @@ -55,6 +53,7 @@ * options. Second layout shows a list of JCheckBox's. * * @author Tilo Hielscher + * @author Jens Lehmann * */ public class WidgetPanelStringSet extends AbstractWidgetPanel<Set<String>> implements ActionListener { @@ -64,17 +63,17 @@ private GridBagLayout gridbag = new GridBagLayout(); private GridBagConstraints constraints = new GridBagConstraints(); - private JPanel widgetPanel = new JPanel(); - private JButton addButton = new JButton("add"); - private JButton removeButton = new JButton("remove"); - private JButton clearButton = new JButton("clear"); - private JTextField stringField = new JTextField(30); + private JPanel widgetPanel; // = new JPanel(); + private JButton addButton; // = new JButton("add"); + private JButton removeButton; // = new JButton("remove"); + private JButton clearButton; // = new JButton("clear"); + private JTextField stringField; // = new JTextField(30); private Set<String> value = new HashSet<String>(); - private JList stringList = new JList(); - private DefaultListModel listModel = new DefaultListModel(); + private JList stringList; // = new JList(); + private DefaultListModel listModel; // = new DefaultListModel(); - private CheckBoxList cBL = new CheckBoxList(this); + private CheckBoxList cBL; // = new CheckBoxList(this); public WidgetPanelStringSet(Config config, Component component, StringSetConfigOption configOption) { super(config, component, configOption); @@ -86,6 +85,7 @@ Set<String> exampleSet = new HashSet<String>(); // add to list if (e.getSource() == addButton && !listModel.contains(stringField.getText())) { + System.out.println("add event"); listModel.addElement(stringField.getText()); } // remove selection @@ -108,41 +108,12 @@ } // set entry value = exampleSet; - setEntry(); +// setEntry(); + fireValueChanged(value); } } /** - * Use this, to set entry for layout 2. - */ - /* - public void specialSet() { - if (isSpecial()) { - this.value = cBL.getSelections(); - setEntry(); - } - }*/ - - public void setEntry() { - StringSetConfigOption specialOption; - specialOption = (StringSetConfigOption) config.getComponentManager().getConfigOption( - component.getClass(), configOption.getName()); - if (specialOption.isValidValue(value)) { - try { - ConfigEntry<Set<String>> specialEntry = new ConfigEntry<Set<String>>(specialOption, - value); - config.getComponentManager().applyConfigEntry(component, specialEntry); - // System.out.println("set StringSet: " + configOption.getName() - // + " = " + value); - } catch (InvalidConfigOptionValueException s) { - s.printStackTrace(); - } - } else - System.out.println("StringSet: not valid value"); - - } - - /** * Define GridBagConstraints */ private void buildConstraints(GridBagConstraints gbc, int gx, int gy, int gw, int gh, int wx, @@ -183,7 +154,7 @@ listModel = new DefaultListModel(); // fill list if (value != null) { - setEntry(); +// setEntry(); for (Iterator<String> iterator = value.iterator(); iterator.hasNext();) { String item = iterator.next(); listModel.addElement(item); Modified: trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelStringTupleList.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelStringTupleList.java 2008-09-15 11:53:03 UTC (rev 1211) +++ trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelStringTupleList.java 2008-09-15 13:17:51 UTC (rev 1212) @@ -39,8 +39,6 @@ import javax.swing.JTextField; import org.dllearner.core.Component; -import org.dllearner.core.config.ConfigEntry; -import org.dllearner.core.config.InvalidConfigOptionValueException; import org.dllearner.core.config.StringTupleListConfigOption; import org.dllearner.gui.Config; import org.dllearner.utilities.datastructures.StringTuple; @@ -58,19 +56,19 @@ private GridBagLayout gridbag = new GridBagLayout(); private GridBagConstraints constraints = new GridBagConstraints(); - private JPanel widgetPanel = new JPanel(); - private JButton addButton = new JButton("add"); - private JButton removeButton = new JButton("remove"); - private JButton clearButton = new JButton("clear"); - private JTextField stringFieldA = new JTextField(10); - private JTextField stringFieldB = new JTextField(10); - private List<StringTuple> exampleList = new LinkedList<StringTuple>(); + private JPanel widgetPanel; // = new JPanel(); + private JButton addButton; // = new JButton("add"); + private JButton removeButton; // = new JButton("remove"); + private JButton clearButton; // = new JButton("clear"); + private JTextField stringFieldA; // = new JTextField(10); + private JTextField stringFieldB; // = new JTextField(10); + private List<StringTuple> exampleList; // = new LinkedList<StringTuple>(); - private List<StringTuple> value = new LinkedList<StringTuple>(); - private JList stringList = new JList(); - private DefaultListModel listModel = new DefaultListModel(); + private List<StringTuple> value; // = new LinkedList<StringTuple>(); + private JList stringList; // = new JList(); + private DefaultListModel listModel; // = new DefaultListModel(); - private JButton setButton = new JButton("set"); + private JButton setButton; // = new JButton("set"); public WidgetPanelStringTupleList(Config config, Component component, StringTupleListConfigOption configOption) { super(config, component, configOption); @@ -102,9 +100,11 @@ } // set entry value = exampleList; - setEntry(); +// setEntry(); + fireValueChanged(value); } + /* public void setEntry() { StringTupleListConfigOption specialOption; specialOption = (StringTupleListConfigOption) config.getComponentManager().getConfigOption( @@ -121,7 +121,7 @@ } } else System.out.println("StringTupleList: not valid value"); - } + }*/ /** * Define GridBagConstraints @@ -162,7 +162,7 @@ value = config.getConfigOptionValue(component, configOption); if (value != null) { - setEntry(); +// setEntry(); exampleList = value; } Modified: trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelURL.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelURL.java 2008-09-15 11:53:03 UTC (rev 1211) +++ trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelURL.java 2008-09-15 13:17:51 UTC (rev 1212) @@ -113,14 +113,18 @@ setButton = new JButton("Set"); setButton.addActionListener(this); - chooseLocalButton = new JButton("Choose Local File"); - chooseLocalButton.addActionListener(this); - add(stringField); - add(setButton); - add(new JLabel(" or ")); - add(chooseLocalButton); + add(setButton); + // if the URL can refer to a file, we add the possibility to + // choose a local file + if(((URLConfigOption)configOption).refersToFile()) { + chooseLocalButton = new JButton("Choose Local File"); + chooseLocalButton.addActionListener(this); + add(new JLabel(" or ")); + add(chooseLocalButton); + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |