JAL-1834 removed quotes around truncated strings with ellipsis
[jalview.git] / src / jalview / gui / HTMLOptions.java
1 package jalview.gui;
2
3 import jalview.util.MessageManager;
4
5 import java.awt.BorderLayout;
6 import java.awt.event.ActionEvent;
7 import java.awt.event.ActionListener;
8
9 import javax.swing.BorderFactory;
10 import javax.swing.ButtonGroup;
11 import javax.swing.JButton;
12 import javax.swing.JCheckBox;
13 import javax.swing.JDialog;
14 import javax.swing.JLabel;
15 import javax.swing.JOptionPane;
16 import javax.swing.JPanel;
17 import javax.swing.JRadioButton;
18
19 public class HTMLOptions extends JPanel
20 {
21   JDialog dialog;
22
23   public boolean cancelled = false;
24
25   String value;
26
27   public HTMLOptions()
28   {
29     try
30     {
31       jbInit();
32     } catch (Exception ex)
33     {
34       ex.printStackTrace();
35     }
36
37     ButtonGroup bg = new ButtonGroup();
38     bg.add(lineart);
39     bg.add(text);
40
41     JOptionPane pane = new JOptionPane(null, JOptionPane.DEFAULT_OPTION,
42             JOptionPane.DEFAULT_OPTION, null, new Object[]
43             { this });
44
45     dialog = pane.createDialog(Desktop.desktop, "HTML Rendering options");
46     dialog.setVisible(true);
47
48   }
49
50   private void jbInit() throws Exception
51   {
52     lineart.setFont(JvSwingUtils.getLabelFont());
53     lineart.setText(MessageManager.getString("label.lineart"));
54     text.setFont(JvSwingUtils.getLabelFont());
55     text.setText(MessageManager.getString("action.text"));
56     text.setSelected(true);
57     askAgain.setFont(JvSwingUtils.getLabelFont());
58     askAgain.setText(MessageManager.getString("label.dont_ask_me_again"));
59     ok.setText(MessageManager.getString("action.ok"));
60     ok.addActionListener(new ActionListener()
61     {
62       public void actionPerformed(ActionEvent e)
63       {
64         ok_actionPerformed(e);
65       }
66     });
67     cancel.setText(MessageManager.getString("action.cancel"));
68     cancel.addActionListener(new ActionListener()
69     {
70       public void actionPerformed(ActionEvent e)
71       {
72         cancel_actionPerformed(e);
73       }
74     });
75     jLabel1.setFont(JvSwingUtils.getLabelFont());
76     jLabel1.setText("Select HTML character rendering style");
77     this.setLayout(borderLayout1);
78     jPanel3.setBorder(BorderFactory.createEtchedBorder());
79     jPanel2.add(text);
80     jPanel2.add(lineart);
81     jPanel2.add(askAgain);
82     jPanel1.add(ok);
83     jPanel1.add(cancel);
84     jPanel3.add(jLabel1);
85     jPanel3.add(jPanel2);
86     this.add(jPanel3, java.awt.BorderLayout.CENTER);
87     this.add(jPanel1, java.awt.BorderLayout.SOUTH);
88   }
89
90   JRadioButton lineart = new JRadioButton();
91
92   JRadioButton text = new JRadioButton();
93
94   JCheckBox askAgain = new JCheckBox();
95
96   JButton ok = new JButton();
97
98   JButton cancel = new JButton();
99
100   JPanel jPanel1 = new JPanel();
101
102   JLabel jLabel1 = new JLabel();
103
104   JPanel jPanel2 = new JPanel();
105
106   JPanel jPanel3 = new JPanel();
107
108   BorderLayout borderLayout1 = new BorderLayout();
109
110   public void ok_actionPerformed(ActionEvent e)
111   {
112     if (lineart.isSelected())
113     {
114       value = "Lineart";
115     }
116     else
117     {
118       value = "Text";
119     }
120
121     if (!askAgain.isSelected())
122     {
123       jalview.bin.Cache.applicationProperties.remove("HTML_RENDERING");
124     }
125     else
126     {
127       jalview.bin.Cache.setProperty("HTML_RENDERING", value);
128     }
129
130     dialog.setVisible(false);
131   }
132
133   public void cancel_actionPerformed(ActionEvent e)
134   {
135     cancelled = true;
136     dialog.setVisible(false);
137   }
138
139   public String getValue()
140   {
141     return value;
142   }
143 }