Changeset 90 for java/main/src/main/java/com/framsticks/gui/Gui.java
- Timestamp:
- 07/02/13 16:20:07 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/main/java/com/framsticks/gui/Gui.java
r87 r90 14 14 import com.framsticks.gui.controls.CheckBoxControl; 15 15 import com.framsticks.gui.controls.Control; 16 import com.framsticks.gui.controls.ControlOwner; 16 17 import com.framsticks.gui.controls.EnumControl; 17 18 import com.framsticks.gui.controls.EventControl; … … 33 34 import com.framsticks.params.types.StringParam; 34 35 import com.framsticks.params.types.UniversalParam; 36 import com.framsticks.util.FramsticksException; 35 37 import com.framsticks.util.lang.Strings; 36 38 … … 92 94 } 93 95 94 public static void fillWithControls(JPanel panel, Collection<Param> params, Map<Param, Control> components) { 95 for (Param param : params) { 96 public static <P extends Param, C extends Control> void fillWithControls(ControlOwner owner, Collection<P> params, Map<P, C> components, Class<C> controlType) { 97 JPanel panel = owner.getPanel(); 98 for (P param : params) { 96 99 if (param.isUserHidden()) { 97 100 continue; 98 101 } 99 102 assert !(param instanceof CompositeParam); 100 Control c ontrol= Gui.createSuitable(param);101 if (control == null) { 102 log.error("component for param " + param + " of type " + param.getClass().getSimpleName() + " was not added");103 continue;103 Control c = Gui.createSuitable(param); 104 105 if (!controlType.isInstance(c)) { 106 throw new FramsticksException().msg("created control is not of required type").arg("control", c).arg("type", controlType); 104 107 } 108 109 C control = controlType.cast(c); 110 111 control.setOwner(owner); 112 105 113 log.debug("add component for " + param); 106 114 JPanel line = new JPanel(); 107 115 line.setLayout(new BoxLayout(line, BoxLayout.LINE_AXIS)); 108 116 line.setAlignmentX(JPanel.LEFT_ALIGNMENT); 109 JLabel label = new JLabel(Strings.notEmpty(param.getName()) ? param.getName() : "? (" + param.getId() + ")");117 JLabel label = new JLabel(Strings.notEmpty(param.getName()) ? param.getName() : (Strings.notEmpty(param.getId()) ? param.getId() : "?")); 110 118 label.setToolTipText(control.getToolTipText()); 111 119 label.setHorizontalAlignment(JLabel.RIGHT);
Note: See TracChangeset
for help on using the changeset viewer.