]> git.uio.no Git - ifi-stolz-refaktor.git/blame - case-study/jdt-after/ui/org/eclipse/jdt/internal/ui/dialogs/StatusInfo.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-after / ui / org / eclipse / jdt / internal / ui / dialogs / StatusInfo.java
CommitLineData
1b2798f6
EK
1/*******************************************************************************
2 * Copyright (c) 2000, 2011 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11package org.eclipse.jdt.internal.ui.dialogs;
12
13import java.io.File;
14import java.io.IOException;
15import java.net.MalformedURLException;
16import java.net.URI;
17import java.net.URL;
18import java.util.ArrayList;
19import java.util.HashSet;
20import java.util.List;
21import java.util.Set;
22
23import org.xml.sax.SAXException;
24
25import org.w3c.dom.Element;
26
27import org.eclipse.core.filesystem.EFS;
28import org.eclipse.core.filesystem.IFileStore;
29
30import org.eclipse.core.runtime.Assert;
31import org.eclipse.core.runtime.CoreException;
32import org.eclipse.core.runtime.IPath;
33import org.eclipse.core.runtime.IStatus;
34import org.eclipse.core.runtime.Path;
35
36import org.eclipse.core.resources.IContainer;
37import org.eclipse.core.resources.IFile;
38import org.eclipse.core.resources.IFolder;
39import org.eclipse.core.resources.IProject;
40import org.eclipse.core.resources.IResource;
41import org.eclipse.core.resources.IWorkspace;
42import org.eclipse.core.resources.IWorkspaceRoot;
43import org.eclipse.core.resources.ResourcesPlugin;
44
45import org.eclipse.jface.dialogs.IDialogSettings;
46
47import org.eclipse.jface.text.templates.TemplateContextType;
48import org.eclipse.jface.text.templates.TemplateException;
49
50import org.eclipse.jdt.core.Flags;
51import org.eclipse.jdt.core.IClasspathAttribute;
52import org.eclipse.jdt.core.IClasspathEntry;
53import org.eclipse.jdt.core.IJavaModelStatus;
54import org.eclipse.jdt.core.IJavaProject;
55import org.eclipse.jdt.core.IPackageFragment;
56import org.eclipse.jdt.core.IPackageFragmentRoot;
57import org.eclipse.jdt.core.JavaConventions;
58import org.eclipse.jdt.core.JavaCore;
59import org.eclipse.jdt.core.JavaModelException;
60import org.eclipse.jdt.core.compiler.IProblem;
61import org.eclipse.jdt.core.dom.ASTParser;
62import org.eclipse.jdt.core.dom.CompilationUnit;
63import org.eclipse.jdt.core.dom.Expression;
64import org.eclipse.jdt.core.dom.IMethodBinding;
65import org.eclipse.jdt.core.dom.ITypeBinding;
66import org.eclipse.jdt.core.dom.MethodInvocation;
67import org.eclipse.jdt.core.dom.ParameterizedType;
68import org.eclipse.jdt.core.dom.Type;
69import org.eclipse.jdt.core.dom.VariableDeclarationExpression;
70import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
71
72import org.eclipse.jdt.internal.corext.fix.ConvertIterableLoopOperation;
73import org.eclipse.jdt.internal.corext.fix.ConvertLoopOperation;
74import org.eclipse.jdt.internal.corext.refactoring.TypeContextChecker;
75import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
76import org.eclipse.jdt.internal.corext.util.Messages;
77
78import org.eclipse.jdt.ui.JavaUI;
79import org.eclipse.jdt.ui.PreferenceConstants;
80import org.eclipse.jdt.ui.wizards.NewContainerWizardPage;
81import org.eclipse.jdt.ui.wizards.NewElementWizardPage;
82import org.eclipse.jdt.ui.wizards.NewTypeWizardPage;
83import org.eclipse.jdt.ui.wizards.NewTypeWizardPage.InterfaceWrapper;
84
85import org.eclipse.jdt.internal.ui.JavaPlugin;
86import org.eclipse.jdt.internal.ui.JavaUIMessages;
87import org.eclipse.jdt.internal.ui.callhierarchy.CallHierarchyMessages;
88import org.eclipse.jdt.internal.ui.callhierarchy.ExpandWithConstructorsConfigurationBlock.CallHierarchyTypesOrMembersDialog;
89import org.eclipse.jdt.internal.ui.dialogs.GenerateToStringDialog.ToStringTemplatesDialog;
90import org.eclipse.jdt.internal.ui.javadocexport.JavadocExportMessages;
91import org.eclipse.jdt.internal.ui.javadocexport.JavadocOptionsManager;
92import org.eclipse.jdt.internal.ui.javadocexport.JavadocReader;
93import org.eclipse.jdt.internal.ui.javadocexport.RecentSettingsStore;
94import org.eclipse.jdt.internal.ui.javaeditor.ASTProvider;
95import org.eclipse.jdt.internal.ui.preferences.CodeAssistAdvancedConfigurationBlock;
96import org.eclipse.jdt.internal.ui.preferences.CodeAssistFavoritesConfigurationBlock.FavoriteStaticMemberInputDialog;
97import org.eclipse.jdt.internal.ui.preferences.ComplianceConfigurationBlock;
98import org.eclipse.jdt.internal.ui.preferences.EditTemplateDialog;
99import org.eclipse.jdt.internal.ui.preferences.ImportOrganizeConfigurationBlock;
100import org.eclipse.jdt.internal.ui.preferences.ImportOrganizeInputDialog;
101import org.eclipse.jdt.internal.ui.preferences.JavaEditorHoverConfigurationBlock;
102import org.eclipse.jdt.internal.ui.preferences.JavadocConfigurationBlock;
103import org.eclipse.jdt.internal.ui.preferences.PreferencesMessages;
104import org.eclipse.jdt.internal.ui.preferences.TodoTaskInputDialog;
105import org.eclipse.jdt.internal.ui.preferences.TypeFilterInputDialog;
106import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels;
107import org.eclipse.jdt.internal.ui.wizards.NewSourceFolderWizardPage;
108import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages;
109import org.eclipse.jdt.internal.ui.wizards.buildpaths.AccessRuleEntryDialog;
110import org.eclipse.jdt.internal.ui.wizards.buildpaths.AddSourceFolderWizardPage;
111import org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathSupport;
112import org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathsBlock;
113import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement;
114import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPVariableElement;
115import org.eclipse.jdt.internal.ui.wizards.buildpaths.ClasspathContainerDefaultPage;
116import org.eclipse.jdt.internal.ui.wizards.buildpaths.EditVariableEntryDialog;
117import org.eclipse.jdt.internal.ui.wizards.buildpaths.ExclusionInclusionEntryDialog;
118import org.eclipse.jdt.internal.ui.wizards.buildpaths.NewContainerDialog;
119import org.eclipse.jdt.internal.ui.wizards.buildpaths.NewSourceFolderDialog;
120import org.eclipse.jdt.internal.ui.wizards.buildpaths.NewVariableEntryDialog;
121import org.eclipse.jdt.internal.ui.wizards.buildpaths.SourceAttachmentBlock;
122import org.eclipse.jdt.internal.ui.wizards.buildpaths.VariableCreationDialog;
123
124/**
125 * A settable IStatus.
126 * Can be an error, warning, info or ok. For error, info and warning states,
127 * a message describes the problem.
128 */
129public class StatusInfo implements IStatus {
130
131 public static final IStatus OK_STATUS= new StatusInfo();
132
133 private String fStatusMessage;
134 private int fSeverity;
135
136 /**
137 * Creates a status set to OK (no message)
138 */
139 public StatusInfo() {
140 this(OK, null);
141 }
142
143 /**
144 * Creates a status .
145 * @param severity The status severity: ERROR, WARNING, INFO and OK.
146 * @param message The message of the status. Applies only for ERROR,
147 * WARNING and INFO.
148 */
149 public StatusInfo(int severity, String message) {
150 fStatusMessage= message;
151 fSeverity= severity;
152 }
153
154 /**
155 * Returns if the status' severity is OK.
156 */
157 public boolean isOK() {
158 return fSeverity == IStatus.OK;
159 }
160
161 /**
162 * Returns if the status' severity is WARNING.
163 */
164 public boolean isWarning() {
165 return fSeverity == IStatus.WARNING;
166 }
167
168 /**
169 * Returns if the status' severity is INFO.
170 */
171 public boolean isInfo() {
172 return fSeverity == IStatus.INFO;
173 }
174
175 /**
176 * Returns if the status' severity is ERROR.
177 */
178 public boolean isError() {
179 return fSeverity == IStatus.ERROR;
180 }
181
182 /**
183 * @see IStatus#getMessage
184 */
185 public String getMessage() {
186 return fStatusMessage;
187 }
188
189 /**
190 * Sets the status to ERROR.
191 * @param errorMessage The error message (can be empty, but not null)
192 */
193 public void setError(String errorMessage) {
194 Assert.isNotNull(errorMessage);
195 fStatusMessage= errorMessage;
196 fSeverity= IStatus.ERROR;
197 }
198
199 /**
200 * Sets the status to WARNING.
201 * @param warningMessage The warning message (can be empty, but not null)
202 */
203 public void setWarning(String warningMessage) {
204 Assert.isNotNull(warningMessage);
205 fStatusMessage= warningMessage;
206 fSeverity= IStatus.WARNING;
207 }
208
209 /**
210 * Sets the status to INFO.
211 * @param infoMessage The info message (can be empty, but not null)
212 */
213 public void setInfo(String infoMessage) {
214 Assert.isNotNull(infoMessage);
215 fStatusMessage= infoMessage;
216 fSeverity= IStatus.INFO;
217 }
218
219 /**
220 * Sets the status to OK.
221 */
222 public void setOK() {
223 fStatusMessage= null;
224 fSeverity= IStatus.OK;
225 }
226
227 /*
228 * @see IStatus#matches(int)
229 */
230 public boolean matches(int severityMask) {
231 return (fSeverity & severityMask) != 0;
232 }
233
234 /**
235 * Returns always <code>false</code>.
236 * @see IStatus#isMultiStatus()
237 */
238 public boolean isMultiStatus() {
239 return false;
240 }
241
242 /*
243 * @see IStatus#getSeverity()
244 */
245 public int getSeverity() {
246 return fSeverity;
247 }
248
249 /*
250 * @see IStatus#getPlugin()
251 */
252 public String getPlugin() {
253 return JavaUI.ID_PLUGIN;
254 }
255
256 /**
257 * Returns always <code>null</code>.
258 * @see IStatus#getException()
259 */
260 public Throwable getException() {
261 return null;
262 }
263
264 /**
265 * Returns always the error severity.
266 * @see IStatus#getCode()
267 */
268 public int getCode() {
269 return fSeverity;
270 }
271
272 /**
273 * Returns always an empty array.
274 * @see IStatus#getChildren()
275 */
276 public IStatus[] getChildren() {
277 return new IStatus[0];
278 }
279
280 /**
281 * Returns a string representation of the status, suitable
282 * for debugging purposes only.
283 */
284 @Override
285 public String toString() {
286 StringBuffer buf = new StringBuffer();
287 buf.append("StatusInfo "); //$NON-NLS-1$
288 if (fSeverity == OK) {
289 buf.append("OK"); //$NON-NLS-1$
290 } else if (fSeverity == ERROR) {
291 buf.append("ERROR"); //$NON-NLS-1$
292 } else if (fSeverity == WARNING) {
293 buf.append("WARNING"); //$NON-NLS-1$
294 } else if (fSeverity == INFO) {
295 buf.append("INFO"); //$NON-NLS-1$
296 } else {
297 buf.append("severity="); //$NON-NLS-1$
298 buf.append(fSeverity);
299 }
300 buf.append(": "); //$NON-NLS-1$
301 buf.append(fStatusMessage);
302 return buf.toString();
303 }
304
305 public void generated_3764810824622344715(CallHierarchyTypesOrMembersDialog callhierarchytypesormembersdialog, String newText) {
306 if (newText.length() == 0) {
307 setError(""); //$NON-NLS-1$
308 } else {
309 IStatus val= JavaConventions.validateJavaTypeName(newText, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3);
310 if (val.matches(IStatus.ERROR)) {
311 if (callhierarchytypesormembersdialog.fIsEditingMember)
312 setError(CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_error_invalidMemberName);
313 else
314 setError(CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_error_invalidTypeName);
315 } else {
316 if (callhierarchytypesormembersdialog.doesExist(newText)) {
317 setError(CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_error_entryExists);
318 }
319 }
320 }
321 }
322
323 public void generated_5489507237624631287(ToStringTemplatesDialog tostringtemplatesdialog) {
324 if (tostringtemplatesdialog.templateNames.size() > 0)
325 setOK();
326 else
327 setError(JavaUIMessages.GenerateToStringDialog_templateManagerNoTemplateErrorMessage);
328 }
329
330 public IStatus generated_2255846643577716416() {
331 setOK();
332 return this;
333 }
334
335 public IStatus generated_7935792217506682991(Object[] selection) {
336 if (selection.length == 1 && (selection[0] instanceof IFile))
337 setOK();
338 else
339 setError(""); //$NON-NLS-1$
340 return this;
341 }
342
343 public void generated_4279979400183450065(String filename) {
344 if (filename.length() == 0) {
345 setError(JavadocExportMessages.JavadocSpecificsWizardPage_overviewnotfound_error);
346 } else {
347 File file= new File(filename);
348 String ext= filename.substring(filename.lastIndexOf('.') + 1);
349 if (!file.isFile()) {
350 setError(JavadocExportMessages.JavadocSpecificsWizardPage_overviewnotfound_error);
351 } else if (!ext.equalsIgnoreCase("html")) { //$NON-NLS-1$
352 setError(JavadocExportMessages.JavadocSpecificsWizardPage_overviewincorrect_error);
353 }
354 }
355 }
356
357 public void generated_4744902361355361343(String filename) {
358 if (filename.length() == 0) {
359 setError(JavadocExportMessages.JavadocSpecificsWizardPage_overviewnotfound_error);
360 } else {
361 File file= new File(filename);
362 String ext= filename.substring(filename.lastIndexOf('.') + 1);
363 if (!file.isFile()) {
364 setError(JavadocExportMessages.JavadocStandardWizardPage_stylesheetnopath_error);
365 } else if (!ext.equalsIgnoreCase("css")) { //$NON-NLS-1$
366 setError(JavadocExportMessages.JavadocStandardWizardPage_stylesheetnotcss_error);
367 }
368 }
369 }
370
371 public void generated_7330943458652497803(String dest) {
372 if (dest.length() == 0) {
373 setError(JavadocExportMessages.JavadocTreeWizardPage_nodestination_error);
374 }
375 File file= new File(dest);
376 if (!Path.ROOT.isValidPath(dest) || file.isFile()) {
377 setError(JavadocExportMessages.JavadocTreeWizardPage_invaliddestination_error);
378 }
379 if (new File(dest, "package-list").exists() || new File(dest, "index.html").exists()) //$NON-NLS-1$//$NON-NLS-2$
380 setWarning(JavadocExportMessages.JavadocTreeWizardPage_warning_mayoverwritefiles);
381 }
382
383 public void generated_7526970014727274382(JavadocOptionsManager javadocoptionsmanager, IFile xmlJavadocFile, List<?> currSelection, IDialogSettings javadocSection, String commandHistory) {
384 if (commandHistory == null || commandHistory.length() == 0) {
385 commandHistory= JavadocOptionsManager.initJavadocCommandDefault();
386 }
387 javadocoptionsmanager.fJavadocCommandHistory= javadocoptionsmanager.arrayFromFlatString(commandHistory);
388
389 javadocoptionsmanager.fRecentSettings= new RecentSettingsStore(javadocSection);
390
391 if (xmlJavadocFile != null) {
392 try {
393 JavadocReader reader= new JavadocReader(xmlJavadocFile.getContents());
394 Element element= reader.readXML();
395 if (element != null) {
396 javadocoptionsmanager.loadFromXML(element);
397 return;
398 }
399 setWarning(JavadocExportMessages.JavadocOptionsManager_antfileincorrectCE_warning);
400 } catch (CoreException e) {
401 JavaPlugin.log(e);
402 setWarning(JavadocExportMessages.JavadocOptionsManager_antfileincorrectCE_warning);
403 } catch (IOException e) {
404 JavaPlugin.log(e);
405 setWarning(JavadocExportMessages.JavadocOptionsManager_antfileincorrectIOE_warning);
406 } catch (SAXException e) {
407 setWarning(JavadocExportMessages.JavadocOptionsManager_antfileincorrectSAXE_warning);
408 }
409 }
410 if (javadocSection != null) {
411 javadocoptionsmanager.loadFromDialogStore(javadocSection, currSelection);
412 } else {
413 javadocoptionsmanager.loadDefaults(currSelection);
414 }
415 }
416
417 public void generated_350887177935622380(TodoTaskInputDialog todotaskinputdialog) {
418 String newText= todotaskinputdialog.fNameDialogField.getText();
419 if (newText.length() == 0) {
420 setError(PreferencesMessages.TodoTaskInputDialog_error_enterName);
421 } else {
422 if (newText.indexOf(',') != -1) {
423 setError(PreferencesMessages.TodoTaskInputDialog_error_comma);
424 } else if (todotaskinputdialog.fExistingNames.contains(newText)) {
425 setError(PreferencesMessages.TodoTaskInputDialog_error_entryExists);
426 } else if (Character.isWhitespace(newText.charAt(0)) || Character.isWhitespace(newText.charAt(newText.length() - 1))) {
427 setError(PreferencesMessages.TodoTaskInputDialog_error_noSpace);
428 }
429 }
430 }
431
432 public void generated_7791403050701141905(JavaEditorHoverConfigurationBlock javaeditorhoverconfigurationblock) {
433 javaeditorhoverconfigurationblock.fMainPreferencePage.setValid(isOK());
434 StatusUtil.applyToStatusLine(javaeditorhoverconfigurationblock.fMainPreferencePage, this);
435 }
436
437 public void generated_5958990709099104451(EditTemplateDialog edittemplatedialog, String text) {
438 setOK();
439 TemplateContextType contextType= edittemplatedialog.fContextTypeRegistry.getContextType(edittemplatedialog.getContextId());
440 if (contextType != null) {
441 try {
442 contextType.validate(text);
443 } catch (TemplateException e) {
444 setError(e.getLocalizedMessage());
445 }
446 }
447 }
448
449 public IStatus generated_8407535136467552723(String number) {
450 if (number.length() == 0) {
451 setError(PreferencesMessages.JavaEditorPreferencePage_empty_input);
452 } else {
453 try {
454 int value= Integer.parseInt(number);
455 if (value < 0)
456 setError(Messages.format(PreferencesMessages.JavaEditorPreferencePage_invalid_input, number));
457 } catch (NumberFormatException e) {
458 setError(Messages.format(PreferencesMessages.JavaEditorPreferencePage_invalid_input, number));
459 }
460 }
461 return this;
462 }
463
464 public void generated_1784172337949317156(ImportOrganizeInputDialog importorganizeinputdialog) {
465 String newText= importorganizeinputdialog.fNameDialogField.getText();
466 if (newText.length() == 0) {
467 setError(""); //$NON-NLS-1$
468 } else {
469 if (newText.equals("*")) { //$NON-NLS-1$
470 if (importorganizeinputdialog.doesExist("", importorganizeinputdialog.fIsStatic)) { //$NON-NLS-1$
471 setError(PreferencesMessages.ImportOrganizeInputDialog_error_entryExists);
472 }
473 } else {
474 IStatus val= JavaConventions.validateJavaTypeName(newText, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3);
475 if (val.matches(IStatus.ERROR)) {
476 setError(PreferencesMessages.ImportOrganizeInputDialog_error_invalidName);
477 } else {
478 if (importorganizeinputdialog.doesExist(newText, importorganizeinputdialog.fIsStatic)) {
479 setError(PreferencesMessages.ImportOrganizeInputDialog_error_entryExists);
480 }
481 }
482 }
483 }
484 }
485
486 public IStatus generated_4175166827632687071(String compliance, String source, String target) {
487 if (JavaModelUtil.isVersionLessThan(compliance, source)) {
488 setError(PreferencesMessages.ComplianceConfigurationBlock_src_greater_compliance);
489 return this;
490 }
491
492 if (JavaModelUtil.isVersionLessThan(compliance, target)) {
493 setError(PreferencesMessages.ComplianceConfigurationBlock_classfile_greater_compliance);
494 return this;
495 }
496
497 if (ComplianceConfigurationBlock.VERSION_CLDC_1_1.equals(target)) {
498 if (!ComplianceConfigurationBlock.VERSION_1_3.equals(source) || !JavaModelUtil.isVersionLessThan(compliance, ComplianceConfigurationBlock.VERSION_1_5)) {
499 setError(PreferencesMessages.ComplianceConfigurationBlock_cldc11_requires_source13_compliance_se14);
500 return this;
501 }
502 }
503
504 // target must not be smaller than source
505 if (!ComplianceConfigurationBlock.VERSION_1_3.equals(source) && JavaModelUtil.isVersionLessThan(target, source)) {
506 setError(PreferencesMessages.ComplianceConfigurationBlock_classfile_greater_source);
507 return this;
508 }
509
510 return this;
511 }
512
513 public IStatus generated_4057359700242502578(String value, String errorMessage) {
514 if (JavaConventions.validateJavaTypeName(value, JavaCore.VERSION_1_5, JavaCore.VERSION_1_5).matches(IStatus.ERROR)
515 || value.indexOf('.') == -1)
516 setError(errorMessage);
517 return this;
518 }
519
520 public void generated_9109049189476184915(String newValue, CodeAssistAdvancedConfigurationBlock codeassistadvancedconfigurationblock) {
521 if (newValue.length() == 0)
522 setError(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_parameterNameFromAttachedJavadoc_timeout_emptyInput);
523 else {
524 try {
525 int number= Integer.parseInt(newValue);
526 int min= 0;
527 int max= 5000;
528 if (number < min || number > max) {
529 String msgFormat= PreferencesMessages.CodeAssistAdvancedConfigurationBlock_parameterNameFromAttachedJavadoc_timeout_invalidRange;
530 String msg= Messages.format(msgFormat, new Object[] {new Integer(min), new Integer(max)});
531 setError(msg);
532 }
533 } catch (NumberFormatException ex) {
534 String msgFormat= PreferencesMessages.CodeAssistAdvancedConfigurationBlock_parameterNameFromAttachedJavadoc_timeout_invalidInput;
535 String msg= Messages.format(msgFormat, newValue);
536 setError(msg);
537 }
538 }
539 codeassistadvancedconfigurationblock.fContext.statusChanged(this);
540 }
541
542 public IStatus generated_30797182611047098(String number) {
543 if (number.length() == 0) {
544 setError(PreferencesMessages.JavaBuildConfigurationBlock_empty_input);
545 } else {
546 try {
547 int value= Integer.parseInt(number);
548 if (value <= 0) {
549 setError(Messages.format(PreferencesMessages.JavaBuildConfigurationBlock_invalid_input, number));
550 }
551 } catch (NumberFormatException e) {
552 setError(Messages.format(PreferencesMessages.JavaBuildConfigurationBlock_invalid_input, number));
553 }
554 }
555 return this;
556 }
557
558 public void generated_8815789725177820272(FavoriteStaticMemberInputDialog favoritestaticmemberinputdialog, String newText) {
559 if (newText.length() == 0) {
560 setError(""); //$NON-NLS-1$
561 } else {
562 IStatus val= JavaConventions.validateJavaTypeName(newText, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3);
563 if (val.matches(IStatus.ERROR)) {
564 if (favoritestaticmemberinputdialog.fIsEditingMember)
565 setError(PreferencesMessages.FavoriteStaticMemberInputDialog_error_invalidMemberName);
566 else
567 setError(PreferencesMessages.FavoriteStaticMemberInputDialog_error_invalidTypeName);
568 } else {
569 if (favoritestaticmemberinputdialog.doesExist(newText)) {
570 setError(PreferencesMessages.FavoriteStaticMemberInputDialog_error_entryExists);
571 }
572 }
573 }
574 }
575
576 public boolean generated_3869218788986760585(ImportOrganizeConfigurationBlock importorganizeconfigurationblock) {
577 importorganizeconfigurationblock.updateStatus(this);
578 return isOK();
579 }
580
581 public void generated_2123518839692534937(TypeFilterInputDialog typefilterinputdialog) {
582 String newText= typefilterinputdialog.fNameDialogField.getText();
583 if (newText.length() == 0) {
584 setError(PreferencesMessages.TypeFilterInputDialog_error_enterName);
585 } else {
586 newText= newText.replace('*', 'X').replace('?', 'Y');
587 IStatus val= JavaConventions.validatePackageName(newText, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3);
588 if (val.matches(IStatus.ERROR)) {
589 setError(Messages.format(PreferencesMessages.TypeFilterInputDialog_error_invalidName, val.getMessage()));
590 } else {
591 if (typefilterinputdialog.fExistingEntries.contains(newText)) {
592 setError(PreferencesMessages.TypeFilterInputDialog_error_entryExists);
593 }
594 }
595 }
596 }
597
598 public IStatus generated_4116422634809019126(String val) {
599 if (val.length() == 0) {
600 return this;
601 }
602 Path path= new Path(val);
603 if (path.isAbsolute()) {
604 if (!path.toFile().isDirectory()) {
605 setWarning(NewWizardMessages.NativeLibrariesDialog_error_external_not_existing);
606 return this;
607 }
608 } else {
609 if (!(ResourcesPlugin.getWorkspace().getRoot().findMember(path) instanceof IContainer)) {
610 setWarning(NewWizardMessages.NativeLibrariesDialog_error_internal_not_existing);
611 return this;
612 }
613 }
614 return this;
615 }
616
617 public IStatus generated_7084452779791600753(JavadocConfigurationBlock javadocconfigurationblock) {
618 try {
619 String jdocLocation= javadocconfigurationblock.fURLField.getText();
620 if (jdocLocation.length() == 0) {
621 return this;
622 }
623 URL url= new URL(jdocLocation);
624 if ("file".equals(url.getProtocol())) { //$NON-NLS-1$
625 if (url.getFile() == null) {
626 setError(PreferencesMessages.JavadocConfigurationBlock_error_notafolder);
627 return this;
628 }
629 }
630 javadocconfigurationblock.fURLResult= url;
631 } catch (MalformedURLException e) {
632 setError(PreferencesMessages.JavadocConfigurationBlock_MalformedURL_error);
633 return this;
634 }
635
636 return this;
637 }
638
639 public IStatus generated_8875932454098679827(JavadocConfigurationBlock javadocconfigurationblock, String jdocLocation) throws MalformedURLException {
640 if (jdocLocation.length() > 0) {
641 if (!Path.ROOT.isValidPath(jdocLocation)) {
642 setError(PreferencesMessages.JavadocConfigurationBlock_error_invalidarchivepath);
643 return this;
644 }
645 if (javadocconfigurationblock.fWorkspaceRadio.isSelected()) {
646 IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
647 IResource res= root.findMember(new Path(jdocLocation));
648 if (res != null) {
649 if (!(res instanceof IFile)) {
650 setError(PreferencesMessages.JavadocConfigurationBlock_error_archive_not_found_in_workspace);
651 return this;
652 }
653 } else {
654 setError(PreferencesMessages.JavadocConfigurationBlock_error_archive_not_found_in_workspace);
655 return this;
656 }
657 } else {
658 IPath path= Path.fromOSString(jdocLocation);
659 if (!path.isAbsolute()) {
660 setError(PreferencesMessages.JavadocConfigurationBlock_error_archivepathnotabsolute);
661 return this;
662 }
663 File jarFile= new File(jdocLocation);
664 if (jarFile.isDirectory()) {
665 setError(PreferencesMessages.JavadocConfigurationBlock_error_notafile);
666 return this;
667 }
668 if (!jarFile.exists()) {
669 setWarning(PreferencesMessages.JavadocConfigurationBlock_error_notafile);
670 }
671 }
672 javadocconfigurationblock.fArchiveURLResult= javadocconfigurationblock.getArchiveURL();
673 }
674 return this;
675 }
676
677 public IStatus generated_2421717078021888208(MalformedURLException e) {
678 setError(e.getMessage());
679 //status.setError(PreferencesMessages.getString("JavadocConfigurationBlock.MalformedURL.error")); //$NON-NLS-1$
680 return this;
681 }
682
683 public void generated_6551968891510580693(NewSourceFolderWizardPage newsourcefolderwizardpage) {
684 String str= newsourcefolderwizardpage.fProjectField.getText();
685 if (str.length() == 0) {
686 setError(NewWizardMessages.NewSourceFolderWizardPage_error_EnterProjectName);
687 return;
688 }
689 IPath path= new Path(str);
690 if (path.segmentCount() != 1) {
691 setError(NewWizardMessages.NewSourceFolderWizardPage_error_InvalidProjectPath);
692 return;
693 }
694 IProject project= newsourcefolderwizardpage.fWorkspaceRoot.getProject(path.toString());
695 if (!project.exists()) {
696 setError(NewWizardMessages.NewSourceFolderWizardPage_error_ProjectNotExists);
697 return;
698 }
699 if (!project.isOpen()) {
700 setError(NewWizardMessages.NewSourceFolderWizardPage_error_ProjectNotOpen);
701 return;
702 }
703 try {
704 if (project.hasNature(JavaCore.NATURE_ID)) {
705 newsourcefolderwizardpage.fCurrJProject= JavaCore.create(project);
706 newsourcefolderwizardpage.fEntries= newsourcefolderwizardpage.fCurrJProject.getRawClasspath();
707 newsourcefolderwizardpage.fOutputLocation= newsourcefolderwizardpage.fCurrJProject.getOutputLocation();
708 setOK();
709 return;
710 }
711 } catch (CoreException e) {
712 JavaPlugin.log(e);
713 newsourcefolderwizardpage.fCurrJProject= null;
714 }
715 setError(NewWizardMessages.NewSourceFolderWizardPage_error_NotAJavaProject);
716 }
717
718 public void generated_8639980978936459268(NewSourceFolderWizardPage newsourcefolderwizardpage) {
719 setOK();
720
721 IPath projPath= newsourcefolderwizardpage.fCurrJProject.getProject().getFullPath();
722 String str= newsourcefolderwizardpage.fRootDialogField.getText();
723 if (str.length() == 0) {
724 setError(Messages.format(NewWizardMessages.NewSourceFolderWizardPage_error_EnterRootName, BasicElementLabels.getPathLabel(newsourcefolderwizardpage.fCurrJProject.getPath(), false)));
725 } else {
726 IPath path= projPath.append(str);
727 IStatus validate= newsourcefolderwizardpage.fWorkspaceRoot.getWorkspace().validatePath(path.toString(), IResource.FOLDER);
728 if (validate.matches(IStatus.ERROR)) {
729 setError(Messages.format(NewWizardMessages.NewSourceFolderWizardPage_error_InvalidRootName, validate.getMessage()));
730 } else {
731 IResource res= newsourcefolderwizardpage.fWorkspaceRoot.findMember(path);
732 if (res != null) {
733 if (res.getType() != IResource.FOLDER) {
734 setError(NewWizardMessages.NewSourceFolderWizardPage_error_NotAFolder);
735 return;
736 }
737 if (res.isVirtual()) {
738 setError(NewWizardMessages.NewSourceFolderWizardPage_error_FolderIsVirtual);
739 return;
740 }
741 } else {
742 if (!ResourcesPlugin.getWorkspace().validateFiltered(newsourcefolderwizardpage.fWorkspaceRoot.getFolder(path)).isOK()) {
743 setError(NewWizardMessages.NewSourceFolderWizardPage_error_FolderNameFiltered);
744 return;
745 }
746 URI projLocation= newsourcefolderwizardpage.fCurrJProject.getProject().getLocationURI();
747 if (projLocation != null) {
748 try {
749 IFileStore store= EFS.getStore(projLocation).getChild(str);
750 if (store.fetchInfo().exists()) {
751 setError(NewWizardMessages.NewSourceFolderWizardPage_error_AlreadyExistingDifferentCase);
752 return;
753 }
754 } catch (CoreException e) {
755 // we couldn't create the file store. Ignore the exception
756 // since we can't check if the file exist. Pretend that it
757 // doesn't.
758 }
759 }
760 }
761 ArrayList<IClasspathEntry> newEntries= new ArrayList<IClasspathEntry>(newsourcefolderwizardpage.fEntries.length + 1);
762 int projectEntryIndex= -1;
763
764 for (int i= 0; i < newsourcefolderwizardpage.fEntries.length; i++) {
765 IClasspathEntry curr= newsourcefolderwizardpage.fEntries[i];
766 if (curr.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
767 if (path.equals(curr.getPath())) {
768 setError(NewWizardMessages.NewSourceFolderWizardPage_error_AlreadyExisting);
769 return;
770 }
771 if (projPath.equals(curr.getPath())) {
772 projectEntryIndex= i;
773 }
774 }
775 newEntries.add(curr);
776 }
777
778 IClasspathAttribute[] attributes;
779 if (newsourcefolderwizardpage.fIgnoreOptionalProblemsField.isSelected()) {
780 attributes= new IClasspathAttribute[] { NewSourceFolderWizardPage.ATTR_IGNORE_OPTIONAL_PROBLEMS_TRUE };
781 } else {
782 attributes= new IClasspathAttribute[] {};
783 }
784 IClasspathEntry newEntry= JavaCore.newSourceEntry(path, null, null, null, attributes);
785
786 Set<IClasspathEntry> modified= new HashSet<IClasspathEntry>();
787 if (newsourcefolderwizardpage.fExcludeInOthersFields.isSelected()) {
788 newsourcefolderwizardpage.addExclusionPatterns(newEntry, newEntries, modified);
789 IClasspathEntry entry= JavaCore.newSourceEntry(path, null, null, null, attributes);
790 newsourcefolderwizardpage.insertAtEndOfCategory(entry, newEntries);
791 } else {
792 if (projectEntryIndex != -1) {
793 newsourcefolderwizardpage.fIsProjectAsSourceFolder= true;
794 newEntries.set(projectEntryIndex, newEntry);
795 } else {
796 IClasspathEntry entry= JavaCore.newSourceEntry(path, null, null, null, attributes);
797 newsourcefolderwizardpage.insertAtEndOfCategory(entry, newEntries);
798 }
799 }
800
801 newsourcefolderwizardpage.fNewEntries= newEntries.toArray(new IClasspathEntry[newEntries.size()]);
802 newsourcefolderwizardpage.fNewOutputLocation= newsourcefolderwizardpage.fOutputLocation;
803
804 IJavaModelStatus status= JavaConventions.validateClasspath(newsourcefolderwizardpage.fCurrJProject, newsourcefolderwizardpage.fNewEntries, newsourcefolderwizardpage.fNewOutputLocation);
805 if (!status.isOK()) {
806 if (newsourcefolderwizardpage.fOutputLocation.equals(projPath)) {
807 newsourcefolderwizardpage.fNewOutputLocation= projPath.append(PreferenceConstants.getPreferenceStore().getString(PreferenceConstants.SRCBIN_BINNAME));
808 IStatus status2= JavaConventions.validateClasspath(newsourcefolderwizardpage.fCurrJProject, newsourcefolderwizardpage.fNewEntries, newsourcefolderwizardpage.fNewOutputLocation);
809 if (status2.isOK()) {
810 if (newsourcefolderwizardpage.fIsProjectAsSourceFolder) {
811 setInfo(Messages.format(NewWizardMessages.NewSourceFolderWizardPage_warning_ReplaceSFandOL, BasicElementLabels.getPathLabel(newsourcefolderwizardpage.fNewOutputLocation, false)));
812 } else {
813 setInfo(Messages.format(NewWizardMessages.NewSourceFolderWizardPage_warning_ReplaceOL, BasicElementLabels.getPathLabel(newsourcefolderwizardpage.fNewOutputLocation, false)));
814 }
815 return;
816 }
817 }
818 setError(status.getMessage());
819 return;
820 } else if (newsourcefolderwizardpage.fIsProjectAsSourceFolder) {
821 setInfo(NewWizardMessages.NewSourceFolderWizardPage_warning_ReplaceSF);
822 return;
823 }
824 if (!modified.isEmpty()) {
825 String info= modified.size() == 1 ? Messages.format(NewWizardMessages.NewSourceFolderWizardPage_warning_AddedExclusions_singular, (modified.iterator().next())
826 .getPath()) : Messages.format(NewWizardMessages.NewSourceFolderWizardPage_warning_AddedExclusions_plural, String.valueOf(modified.size()));
827 setInfo(info);
828 return;
829 }
830 }
831 }
832 }
833
834 public boolean generated_6969006136874365073(boolean isValidSelection, boolean canExtend, NewVariableEntryDialog newvariableentrydialog) {
835 List<CPVariableElement> selected= newvariableentrydialog.fVariablesList.getSelectedElements();
836 int nSelected= selected.size();
837
838 if (nSelected > 0) {
839 newvariableentrydialog.fResultPaths= new Path[nSelected];
840 for (int i= 0; i < nSelected; i++) {
841 CPVariableElement curr= selected.get(i);
842 newvariableentrydialog.fResultPaths[i]= new Path(curr.getName());
843 File file= curr.getPath().toFile();
844 if (!file.exists()) {
845 setError(NewWizardMessages.NewVariableEntryDialog_info_notexists);
846 isValidSelection= false;
847 break;
848 }
849 if (file.isDirectory()) {
850 canExtend= true;
851 }
852 }
853 } else {
854 isValidSelection= false;
855 setInfo(NewWizardMessages.NewVariableEntryDialog_info_noselection);
856 }
857 if (isValidSelection && nSelected > 1) {
858 String str= Messages.format(NewWizardMessages.NewVariableEntryDialog_info_selected, String.valueOf(nSelected));
859 setInfo(str);
860 }
861 newvariableentrydialog.fCanExtend= nSelected == 1 && canExtend;
862 return isValidSelection;
863 }
864
865 public void generated_5389861987696786622(AccessRuleEntryDialog accessruleentrydialog, String pattern) {
866 if (pattern.length() == 0) {
867 setError(NewWizardMessages.TypeRestrictionEntryDialog_error_empty);
868 return;
869 }
870 IPath path= new Path(pattern);
871 if (path.isAbsolute() || path.getDevice() != null) {
872 setError(NewWizardMessages.TypeRestrictionEntryDialog_error_notrelative);
873 return;
874 }
875
876 accessruleentrydialog.fPattern= pattern;
877 setOK();
878 }
879
880 public void generated_9003560349547791014(BuildPathsBlock buildpathsblock, String text) {
881 if ("".equals(text)) { //$NON-NLS-1$
882 setError(NewWizardMessages.BuildPathsBlock_error_EnterBuildPath);
883 return;
884 }
885 IPath path= buildpathsblock.getOutputLocation();
886 buildpathsblock.fOutputLocationPath= path;
887
888 IResource res= buildpathsblock.fWorkspaceRoot.findMember(path);
889 if (res != null) {
890 // if exists, must be a folder or project
891 if (res.getType() == IResource.FILE) {
892 setError(NewWizardMessages.BuildPathsBlock_error_InvalidBuildPath);
893 return;
894 }
895 }
896
897 setOK();
898
899 String pathStr= buildpathsblock.fBuildPathDialogField.getText();
900 Path outputPath= (new Path(pathStr));
901 pathStr= outputPath.lastSegment();
902 if (pathStr.equals(".settings") && outputPath.segmentCount() == 2) { //$NON-NLS-1$
903 setWarning(NewWizardMessages.OutputLocation_SettingsAsLocation);
904 }
905
906 if (pathStr.charAt(0) == '.' && pathStr.length() > 1) {
907 setWarning(Messages.format(NewWizardMessages.OutputLocation_DotAsLocation, BasicElementLabels.getResourceName(pathStr)));
908 }
909
910 buildpathsblock.updateBuildPathStatus();
911 }
912
913 public void generated_4722824856299309518(BuildPathsBlock buildpathsblock) {
914 List<CPListElement> elements= buildpathsblock.fClassPathList.getElements();
915 IClasspathEntry[] entries= new IClasspathEntry[elements.size()];
916
917 for (int i= elements.size()-1 ; i >= 0 ; i--) {
918 CPListElement currElement= elements.get(i);
919 entries[i]= currElement.getClasspathEntry();
920 }
921
922 IJavaModelStatus status= JavaConventions.validateClasspath(buildpathsblock.fCurrJProject, entries, buildpathsblock.fOutputLocationPath);
923 if (!status.isOK()) {
924 setError(status.getMessage());
925 return;
926 }
927 setOK();
928 }
929
930 public void generated_671000712031234083(ClasspathContainerDefaultPage classpathcontainerdefaultpage, String str) {
931 if (str.length() == 0) {
932 setError(NewWizardMessages.ClasspathContainerDefaultPage_path_error_enterpath);
933 } else if (!Path.ROOT.isValidPath(str)) {
934 setError(NewWizardMessages.ClasspathContainerDefaultPage_path_error_invalidpath);
935 } else {
936 IPath path= new Path(str);
937 if (path.segmentCount() == 0) {
938 setError(NewWizardMessages.ClasspathContainerDefaultPage_path_error_needssegment);
939 } else if (classpathcontainerdefaultpage.fUsedPaths.contains(path)) {
940 setError(NewWizardMessages.ClasspathContainerDefaultPage_path_error_alreadyexists);
941 }
942 }
943 }
944
945 public IStatus generated_3320629973234764359(SourceAttachmentBlock sourceattachmentblock, String fileName) {
946 if (fileName.length() == 0) {
947 // no source attachment
948 return this;
949 } else {
950 if (!Path.EMPTY.isValidPath(fileName)) {
951 setError(NewWizardMessages.SourceAttachmentBlock_filename_error_notvalid);
952 return this;
953 }
954 IPath filePath= Path.fromOSString(fileName);
955 IPath resolvedPath;
956 if (sourceattachmentblock.isVariableEntry()) {
957 if (filePath.getDevice() != null) {
958 setError(NewWizardMessages.SourceAttachmentBlock_filename_error_deviceinpath);
959 return this;
960 }
961 String varName= filePath.segment(0);
962 if (varName == null) {
963 setError(NewWizardMessages.SourceAttachmentBlock_filename_error_notvalid);
964 return this;
965 }
966 sourceattachmentblock.fFileVariablePath= JavaCore.getClasspathVariable(varName);
967 if (sourceattachmentblock.fFileVariablePath == null) {
968 setError(NewWizardMessages.SourceAttachmentBlock_filename_error_varnotexists);
969 return this;
970 }
971 resolvedPath= sourceattachmentblock.fFileVariablePath.append(filePath.removeFirstSegments(1));
972
973 if (resolvedPath.isEmpty()) {
974 setWarning(NewWizardMessages.SourceAttachmentBlock_filename_warning_varempty);
975 return this;
976 }
977 File file= resolvedPath.toFile();
978 if (!file.exists()) {
979 String message= Messages.format(NewWizardMessages.SourceAttachmentBlock_filename_error_filenotexists, BasicElementLabels.getPathLabel(resolvedPath, true));
980 setWarning(message);
981 return this;
982 }
983 if (!resolvedPath.isAbsolute()) {
984 String message= Messages.format(NewWizardMessages.SourceAttachmentBlock_filename_error_notabsolute, BasicElementLabels.getPathLabel(filePath, false));
985 setError(message);
986 return this;
987 }
988
989 String deprecationMessage= BuildPathSupport.getDeprecationMessage(varName);
990 if (deprecationMessage != null) {
991 setWarning(deprecationMessage);
992 return this;
993 }
994
995 } else {
996 // JDT/Core only supports source attachments in archives on the
997 // local file system. So using getLocation is save here.
998 File file= filePath.toFile();
999 IResource res= sourceattachmentblock.fWorkspaceRoot.findMember(filePath);
1000 if (res != null && res.getLocation() != null) {
1001 file= res.getLocation().toFile();
1002 }
1003 if (!file.exists()) {
1004 String message= Messages.format(NewWizardMessages.SourceAttachmentBlock_filename_error_filenotexists, BasicElementLabels.getPathLabel(filePath, false));
1005 setError(message);
1006 return this;
1007 }
1008 if (res == null) {
1009 if (!filePath.isAbsolute()) {
1010 String message= Messages.format(NewWizardMessages.SourceAttachmentBlock_filename_error_notabsolute, BasicElementLabels.getPathLabel(filePath, false));
1011 setError(message);
1012 return this;
1013 }
1014 }
1015 }
1016
1017 }
1018 return this;
1019 }
1020
1021 public void generated_7340645186492419393(NewSourceFolderDialog newsourcefolderdialog) {
1022 newsourcefolderdialog.fFolder= null;
1023 IContainer folder= null;
1024 if (newsourcefolderdialog.fUseFolderButton.isSelected()) {
1025 String pathStr= newsourcefolderdialog.fContainerDialogField.getText();
1026 if (pathStr.length() == 0) {
1027 setError(NewWizardMessages.NewSourceFolderDialog_error_enterpath);
1028 return;
1029 }
1030 IPath path= newsourcefolderdialog.fCurrProject.getFullPath().append(pathStr);
1031 IWorkspace workspace= newsourcefolderdialog.fCurrProject.getWorkspace();
1032
1033 IStatus pathValidation= workspace.validatePath(path.toString(), IResource.FOLDER);
1034 if (!pathValidation.isOK()) {
1035 setError(Messages.format(NewWizardMessages.NewSourceFolderDialog_error_invalidpath, pathValidation.getMessage()));
1036 return;
1037 }
1038 folder= newsourcefolderdialog.fCurrProject.getFolder(pathStr);
1039 } else {
1040 folder= newsourcefolderdialog.fCurrProject;
1041 }
1042 if (newsourcefolderdialog.isExisting(folder)) {
1043 setError(NewWizardMessages.NewSourceFolderDialog_error_pathexists);
1044 return;
1045 }
1046 setOK();
1047 newsourcefolderdialog.fFolder= folder;
1048 }
1049
1050 public void generated_683443080356209627(NewContainerDialog newcontainerdialog, String pathStr) {
1051 if (pathStr.length() == 0) {
1052 setError(NewWizardMessages.NewContainerDialog_error_enterpath);
1053 return;
1054 }
1055 IPath path= newcontainerdialog.fCurrProject.getFullPath().append(pathStr);
1056 IWorkspace workspace= newcontainerdialog.fCurrProject.getWorkspace();
1057
1058 IStatus pathValidation= workspace.validatePath(path.toString(), IResource.FOLDER);
1059 if (!pathValidation.isOK()) {
1060 setError(Messages.format(NewWizardMessages.NewContainerDialog_error_invalidpath, pathValidation.getMessage()));
1061 return;
1062 }
1063 IFolder folder= newcontainerdialog.fCurrProject.getFolder(pathStr);
1064 if (newcontainerdialog.isFolderExisting(folder)) {
1065 setError(NewWizardMessages.NewContainerDialog_error_pathexists);
1066 return;
1067 }
1068 setOK();
1069 newcontainerdialog.fFolder= folder;
1070 }
1071
1072 public StatusInfo generated_3811949559659235490(VariableCreationDialog variablecreationdialog, String name) {
1073 if (name.length() == 0) {
1074 setError(NewWizardMessages.VariableCreationDialog_error_entername);
1075 return this;
1076 }
1077 if (name.trim().length() != name.length()) {
1078 setError(NewWizardMessages.VariableCreationDialog_error_whitespace);
1079 } else if (!Path.ROOT.isValidSegment(name)) {
1080 setError(NewWizardMessages.VariableCreationDialog_error_invalidname);
1081 } else if (variablecreationdialog.nameConflict(name)) {
1082 setError(NewWizardMessages.VariableCreationDialog_error_nameexists);
1083 }
1084 return this;
1085 }
1086
1087 public StatusInfo generated_1933544809482677536(String path) {
1088 if (path.length() > 0) { // empty path is ok
1089 if (!Path.ROOT.isValidPath(path)) {
1090 setError(NewWizardMessages.VariableCreationDialog_error_invalidpath);
1091 } else if (!new File(path).exists()) {
1092 setWarning(NewWizardMessages.VariableCreationDialog_warning_pathnotexists);
1093 }
1094 }
1095 return this;
1096 }
1097
1098 public void generated_5016018090053794507(ExclusionInclusionEntryDialog exclusioninclusionentrydialog, String pattern) {
1099 if (pattern.length() == 0) {
1100 setError(NewWizardMessages.ExclusionInclusionEntryDialog_error_empty);
1101 return;
1102 }
1103 IPath path= new Path(pattern);
1104 if (path.isAbsolute() || path.getDevice() != null) {
1105 setError(NewWizardMessages.ExclusionInclusionEntryDialog_error_notrelative);
1106 return;
1107 }
1108 if (exclusioninclusionentrydialog.fExistingPatterns.contains(pattern)) {
1109 setError(NewWizardMessages.ExclusionInclusionEntryDialog_error_exists);
1110 return;
1111 }
1112
1113 exclusioninclusionentrydialog.fExclusionPattern= pattern;
1114 setOK();
1115 }
1116
1117 public IStatus generated_9097598671688101024(EditVariableEntryDialog editvariableentrydialog, String fileName) {
1118 if (fileName.length() == 0) {
1119 setError(NewWizardMessages.EditVariableEntryDialog_filename_empty);
1120 return this;
1121 } else {
1122 if (!Path.EMPTY.isValidPath(fileName)) {
1123 setError(NewWizardMessages.EditVariableEntryDialog_filename_error_notvalid);
1124 return this;
1125 }
1126 IPath filePath= Path.fromOSString(fileName);
1127 IPath resolvedPath;
1128
1129
1130 if (filePath.getDevice() != null) {
1131 setError(NewWizardMessages.EditVariableEntryDialog_filename_error_deviceinpath);
1132 return this;
1133 }
1134 String varName= filePath.segment(0);
1135 if (varName == null) {
1136 setError(NewWizardMessages.EditVariableEntryDialog_filename_error_notvalid);
1137 return this;
1138 }
1139 editvariableentrydialog.fFileVariablePath= JavaCore.getClasspathVariable(varName);
1140 if (editvariableentrydialog.fFileVariablePath == null) {
1141 setError(NewWizardMessages.EditVariableEntryDialog_filename_error_varnotexists);
1142 return this;
1143 }
1144
1145 String deprecationMessage= BuildPathSupport.getDeprecationMessage(varName);
1146
1147 resolvedPath= editvariableentrydialog.fFileVariablePath.append(filePath.removeFirstSegments(1));
1148 if (resolvedPath.isEmpty()) {
1149 String message= NewWizardMessages.EditVariableEntryDialog_filename_warning_varempty;
1150 if (deprecationMessage != null) {
1151 message= deprecationMessage + "\n" + message; //$NON-NLS-1$
1152 }
1153 setWarning(message);
1154 return this;
1155 }
1156 File file= resolvedPath.toFile();
1157 if (!file.exists()) {
1158 String message= Messages.format(NewWizardMessages.EditVariableEntryDialog_filename_error_filenotexists, BasicElementLabels.getPathLabel(resolvedPath, true));
1159 if (deprecationMessage != null) {
1160 message= deprecationMessage + "\n" + message; //$NON-NLS-1$
1161 setWarning(message);
1162 } else {
1163 setInfo(message);
1164 }
1165 return this;
1166 }
1167 if (deprecationMessage != null) {
1168 setWarning(deprecationMessage);
1169 return this;
1170 }
1171 }
1172 return this;
1173 }
1174
1175 public StatusInfo generated_2551826335379734895(IJavaProject javaProject, AddSourceFolderWizardPage addsourcefolderwizardpage, IPath projPath, IPath path, int projectEntryIndex) {
1176 boolean createFolderForExisting= false;
1177
1178 IFolder folder= addsourcefolderwizardpage.fParent.getFolder(new Path(addsourcefolderwizardpage.fRootDialogField.getText()));
1179 for (int i= 0; i < addsourcefolderwizardpage.fExistingEntries.size(); i++) {
1180 IClasspathEntry curr= addsourcefolderwizardpage.fExistingEntries.get(i).getClasspathEntry();
1181 if (curr.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
1182 if (path.equals(curr.getPath()) && addsourcefolderwizardpage.fExistingEntries.get(i) != addsourcefolderwizardpage.fNewElement) {
1183 if (folder.exists()) {
1184 setError(NewWizardMessages.NewSourceFolderWizardPage_error_AlreadyExisting);
1185 return this;
1186 } else {
1187 createFolderForExisting= true;
1188 }
1189 }
1190 if (projPath.equals(curr.getPath())) {
1191 projectEntryIndex= i;
1192 }
1193 }
1194 }
1195
1196 if (folder.exists() && !folder.getFullPath().equals(addsourcefolderwizardpage.fOrginalPath))
1197 return new StatusInfo(IStatus.ERROR, Messages.format(NewWizardMessages.NewFolderDialog_folderNameEmpty_alreadyExists, BasicElementLabels.getPathLabel(folder.getFullPath(), false)));
1198
1199 boolean isProjectASourceFolder= projectEntryIndex != -1;
1200
1201 addsourcefolderwizardpage.fModifiedElements.clear();
1202 addsourcefolderwizardpage.updateFilters(addsourcefolderwizardpage.fNewElement.getPath(), path);
1203
1204 addsourcefolderwizardpage.fNewElement.setPath(path);
1205 if (addsourcefolderwizardpage.fLinkedMode) {
1206 addsourcefolderwizardpage.fNewElement.setLinkTarget(addsourcefolderwizardpage.fLinkFields.getLinkTarget());
1207 }
1208 addsourcefolderwizardpage.fRemovedElements.clear();
1209 Set<CPListElement> modified= new HashSet<CPListElement>();
1210 boolean isProjectSourceFolderReplaced= false;
1211 if (addsourcefolderwizardpage.fAddExclusionPatterns.isSelected()) {
1212 if (addsourcefolderwizardpage.fOrginalPath == null) {
1213 addsourcefolderwizardpage.addExclusionPatterns(addsourcefolderwizardpage.fNewElement, addsourcefolderwizardpage.fExistingEntries, modified);
1214 addsourcefolderwizardpage.fModifiedElements.addAll(modified);
1215 if (!createFolderForExisting)
1216 CPListElement.insert(addsourcefolderwizardpage.fNewElement, addsourcefolderwizardpage.fExistingEntries);
1217 }
1218 } else {
1219 if (isProjectASourceFolder) {
1220 if (addsourcefolderwizardpage.fRemoveProjectFolder.isSelected()) {
1221 addsourcefolderwizardpage.fOldProjectSourceFolder= addsourcefolderwizardpage.fExistingEntries.get(projectEntryIndex);
1222 addsourcefolderwizardpage.fRemovedElements.add(addsourcefolderwizardpage.fOldProjectSourceFolder);
1223 addsourcefolderwizardpage.fExistingEntries.set(projectEntryIndex, addsourcefolderwizardpage.fNewElement);
1224 isProjectSourceFolderReplaced= true;
1225 } else {
1226 if (!createFolderForExisting)
1227 CPListElement.insert(addsourcefolderwizardpage.fNewElement, addsourcefolderwizardpage.fExistingEntries);
1228 }
1229 } else {
1230 if (!createFolderForExisting)
1231 CPListElement.insert(addsourcefolderwizardpage.fNewElement, addsourcefolderwizardpage.fExistingEntries);
1232 }
1233 }
1234
1235 if ((!addsourcefolderwizardpage.fAllowConflict && addsourcefolderwizardpage.fCanCommitConflictingBuildpath) || createFolderForExisting)
1236 return new StatusInfo();
1237
1238 addsourcefolderwizardpage.fNewOutputLocation= null;
1239 IJavaModelStatus status= JavaConventions.validateClasspath(javaProject, CPListElement.convertToClasspathEntries(addsourcefolderwizardpage.fExistingEntries), addsourcefolderwizardpage.fOutputLocation);
1240 if (!status.isOK()) {
1241 if (addsourcefolderwizardpage.fOutputLocation.equals(projPath)) {
1242 //Try to change the output folder
1243 addsourcefolderwizardpage.fNewOutputLocation= projPath.append(PreferenceConstants.getPreferenceStore().getString(PreferenceConstants.SRCBIN_BINNAME));
1244 IStatus status2= JavaConventions.validateClasspath(javaProject, CPListElement.convertToClasspathEntries(addsourcefolderwizardpage.fExistingEntries), addsourcefolderwizardpage.fNewOutputLocation);
1245 if (status2.isOK()) {
1246 if (isProjectSourceFolderReplaced) {
1247 setInfo(Messages.format(NewWizardMessages.NewSourceFolderWizardPage_warning_ReplaceSFandOL, BasicElementLabels.getPathLabel(addsourcefolderwizardpage.fNewOutputLocation, false)));
1248 } else {
1249 setInfo(Messages.format(NewWizardMessages.NewSourceFolderWizardPage_warning_ReplaceOL, BasicElementLabels.getPathLabel(addsourcefolderwizardpage.fNewOutputLocation, false)));
1250 }
1251 return this;
1252 }
1253 }
1254 //Don't know what the problem is, report to user
1255 addsourcefolderwizardpage.fNewOutputLocation= null;
1256 if (addsourcefolderwizardpage.fCanCommitConflictingBuildpath) {
1257 setInfo(NewWizardMessages.AddSourceFolderWizardPage_conflictWarning + status.getMessage());
1258 } else {
1259 setError(status.getMessage());
1260 }
1261 return this;
1262 }
1263 if (!modified.isEmpty()) {
1264 //Added exclusion patterns to solve problem
1265 if (modified.size() == 1) {
1266 CPListElement elem= (CPListElement)modified.toArray()[0];
1267 String changed= BasicElementLabels.getPathLabel(elem.getPath(), false);
1268 String excl= BasicElementLabels.getPathLabel(addsourcefolderwizardpage.fNewElement.getPath(), false);
1269 setInfo(Messages.format(NewWizardMessages.AddSourceFolderWizardPage_addSinglePattern, new Object[] {excl, changed}));
1270 } else {
1271 setInfo(Messages.format(NewWizardMessages.NewSourceFolderWizardPage_warning_AddedExclusions_plural, String.valueOf(modified.size())));
1272 }
1273 return this;
1274 }
1275 if (isProjectSourceFolderReplaced) {
1276 setInfo(NewWizardMessages.AddSourceFolderWizardPage_replaceSourceFolderInfo);
1277 return this;
1278 }
1279
1280 return this;
1281 }
1282
1283 public void generated_8792137329388506661() throws CoreException {
1284 setError(NewWizardMessages.ClasspathModifier_Error_NoNatures);
1285 throw new CoreException(this);
1286 }
1287
1288 public void generated_6530786110144286140(NewElementWizardPage newelementwizardpage) {
1289 setError(""); //$NON-NLS-1$
1290 newelementwizardpage.fCurrStatus= this;
1291 }
1292
1293 public IStatus generated_1936382759706378607(NewContainerWizardPage newcontainerwizardpage, String str) {
1294 if (str.length() == 0) {
1295 setError(NewWizardMessages.NewContainerWizardPage_error_EnterContainerName);
1296 return this;
1297 }
1298 IPath path= new Path(str);
1299 IResource res= newcontainerwizardpage.fWorkspaceRoot.findMember(path);
1300 if (res != null) {
1301 int resType= res.getType();
1302 if (resType == IResource.PROJECT || resType == IResource.FOLDER) {
1303 IProject proj= res.getProject();
1304 if (!proj.isOpen()) {
1305 setError(Messages.format(NewWizardMessages.NewContainerWizardPage_error_ProjectClosed, BasicElementLabels.getPathLabel(proj.getFullPath(), false)));
1306 return this;
1307 }
1308 IJavaProject jproject= JavaCore.create(proj);
1309 newcontainerwizardpage.fCurrRoot= jproject.getPackageFragmentRoot(res);
1310 if (res.exists()) {
1311 if (res.isVirtual()) {
1312 setError(NewWizardMessages.NewContainerWizardPage_error_FolderIsVirtual);
1313 return this;
1314 }
1315 try {
1316 if (!proj.hasNature(JavaCore.NATURE_ID)) {
1317 if (resType == IResource.PROJECT) {
1318 setError(NewWizardMessages.NewContainerWizardPage_warning_NotAJavaProject);
1319 } else {
1320 setWarning(NewWizardMessages.NewContainerWizardPage_warning_NotInAJavaProject);
1321 }
1322 return this;
1323 }
1324 if (newcontainerwizardpage.fCurrRoot.isArchive()) {
1325 setError(Messages.format(NewWizardMessages.NewContainerWizardPage_error_ContainerIsBinary, BasicElementLabels.getPathLabel(path, false)));
1326 return this;
1327 }
1328 if (newcontainerwizardpage.fCurrRoot.getKind() == IPackageFragmentRoot.K_BINARY) {
1329 setWarning(Messages.format(NewWizardMessages.NewContainerWizardPage_warning_inside_classfolder, BasicElementLabels.getPathLabel(path, false)));
1330 } else if (!jproject.isOnClasspath(newcontainerwizardpage.fCurrRoot)) {
1331 setWarning(Messages.format(NewWizardMessages.NewContainerWizardPage_warning_NotOnClassPath, BasicElementLabels.getPathLabel(path, false)));
1332 }
1333 } catch (JavaModelException e) {
1334 setWarning(NewWizardMessages.NewContainerWizardPage_warning_NotOnClassPath);
1335 } catch (CoreException e) {
1336 setWarning(NewWizardMessages.NewContainerWizardPage_warning_NotAJavaProject);
1337 }
1338 }
1339 return this;
1340 } else {
1341 setError(Messages.format(NewWizardMessages.NewContainerWizardPage_error_NotAFolder, BasicElementLabels.getPathLabel(path, false)));
1342 return this;
1343 }
1344 } else {
1345 setError(Messages.format(NewWizardMessages.NewContainerWizardPage_error_ContainerDoesNotExist, BasicElementLabels.getPathLabel(path, false)));
1346 return this;
1347 }
1348 }
1349
1350 public IStatus generated_1429417320186001881(NewTypeWizardPage newtypewizardpage) {
1351 IPackageFragmentRoot root= newtypewizardpage.getPackageFragmentRoot();
1352 newtypewizardpage.fPackageDialogField.enableButton(root != null);
1353
1354 IJavaProject project= root != null ? root.getJavaProject() : null;
1355
1356 String packName= newtypewizardpage.getPackageText();
1357 if (packName.length() > 0) {
1358 IStatus val= NewTypeWizardPage.validatePackageName(packName, project);
1359 if (val.getSeverity() == IStatus.ERROR) {
1360 setError(Messages.format(NewWizardMessages.NewTypeWizardPage_error_InvalidPackageName, val.getMessage()));
1361 return this;
1362 } else if (val.getSeverity() == IStatus.WARNING) {
1363 setWarning(Messages.format(NewWizardMessages.NewTypeWizardPage_warning_DiscouragedPackageName, val.getMessage()));
1364 // continue
1365 }
1366 } else {
1367 setWarning(NewWizardMessages.NewTypeWizardPage_warning_DefaultPackageDiscouraged);
1368 }
1369
1370 if (project != null) {
1371 if (project.exists() && packName.length() > 0) {
1372 try {
1373 IPath rootPath= root.getPath();
1374 IPath outputPath= project.getOutputLocation();
1375 if (rootPath.isPrefixOf(outputPath) && !rootPath.equals(outputPath)) {
1376 // if the bin folder is inside of our root, don't allow to name a package
1377 // like the bin folder
1378 IPath packagePath= rootPath.append(packName.replace('.', '/'));
1379 if (outputPath.isPrefixOf(packagePath)) {
1380 setError(NewWizardMessages.NewTypeWizardPage_error_ClashOutputLocation);
1381 return this;
1382 }
1383 }
1384 } catch (JavaModelException e) {
1385 JavaPlugin.log(e);
1386 // let pass
1387 }
1388 }
1389
1390 newtypewizardpage.fCurrPackage= root.getPackageFragment(packName);
1391 IResource resource= newtypewizardpage.fCurrPackage.getResource();
1392 if (resource != null){
1393 if (resource.isVirtual()){
1394 setError(NewWizardMessages.NewTypeWizardPage_error_PackageIsVirtual);
1395 return this;
1396 }
1397 if (!ResourcesPlugin.getWorkspace().validateFiltered(resource).isOK()) {
1398 setError(NewWizardMessages.NewTypeWizardPage_error_PackageNameFiltered);
1399 return this;
1400 }
1401 }
1402 } else {
1403 setError(""); //$NON-NLS-1$
1404 }
1405 return this;
1406 }
1407
1408 public IStatus generated_1881670470749155116() {
1409 setError(""); //$NON-NLS-1$
1410 return this;
1411 }
1412
1413 public IStatus generated_4559436795639320427(String typeNameWithParameters, String typeName, IJavaProject project) {
1414 if (!typeNameWithParameters.equals(typeName) && project != null) {
1415 if (!JavaModelUtil.is50OrHigher(project)) {
1416 setError(NewWizardMessages.NewTypeWizardPage_error_TypeParameters);
1417 return this;
1418 }
1419 String typeDeclaration= "class " + typeNameWithParameters + " {}"; //$NON-NLS-1$//$NON-NLS-2$
1420 ASTParser parser= ASTParser.newParser(ASTProvider.SHARED_AST_LEVEL);
1421 parser.setSource(typeDeclaration.toCharArray());
1422 parser.setProject(project);
1423 CompilationUnit compilationUnit= (CompilationUnit) parser.createAST(null);
1424 IProblem[] problems= compilationUnit.getProblems();
1425 if (problems.length > 0) {
1426 setError(Messages.format(NewWizardMessages.NewTypeWizardPage_error_InvalidTypeName, problems[0].getMessage()));
1427 return this;
1428 }
1429 }
1430 return this;
1431 }
1432
1433 public IStatus generated_3206039554864158094(IPackageFragmentRoot root, String sclassName) {
1434 if (sclassName.length() == 0) {
1435 // accept the empty field (stands for java.lang.Object)
1436 return this;
1437 }
1438
1439 if (root != null) {
1440 Type type= TypeContextChecker.parseSuperClass(sclassName);
1441 if (type == null) {
1442 setError(NewWizardMessages.NewTypeWizardPage_error_InvalidSuperClassName);
1443 return this;
1444 }
1445 if (type instanceof ParameterizedType && ! JavaModelUtil.is50OrHigher(root.getJavaProject())) {
1446 setError(NewWizardMessages.NewTypeWizardPage_error_SuperClassNotParameterized);
1447 return this;
1448 }
1449 } else {
1450 setError(""); //$NON-NLS-1$
1451 }
1452 return this;
1453 }
1454
1455 public IStatus generated_6833489594346951861(NewTypeWizardPage newtypewizardpage, IPackageFragmentRoot root) {
1456 if (root != null) {
1457 List<InterfaceWrapper> elements= newtypewizardpage.fSuperInterfacesDialogField.getElements();
1458 int nElements= elements.size();
1459 for (int i= 0; i < nElements; i++) {
1460 String intfname= elements.get(i).interfaceName;
1461 Type type= TypeContextChecker.parseSuperInterface(intfname);
1462 if (type == null) {
1463 setError(Messages.format(NewWizardMessages.NewTypeWizardPage_error_InvalidSuperInterfaceName, BasicElementLabels.getJavaElementName(intfname)));
1464 return this;
1465 }
1466 if (type instanceof ParameterizedType && ! JavaModelUtil.is50OrHigher(root.getJavaProject())) {
1467 setError(Messages.format(NewWizardMessages.NewTypeWizardPage_error_SuperInterfaceNotParameterized, BasicElementLabels.getJavaElementName(intfname)));
1468 return this;
1469 }
1470 }
1471 }
1472 return this;
1473 }
1474
1475 public IStatus generated_5181987537003680498(NewTypeWizardPage newtypewizardpage) {
1476 int modifiers= newtypewizardpage.getModifiers();
1477 if (Flags.isFinal(modifiers) && Flags.isAbstract(modifiers)) {
1478 setError(NewWizardMessages.NewTypeWizardPage_error_ModifiersFinalAndAbstract);
1479 }
1480 return this;
1481 }
1482
1483 public void generated_700241883069130654(IPackageFragment pack) throws JavaModelException {
1484 if (pack.containsJavaResources() || !pack.hasSubpackages()) {
1485 setError(NewWizardMessages.NewPackageWizardPage_error_PackageExists);
1486 } else {
1487 setError(NewWizardMessages.NewPackageWizardPage_error_PackageNotShown);
1488 }
1489 }
1490
1491 public IStatus generated_8038334573168158399(ConvertIterableLoopOperation convertiterableloopoperation, Expression expression) {
1492 if (!(expression instanceof MethodInvocation))
1493 return this;
1494
1495 MethodInvocation invoc= (MethodInvocation)expression;
1496 IMethodBinding methodBinding= invoc.resolveMethodBinding();
1497 if (methodBinding == null)
1498 return ConvertLoopOperation.ERROR_STATUS;
1499
1500 ITypeBinding declaringClass= methodBinding.getDeclaringClass();
1501 if (declaringClass == null)
1502 return ConvertLoopOperation.ERROR_STATUS;
1503
1504 String qualifiedName= declaringClass.getQualifiedName();
1505 String methodName= invoc.getName().getIdentifier();
1506 if (qualifiedName.startsWith("java.util.Enumeration")) { //$NON-NLS-1$
1507 if (!methodName.equals("hasMoreElements")) //$NON-NLS-1$
1508 return this;
1509 } else if (qualifiedName.startsWith("java.util.Iterator")) { //$NON-NLS-1$
1510 if (!methodName.equals("hasNext")) //$NON-NLS-1$
1511 return this;
1512 return convertiterableloopoperation.checkIteratorCondition();
1513 } else {
1514 return this;
1515 }
1516
1517 return StatusInfo.OK_STATUS;
1518 }
1519
1520 public IStatus generated_7916279993924113081(List<Expression> initializers) {
1521 if (initializers.size() != 1)
1522 return this;
1523
1524 Expression expression= initializers.get(0);
1525 if (!(expression instanceof VariableDeclarationExpression))
1526 return this;
1527
1528 VariableDeclarationExpression declaration= (VariableDeclarationExpression)expression;
1529 List<VariableDeclarationFragment> variableDeclarationFragments= declaration.fragments();
1530 if (variableDeclarationFragments.size() != 1)
1531 return this;
1532
1533 VariableDeclarationFragment declarationFragment= variableDeclarationFragments.get(0);
1534
1535 Expression initializer= declarationFragment.getInitializer();
1536 if (!(initializer instanceof MethodInvocation))
1537 return this;
1538
1539 MethodInvocation methodInvocation= (MethodInvocation)initializer;
1540 String methodName= methodInvocation.getName().getIdentifier();
1541 if (!"iterator".equals(methodName)) //$NON-NLS-1$
1542 return this;
1543
1544 return StatusInfo.OK_STATUS;
1545 }
1546}