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/core/TreeOperations.java

    r98 r99  
    22
    33
     4import java.util.HashSet;
    45import java.util.List;
     6import java.util.Set;
    57
    68import javax.annotation.Nonnull;
     
    1012import com.framsticks.communication.File;
    1113import com.framsticks.params.AccessInterface;
    12 import com.framsticks.params.CompositeParam;
     14import com.framsticks.params.EventListener;
    1315import com.framsticks.params.FramsClass;
    1416import com.framsticks.params.ListAccess;
    1517import com.framsticks.params.Param;
    1618import com.framsticks.params.PrimitiveParam;
     19import com.framsticks.params.UniqueListAccess;
     20import com.framsticks.params.Util;
     21import com.framsticks.params.types.EventParam;
    1722import com.framsticks.params.types.ObjectParam;
    1823import com.framsticks.params.types.ProcedureParam;
     
    7378
    7479                        ListAccess listAccess = (ListAccess) bindAccess(node);
    75                         listAccess.clearValues();
     80
     81                        Set<String> oldValuesIds = new HashSet<>();
     82                        for (Param p : listAccess.getParams()) {
     83                                oldValuesIds.add(p.getId());
     84                        }
     85
     86                        // listAccess.clearValues();
    7687
    7788                        AccessInterface elementAccess = listAccess.getElementAccess();
     89                        AccessInterface clonerInterface = elementAccess.cloneAccess();
     90
    7891                        loader.addAccessInterface(elementAccess);
    7992                        MultiParamLoader.Status status;
     93                        int number = 0;
    8094                        while ((status = loader.go()) != MultiParamLoader.Status.Finished) {
    8195                                if (status == MultiParamLoader.Status.AfterObject) {
    8296                                        AccessInterface accessInterface = loader.getLastAccessInterface();
    8397
    84                                         String id = listAccess.computeIdentifierFor(accessInterface.getSelected());
    85                                         //TODO listAccessParam
    86                                         CompositeParam param = Param.build().forAccess(accessInterface).id(id).finish(CompositeParam.class);
    87                                         Object child = accessInterface.getSelected();
     98                                        String id;
     99                                        if (listAccess instanceof UniqueListAccess) {
     100                                                id = ((UniqueListAccess) listAccess).computeIdentifierFor(accessInterface.getSelected());
     101                                        } else {
     102                                                id = Integer.toString(number);
     103                                        }
     104                                        ++number;
     105
     106                                        Object childTo = listAccess.get(id, Object.class);
     107                                        boolean newOne;
     108                                        if (childTo == null) {
     109                                                childTo = clonerInterface.createAccessee();
     110                                                newOne = true;
     111                                        } else {
     112                                                assert oldValuesIds.contains(id);
     113                                                newOne = false;
     114                                        }
     115                                        oldValuesIds.remove(id);
     116                                        clonerInterface.select(childTo);
     117                                        Util.takeAllNonNullValues(clonerInterface, accessInterface);
     118                                        if (newOne) {
     119                                                listAccess.set(id, childTo);
     120                                        }
     121
     122                                        // listAccess.set(id, accessInterface.getSelected());
    88123                                        accessInterface.select(null);
    89                                         assert child != null;
    90                                         bindAccess(node).set(param, child);
     124
    91125                                }
     126                        }
     127                        /** It looks tricky for ArrayListAccess but should also work.
     128                         *
     129                         * They should be sorted.
     130                         */
     131                        for (String id : oldValuesIds) {
     132                                listAccess.set(id, null);
    92133                        }
    93134
     
    170211        }
    171212
    172 
    173         /** This might not be correct. */
     213        public static <A> void addListener(final Path path, final EventParam param, final EventListener<A> listener, final Class<A> argument, final Future<Void> future) {
     214                final Tree tree = path.getTree();
     215
     216                dispatchIfNotActive(tree, new RunAt<Tree>(future) {
     217                        @Override
     218                        protected void runAt() {
     219                                tree.addListener(path, param, listener, argument, future);
     220                        }
     221                });
     222        }
     223
     224        public static void removeListener(final Path path, final EventParam param, final EventListener<?> listener, final Future<Void> future) {
     225                final Tree tree = path.getTree();
     226
     227                dispatchIfNotActive(tree, new RunAt<Tree>(future) {
     228                        @Override
     229                        protected void runAt() {
     230                                tree.removeListener(path, param, listener, future);
     231                        }
     232                });
     233        }
     234
     235
     236        /**
     237         *
     238         * If StackOverflow occurs in that loop in LocalTree it is probably caused
     239         * the by the fact, that get operation may find the object, but Path resolution
     240         * cannot.
     241         * */
    174242        public static void tryGet(final Tree tree, final String targetPath, final Future<Path> future) {
    175243                log.debug("resolve textual: " + targetPath + " for " + tree);
     
    178246                        @Override
    179247                        protected void runAt() {
    180                                 final Path path = Path.to(tree, targetPath);
     248                                final Path path = Path.tryTo(tree, targetPath).tryResolveIfNeeded();
     249                                log.debug("found: " + path);
    181250                                if (path.isResolved()) {
    182251                                        future.pass(path);
     
    184253                                }
    185254
    186                                 tree.get(path, Mode.FETCH, new FutureHandler<Path>(future) {
     255                                tree.get(path, new FutureHandler<Path>(future) {
    187256                                        @Override
    188257                                        protected void result(Path result) {
     258                                                // if (result.isResolved(targetPath)) {
     259                                                //      future.pass(result);
     260                                                //      return;
     261                                                // }
     262                                                log.debug("retrying resolve textual: " + targetPath + " for " + tree + " with " + result);
    189263                                                tryGet(tree, targetPath, future);
    190264                                        }
     
    198272                return path.getTree().getInfoFromCache(path.getTop().getParam().getContainedTypeName());
    199273        }
     274
    200275}
Note: See TracChangeset for help on using the changeset viewer.