### Eclipse Workspace Patch 1.0 #P org.eclipse.mtj.core Index: src/org/eclipse/mtj/internal/core/util/Utils.java =================================================================== --- src/org/eclipse/mtj/internal/core/util/Utils.java (revision 1344) +++ src/org/eclipse/mtj/internal/core/util/Utils.java (working copy) @@ -25,6 +25,8 @@ * David Marques (Motorola) - Adding getSourceFolders method. * David Marques (Motorola) - Adding isAutobuilding * David Aragão (Motorola) - Add isValidFolderName + * Fernando Rocha(Motorola) - Refactor in isValidFolderName and add methods + * for marker management */ package org.eclipse.mtj.internal.core.util; @@ -51,6 +53,7 @@ import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspace; @@ -1372,10 +1375,41 @@ * @return */ public static boolean isValidFolderName(String folderName) { - String property = System.getProperty("java.io.tmpdir"); - File folder = new File(property, folderName); - return (folder.exists() || folder.mkdir()); + IWorkspace workspace = MTJCore.getWorkspace(); + IStatus result = workspace.validateName(folderName, IResource.FOLDER); + return result.isOK(); } + + /** + * Verifies if a file name is valid. + * @param fileName + * @return + */ + public static boolean isValidFileName(String fileName) { + IWorkspace workspace = MTJCore.getWorkspace(); + IStatus result = workspace.validateName(fileName, IResource.FOLDER); + return result.isOK(); + } + /** + * Create an error marker in a resource + * @param resource + * @param message + * @throws CoreException + */ + public static void createErrorMarker(IResource resource, String message) throws CoreException { + IMarker marker = resource.createMarker("org.eclipse.mtj.core.problem"); + marker.setAttribute(IMarker.MESSAGE, message); + marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR); + } + + /** + * Remove all the error markers + * @param resource + * @throws CoreException + */ + public static void removeAllErrorMarkers(IResource resource) throws CoreException { + resource.deleteMarkers("org.eclipse.mtj.core.problem", false, IResource.DEPTH_ZERO); + } } #P org.eclipse.mtj.ui Index: src/org/eclipse/mtj/internal/ui/editors/jad/form/pages/OverviewEditorPage.java =================================================================== --- src/org/eclipse/mtj/internal/ui/editors/jad/form/pages/OverviewEditorPage.java (revision 1345) +++ src/org/eclipse/mtj/internal/ui/editors/jad/form/pages/OverviewEditorPage.java (working copy) @@ -13,9 +13,11 @@ * Configuration Manager, for Multi-configs support. * Diego Sandin (Motorola) - Use Eclipse Message Bundles [Bug 255874] * Fernando Rocha(Motorola)- Add validation to JAR URL. + * Fernando Rocha(Motorola)- Problem marker for the description file. */ package org.eclipse.mtj.internal.ui.editors.jad.form.pages; +import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.runtime.CoreException; @@ -157,15 +159,46 @@ public void doSave(IProgressMonitor monitor) { super.doSave(monitor); + IFile applicationDescriptorFile = midletProject.getApplicationDescriptorFile(); + try { + Utils.removeAllErrorMarkers(applicationDescriptorFile); + } catch (CoreException e) { + e.printStackTrace(); + } + String currentJarUrl = getPreferenceStore().getString( IJADConstants.JAD_MIDLET_JAR_URL); + String currentMidletName = getPreferenceStore().getString(IJADConstants.JAD_MIDLET_NAME); + String currentMidletVendor = getPreferenceStore().getString(IJADConstants.JAD_MIDLET_VENDOR); + String currentMidletVersion = getPreferenceStore().getString(IJADConstants.JAD_MIDLET_VERSION); + + if(currentMidletName.equals("")) { + try { + Utils.createErrorMarker(applicationDescriptorFile, "MIDLet name empty."); + } catch (CoreException e) { + e.printStackTrace(); + } + } + if(currentMidletVendor.equals("")) { + try { + Utils.createErrorMarker(applicationDescriptorFile, "MIDLet vendor empty."); + } catch (CoreException e) { + e.printStackTrace(); + } + } + if(currentMidletVersion.equals("")) { + try { + Utils.createErrorMarker(applicationDescriptorFile, "MIDLet version empty."); + } catch (CoreException e) { + e.printStackTrace(); + } + } - IWorkspace workspace = MTJCore.getWorkspace(); - IStatus result = workspace.validateName(currentJarUrl, IResource.FILE); - if (!result.isOK()) { + if (!Utils.isValidFileName(currentJarUrl)) { getPreferenceStore().putValue(IJADConstants.JAD_MIDLET_JAR_URL, loadedJarUrl); getErrorMessageManager().removeAllMessages(); + } else if (!currentJarUrl.substring(currentJarUrl.length() - 4) .equalsIgnoreCase(".jar")) { //$NON-NLS-1$ getPreferenceStore().putValue(IJADConstants.JAD_MIDLET_JAR_URL,