source: java/main/src/main/java/com/framsticks/gui/ModifiablePanel.java @ 101

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

HIGHLIGHTS:

  • improve tree side notes
  • improve GUI layout
  • add foldable list of occured events to EventControl?
  • improve automatic type conversion in proxy listeners
  • implement several Access functionalities as algorithms independent of Access type
  • introduce draft base classes for distributed experiments
  • automatically register dependant Java classes to FramsClass? registry
  • add testing prime experiment and configuration
  • simplify and improve task dispatching

CHANGELOG:
Improve task dispatching in RemoteTree?.

GUI no longer hangs on connection problems.

Make all dispatchers joinables.

Refactorize Thread dispatcher.

Remove Task and PeriodicTask?.

Use Java utilities in those situations.

Reworking tasks dispatching.

Fix bug in EventControl? listener dispatching.

Minor improvements.

Add testing configuration for ExternalProcess? in GUI.

More improvement to prime.

Support for USERREADONLY in GUI.

Add that flag to various params in Java classes.

Remove redundant register clauses from several FramsClassAnnotations?.

Automatically gather and register dependant classes.

Add configuration for prime.

Improve Simulator class.

Add prime.xml configuration.

Introduce draft Experiment and Simulator classes.

Add prime experiment tests.

Enclose typical map with listeners into SimpleUniqueList?.

Needfile works in GUI.

Improve needfile handling in Browser.

More improvement with NeedFile?.

Implementing needfile.

Update test.

Rename ChangeEvent? to TestChangeEvent?.

Automatic argument type search in RemoteTree? listeners.

MultiParamLoader? uses AccessProvider?. By default old implementation
enclosed in AccessStash? or Registry.

Minor changes.

Rename SourceInterface? to Source.

Also improve toString of File and ListSource?.

Remove unused SimpleSource? class.

Add clearing in HistoryControl?.

Show entries in table at EventControl?.

Improve EventControl?.

Add listeners registration to EventControl?.

Add foldable table to HistoryControl?.

Add control row to Procedure and Event controls.

Improve layout of controls.

Another minor change to gui layout.

Minor improvement in the SliderControl?.

Minor changes.

Move ReflectionAccess?.Backend to separate file.

It was to cluttered.

Cleanup in ReflectionAccess?.

Move setMin, setMax, setDef to AccessOperations?.

Extract loading operation into AccessOperations?.

Append Framsticks to name of UnsupportedOperationException?.

The java.lang.UnsupportedOperationException? was shadowing this class.

Rename params.Util to params.ParamsUtil?.

Several improvements.

Minor changes.

Implement revert functionality.

Improve local changes management.

Minor improvement.

Remove methods rendered superfluous after SideNoteKey? improvement.

Improve SideNoteKey?.

It is now generic type, so explicit type specification at
call site is no more needed.

Introduce SideNoteKey? interface.

Only Objects implementing that key may be used as side note keys.

Minor improvements.

Use strings instead of ValueControls? in several gui mappings.

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