From: <ton...@us...> - 2008-01-30 06:03:31
|
Revision: 459 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=459&view=rev Author: tonytacker Date: 2008-01-29 22:03:27 -0800 (Tue, 29 Jan 2008) Log Message: ----------- widgetPanelBoolean without setButton, add widget double, add widget string Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java Modified: trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-01-29 20:04:57 UTC (rev 458) +++ trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-01-30 06:03:27 UTC (rev 459) @@ -92,10 +92,7 @@ */ private void showWidgets() { JPanel widgetPanel; - optionList = ComponentManager.getConfigOptions(componentOption); // get - // class - // for - // options + optionList = ComponentManager.getConfigOptions(componentOption); centerPanel.removeAll(); // clear panel for (int i = 0; i < optionList.size(); i++) { buildConstraints(constraints, 0, i, 1, 1, 0, 0); @@ -107,6 +104,14 @@ "BooleanConfigOption")) { widgetPanel = new WidgetPanelBoolean(config, component, componentOption, optionList.get(i)); + } else if (optionList.get(i).getClass().toString().contains( + "DoubleConfigOption")) { + widgetPanel = new WidgetPanelDouble(config, component, + componentOption, optionList.get(i)); + } else if (optionList.get(i).getClass().toString().contains( + "StringConfigOption")) { + widgetPanel = new WidgetPanelString(config, component, + componentOption, optionList.get(i)); } else { widgetPanel = new WidgetPanelDefault(config, component, componentOption, optionList.get(i)); Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-01-29 20:04:57 UTC (rev 458) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-01-30 06:03:27 UTC (rev 459) @@ -50,7 +50,6 @@ private ConfigOption<?> configOption; private JLabel nameLabel; private JPanel widgetPanel = new JPanel(); - private JButton setButton = new JButton("Set"); private Component component; private Class<? extends Component> componentOption; @@ -76,9 +75,7 @@ } public void actionPerformed(ActionEvent e) { - if (e.getSource() == setButton) { - setEntry(); - } + setEntry(); } @Override @@ -107,9 +104,9 @@ cb.setSelectedIndex(0); else cb.setSelectedIndex(1); - setButton.addActionListener(this); + cb.addActionListener(this); + widgetPanel.add(cb); - widgetPanel.add(setButton); } // UNKNOWN else { Added: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java 2008-01-30 06:03:27 UTC (rev 459) @@ -0,0 +1,140 @@ +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.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.Color; + +import javax.swing.JTextField; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JButton; + +import org.dllearner.core.Component; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.config.ConfigOption; +import org.dllearner.core.config.DoubleConfigOption; +import org.dllearner.core.config.InvalidConfigOptionValueException; + +/** + * WidgetPanelDouble + * + * @author Tilo Hielscher + * + */ +public class WidgetPanelDouble extends AbstractWidgetPanel implements + ActionListener { + + private static final long serialVersionUID = 5238903690721116289L; + private Config config; + private ConfigOption<?> configOption; + private JLabel nameLabel; + private JPanel widgetPanel = new JPanel(); + private JButton setButton = new JButton("Set"); + private Component component; + private Class<? extends Component> componentOption; + + private Double value; + private JTextField doubleField = new JTextField(5); + + public WidgetPanelDouble(Config config, Component component, + Class<? extends Component> componentOption, + ConfigOption<?> configOption) { + this.config = config; + this.configOption = configOption; + this.component = component; + this.componentOption = componentOption; + + showLabel(); // name of option and tooltip + showThingToChange(); // textfield, setbutton + add(widgetPanel, BorderLayout.CENTER); + } + + public JPanel getPanel() { + return this; + } + + public void actionPerformed(ActionEvent e) { + if (e.getSource() == setButton) { + setEntry(); + } + } + + @Override + protected void showLabel() { + nameLabel = new JLabel(configOption.getName()); + nameLabel.setToolTipText(configOption.getDescription()); + widgetPanel.add(nameLabel); + } + + @Override + protected void showThingToChange() { + if (component != null) { + // DoubleConfigOption + if (configOption.getClass().toString().contains( + "DoubleConfigOption")) { + // default value + if (configOption.getDefaultValue() != null) { + value = (Double) configOption.getDefaultValue(); + } + // then 0 + else { + value = 0.0; + } + doubleField.setText(value.toString()); + doubleField.setToolTipText(configOption.getAllowedValuesDescription()); + setButton.addActionListener(this); + widgetPanel.add(doubleField); + widgetPanel.add(setButton); + } + // UNKNOWN + else { + JLabel notImplementedLabel = new JLabel("not a double"); + notImplementedLabel.setForeground(Color.RED); + widgetPanel.add(notImplementedLabel); + } + } else { // configOption == NULL + JLabel noConfigOptionLabel = new JLabel("no init (Double)"); + noConfigOptionLabel.setForeground(Color.MAGENTA); + widgetPanel.add(noConfigOptionLabel); + } + } + + @Override + protected void setEntry() { + DoubleConfigOption specialOption; + value = Double.parseDouble(doubleField.getText()); // get from input + specialOption = (DoubleConfigOption) config.getComponentManager() + .getConfigOption(componentOption, configOption.getName()); + 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(); + } + } +} Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-01-29 20:04:57 UTC (rev 458) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-01-30 06:03:27 UTC (rev 459) @@ -103,6 +103,7 @@ value = 0; } integerField.setText(value.toString()); + integerField.setToolTipText(configOption.getAllowedValuesDescription()); setButton.addActionListener(this); widgetPanel.add(integerField); widgetPanel.add(setButton); Added: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-01-30 06:03:27 UTC (rev 459) @@ -0,0 +1,140 @@ +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.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.Color; + +import javax.swing.JTextField; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JButton; + +import org.dllearner.core.Component; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.config.ConfigOption; +import org.dllearner.core.config.StringConfigOption; +import org.dllearner.core.config.InvalidConfigOptionValueException; + +/** + * WidgetPanelString + * + * @author Tilo Hielscher + * + */ +public class WidgetPanelString extends AbstractWidgetPanel implements + ActionListener { + + private static final long serialVersionUID = -2169739820989891226L; + private Config config; + private ConfigOption<?> configOption; + private JLabel nameLabel; + private JPanel widgetPanel = new JPanel(); + private JButton setButton = new JButton("Set"); + private Component component; + private Class<? extends Component> componentOption; + + private String value; + private JTextField stringField = new JTextField(15); + + public WidgetPanelString(Config config, Component component, + Class<? extends Component> componentOption, + ConfigOption<?> configOption) { + this.config = config; + this.configOption = configOption; + this.component = component; + this.componentOption = componentOption; + + showLabel(); // name of option and tooltip + showThingToChange(); // textfield, setbutton + add(widgetPanel, BorderLayout.CENTER); + } + + public JPanel getPanel() { + return this; + } + + public void actionPerformed(ActionEvent e) { + if (e.getSource() == setButton) { + setEntry(); + } + } + + @Override + protected void showLabel() { + nameLabel = new JLabel(configOption.getName()); + nameLabel.setToolTipText(configOption.getDescription()); + widgetPanel.add(nameLabel); + } + + @Override + protected void showThingToChange() { + if (component != null) { + // StringConfigOption + if (configOption.getClass().toString().contains( + "StringConfigOption")) { + // default value + if (configOption.getDefaultValue() != null) { + value = (String) configOption.getDefaultValue(); + } + // then "" + else { + value = ""; + } + stringField.setText(value.toString()); + stringField.setToolTipText(configOption.getAllowedValuesDescription()); + setButton.addActionListener(this); + widgetPanel.add(stringField); + widgetPanel.add(setButton); + } + // UNKNOWN + else { + JLabel notImplementedLabel = new JLabel("not a string"); + notImplementedLabel.setForeground(Color.RED); + widgetPanel.add(notImplementedLabel); + } + } else { // configOption == NULL + JLabel noConfigOptionLabel = new JLabel("no init (String)"); + noConfigOptionLabel.setForeground(Color.MAGENTA); + widgetPanel.add(noConfigOptionLabel); + } + } + + @Override + protected void setEntry() { + StringConfigOption specialOption; + value = stringField.getText(); // get from input + specialOption = (StringConfigOption) config.getComponentManager() + .getConfigOption(componentOption, configOption.getName()); + 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(); + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |