Ignore:
Timestamp:
07/12/13 23:41:06 (11 years ago)
Author:
psniegowski
Message:

HIGHLIGHTS:

  • add <include/> to configuration
  • add side notes to tree
    • used to store arbitrary information alongside the tree structure
  • migrate to log4j2
    • supports lazy string evaluation of passed arguments
  • improve GUI tree
    • it stays in synchronization with actual state (even in high load test scenario)
  • improve panel management in GUI
  • make loading objects in GUI more lazy
  • offload parsing to connection receiver thread
    • info parsing
    • first step of objects parsing
  • fix connection parsing bug (eof in long values)
  • support zero-arguments procedure in table view

CHANGELOG:
Implement procedure calls from table view.

Refactorization around procedures in tables.

Add table editor for buttons.

Render buttons in the the list view.

Further improve Columns.

Add Column class for TableModel?.

Accept also non-arguments ProcedureParams? in tableView.

Increase maximal TextAreaControl? size.

Add tooltip to ProcedureControl?.

Fix bug of interpreting eofs in long values by connection reader.

Further rework connection parsing.

Simplify client connection processing.

Test ListChange? modification.

Test ListChange? events with java server.

Add TestChild?.

Fix bug with fast deregistering when connecting to running server.

Another minor refactorization in TreeOperations?.

Fix bug in SimpleAbstractAccess? loading routine.

Another minor improvement.

Minor change.

Make reading of List objects two-phase.

Another minor change.

Dispatch parsing into receiver thread.

Another step.

Enclose passing value in ObjectParam? case in closure.

Minor step.

Minor change on way to offload parsing.

Temporarily comment out single ValueParam? get.

It will be generalized to multi ValueParam?.

Process info in receiver thread.

Add DispatchingExceptionHandler?.

Make waits in browser test longer.

Use FETCHED_MARK.

It is honored in GUI, where it used to decide whether to get values

after user action.

It is set in standard algorithm for processing fetched values.

Add remove operation to side notes.

Make loading more lazy.

Improve loading policy.

On node choose load itself, on node expansion, load children.

Minor improvement.

Fix bug with panel interleaving.

Minor improvements.

Improve panel management.

More cleaning around panels.

Reorganize panels.

Further improve tree.

Fix bug in TreeModel?.

Remove children from TreeNode?.

Implement TreeNode? hashCode and equals.

Make TreeNode? delegate equals and hashcode to internal reference.

Move listeners from TreeNode? to side notes.

Store path.textual as a side note.

Side note params instead of accesses for objects.

More refactorizations.

In TreeNode? bindAccess based on side notes.

Minor step.

Hide createAccess.

Rename AccessInterface? to Access.

Minor changes.

Several improvements in high load scenarios.

Change semantics of ArrayListAccess?.set(index, null);

It now removes the element, making list shorter
(it was set to null before).

Add path remove handler.

Handle exceptions in Connection.

Update .gitignore

Configure logging to file.

Move registration to TreeModel?.

Further refactorization.

Minor refactorization.

Minor improvements.

Use specialized event also for Modify action of ListChange?.

Use remove events.

Use the insertion events for tree.

Further improve tree refreshing.

Further improve reacting on events in GUI.

Fix problem with not adding objects on addition list change.

Migrate to log4j lazy String construction interface.

Migrate imports to log4j2.

Drop dependency on adapter to version 1.2.

Switch log4j implementation to log4j2.

Add dirty mark to the NodeAtFrame?.

Make selecting in AccessInterfaces? type safe.

Ignore containers size settings in Model and Genotype.

Use tree side notes to remember local changes and panels.

Add sideNotes to tree.

They will be used to store various accompanying information
right in the tree.

Use ReferenceIdentityMap? from apache in TreeNode?.

It suits the need perfectly (weak semantics on both key and value).

Make ArrayListParam? do not react size changes.

Guard in TableModel? before not yet loaded objects.

Add <include/> clause and AutoInjector?.

Extract common columns configuration to separate xml,
that can be included by other configurations.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • java/main/src/main/java/com/framsticks/gui/table/TableModel.java

    r99 r100  
    66import java.util.List;
    77
     8import javax.swing.JCheckBox;
     9import javax.swing.JComponent;
     10import javax.swing.JTable;
     11import javax.swing.UIManager;
    812import javax.swing.event.TableModelEvent;
    913import javax.swing.event.TableModelListener;
    1014
    11 import org.apache.log4j.Logger;
     15import org.apache.logging.log4j.Logger;
     16import org.apache.logging.log4j.LogManager;
    1217
    13 import com.framsticks.params.AccessInterface;
     18import com.framsticks.params.Access;
    1419import com.framsticks.params.ListAccess;
     20import com.framsticks.params.Param;
    1521import com.framsticks.params.PrimitiveParam;
    16 import com.framsticks.util.UnsupportedOperationException;
     22import com.framsticks.params.types.ProcedureParam;
    1723import com.framsticks.util.lang.Casting;
    1824
    1925public class TableModel implements javax.swing.table.TableModel {
    20         private static final Logger log =
    21                 Logger.getLogger(TableModel.class);
    2226
     27        private static final Logger log = LogManager.getLogger(TableModel.class);
    2328
    2429        protected List<TableModelListener> listeners = new LinkedList<>();
    2530        protected ListAccess access;
    26         protected AccessInterface elementAccess;
    27         protected final List<PrimitiveParam<?>> columnParams = new ArrayList<>();
     31        protected Access elementAccess;
     32        protected final List<Column> columns = new ArrayList<>();
     33        protected final ListPanel listPanel;
     34        protected JTable table;
     35
     36        /**
     37         * @param listPanel
     38         */
     39        public TableModel(ListPanel listPanel) {
     40                this.listPanel = listPanel;
     41        }
     42
     43        /**
     44         * @return the listPanel
     45         */
     46        public ListPanel getListPanel() {
     47                return listPanel;
     48        }
     49
     50        public JTable getTable() {
     51                return listPanel.getTable();
     52        }
    2853
    2954        protected void refreshAll() {
     
    3156                        l.tableChanged(new TableModelEvent(this));
    3257                }
     58        }
    3359
     60        /**
     61         * @param table the table to set
     62         */
     63        public void setupTable() {
     64                getTable().setDefaultRenderer(ProcedureParam.class, new ProcedureRenderer());
     65                getTable().setDefaultEditor(ProcedureParam.class, new ProcedureEditor(new JCheckBox()));
    3466        }
    3567
     
    3870
    3971                this.elementAccess = this.access.getElementAccess().cloneAccess();
    40                 log.debug("attached " + access);
     72                log.debug("attached {}", access);
    4173                refreshAll();
    4274        }
     
    4981        @Override
    5082        public Class<?> getColumnClass(int columnIndex) {
    51                 // log.debug("returning column type " + columnParams.get(columnIndex).getStorageType());
    52                 return columnParams.get(columnIndex).getStorageType();
     83                // log.debug("returning column type {}", columnParams.get(columnIndex).getStorageType());
     84                return columns.get(columnIndex).getColumnClass();
    5385        }
    5486
    5587        @Override
    5688        public int getColumnCount() {
    57                 // log.debug("returning column count " + columnParams.size());
    58                 return columnParams.size();
     89                // log.debug("returning column count {}", columnParams.size());
     90                return columns.size();
    5991        }
    6092
    6193        @Override
    6294        public String getColumnName(int columnIndex) {
    63                 return columnParams.get(columnIndex).getName();
     95                return columns.get(columnIndex).getParam().getName();
    6496        }
    6597
    6698        @Override
    6799        public int getRowCount() {
    68                 // log.debug("returning row count " + access.getParamCount());
    69                 return access.getParamCount();
     100                // log.debug("returning row count {}", access.getParamCount());
     101                return access == null ? 0 : access.getParamCount();
    70102        }
    71103
    72104        @Override
    73105        public Object getValueAt(int rowIndex, int columnIndex) {
    74                 assert (rowIndex < access.getParamCount() && columnIndex < columnParams.size());
     106                assert (rowIndex < access.getParamCount() && columnIndex < columns.size());
    75107
    76                 return elementAccess.select(access.get(rowIndex, Object.class)).get(columnParams.get(columnIndex), Object.class);
     108                return columns.get(columnIndex).getValueAt(rowIndex);
    77109        }
    78110
    79111        @Override
    80112        public boolean isCellEditable(int rowIndex, int columnIndex) {
    81                 return false;
     113                return columns.get(columnIndex).isEditable();
    82114        }
    83115
     
    87119        }
    88120
     121
    89122        @Override
    90123        public void setValueAt(Object value, int rowIndex, int columnIndex) {
    91                 throw new UnsupportedOperationException().msg("setting value in table");
    92 
     124                assert (rowIndex < access.getParamCount() && columnIndex < columns.size());
     125                // Object object = getObjectAt(rowIndex, columnIndex);
     126                // if (object == null) {
     127                //      return;
     128                // }
     129                columns.get(columnIndex).setValueAt(rowIndex, value);
    93130        }
    94131
    95         public void addColumn(PrimitiveParam<?> columnParam) {
    96                 log.debug("added " + columnParam);
    97                 columnParams.add(columnParam);
     132        public void addColumn(Column column) {
     133                log.debug("added {}", column);
     134                columns.add(column);
     135        }
     136
     137        /**
     138         * @return the access
     139         */
     140        public ListAccess getAccess() {
     141                return access;
     142        }
     143
     144        /**
     145         * @return the elementAccess
     146         */
     147        public Access getElementAccess() {
     148                return elementAccess;
    98149        }
    99150
     
    101152         * @return the columnParams
    102153         */
    103         public List<PrimitiveParam<?>> getColumnParams() {
    104                 return Collections.unmodifiableList(columnParams);
     154        public List<Column> getColumns() {
     155                return Collections.unmodifiableList(columns);
     156        }
     157
     158
     159        public boolean addColumnIfSupported(Param param) {
     160                if (param instanceof PrimitiveParam) {
     161                        addColumn(new PrimitiveColumn((PrimitiveParam<?>) param, this));
     162                        return true;
     163                }
     164                if (param instanceof ProcedureParam) {
     165                        if (((ProcedureParam) param).getArgumentsType().size() == 0) {
     166                                addColumn(new ProcedureColumn((ProcedureParam) param, this));
     167                                return true;
     168                        }
     169                        return false;
     170                }
     171                return false;
     172        }
     173
     174        public static void transferCellAppeariance(JTable table, JComponent component, boolean isSelected) {
     175                if (isSelected) {
     176                        component.setForeground(table.getSelectionForeground());
     177                        component.setBackground(table.getSelectionBackground());
     178                } else {
     179                        component.setForeground(table.getForeground());
     180                        component.setBackground(UIManager.getColor("Button.background"));
     181                }
     182
    105183        }
    106184
Note: See TracChangeset for help on using the changeset viewer.