/*
* SelectorPanel.java
*
* Created on 2009. okt�ber 29., 8:06
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package swing.panel;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JPanel;
import swing.button.OpenFormButton;
import swing.form.Form;
import swing.form.FormUtil;
import system.util.Login;
/**
*
* @author laci
*/
public abstract class SelectorPanel extends Panel{
// <editor-fold defaultstate="collapsed" desc="konstansok">
public static final int DEFAULT_LENGTH = 20;
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="konstruktor">
/** Creates a new instance of SelectorPanel */
public SelectorPanel(Login login, String title, int length) {
super(login,new GridBagLayout());
initialize(title, length);
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="inicializalas">
public void initialize(String title, int length) {
setTitle(title);
createLayout();
getMezo().setColumns(length);
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="createLayout">
protected void createLayout() {
setLayout(new GridBagLayout());
add(getTitle(), FormUtil.newGBConstraints(0, 0, 1, 1, FormUtil.ANCHOR_WEST, FormUtil.FILL_NONE, new Insets(0,0,0,0)));
JPanel flow = new JPanel(new FlowLayout());
add(flow, FormUtil.newGBConstraints(0, 1, 2, 1, FormUtil.ANCHOR_WEST, FormUtil.FILL_NONE, new Insets(0,0,0,0)));
flow.add(getMezo());
flow.add(getUjButton());
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="mezo">
private TextFieldPanel mezo;
protected TextFieldPanel getMezo() {
if (mezo == null) {
mezo = createMezo();
}
return mezo;
}
protected TextFieldPanel createMezo() {
TextFieldPanel temp = new TextFieldPanel(getLogin());
temp.setEnabled(false);
temp.setForeground(Color.GRAY);
return temp;
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="uj gomb">
private OpenFormButton ujButton;
protected OpenFormButton getUjButton() {
if(ujButton == null) {
ujButton = createUjButton();
}
return ujButton;
}
protected OpenFormButton createUjButton() {
OpenFormButton temp = new OpenFormButton(getFormResource("Button.Uj"));
return temp;
}
private Form form;
public void setForm(Form form) {
this.form = form;
form.addCancelButtonListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setListaModel();
}
});
form.addOkButtonListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setListaModel();
setTkod(getForm().getTkod());
getForm().deactivate();
}
});
}
public Form getForm() {
return form;
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="setListaModel">
protected abstract void setListaModel();
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Objektum">
private Object elem;
public Object getValue() {
return elem;
}
public void setValue(Object mire) {
elem = mire;
}
public abstract void setTkod(Integer tkod);
public abstract Integer getTkod();
// </editor-fold>
}