/* * 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.change.store.ChangeSetMode; import javax.swing.ComboBoxModel; import javax.swing.DefaultComboBoxModel; import javax.swing.JPanel; /** * * @author tveki */ public class ChangesetModeChooserPanel extends JPanel { private ChangeSetMode changeSetMode; private ComboBoxModel changeSetModes; /** * Creates new form SaveChangelogVisualPanel1 */ public ChangesetModeChooserPanel() { initComponents(); initWithDefaultChangesetMode(); } private void initWithDefaultChangesetMode(){ for (int i=0; i < getChangeSetModes().getSize(); i++){ if (ChangeSetMode.SEPARATE_FOR_EACH.equals(getChangeSetModes().getElementAt(i))){ changesetModeCombo.setSelectedIndex(i); break; } } } @Override public String getName() { return "Select changeset mode"; } public ChangeSetMode getChangeSetMode(){ return changeSetMode; } private ComboBoxModel getChangeSetModes(){ if (changeSetModes == null){ changeSetModes = new DefaultComboBoxModel(ChangeSetMode.values()); } return changeSetModes; } /** * 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. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { changesetModeLabel = new javax.swing.JLabel(); changesetModeCombo = new javax.swing.JComboBox(); changesetModeLabel.setText(org.openide.util.NbBundle.getMessage(ChangesetModeChooserPanel.class, "ChangesetModeChooserPanel.changesetModeLabel.text")); // NOI18N changesetModeCombo.setModel(getChangeSetModes()); changesetModeCombo.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { onChangeSetModeChange(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(changesetModeLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(changesetModeCombo, javax.swing.GroupLayout.PREFERRED_SIZE, 463, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(64, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(83, 83, 83) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(changesetModeLabel) .addComponent(changesetModeCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(456, Short.MAX_VALUE)) ); }// </editor-fold>//GEN-END:initComponents private void onChangeSetModeChange(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onChangeSetModeChange if (changesetModeCombo.getSelectedIndex() >= 0){ changeSetMode = (ChangeSetMode) changeSetModes.getElementAt(changesetModeCombo.getSelectedIndex()); System.out.format("changeSetMode=%s%n", changeSetMode); } else { changeSetMode = null; } }//GEN-LAST:event_onChangeSetModeChange // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JComboBox changesetModeCombo; private javax.swing.JLabel changesetModeLabel; // End of variables declaration//GEN-END:variables }