/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package com.wcs.netbeans.liquiface.ui.wizards.panel; /* * #%L * Liquiface - GUI for Liquibase * %% * Copyright (C) 2013 Webstar Csoport Kft. * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% */ import com.wcs.netbeans.liquiface.ui.wizards.XmlFilter; import java.io.File; import javax.swing.JFileChooser; import javax.swing.JPanel; import org.openide.filesystems.FileChooserBuilder; public class ChangelogFileChooserPanel extends JPanel { private File changelogFile; /** * Creates new form LoadChangeLogFileVisualPanel1 */ public ChangelogFileChooserPanel() { initComponents(); } public File getChangelogFile(){ return changelogFile; } @Override public String getName() { return "Choose changelog file"; } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { changelogFileLabel = new javax.swing.JLabel(); changelogFileNameField = new javax.swing.JTextField(); browseButton = new javax.swing.JButton(); org.openide.awt.Mnemonics.setLocalizedText(changelogFileLabel, org.openide.util.NbBundle.getMessage(ChangelogFileChooserPanel.class, "ChangelogFileChooserPanel.changelogFileLabel.text")); // NOI18N changelogFileNameField.setEditable(false); changelogFileNameField.setText(org.openide.util.NbBundle.getMessage(ChangelogFileChooserPanel.class, "ChangelogFileChooserPanel.changelogFileNameField.text")); // NOI18N changelogFileNameField.setToolTipText(org.openide.util.NbBundle.getMessage(ChangelogFileChooserPanel.class, "ChangelogFileChooserPanel.changelogFileNameField.toolTipText")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(browseButton, org.openide.util.NbBundle.getMessage(ChangelogFileChooserPanel.class, "ChangelogFileChooserPanel.browseButton.text")); // NOI18N browseButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { onBrowse(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(changelogFileLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(changelogFileNameField, javax.swing.GroupLayout.PREFERRED_SIZE, 545, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(browseButton) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(82, 82, 82) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(changelogFileLabel) .addComponent(changelogFileNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(browseButton)) .addContainerGap(281, Short.MAX_VALUE)) ); }// </editor-fold>//GEN-END:initComponents private void onBrowse(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onBrowse FileChooserBuilder fcb = new FileChooserBuilder(ChangelogFileChooserPanel.class); JFileChooser fc = fcb.createFileChooser(); fc.setFileFilter(new XmlFilter()); if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION){ changelogFile = fc.getSelectedFile(); changelogFileNameField.setText(changelogFile.getAbsolutePath()); } }//GEN-LAST:event_onBrowse // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton browseButton; private javax.swing.JLabel changelogFileLabel; private javax.swing.JTextField changelogFileNameField; // End of variables declaration//GEN-END:variables }