source: java/main/src/main/java/com/framsticks/gui/Gui.java @ 100

Last change on this file since 100 was 100, checked in by psniegowski, 11 years ago

HIGHLIGHTS:

  • add <include/> to configuration
  • add side notes to tree
    • used to store arbitrary information alongside the tree structure
  • migrate to log4j2
    • supports lazy string evaluation of passed arguments
  • improve GUI tree
    • it stays in synchronization with actual state (even in high load test scenario)
  • improve panel management in GUI
  • make loading objects in GUI more lazy
  • offload parsing to connection receiver thread
    • info parsing
    • first step of objects parsing
  • fix connection parsing bug (eof in long values)
  • support zero-arguments procedure in table view

CHANGELOG:
Implement procedure calls from table view.

Refactorization around procedures in tables.

Add table editor for buttons.

Render buttons in the the list view.

Further improve Columns.

Add Column class for TableModel?.

Accept also non-arguments ProcedureParams? in tableView.

Increase maximal TextAreaControl? size.

Add tooltip to ProcedureControl?.

Fix bug of interpreting eofs in long values by connection reader.

Further rework connection parsing.

Simplify client connection processing.

Test ListChange? modification.

Test ListChange? events with java server.

Add TestChild?.

Fix bug with fast deregistering when connecting to running server.

Another minor refactorization in TreeOperations?.

Fix bug in SimpleAbstractAccess? loading routine.

Another minor improvement.

Minor change.

Make reading of List objects two-phase.

Another minor change.

Dispatch parsing into receiver thread.

Another step.

Enclose passing value in ObjectParam? case in closure.

Minor step.

Minor change on way to offload parsing.

Temporarily comment out single ValueParam? get.

It will be generalized to multi ValueParam?.

Process info in receiver thread.

Add DispatchingExceptionHandler?.

Make waits in browser test longer.

Use FETCHED_MARK.

It is honored in GUI, where it used to decide whether to get values

after user action.

It is set in standard algorithm for processing fetched values.

Add remove operation to side notes.

Make loading more lazy.

Improve loading policy.

On node choose load itself, on node expansion, load children.

Minor improvement.

Fix bug with panel interleaving.

Minor improvements.

Improve panel management.

More cleaning around panels.

Reorganize panels.

Further improve tree.

Fix bug in TreeModel?.

Remove children from TreeNode?.

Implement TreeNode? hashCode and equals.

Make TreeNode? delegate equals and hashcode to internal reference.

Move listeners from TreeNode? to side notes.

Store path.textual as a side note.

Side note params instead of accesses for objects.

More refactorizations.

In TreeNode? bindAccess based on side notes.

Minor step.

Hide createAccess.

Rename AccessInterface? to Access.

Minor changes.

Several improvements in high load scenarios.

Change semantics of ArrayListAccess?.set(index, null);

It now removes the element, making list shorter
(it was set to null before).

Add path remove handler.

Handle exceptions in Connection.

Update .gitignore

Configure logging to file.

Move registration to TreeModel?.

Further refactorization.

Minor refactorization.

Minor improvements.

Use specialized event also for Modify action of ListChange?.

Use remove events.

Use the insertion events for tree.

Further improve tree refreshing.

Further improve reacting on events in GUI.

Fix problem with not adding objects on addition list change.

Migrate to log4j lazy String construction interface.

Migrate imports to log4j2.

Drop dependency on adapter to version 1.2.

Switch log4j implementation to log4j2.

Add dirty mark to the NodeAtFrame?.

Make selecting in AccessInterfaces? type safe.

Ignore containers size settings in Model and Genotype.

Use tree side notes to remember local changes and panels.

Add sideNotes to tree.

They will be used to store various accompanying information
right in the tree.

Use ReferenceIdentityMap? from apache in TreeNode?.

It suits the need perfectly (weak semantics on both key and value).

Make ArrayListParam? do not react size changes.

Guard in TableModel? before not yet loaded objects.

Add <include/> clause and AutoInjector?.

Extract common columns configuration to separate xml,
that can be included by other configurations.

File size: 4.7 KB
Line 
1package com.framsticks.gui;
2
3import java.awt.Dimension;
4import java.util.Collection;
5import java.util.Map;
6
7import javax.swing.Box;
8import javax.swing.BoxLayout;
9import javax.swing.JLabel;
10import javax.swing.JPanel;
11
12import org.apache.logging.log4j.Logger;
13import org.apache.logging.log4j.LogManager;
14
15import com.framsticks.gui.controls.CheckBoxControl;
16import com.framsticks.gui.controls.Control;
17import com.framsticks.gui.controls.ControlOwner;
18import com.framsticks.gui.controls.EnumControl;
19import com.framsticks.gui.controls.EventControl;
20import com.framsticks.gui.controls.ProcedureControl;
21import com.framsticks.gui.controls.SliderControl;
22import com.framsticks.gui.controls.TextAreaControl;
23import com.framsticks.gui.controls.TextFieldControl;
24import com.framsticks.params.CompositeParam;
25import com.framsticks.params.Param;
26import com.framsticks.params.PrimitiveParam;
27import com.framsticks.params.types.BinaryParam;
28import com.framsticks.params.types.BooleanParam;
29import com.framsticks.params.types.ColorParam;
30import com.framsticks.params.types.DecimalParam;
31import com.framsticks.params.types.EnumParam;
32import com.framsticks.params.types.EventParam;
33import com.framsticks.params.types.FloatParam;
34import com.framsticks.params.types.ProcedureParam;
35import com.framsticks.params.types.StringParam;
36import com.framsticks.params.types.UniversalParam;
37import com.framsticks.util.FramsticksException;
38import com.framsticks.util.lang.Strings;
39
40public final class Gui {
41
42        private static final Logger log = LogManager.getLogger(Gui.class.getName());
43
44        private Gui() {
45        }
46
47        public static Control createComponentForText(PrimitiveParam<?> valueParam) {
48                if (valueParam.getMax(Object.class) != null) {
49                        return new TextFieldControl(valueParam);
50                }
51                return new TextAreaControl(valueParam);
52
53
54                // if (valueParam.getMin(Object.class) != null) {
55                //      return new TextAreaControl(valueParam);
56                // }
57                // return new TextFieldControl(valueParam);
58        }
59
60        public static Control createSuitable(Param param) {
61
62                if (param instanceof EnumParam) {
63                        return new EnumControl((EnumParam) param);
64                }
65                if (param instanceof BooleanParam) {
66                        return new CheckBoxControl((BooleanParam) param);
67                }
68                if (param instanceof DecimalParam) {
69                        DecimalParam decimalParam = (DecimalParam)param;
70                        if (decimalParam.getMin(Integer.class) != null && decimalParam.getMax(Integer.class) != null) {
71                                return new SliderControl(decimalParam);
72                        }
73                        return new TextFieldControl(decimalParam);
74                }
75                if (param instanceof FloatParam) {
76                        FloatParam floatParam = (FloatParam)param;
77                        if (floatParam.getMin(Double.class) != null && floatParam.getMax(Double.class) != null) {
78                                return new SliderControl(floatParam);
79                        }
80                        return new TextFieldControl(floatParam);
81                }
82                if (param instanceof StringParam) {
83                        return createComponentForText((StringParam) param);
84                }
85                if (param instanceof ProcedureParam) {
86                        return new ProcedureControl((ProcedureParam) param);
87                }
88                if (param instanceof BinaryParam) {
89                        return new TextFieldControl((BinaryParam) param);
90                }
91                if (param instanceof ColorParam) {
92                        return new TextFieldControl((ColorParam) param);
93                }
94                if (param instanceof UniversalParam) {
95                        return new TextAreaControl((UniversalParam) param);
96                }
97                if (param instanceof EventParam) {
98                        return new EventControl((EventParam) param);
99                }
100                return null;
101        }
102
103        public static <P extends Param, C extends Control> void fillWithControls(ControlOwner owner, Collection<P> params, Map<P, C> components, Class<C> controlType) {
104                JPanel panel = owner.getPanelForControls();
105                for (P param : params) {
106                        if (param.isUserHidden()) {
107                                continue;
108                        }
109                        assert !(param instanceof CompositeParam);
110                        Control c = Gui.createSuitable(param);
111
112                        if (!controlType.isInstance(c)) {
113                                throw new FramsticksException().msg("created control is not of required type").arg("control", c).arg("type", controlType);
114                        }
115
116                        C control = controlType.cast(c);
117
118                        control.setOwner(owner);
119
120                        log.debug("add component for {}", param);
121                        JPanel line = new JPanel();
122                        line.setLayout(new BoxLayout(line, BoxLayout.LINE_AXIS));
123                        line.setAlignmentX(JPanel.LEFT_ALIGNMENT);
124                        JLabel label = new JLabel(Strings.notEmpty(param.getName()) ? param.getName() : (Strings.notEmpty(param.getId()) ? param.getId() : "?"));
125                        label.setToolTipText(control.getToolTipText());
126                        label.setHorizontalAlignment(JLabel.RIGHT);
127                        Dimension labelSize = new Dimension(150, 30);
128                        label.setMaximumSize(labelSize);
129                        label.setMinimumSize(labelSize);
130                        label.setPreferredSize(labelSize);
131                        line.add(label);
132                        line.add(Box.createRigidArea(new Dimension(8, 0)));
133                        line.add(control);
134                        line.revalidate();
135                        panel.add(line);
136                        panel.add(Box.createRigidArea(new Dimension(0, 8)));
137                        //component.setAlignmentX(LEFT_ALIGNMENT);
138                        components.put(param, control);
139                }
140
141        }
142}
Note: See TracBrowser for help on using the repository browser.