Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 141667 Details for
Bug 246787
[fiximprove] [AppDescEditor]: Application descriptor does not inform error on the "Package Explorer"
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
The proposed patch for the bug correction
bug246787.patch (text/plain), 10.19 KB, created by
Fernando Rocha
on 2009-07-15 12:43:42 EDT
(
hide
)
Description:
The proposed patch for the bug correction
Filename:
MIME Type:
Creator:
Fernando Rocha
Created:
2009-07-15 12:43:42 EDT
Size:
10.19 KB
patch
obsolete
>### 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 1347) >+++ 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; > >@@ -53,6 +55,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; >@@ -1366,10 +1369,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(IMTJCoreConstants.JAVAME_PROBLEM_MARKER); >+ 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(IMTJCoreConstants.JAVAME_PROBLEM_MARKER, 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 1347) >+++ src/org/eclipse/mtj/internal/ui/editors/jad/form/pages/OverviewEditorPage.java (working copy) >@@ -13,11 +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.IResource; >-import org.eclipse.core.resources.IWorkspace; >+import org.eclipse.core.resources.IFile; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IConfigurationElement; > import org.eclipse.core.runtime.IExtensionRegistry; >@@ -22,7 +22,6 @@ > import org.eclipse.core.runtime.IConfigurationElement; > import org.eclipse.core.runtime.IExtensionRegistry; > import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.Platform; > import org.eclipse.debug.ui.ILaunchShortcut; > import org.eclipse.jdt.core.IJavaProject; >@@ -34,7 +33,6 @@ > import org.eclipse.jface.util.IPropertyChangeListener; > import org.eclipse.jface.util.PropertyChangeEvent; > import org.eclipse.jface.viewers.StructuredSelection; >-import org.eclipse.mtj.core.MTJCore; > import org.eclipse.mtj.core.project.midp.IMidletSuiteProject; > import org.eclipse.mtj.core.project.runtime.event.AddMTJRuntimeEvent; > import org.eclipse.mtj.core.project.runtime.event.IMTJRuntimeChangeListener; >@@ -61,6 +59,7 @@ > import org.eclipse.mtj.ui.editors.jad.JADPropertiesEditorPage; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Text; > import org.eclipse.ui.IEditorInput; > import org.eclipse.ui.IWorkbenchPart; > import org.eclipse.ui.PlatformUI; >@@ -157,15 +156,30 @@ > public void doSave(IProgressMonitor monitor) { > super.doSave(monitor); > >+ validateFields(); >+ > String currentJarUrl = getPreferenceStore().getString( > IJADConstants.JAD_MIDLET_JAR_URL); >- >- IWorkspace workspace = MTJCore.getWorkspace(); >- IStatus result = workspace.validateName(currentJarUrl, IResource.FILE); >- if (!result.isOK()) { >+ >+ Control jarURLControl = null; >+ for (FieldEditor field : fieldEditors) { >+ if (field instanceof ExtendedStringFieldEditor) { >+ String fieldEditorLabel = field.getLabelText(); >+ if (fieldEditorLabel >+ .equals(MTJUIMessages.RequiredJADDesciptorsProvider_midlet_jar_url)) { >+ jarURLControl = ((ExtendedStringFieldEditor) field) >+ .getFieldEditorTextControl(); >+ break; >+ } >+ } >+ } >+ >+ if (!Utils.isValidFileName(currentJarUrl)) { > getPreferenceStore().putValue(IJADConstants.JAD_MIDLET_JAR_URL, > loadedJarUrl); >- getErrorMessageManager().removeAllMessages(); >+ getErrorMessageManager() >+ .removeMessage( >+ "textLength_" + MTJUIMessages.RequiredJADDesciptorsProvider_midlet_jar_url, jarURLControl); //$NON-NLS-1$ > } else if (!currentJarUrl.substring(currentJarUrl.length() - 4) > .equalsIgnoreCase(".jar")) { //$NON-NLS-1$ > getPreferenceStore().putValue(IJADConstants.JAD_MIDLET_JAR_URL, >@@ -170,9 +184,11 @@ > .equalsIgnoreCase(".jar")) { //$NON-NLS-1$ > getPreferenceStore().putValue(IJADConstants.JAD_MIDLET_JAR_URL, > loadedJarUrl); >- getErrorMessageManager().removeAllMessages(); >+ getErrorMessageManager() >+ .removeMessage( >+ "textLength_" + MTJUIMessages.RequiredJADDesciptorsProvider_midlet_jar_url, jarURLControl); //$NON-NLS-1$ > } >- >+ > if (!currentJarUrl.equals(loadedJarUrl)) { > ((JADFormEditor) getEditor()).setCleanRequired(true); > } >@@ -188,6 +204,48 @@ > } > > } >+ >+ /** >+ * Validate editor fields >+ */ >+ public void validateFields() { >+ IFile applicationDescriptorFile = midletProject >+ .getApplicationDescriptorFile(); >+ try { >+ Utils.removeAllErrorMarkers(applicationDescriptorFile); >+ } catch (CoreException e) { >+ e.printStackTrace(); >+ } >+ >+ for (FieldEditor field : fieldEditors) { >+ if (field instanceof ExtendedStringFieldEditor) { >+ String fieldEditorLabel = field.getLabelText(); >+ Text control = ((ExtendedStringFieldEditor) field) >+ .getFieldEditorTextControl(); >+ if (!fieldEditorLabel >+ .equals(MTJUIMessages.RequiredJADDesciptorsProvider_midlet_jar_url)) { >+ if (control.getText().equals(Utils.EMPTY_STRING)) { >+ getErrorMessageManager() >+ .addMessage( >+ "textLength_" + fieldEditorLabel, //$NON-NLS-1$ >+ MTJUIMessages.OverviewEditorPage_empty_field_error_msg, >+ null, IMessageProvider.ERROR, control); >+ >+ try { >+ Utils >+ .createErrorMarker( >+ applicationDescriptorFile, >+ fieldEditorLabel >+ + ":" //$NON-NLS-1$ >+ + MTJUIMessages.OverviewEditorPage_empty_field_error_msg); >+ } catch (CoreException e) { >+ e.printStackTrace(); >+ } >+ } >+ } >+ } >+ } >+ } > > /* (non-Javadoc) > * @see org.eclipse.mtj.ui.editors.jad.AbstractJADEditorPage#getTitle() >@@ -248,9 +306,6 @@ > .getPreferenceName().equals( > IJADConstants.JAD_MIDLET_JAR_URL)) { > String jarFileName = (String) event.getNewValue(); >- IWorkspace workspace = MTJCore.getWorkspace(); >- IStatus result = workspace.validateName(jarFileName, >- IResource.FILE); > if (!jarFileName.substring(jarFileName.length() - 4) > .equalsIgnoreCase(".jar")) { //$NON-NLS-1$ > getErrorMessageManager() >@@ -258,7 +313,7 @@ > "textLength_" + fieldEditorLabel, //$NON-NLS-1$ > MTJUIMessages.J2MEProjectPropertiesPage_validatePage_jar_error, > null, IMessageProvider.ERROR, c); >- } else if (!result.isOK()) { >+ } else if (!Utils.isValidFileName(jarFileName)) { > getErrorMessageManager() > .addMessage( > "textLength_" + fieldEditorLabel, //$NON-NLS-1$ >@@ -568,6 +623,8 @@ > form.updateToolBar(); > > fillEditorPageBody(managedForm); >+ >+ validateFields(); > } > > /* (non-Javadoc)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
wtv368
:
iplog+
wtv368
:
review+
Actions:
View
|
Diff
Attachments on
bug 246787
:
141572
| 141667