1 /*- 2 * Copyright (C) 2007 Erik Larsson 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 package org.catacombae.hfsexplorer.gui; 19 20 import javax.swing.JDialog; 21 import java.awt.event.ActionListener; 22 23 /** 24 * @author <a href="http://www.catacombae.org/" target="_top">Erik Larsson</a> 25 */ 26 public class FileOperationsPanel extends javax.swing.JPanel { 27 28 /** Creates new form FileOperationsPanel */ FileOperationsPanel(JDialog dialog, String filename, long fileSize, ActionListener openListener, ActionListener saveListener)29 public FileOperationsPanel(JDialog dialog, String filename, long fileSize, 30 ActionListener openListener, 31 ActionListener saveListener) { 32 initComponents(); 33 filenameField.setText(filename); 34 sizeField.setText("" + fileSize + " bytes"); 35 if(openListener != null) { 36 openFileButton.addActionListener(openListener); 37 openFileButton.setEnabled(true); 38 dialog.getRootPane().setDefaultButton(openFileButton); 39 } 40 else { 41 dialog.getRootPane().setDefaultButton(saveFileButton); 42 } 43 saveFileButton.addActionListener(saveListener); 44 45 } 46 47 /** This method is called from within the constructor to 48 * initialize the form. 49 * WARNING: Do NOT modify this code. The content of this method is 50 * always regenerated by the Form Editor. 51 */ 52 // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents initComponents()53 private void initComponents() { 54 openFileButton = new javax.swing.JButton(); 55 saveFileButton = new javax.swing.JButton(); 56 jLabel1 = new javax.swing.JLabel(); 57 filenameField = new javax.swing.JTextField(); 58 jLabel2 = new javax.swing.JLabel(); 59 sizeField = new javax.swing.JTextField(); 60 61 openFileButton.setText("Open file"); 62 openFileButton.setToolTipText("Extracts the file to a temporary folder and\nopens it with the platform's default helper"); 63 openFileButton.setEnabled(false); 64 65 saveFileButton.setText("Save file to..."); 66 67 jLabel1.setText("Filename:"); 68 69 filenameField.setEditable(false); 70 filenameField.setText("jTextField1"); 71 filenameField.setBorder(null); 72 filenameField.setOpaque(false); 73 74 jLabel2.setText("Size:"); 75 76 sizeField.setEditable(false); 77 sizeField.setText("jTextField2"); 78 sizeField.setBorder(null); 79 sizeField.setOpaque(false); 80 81 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); 82 this.setLayout(layout); 83 layout.setHorizontalGroup( 84 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 85 .add(layout.createSequentialGroup() 86 .addContainerGap() 87 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 88 .add(layout.createSequentialGroup() 89 .add(openFileButton) 90 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 91 .add(saveFileButton)) 92 .add(layout.createSequentialGroup() 93 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 94 .add(jLabel1) 95 .add(jLabel2)) 96 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 97 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 98 .add(sizeField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 275, Short.MAX_VALUE) 99 .add(filenameField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 275, Short.MAX_VALUE)))) 100 .addContainerGap()) 101 ); 102 layout.setVerticalGroup( 103 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 104 .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() 105 .addContainerGap() 106 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 107 .add(jLabel1) 108 .add(filenameField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 109 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 110 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 111 .add(jLabel2) 112 .add(sizeField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 113 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 114 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 115 .add(openFileButton) 116 .add(saveFileButton)) 117 .addContainerGap()) 118 ); 119 }// </editor-fold>//GEN-END:initComponents 120 121 122 // Variables declaration - do not modify//GEN-BEGIN:variables 123 private javax.swing.JTextField filenameField; 124 private javax.swing.JLabel jLabel1; 125 private javax.swing.JLabel jLabel2; 126 private javax.swing.JButton openFileButton; 127 private javax.swing.JButton saveFileButton; 128 private javax.swing.JTextField sizeField; 129 // End of variables declaration//GEN-END:variables 130 131 } 132