3
* $Date: 2007-01-04 18:26:00 +0100 (Thu, 04 Jan 2007) $
6
* Copyright (C) 1997-2007 The JChemPaint project
8
* Contact: jchempaint-devel@lists.sf.net
10
* This program is free software; you can redistribute it and/or
11
* modify it under the terms of the GNU Lesser General Public License
12
* as published by the Free Software Foundation; either version 2.1
13
* of the License, or (at your option) any later version.
14
* All we ask is that proper credit is given for our work, which includes
15
* - but is not limited to - adding the above copyright notice to the beginning
16
* of your source code files, and to any copyright notice that you may distribute
17
* with programs based on this work.
19
* This program is distributed in the hope that it will be useful,
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
* GNU Lesser General Public License for more details.
24
* You should have received a copy of the GNU Lesser General Public License
25
* along with this program; if not, write to the Free Software
26
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
28
package org.openscience.cdk.applications.jchempaint.dialogs;
30
import java.awt.BorderLayout;
31
import java.awt.Color;
32
import java.awt.Dimension;
34
import javax.swing.BorderFactory;
35
import javax.swing.JEditorPane;
36
import javax.swing.JFrame;
37
import javax.swing.JScrollPane;
38
import javax.swing.JTextArea;
39
import javax.swing.border.Border;
41
import org.openscience.cdk.applications.jchempaint.JChemPaintEditorPanel;
42
import org.openscience.cdk.dict.DictionaryDatabase;
45
* Simple Dialog that shows the loaded dictionaries.
47
* @cdk.module jchempaint
49
public class DictionaryDialog extends JFrame {
51
private static final long serialVersionUID = -8933920987749316390L;
53
private JEditorPane infoPane;
56
* Displays the Info Dialog for JChemPaint.
58
public DictionaryDialog() {
59
super("Loaded Dictionaries");
68
private void createDialog(){
70
getContentPane().setLayout(new BorderLayout());
71
setBackground(Color.white);
73
Border lb = BorderFactory.createLineBorder(Color.white, 5);
74
JTextArea jtf1 = new JTextArea("Loaded Dictionaries");
76
jtf1.setEditable(false);
77
infoPane = new JEditorPane();
78
infoPane.setEditable(false);
79
infoPane.setBorder(lb);
80
infoPane.revalidate();
81
JScrollPane scrollPane = new JScrollPane(infoPane);
82
scrollPane.setPreferredSize(new Dimension(400, 350));
84
setTitle("Information");
85
getContentPane().add("Center",scrollPane);
86
getContentPane().add("North",jtf1);
89
private void displayContent() {
90
StringBuffer content = new StringBuffer();
91
content.append("<html>\n");
93
// convert Dictionary to HTML
94
DictionaryDatabase dictdb = JChemPaintEditorPanel.getDictionaryDatabase();
95
String[] dicts = dictdb.getDictionaryNames();
96
if (dicts.length > 0) {
97
content.append("<table>");
98
for (int i=0; i<dicts.length; i++) {
99
String[] entries = dictdb.getDictionaryEntries(dicts[i]);
100
for (int j=0; j<entries.length; j++) {
101
content.append("<tr>");
102
content.append("<td>" + dicts[i]);
103
content.append("<td>" + entries[j]);
104
content.append("</tr>\n");
107
content.append("</table>");
109
content.append("<p>No dictionaries are loaded.");
112
content.append("</html>\n");
114
infoPane.setContentType("text/html");
115
infoPane.setText(content.toString());
116
infoPane.revalidate();