Ignore:
Timestamp:
07/08/13 23:04:56 (11 years ago)
Author:
psniegowski
Message:

HIGHLIGHTS:

CHANGELOG:
Get data also on tree expansion.

Use nice framstick icon for empty nodes.

Update panel after reload if it is current.

Add shallow reload procedure.

Cut Gui prefix from several tree classes.

Bring back counter of GuiTreeNode?.

Use IdentityHashMap? were it is more appriopriate.

Remove TreeListener?.

Do not use TreeListener? in GUI.

Minor change.

Done migration to GuiTreeModel?.

BrowserTest? in that version always crashes frams.linux.

Move rendering implementation into GuiAbstractNode?.

Use hand-crafted list in GuiTreeNode?.

Generally, it would be a great place for WeakIdentityHashMap?
(but there is none in Java Collection Framework).

Remove superfluous logging.

Fix bug in GuiTreeNode?.

Use IdentityHashMap? instead of HashMap?.

Improve structure update.

Filter out invalid uids in UniqueListAccess?.

Improve TreeCellRenderer?.

Add filtering in TrackConsole?.

Improve TreeModel?.

More changes.

More improvements.

More changes.

Remove TreeNode?.

Support MetaNode? in the GuiTreeModel?.

Implement more in GuiTreeModel?.

Add CompositeParam? interface to FramsClass? and AccessInterface?.

Allow access by number to UniqueList?.

Add UidComparator?.

Use TreeMap? as a default accessee in unique list.

It keeps order of keys.

Introduce classes to use with new TreeModel?.

Another step.

Migrate from TreeNode? to Node in many places.

Remove some uses of TreeNode? as DefaultMutableTreeNode?.

Remove Path from TreeNode? interface.

Remove Path from TreeNode?.

Add Path recration from node feature.

Reworking TreeCellRenderer?.

Minor change of TreeOperations? interface.

Remove last methods from TreeNode?.

Another minor step.

Do not store reference to TreeAtFrame? in TreeNode?.

Add proxy exceptionHandler to StatusBar?.

Move panels management to TreeAtFrame?.

Store localChanges in the NodeAtFrame?.

More cleanup.

Move name computing to TreeCellRenderer?.

Move tooltip and icon computations to TreeCellRenderer?.

More dispatches removed.

Remove most dispatching from TreeNode?.

TreeNode? does not actually redispatch tasks.

Make Tree embedded in Browser use SwingDispatcher?.

Make lazy binding of Tree with Dispatcher.

Minor changes.

Organizational change in AbstractTree?.

Make AbstractTree? compose from Thread instead of inherit from it.

Make SwingDispatcher? and AtOnceDispatcher? Joinable compatible.

Add ListPanelProvider?.

Improve Controls readonly and enabled handling.

Properly pass ExceptionHandlers? in more places.

Make Tree.get accept ValueParam?.

  • This is to allow access number of list elements.

Remove not needed get redirection in ClientAtServer?.

Rename tryResolve to tryGet.

Unify tryResolveAndGet into tryResolve.

Remove resolveTop from Tree interface.

Make Tree.get accept Future<Path>.

Use get to implement resolveTop also in ObjectTree?.

Unify resolveTop and get in RemoteTree?.

Another minor step.

More minor changes in tree operations.

Minor organizational changes.

In RemoteTree? first fetch info for root.

Reworking resolving.

Minor changes.

Make ListAccess? return proxy iterators (instead of creating temporary collection).

Let AccessInterface? return Iterable<Param>.

Improve resolving.

More improvements.

First working completion in ManagedConsole?.

Rename resolve to resolveTop.

This reflects the actuall functionality.

Change semantic of tryResolve and tryResolveAndGet.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • java/main/src/main/java/com/framsticks/core/TreeOperations.java

    r97 r98  
    11package com.framsticks.core;
     2
    23
    34import java.util.List;
     
    1415import com.framsticks.params.Param;
    1516import com.framsticks.params.PrimitiveParam;
    16 import com.framsticks.params.ValueParam;
    1717import com.framsticks.params.types.ObjectParam;
    1818import com.framsticks.params.types.ProcedureParam;
     
    2828public final class TreeOperations {
    2929
    30         private static final Logger log = Logger.getLogger(TreeOperations.class.getName());
     30        private static final Logger log = Logger.getLogger(TreeOperations.class);
    3131
    3232        private TreeOperations() {
     
    3636                assert tree.isActive();
    3737                FramsClass framsClass = Loaders.loadFramsClass(file.getContent());
    38                 if ("/".equals(file.getPath())) {
    39                         if (tree.getRoot().getParam().getContainedTypeName() == null) {
    40                                 tree.setRoot(new Node(Param.build().name("Tree").id(tree.getName()).type("o " + framsClass.getId()).finish(CompositeParam.class), tree.getRoot().getObject()));
    41                         }
    42                 }
     38                log.debug("process fetched info for " + tree + ": " + framsClass);
    4339                tree.putInfoIntoCache(framsClass);
    4440                return framsClass;
    4541        }
    4642
     43        public static void processFetchedValues(Path path, List<File> files) {
     44                Tree tree = path.getTree();
     45                assert tree.isActive();
     46                assert files.size() == 1;
     47                assert path.isTheSame(files.get(0).getPath());
     48
     49                if (!path.isResolved()) {
     50                        AccessInterface access = tree.prepareAccess(path.getTop().getParam());
     51                        Object child = access.createAccessee();
     52                        assert child != null;
     53                        if (path.size() == 1) {
     54                                tree.assignRootObject(child);
     55                        } else {
     56                                bindAccess(path.getUnder()).set(path.getTop().getParam(), child);
     57                        }
     58                        path = path.appendResolution(child);
     59                }
     60
     61                log.debug("process fetched values: " + path);
     62                Node node = path.getTop();
     63                MultiParamLoader loader = new MultiParamLoader();
     64                loader.setNewSource(files.get(0).getContent());
     65                loader.addBreakCondition(MultiParamLoader.Status.AfterObject);
     66
     67                try {
     68                        if (node.getParam() instanceof ObjectParam) {
     69                                loader.addAccessInterface(bindAccess(node));
     70                                loader.go();
     71                                return;
     72                        }
     73
     74                        ListAccess listAccess = (ListAccess) bindAccess(node);
     75                        listAccess.clearValues();
     76
     77                        AccessInterface elementAccess = listAccess.getElementAccess();
     78                        loader.addAccessInterface(elementAccess);
     79                        MultiParamLoader.Status status;
     80                        while ((status = loader.go()) != MultiParamLoader.Status.Finished) {
     81                                if (status == MultiParamLoader.Status.AfterObject) {
     82                                        AccessInterface accessInterface = loader.getLastAccessInterface();
     83
     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();
     88                                        accessInterface.select(null);
     89                                        assert child != null;
     90                                        bindAccess(node).set(param, child);
     91                                }
     92                        }
     93
     94                } catch (FramsticksException e) {
     95                        throw new FramsticksException().msg("exception occurred while loading").cause(e);
     96                }
     97        }
     98
    4799        public static FramsClass getInfo(Path path) {
    48100                Tree tree = path.getTree();
    49101                assert tree.isActive();
     102                log.debug("get info for: " + path);
    50103                final String name = path.getTop().getParam().getContainedTypeName();
    51104                return tree.getInfoFromCache(name);
     
    53106
    54107        public static void findInfo(final Path path, final Future<FramsClass> future) {
     108                log.debug("find info for: " + path);
    55109                try {
    56110                        Tree tree = path.getTree();
     
    67121        }
    68122
    69         public static void processFetchedValues(Path path, List<File> files) {
    70                 Tree tree = path.getTree();
    71                 assert tree.isActive();
    72                 assert files.size() == 1;
    73                 assert path.isTheSame(files.get(0).getPath());
    74                 Node node = path.getTop();
    75                 MultiParamLoader loader = new MultiParamLoader();
    76                 loader.setNewSource(files.get(0).getContent());
    77                 loader.addBreakCondition(MultiParamLoader.Status.AfterObject);
    78 
    79                 try {
    80                         if (node.getParam() instanceof ObjectParam) {
    81                                 loader.addAccessInterface(TreeOperations.bindAccess(tree, node));
    82                                 loader.go();
    83                                 tree.notifyOfFetch(path);
    84                                 return;
    85                         }
    86 
    87                         ListAccess listAccess = ((ListAccess) TreeOperations.bindAccess(tree, node));
    88                         assert listAccess != null;
    89                         listAccess.clearValues();
    90 
    91                         AccessInterface elementAccess = listAccess.getElementAccess();
    92                         loader.addAccessInterface(elementAccess);
    93                         MultiParamLoader.Status status;
    94                         while ((status = loader.go()) != MultiParamLoader.Status.Finished) {
    95                                 if (status == MultiParamLoader.Status.AfterObject) {
    96                                         AccessInterface accessInterface = loader.getLastAccessInterface();
    97 
    98                                         String id = listAccess.computeIdentifierFor(accessInterface.getSelected());
    99                                         //TODO listAccessParam
    100                                         Param param = Param.build().forAccess(accessInterface).id(id).finish();
    101                                         Object child = accessInterface.getSelected();
    102                                         accessInterface.select(null);
    103                                         assert child != null;
    104                                         TreeOperations.bindAccess(tree, node).set((ValueParam) param, child);
    105                                 }
    106                         }
    107 
    108                         tree.notifyOfFetch(path);
    109                 } catch (Exception e) {
    110                         log.error("exception occurred while loading: " + e);
    111                 }
    112 
    113         }
    114 
    115         public static void resolveAndGet(final Tree tree, final String targetPath, final Future<Path> future) {
    116                 resolve(tree, targetPath, new FutureHandler<Path>(future) {
    117                         @Override
    118                         protected void result(final Path path) {
    119                                 assert path.isResolved(targetPath);
    120                                 //TODO Future
    121                                 tree.get(path, Mode.FETCH, new FutureHandler<Object>(future) {
    122                                         @Override
    123                                         protected void result(Object object) {
    124                                                 future.pass(path);
    125                                         }
    126                                 });
    127                         }
    128                 });
    129         }
    130 
    131 
    132         public static void resolve(final Path path, final Future<Path> future) {
    133                 final Tree tree = path.getTree();
    134                 assert tree.isActive();
    135                 if (path.getTop().getObject() != null) {
    136                         if (getInfoFromCache(path) != null) {
    137                                 future.pass(path);
    138                                 return;
    139                         }
    140                         TreeOperations.findInfo(path, new FutureHandler<FramsClass>(future) {
    141                                 @Override
    142                                 protected void result(FramsClass result) {
    143                                         future.pass(path);
    144                                 }
    145                         });
    146                         return;
    147                 }
    148                 TreeOperations.findInfo(path, new FutureHandler<FramsClass>(future) {
    149                         @Override
    150                         protected void result(FramsClass result) {
    151                                 assert tree.isActive();
    152                                 assert path.getTop().getParam().isMatchingContainedName(result.getId());
    153                                 Path p = (path.getTop().getParam().getContainedTypeName() != null ? path : path.tryFindResolution());
    154                                 future.pass(TreeOperations.createIfNeeded(p));
    155                         }
    156                 });
    157         }
    158 
    159         public static Path createIfNeeded(Tree tree, String path) {
    160                 assert tree.isActive();
    161                 Path p;
    162                 while (!(p = Path.to(tree, path)).isResolved(path)) {
    163                         tree.create(p);
    164                 }
    165                 return p;
    166         }
    167 
    168         public static Path createIfNeeded(Path path) {
    169                 Tree tree = path.getTree();
    170                 assert tree.isActive();
    171                 if (path.isResolved()) {
    172                         return path;
    173                 }
    174                 return tree.create(path);
    175         }
     123
    176124
    177125        public static @Nonnull AccessInterface bindAccess(Tree tree, String path) {
     126                log.debug("bind access for textual: " + path + " in " + tree);
    178127                return bindAccess(Path.to(tree, path));
    179128        }
    180129
    181         public static @Nonnull AccessInterface bindAccess(Tree tree, Node node) {
     130        public static @Nonnull AccessInterface bindAccess(Node node) {
     131                Tree tree = node.getTree();
    182132                assert tree.isActive();
    183133                assert node.getObject() != null;
     
    194144                assert path.getTree().isActive();
    195145                path.assureResolved();
    196                 return bindAccess(path.getTree(), path.getTop());
     146                log.debug("bind access for: " + path);
     147                return bindAccess(path.getTop());
    197148        }
    198149
     
    219170        }
    220171
     172
    221173        /** This might not be correct. */
    222         public static void resolve(final Tree tree, final String targetPath, final Future<Path> future) {
     174        public static void tryGet(final Tree tree, final String targetPath, final Future<Path> future) {
     175                log.debug("resolve textual: " + targetPath + " for " + tree);
    223176                dispatchIfNotActive(tree, new RunAt<Tree>(future) {
    224177
    225178                        @Override
    226179                        protected void runAt() {
    227                                 tree.resolve(Path.to(tree, targetPath), new FutureHandler<Path>(future) {
     180                                final Path path = Path.to(tree, targetPath);
     181                                if (path.isResolved()) {
     182                                        future.pass(path);
     183                                        return;
     184                                }
     185
     186                                tree.get(path, Mode.FETCH, new FutureHandler<Path>(future) {
    228187                                        @Override
    229188                                        protected void result(Path result) {
    230                                                 assert result.getTree().isActive();
    231                                                 if (result.isResolved(targetPath)) {
    232                                                         future.pass(result);
    233                                                         return;
    234                                                 }
    235                                                 resolve(tree, targetPath, future);
     189                                                tryGet(tree, targetPath, future);
    236190                                        }
    237191                                });
Note: See TracChangeset for help on using the changeset viewer.