From: <Jen...@us...> - 2008-09-09 13:48:21
|
Revision: 1187 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1187&view=rev Author: JensLehmann Date: 2008-09-09 13:48:15 +0000 (Tue, 09 Sep 2008) Log Message: ----------- refactoring: widgets moved to separate package Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/gui/widgets/ trunk/src/dl-learner/org/dllearner/gui/widgets/AbstractWidgetPanel.java trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelBoolean.java trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelDefault.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 Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/gui/AbstractWidgetPanel.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java Deleted: trunk/src/dl-learner/org/dllearner/gui/AbstractWidgetPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/AbstractWidgetPanel.java 2008-09-09 13:44:25 UTC (rev 1186) +++ trunk/src/dl-learner/org/dllearner/gui/AbstractWidgetPanel.java 2008-09-09 13:48:15 UTC (rev 1187) @@ -1,85 +0,0 @@ -/** - * Copyright (C) 2007-2008, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.gui; - -import javax.swing.JLabel; -import javax.swing.JPanel; - -import org.dllearner.core.Component; -import org.dllearner.core.config.ConfigEntry; -import org.dllearner.core.config.ConfigOption; -import org.dllearner.core.config.InvalidConfigOptionValueException; - -/** - * Abstract superclass of all widgets. Each widget has an associated component and configuration option, - * for which it allows modification by the user. - * - * @author Jens Lehmann - */ -public abstract class AbstractWidgetPanel<T> extends JPanel { - - protected ConfigOption<T> configOption; - protected Config config; - protected Component component; - - /** - * Constructs a widget. - * @param config The status of all components and options (which may be updated by this widget). - * @param component The component potentially changed by this widget. - * @param optionOption The config option of the specified component, which is potentially changed by this widget. - */ - public AbstractWidgetPanel(Config config, Component component, ConfigOption<T> optionOption) { - this.config = config; - this.component = component; - this.configOption = optionOption; - - if(configOption == null || component == null || config == null) { - System.out.println("| " + component + ", " + configOption + ", " + config + " |"); - throw new Error("Parameters must not be null."); - } - - buildWidgetPanel(); - } - - // convenience method - protected JLabel getLabel() { - JLabel nameLabel = new JLabel(configOption.getName()); - nameLabel.setToolTipText(configOption.getDescription()); - return nameLabel; - } - - // subclasses should call this method if a configuration option has changed - public void fireValueChanged(T value) { - ConfigEntry<T> entry = null; - try { - entry = new ConfigEntry<T>(configOption, value); - } catch (InvalidConfigOptionValueException e) { - // TODO display a message on the status bar (where the init - // has been before) - e.printStackTrace(); - } - // notify config that a value has changed -> it decides what to do - config.applyConfigEntry(component, entry); - } - - // subclasses should use this method to build the graphical representation of the widgets - public abstract void buildWidgetPanel(); - -} Modified: trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java 2008-09-09 13:44:25 UTC (rev 1186) +++ trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java 2008-09-09 13:48:15 UTC (rev 1187) @@ -20,6 +20,9 @@ package org.dllearner.gui; import javax.swing.*; + +import org.dllearner.gui.widgets.WidgetPanelStringSet; + import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.BorderLayout; Modified: trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-09-09 13:44:25 UTC (rev 1186) +++ trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-09-09 13:48:15 UTC (rev 1187) @@ -32,6 +32,13 @@ import org.dllearner.core.Component; import org.dllearner.core.ComponentManager; import org.dllearner.core.config.*; +import org.dllearner.gui.widgets.WidgetPanelBoolean; +import org.dllearner.gui.widgets.WidgetPanelDefault; +import org.dllearner.gui.widgets.WidgetPanelDouble; +import org.dllearner.gui.widgets.WidgetPanelInteger; +import org.dllearner.gui.widgets.WidgetPanelString; +import org.dllearner.gui.widgets.WidgetPanelStringSet; +import org.dllearner.gui.widgets.WidgetPanelStringTupleList; /** * OptionPanel reads all possible options and use all widgets. Definition map is Deleted: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-09-09 13:44:25 UTC (rev 1186) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-09-09 13:48:15 UTC (rev 1187) @@ -1,114 +0,0 @@ -/** - * Copyright (C) 2007-2008, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.gui; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JComboBox; - -import org.dllearner.core.Component; -import org.dllearner.core.config.BooleanConfigOption; -import org.dllearner.core.config.ConfigEntry; -import org.dllearner.core.config.InvalidConfigOptionValueException; - -/** - * Panel for option Boolean, defined in - * org.dllearner.core.config.BooleanConfigOption. - * - * @author Jens Lehmann - * @author Tilo Hielscher - */ -public class WidgetPanelBoolean extends AbstractWidgetPanel<Boolean> implements ActionListener { - - private static final long serialVersionUID = -4800583253223939928L; - - private Boolean value; -// private String[] kbBoxItems; // = { "false", "true" }; - private JComboBox cb; // = new JComboBox(kbBoxItems); - - public WidgetPanelBoolean(Config config, Component component, BooleanConfigOption configOption) { - super(config, component, configOption); - } - - public void actionPerformed(ActionEvent e) { - if (cb.getSelectedIndex() == 0) - value = false; - 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"); - } - - 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()); - - value = config.getConfigOptionValue(component, configOption); - - if (value == null) - value = false; - else - setEntry(); - - // set cb-index - String[] kbBoxItems = { "false", "true" }; - cb = new JComboBox(kbBoxItems); - if (!value) - cb.setSelectedIndex(0); - else - cb.setSelectedIndex(1); - - cb.addActionListener(this); - add(cb); - - } - -} Deleted: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java 2008-09-09 13:44:25 UTC (rev 1186) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java 2008-09-09 13:48:15 UTC (rev 1187) @@ -1,51 +0,0 @@ -/** - * Copyright (C) 2007-2008, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.gui; - -import java.awt.Color; - -import javax.swing.JLabel; - -import org.dllearner.core.Component; -import org.dllearner.core.config.ConfigOption; - -/** - * Panel for not defined options. - * - * @author Tilo Hielscher - * - */ -public class WidgetPanelDefault extends AbstractWidgetPanel<Object> { - - private static final long serialVersionUID = 4059515858894036769L; - - public WidgetPanelDefault(Config config, Component component, ConfigOption<Object> configOption) { - super(config, component, configOption); - } - - @Override - public void buildWidgetPanel() { - JLabel notImplementedLabel = new JLabel(configOption.getClass().getSimpleName() - + " not implemented"); - notImplementedLabel.setForeground(Color.RED); - add(notImplementedLabel); - } - -} Deleted: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java 2008-09-09 13:44:25 UTC (rev 1186) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java 2008-09-09 13:48:15 UTC (rev 1187) @@ -1,102 +0,0 @@ -package org.dllearner.gui; - -/** - * Copyright (C) 2007-2008, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JButton; -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; - -/** - * Panel for option Double, defined in - * {@link org.dllearner.core.config.DoubleConfigOption}. - * - * @author Tilo Hielscher - * - */ -public class WidgetPanelDouble extends AbstractWidgetPanel<Double> implements ActionListener { - - private static final long serialVersionUID = 5238903690721116289L; - - private JButton setButton = new JButton("Set"); - -// private Class<? extends Component> componentOption; - - private Double value; - private JTextField doubleField = new JTextField(5); - - public WidgetPanelDouble(Config config, Component component, DoubleConfigOption configOption) { - super(config, component, configOption); - } - - public void actionPerformed(ActionEvent e) { - if (e.getSource() == setButton) { - setEntry(); - } - } - - 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()); - - value = config.getConfigOptionValue(component, configOption); - - setButton = new JButton("Set"); - doubleField = new JTextField(5); - if (value == null) - value = 0.0; - else { - doubleField.setText(value.toString()); - setEntry(); - } - - doubleField.setText(value.toString()); - doubleField.setToolTipText(configOption.getAllowedValuesDescription()); - setButton.addActionListener(this); - add(doubleField); - add(setButton); - - } -} Deleted: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-09-09 13:44:25 UTC (rev 1186) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-09-09 13:48:15 UTC (rev 1187) @@ -1,99 +0,0 @@ -package org.dllearner.gui; - -/** - * Copyright (C) 2007-2008, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JButton; -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; - -/** - * Panel for option Integer, defined in - * org.dllearner.core.config.IntegerConfigOption. - * - * @author Tilo Hielscher - * - */ -public class WidgetPanelInteger extends AbstractWidgetPanel<Integer> implements ActionListener { - - private static final long serialVersionUID = -1802111225835164644L; - - private JButton setButton = new JButton("Set"); - - private Integer value; - private JTextField integerField = new JTextField(3); - - public WidgetPanelInteger(Config config, Component component, IntegerConfigOption configOption) { - super(config, component, configOption); - } - - 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)) { - 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(); - } - } else - System.out.println("Integer: not valid value"); - } - - @Override - public void buildWidgetPanel() { - add(getLabel()); - - value = config.getConfigOptionValue(component, configOption); - - setButton = new JButton("Set"); - integerField = new JTextField(3); - if (value == null) - value = 0; - else { - integerField.setText(value.toString()); - setEntry(); - } - - integerField.setText(value.toString()); - integerField.setToolTipText(configOption.getAllowedValuesDescription()); - setButton.addActionListener(this); - add(integerField); - add(setButton); - } -} Deleted: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-09-09 13:44:25 UTC (rev 1186) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-09-09 13:48:15 UTC (rev 1187) @@ -1,129 +0,0 @@ -/** - * Copyright (C) 2007-2008, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.gui; - -import java.awt.event.ActionEvent; -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.kb.OWLFile; - -/** - * Panel for option String, defined in - * {@link org.dllearner.core.config.StringConfigOption}. - * - * @author Jens Lehmann - * @author Tilo Hielscher - * - */ -public class WidgetPanelString extends AbstractWidgetPanel<String> implements ActionListener { - - private static final long serialVersionUID = -2169739820989891226L; - -// private JPanel widgetPanel = new JPanel(); - private JButton setButton; // = new JButton("Set"); - - private String value; - private JTextField stringField; // = new JTextField(35); - - public WidgetPanelString(Config config, Component component, StringConfigOption configOption) { - super(config, component, configOption); - } - - public void actionPerformed(ActionEvent e) { - if (e.getSource() == setButton) { - if (configOption.getName().equals("filename")) { - 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); - } - } - 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()); - - // get current value of this option for the given component - value = config.getConfigOptionValue(component, configOption); - // 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) - 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"); - - } - -} Deleted: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-09-09 13:44:25 UTC (rev 1186) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-09-09 13:48:15 UTC (rev 1187) @@ -1,283 +0,0 @@ -/** - * Copyright (C) 2007-2008, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.gui; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.Set; - -import javax.swing.DefaultListModel; -import javax.swing.JButton; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -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; -import org.dllearner.core.owl.ObjectProperty; - -/** - * Panel for option StringSet, defined in - * org.dllearner.core.config.StringSetConfigOption. - * - * There are 2 layouts defined. First for normal option and a second for special - * options. Second layout shows a list of JCheckBox's. - * - * @author Tilo Hielscher - * - */ -public class WidgetPanelStringSet extends AbstractWidgetPanel<Set<String>> implements ActionListener { - - private static final long serialVersionUID = 7832726987046601916L; - - 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 Set<String> value = new HashSet<String>(); - private JList stringList = new JList(); - private DefaultListModel listModel = new DefaultListModel(); - - private CheckBoxList cBL = new CheckBoxList(this); - - public WidgetPanelStringSet(Config config, Component component, StringSetConfigOption configOption) { - super(config, component, configOption); - } - - public void actionPerformed(ActionEvent e) { - if (!isSpecial()) { - // NORMAL LAYOUT - Set<String> exampleSet = new HashSet<String>(); - // add to list - if (e.getSource() == addButton && !listModel.contains(stringField.getText())) { - listModel.addElement(stringField.getText()); - } - // remove selection - if (e.getSource() == removeButton) { - int[] selectedIndices = stringList.getSelectedIndices(); - int count = 0; - // remove i.e. 2 and 4: after delete 2: 4 is now 3 - for (int i : selectedIndices) - listModel.remove(i - count++); - } - // clear list - if (e.getSource() == clearButton) { - listModel.clear(); - } - // update - // stringList.setModel(listModel); - for (int i = 0; i < listModel.size(); i++) { - if (!listModel.get(i).toString().equalsIgnoreCase("")) - exampleSet.add(listModel.get(i).toString()); - } - // set entry - value = exampleSet; - setEntry(); - } - } - - /** - * 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, - int wy) { - gbc.gridx = gx; - gbc.gridy = gy; - gbc.gridwidth = gw; - gbc.gridheight = gh; - gbc.weightx = wx; - gbc.weighty = wy; - } - - /** - * special layout returns true if 2nd layout should used - */ - private boolean isSpecial() { - if (configOption.getName().equalsIgnoreCase("positiveExamples") - || configOption.getName().equalsIgnoreCase("negativeExamples") - || configOption.getName().equalsIgnoreCase("allowedConcepts") - || configOption.getName().equalsIgnoreCase("ignoredConcepts") - || configOption.getName().equalsIgnoreCase("allowedRoles") - || configOption.getName().equalsIgnoreCase("ignoredRoles")) - return true; - else - return false; - } - - @Override - public void buildWidgetPanel() { - gridbag = new GridBagLayout(); - widgetPanel = new JPanel(); - widgetPanel.setLayout(gridbag); - add(widgetPanel, BorderLayout.CENTER); - add(getLabel()); - - value = config.getConfigOptionValue(component, configOption); - - listModel = new DefaultListModel(); - // fill list - if (value != null) { - setEntry(); - for (Iterator<String> iterator = value.iterator(); iterator.hasNext();) { - String item = iterator.next(); - listModel.addElement(item); - } - } - - constraints = new GridBagConstraints(); - cBL = new CheckBoxList(this); - stringList = new JList(); - stringField = new JTextField(30); - addButton = new JButton("add"); - removeButton = new JButton("remove"); - clearButton = new JButton("clear"); - - if (!isSpecial()) { - // NORMAL LAYOUT - // stringField - buildConstraints(constraints, 0, 1, 1, 1, 100, 100); - gridbag.setConstraints(stringField, constraints); - widgetPanel.add(stringField, constraints); - // addButton - buildConstraints(constraints, 1, 1, 1, 1, 100, 100); - gridbag.setConstraints(addButton, constraints); - widgetPanel.add(addButton, constraints); - // list - stringList.setModel(listModel); - stringList.setLayoutOrientation(JList.VERTICAL); - stringList.setVisibleRowCount(-1); - JScrollPane stringListScroller = new JScrollPane(stringList); - stringListScroller.setPreferredSize(new Dimension(380, 100)); - buildConstraints(constraints, 0, 2, 1, 2, 100, 100); - gridbag.setConstraints(stringListScroller, constraints); - widgetPanel.add(stringListScroller, constraints); - // removeButton - buildConstraints(constraints, 1, 2, 1, 1, 100, 100); - gridbag.setConstraints(removeButton, constraints); - widgetPanel.add(removeButton, constraints); - // clearButton - buildConstraints(constraints, 1, 3, 1, 1, 100, 100); - gridbag.setConstraints(clearButton, constraints); - widgetPanel.add(clearButton, constraints); - } else { - System.out.println("SPECIAL OPTION " + configOption.getName()); - - // SPECIAL LAYOUT - // ComboBoxList - buildConstraints(constraints, 0, 1, 1, 1, 100, 100); - gridbag.setConstraints(cBL, constraints); - widgetPanel.add(cBL, constraints); - // DEFINE LIST - // positiveExamples or negativeExamples - if (configOption.getName().equalsIgnoreCase("positiveExamples") - || configOption.getName().equalsIgnoreCase("negativeExamples")) { - // fill lists - Set<Individual> individualsSet = config.getReasoningService() - .getIndividuals(); - LinkedList<Individual> individuals = new LinkedList<Individual>( - individualsSet); - for (Individual ind : individuals) { - System.out.println(ind.getName()); - cBL.add(ind.getName()); - } - } - // allowedConcepts or ignoredConcepts - if (configOption.getName().equalsIgnoreCase("allowedConcepts") - || configOption.getName().equalsIgnoreCase("ignoredConcepts")) { - // fill lists - Set<NamedClass> atomicsSet = config.getReasoningService() - .getNamedClasses(); - LinkedList<NamedClass> atomicConcepts = new LinkedList<NamedClass>( - atomicsSet); - for (NamedClass ind : atomicConcepts) - cBL.add(ind.getName()); - } - // allowedRoles or ignoredRoles - if (configOption.getName().equalsIgnoreCase("allowedRoles") - || configOption.getName().equalsIgnoreCase("ignoredRoles")) { - // fill lists - Set<ObjectProperty> atomicsSet = config.getReasoningService() - .getObjectProperties(); - LinkedList<ObjectProperty> atomicRoles = new LinkedList<ObjectProperty>( - atomicsSet); - for (ObjectProperty ind : atomicRoles) - cBL.add(ind.getName()); - } - // set selections - if (value != null) - cBL.setSelections(value); - } - - stringList.setModel(listModel); - - // ActionListeners - addButton.addActionListener(this); - removeButton.addActionListener(this); - clearButton.addActionListener(this); - - } - -} Deleted: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java 2008-09-09 13:44:25 UTC (rev 1186) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java 2008-09-09 13:48:15 UTC (rev 1187) @@ -1,220 +0,0 @@ -package org.dllearner.gui; - -/** - * Copyright (C) 2007-2008, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import javax.swing.DefaultListModel; -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -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.utilities.datastructures.StringTuple; - -/** - * Panel for option StringTupleList, defined in - * org.dllearner.core.config.StringTupleListConfigOption. - * - * @author Tilo Hielscher - */ -public class WidgetPanelStringTupleList extends AbstractWidgetPanel<List<StringTuple>> implements ActionListener { - - private static final long serialVersionUID = 7832726987046601916L; - - 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 List<StringTuple> value = new LinkedList<StringTuple>(); - private JList stringList = new JList(); - private DefaultListModel listModel = new DefaultListModel(); - - private JButton setButton = new JButton("set"); - - public WidgetPanelStringTupleList(Config config, Component component, StringTupleListConfigOption configOption) { - super(config, component, configOption); - } - - public void actionPerformed(ActionEvent e) { - // add to list - if (e.getSource() == addButton - && !listModel.contains(stringFieldA.getText() + " --> " + stringFieldB.getText()) - && !stringFieldA.getText().equalsIgnoreCase("") - && !stringFieldB.getText().equalsIgnoreCase("")) { - listModel.addElement(stringFieldA.getText() + " --> " + stringFieldB.getText()); - exampleList.add(new StringTuple(stringFieldA.getText(), stringFieldB.getText())); - } - // remove selection - if (e.getSource() == removeButton) { - int[] selectedIndices = stringList.getSelectedIndices(); - int count = 0; - // remove i.e. 2 and 4: after delete 2: 4 is now 3 - for (int i : selectedIndices) { - listModel.remove(i - count); - exampleList.remove(i - count++); - } - } - // clear list - if (e.getSource() == clearButton) { - listModel.clear(); - exampleList.clear(); - } - // set entry - value = exampleList; - setEntry(); - } - - public void setEntry() { - StringTupleListConfigOption specialOption; - specialOption = (StringTupleListConfigOption) config.getComponentManager().getConfigOption( - component.getClass(), configOption.getName()); - if (specialOption.isValidValue(value)) { - try { - ConfigEntry<List<StringTuple>> specialEntry = new ConfigEntry<List<StringTuple>>( - specialOption, value); - config.getComponentManager().applyConfigEntry(component, specialEntry); - // System.out.println("set StringTupleList: " + - // configOption.getName() + " = " + value); - } catch (InvalidConfigOptionValueException s) { - s.printStackTrace(); - } - } else - System.out.println("StringTupleList: not valid value"); - } - - /** - * Define GridBagConstraints - */ - private void buildConstraints(GridBagConstraints gbc, int gx, int gy, int gw, int gh, int wx, - int wy) { - gbc.gridx = gx; - gbc.gridy = gy; - gbc.gridwidth = gw; - gbc.gridheight = gh; - gbc.weightx = wx; - gbc.weighty = wy; - } - - @Override - public void buildWidgetPanel() { - - gridbag = new GridBagLayout(); - constraints = new GridBagConstraints(); - - widgetPanel = new JPanel(); - addButton = new JButton("add"); - removeButton = new JButton("remove"); - clearButton = new JButton("clear"); - stringFieldA = new JTextField(10); - stringFieldB = new JTextField(10); - exampleList = new LinkedList<StringTuple>(); - - stringList = new JList(); - listModel = new DefaultListModel(); - - setButton = new JButton("set"); - - widgetPanel.setLayout(gridbag); - add(widgetPanel, BorderLayout.CENTER); - add(getLabel()); - - value = config.getConfigOptionValue(component, configOption); - - if (value != null) { - setEntry(); - exampleList = value; - } - - // fill list - if (value != null) { - for (Iterator<StringTuple> iterator = value.iterator(); iterator.hasNext();) { - StringTuple item = iterator.next(); - listModel.addElement(item); - } - } - - // stringFieldA - buildConstraints(constraints, 0, 1, 1, 1, 100, 100); - gridbag.setConstraints(stringFieldA, constraints); - widgetPanel.add(stringFieldA, constraints); - // arrow - JLabel arrowLabel = new JLabel(" --> "); - buildConstraints(constraints, 1, 1, 1, 1, 100, 100); - constraints.anchor = GridBagConstraints.WEST; - gridbag.setConstraints(arrowLabel, constraints); - widgetPanel.add(arrowLabel, constraints); - // stringFieldB - buildConstraints(constraints, 2, 1, 1, 1, 100, 100); - gridbag.setConstraints(stringFieldB, constraints); - widgetPanel.add(stringFieldB, constraints); - // addButton - buildConstraints(constraints, 3, 1, 1, 1, 100, 100); - gridbag.setConstraints(addButton, constraints); - widgetPanel.add(addButton, constraints); - // list - stringList.setModel(listModel); - stringList.setLayoutOrientation(JList.VERTICAL); - stringList.setVisibleRowCount(-1); - JScrollPane stringListScroller = new JScrollPane(stringList); - stringListScroller.setPreferredSize(new Dimension(280, 100)); - buildConstraints(constraints, 0, 2, 3, 2, 100, 100); - gridbag.setConstraints(stringListScroller, constraints); - widgetPanel.add(stringListScroller, constraints); - // removeButton - buildConstraints(constraints, 3, 2, 1, 1, 100, 100); - gridbag.setConstraints(removeButton, constraints); - widgetPanel.add(removeButton, constraints); - // clearButton - buildConstraints(constraints, 3, 3, 1, 1, 100, 100); - gridbag.setConstraints(clearButton, constraints); - widgetPanel.add(clearButton, constraints); - - stringList.setModel(listModel); - // ActionListeners - addButton.addActionListener(this); - removeButton.addActionListener(this); - clearButton.addActionListener(this); - setButton.addActionListener(this); - } - -} Copied: trunk/src/dl-learner/org/dllearner/gui/widgets/AbstractWidgetPanel.java (from rev 1185, trunk/src/dl-learner/org/dllearner/gui/AbstractWidgetPanel.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/widgets/AbstractWidgetPanel.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/widgets/AbstractWidgetPanel.java 2008-09-09 13:48:15 UTC (rev 1187) @@ -0,0 +1,86 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.gui.widgets; + +import javax.swing.JLabel; +import javax.swing.JPanel; + +import org.dllearner.core.Component; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.config.ConfigOption; +import org.dllearner.core.config.InvalidConfigOptionValueException; +import org.dllearner.gui.Config; + +/** + * Abstract superclass of all widgets. Each widget has an associated component and configuration option, + * for which it allows modification by the user. + * + * @author Jens Lehmann + */ +public abstract class AbstractWidgetPanel<T> extends JPanel { + + protected ConfigOption<T> configOption; + protected Config config; + protected Component component; + + /** + * Constructs a widget. + * @param config The status of all components and options (which may be updated by this widget). + * @param component The component potentially changed by this widget. + * @param optionOption The config option of the specified component, which is potentially changed by this widget. + */ + public AbstractWidgetPanel(Config config, Component component, ConfigOption<T> optionOption) { + this.config = config; + this.component = component; + this.configOption = optionOption; + + if(configOption == null || component == null || config == null) { + System.out.println("| " + component + ", " + configOption + ", " + config + " |"); + throw new Error("Parameters must not be null."); + } + + buildWidgetPanel(); + } + + // convenience method + protected JLabel getLabel() { + JLabel nameLabel = new JLabel(configOption.getName()); + nameLabel.setToolTipText(configOption.getDescription()); + return nameLabel; + } + + // subclasses should call this method if a configuration option has changed + public void fireValueChanged(T value) { + ConfigEntry<T> entry = null; + try { + entry = new ConfigEntry<T>(configOption, value); + } catch (InvalidConfigOptionValueException e) { + // TODO display a message on the status bar (where the init + // has been before) + e.printStackTrace(); + } + // notify config that a value has changed -> it decides what to do + config.applyConfigEntry(component, entry); + } + + // subclasses should use this method to build the graphical representation of the widgets + public abstract void buildWidgetPanel(); + +} Copied: trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelBoolean.java (from rev 1185, trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelBoolean.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelBoolean.java 2008-09-09 13:48:15 UTC (rev 1187) @@ -0,0 +1,115 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.gui.widgets; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JComboBox; + +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; + +/** + * Panel for option Boolean, defined in + * org.dllearner.core.config.BooleanConfigOption. + * + * @author Jens Lehmann + * @author Tilo Hielscher + */ +public class WidgetPanelBoolean extends AbstractWidgetPanel<Boolean> implements ActionListener { + + private static final long serialVersionUID = -4800583253223939928L; + + private Boolean value; +// private String[] kbBoxItems; // = { "false", "true" }; + private JComboBox cb; // = new JComboBox(kbBoxItems); + + public WidgetPanelBoolean(Config config, Component component, BooleanConfigOption configOption) { + super(config, component, configOption); + } + + public void actionPerformed(ActionEvent e) { + if (cb.getSelectedIndex() == 0) + value = false; + 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"); + } + + 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()); + + value = config.getConfigOptionValue(component, configOption); + + if (value == null) + value = false; + else + setEntry(); + + // set cb-index + String[] kbBoxItems = { "false", "true" }; + cb = new JComboBox(kbBoxItems); + if (!value) + cb.setSelectedIndex(0); + else + cb.setSelectedIndex(1); + + cb.addActionListener(this); + add(cb); + + } + +} Copied: trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelDefault.java (from rev 1185, trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelDefault.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelDefault.java 2008-09-09 13:48:15 UTC (rev 1187) @@ -0,0 +1,52 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.gui.widgets; + +import java.awt.Color; + +import javax.swing.JLabel; + +import org.dllearner.core.Component; +import org.dllearner.core.config.ConfigOption; +import org.dllearner.gui.Config; + +/** + * Panel for not defined options. + * + * @author Tilo Hielscher + * + */ +public class WidgetPanelDefault extends AbstractWidgetPanel<Object> { + + private static final long serialVersionUID = 4059515858894036769L; + + public WidgetPanelDefault(Config config, Component component, ConfigOption<Object> configOption) { + super(config, component, configOption); + } + + @Override + public void buildWidgetPanel() { + JLabel notImplementedLabel = new JLabel(configOption.getClass().getSimpleName() + + " not implemented"); + notImplementedLabel.setForeground(Color.RED); + add(notImplementedLabel); + } + +} Copied: trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelDouble.java (from rev 1185, trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelDouble.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelDouble.java 2008-09-09 13:48:15 UTC (rev 1187) @@ -0,0 +1,103 @@ +package org.dllearner.gui.widgets; + +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +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; + +/** + * Panel for option Double, defined in + * {@link org.dllearner.core.config.DoubleConfigOption}. + * + * @author Tilo Hielscher + * + */ +public class WidgetPanelDouble extends AbstractWidgetPanel<Double> implements ActionListener { + + private static final long serialVersionUID = 5238903690721116289L; + + private JButton setButton = new JButton("Set"); + +// private Class<? extends Component> componentOption; + + private Double value; + private JTextField doubleField = new JTextField(5); + + public WidgetPanelDouble(Config config, Component component, DoubleConfigOption configOption) { + super(config, component, configOption); + } + + public void actionPerformed(ActionEvent e) { + if (e.getSource() == setButton) { + setEntry(); + } + } + + 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()); + + value = config.getConfigOptionValue(component, configOption); + + setButton = new JButton("Set"); + doubleField = new JTextField(5); + if (value == null) + value = 0.0; + else { + doubleField.setText(value.toString()); + setEntry(); + } + + doubleField.setText(value.toString()); + doubleField.setToolTipText(configOption.getAllowedValuesDescription()); + setButton.addActionListener(this); + add(doubleField); + add(setButton); + + } +} Copied: trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelInteger.java (from rev 1185, trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelInteger.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelInteger.java 2008-09-09 13:48:15 UTC (rev 1187) @@ -0,0 +1,100 @@ +package org.dllearner.gui.widgets; + +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +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; + +/** + * Panel for option Integer, defined in + * org.dllearner.core.config.IntegerConfigOption. + * + * @author Tilo Hielscher + * + */ +public class WidgetPanelInteger extends AbstractWidgetPanel<Integer> implements ActionListener { + + private static final long serialVersionUID = -1802111225835164644L; + + private JButton setButton = new JButton("Set"); + + private Integer value; + private JTextField integerField = new JTextField(3); + + public WidgetPanelInteger(Config config, Component component, IntegerConfigOption configOption) { + super(config, component, configOption); + } + + 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)) { + 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(); + } + } else + System.out.println("Integer: not valid value"); + } + + @Override + public void buildWidgetPanel() { + add(getLabel()); + + value = config.getConfigOptionValue(component, configOption); + + setButton = new JButton("Set"); + integerField = new JTextField(3); + if (value == null) + value = 0; + else { + integerField.setText(value.toString()); + setEntry(); + } + + integerField.setText(value.toString()); + integerField.setToolTipText(configOption.getAllowedValuesDescription()); + setButton.addActionListener(this); + add(integerField); + add(setButton); + } +} Copied: trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelString.java (from rev 1186, trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelString.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelString.java 2008-09-09 13:48:15 UTC (rev 1187) @@ -0,0 +1,131 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.gui.widgets; + +import java.awt.event.ActionEvent; +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 + * {@link org.dllearner.core.config.StringConfigOption}. + * + * @author Jens Lehmann + * @author Tilo Hielscher + * + */ +public class WidgetPanelString extends AbstractWidgetPanel<String> implements ActionListener { + + private static ... [truncated message content] |