New Jide License
[indepmod/experimental.git] / IndependentModeler / src / cz / cvut / promod / gui / dialogs / simpleTextFieldDialog / SimpleTextFieldDialogView.java
blob226b488c03b9e4c27bb9ba7d747a94f14a48c946
1 package cz.cvut.promod.gui.dialogs.simpleTextFieldDialog;
3 import cz.cvut.promod.services.ModelerSession;
4 import cz.cvut.promod.services.componentFactoryService.ComponentFactoryService;
6 import javax.swing.*;
7 import java.awt.*;
9 import com.jgoodies.forms.factories.Borders;
10 import com.jgoodies.forms.layout.FormLayout;
11 import com.jgoodies.forms.layout.CellConstraints;
13 /**
14 * ProMod, master thesis project
15 * User: Petr Zverina, petr.zverina@gmail.com
16 * Date: 23:49:51, 23.10.2009
18 * A View component of SimpleTextFieldDialog.
20 public class SimpleTextFieldDialogView extends JDialog{
22 private final Dimension INIT_SIZE = new Dimension(450, 170);
24 protected JLabel textLabel = ModelerSession.getComponentFactoryService().createLabel("");
25 protected JTextField inputTextField = ModelerSession.getComponentFactoryService().createTextField();
27 protected final JLabel errorLabel = ModelerSession.getComponentFactoryService().createLabel("");
29 protected JButton confirmButton = ModelerSession.getComponentFactoryService().createButton("", null);
30 protected JButton cancelButton = ModelerSession.getComponentFactoryService().createButton("", null);
32 protected SimpleTextFieldDialogView(){
33 initLayout();
35 errorLabel.setForeground(Color.RED);
38 private void initLayout() {
39 setSize(INIT_SIZE);
41 final JPanel centerPanel = ModelerSession.getComponentFactoryService().createPanel();
42 centerPanel.setBorder(Borders.createEmptyBorder(ComponentFactoryService.DEFAULT_FORM_BORDER));
44 centerPanel.setLayout(new FormLayout(
45 "min(pref;2000dlu):grow",
46 "pref, 3dlu, pref, 3dlu, pref, 7dlu"
47 ));
48 final CellConstraints cellConstraints = new CellConstraints();
50 centerPanel.add(textLabel, cellConstraints. xy(1, 1));
51 centerPanel.add(inputTextField, cellConstraints.xy(1,3));
53 centerPanel.add(errorLabel, cellConstraints.xy(1, 5));
55 final JPanel southPanel = ModelerSession.getComponentFactoryService().createPanel();
56 southPanel.setBorder(Borders.createEmptyBorder(ComponentFactoryService.DEFAULT_FORM_BORDER));
58 southPanel.setLayout(new FormLayout(
59 "pref:grow, pref, 3dlu, pref, pref:grow",
60 "pref"));
62 southPanel.add(confirmButton, cellConstraints.xy(2, 1));
63 southPanel.add(cancelButton, cellConstraints.xy(4, 1));
65 setLayout(new BorderLayout());
66 add(centerPanel, BorderLayout.CENTER);
67 add(southPanel, BorderLayout.SOUTH);