1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package de.desy.acop.displayers.chart;
24
25 import java.awt.Component;
26 import java.awt.GridBagConstraints;
27 import java.awt.GridBagLayout;
28 import java.awt.Insets;
29 import java.awt.event.ActionEvent;
30 import java.awt.event.ActionListener;
31
32 import javax.swing.JButton;
33 import javax.swing.JDialog;
34 import javax.swing.JOptionPane;
35 import javax.swing.JPanel;
36
37 import de.desy.acop.displayers.selector.SelectorUtilities;
38 import de.desy.acop.transport.ConnectionParameters;
39
40
41
42
43
44
45
46
47
48 public class TrendSelectorDialog {
49
50 private static final long serialVersionUID = 1L;
51
52 private JDialog dialog;
53 private TrendSelector trendSelector;
54 private JButton applyButton;
55
56 private boolean apply = false;
57
58 public TrendSelectorDialog(Component owner) {
59 dialog = new JDialog(JOptionPane.getFrameForComponent(owner), "Trend Settings", true);
60 dialog.setSize(300, 400);
61 JPanel contentPane = new JPanel(new GridBagLayout());
62 trendSelector = new TrendSelector();
63 applyButton = new JButton("Apply");
64 applyButton.addActionListener(new ActionListener() {
65 public void actionPerformed(ActionEvent e) {
66 apply = true;
67 dialog.setVisible(false);
68 }});
69 contentPane.add(trendSelector, new GridBagConstraints(0,0,1,1,1,1,GridBagConstraints.CENTER,GridBagConstraints.BOTH,new Insets(1,1,1,1),0,0));
70 contentPane.add(applyButton, new GridBagConstraints(0,1,1,1,0,0,GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(1,1,1,1),0,0));
71 dialog.setContentPane(contentPane);
72 }
73
74
75
76
77
78
79
80
81 public HistoryParameters chooseHistoryParameters(ConnectionParameters cp) {
82 apply = false;
83 trendSelector.setHistoryParameters(cp.getDeviceContext(), cp.getDeviceGroup(), cp.getDeviceName(), cp.getDeviceProperty());
84 if (SelectorUtilities.isConnectionParametersValid(cp)) {
85 trendSelector.setIndexMax(SelectorUtilities.getSequenceLength(cp)-1);
86 }
87 dialog.setLocationRelativeTo(dialog.getOwner());
88 dialog.setVisible(true);
89 if (apply) return trendSelector.getHistoryParameters();
90 else return null;
91 }
92
93 }