JAL-1354 replacement of bare strings in GUI dialogs with i18n bundle lookup via jalvi...
[jalview.git] / src / jalview / gui / EPSOptions.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
3  * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
10  *  
11  * Jalview is distributed in the hope that it will be useful, but 
12  * WITHOUT ANY WARRANTY; without even the implied warranty 
13  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14  * PURPOSE.  See the GNU General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 package jalview.gui;
19
20 import jalview.util.MessageManager;
21
22 import java.awt.*;
23 import java.awt.event.*;
24 import javax.swing.*;
25
26 public class EPSOptions extends JPanel
27 {
28   JDialog dialog;
29
30   public boolean cancelled = false;
31
32   String value;
33
34   public EPSOptions()
35   {
36     try
37     {
38       jbInit();
39     } catch (Exception ex)
40     {
41       ex.printStackTrace();
42     }
43
44     ButtonGroup bg = new ButtonGroup();
45     bg.add(lineart);
46     bg.add(text);
47
48     JOptionPane pane = new JOptionPane(null, JOptionPane.DEFAULT_OPTION,
49             JOptionPane.DEFAULT_OPTION, null, new Object[]
50             { this });
51
52     dialog = pane.createDialog(Desktop.desktop, "EPS Rendering options");
53     dialog.setVisible(true);
54
55   }
56
57   private void jbInit() throws Exception
58   {
59     lineart.setFont(JvSwingUtils.getLabelFont());
60     lineart.setText(MessageManager.getString("label.lineart"));
61     text.setFont(JvSwingUtils.getLabelFont());
62     text.setText(MessageManager.getString("action.text"));
63     text.setSelected(true);
64     askAgain.setFont(JvSwingUtils.getLabelFont());
65     askAgain.setText(MessageManager.getString("label.dont_ask_me_again"));
66     ok.setText(MessageManager.getString("action.ok"));
67     ok.addActionListener(new ActionListener()
68     {
69       public void actionPerformed(ActionEvent e)
70       {
71         ok_actionPerformed(e);
72       }
73     });
74     cancel.setText(MessageManager.getString("action.cancel"));
75     cancel.addActionListener(new ActionListener()
76     {
77       public void actionPerformed(ActionEvent e)
78       {
79         cancel_actionPerformed(e);
80       }
81     });
82     jLabel1.setFont(JvSwingUtils.getLabelFont());
83     jLabel1.setText(MessageManager.getString("label.select_eps_character_rendering_style"));
84     this.setLayout(borderLayout1);
85     jPanel3.setBorder(BorderFactory.createEtchedBorder());
86     jPanel2.add(text);
87     jPanel2.add(lineart);
88     jPanel2.add(askAgain);
89     jPanel1.add(ok);
90     jPanel1.add(cancel);
91     jPanel3.add(jLabel1);
92     jPanel3.add(jPanel2);
93     this.add(jPanel3, java.awt.BorderLayout.CENTER);
94     this.add(jPanel1, java.awt.BorderLayout.SOUTH);
95   }
96
97   JRadioButton lineart = new JRadioButton();
98
99   JRadioButton text = new JRadioButton();
100
101   JCheckBox askAgain = new JCheckBox();
102
103   JButton ok = new JButton();
104
105   JButton cancel = new JButton();
106
107   JPanel jPanel1 = new JPanel();
108
109   JLabel jLabel1 = new JLabel();
110
111   JPanel jPanel2 = new JPanel();
112
113   JPanel jPanel3 = new JPanel();
114
115   BorderLayout borderLayout1 = new BorderLayout();
116
117   public void ok_actionPerformed(ActionEvent e)
118   {
119     if (lineart.isSelected())
120     {
121       value = "Lineart";
122     }
123     else
124     {
125       value = "Text";
126     }
127
128     if (!askAgain.isSelected())
129     {
130       jalview.bin.Cache.applicationProperties.remove("EPS_RENDERING");
131     }
132     else
133     {
134       jalview.bin.Cache.setProperty("EPS_RENDERING", value);
135     }
136
137     dialog.setVisible(false);
138   }
139
140   public void cancel_actionPerformed(ActionEvent e)
141   {
142     cancelled = true;
143     dialog.setVisible(false);
144   }
145
146   public String getValue()
147   {
148     return value;
149   }
150 }