56 |
56 |
57 public IStatus validate(Object value) { |
57 public IStatus validate(Object value) { |
58 IWorkspace workspace = IDEWorkbenchPlugin.getPluginWorkspace(); |
58 IWorkspace workspace = IDEWorkbenchPlugin.getPluginWorkspace(); |
59 |
59 |
60 String projectFieldContents = (String) value; |
60 String projectFieldContents = (String) value; |
61 IStatus nameStatus = workspace.validateName(projectFieldContents, |
61 IStatus nameStatus = workspace.validateName(projectFieldContents, IResource.PROJECT); |
62 IResource.PROJECT); |
|
63 if (!nameStatus.isOK()) { |
62 if (!nameStatus.isOK()) { |
64 return nameStatus; |
63 return nameStatus; |
65 } |
64 } |
66 |
65 |
67 IProject handle = ResourcesPlugin.getWorkspace().getRoot() |
66 IProject handle = ResourcesPlugin.getWorkspace().getRoot().getProject(projectFieldContents); |
68 .getProject(projectFieldContents); |
|
69 if (handle.exists()) { |
67 if (handle.exists()) { |
70 return new Status( |
68 return new Status(IStatus.ERROR, Activator.PLUGIN_ID, |
71 IStatus.ERROR, |
|
72 Activator.PLUGIN_ID, |
|
73 IDEWorkbenchMessages.WizardNewProjectCreationPage_projectExistsMessage); |
69 IDEWorkbenchMessages.WizardNewProjectCreationPage_projectExistsMessage); |
74 } |
70 } |
75 return Status.OK_STATUS; |
71 return Status.OK_STATUS; |
76 } |
72 } |
77 |
73 |
94 public void createControl(Composite parent) { |
89 public void createControl(Composite parent) { |
95 Composite root = new Composite(parent, SWT.NONE); |
90 Composite root = new Composite(parent, SWT.NONE); |
96 |
91 |
97 initializeDialogUnits(parent); |
92 initializeDialogUnits(parent); |
98 |
93 |
99 PlatformUI.getWorkbench().getHelpSystem() |
94 PlatformUI.getWorkbench().getHelpSystem().setHelp(root, IIDEHelpContextIds.NEW_PROJECT_WIZARD_PAGE); |
100 .setHelp(root, IIDEHelpContextIds.NEW_PROJECT_WIZARD_PAGE); |
|
101 |
95 |
102 WizardPageSupport.create(this, bindingContext); |
96 WizardPageSupport.create(this, bindingContext); |
103 root.setLayout(new GridLayout(2, false)); |
97 root.setLayout(new GridLayout(2, false)); |
|
98 createProjectNameGroup(root); |
|
99 |
|
100 context.createLabel(root, ""); |
|
101 context.createLabel(root, ""); |
|
102 context.createLabel(root, "Application identifier:"); |
|
103 |
|
104 context.createText(root, WizardContext.WIDGET_ID, "applicatoin identifier", bindingContext, null, |
|
105 new RegexpValidator("[\\w]*(\\.\\w[\\w]*)*", "{0} is not a valid applicatoin ID", true)); |
|
106 context.createLabel(root, ""); |
|
107 context.createLabel(root, "This id should be unique for succesful installation of application on the device"); |
|
108 |
|
109 context.createLabel(root, ""); |
|
110 context.createLabel(root, ""); |
|
111 |
104 context.createLabel(root, "Application name:"); |
112 context.createLabel(root, "Application name:"); |
105 |
113 |
106 context.createText(root, WizardContext.WIDGET_NAME, "application name", |
114 context.createText(root, WizardContext.WIDGET_NAME, "application name", bindingContext, null, |
107 bindingContext, null, new RegexpValidator("[^\\w\\. ]", |
115 new RegexpValidator("[^\\w\\. ]", "Application name cannot contain {0} character", false)); |
108 "Application name cannot contain {0} character", false)); |
116 |
109 |
117 context.createLabel(root, ""); |
110 context.createLabel(root, ""); |
118 context.createLabel(root, "This will be the application display name on the device"); |
111 context.createLabel(root, |
|
112 "This will be the application display name on the device"); |
|
113 context.createLabel(root, ""); |
|
114 context.createLabel(root, ""); |
|
115 context.createLabel(root, "Widget identifier:"); |
|
116 |
|
117 context.createText(root, WizardContext.WIDGET_ID, |
|
118 "applicatoin identifier", bindingContext, null, |
|
119 new RegexpValidator("[\\w]*(\\.\\w[\\w]*)*", |
|
120 "{0} is not a valid applicatoin ID", true)); |
|
121 context.createLabel(root, ""); |
|
122 context.createLabel( |
|
123 root, |
|
124 "This id should be unique for succesful installation of application on the device"); |
|
125 context.createLabel(root, ""); |
|
126 context.createLabel(root, ""); |
|
127 |
|
128 createProjectNameGroup(root); |
|
129 |
119 |
130 Composite composite = new Composite(root, SWT.NONE); |
120 Composite composite = new Composite(root, SWT.NONE); |
131 GridLayout gridLayout = new GridLayout(1, false); |
121 GridLayout gridLayout = new GridLayout(1, false); |
132 gridLayout.marginWidth = 0; |
122 gridLayout.marginWidth = 0; |
133 composite.setLayout(gridLayout); |
123 composite.setLayout(gridLayout); |
134 composite.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, |
124 composite.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, true, 2, 1)); |
135 true, true, 2, 1)); |
125 |
136 |
126 locationArea = new ProjectContentsLocationArea(getErrorReporter(), composite); |
137 locationArea = new ProjectContentsLocationArea(getErrorReporter(), |
127 if (context.getProjectName() != null && context.getProjectName().trim().length() > 0) { |
138 composite); |
|
139 if (context.getProjectName() != null |
|
140 && context.getProjectName().trim().length() > 0) { |
|
141 locationArea.updateProjectName(context.getProjectName()); |
128 locationArea.updateProjectName(context.getProjectName()); |
142 } |
129 } |
143 |
130 |
144 // Scale the button based on the rest of the dialog |
131 // Scale the button based on the rest of the dialog |
145 setButtonLayoutData(locationArea.getBrowseButton()); |
132 setButtonLayoutData(locationArea.getBrowseButton()); |
159 * the parent composite |
146 * the parent composite |
160 */ |
147 */ |
161 private final void createProjectNameGroup(Composite parent) { |
148 private final void createProjectNameGroup(Composite parent) { |
162 // new project label |
149 // new project label |
163 Label projectLabel = new Label(parent, SWT.NONE); |
150 Label projectLabel = new Label(parent, SWT.NONE); |
164 projectLabel |
151 projectLabel.setText(IDEWorkbenchMessages.WizardNewProjectCreationPage_nameLabel); |
165 .setText(IDEWorkbenchMessages.WizardNewProjectCreationPage_nameLabel); |
|
166 projectLabel.setFont(parent.getFont()); |
152 projectLabel.setFont(parent.getFont()); |
167 |
153 |
168 Text projectNameField = context.createText(parent, |
154 Text projectNameField = context.createText(parent, WizardContext.PROJECT_NAME, "project name", bindingContext, |
169 WizardContext.PROJECT_NAME, "project name", bindingContext, |
|
170 null, new ProjectNameValidator()); |
155 null, new ProjectNameValidator()); |
171 |
156 |
172 projectNameField.setFont(parent.getFont()); |
157 projectNameField.setFont(parent.getFont()); |
173 |
158 |
174 projectNameField.addListener(SWT.Modify, nameModifyListener); |
159 projectNameField.addListener(SWT.Modify, nameModifyListener); |