source: java/main/src/main/java/com/framsticks/gui/table/TableModel.java @ 99

Last change on this file since 99 was 99, checked in by psniegowski, 11 years ago

HIGHLIGTS:

  • complete events implementation
  • add CLI in Java Framsticks server
  • add automatic registration for events in GUI
  • improve objects fetching (object are never overwritten with new instances)
  • properly react for ListChange? events
  • add ListPanel? with table view
    • columns to be shown may be statically specified in configuration
    • currently modyfying data through tables is not available
  • improve maven configuration
    • configuration file may be specified without touching pom.xml

CHANGELOG:
Extract constants from Flags into ParamFlags? and SetStateFlags?.

Extract flags I/O to FlagsUtils? class.

Configured maven to exec given resource configuration.

For example:
mvn exec:exec -Dframsticks.config=/configs/managed-console.xml

Cleanup pom.xml

Rename ObjectTree? to LocalTree? (also make LocalTree? and RemoteTree? final).

Minor change.

Add maximum number of columns in ListPanelProvider?.

Improve ColumnsConfig? interpretation.

Automatically fill FramsClass?.name if trying to construct empty.

Improve identitifer case mangling in XmlLoader?.

Introduce configurable ColumnsConfig?.

Draft working version of ListPanel?.

Table is being shown (although empty).

More improvements to table building.

Move some functionality from Frame to TreeModel?.

Move tree classes in gui to separate package.

Remove old table related classes.

Add draft implementation of TableModel?.

Redirect ParamBuilder?.forAccess to AccessInterface?.

Optimize ParamBuilder?.forAccess()

Do not clear list when loading.

Do not load fetched values directly.

Implement different AccessInterface? copying policy.

Optimize fetching values routine.

Remove Mode enum (work out get semantics).

Some improvements to ListChange? handling.

Improve UniqueListAccess?.

Add reaction for ListChanges? in the TreeNode?.

EventListeners? are being added in the TreeNode?.

Listeners for ListParams? are now very naive (they download
whole list).

Automatially register on events in GUI.

Events are working in RemoteTree? and Server.

Move listeners to the ClientSideManagedConnection?.

Remove old classes responsible for event subscriptions.

Improve event reading.

Improve events handling at server side.

Add register attribute in FramsClassAnnotation?
to automatically also register other classes.

Registering events works.

Setup for remote listeners registration.

More improvements.

Minor changes.

Add rootTree to the ClientAtServer?.

Moving CLI to the ClientAtServer?.

Fix bug: use Void.TYPE instead of Void.class

More development around CLI.

  • Improve Path resolving.

Add synthetic root to ObjectTree?.

It is needed to allow sybling for the original root
that would containg CLI.

Some work with registering events in RemoteTree?.

Draft implementation of listener registering in RemoteTree?.

Support events registration in the ObjectTree?.

Add events support to ReflectionAccess?.

EventParam? is recognized by ParamCandidate?.

Prepare interface for Events across project.

Add EventListener? and API for listeners in Tree.

File size: 2.8 KB
Line 
1package com.framsticks.gui.table;
2
3import java.util.ArrayList;
4import java.util.Collections;
5import java.util.LinkedList;
6import java.util.List;
7
8import javax.swing.event.TableModelEvent;
9import javax.swing.event.TableModelListener;
10
11import org.apache.log4j.Logger;
12
13import com.framsticks.params.AccessInterface;
14import com.framsticks.params.ListAccess;
15import com.framsticks.params.PrimitiveParam;
16import com.framsticks.util.UnsupportedOperationException;
17import com.framsticks.util.lang.Casting;
18
19public class TableModel implements javax.swing.table.TableModel {
20        private static final Logger log =
21                Logger.getLogger(TableModel.class);
22
23
24        protected List<TableModelListener> listeners = new LinkedList<>();
25        protected ListAccess access;
26        protected AccessInterface elementAccess;
27        protected final List<PrimitiveParam<?>> columnParams = new ArrayList<>();
28
29        protected void refreshAll() {
30                for (TableModelListener l : listeners) {
31                        l.tableChanged(new TableModelEvent(this));
32                }
33
34        }
35
36        public void attachSource(ListAccess access) {
37                this.access = Casting.assertCast(ListAccess.class, access.cloneAccess().select(access.getSelected()));
38
39                this.elementAccess = this.access.getElementAccess().cloneAccess();
40                log.debug("attached " + access);
41                refreshAll();
42        }
43
44        @Override
45        public void addTableModelListener(TableModelListener listener) {
46                listeners.add(listener);
47        }
48
49        @Override
50        public Class<?> getColumnClass(int columnIndex) {
51                // log.debug("returning column type " + columnParams.get(columnIndex).getStorageType());
52                return columnParams.get(columnIndex).getStorageType();
53        }
54
55        @Override
56        public int getColumnCount() {
57                // log.debug("returning column count " + columnParams.size());
58                return columnParams.size();
59        }
60
61        @Override
62        public String getColumnName(int columnIndex) {
63                return columnParams.get(columnIndex).getName();
64        }
65
66        @Override
67        public int getRowCount() {
68                // log.debug("returning row count " + access.getParamCount());
69                return access.getParamCount();
70        }
71
72        @Override
73        public Object getValueAt(int rowIndex, int columnIndex) {
74                assert (rowIndex < access.getParamCount() && columnIndex < columnParams.size());
75
76                return elementAccess.select(access.get(rowIndex, Object.class)).get(columnParams.get(columnIndex), Object.class);
77        }
78
79        @Override
80        public boolean isCellEditable(int rowIndex, int columnIndex) {
81                return false;
82        }
83
84        @Override
85        public void removeTableModelListener(TableModelListener listener) {
86                listeners.remove(listener);
87        }
88
89        @Override
90        public void setValueAt(Object value, int rowIndex, int columnIndex) {
91                throw new UnsupportedOperationException().msg("setting value in table");
92
93        }
94
95        public void addColumn(PrimitiveParam<?> columnParam) {
96                log.debug("added " + columnParam);
97                columnParams.add(columnParam);
98        }
99
100        /**
101         * @return the columnParams
102         */
103        public List<PrimitiveParam<?>> getColumnParams() {
104                return Collections.unmodifiableList(columnParams);
105        }
106
107}
Note: See TracBrowser for help on using the repository browser.