[Bprocessor-commit] bprocessor/src/net/sourceforge/bprocessor/packages/skeleton BooleanControl.jav
Status: Pre-Alpha
Brought to you by:
henryml
|
From: Michael L. <he...@us...> - 2011-06-15 13:54:59
|
Update of /cvsroot/bprocessor/bprocessor/src/net/sourceforge/bprocessor/packages/skeleton
In directory vz-cvs-2.sog:/tmp/cvs-serv17989/src/net/sourceforge/bprocessor/packages/skeleton
Modified Files:
SkeletonPackage.java
Added Files:
BooleanControl.java BooleanValue.java
Log Message:
--- NEW FILE: BooleanValue.java ---
package net.sourceforge.bprocessor.packages.skeleton;
public class BooleanValue implements ControlValue {
private boolean value;
public BooleanValue(boolean value) {
this.value = value;
}
public boolean getValue() {
return value;
}
public void setValue(boolean value) {
this.value = value;
}
public String format() {
return value ? "YES" : "NO";
}
public void parse(String string) {
if (string.equalsIgnoreCase("YES")) {
value = true;
} else if (string.equalsIgnoreCase("TRUE")) {
value = true;
} else if (string.equalsIgnoreCase("NO")) {
value = false;
} else if (string.equalsIgnoreCase("FALSE")) {
value = false;
}
}
}
--- NEW FILE: BooleanControl.java ---
package net.sourceforge.bprocessor.packages.skeleton;
import java.awt.Insets;
import javax.swing.Box;
import javax.swing.JCheckBox;
import javax.swing.JToggleButton;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import net.sourceforge.bprocessor.gui.attrview.AttributeView;
public class BooleanControl extends Control implements ChangeListener {
private Box row;
private JToggleButton valueLabel;
private BooleanValue value;
private ControlDelegate delegate;
public BooleanControl(BooleanValue value, ControlDelegate delegate, String label) {
this.value = value;
this.delegate = delegate;
row = Box.createHorizontalBox();
valueLabel = new JCheckBox(label);
valueLabel.setSelected(value.getValue());
valueLabel.setFont(AttributeView.FONT_PLAIN);
valueLabel.setMargin(new Insets(1, 1, 1, 1));
row.add(Box.createHorizontalStrut(5));
row.add(valueLabel);
row.add(Box.createHorizontalGlue());
valueLabel.addChangeListener(this);
}
public Box row() {
return row;
}
public void stateChanged(ChangeEvent arg0) {
if (valueLabel.isSelected() != value.getValue()) {
value.setValue(valueLabel.isSelected());
if (delegate != null) {
delegate.changed(this);
}
}
}
}
Index: SkeletonPackage.java
===================================================================
RCS file: /cvsroot/bprocessor/bprocessor/src/net/sourceforge/bprocessor/packages/skeleton/SkeletonPackage.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** SkeletonPackage.java 5 Jun 2011 19:57:14 -0000 1.6
--- SkeletonPackage.java 15 Jun 2011 13:54:54 -0000 1.7
***************
*** 45,48 ****
--- 45,49 ----
private DoubleValue skeletonConstant;
private StringValue skeletonName;
+ private BooleanValue active;
//getters for parameters
***************
*** 59,62 ****
--- 60,64 ----
skeletonConstant = new DoubleValue(42);
skeletonName = new StringValue("Mike");
+ active = new BooleanValue(false);
panel = new ControlPanel(this);
GUI.getInstance().registerControlPanel(panel);
***************
*** 67,70 ****
--- 69,76 ----
System.out.println("skeleton-constant: " + skeletonConstant.getValue());
System.out.println("name: " + skeletonName.getValue());
+ System.out.println("active: " + active.format());
+ }
+ public BooleanValue getActive() {
+ return active;
}
}
***************
*** 213,216 ****
--- 219,227 ----
content.add(labelled.row());
}
+ {
+
+ BooleanControl control = new BooleanControl(skeleton.getActive(), this, "Active");
+ content.add(control.row());
+ }
}
public void changed(Object source) {
|