source: java/main/src/main/java/com/framsticks/gui/table/ListPanel.java @ 105

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

HIGHLIGHTS:

  • import refactorization: move Tree, Path, etc.

from core to structure package

  • initial serialization implementation
  • improve PrimeExperiment? test
  • many organizational changes and convenience improvements

CHANGELOG:
Make registry in AbstractTree? final.

Move most classes from core to structure package.

Minor changes.

Switch names of Future and FutureHandler?.

Rename ExceptionResultHandler? to ExceptionHandler?.

Rename ExceptionHandler? to ExceptionDispatcherHandler?.

Fix bug in ParamCandidate? cache.

Add missing synchronization to the BufferedDispatcher?.

Develop @Serialized support.

Rework serialization further.

Add serialization/deserialization interface to ValueParam?.

Move getStorageType and isNumeric from Param down to params hierarchy.

Minor changes.

Improve param type induction.

Add TestSerializedClass? for testing new serialization.

Add info files gor GenePool? and Population.

Add standard.expt exemplary netfile.

Add type name field to PropertiesObject?.

Use PropertiesObject? for PropertiesAccess? instead of ordinary map.

Hide getFramsClass is several more places.

More unification accross FramsClass?, Access and Path.

Add ParamCollection?.

Simplify interface for getting params from FramsClass?, Access
or Path.

Make Access.call() interface variadic.

Add arguments(args) convenience wrapper around new Object[] {args}.

Upgrade to apache.commons.lang version 3.1

Minor improvement with Response constructors.

Develop proper result printing in ClientAtServer?.

Add experimentNetsave to PrimeExperiment?.

File size: 2.5 KB
Line 
1package com.framsticks.gui.table;
2
3
4import com.framsticks.gui.ModifiablePanel;
5import com.framsticks.params.Access;
6import com.framsticks.params.ListAccess;
7import com.framsticks.params.Param;
8import com.framsticks.util.FramsticksException;
9import com.framsticks.util.lang.Casting;
10
11import org.apache.logging.log4j.Logger;
12import org.apache.logging.log4j.LogManager;
13
14import javax.swing.*;
15
16/**
17 * Panel contains table and allows to manages displaying columns.
18 */
19@SuppressWarnings("serial")
20public class ListPanel extends ModifiablePanel {
21
22        private static final Logger log = LogManager.getLogger(ListPanel.class.getName());
23
24        protected final TableModel tableModel;
25        protected final JTable table;
26        protected final JScrollPane scrollPane;
27
28        public ListPanel(Parameters parameters, ListPanelProvider provider) {
29                super(parameters);
30
31                final ColumnsConfig config = provider.getColumnsConfigs().get(framsClass.getName());
32                log.debug("creating ListPanel for {} using config {}", parameters.framsClass, config);
33
34                tableModel = new TableModel(this);
35                if (config != null) {
36                        for (String id : config.getColumnsNames()) {
37                                Param param = framsClass.getParam(id);
38                                if (param == null) {
39                                        throw new FramsticksException().msg("requested param not found in frams class").arg("param", id).arg("frams class", framsClass);
40                                }
41                                if (!tableModel.addColumnIfSupported(param)) {
42                                        throw new FramsticksException().msg("param is not supported in table view").arg("param", param).arg("frams class", framsClass);
43                                }
44                        }
45                } else {
46                        for (Param param : framsClass.getParams()) {
47                                if (provider.getMaximumColumnNumber() != null && tableModel.getColumnCount() >= provider.getMaximumColumnNumber()) {
48                                        break;
49                                }
50                                tableModel.addColumnIfSupported(param);
51                        }
52                }
53
54                table = new JTable(tableModel);
55                tableModel.setupTable();
56                table.setShowGrid(false);
57
58                scrollPane = new JScrollPane(table);
59                setupContentComponent(scrollPane);
60
61                table.getTableHeader().setReorderingAllowed(false);
62                table.setColumnSelectionAllowed(false);
63                table.setCellSelectionEnabled(false);
64                table.setColumnSelectionAllowed(false);
65
66                this.revalidate();
67        }
68
69
70        @Override
71        protected void applyChanges() {
72        }
73
74        @Override
75        protected void revertChanges() {
76        }
77
78        @Override
79        public void pullValuesFromLocalToUser(Access access) {
80                tableModel.attachSource(Casting.throwCast(ListAccess.class, access));
81                refreshControlButtons();
82        }
83
84        @Override
85        public String getTitle() {
86                return "List";
87        }
88
89        /**
90         * @return the table
91         */
92        public JTable getTable() {
93                return table;
94        }
95
96}
Note: See TracBrowser for help on using the repository browser.