001: /*
002: * Copyright (C) 2005 - 2008 JasperSoft Corporation. All rights reserved.
003: * http://www.jaspersoft.com.
004: *
005: * Unless you have purchased a commercial license agreement from JasperSoft,
006: * the following license terms apply:
007: *
008: * This program is free software; you can redistribute it and/or modify
009: * it under the terms of the GNU General Public License version 2 as published by
010: * the Free Software Foundation.
011: *
012: * This program is distributed WITHOUT ANY WARRANTY; and without the
013: * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
014: * See the GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
018: * or write to:
019: *
020: * Free Software Foundation, Inc.,
021: * 59 Temple Place - Suite 330,
022: * Boston, MA USA 02111-1307
023: *
024: *
025: *
026: *
027: * MassiveCompilerFrame.java
028: *
029: * Created on 19 maggio 2004, 6.16
030: *
031: */
032:
033: package it.businesslogic.ireport.plugin.massivecompiler;
034:
035: import it.businesslogic.ireport.plugin.*;
036: import javax.swing.table.*;
037: import javax.swing.*;
038: import javax.swing.event.ListSelectionEvent;
039: import it.businesslogic.ireport.util.I18n;
040:
041: /**
042: *
043: * @author Administrator
044: */
045: public class MassiveCompilerFrame extends javax.swing.JFrame {
046:
047: private FindThread findThread = null;
048: private CompileThread compileThread = null;
049: private boolean finding = false;
050: private boolean compiling = false;
051: private it.businesslogic.ireport.gui.MainFrame iReportMainFrame = null;
052:
053: /** Creates new form MassiveCompilationFrame */
054: public MassiveCompilerFrame() {
055: initComponents();
056:
057: this .setSize(550, 380);
058: it.businesslogic.ireport.util.Misc.centerFrame(this );
059: // Adjust table columns...
060: DefaultTableColumnModel dtcm = (DefaultTableColumnModel) this .jTableFiles
061: .getColumnModel();
062:
063: jTableFiles.getColumnModel().getColumn(0).setCellRenderer(
064: new ImageCellRenderer());
065:
066: jTableFiles.setRowHeight(18);
067: dtcm.getColumn(0).setWidth(18);
068: dtcm.getColumn(1).setWidth(300);
069: dtcm.getColumn(2).setWidth(50);
070:
071: dtcm.getColumn(0).setPreferredWidth(18);
072: dtcm.getColumn(1).setPreferredWidth(300);
073: dtcm.getColumn(2).setPreferredWidth(50);
074:
075: dtcm.getColumn(0).setMinWidth(18);
076: dtcm.getColumn(0).setMaxWidth(18);
077: //dtcm.getColumn(2).setMinWidth(300);
078: //dtcm.getColumn(3).setMinWidth(50);
079:
080: DefaultListSelectionModel dlsm = (DefaultListSelectionModel) this .jTableFiles
081: .getSelectionModel();
082: dlsm
083: .addListSelectionListener(new javax.swing.event.ListSelectionListener() {
084: public void valueChanged(ListSelectionEvent e) {
085: jTableFilesListSelectionValueChanged(e);
086: }
087: });
088:
089: applyI18n();
090: }
091:
092: /** This method is called from within the constructor to
093: * initialize the form.
094: * WARNING: Do NOT modify this code. The content of this method is
095: * always regenerated by the Form Editor.
096: */
097: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
098: private void initComponents() {
099: java.awt.GridBagConstraints gridBagConstraints;
100:
101: jPopupMenuFiles = new javax.swing.JPopupMenu();
102: jMenuItemDetails = new javax.swing.JMenuItem();
103: jMenuItemOpen = new javax.swing.JMenuItem();
104: jMenuItemViewSource = new javax.swing.JMenuItem();
105: jPanel1 = new javax.swing.JPanel();
106: jTextFieldPath = new javax.swing.JTextField();
107: jButtonBrowse = new javax.swing.JButton();
108: jCheckBoxSubDir = new javax.swing.JCheckBox();
109: jScrollPane1 = new javax.swing.JScrollPane();
110: jTableFiles = new javax.swing.JTable();
111: jPanel2 = new javax.swing.JPanel();
112: jButtonClose = new javax.swing.JButton();
113: jPanel4 = new javax.swing.JPanel();
114: jCheckBoxChangeFileExt = new javax.swing.JCheckBox();
115: jCheckBoxBackup = new javax.swing.JCheckBox();
116: jCheckBoxDirectory = new javax.swing.JCheckBox();
117: jPanel5 = new javax.swing.JPanel();
118: jButtonCompile = new javax.swing.JButton();
119: jButtonCancelCompile = new javax.swing.JButton();
120: jButtonCompileAll = new javax.swing.JButton();
121: jPanel6 = new javax.swing.JPanel();
122: jPanel3 = new javax.swing.JPanel();
123: jButtonFind = new javax.swing.JButton();
124: jButtonCancelFind = new javax.swing.JButton();
125:
126: jMenuItemDetails.setText("Details and error messages");
127: jMenuItemDetails
128: .addActionListener(new java.awt.event.ActionListener() {
129: public void actionPerformed(
130: java.awt.event.ActionEvent evt) {
131: jMenuItemDetailsActionPerformed(evt);
132: }
133: });
134:
135: jPopupMenuFiles.add(jMenuItemDetails);
136:
137: jMenuItemOpen.setText("Send to editor");
138: jMenuItemOpen
139: .addActionListener(new java.awt.event.ActionListener() {
140: public void actionPerformed(
141: java.awt.event.ActionEvent evt) {
142: jMenuItemOpenActionPerformed(evt);
143: }
144: });
145:
146: jPopupMenuFiles.add(jMenuItemOpen);
147:
148: jMenuItemViewSource.setText("View source");
149: jMenuItemViewSource
150: .addActionListener(new java.awt.event.ActionListener() {
151: public void actionPerformed(
152: java.awt.event.ActionEvent evt) {
153: jMenuItemViewSourceActionPerformed(evt);
154: }
155: });
156:
157: jPopupMenuFiles.add(jMenuItemViewSource);
158:
159: getContentPane().setLayout(new java.awt.GridBagLayout());
160:
161: setTitle("Massive compiler");
162: addWindowListener(new java.awt.event.WindowAdapter() {
163: public void windowClosing(java.awt.event.WindowEvent evt) {
164: exitForm(evt);
165: }
166: });
167:
168: jPanel1.setLayout(new java.awt.GridBagLayout());
169:
170: jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(
171: javax.swing.BorderFactory.createEtchedBorder(),
172: "Directory"));
173: jPanel1.setMinimumSize(new java.awt.Dimension(0, 70));
174: jPanel1.setPreferredSize(new java.awt.Dimension(0, 70));
175: jTextFieldPath
176: .addActionListener(new java.awt.event.ActionListener() {
177: public void actionPerformed(
178: java.awt.event.ActionEvent evt) {
179: jTextFieldPathActionPerformed(evt);
180: }
181: });
182:
183: gridBagConstraints = new java.awt.GridBagConstraints();
184: gridBagConstraints.gridx = 0;
185: gridBagConstraints.gridy = 1;
186: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
187: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
188: gridBagConstraints.weightx = 1.0;
189: gridBagConstraints.insets = new java.awt.Insets(0, 2, 0, 2);
190: jPanel1.add(jTextFieldPath, gridBagConstraints);
191:
192: jButtonBrowse.setText("Browse...");
193: jButtonBrowse.setMinimumSize(new java.awt.Dimension(87, 20));
194: jButtonBrowse.setPreferredSize(new java.awt.Dimension(87, 20));
195: jButtonBrowse
196: .addActionListener(new java.awt.event.ActionListener() {
197: public void actionPerformed(
198: java.awt.event.ActionEvent evt) {
199: jButtonBrowseActionPerformed(evt);
200: }
201: });
202:
203: gridBagConstraints = new java.awt.GridBagConstraints();
204: gridBagConstraints.gridx = 1;
205: gridBagConstraints.gridy = 0;
206: gridBagConstraints.gridheight = 2;
207: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
208: jPanel1.add(jButtonBrowse, gridBagConstraints);
209:
210: jCheckBoxSubDir.setText("Search Sub Directories");
211: gridBagConstraints = new java.awt.GridBagConstraints();
212: gridBagConstraints.gridx = 0;
213: gridBagConstraints.gridy = 2;
214: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
215: jPanel1.add(jCheckBoxSubDir, gridBagConstraints);
216:
217: gridBagConstraints = new java.awt.GridBagConstraints();
218: gridBagConstraints.gridx = 0;
219: gridBagConstraints.gridy = 0;
220: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
221: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
222: gridBagConstraints.weightx = 1.0;
223: gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
224: getContentPane().add(jPanel1, gridBagConstraints);
225:
226: jTableFiles.setModel(new javax.swing.table.DefaultTableModel(
227: new Object[][] {
228:
229: }, new String[] { "", "File", "Status" }) {
230: boolean[] canEdit = new boolean[] { false, false, false };
231:
232: public boolean isCellEditable(int rowIndex, int columnIndex) {
233: return canEdit[columnIndex];
234: }
235: });
236: jTableFiles.addMouseListener(new java.awt.event.MouseAdapter() {
237: public void mouseClicked(java.awt.event.MouseEvent evt) {
238: jTableFilesMouseClicked(evt);
239: }
240: });
241:
242: jScrollPane1.setViewportView(jTableFiles);
243:
244: gridBagConstraints = new java.awt.GridBagConstraints();
245: gridBagConstraints.gridx = 0;
246: gridBagConstraints.gridy = 1;
247: gridBagConstraints.gridwidth = 2;
248: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
249: gridBagConstraints.weightx = 1.0;
250: gridBagConstraints.weighty = 1.0;
251: gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 4);
252: getContentPane().add(jScrollPane1, gridBagConstraints);
253:
254: jPanel2.setLayout(new java.awt.GridBagLayout());
255:
256: jPanel2.setMinimumSize(new java.awt.Dimension(0, 125));
257: jPanel2.setPreferredSize(new java.awt.Dimension(0, 125));
258: jButtonClose.setText("Close");
259: jButtonClose
260: .addActionListener(new java.awt.event.ActionListener() {
261: public void actionPerformed(
262: java.awt.event.ActionEvent evt) {
263: jButtonCloseActionPerformed(evt);
264: }
265: });
266:
267: gridBagConstraints = new java.awt.GridBagConstraints();
268: gridBagConstraints.gridx = 1;
269: gridBagConstraints.gridy = 1;
270: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
271: gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
272: gridBagConstraints.weightx = 0.2;
273: gridBagConstraints.insets = new java.awt.Insets(4, 0, 4, 4);
274: jPanel2.add(jButtonClose, gridBagConstraints);
275:
276: jPanel4.setLayout(new java.awt.GridBagLayout());
277:
278: jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(
279: javax.swing.BorderFactory.createEtchedBorder(),
280: "Options"));
281: jPanel4.setMinimumSize(new java.awt.Dimension(200, 80));
282: jPanel4.setPreferredSize(new java.awt.Dimension(200, 80));
283: jCheckBoxChangeFileExt
284: .setText("Change file extension to .jrxml");
285: gridBagConstraints = new java.awt.GridBagConstraints();
286: gridBagConstraints.gridx = 0;
287: gridBagConstraints.gridy = 0;
288: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
289: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
290: gridBagConstraints.weightx = 1.0;
291: jPanel4.add(jCheckBoxChangeFileExt, gridBagConstraints);
292:
293: jCheckBoxBackup.setText("Backup old compiled files");
294: gridBagConstraints = new java.awt.GridBagConstraints();
295: gridBagConstraints.gridx = 0;
296: gridBagConstraints.gridy = 1;
297: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
298: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
299: gridBagConstraints.weightx = 1.0;
300: jPanel4.add(jCheckBoxBackup, gridBagConstraints);
301:
302: jCheckBoxDirectory.setSelected(true);
303: jCheckBoxDirectory
304: .setLabel("Use the compilation directory set in the options window");
305: gridBagConstraints = new java.awt.GridBagConstraints();
306: gridBagConstraints.gridx = 0;
307: gridBagConstraints.gridy = 2;
308: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
309: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
310: gridBagConstraints.weightx = 1.0;
311: jPanel4.add(jCheckBoxDirectory, gridBagConstraints);
312:
313: gridBagConstraints = new java.awt.GridBagConstraints();
314: gridBagConstraints.gridx = 0;
315: gridBagConstraints.gridy = 0;
316: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
317: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
318: gridBagConstraints.weightx = 0.8;
319: gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 4);
320: jPanel2.add(jPanel4, gridBagConstraints);
321:
322: jPanel5.setLayout(new java.awt.GridBagLayout());
323:
324: jPanel5.setPreferredSize(new java.awt.Dimension(100, 10));
325: jButtonCompile.setText("Compile selected file(s)");
326: jButtonCompile.setEnabled(false);
327: jButtonCompile
328: .addActionListener(new java.awt.event.ActionListener() {
329: public void actionPerformed(
330: java.awt.event.ActionEvent evt) {
331: jButtonCompileActionPerformed(evt);
332: }
333: });
334:
335: gridBagConstraints = new java.awt.GridBagConstraints();
336: gridBagConstraints.gridx = 0;
337: gridBagConstraints.gridy = 0;
338: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
339: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
340: gridBagConstraints.weightx = 1.0;
341: gridBagConstraints.insets = new java.awt.Insets(4, 0, 0, 0);
342: jPanel5.add(jButtonCompile, gridBagConstraints);
343:
344: jButtonCancelCompile.setText("Cancel");
345: jButtonCancelCompile.setEnabled(false);
346: jButtonCancelCompile
347: .addActionListener(new java.awt.event.ActionListener() {
348: public void actionPerformed(
349: java.awt.event.ActionEvent evt) {
350: jButtonCancelCompileActionPerformed(evt);
351: }
352: });
353:
354: gridBagConstraints = new java.awt.GridBagConstraints();
355: gridBagConstraints.gridx = 0;
356: gridBagConstraints.gridy = 2;
357: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
358: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
359: gridBagConstraints.weightx = 1.0;
360: jPanel5.add(jButtonCancelCompile, gridBagConstraints);
361:
362: jButtonCompileAll.setText("Compile All");
363: jButtonCompileAll.setEnabled(false);
364: jButtonCompileAll
365: .addActionListener(new java.awt.event.ActionListener() {
366: public void actionPerformed(
367: java.awt.event.ActionEvent evt) {
368: jButtonCompileAllActionPerformed(evt);
369: }
370: });
371:
372: gridBagConstraints = new java.awt.GridBagConstraints();
373: gridBagConstraints.gridx = 0;
374: gridBagConstraints.gridy = 1;
375: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
376: gridBagConstraints.weightx = 1.0;
377: jPanel5.add(jButtonCompileAll, gridBagConstraints);
378:
379: gridBagConstraints = new java.awt.GridBagConstraints();
380: gridBagConstraints.gridx = 0;
381: gridBagConstraints.gridy = 3;
382: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
383: gridBagConstraints.weighty = 1.0;
384: jPanel5.add(jPanel6, gridBagConstraints);
385:
386: gridBagConstraints = new java.awt.GridBagConstraints();
387: gridBagConstraints.gridx = 1;
388: gridBagConstraints.gridy = 0;
389: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
390: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
391: gridBagConstraints.weightx = 0.2;
392: gridBagConstraints.weighty = 1.0;
393: gridBagConstraints.insets = new java.awt.Insets(4, 0, 0, 4);
394: jPanel2.add(jPanel5, gridBagConstraints);
395:
396: gridBagConstraints = new java.awt.GridBagConstraints();
397: gridBagConstraints.gridx = 0;
398: gridBagConstraints.gridy = 2;
399: gridBagConstraints.gridwidth = 2;
400: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
401: getContentPane().add(jPanel2, gridBagConstraints);
402:
403: jPanel3.setLayout(new java.awt.GridBagLayout());
404:
405: jPanel3.setMinimumSize(new java.awt.Dimension(100, 10));
406: jPanel3.setPreferredSize(new java.awt.Dimension(100, 10));
407: jButtonFind.setText("Find");
408: jButtonFind
409: .addActionListener(new java.awt.event.ActionListener() {
410: public void actionPerformed(
411: java.awt.event.ActionEvent evt) {
412: jButtonFindActionPerformed(evt);
413: }
414: });
415:
416: gridBagConstraints = new java.awt.GridBagConstraints();
417: gridBagConstraints.gridx = 0;
418: gridBagConstraints.gridy = 0;
419: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
420: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
421: gridBagConstraints.weightx = 1.0;
422: jPanel3.add(jButtonFind, gridBagConstraints);
423:
424: jButtonCancelFind.setText("Cancel");
425: jButtonCancelFind.setEnabled(false);
426: jButtonCancelFind
427: .addActionListener(new java.awt.event.ActionListener() {
428: public void actionPerformed(
429: java.awt.event.ActionEvent evt) {
430: jButtonCancelFindActionPerformed(evt);
431: }
432: });
433:
434: gridBagConstraints = new java.awt.GridBagConstraints();
435: gridBagConstraints.gridx = 0;
436: gridBagConstraints.gridy = 1;
437: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
438: gridBagConstraints.insets = new java.awt.Insets(2, 0, 0, 0);
439: jPanel3.add(jButtonCancelFind, gridBagConstraints);
440:
441: gridBagConstraints = new java.awt.GridBagConstraints();
442: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
443: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
444: gridBagConstraints.insets = new java.awt.Insets(4, 0, 4, 4);
445: getContentPane().add(jPanel3, gridBagConstraints);
446:
447: pack();
448: }// </editor-fold>//GEN-END:initComponents
449:
450: private void jMenuItemViewSourceActionPerformed(
451: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemViewSourceActionPerformed
452: if (iReportMainFrame == null)
453: return;
454: if (jTableFiles.getSelectedRowCount() != 0) {
455: Runtime rt = Runtime.getRuntime();
456: String editor = "notepad.exe";
457: try {
458: if (iReportMainFrame.getProperties().getProperty(
459: "ExternalEditor") != null)
460: editor = (String) iReportMainFrame.getProperties()
461: .getProperty("ExternalEditor");
462: if (editor == null || editor.equals("")) {
463: iReportMainFrame.logOnConsole(I18n.getString(
464: "messages.useNotepad",
465: "Using notepad.exe as default editor!\n"),
466: false);
467: editor = "notepad.exe";
468: }
469:
470: rt.exec(editor
471: + " \""
472: + ((FileEntry) this .jTableFiles.getValueAt(
473: jTableFiles.getSelectedRow(), 0))
474: .getFile().getCanonicalPath() + "\"");
475: } catch (Exception ex) {
476:
477: javax.swing.JOptionPane
478: .showMessageDialog(
479: this ,
480: I18n
481: .getFormattedString(
482: "messages.errorExecutingEditor",
483: "An exception is occured executing:\n{0} \"{1}\"",
484: new Object[] {
485: editor,
486: ""
487: + ((FileEntry) this .jTableFiles
488: .getValueAt(
489: jTableFiles
490: .getSelectedRow(),
491: 0))
492: .getFile() }),
493: "",
494: javax.swing.JOptionPane.ERROR_MESSAGE);
495: }
496: }
497: }//GEN-LAST:event_jMenuItemViewSourceActionPerformed
498:
499: private void jMenuItemOpenActionPerformed(
500: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemOpenActionPerformed
501: if (iReportMainFrame == null)
502: return;
503: if (jTableFiles.getSelectedRowCount() != 0) {
504: iReportMainFrame.openFile(((FileEntry) this .jTableFiles
505: .getValueAt(jTableFiles.getSelectedRow(), 0))
506: .getFile());
507: }
508: }//GEN-LAST:event_jMenuItemOpenActionPerformed
509:
510: private void jMenuItemDetailsActionPerformed(
511: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemDetailsActionPerformed
512: if (jTableFiles.getSelectedRowCount() != 0) {
513: FileDetails fd = new FileDetails(this , true);
514: fd.setFileEntry((FileEntry) this .jTableFiles.getValueAt(
515: jTableFiles.getSelectedRow(), 0));
516: fd.setVisible(true);
517: }
518: }//GEN-LAST:event_jMenuItemDetailsActionPerformed
519:
520: private void jTableFilesMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableFilesMouseClicked
521: if (evt.getButton() == evt.BUTTON1 && evt.getClickCount() == 2) {
522: if (jTableFiles.getSelectedRowCount() != 0) {
523: FileDetails fd = new FileDetails(this , true);
524: fd.setFileEntry((FileEntry) this .jTableFiles
525: .getValueAt(jTableFiles.getSelectedRow(), 0));
526: fd.setVisible(true);
527: }
528: } else if (evt.getButton() == evt.BUTTON3
529: && evt.getClickCount() == 1) {
530: this .jPopupMenuFiles.show(jTableFiles, evt.getPoint().x,
531: evt.getPoint().y);
532: }
533: }//GEN-LAST:event_jTableFilesMouseClicked
534:
535: private void jButtonCompileAllActionPerformed(
536: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCompileAllActionPerformed
537: // Retrive data for compilation...
538:
539: compileThread = new CompileThread(this );
540: compileThread.setCompileSelectedOnly(false);
541: startCompiling();
542: compileThread.start();
543: }//GEN-LAST:event_jButtonCompileAllActionPerformed
544:
545: private void jButtonCancelCompileActionPerformed(
546: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelCompileActionPerformed
547: compileThread.stop();
548: finishedCompiling();
549: }//GEN-LAST:event_jButtonCancelCompileActionPerformed
550:
551: private void jButtonCompileActionPerformed(
552: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCompileActionPerformed
553:
554: // Retrive data for compilation...
555:
556: compileThread = new CompileThread(this );
557: compileThread.setCompileSelectedOnly(true);
558: startCompiling();
559: compileThread.start();
560:
561: }//GEN-LAST:event_jButtonCompileActionPerformed
562:
563: private void jButtonCloseActionPerformed(
564: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCloseActionPerformed
565: this .setVisible(false);
566: }//GEN-LAST:event_jButtonCloseActionPerformed
567:
568: private void jButtonCancelFindActionPerformed(
569: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelFindActionPerformed
570:
571: findThread.stop();
572: finishedFind();
573:
574: }//GEN-LAST:event_jButtonCancelFindActionPerformed
575:
576: private void jButtonFindActionPerformed(
577: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonFindActionPerformed
578:
579: if (jTextFieldPath.getText().length() == 0) {
580: JOptionPane.showMessageDialog(this , I18n.getString(
581: "messages.massiveCompilerFrame.noDir",
582: "Please select a directory."), I18n.getString(
583: "messages.massiveCompilerFrame.noDirCaption",
584: "No dir..."), JOptionPane.WARNING_MESSAGE);
585: return;
586: }
587: findThread = new FindThread(this );
588: startFind();
589: findThread.start();
590:
591: }//GEN-LAST:event_jButtonFindActionPerformed
592:
593: private void jButtonBrowseActionPerformed(
594: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBrowseActionPerformed
595:
596: // Select a directory...
597: JFileChooser jfc = new JFileChooser();
598: jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
599: if (jfc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
600: jTextFieldPath.setText(jfc.getSelectedFile().getPath());
601: }
602:
603: }//GEN-LAST:event_jButtonBrowseActionPerformed
604:
605: private void jTextFieldPathActionPerformed(
606: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldPathActionPerformed
607: // Add your handling code here:
608: }//GEN-LAST:event_jTextFieldPathActionPerformed
609:
610: /** Exit the Application */
611: private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
612: this .setVisible(false);
613: }//GEN-LAST:event_exitForm
614:
615: /**
616: * @param args the command line arguments
617: */
618: public static void main(String args[]) {
619: new MassiveCompilerFrame().setVisible(true);
620: }
621:
622: // Variables declaration - do not modify//GEN-BEGIN:variables
623: private javax.swing.JButton jButtonBrowse;
624: private javax.swing.JButton jButtonCancelCompile;
625: private javax.swing.JButton jButtonCancelFind;
626: private javax.swing.JButton jButtonClose;
627: private javax.swing.JButton jButtonCompile;
628: private javax.swing.JButton jButtonCompileAll;
629: private javax.swing.JButton jButtonFind;
630: private javax.swing.JCheckBox jCheckBoxBackup;
631: private javax.swing.JCheckBox jCheckBoxChangeFileExt;
632: private javax.swing.JCheckBox jCheckBoxDirectory;
633: private javax.swing.JCheckBox jCheckBoxSubDir;
634: private javax.swing.JMenuItem jMenuItemDetails;
635: private javax.swing.JMenuItem jMenuItemOpen;
636: private javax.swing.JMenuItem jMenuItemViewSource;
637: private javax.swing.JPanel jPanel1;
638: private javax.swing.JPanel jPanel2;
639: private javax.swing.JPanel jPanel3;
640: private javax.swing.JPanel jPanel4;
641: private javax.swing.JPanel jPanel5;
642: private javax.swing.JPanel jPanel6;
643: private javax.swing.JPopupMenu jPopupMenuFiles;
644: private javax.swing.JScrollPane jScrollPane1;
645: private javax.swing.JTable jTableFiles;
646: private javax.swing.JTextField jTextFieldPath;
647:
648: // End of variables declaration//GEN-END:variables
649:
650: public javax.swing.JTable getFileTable() {
651: return jTableFiles;
652: }
653:
654: public String getFindDirectory() {
655: return jTextFieldPath.getText();
656: }
657:
658: public boolean isSearchSubDirectory() {
659: return jCheckBoxSubDir.isSelected();
660: }
661:
662: public boolean isSelectedChangeFileExt() {
663: return jCheckBoxChangeFileExt.isSelected();
664: }
665:
666: public boolean isSelectedBackup() {
667: return jCheckBoxBackup.isSelected();
668: }
669:
670: public boolean isSelectedOptionsCompileDir() {
671: return jCheckBoxDirectory.isSelected();
672: }
673:
674: public void finishedFind() {
675: finding = false;
676: this .jButtonCancelFind.setEnabled(false);
677: this .jButtonFind.setEnabled(true);
678: this .jButtonClose.setEnabled(true);
679: this .jCheckBoxSubDir.setEnabled(true);
680: this .jTextFieldPath.setEditable(true);
681:
682: if (this .jTableFiles.getRowCount() > 0) {
683: this .jButtonCompileAll.setEnabled(true);
684: jTableFilesListSelectionValueChanged(new ListSelectionEvent(
685: this , 0, 0, false));
686: } else {
687: this .jButtonCompileAll.setEnabled(false);
688: }
689:
690: }
691:
692: public void startFind() {
693: finding = true;
694: this .jButtonCancelFind.setEnabled(true);
695: this .jButtonFind.setEnabled(false);
696:
697: this .jButtonCompileAll.setEnabled(false);
698: this .jButtonCompile.setEnabled(false);
699: this .jButtonClose.setEnabled(false);
700: this .jCheckBoxSubDir.setEnabled(false);
701: this .jTextFieldPath.setEditable(false);
702:
703: }
704:
705: public void finishedCompiling() {
706: compiling = false;
707: this .jButtonCancelCompile.setEnabled(false);
708: this .jButtonFind.setEnabled(true);
709: this .jButtonClose.setEnabled(true);
710: this .jCheckBoxBackup.setEnabled(true);
711: this .jCheckBoxChangeFileExt.setEnabled(true);
712:
713: if (this .jTableFiles.getRowCount() > 0) {
714: this .jButtonCompileAll.setEnabled(true);
715: jTableFilesListSelectionValueChanged(new ListSelectionEvent(
716: this , 0, 0, false));
717: } else {
718: this .jButtonCompileAll.setEnabled(false);
719: }
720: }
721:
722: public void startCompiling() {
723: compiling = true;
724: this .jButtonCancelCompile.setEnabled(false);
725: this .jButtonFind.setEnabled(false);
726:
727: this .jButtonCompileAll.setEnabled(false);
728: this .jButtonCompile.setEnabled(false);
729: this .jButtonClose.setEnabled(false);
730: this .jCheckBoxBackup.setEnabled(false);
731: this .jCheckBoxChangeFileExt.setEnabled(false);
732: }
733:
734: public void jTableFilesListSelectionValueChanged(
735: ListSelectionEvent e) {
736: if (finding)
737: return;
738: if (this .jTableFiles.getSelectedRowCount() > 0) {
739: this .jButtonCompile.setEnabled(true);
740: } else {
741: this .jButtonCompile.setEnabled(false);
742: }
743: }
744:
745: /** Getter for property iReportMainFrame.
746: * @return Value of property iReportMainFrame.
747: *
748: */
749: public it.businesslogic.ireport.gui.MainFrame getIReportMainFrame() {
750: return iReportMainFrame;
751: }
752:
753: /** Setter for property iReportMainFrame.
754: * @param iReportMainFrame New value of property iReportMainFrame.
755: *
756: */
757: public void setIReportMainFrame(
758: it.businesslogic.ireport.gui.MainFrame iReportMainFrame) {
759: this .iReportMainFrame = iReportMainFrame;
760: }
761:
762: public void applyI18n() {
763: // Start autogenerated code ----------------------
764: jMenuItemDetails.setText(I18n.getString(
765: "massiveCompilerFrame.menuItemDetails",
766: "Details and error messages"));
767: jMenuItemOpen.setText(I18n.getString(
768: "massiveCompilerFrame.menuItemOpen", "Send to editor"));
769: jMenuItemViewSource.setText(I18n.getString(
770: "massiveCompilerFrame.menuItemViewSource",
771: "View source"));
772: // End autogenerated code ----------------------
773: // Start autogenerated code ----------------------
774: jCheckBoxBackup.setText(I18n.getString(
775: "massiveCompilerFrame.checkBoxBackup",
776: "Backup old compiled files"));
777: jCheckBoxChangeFileExt.setText(I18n.getString(
778: "massiveCompilerFrame.checkBoxChangeFileExt",
779: "Change file extension to .jrxml"));
780: jCheckBoxSubDir.setText(I18n.getString(
781: "massiveCompilerFrame.checkBoxSubDir",
782: "Search Sub Directories"));
783: // End autogenerated code ----------------------
784: // Start autogenerated code ----------------------
785: jButtonBrowse.setText(I18n.getString(
786: "massiveCompilerFrame.buttonBrowse", "Browse..."));
787: jButtonCancelCompile.setText(I18n.getString(
788: "massiveCompilerFrame.buttonCancelCompile", "Cancel"));
789: jButtonCancelFind.setText(I18n.getString(
790: "massiveCompilerFrame.buttonCancelFind", "Cancel"));
791: jButtonClose.setText(I18n.getString(
792: "massiveCompilerFrame.buttonClose", "Close"));
793: jButtonCompile.setText(I18n.getString(
794: "massiveCompilerFrame.buttonCompile",
795: "Compile selected file(s)"));
796: jButtonCompileAll
797: .setText(I18n.getString(
798: "massiveCompilerFrame.buttonCompileAll",
799: "Compile All"));
800: jButtonFind.setText(I18n.getString(
801: "massiveCompilerFrame.buttonFind", "Find"));
802: // End autogenerated code ----------------------
803:
804: jTableFiles.getColumnModel().getColumn(1).setHeaderValue(
805: I18n.getString("massiveCompilerFrame.tablecolumn.file",
806: "File"));
807: jTableFiles.getColumnModel().getColumn(2).setHeaderValue(
808: I18n.getString(
809: "massiveCompilerFrame.tablecolumn.status",
810: "Status"));
811:
812: ((javax.swing.border.TitledBorder) jPanel1.getBorder())
813: .setTitle(I18n.getString(
814: "massiveCompilerFrame.panelBorder.Directory",
815: "Directory"));
816: ((javax.swing.border.TitledBorder) jPanel4.getBorder())
817: .setTitle(I18n.getString(
818: "massiveCompilerFrame.panelBorder.Options",
819: "Options"));
820:
821: this .setTitle(I18n.getString("massiveCompilerFrame.title",
822: "Massive compiler"));
823:
824: }
825: }
|