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/gui/view/TreeCellRenderer.java

    r90 r98  
    11package com.framsticks.gui.view;
    22
    3 import com.framsticks.gui.ImageProvider;
    4 import com.framsticks.gui.TreeNode;
     3import java.awt.Component;
    54
    6 import javax.swing.*;
     5import javax.swing.JTree;
    76import javax.swing.tree.DefaultTreeCellRenderer;
    87
    9 import org.apache.log4j.Logger;
    10 
    11 import java.awt.*;
     8import com.framsticks.gui.AbstractNode;
     9import com.framsticks.gui.ImageProvider;
     10import com.framsticks.params.CompositeParam;
    1211
    1312/**
     
    1615@SuppressWarnings("serial")
    1716public class TreeCellRenderer extends DefaultTreeCellRenderer {
    18         private static final Logger log =
    19                 Logger.getLogger(TreeCellRenderer.class);
    20 
    2117
    2218        public TreeCellRenderer() {
    23                 setOpenIcon(null);
    24                 setClosedIcon(null);
    25                 setLeafIcon(null);
     19
     20                // setOpenIcon(ImageProvider.loadImage(ImageProvider.FOLDER_OPEN));
     21                // setClosedIcon(ImageProvider.loadImage(ImageProvider.FOLDER_CLOSED));
     22                // setLeafIcon(ImageProvider.loadImage(ImageProvider.NODE));
    2623        }
    2724
     
    3128                        boolean hasFocus) {
    3229
    33                 //super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf,
    34                 //              row, hasFocus);
     30                super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
     31
    3532                if (value == null) {
     33                        setText("!null value");
    3634                        return this;
    3735                }
    38                 if (!(value instanceof TreeNode)) {
     36
     37                if (!(value instanceof AbstractNode)) {
    3938                        setIcon(ImageProvider.loadImage(ImageProvider.SERVER));
    4039                        setText("framsticks");
    4140                        return this;
    4241                }
    43                 TreeNode treeNode = (TreeNode)value;
    44                 assert treeNode.getFrame().isActive();
    45                 setToolTipText(treeNode.getTooltip());
    46                 setIcon(ImageProvider.loadImage(treeNode.getIconName()));
    47                 setText(treeNode.getName());
     42                ((AbstractNode) value).render(this);
     43
    4844                return this;
    4945        }
    5046
    51         public static String findIconName(String nodeName, String path) {
    52                 if (nodeName == null || path == null) {
    53                         log.warn("given invalid parameters: " + nodeName + " " + path);
    54                         // return null;
    55                         return ImageProvider.SERVER;
     47        public static String findIconName(CompositeParam param) {
     48                switch (param.getFramsTypeName()) {
     49                        case "o Server": return ImageProvider.SERVER;
     50                        case "o Simulator": return ImageProvider.SIMULATOR;
     51                        case "o CLI": return ImageProvider.CLI;
     52                        case "o World": return ImageProvider.WORLD;
     53                        case "o GenePools": return ImageProvider.GENEPOOLS;
     54                        case "l GenePool": return ImageProvider.SIMULATOR; //HERE
     55                        case "o GenePool": return ImageProvider.GENEPOOLS_GROUP; //HERE
     56
     57                        case "o Populations": return ImageProvider.POPULATIONS;
     58                        case "l Population": return ImageProvider.SIMULATOR; ///HERE
     59                        case "o Population": return ImageProvider.POPULATION_GROUP;
     60                        case "o ExpParams": return ImageProvider.EXPERIMENT;
     61                        case "o stats": return ImageProvider.STATISTIC;
     62                        case "l Genotype uid": return ImageProvider.GENOTYPES_GROUP;
     63                        case "o Genotype": return ImageProvider.GENOTYPES;
     64
     65                        case "o Part": return ImageProvider.PART;
     66                        case "o Joint": return ImageProvider.JOINT;
     67                        case "o NeuroDef": return ImageProvider.NEURON_DEF;
     68                        case "o NeuroConn": return ImageProvider.NEURON_DEF;
     69
     70                        case "o MechPart": return ImageProvider.MECH_PART;
     71                        case "o MechJoint": return ImageProvider.MECH_JOINT;
     72                        case "o Neuro": return ImageProvider.NEURON;
     73
     74                        case "l Part": return ImageProvider.PART_GROUP;
     75                        case "l Joint": return ImageProvider.JOINT_GROUP;
     76                        case "l NeuroDef": return ImageProvider.NEURON_DEF_GROUP;
     77                        case "l NeuroConn": return ImageProvider.NEURON_DEF_GROUP;
     78
     79                        case "l MechPart": return ImageProvider.MECH_PART_GROUP;
     80                        case "l MechJoint": return ImageProvider.MECH_JOINT_GROUP;
     81                        case "l Neuro": return ImageProvider.NEURON_GROUP;
     82
     83                        case "o Creature": return ImageProvider.CREATURE;
     84                        case "l Creature uid": return ImageProvider.CREATURES_GROUP;
     85                        case "l Event id": return ImageProvider.EVENT;
     86                        case "o Event": return ImageProvider.EVENT;
     87
    5688                }
    57                 if (path.equals("/")) {
    58                         return ImageProvider.SERVER;
    59                 }
    60                 if (path.endsWith("simulator")) {
    61                         return ImageProvider.SIMULATOR;
    62                 }
    63                 if (path.endsWith("cli")) {
    64                         return ImageProvider.CLI;
    65                 }
    66                 if (path.endsWith("world")) {
    67                         return ImageProvider.WORLD;
    68                 }
    69                 if (path.endsWith("genepools")) {
    70                         return ImageProvider.GENEPOOLS;
    71                 }
    72                 if (path.endsWith("populations")) {
    73                         return ImageProvider.POPULATIONS;
    74                 }
    75                 if (path.endsWith("experiment")) {
    76                         return ImageProvider.EXPERIMENT;
    77                 }
    78                 if (path.endsWith("stats")) {
    79                         return ImageProvider.STATISTIC;
    80                 }
    81                 if (nodeName.equals("creatures") || path.endsWith("creatures")) {
    82                         return ImageProvider.CREATURES_GROUP;
    83                 }
    84                 if (nodeName.equals("Favourite Fields")) {
    85                         return ImageProvider.FAVORITE_FIELDS;
    86                 }
    87                 if (nodeName.equals("genotypes") || path.endsWith("creatures")) {
    88                         return ImageProvider.GENOTYPES_GROUP;
    89                 }
    90                 if (nodeName.equals("parts") || path.endsWith("parts")) {
    91                         return ImageProvider.PART_GROUP;
    92                 }
    93                 if (nodeName.equals("joints") || path.endsWith("joints")) {
    94                         return ImageProvider.JOINT_GROUP;
    95                 }
    96                 if (nodeName.equals("neurodefs") || path.endsWith("neurodefs")) {
    97                         return ImageProvider.NEURON_DEF_GROUP;
    98                 }
    99                 if (nodeName.equals("neuroconns") || path.endsWith("neuroconns")) {
    100                         return ImageProvider.NEURON_DEF_GROUP;
    101                 }
    102                 if (nodeName.equals("mechparts") || path.endsWith("mechparts")) {
    103                         return ImageProvider.MECH_PART_GROUP;
    104                 }
    105                 if (nodeName.equals("mechjoints") || path.endsWith("mechjoints")) {
    106                         return ImageProvider.MECH_JOINT_GROUP;
    107                 }
    108                 if (nodeName.equals("neurons") || path.endsWith("neurons")) {
    109                         return ImageProvider.NEURON_GROUP;
    110                 }
    111                 if (path.matches("^.*parts/[0-9]+$")) {
    112                         return ImageProvider.PART;
    113                 }
    114                 if (path.matches("^.*joints/[0-9]+$")) {
    115                         return ImageProvider.JOINT;
    116                 }
    117                 if (path.matches("^.*neurodefs/[0-9]+$")) {
    118                         return ImageProvider.NEURON_DEF;
    119                 }
    120                 if (path.matches("^.*neuroconns/[0-9]+$")) {
    121                         return ImageProvider.NEURON_DEF;
    122                 }
    123                 if (path.matches("^.*mechparts/[0-9]+$")) {
    124                         return ImageProvider.MECH_PART;
    125                 }
    126                 if (path.matches("^.*mechjoints/[0-9]+$")) {
    127                         return ImageProvider.MECH_JOINT;
    128                 }
    129                 if (path.matches("^.*neurons/[0-9]+$")) {
    130                         return ImageProvider.NEURON;
    131                 }
    132                 if (path.matches("^.*creatures/c[0-9]+$")) {
    133                         return ImageProvider.CREATURE;
    134                 }
    135                 if (path.matches("^.*genotypes/g[0-9]+$")) {
    136                         return ImageProvider.GENOTYPES;
    137                 }
    138                 if (path.matches("^.*populations/groups/[0-9]+$")) {
    139                         return ImageProvider.POPULATION_GROUP;
    140                 }
    141                 if (path.matches("^.*genepools/groups/[0-9]+$")) {
    142                         return ImageProvider.GENEPOOLS_GROUP;
    143                 }
    144                 if (path.matches("^.*events/e[0-9]+$")) {
    145                         return ImageProvider.EVENT;
    146                 }
    147                 return ImageProvider.SIMULATOR;
     89
     90
     91                return ImageProvider.SERVER;
    14892        }
    14993
    15094
     95
    15196}
Note: See TracChangeset for help on using the changeset viewer.