From: <ton...@us...> - 2008-02-04 11:12:58
|
Revision: 487 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=487&view=rev Author: tonytacker Date: 2008-02-04 03:12:46 -0800 (Mon, 04 Feb 2008) Log Message: ----------- could be a way to change set<String> - change button should later open an extra window Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-03 04:55:57 UTC (rev 486) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-04 11:12:46 UTC (rev 487) @@ -68,6 +68,7 @@ super(new BorderLayout()); this.config = config; + problems = config.getComponentManager().getLearningProblems(); initButton = new JButton("Init LearningProblem"); initButton.addActionListener(this); @@ -78,8 +79,6 @@ choosePanel.add(getInstancesButton); cb.addActionListener(this); - problems = config.getComponentManager().getLearningProblems(); - // add into comboBox for (int i = 0; i < problems.size(); i++) { cb.addItem(config.getComponentManager().getComponentName( @@ -139,6 +138,10 @@ for (int i : selectedIndices) posExampleSet.add(individuals.get(i).toString()); config.setPosExampleSet(posExampleSet); + config.getComponentManager().applyConfigEntry( + config.getLearningProblem(), "positiveExamples", + config.getPosExampleSet()); + updateOptionPanel(); } }); @@ -153,6 +156,10 @@ for (int i : selectedIndices) negExampleSet.add(individuals.get(i).toString()); config.setNegExampleSet(negExampleSet); + config.getComponentManager().applyConfigEntry( + config.getLearningProblem(), "negativeExamples", + config.getNegExampleSet()); + updateOptionPanel(); } }); @@ -219,10 +226,8 @@ * after this, next tab can be used */ public void init() { + config.getComponentManager().applyConfigEntry( - config.getLearningProblem(), "positiveExamples", - config.getPosExampleSet()); - config.getComponentManager().applyConfigEntry( config.getLearningProblem(), "negativeExamples", config.getNegExampleSet()); config.getLearningProblem().init(); Modified: trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-03 04:55:57 UTC (rev 486) +++ trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-04 11:12:46 UTC (rev 487) @@ -109,11 +109,11 @@ "StringConfigOption")) { widgetPanel = new WidgetPanelString(config, component, componentOption, optionList.get(i)); -/* } else if (optionList.get(i).getClass().toString().contains( + } else if (optionList.get(i).getClass().toString().contains( "StringSetConfigOption")) { widgetPanel = new WidgetPanelStringSet(config, component, componentOption, optionList.get(i)); -*/ } else { + } else { widgetPanel = new WidgetPanelDefault(config, component, componentOption, optionList.get(i)); } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-02-03 04:55:57 UTC (rev 486) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-02-04 11:12:46 UTC (rev 487) @@ -21,15 +21,18 @@ */ import java.awt.BorderLayout; +import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.Color; -import java.util.Set; +import java.util.*; -//import javax.swing.JTextField; +import javax.swing.DefaultListModel; import javax.swing.JLabel; +import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JButton; +import javax.swing.JScrollPane; import org.dllearner.core.Component; import org.dllearner.core.config.ConfigEntry; @@ -51,13 +54,15 @@ private ConfigOption<?> configOption; private JLabel nameLabel; private JPanel widgetPanel = new JPanel(); - private JButton setButton = new JButton("Set"); + private JButton changeButton = new JButton("Change"); private Component component; private Class<? extends Component> componentOption; - private Set<String> value; - //private JTextField stringField = new JTextField(15); + private Set<String> value = new HashSet<String>(); + private JList stringList = new JList(); + private DefaultListModel listModel = new DefaultListModel(); + public WidgetPanelStringSet(Config config, Component component, Class<? extends Component> componentOption, ConfigOption<?> configOption) { @@ -76,7 +81,7 @@ } public void actionPerformed(ActionEvent e) { - if (e.getSource() == setButton) { + if (e.getSource() == changeButton) { setEntry(); } } @@ -88,19 +93,40 @@ widgetPanel.add(nameLabel); } + @SuppressWarnings("unchecked") @Override protected void showThingToChange() { if (component != null) { // StringSetConfigOption if (configOption.getClass().toString().contains( "StringSetConfigOption")) { - setButton.addActionListener(this); - //widgetPanel.add(stringField); - widgetPanel.add(setButton); + // previous set value + if (configOption != null) { + // take set + value = (Set<String>) config.getComponentManager() + .getConfigOptionValue(component, + configOption.getName()); + // fill list + if (value != null) { + for (Iterator<String> iterator = value.iterator(); iterator + .hasNext();) { + String item = iterator.next(); + listModel.addElement(item); + } + } + } + stringList.setModel(listModel); + stringList.setLayoutOrientation(JList.VERTICAL); + stringList.setVisibleRowCount(-1); + JScrollPane stringListScroller = new JScrollPane(stringList); + stringListScroller.setPreferredSize(new Dimension(200, 100)); + widgetPanel.add(stringListScroller); + widgetPanel.add(changeButton); + changeButton.addActionListener(this); } // UNKNOWN else { - JLabel notImplementedLabel = new JLabel("not a stringSet"); + JLabel notImplementedLabel = new JLabel("not a set of strings"); notImplementedLabel.setForeground(Color.RED); widgetPanel.add(notImplementedLabel); } @@ -109,31 +135,26 @@ noConfigOptionLabel.setForeground(Color.MAGENTA); widgetPanel.add(noConfigOptionLabel); } - - //System.out.println("value: " + value); - - } @Override protected void setEntry() { StringSetConfigOption specialOption; - //value = stringField.getText(); // get from input + // value = stringField.getText(); // get from input specialOption = (StringSetConfigOption) config.getComponentManager() .getConfigOption(componentOption, configOption.getName()); + try { ConfigEntry<Set<String>> specialEntry = new ConfigEntry<Set<String>>( specialOption, value); config.getComponentManager().applyConfigEntry(component, specialEntry); - System.out.println("set String: " + configOption.getName() + " = " + System.out.println("set StringSet: " + configOption.getName() + " = " + value); } catch (InvalidConfigOptionValueException s) { s.printStackTrace(); } - } - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |