/*
* 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/>.
*/
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* FirstStartName.java
*
* Created on Nov 29, 2010, 10:23:05 PM
*/
package de.aidger.view.wizard;
import static de.aidger.utils.Translation._;
import de.aidger.controller.ActionNotFoundException;
import de.aidger.controller.ActionRegistry;
import de.aidger.controller.actions.FirstStartNameFinishAction;
import de.aidger.view.UI;
import de.aidger.view.WizardPanel;
import de.aidger.view.utils.MultiLineLabelUI;
import javax.swing.AbstractAction;
/**
* Get the name of the user.
*
* @author rmbl
*/
public class FirstStartName extends WizardPanel {
/** Creates new form FirstStartName */
public FirstStartName() {
initComponents();
try {
setNextAction((AbstractAction) ActionRegistry.getInstance().get(FirstStartNameFinishAction.class.getName()));
} catch (ActionNotFoundException ex) {
UI.displayError(ex.getMessage());
}
jLabel1.setUI(MultiLineLabelUI.labelUI);
}
@Override
public void preparePanel() {
return;
}
/**
* Return the entered name.
*
* @return The entered name
*/
public String getUsername() {
return jTextField1.getText().equals(_("Name")) ? "" : jTextField1.getText();
}
/** 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() {
jLabel2 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
setPreferredSize(new java.awt.Dimension(500, 300));
jLabel2.setFont(new java.awt.Font("DejaVu Sans", 0, 36)); // NOI18N
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(_("Please enter your FULL name in the field below.\nThis name will be used in all your activities."));
jLabel1.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
jTextField1.setText(_("Name"));
jTextField1.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusGained(java.awt.event.FocusEvent evt) {
jTextField1FocusGained(evt);
}
public void focusLost(java.awt.event.FocusEvent evt) {
jTextField1FocusLost(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()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)
.addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 193, javax.swing.GroupLayout.PREFERRED_SIZE))
.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, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(118, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
private void jTextField1FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField1FocusGained
if (jTextField1.getText().equals(_("Name"))) {
jTextField1.setText("");
}
}//GEN-LAST:event_jTextField1FocusGained
private void jTextField1FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField1FocusLost
if (jTextField1.getText().isEmpty()) {
jTextField1.setText(_("Name"));
}
}//GEN-LAST:event_jTextField1FocusLost
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JTextField jTextField1;
// End of variables declaration//GEN-END:variables
}