Ignore:
Timestamp:
07/10/13 22:41:02 (11 years ago)
Author:
psniegowski
Message:

HIGHLIGTS:

  • complete events implementation
  • add CLI in Java Framsticks server
  • add automatic registration for events in GUI
  • improve objects fetching (object are never overwritten with new instances)
  • properly react for ListChange? events
  • add ListPanel? with table view
    • columns to be shown may be statically specified in configuration
    • currently modyfying data through tables is not available
  • improve maven configuration
    • configuration file may be specified without touching pom.xml

CHANGELOG:
Extract constants from Flags into ParamFlags? and SetStateFlags?.

Extract flags I/O to FlagsUtils? class.

Configured maven to exec given resource configuration.

For example:
mvn exec:exec -Dframsticks.config=/configs/managed-console.xml

Cleanup pom.xml

Rename ObjectTree? to LocalTree? (also make LocalTree? and RemoteTree? final).

Minor change.

Add maximum number of columns in ListPanelProvider?.

Improve ColumnsConfig? interpretation.

Automatically fill FramsClass?.name if trying to construct empty.

Improve identitifer case mangling in XmlLoader?.

Introduce configurable ColumnsConfig?.

Draft working version of ListPanel?.

Table is being shown (although empty).

More improvements to table building.

Move some functionality from Frame to TreeModel?.

Move tree classes in gui to separate package.

Remove old table related classes.

Add draft implementation of TableModel?.

Redirect ParamBuilder?.forAccess to AccessInterface?.

Optimize ParamBuilder?.forAccess()

Do not clear list when loading.

Do not load fetched values directly.

Implement different AccessInterface? copying policy.

Optimize fetching values routine.

Remove Mode enum (work out get semantics).

Some improvements to ListChange? handling.

Improve UniqueListAccess?.

Add reaction for ListChanges? in the TreeNode?.

EventListeners? are being added in the TreeNode?.

Listeners for ListParams? are now very naive (they download
whole list).

Automatially register on events in GUI.

Events are working in RemoteTree? and Server.

Move listeners to the ClientSideManagedConnection?.

Remove old classes responsible for event subscriptions.

Improve event reading.

Improve events handling at server side.

Add register attribute in FramsClassAnnotation?
to automatically also register other classes.

Registering events works.

Setup for remote listeners registration.

More improvements.

Minor changes.

Add rootTree to the ClientAtServer?.

Moving CLI to the ClientAtServer?.

Fix bug: use Void.TYPE instead of Void.class

More development around CLI.

  • Improve Path resolving.

Add synthetic root to ObjectTree?.

It is needed to allow sybling for the original root
that would containg CLI.

Some work with registering events in RemoteTree?.

Draft implementation of listener registering in RemoteTree?.

Support events registration in the ObjectTree?.

Add events support to ReflectionAccess?.

EventParam? is recognized by ParamCandidate?.

Prepare interface for Events across project.

Add EventListener? and API for listeners in Tree.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • java/main/src/main/java/com/framsticks/params/ReflectionAccess.java

    r98 r99  
    1717
    1818import com.framsticks.params.annotations.AutoAppendAnnotation;
     19import com.framsticks.params.types.EventParam;
    1920import com.framsticks.params.types.ProcedureParam;
    2021import com.framsticks.util.FramsticksException;
     
    5758                }
    5859
     60                public interface ReflectedAdder{
     61                        public void reg(Object object, EventListener<?> listener) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException;
     62                }
     63
     64                public interface ReflectedRemover{
     65                        public void regRemove(Object object, EventListener<?> listener) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException;
     66                }
     67
    5968                protected final Map<ValueParam, ReflectedSetter> setters = new IdentityHashMap<>();
    6069                protected final Map<ValueParam, ReflectedGetter> getters = new IdentityHashMap<>();
    6170                protected final Map<ProcedureParam, ReflectedCaller> callers = new IdentityHashMap<>();
     71                protected final Map<EventParam, ReflectedAdder> adders = new IdentityHashMap<>();
     72                protected final Map<EventParam, ReflectedRemover> removers = new IdentityHashMap<>();
     73
    6274                protected final List<Method> autoAppendMethods = new ArrayList<>();
    6375
     
    100112                                }
    101113
     114                                for (final EventParam ep : filterInstanceof(framsClass.getParamEntries(), EventParam.class)) {
     115                                        if (!candidates.containsKey(ep.getId())) {
     116                                                log.trace("java class does not implement the event param " + ep);
     117                                                continue;
     118                                        }
     119                                        ParamCandidate ec = candidates.get(ep.getId());
     120                                        final Method adder = ec.getAdder();
     121                                        final Method remover = ec.getRemover();
     122
     123                                        backend.adders.put(ep, new ReflectedAdder() {
     124
     125                                                @Override
     126                                                public void reg(Object object, EventListener<?> listener) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
     127                                                        adder.invoke(object, listener);
     128                                                }
     129                                        });
     130
     131                                        backend.removers.put(ep, new ReflectedRemover() {
     132
     133                                                @Override
     134                                                public void regRemove(Object object, EventListener<?> listener) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
     135                                                        remover.invoke(object, listener);
     136                                                }
     137                                        });
     138                                }
     139
    102140                                for (final ValueParam vp : filterInstanceof(framsClass.getParamEntries(), ValueParam.class)) {
    103141                                        if (!candidates.containsKey(vp.getId())) {
     
    105143                                        }
    106144                                        ParamCandidate pc = candidates.get(vp.getId());
    107                                         if (pc.isReadOnly() && !vp.hasFlag(Flags.READONLY)) {
     145                                        if (pc.isReadOnly() && !vp.hasFlag(ParamFlags.READONLY)) {
    108146                                                throw new ConstructionException().msg("readonly state conflict").arg("param", vp);
    109147                                        }
     
    200238        }
    201239
    202         public ReflectionAccess(Class<?> reflectedClass) throws ConstructionException {
    203                 this(reflectedClass, FramsClass.build().forClass(reflectedClass));
    204         }
    205 
    206240        public static boolean typeMatch(Class<?> a, Class<?> b) {
    207                 assert !b.isPrimitive();
     241                if (b.isPrimitive()) {
     242                        throw new FramsticksException().msg("failed to match type, right argument is primitive").arg("left", a).arg("right", b);
     243                }
    208244                if (!a.isPrimitive()) {
    209245                        return a.equals(b);
     
    219255                        return b.equals(Boolean.class);
    220256                }
    221                 assert false;
    222                 return false;
    223         }
    224 
    225         public ReflectionAccess(Class<?> reflectedClass, FramsClass framsClass) throws ConstructionException {
     257                throw new FramsticksException().msg("failed to match types").arg("left", a).arg("right", b);
     258        }
     259
     260
     261
     262
     263        public ReflectionAccess(Class<?> javaClass) throws ConstructionException {
     264                this(javaClass, FramsClass.build().forClass(javaClass));
     265        }
     266
     267
     268        public ReflectionAccess(Class<?> javaClass, FramsClass framsClass) throws ConstructionException {
     269                this(javaClass, framsClass, Backend.getOrCreateFor(javaClass, framsClass));
     270        }
     271
     272        protected ReflectionAccess(Class<?> javaClass, FramsClass framsClass, Backend backend) throws ConstructionException {
    226273                super(framsClass);
    227                 this.javaClass = reflectedClass;
    228                 this.backend = Backend.getOrCreateFor(reflectedClass, framsClass);
    229         }
    230 
     274                this.javaClass = javaClass;
     275                this.backend = backend;
     276        }
     277
     278        @Override
     279        public ReflectionAccess cloneAccess() throws ConstructionException {
     280                return new ReflectionAccess(javaClass, framsClass, backend);
     281        }
    231282
    232283        @Override
     
    268319                } catch (FramsticksException e) {
    269320                        throw e.arg("param", param).arg("value", value).arg("access", this);
     321                }
     322        }
     323
     324        @Override
     325        public void reg(EventParam param, EventListener<?> listener) {
     326                try {
     327                        try {
     328                                if (object == null) {
     329                                        throw new FramsticksException().msg("no object set");
     330                                }
     331
     332                                backend.adders.get(param).reg(object, listener);
     333                                return;
     334                        } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
     335                                throw new FramsticksException().msg("failed to add listener").cause(e);
     336                        }
     337                } catch (FramsticksException e) {
     338                        throw e.arg("param", param).arg("access", this);
     339                }
     340        }
     341
     342        @Override
     343        public void regRemove(EventParam param, EventListener<?> listener) {
     344                try {
     345                        try {
     346                                if (object == null) {
     347                                        throw new FramsticksException().msg("no object set");
     348                                }
     349
     350                                backend.removers.get(param).regRemove(object, listener);
     351                                return;
     352                        } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
     353                                throw new FramsticksException().msg("failed to remove listener").cause(e);
     354                        }
     355                } catch (FramsticksException e) {
     356                        throw e.arg("param", param).arg("access", this);
    270357                }
    271358        }
     
    352439        }
    353440
    354         @Override
    355         public ReflectionAccess cloneAccess() throws ConstructionException {
    356                 return new ReflectionAccess(javaClass, framsClass);
    357         }
    358441
    359442        @Override
     
    368451        }
    369452
    370         @Override
    371         public String toString() {
    372                 StringBuilder b = new StringBuilder();
    373                 b.append(framsClass);
    374                 if (object != null) {
    375                         b.append("(").append(object).append(")");
    376                 }
    377                 return b.toString();
    378         }
    379453
    380454        @Override
Note: See TracChangeset for help on using the changeset viewer.