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/AbstractTree.java

    r97 r98  
    11package com.framsticks.core;
    2 import java.util.HashSet;
    3 import java.util.Set;
    42
    53import javax.annotation.Nonnull;
     
    108import com.framsticks.params.CompositeParam;
    119import com.framsticks.params.FramsClass;
    12 import com.framsticks.params.Param;
    1310import com.framsticks.params.ParamsPackage;
    1411import com.framsticks.params.Registry;
    1512import com.framsticks.params.annotations.AutoAppendAnnotation;
    1613import com.framsticks.params.annotations.FramsClassAnnotation;
     14import com.framsticks.params.annotations.ParamAnnotation;
     15import com.framsticks.util.FramsticksException;
     16import com.framsticks.util.dispatching.AbstractJoinable;
     17import com.framsticks.util.dispatching.Dispatcher;
    1718import com.framsticks.util.dispatching.Dispatching;
     19import com.framsticks.util.dispatching.ExceptionResultHandler;
     20import com.framsticks.util.dispatching.Joinable;
     21import com.framsticks.util.dispatching.JoinableDispatcher;
     22import com.framsticks.util.dispatching.JoinableParent;
     23import com.framsticks.util.dispatching.JoinableState;
    1824import com.framsticks.util.dispatching.RunAt;
    1925import com.framsticks.util.dispatching.Thread;
     
    2430 */
    2531@FramsClassAnnotation
    26 public abstract class AbstractTree extends Thread<Tree> implements Tree {
     32public abstract class AbstractTree extends AbstractJoinable implements Dispatcher<Tree>, Tree, JoinableParent {
    2733
    2834        private static final Logger log = Logger.getLogger(Tree.class);
    2935
    30         private Node root;
    31 
    32         @Override
    33         public void setRoot(Node node) {
    34                 root = node;
    35         }
    36 
    37         @Override
    38         public @Nonnull Node getRoot() {
    39                 assert root != null;
     36        private Node root = null;
     37        private ExceptionResultHandler handler = ThrowExceptionHandler.getInstance();
     38
     39        private JoinableDispatcher<Tree> dispatcher;
     40
     41        @Override
     42        public void assignRootParam(CompositeParam param) {
     43                if (root != null) {
     44                        throw new FramsticksException().msg("root has already specified type");
     45                }
     46                root = new Node(this, param, null);
     47                log.info("assigned root type: " + root);
     48        }
     49
     50        @Override
     51        public void assignRootObject(Object object) {
     52                if (root == null) {
     53                        throw new FramsticksException().msg("root is has no type specified");
     54                }
     55                if (root.getObject() != null) {
     56                        throw new FramsticksException().msg("root has already object assigned").arg("current", root.getObject()).arg("candidate", object);
     57                }
     58                root = new Node(this, root.getParam(), object);
     59                log.info("assigned root object: " + root);
     60        }
     61
     62        @Override
     63        public @Nonnull Node getAssignedRoot() {
     64                if (root == null) {
     65                        throw new FramsticksException().msg("root has no type specified yet");
     66                }
    4067                return root;
    4168        }
     
    4673        }
    4774
    48         protected Set<TreeListener> listeners = new HashSet<TreeListener>();
     75        protected String name;
    4976
    5077        public AbstractTree() {
    51                 setName("entity");
     78                setName("tree");
    5279        }
    5380
     
    5582
    5683        }
    57 
    58 
    59         protected void fireRun(Exception e) {
    60                 for (TreeListener l : this.listeners) {
    61                         l.onRun(e);
    62                 }
    63         }
    64 
    65         protected void fireStop(Exception e) {
    66                 for (TreeListener l : this.listeners) {
    67                         l.onStop(e);
    68                 }
    69         }
    70 
    71         @Override
    72         public void addListener(final TreeListener listener) {
    73                 assert Dispatching.isThreadSafe();
    74                 Dispatching.dispatchIfNotActive(this, new RunAt<Tree>(ThrowExceptionHandler.getInstance()) {
    75                         @Override
    76                         protected void runAt() {
    77                                 listeners.add(listener);
    78                         }
    79                 });
    80         }
    81 
    82         @Override
    83         public void removeListener(final TreeListener listener) {
    84                 assert Dispatching.isThreadSafe();
    85                 Dispatching.dispatchIfNotActive(this, new RunAt<Tree>(ThrowExceptionHandler.getInstance()) {
    86                         @Override
    87                         protected void runAt() {
    88                                 listeners.remove(listener);
    89                         }
    90                 });
    91         }
    92 
    93         protected void fireListChange(Path path, ListChange change) {
    94                 assert isActive();
    95                 for (TreeListener l : this.listeners) {
    96                         l.onListChange(path, change);
    97                 }
    98         }
    99 
    100         @Override
    101         public void notifyOfFetch(Path path) {
    102                 fireFetch(path);
    103         }
    104 
    105         protected void fireFetch(Path path) {
    106                 assert isActive();
    107                 for (TreeListener l : this.listeners) {
    108                         l.onFetch(path);
    109                 }
    110         }
    111 
    11284
    11385        @Override
     
    142114        }
    143115
    144         @Override
    145         protected void joinableStart() {
    146                 dispatch(new RunAt<Tree>(ThrowExceptionHandler.getInstance()) {
    147                         @Override
    148                         protected void runAt() {
    149                                 if (!isRootAssigned()) {
    150                                         setRoot(new Node(Param.build().name("Tree").id(getName()).type("o").finish(CompositeParam.class), null));
    151                                 }
    152                         }
    153                 });
    154                 super.joinableStart();
    155         }
    156116
    157117        @Override
     
    159119                registry.putFramsClass(framclass);
    160120        }
     121
     122
     123        /**
     124         * @return the handler
     125         */
     126        @Override
     127        public ExceptionResultHandler getExceptionHandler() {
     128                return handler;
     129        }
     130
     131        /**
     132         * @param handler the handler to set
     133         */
     134        @Override
     135        public void setExceptionHandler(ExceptionResultHandler handler) {
     136                this.handler = handler;
     137        }
     138
     139        @Override
     140        public void handle(FramsticksException exception) {
     141                handler.handle(exception);
     142        }
     143
     144        /**
     145         * @return the dispatcher
     146         */
     147        @Override
     148        public JoinableDispatcher<Tree> getDispatcher() {
     149                return dispatcher;
     150        }
     151
     152        /**
     153         * @param dispatcher the dispatcher to set
     154         */
     155        @Override
     156        public void setDispatcher(JoinableDispatcher<Tree> dispatcher) {
     157                if (this.dispatcher != null) {
     158                        throw new FramsticksException().msg("dispatcher is already set").arg("tree", this).arg("dispatcher", dispatcher);
     159                }
     160                this.dispatcher = dispatcher;
     161        }
     162
     163        /**
     164         * @return the name
     165         */
     166        @ParamAnnotation
     167        public String getName() {
     168                return name;
     169        }
     170
     171        /**
     172         * @param name the name to set
     173         */
     174        @ParamAnnotation
     175        public void setName(String name) {
     176                this.name = name;
     177        }
     178
     179        @Override
     180        protected void joinableStart() {
     181                if (dispatcher == null) {
     182                        dispatcher = new Thread<Tree>();
     183                }
     184                Dispatching.use(dispatcher, this);
     185        }
     186
     187        @Override
     188        protected void joinableInterrupt() {
     189                Dispatching.drop(dispatcher, this);
     190        }
     191
     192        @Override
     193        protected void joinableFinish() {
     194
     195        }
     196
     197        @Override
     198        protected void joinableJoin() throws InterruptedException {
     199                Dispatching.join(dispatcher);
     200        }
     201
     202        @Override
     203        public void childChangedState(Joinable joinable, JoinableState state) {
     204                if (joinable == dispatcher) {
     205                        proceedToState(state);
     206                }
     207        }
     208
     209        @Override
     210        public boolean isActive() {
     211                if (dispatcher == null) {
     212                        throw new FramsticksException().msg("no dispatcher is set for tree yet").arg("tree", this);
     213                }
     214                return dispatcher.isActive();
     215        }
     216
     217        @Override
     218        public void dispatch(RunAt<? extends Tree> runnable) {
     219                if (dispatcher == null) {
     220                        throw new FramsticksException().msg("no dispatcher is set for tree yet").arg("tree", this);
     221                }
     222                dispatcher.dispatch(runnable);
     223        }
     224
    161225}
    162226
Note: See TracChangeset for help on using the changeset viewer.