source: java/main/src/main/java/com/framsticks/gui/ModifiablePanel.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.6 KB
Line 
1package com.framsticks.gui;
2
3import org.apache.logging.log4j.Logger;
4import org.apache.logging.log4j.LogManager;
5
6
7import javax.swing.*;
8import java.awt.*;
9import java.awt.event.ActionEvent;
10import java.awt.event.ActionListener;
11
12import static com.framsticks.structure.TreeOperations.*;
13
14/**
15 * @author Piotr Sniegowski
16 */
17@SuppressWarnings("serial")
18public abstract class ModifiablePanel extends TreePanel {
19
20        private static final Logger log = LogManager.getLogger(ModifiablePanel.class.getName());
21
22        /**
23         * Pane to which components will be added.
24         */
25
26        protected final JLabel label;
27        protected final JButton applyButton;
28        protected final JButton revertButton;
29        protected final JPanel centerPanel;
30
31        protected Component contentComponent;
32
33        public ModifiablePanel(TreePanel.Parameters parameters) {
34                super(parameters);
35                log.debug("create panel for type: {}", className);
36
37                JPanel pageEndPanel = new JPanel();
38                pageEndPanel.setLayout(new BoxLayout(pageEndPanel, BoxLayout.X_AXIS));
39                pageEndPanel.add(Box.createHorizontalGlue());
40
41                applyButton = new JButton("Apply");
42                applyButton.setName("apply");
43
44                revertButton = new JButton("Revert");
45                revertButton.setName("revert");
46
47                pageEndPanel.add(applyButton);
48                pageEndPanel.add(Box.createHorizontalStrut(10));
49
50                pageEndPanel.add(revertButton);
51                pageEndPanel.add(Box.createHorizontalStrut(10));
52
53                pageEndPanel.setPreferredSize(new Dimension(0, 30));
54
55                applyButton.addActionListener(new ActionListener() {
56                        public void actionPerformed(ActionEvent e) {
57                                applyChanges();
58                        }
59                });
60
61                revertButton.addActionListener(new ActionListener() {
62                        public void actionPerformed(ActionEvent e) {
63                                revertChanges();
64                        }
65                });
66
67                label = new JLabel();
68                centerPanel = new JPanel();
69                centerPanel.setLayout(new BorderLayout());
70                centerPanel.add(Box.createHorizontalStrut(10), BorderLayout.LINE_START);
71                centerPanel.add(Box.createHorizontalStrut(10), BorderLayout.LINE_END);
72                centerPanel.add(label, BorderLayout.PAGE_START);
73
74
75                centerPanel.add(pageEndPanel, BorderLayout.PAGE_END);
76
77                this.setLayout(new BorderLayout());
78                this.add(centerPanel, BorderLayout.CENTER);
79                //this.add(new ViewerTest(), BorderLayout.PAGE_END);
80        }
81
82        protected abstract void applyChanges();
83        protected abstract void revertChanges();
84
85        protected void setupContentComponent(Component contentComponent) {
86                this.contentComponent = contentComponent;
87                centerPanel.add(contentComponent, BorderLayout.CENTER);
88        }
89
90        protected void refreshControlButtons() {
91                assert frame.isActive();
92                boolean hasChanges = hasSideNotes(getTree(), getCurrentObject(), treeAtFrame.getUserChangesKey());
93                applyButton.setEnabled(hasChanges);
94                revertButton.setEnabled(hasChanges);
95        }
96
97}
Note: See TracBrowser for help on using the repository browser.