/* * This file is part of the aidGer project. * * Copyright (C) 2010-2013 The aidGer Team * * 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/>. */ package de.aidger.view.wizard; import de.aidger.controller.ActionNotFoundException; import de.aidger.controller.ActionRegistry; import de.aidger.controller.actions.DatabaseSelectionFinishAction; import de.aidger.model.Runtime; import static de.aidger.utils.Translation._; import de.aidger.view.UI; import de.aidger.view.WizardPanel; import de.aidger.view.utils.MultiLineLabelUI; import javax.swing.AbstractAction; /** * * @author rmbl */ public class DatabaseSelection extends WizardPanel { /** Creates new form DatabaseSelection */ public DatabaseSelection() { initComponents(); try { setNextAction((AbstractAction) ActionRegistry.getInstance().get( DatabaseSelectionFinishAction.class.getName())); } catch (ActionNotFoundException ex) { UI.displayError(ex.getMessage()); } jLabel1.setUI(MultiLineLabelUI.labelUI); String sel = Runtime.getInstance().getOption("database-type"); if (sel != null && sel.equals("1")) { jRadioButton2.setSelected(true); } else if (sel != null && sel.equals("2")) { jRadioButton3.setSelected(true); } } @Override public void preparePanel() { return; } /** * Get the selected database. * * @return The index of the database */ public int getDBSelection() { return jRadioButton1.isSelected() ? 0 : (jRadioButton2.isSelected() ? 1 : 2); } /** 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() { buttonGroup1 = new javax.swing.ButtonGroup(); jLabel2 = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel(); jRadioButton1 = new javax.swing.JRadioButton(); jRadioButton2 = new javax.swing.JRadioButton(); jRadioButton3 = new javax.swing.JRadioButton(); setPreferredSize(new java.awt.Dimension(500, 300)); jLabel2.setFont(new java.awt.Font("DejaVu Sans", 0, 36)); jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/de/aidger/res/icons/aidger-icon.png"))); // NOI18N jLabel2.setText("aidGer"); jLabel1.setText(_("Select the type of database that you want to use.\nThe default value is a safe guess if you want to try aidGer or only plan to use it on one computer.")); jLabel1.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM); buttonGroup1.add(jRadioButton1); jRadioButton1.setSelected(true); jRadioButton1.setText(_("Derby Database")); buttonGroup1.add(jRadioButton2); jRadioButton2.setText(_("MySQL Database")); buttonGroup1.add(jRadioButton3); jRadioButton3.setText(_("Advanced Configuration")); 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() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 476, Short.MAX_VALUE) .addComponent(jRadioButton1) .addComponent(jRadioButton2) .addComponent(jRadioButton3) .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 476, Short.MAX_VALUE)) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel2) .addGap(18, 18, 18) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jRadioButton2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jRadioButton3) .addContainerGap(58, Short.MAX_VALUE)) ); }// </editor-fold>//GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.ButtonGroup buttonGroup1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JRadioButton jRadioButton1; private javax.swing.JRadioButton jRadioButton2; private javax.swing.JRadioButton jRadioButton3; // End of variables declaration//GEN-END:variables }