source: java/main/src/main/java/com/framsticks/gui/controls/TextControl.java @ 87

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

HIGHLIGHTS:

  • FramsClass? and contained Param are now immutable classes (like String),

which allows to refer to them concurrently without synchronization
(which for example in turn simplifies GUI management)

  • also make Path immutable (which was earlier only assumed)
  • add global cache for FramsClasses? created solely and automatically

on base of Java classes.

representations basing on given FramsClass?

  • above changes greatly improved GUI responsivness during browsing
  • furtherly improve Param class hierarchy
  • allow to inject actions on state changes into MultiParamLoader?
  • add more tests

CHANGELOG:

Add StatusListener? to MultiParamLoader?.

Minor refactorization in MultiParamLoader?.

First step with auto append.

Add SchemaTest?.

Improve Registry.

Clean up in Registry.

Work out Registry.

Use annotations for Param.

Fix ListChange?.

Improve fluent interface of the FramsClassBuilder?.

Done caching of ReflectionAccess?.Backend

Fix hashCode of Pair.

A step on a way to cache ReflectionAccess?.Backend

Make SimpleAbstractAccess?.framsClass a final field.

Add static cache for FramsClasses? based on java.

Only classes created strictly and automatically
based on java classes are using this cache.

Make all Params immutable.

Many improvement to make Param immutable.

Make PrimitiveParam? generic type.

Several changes to make Param immutable.

Make FramsClass? immutable.

Another improvement to Path immutability.

Several improvements to Path.

Improve PathTest?.

Configurarable MutabilityDetector?.

File size: 1015 bytes
Line 
1package com.framsticks.gui.controls;
2
3import javax.swing.event.DocumentEvent;
4import javax.swing.event.DocumentListener;
5import javax.swing.text.JTextComponent;
6
7import com.framsticks.params.PrimitiveParam;
8
9@SuppressWarnings("serial")
10public abstract class TextControl extends ValueControl {
11
12        public TextControl(PrimitiveParam<?> valueParam) {
13                super(valueParam);
14        }
15
16        protected void addDefaultDocumentListener(JTextComponent text) {
17                text.getDocument().addDocumentListener(createDocumentListener(new Runnable() {
18                        @Override
19                        public void run() {
20                                notifyOfChange();
21                        }
22                }));
23        }
24
25        protected static DocumentListener createDocumentListener(final Runnable runnable) {
26                return new DocumentListener() {
27                        @Override
28                        public void insertUpdate(DocumentEvent documentEvent) {
29                                runnable.run();
30                        }
31
32                        @Override
33                        public void removeUpdate(DocumentEvent documentEvent) {
34                                runnable.run();
35                        }
36
37                        @Override
38                        public void changedUpdate(DocumentEvent documentEvent) {
39                                runnable.run();
40                        }
41                };
42        }
43}
Note: See TracBrowser for help on using the repository browser.