View | Details | Raw Unified | Return to bug 246787 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/mtj/internal/core/util/Utils.java (-3 / +37 lines)
Lines 25-30 Link Here
25
 *     David Marques (Motorola) - Adding getSourceFolders method.
25
 *     David Marques (Motorola) - Adding getSourceFolders method.
26
 *     David Marques (Motorola) - Adding isAutobuilding
26
 *     David Marques (Motorola) - Adding isAutobuilding
27
 *     David Aragão (Motorola)  - Add isValidFolderName
27
 *     David Aragão (Motorola)  - Add isValidFolderName
28
 *     Fernando Rocha(Motorola) - Refactor in isValidFolderName and add methods
29
 *                                for marker management
28
 */
30
 */
29
package org.eclipse.mtj.internal.core.util;
31
package org.eclipse.mtj.internal.core.util;
30
32
Lines 51-56 Link Here
51
import org.eclipse.core.resources.IContainer;
53
import org.eclipse.core.resources.IContainer;
52
import org.eclipse.core.resources.IFile;
54
import org.eclipse.core.resources.IFile;
53
import org.eclipse.core.resources.IFolder;
55
import org.eclipse.core.resources.IFolder;
56
import org.eclipse.core.resources.IMarker;
54
import org.eclipse.core.resources.IProject;
57
import org.eclipse.core.resources.IProject;
55
import org.eclipse.core.resources.IResource;
58
import org.eclipse.core.resources.IResource;
56
import org.eclipse.core.resources.IWorkspace;
59
import org.eclipse.core.resources.IWorkspace;
Lines 1372-1381 Link Here
1372
     * @return
1375
     * @return
1373
     */
1376
     */
1374
    public static boolean isValidFolderName(String folderName) {
1377
    public static boolean isValidFolderName(String folderName) {
1375
		String property = System.getProperty("java.io.tmpdir");
1378
                IWorkspace workspace = MTJCore.getWorkspace();
1376
		File folder = new File(property, folderName);
1379
                IStatus result = workspace.validateName(folderName, IResource.FOLDER);
1377
		return (folder.exists() || folder.mkdir());
1380
		return result.isOK();
1378
	}
1381
	}
1382
    
1383
    /**
1384
     * Verifies if a file name is valid.
1385
     * @param fileName
1386
     * @return
1387
     */
1388
    public static boolean isValidFileName(String fileName) {
1389
        IWorkspace workspace = MTJCore.getWorkspace();
1390
        IStatus result = workspace.validateName(fileName, IResource.FOLDER);
1391
        return result.isOK();
1392
    }
1379
1393
1394
    /**
1395
     * Create an error marker in a resource 
1396
     * @param resource
1397
     * @param message
1398
     * @throws CoreException
1399
     */
1400
    public static void createErrorMarker(IResource resource, String message) throws CoreException {
1401
        IMarker marker = resource.createMarker("org.eclipse.mtj.core.problem");
1402
        marker.setAttribute(IMarker.MESSAGE, message);
1403
        marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
1404
    }
1405
    
1406
    /**
1407
     * Remove all the error markers
1408
     * @param resource
1409
     * @throws CoreException
1410
     */
1411
    public static void removeAllErrorMarkers(IResource resource) throws CoreException {
1412
        resource.deleteMarkers("org.eclipse.mtj.core.problem", false, IResource.DEPTH_ZERO);
1413
    }
1380
    
1414
    
1381
}
1415
}
(-)src/org/eclipse/mtj/internal/ui/editors/jad/form/pages/OverviewEditorPage.java (-3 / +36 lines)
Lines 13-21 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
20
import org.eclipse.core.resources.IFile;
19
import org.eclipse.core.resources.IResource;
21
import org.eclipse.core.resources.IResource;
20
import org.eclipse.core.resources.IWorkspace;
22
import org.eclipse.core.resources.IWorkspace;
21
import org.eclipse.core.runtime.CoreException;
23
import org.eclipse.core.runtime.CoreException;
Lines 157-171 Link Here
157
    public void doSave(IProgressMonitor monitor) {
159
    public void doSave(IProgressMonitor monitor) {
158
        super.doSave(monitor);
160
        super.doSave(monitor);
159
161
162
        IFile applicationDescriptorFile = midletProject.getApplicationDescriptorFile();
163
        try {
164
            Utils.removeAllErrorMarkers(applicationDescriptorFile);
165
        } catch (CoreException e) {
166
            e.printStackTrace();
167
        }
168
        
160
        String currentJarUrl = getPreferenceStore().getString(
169
        String currentJarUrl = getPreferenceStore().getString(
161
                IJADConstants.JAD_MIDLET_JAR_URL);
170
                IJADConstants.JAD_MIDLET_JAR_URL);
171
        String currentMidletName = getPreferenceStore().getString(IJADConstants.JAD_MIDLET_NAME);
172
        String currentMidletVendor = getPreferenceStore().getString(IJADConstants.JAD_MIDLET_VENDOR);
173
        String currentMidletVersion = getPreferenceStore().getString(IJADConstants.JAD_MIDLET_VERSION);
174
        
175
        if(currentMidletName.equals("")) {
176
            try {
177
                Utils.createErrorMarker(applicationDescriptorFile, "MIDLet name empty.");
178
            } catch (CoreException e) {
179
                e.printStackTrace();
180
            }
181
        }
182
        if(currentMidletVendor.equals("")) {
183
            try {
184
                Utils.createErrorMarker(applicationDescriptorFile, "MIDLet vendor empty.");
185
            } catch (CoreException e) {
186
                e.printStackTrace();
187
            }
188
        }
189
        if(currentMidletVersion.equals("")) {
190
            try {
191
                Utils.createErrorMarker(applicationDescriptorFile, "MIDLet version empty.");
192
            } catch (CoreException e) {
193
                e.printStackTrace();
194
            }
195
        }
162
        
196
        
163
        IWorkspace workspace = MTJCore.getWorkspace();
197
        if (!Utils.isValidFileName(currentJarUrl)) {
164
        IStatus result = workspace.validateName(currentJarUrl, IResource.FILE);
165
        if (!result.isOK()) {
166
            getPreferenceStore().putValue(IJADConstants.JAD_MIDLET_JAR_URL,
198
            getPreferenceStore().putValue(IJADConstants.JAD_MIDLET_JAR_URL,
167
                    loadedJarUrl);
199
                    loadedJarUrl);
168
            getErrorMessageManager().removeAllMessages();
200
            getErrorMessageManager().removeAllMessages();
201
            
169
        } else if (!currentJarUrl.substring(currentJarUrl.length() - 4)
202
        } else if (!currentJarUrl.substring(currentJarUrl.length() - 4)
170
                .equalsIgnoreCase(".jar")) { //$NON-NLS-1$
203
                .equalsIgnoreCase(".jar")) { //$NON-NLS-1$
171
            getPreferenceStore().putValue(IJADConstants.JAD_MIDLET_JAR_URL,
204
            getPreferenceStore().putValue(IJADConstants.JAD_MIDLET_JAR_URL,

Return to bug 246787