Converted all CRLF to LF.
[indepmod/experimental.git] / IndependentModeler / src / cz / cvut / promod / gui / dialogs / newProject / NewProjectDialogModel.java
blob03931720c95e83854dfe2a40cef61bfbf0f34031
1 package cz.cvut.promod.gui.dialogs.newProject;
3 import com.jgoodies.binding.beans.Model;
4 import cz.cvut.promod.services.ModelerSession;
5 import cz.cvut.promod.services.projectService.treeProjectNode.ProjectRoot;
8 /**
9 * ProMod, master thesis project
10 * User: Petr Zverina, petr.zverina@gmail.com
11 * Date: 1:40:17, 20.10.2009
13 * The model component for NewProjectDialog.
15 public class NewProjectDialogModel extends Model{
17 public static final String PROPERTY_PROJECT_LOCATION = "projectLocation";
18 private String projectLocation;
20 public static final String PROPERTY_PROJECT_NAME = "projectName";
21 private String projectName;
23 private static final String DEFAULT_PROJECT_NAME = "Project";
24 private int projectNumber = 1;
26 private static final String DEFAULT_PROJECT_DIRECTORY = "ProMod";
29 /**
30 * Generates the initial name for new project.
32 public void generateInitialProjectName() {
33 String projectName = DEFAULT_PROJECT_NAME + projectNumber;
35 // test whether the is no open project with the same name as the implicit one
36 boolean testName;
37 do{
38 testName = false;
39 for(final ProjectRoot projectRoot : ModelerSession.getProjectService().getProjects()){
40 if(projectRoot.getDisplayName().equals(projectName)){
41 testName = true;
42 ++projectNumber;
43 projectName = DEFAULT_PROJECT_NAME + projectNumber;
46 } while (testName);
48 setProjectName(DEFAULT_PROJECT_NAME + projectNumber);
51 public String getProjectLocation() {
52 return projectLocation;
55 public void setProjectLocation(final String projectLocation) {
56 final String oldProjectLocation = this.projectLocation;
57 this.projectLocation = projectLocation;
58 firePropertyChange(PROPERTY_PROJECT_LOCATION, oldProjectLocation, projectLocation);
61 public String getProjectName() {
62 return projectName;
65 public void setProjectName(final String projectName) {
66 final String oldProjectName = this.projectName;
67 this.projectName = projectName;
68 firePropertyChange(PROPERTY_PROJECT_NAME, oldProjectName, projectName);
71 public void generateInitialProjectLocation() {
72 setProjectLocation(System.getProperty("user.home") +
73 System.getProperty("file.separator") +
74 DEFAULT_PROJECT_DIRECTORY +
75 System.getProperty("file.separator") +
76 getProjectName());