Lines 13-23
Link Here
|
13 |
* Configuration Manager, for Multi-configs support. |
13 |
* Configuration Manager, for Multi-configs support. |
14 |
* Diego Sandin (Motorola) - Use Eclipse Message Bundles [Bug 255874] |
14 |
* Diego Sandin (Motorola) - Use Eclipse Message Bundles [Bug 255874] |
15 |
* Fernando Rocha(Motorola)- Add validation to JAR URL. |
15 |
* Fernando Rocha(Motorola)- Add validation to JAR URL. |
|
|
16 |
* Fernando Rocha(Motorola)- Problem marker for the description file. |
16 |
*/ |
17 |
*/ |
17 |
package org.eclipse.mtj.internal.ui.editors.jad.form.pages; |
18 |
package org.eclipse.mtj.internal.ui.editors.jad.form.pages; |
18 |
|
19 |
|
19 |
import org.eclipse.core.resources.IResource; |
20 |
import org.eclipse.core.resources.IFile; |
20 |
import org.eclipse.core.resources.IWorkspace; |
|
|
21 |
import org.eclipse.core.runtime.CoreException; |
21 |
import org.eclipse.core.runtime.CoreException; |
22 |
import org.eclipse.core.runtime.IConfigurationElement; |
22 |
import org.eclipse.core.runtime.IConfigurationElement; |
23 |
import org.eclipse.core.runtime.IExtensionRegistry; |
23 |
import org.eclipse.core.runtime.IExtensionRegistry; |
Lines 22-28
Link Here
|
22 |
import org.eclipse.core.runtime.IConfigurationElement; |
22 |
import org.eclipse.core.runtime.IConfigurationElement; |
23 |
import org.eclipse.core.runtime.IExtensionRegistry; |
23 |
import org.eclipse.core.runtime.IExtensionRegistry; |
24 |
import org.eclipse.core.runtime.IProgressMonitor; |
24 |
import org.eclipse.core.runtime.IProgressMonitor; |
25 |
import org.eclipse.core.runtime.IStatus; |
|
|
26 |
import org.eclipse.core.runtime.Platform; |
25 |
import org.eclipse.core.runtime.Platform; |
27 |
import org.eclipse.debug.ui.ILaunchShortcut; |
26 |
import org.eclipse.debug.ui.ILaunchShortcut; |
28 |
import org.eclipse.jdt.core.IJavaProject; |
27 |
import org.eclipse.jdt.core.IJavaProject; |
Lines 34-40
Link Here
|
34 |
import org.eclipse.jface.util.IPropertyChangeListener; |
33 |
import org.eclipse.jface.util.IPropertyChangeListener; |
35 |
import org.eclipse.jface.util.PropertyChangeEvent; |
34 |
import org.eclipse.jface.util.PropertyChangeEvent; |
36 |
import org.eclipse.jface.viewers.StructuredSelection; |
35 |
import org.eclipse.jface.viewers.StructuredSelection; |
37 |
import org.eclipse.mtj.core.MTJCore; |
|
|
38 |
import org.eclipse.mtj.core.project.midp.IMidletSuiteProject; |
36 |
import org.eclipse.mtj.core.project.midp.IMidletSuiteProject; |
39 |
import org.eclipse.mtj.core.project.runtime.event.AddMTJRuntimeEvent; |
37 |
import org.eclipse.mtj.core.project.runtime.event.AddMTJRuntimeEvent; |
40 |
import org.eclipse.mtj.core.project.runtime.event.IMTJRuntimeChangeListener; |
38 |
import org.eclipse.mtj.core.project.runtime.event.IMTJRuntimeChangeListener; |
Lines 61-66
Link Here
|
61 |
import org.eclipse.mtj.ui.editors.jad.JADPropertiesEditorPage; |
59 |
import org.eclipse.mtj.ui.editors.jad.JADPropertiesEditorPage; |
62 |
import org.eclipse.swt.widgets.Composite; |
60 |
import org.eclipse.swt.widgets.Composite; |
63 |
import org.eclipse.swt.widgets.Control; |
61 |
import org.eclipse.swt.widgets.Control; |
|
|
62 |
import org.eclipse.swt.widgets.Text; |
64 |
import org.eclipse.ui.IEditorInput; |
63 |
import org.eclipse.ui.IEditorInput; |
65 |
import org.eclipse.ui.IWorkbenchPart; |
64 |
import org.eclipse.ui.IWorkbenchPart; |
66 |
import org.eclipse.ui.PlatformUI; |
65 |
import org.eclipse.ui.PlatformUI; |
Lines 157-171
Link Here
|
157 |
public void doSave(IProgressMonitor monitor) { |
156 |
public void doSave(IProgressMonitor monitor) { |
158 |
super.doSave(monitor); |
157 |
super.doSave(monitor); |
159 |
|
158 |
|
|
|
159 |
validateFields(); |
160 |
|
160 |
String currentJarUrl = getPreferenceStore().getString( |
161 |
String currentJarUrl = getPreferenceStore().getString( |
161 |
IJADConstants.JAD_MIDLET_JAR_URL); |
162 |
IJADConstants.JAD_MIDLET_JAR_URL); |
162 |
|
163 |
|
163 |
IWorkspace workspace = MTJCore.getWorkspace(); |
164 |
Control jarURLControl = null; |
164 |
IStatus result = workspace.validateName(currentJarUrl, IResource.FILE); |
165 |
for (FieldEditor field : fieldEditors) { |
165 |
if (!result.isOK()) { |
166 |
if (field instanceof ExtendedStringFieldEditor) { |
|
|
167 |
String fieldEditorLabel = field.getLabelText(); |
168 |
if (fieldEditorLabel |
169 |
.equals(MTJUIMessages.RequiredJADDesciptorsProvider_midlet_jar_url)) { |
170 |
jarURLControl = ((ExtendedStringFieldEditor) field) |
171 |
.getFieldEditorTextControl(); |
172 |
break; |
173 |
} |
174 |
} |
175 |
} |
176 |
|
177 |
if (!Utils.isValidFileName(currentJarUrl)) { |
166 |
getPreferenceStore().putValue(IJADConstants.JAD_MIDLET_JAR_URL, |
178 |
getPreferenceStore().putValue(IJADConstants.JAD_MIDLET_JAR_URL, |
167 |
loadedJarUrl); |
179 |
loadedJarUrl); |
168 |
getErrorMessageManager().removeAllMessages(); |
180 |
getErrorMessageManager() |
|
|
181 |
.removeMessage( |
182 |
"textLength_" + MTJUIMessages.RequiredJADDesciptorsProvider_midlet_jar_url, jarURLControl); //$NON-NLS-1$ |
169 |
} else if (!currentJarUrl.substring(currentJarUrl.length() - 4) |
183 |
} else if (!currentJarUrl.substring(currentJarUrl.length() - 4) |
170 |
.equalsIgnoreCase(".jar")) { //$NON-NLS-1$ |
184 |
.equalsIgnoreCase(".jar")) { //$NON-NLS-1$ |
171 |
getPreferenceStore().putValue(IJADConstants.JAD_MIDLET_JAR_URL, |
185 |
getPreferenceStore().putValue(IJADConstants.JAD_MIDLET_JAR_URL, |
Lines 170-178
Link Here
|
170 |
.equalsIgnoreCase(".jar")) { //$NON-NLS-1$ |
184 |
.equalsIgnoreCase(".jar")) { //$NON-NLS-1$ |
171 |
getPreferenceStore().putValue(IJADConstants.JAD_MIDLET_JAR_URL, |
185 |
getPreferenceStore().putValue(IJADConstants.JAD_MIDLET_JAR_URL, |
172 |
loadedJarUrl); |
186 |
loadedJarUrl); |
173 |
getErrorMessageManager().removeAllMessages(); |
187 |
getErrorMessageManager() |
|
|
188 |
.removeMessage( |
189 |
"textLength_" + MTJUIMessages.RequiredJADDesciptorsProvider_midlet_jar_url, jarURLControl); //$NON-NLS-1$ |
174 |
} |
190 |
} |
175 |
|
191 |
|
176 |
if (!currentJarUrl.equals(loadedJarUrl)) { |
192 |
if (!currentJarUrl.equals(loadedJarUrl)) { |
177 |
((JADFormEditor) getEditor()).setCleanRequired(true); |
193 |
((JADFormEditor) getEditor()).setCleanRequired(true); |
178 |
} |
194 |
} |
Lines 188-193
Link Here
|
188 |
} |
204 |
} |
189 |
|
205 |
|
190 |
} |
206 |
} |
|
|
207 |
|
208 |
/** |
209 |
* Validate editor fields |
210 |
*/ |
211 |
public void validateFields() { |
212 |
IFile applicationDescriptorFile = midletProject |
213 |
.getApplicationDescriptorFile(); |
214 |
try { |
215 |
Utils.removeAllErrorMarkers(applicationDescriptorFile); |
216 |
} catch (CoreException e) { |
217 |
e.printStackTrace(); |
218 |
} |
219 |
|
220 |
for (FieldEditor field : fieldEditors) { |
221 |
if (field instanceof ExtendedStringFieldEditor) { |
222 |
String fieldEditorLabel = field.getLabelText(); |
223 |
Text control = ((ExtendedStringFieldEditor) field) |
224 |
.getFieldEditorTextControl(); |
225 |
if (!fieldEditorLabel |
226 |
.equals(MTJUIMessages.RequiredJADDesciptorsProvider_midlet_jar_url)) { |
227 |
if (control.getText().equals(Utils.EMPTY_STRING)) { |
228 |
getErrorMessageManager() |
229 |
.addMessage( |
230 |
"textLength_" + fieldEditorLabel, //$NON-NLS-1$ |
231 |
MTJUIMessages.OverviewEditorPage_empty_field_error_msg, |
232 |
null, IMessageProvider.ERROR, control); |
233 |
|
234 |
try { |
235 |
Utils |
236 |
.createErrorMarker( |
237 |
applicationDescriptorFile, |
238 |
fieldEditorLabel |
239 |
+ ":" //$NON-NLS-1$ |
240 |
+ MTJUIMessages.OverviewEditorPage_empty_field_error_msg); |
241 |
} catch (CoreException e) { |
242 |
e.printStackTrace(); |
243 |
} |
244 |
} |
245 |
} |
246 |
} |
247 |
} |
248 |
} |
191 |
|
249 |
|
192 |
/* (non-Javadoc) |
250 |
/* (non-Javadoc) |
193 |
* @see org.eclipse.mtj.ui.editors.jad.AbstractJADEditorPage#getTitle() |
251 |
* @see org.eclipse.mtj.ui.editors.jad.AbstractJADEditorPage#getTitle() |
Lines 248-256
Link Here
|
248 |
.getPreferenceName().equals( |
306 |
.getPreferenceName().equals( |
249 |
IJADConstants.JAD_MIDLET_JAR_URL)) { |
307 |
IJADConstants.JAD_MIDLET_JAR_URL)) { |
250 |
String jarFileName = (String) event.getNewValue(); |
308 |
String jarFileName = (String) event.getNewValue(); |
251 |
IWorkspace workspace = MTJCore.getWorkspace(); |
|
|
252 |
IStatus result = workspace.validateName(jarFileName, |
253 |
IResource.FILE); |
254 |
if (!jarFileName.substring(jarFileName.length() - 4) |
309 |
if (!jarFileName.substring(jarFileName.length() - 4) |
255 |
.equalsIgnoreCase(".jar")) { //$NON-NLS-1$ |
310 |
.equalsIgnoreCase(".jar")) { //$NON-NLS-1$ |
256 |
getErrorMessageManager() |
311 |
getErrorMessageManager() |
Lines 258-264
Link Here
|
258 |
"textLength_" + fieldEditorLabel, //$NON-NLS-1$ |
313 |
"textLength_" + fieldEditorLabel, //$NON-NLS-1$ |
259 |
MTJUIMessages.J2MEProjectPropertiesPage_validatePage_jar_error, |
314 |
MTJUIMessages.J2MEProjectPropertiesPage_validatePage_jar_error, |
260 |
null, IMessageProvider.ERROR, c); |
315 |
null, IMessageProvider.ERROR, c); |
261 |
} else if (!result.isOK()) { |
316 |
} else if (!Utils.isValidFileName(jarFileName)) { |
262 |
getErrorMessageManager() |
317 |
getErrorMessageManager() |
263 |
.addMessage( |
318 |
.addMessage( |
264 |
"textLength_" + fieldEditorLabel, //$NON-NLS-1$ |
319 |
"textLength_" + fieldEditorLabel, //$NON-NLS-1$ |
Lines 568-573
Link Here
|
568 |
form.updateToolBar(); |
623 |
form.updateToolBar(); |
569 |
|
624 |
|
570 |
fillEditorPageBody(managedForm); |
625 |
fillEditorPageBody(managedForm); |
|
|
626 |
|
627 |
validateFields(); |
571 |
} |
628 |
} |
572 |
|
629 |
|
573 |
/* (non-Javadoc) |
630 |
/* (non-Javadoc) |