source: java/main/src/main/java/com/framsticks/gui/controls/ValueControl.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: 3.0 KB
Line 
1package com.framsticks.gui.controls;
2
3import org.apache.logging.log4j.Logger;
4import org.apache.logging.log4j.LogManager;
5
6import com.framsticks.params.CastFailure;
7import com.framsticks.params.ParamFlags;
8import com.framsticks.params.PrimitiveParam;
9import com.framsticks.params.ReassignResult;
10import com.framsticks.params.SetStateFlags;
11import com.framsticks.util.FramsticksException;
12import com.framsticks.util.lang.FlagsUtil;
13import com.framsticks.util.swing.TooltipConstructor;
14
15/**
16 * @author Piotr Sniegowski
17 */
18@SuppressWarnings("serial")
19public abstract class ValueControl extends Control {
20        private static final Logger log =
21                LogManager.getLogger(ValueControl.class);
22
23        /**
24         *
25         */
26        protected ValueControlListener listener;
27
28        public ValueControl(PrimitiveParam<?> primitiveParam) {
29                super(primitiveParam);
30
31                this.setToolTipText(new TooltipConstructor()
32                        .append("name", primitiveParam.getName())
33                        .append("id", primitiveParam.getId())
34                        .append("help", primitiveParam.getHelp())
35                        .append("def", primitiveParam.getDef(Object.class))
36                        .append("min", primitiveParam.getMin(Object.class))
37                        .append("max", primitiveParam.getMax(Object.class))
38                        .append("flags", FlagsUtil.write(ParamFlags.class, primitiveParam.getFlags(), null))
39                        .append("group", primitiveParam.getGroup())
40                        .append("extra", primitiveParam.getExtra())
41                        .build())
42                        ;
43        }
44
45        @Override
46        public PrimitiveParam<?> getParam() {
47                return (PrimitiveParam<?>) param;
48        }
49
50        protected abstract void pushValueToUserInterfaceImpl(Object value);
51
52        /** I consider this an ugly solution, but I was unable to find proper
53         * action listeners for underlying swing controls, that would only fire
54         * on user change and on programmatic change.
55         */
56        protected boolean programmaticChange = false;
57
58        public void pushValueToUserInterface(Object value) {
59                programmaticChange = true;
60                pushValueToUserInterfaceImpl(value);
61                programmaticChange = false;
62        }
63
64        public abstract Object pullValueFromUserInterface();
65
66        public void setListener(ValueControlListener listener) {
67                this.listener = listener;
68        }
69
70        protected Object filterValueThroughConstraints(Object candidate) {
71                Object oldValue = pullValueFromUserInterface();
72                try {
73                        ReassignResult<?> res = getParam().reassign(candidate, oldValue);
74                        if (res.getFlags() != 0) {
75                                log.warn("filter of param {} failed: {}", param, FlagsUtil.write(SetStateFlags.class, res.getFlags(), "0"));
76                        }
77                        return res.getValue();
78                } catch (CastFailure e) {
79                        //TODO just throw here, but check where that function is being used
80                        handle(new FramsticksException().msg("invalid value in control").arg("param", param).arg("value", candidate).cause(e));
81                }
82                return oldValue;
83        }
84
85        /** This method is meant as a public interface to obtain current and correct value from control.
86         *
87         */
88        public final Object getCurrentValue() {
89                return filterValueThroughConstraints(pullValueFromUserInterface());
90        }
91
92        protected boolean notifyOfChange() {
93                if (!programmaticChange) {
94                        if (listener == null) {
95                                return true;
96                        }
97                        return listener.onChange(getCurrentValue());
98                }
99                return true;
100        }
101
102
103}
Note: See TracBrowser for help on using the repository browser.