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/params/UniqueListAccess.java

    r90 r98  
    11package com.framsticks.params;
    22
     3import com.framsticks.util.FramsticksException;
     4import com.framsticks.util.UnimplementedException;
     5import com.framsticks.util.UnsupportedOperationException;
    36import com.framsticks.util.lang.Casting;
    47import com.framsticks.util.lang.Numbers;
     
    1215public class UniqueListAccess extends ListAccess {
    1316
    14         private static final Logger log = Logger.getLogger(UniqueListAccess.class.getName());
     17        private static final Logger log = Logger.getLogger(UniqueListAccess.class);
    1518
    1619        Map<String, Object> map;
     
    2326        }
    2427
     28        public static Integer getUidNumber(String uid) {
     29                try {
     30                        return Integer.valueOf(uid.substring(1));
     31                } catch (NumberFormatException e) {
     32                        return null;
     33                }
     34        }
     35
     36        public static class UidComparator implements Comparator<String> {
     37
     38                protected String name;
     39
     40                /**
     41                 * @param name
     42                 */
     43                public UidComparator(String name) {
     44                        this.name = name;
     45                }
     46
     47                @Override
     48                public int compare(String a, String b) {
     49                        if (a.equals(b)) {
     50                                return 0;
     51                        }
     52                        int diff = a.length() - b.length();
     53                        if (diff != 0) {
     54                                return diff;
     55                        }
     56                        Integer au = getUidNumber(a);
     57                        Integer bu = getUidNumber(b);
     58                        if (au == null || bu == null) {
     59                                throw new FramsticksException().msg("comparator failure").arg("left", a).arg("right", b).arg("in", this);
     60                        }
     61                        return au - bu;
     62                }
     63
     64                @Override
     65                public String toString() {
     66                        return "comparator " + name;
     67                }
     68
     69
     70        }
     71
    2572        @Override
    2673        public Map<String, Object> createAccessee() {
    27                 return new HashMap<String, Object>();
    28         }
    29 
    30         @Override
    31         public Param getParam(int i) {
    32                 log.error("accesing unique list through index");
    33                 assert false;
    34                 return null;
    35                 //log.error("accesing unique list through index");
    36                 //return null;
    37                 //return Param.build().setId(Integer.toString(i)).setName(elementAccess.getId()).type("o " + elementAccess.getId()).build();
    38         }
    39 
    40         @Override
    41         public Param getParam(String id) {
     74                return new TreeMap<String, Object>(new UidComparator(elementAccess.toString()));
     75        }
     76
     77        @Override
     78        public CompositeParam getParam(int i) {
     79                if ((i < 0) ||  (i >= map.size())) {
     80                        return null;
     81                }
     82                return Param.build().id(Integer.toString(i)).forAccess(elementAccess).finish(CompositeParam.class);
     83        }
     84
     85        @Override
     86        public CompositeParam getParam(String id) {
    4287                Integer i = Numbers.parse(id, Integer.class);
    4388                if (i != null) {
    4489                        return getParam(i);
    4590                }
    46                 //TODO list access here
    47                 return Param.build().id(id).forAccess(elementAccess).finish();
     91                Integer uidNumber = getUidNumber(id);
     92                if (uidNumber == null) {
     93                        return null;
     94                }
     95                if (!map.containsKey(id)) {
     96                        return null;
     97                }
     98                return Param.build().id(id).forAccess(elementAccess).finish(CompositeParam.class);
    4899        }
    49100
     
    60111        @Override
    61112        public <T> T get(int i, Class<T> type) {
    62                 log.error("accesing unique list through index");
    63                 assert false;
    64                 return null;
    65                 //Object[] values = map.values().toArray();
    66                 //return Casting.tryCast(i < values.length ? values[i] : null, type);
     113                Iterator<Map.Entry<String, Object>> iterator = map.entrySet().iterator();
     114                while (i > 0 && iterator.hasNext()) {
     115                        iterator.next();
     116                        --i;
     117                }
     118                if (i > 0) {
     119                        return null;
     120                }
     121                if (!iterator.hasNext()) {
     122                        return null;
     123                }
     124                return Casting.tryCast(type, iterator.next().getValue());
    67125        }
    68126
     
    73131                        return get(i, type);
    74132                }
    75                 return Casting.tryCast(type, map.containsKey(id) ? map.get(id) : null);
     133                Integer uidNumber = getUidNumber(id);
     134                if (uidNumber == null) {
     135                        return null;
     136                }
     137                return Casting.tryCast(type, map.get(id));
    76138        }
    77139
     
    110172        @Override
    111173        public <T> int set(int i, T value) {
    112                 log.error("accesing unique list through index");
    113                 //return setByUid(value, null);
    114                 return 0;
     174                throw new UnsupportedOperationException().msg("accesing unique list through index");
    115175        }
    116176
     
    184244
    185245        @Override
    186         public Collection<Param> getParams() {
    187                 List<Param> result = new LinkedList<Param>();
    188                 if (map == null) {
    189                         return result;
    190                 }
    191                 for (String k : map.keySet()) {
    192                         result.add(getParam(k));
    193                 }
    194                 return result;
     246        public Iterable<Param> getParams() {
     247                return new Iterable<Param>() {
     248
     249                        @Override
     250                        public Iterator<Param> iterator() {
     251                                return new Iterator<Param>() {
     252
     253                                        protected Iterator<Map.Entry<String, Object>> internal = map.entrySet().iterator();
     254
     255                                        @Override
     256                                        public boolean hasNext() {
     257                                                return internal.hasNext();
     258                                        }
     259
     260                                        @Override
     261                                        public Param next() {
     262                                                return Param.build().id(internal.next().getKey()).forAccess(elementAccess).finish();
     263                                        }
     264
     265                                        @Override
     266                                        public void remove() {
     267                                                throw new UnimplementedException().msg("remove element from list").arg("list", UniqueListAccess.this);
     268
     269                                        }
     270                                };
     271                        }
     272                };
     273        }
     274
     275        @Override
     276        public int getCompositeParamCount() {
     277                return map.size();
     278        }
     279
     280        @Override
     281        public CompositeParam getCompositeParam(int number) {
     282                return getParam(number);
    195283        }
    196284}
Note: See TracChangeset for help on using the changeset viewer.