From: <ton...@us...> - 2008-02-12 09:15:23
|
Revision: 544 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=544&view=rev Author: tonytacker Date: 2008-02-12 01:15:20 -0800 (Tue, 12 Feb 2008) Log Message: ----------- new method for selecting checkbox's Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java Modified: trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java 2008-02-11 19:01:36 UTC (rev 543) +++ trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java 2008-02-12 09:15:20 UTC (rev 544) @@ -41,7 +41,6 @@ private LinkedList<JCheckBox> list = new LinkedList<JCheckBox>(); private GridBagLayout gridbag = new GridBagLayout(); private GridBagConstraints constraints = new GridBagConstraints(); - private Set<String> selectionSet = new HashSet<String>(); /** * get a JPanel @@ -53,9 +52,9 @@ } /** - * add new entry + * Add new entry and make a new JCheckBox. * - * @param label + * @param label This text will be shown. */ public void add(String label) { list.add(new JCheckBox(label)); @@ -63,18 +62,33 @@ } /** - * return a set of selected items + * Return a set of selected items. */ public Set<String> getSelections() { + Set<String> selectionSet = new HashSet<String>(); selectionSet.clear(); // remove all for (int i = 0; i < list.size(); i++) { if (list.get(i).isSelected()) - this.selectionSet.add(list.get(i).getText()); + selectionSet.add(list.get(i).getText()); } - return this.selectionSet; + return selectionSet; } /** + * Select items. + * + * @param selectionSet Is a Set of Strings. + */ + public void setSelections(Set<String> selectionSet) { + for (int i = 0; i < list.size(); i++) { + if (selectionSet.contains(list.get(i).getText())) + list.get(i).setSelected(true); + else + list.get(i).setSelected(false); + } + } + + /** * update JCheckBox's */ private void update() { Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-02-11 19:01:36 UTC (rev 543) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-02-12 09:15:20 UTC (rev 544) @@ -111,9 +111,8 @@ // remove selection if (e.getSource() == removeButton) { int[] selectedIndices = stringList.getSelectedIndices(); - int count = 0; // remove i.e. index 2 and 4: after delete 2, 4 - // is - // now index 3 + int count = 0; + // remove i.e. 2 and 4: after delete 2: 4 is now 3 for (int i : selectedIndices) listModel.remove(i - count++); } @@ -212,6 +211,8 @@ buildConstraints(constraints, 1, 1, 1, 1, 100, 100); gridbag.setConstraints(setButton, constraints); widgetPanel.add(setButton, constraints); + // set selections + cBL.setSelections(value); // DEFINE LIST // positiveExamples or negativeExamples if (configOption.getName().equalsIgnoreCase( @@ -255,23 +256,24 @@ } // UNKNOWN else { - JLabel notImplementedLabel = new JLabel("not a set of strings"); + JLabel notImplementedLabel = new JLabel(" not a set of strings"); notImplementedLabel.setForeground(Color.RED); - buildConstraints(constraints, 0, 1, 1, 1, 100, 100); + buildConstraints(constraints, 1, 0, 1, 1, 100, 100); gridbag.setConstraints(notImplementedLabel, constraints); widgetPanel.add(notImplementedLabel); } } else { // configOption == NULL - JLabel noConfigOptionLabel = new JLabel("no init (StringSet)"); + JLabel noConfigOptionLabel = new JLabel(" no init (StringSet)"); noConfigOptionLabel.setForeground(Color.MAGENTA); - widgetPanel.add(noConfigOptionLabel); + buildConstraints(constraints, 1, 0, 1, 1, 100, 100); + gridbag.setConstraints(noConfigOptionLabel, constraints); + widgetPanel.add(noConfigOptionLabel, constraints); } } @Override protected void setEntry() { StringSetConfigOption specialOption; - // value = stringField.getText(); // get from input specialOption = (StringSetConfigOption) config.getComponentManager() .getConfigOption(componentOption, configOption.getName()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |