Lines 12-17
Link Here
|
12 |
* standards |
12 |
* standards |
13 |
* Feng(Marvin) Wang (Sybase) - Add validations. Ensure that user cannot |
13 |
* Feng(Marvin) Wang (Sybase) - Add validations. Ensure that user cannot |
14 |
* create a Midlet in a non-midlet project. |
14 |
* create a Midlet in a non-midlet project. |
|
|
15 |
* Gang Ma (Sybase) - Add validations to ensure that user cannot |
16 |
* create a Non-MIDlet class. |
15 |
*/ |
17 |
*/ |
16 |
package org.eclipse.mtj.ui.internal.wizards.midlet.page; |
18 |
package org.eclipse.mtj.ui.internal.wizards.midlet.page; |
17 |
|
19 |
|
Lines 21-26
Link Here
|
21 |
import org.eclipse.core.runtime.IPath; |
23 |
import org.eclipse.core.runtime.IPath; |
22 |
import org.eclipse.core.runtime.IProgressMonitor; |
24 |
import org.eclipse.core.runtime.IProgressMonitor; |
23 |
import org.eclipse.core.runtime.IStatus; |
25 |
import org.eclipse.core.runtime.IStatus; |
|
|
26 |
import org.eclipse.core.runtime.NullProgressMonitor; |
24 |
import org.eclipse.core.runtime.Path; |
27 |
import org.eclipse.core.runtime.Path; |
25 |
import org.eclipse.core.runtime.Status; |
28 |
import org.eclipse.core.runtime.Status; |
26 |
import org.eclipse.core.runtime.SubProgressMonitor; |
29 |
import org.eclipse.core.runtime.SubProgressMonitor; |
Lines 25-31
Link Here
|
25 |
import org.eclipse.core.runtime.Status; |
28 |
import org.eclipse.core.runtime.Status; |
26 |
import org.eclipse.core.runtime.SubProgressMonitor; |
29 |
import org.eclipse.core.runtime.SubProgressMonitor; |
27 |
import org.eclipse.jdt.core.IJavaElement; |
30 |
import org.eclipse.jdt.core.IJavaElement; |
|
|
31 |
import org.eclipse.jdt.core.IJavaProject; |
28 |
import org.eclipse.jdt.core.IType; |
32 |
import org.eclipse.jdt.core.IType; |
|
|
33 |
import org.eclipse.jdt.core.JavaCore; |
34 |
import org.eclipse.jdt.core.JavaModelException; |
29 |
import org.eclipse.jdt.ui.wizards.NewTypeWizardPage; |
35 |
import org.eclipse.jdt.ui.wizards.NewTypeWizardPage; |
30 |
import org.eclipse.jface.dialogs.Dialog; |
36 |
import org.eclipse.jface.dialogs.Dialog; |
31 |
import org.eclipse.jface.dialogs.IDialogSettings; |
37 |
import org.eclipse.jface.dialogs.IDialogSettings; |
Lines 32-37
Link Here
|
32 |
import org.eclipse.jface.viewers.IStructuredSelection; |
38 |
import org.eclipse.jface.viewers.IStructuredSelection; |
33 |
import org.eclipse.mtj.core.IMTJCoreConstants; |
39 |
import org.eclipse.mtj.core.IMTJCoreConstants; |
34 |
import org.eclipse.mtj.core.internal.MTJCorePlugin; |
40 |
import org.eclipse.mtj.core.internal.MTJCorePlugin; |
|
|
41 |
import org.eclipse.mtj.core.internal.utils.Utils; |
35 |
import org.eclipse.mtj.ui.IMTJUIConstants; |
42 |
import org.eclipse.mtj.ui.IMTJUIConstants; |
36 |
import org.eclipse.mtj.ui.MTJUIStrings; |
43 |
import org.eclipse.mtj.ui.MTJUIStrings; |
37 |
import org.eclipse.mtj.ui.internal.MTJUIPlugin; |
44 |
import org.eclipse.mtj.ui.internal.MTJUIPlugin; |
Lines 153-159
Link Here
|
153 |
} |
160 |
} |
154 |
return containerStatus; |
161 |
return containerStatus; |
155 |
} |
162 |
} |
156 |
|
163 |
/* |
|
|
164 |
* (non-Javadoc) |
165 |
* @see org.eclipse.jdt.ui.wizards.NewTypeWizardPage#superClassChanged() |
166 |
*/ |
167 |
@Override |
168 |
protected IStatus superClassChanged() { |
169 |
IStatus superClassStatus = super.superClassChanged(); |
170 |
boolean isMidlet = false; |
171 |
|
172 |
String sclassName= getSuperClass(); |
173 |
IProject project = getContainedProject(); |
174 |
IJavaProject javaProject = JavaCore.create(project); |
175 |
try { |
176 |
if(javaProject!=null) |
177 |
isMidlet = Utils.isMidlet(javaProject.findType(sclassName),new NullProgressMonitor()); |
178 |
} catch (JavaModelException e) { |
179 |
} |
180 |
|
181 |
if (!isMidlet) { |
182 |
return new Status( |
183 |
IStatus.ERROR, |
184 |
IMTJUIConstants.PLUGIN_ID, |
185 |
MTJUIStrings |
186 |
.getString("wiz.newmidlet.warning.super_not_midlet")); |
187 |
} |
188 |
return superClassStatus; |
189 |
} |
190 |
|
191 |
private IProject getContainedProject(){ |
192 |
IProject prj = null; |
193 |
String str = getPackageFragmentRootText(); |
194 |
IPath path = new Path(str); |
195 |
IResource res = getWorkspaceRoot().findMember(path); |
196 |
if(res!=null) |
197 |
prj = res.getProject(); |
198 |
return prj; |
199 |
} |
157 |
// ------ UI -------- |
200 |
// ------ UI -------- |
158 |
/** |
201 |
/** |
159 |
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) |
202 |
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) |