New Jide License
[indepmod/experimental.git] / IndependentModeler / src / cz / cvut / promod / gui / dialogs / newProject / NewProjectDialogView.java
blob974b5fe776781f3ea2492a3b9ce06765bc1bb7e0
1 package cz.cvut.promod.gui.dialogs.newProject;
3 import com.jgoodies.forms.layout.FormLayout;
4 import com.jgoodies.forms.layout.CellConstraints;
5 import com.jgoodies.forms.factories.Borders;
7 import javax.swing.*;
8 import java.awt.*;
10 import cz.cvut.promod.services.ModelerSession;
11 import cz.cvut.promod.services.componentFactoryService.ComponentFactoryService;
13 /**
14 * ProMod, master thesis project
15 * User: Petr Zverina, petr.zverina@gmail.com
16 * Date: 1:40:04, 20.10.2009
18 * The view component for NewProjectDialog.
20 public class NewProjectDialogView extends JDialog {
22 private final JLabel projectNameLabel = ModelerSession.getComponentFactoryService().createLabel("project name");
23 protected final JTextField projectNameTextField = ModelerSession.getComponentFactoryService().createTextField();
25 private final JLabel projectLocationLabel = ModelerSession.getComponentFactoryService().createLabel("project location");
26 protected final JTextField projectLocationTextField = ModelerSession.getComponentFactoryService().createTextField();
27 protected final JButton projectLocationButton = ModelerSession.getComponentFactoryService().createButton("...", null);
29 protected final JButton createProjectButton = ModelerSession.getComponentFactoryService().createButton("create project", null);
30 protected final JButton cancelButton = ModelerSession.getComponentFactoryService().createButton("cancel", null);
32 protected final JLabel errorLabel = ModelerSession.getComponentFactoryService().createLabel("");
34 protected final JPanel centerPanel = ModelerSession.getComponentFactoryService().createPanel();
36 public static final String TITLE =
37 ModelerSession.getCommonResourceBundle().getString("modeler.action.new.project.dialog");
39 public NewProjectDialogView(){
40 setTitle(TITLE);
42 setModal(true);
44 errorLabel.setForeground(Color.RED);
46 initLayout();
48 pack();
51 private void initLayout() {
52 centerPanel.setBorder(Borders.createEmptyBorder(ComponentFactoryService.DEFAULT_FORM_BORDER));
53 centerPanel.setLayout(new FormLayout(
54 "pref, 3dlu, max(180dlu;pref):grow, 3dlu, pref",
55 "pref, 3dlu, pref, 3dlu, pref, 20dlu")
58 int row = 1;
59 final CellConstraints cellConstraints = new CellConstraints();
61 centerPanel.add(projectNameLabel, cellConstraints.xy(1, row));
62 centerPanel.add(projectNameTextField, cellConstraints.xyw(3, row, 3));
64 row += 2;
65 centerPanel.add(projectLocationLabel, cellConstraints.xy(1, row));
66 centerPanel.add(projectLocationTextField, cellConstraints.xy(3, row));
67 centerPanel.add(projectLocationButton, cellConstraints.xy(5, row));
70 final JPanel southPanel = ModelerSession.getComponentFactoryService().createPanel();
71 southPanel.setBorder(Borders.createEmptyBorder(ComponentFactoryService.DEFAULT_FORM_BORDER));
72 southPanel.setLayout(new FormLayout(
73 "pref, 50dlu:grow, pref",
74 "pref, 3dlu, pref"
75 ));
77 southPanel.add(errorLabel, cellConstraints.xyw(1, 1, 3));
79 southPanel.add(cancelButton, cellConstraints.xy(1, 3));
80 southPanel.add(createProjectButton, cellConstraints.xy(3, 3));
83 setLayout(new BorderLayout());
84 add(centerPanel, BorderLayout.CENTER);
85 add(southPanel, BorderLayout.SOUTH);