f@0
|
1 /*
|
f@0
|
2 Cross-Modal DAW Prototype - Prototype of a simple Cross-Modal Digital Audio Workstation.
|
f@0
|
3
|
f@0
|
4 Copyright (C) 2015 Queen Mary University of London (http://depic.eecs.qmul.ac.uk/)
|
f@0
|
5
|
f@0
|
6 This program is free software: you can redistribute it and/or modify
|
f@0
|
7 it under the terms of the GNU General Public License as published by
|
f@0
|
8 the Free Software Foundation, either version 3 of the License, or
|
f@0
|
9 (at your option) any later version.
|
f@0
|
10
|
f@0
|
11 This program is distributed in the hope that it will be useful,
|
f@0
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
f@0
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
f@0
|
14 GNU General Public License for more details.
|
f@0
|
15
|
f@0
|
16 You should have received a copy of the GNU General Public License
|
f@0
|
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
|
f@0
|
18 */
|
f@0
|
19 package uk.ac.qmul.eecs.depic.daw.gui;
|
f@0
|
20
|
f@0
|
21 import java.awt.BorderLayout;
|
f@0
|
22 import java.awt.Color;
|
f@0
|
23 import java.awt.FlowLayout;
|
f@0
|
24 import java.awt.Frame;
|
f@0
|
25 import java.awt.event.ActionEvent;
|
f@0
|
26 import java.awt.event.ActionListener;
|
f@0
|
27 import java.util.ArrayList;
|
f@0
|
28
|
f@0
|
29 import javax.swing.BorderFactory;
|
f@0
|
30 import javax.swing.JButton;
|
f@0
|
31 import javax.swing.JDialog;
|
f@0
|
32 import javax.swing.JPanel;
|
f@0
|
33 import javax.swing.JTabbedPane;
|
f@0
|
34
|
f@2
|
35 /**
|
f@2
|
36 *
|
f@2
|
37 * Preference Dialog. It contains preference panels and when OK button is pressed
|
f@2
|
38 * it calls {@code savePrefs()} on all the panels.
|
f@2
|
39 *
|
f@2
|
40 */
|
f@0
|
41 public class PreferencesDialog extends JDialog {
|
f@0
|
42 private static final long serialVersionUID = 1L;
|
f@0
|
43 private final JTabbedPane content = new JTabbedPane();
|
f@0
|
44 private ArrayList<PreferencesPanel> panels;
|
f@0
|
45
|
f@0
|
46 private ActionListener actionListener = new ActionListener(){
|
f@0
|
47 @Override
|
f@0
|
48 public void actionPerformed(ActionEvent evt) {
|
f@0
|
49 if("OK".equals(evt.getActionCommand())){
|
f@0
|
50 savePrefs();
|
f@0
|
51 dispose();
|
f@0
|
52 }else if("Cancel".equals(evt.getActionCommand())){
|
f@0
|
53 dispose();
|
f@0
|
54 }
|
f@0
|
55 }
|
f@0
|
56 };
|
f@0
|
57
|
f@0
|
58 /**
|
f@0
|
59 * Create the dialog.
|
f@0
|
60 */
|
f@0
|
61 public PreferencesDialog(Frame owner) {
|
f@0
|
62 super(owner,"Preferences",true);
|
f@0
|
63 panels = new ArrayList<>();
|
f@0
|
64
|
f@0
|
65 setBounds(100, 100, 387, 269);
|
f@0
|
66 getContentPane().setLayout(new BorderLayout());
|
f@0
|
67 //content.setBorder(new EmptyBorder(5, 5, 5, 5));
|
f@0
|
68 getContentPane().add(content, BorderLayout.CENTER);
|
f@0
|
69
|
f@0
|
70 {
|
f@0
|
71 JPanel buttonPane = new JPanel();
|
f@0
|
72 buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
f@0
|
73 buttonPane.setBorder(BorderFactory.createMatteBorder(1,0,0,0,Color.GRAY));
|
f@0
|
74 getContentPane().add(buttonPane, BorderLayout.SOUTH);
|
f@0
|
75 {
|
f@0
|
76 JButton okButton = new JButton("OK");
|
f@0
|
77 okButton.setActionCommand("OK");
|
f@0
|
78 okButton.addActionListener(actionListener);
|
f@0
|
79 buttonPane.add(okButton);
|
f@0
|
80 getRootPane().setDefaultButton(okButton);
|
f@0
|
81 }
|
f@0
|
82 {
|
f@0
|
83 JButton cancelButton = new JButton("Cancel");
|
f@0
|
84 cancelButton.setActionCommand("Cancel");
|
f@0
|
85 cancelButton.addActionListener(actionListener);
|
f@0
|
86 buttonPane.add(cancelButton);
|
f@0
|
87 }
|
f@0
|
88 }
|
f@0
|
89 }
|
f@0
|
90
|
f@0
|
91 private void savePrefs(){
|
f@0
|
92 for(PreferencesPanel p : panels)
|
f@0
|
93 p.savePrefs();
|
f@0
|
94 }
|
f@0
|
95
|
f@0
|
96 public void addPanel(PreferencesPanel p){
|
f@0
|
97 panels.add(p);
|
f@0
|
98 content.add(p,p.getTitle());
|
f@0
|
99 }
|
f@0
|
100 }
|
f@0
|
101
|