1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
package net.sf.jabref.wizard.integrity.gui ; |
36 | |
|
37 | |
import java.awt.*; |
38 | |
import java.awt.event.ActionEvent; |
39 | |
import java.awt.event.ActionListener; |
40 | |
import java.io.IOException; |
41 | |
import java.net.URL; |
42 | |
|
43 | |
import javax.swing.*; |
44 | |
import javax.swing.border.EtchedBorder; |
45 | |
|
46 | |
import net.sf.jabref.*; |
47 | |
|
48 | 82628 | public class IntegrityWizard extends JDialog implements ActionListener { |
49 | |
|
50 | |
private BibtexDatabase dbase ; |
51 | |
private BasePanel basePanel; |
52 | |
private JButton closeButton ; |
53 | |
private JButton startButton ; |
54 | |
private IntegrityMessagePanel warnPanel ; |
55 | |
|
56 | |
public IntegrityWizard( JabRefFrame frame, BasePanel basePanel) |
57 | |
{ |
58 | 325535 | super( frame, "dialog", false ) ; |
59 | |
|
60 | 325535 | this.basePanel = basePanel; |
61 | 325535 | dbase = basePanel.database(); |
62 | |
|
63 | |
try |
64 | |
{ |
65 | 325535 | jbInit() ; |
66 | 325535 | pack() ; |
67 | |
} |
68 | 0 | catch ( Exception ex ) |
69 | |
{ |
70 | 0 | ex.printStackTrace() ; |
71 | 325535 | } |
72 | 325535 | } |
73 | |
|
74 | |
private void jbInit() { |
75 | |
|
76 | 325535 | this.setResizable( false ) ; |
77 | |
|
78 | |
|
79 | 325535 | this.setTitle( Globals.lang("Integrity_check") ) ; |
80 | |
|
81 | |
|
82 | 325535 | warnPanel = new IntegrityMessagePanel(basePanel) ; |
83 | |
|
84 | |
|
85 | |
|
86 | 325535 | JPanel buttonPanel = new JPanel() ; |
87 | 325535 | GridBagLayout gbl = new GridBagLayout() ; |
88 | 325535 | GridBagConstraints con = new GridBagConstraints() ; |
89 | 325535 | con.weightx = 0 ; |
90 | 325535 | con.insets = new Insets( 5, 10, 0, 10 ) ; |
91 | 325535 | con.fill = GridBagConstraints.HORIZONTAL ; |
92 | |
|
93 | |
|
94 | 325535 | startButton = new JButton(Globals.lang("Scan")) ; |
95 | 325535 | startButton.addActionListener( this) ; |
96 | 325535 | closeButton = new JButton(Globals.lang("Close")); |
97 | 325535 | closeButton.addActionListener( this) ; |
98 | |
|
99 | |
|
100 | 325535 | con.gridwidth = GridBagConstraints.REMAINDER ; |
101 | 325535 | gbl.setConstraints( startButton, con ) ; |
102 | 325535 | buttonPanel.add( startButton ) ; |
103 | |
|
104 | 325535 | gbl.setConstraints( closeButton, con ) ; |
105 | 325535 | buttonPanel.add( closeButton ) ; |
106 | |
|
107 | |
|
108 | |
|
109 | |
|
110 | 325535 | JEditorPane infoText = null ; |
111 | |
|
112 | 325535 | URL infoURL = JabRef.class.getResource(GUIGlobals.getLocaleHelpPath() |
113 | |
+GUIGlobals.shortIntegrityCheck); |
114 | 325535 | if (infoURL != null) |
115 | |
try |
116 | |
{ |
117 | 325535 | infoText = new JEditorPane() ; |
118 | 325535 | infoText.setEditable(false); |
119 | 325535 | infoText.setPreferredSize( new Dimension(220, 60)); |
120 | 325535 | infoText.setMinimumSize( new Dimension(180, 50)); |
121 | 325535 | infoText.setPage(infoURL); |
122 | 325535 | infoText.setBackground(GUIGlobals.infoField); |
123 | 325535 | infoText.setBorder(new EtchedBorder(EtchedBorder.LOWERED)); |
124 | |
|
125 | |
} |
126 | 0 | catch (IOException e) |
127 | |
{ |
128 | 0 | infoText = null ; |
129 | 325535 | } |
130 | |
|
131 | |
|
132 | |
|
133 | |
|
134 | 325535 | Container content = this.getContentPane() ; |
135 | 325535 | content.setLayout( new BorderLayout()); |
136 | |
|
137 | 325535 | if (infoText != null) |
138 | |
{ |
139 | 325535 | content.add( infoText, BorderLayout.PAGE_START ) ; |
140 | |
} |
141 | 325535 | content.add(warnPanel, BorderLayout.CENTER) ; |
142 | 325535 | content.add(buttonPanel, BorderLayout.PAGE_END) ; |
143 | 325535 | } |
144 | |
|
145 | |
|
146 | |
|
147 | |
|
148 | |
|
149 | |
public void actionPerformed( ActionEvent e ) |
150 | |
{ |
151 | 193256 | Object sender = e.getSource() ; |
152 | |
|
153 | 193256 | if (sender == closeButton) |
154 | |
{ |
155 | 151942 | dispose() ; |
156 | |
} |
157 | 41314 | else if (sender == startButton) |
158 | |
{ |
159 | 41314 | startButton.setEnabled(false); |
160 | 41314 | Runnable scanWork = new Runnable() |
161 | 41314 | { |
162 | |
public void run() |
163 | |
{ |
164 | 41314 | warnPanel.updateView(dbase); |
165 | 41314 | } |
166 | |
} ; |
167 | 41314 | SwingUtilities.invokeLater(scanWork); |
168 | 41314 | startButton.setEnabled(true); |
169 | |
} |
170 | 193256 | } |
171 | |
|
172 | |
|
173 | |
|
174 | |
} |