From 3c0e36f85d5a39b357d2b784e0d14acac5614f0c Mon Sep 17 00:00:00 2001
From: Szymon Ptaszkiewicz
Date: Thu, 16 Feb 2012 11:48:01 +0100
Subject: Bug 220928: [buildpath] Should be able to ignore warnings from
certain source folders
---
.../full/obj16/ignore_optional_problems_attrib.gif | Bin 0 -> 321 bytes
.../full/ovr16/ignore_optional_problems_co.gif | Bin 0 -> 170 bytes
org.eclipse.jdt.ui/plugin.properties | 3 +-
org.eclipse.jdt.ui/plugin.xml | 15 +++
.../eclipse/jdt/internal/ui/JavaPluginImages.java | 7 +-
.../ui/preferences/BuildPathsPropertyPage.java | 17 ++-
.../ui/preferences/JavaCompilerPropertyPage.java | 148 +++++++++++++++++++++
.../JavadocProblemsConfigurationBlock.java | 4 +-
.../ui/preferences/OptionsConfigurationBlock.java | 54 +++++++-
.../ui/preferences/PreferencesMessages.java | 3 +
.../ui/preferences/PreferencesMessages.properties | 4 +
.../ProblemSeveritiesConfigurationBlock.java | 2 +
.../ui/wizards/NewSourceFolderWizardPage.java | 26 +++-
.../jdt/internal/ui/wizards/NewWizardMessages.java | 6 +-
.../ui/wizards/NewWizardMessages.properties | 6 +-
.../ui/wizards/buildpaths/CPListElement.java | 4 +-
.../ui/wizards/buildpaths/CPListLabelProvider.java | 12 +-
.../buildpaths/SourceContainerWorkbookPage.java | 8 +-
.../eclipse/jdt/ui/JavaElementImageDescriptor.java | 11 +-
.../org/eclipse/jdt/ui/ProblemsLabelDecorator.java | 34 ++++-
20 files changed, 346 insertions(+), 18 deletions(-)
create mode 100644 org.eclipse.jdt.ui/icons/full/obj16/ignore_optional_problems_attrib.gif
create mode 100644 org.eclipse.jdt.ui/icons/full/ovr16/ignore_optional_problems_co.gif
create mode 100644 org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaCompilerPropertyPage.java
diff --git a/org.eclipse.jdt.ui/icons/full/obj16/ignore_optional_problems_attrib.gif b/org.eclipse.jdt.ui/icons/full/obj16/ignore_optional_problems_attrib.gif
new file mode 100644
index 0000000000..f68c6d4cf4
Binary files /dev/null and b/org.eclipse.jdt.ui/icons/full/obj16/ignore_optional_problems_attrib.gif differ
diff --git a/org.eclipse.jdt.ui/icons/full/ovr16/ignore_optional_problems_co.gif b/org.eclipse.jdt.ui/icons/full/ovr16/ignore_optional_problems_co.gif
new file mode 100644
index 0000000000..0962018c2b
Binary files /dev/null and b/org.eclipse.jdt.ui/icons/full/ovr16/ignore_optional_problems_co.gif differ
diff --git a/org.eclipse.jdt.ui/plugin.properties b/org.eclipse.jdt.ui/plugin.properties
index f37ce207a6..4142cfb593 100644
--- a/org.eclipse.jdt.ui/plugin.properties
+++ b/org.eclipse.jdt.ui/plugin.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2011 IBM Corporation and others.
+# Copyright (c) 2000, 2012 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
@@ -87,6 +87,7 @@ builderPageName=Building
compliancePageName=Java Compiler
todoPageName=Task Tags
javadocLocationPageName=Javadoc Location
+javaCompilerPageName=Java Compiler
preferenceKeywords.general=Java package explorer call type hierarchy refactoring rename editor search
preferenceKeywords.appearance=Java appearance package explorer browsing compress show method return types categories members
diff --git a/org.eclipse.jdt.ui/plugin.xml b/org.eclipse.jdt.ui/plugin.xml
index afb26b6a89..eb4a4425f4 100644
--- a/org.eclipse.jdt.ui/plugin.xml
+++ b/org.eclipse.jdt.ui/plugin.xml
@@ -924,6 +924,21 @@
+
+
+
+
+
+
+
+
+
+
here)
FilterTextControl_Clear=Clear
FilterTextControl_ClearFilterField=Clear filter field
+
+JavaCompilerPropertyPage_ignore_optional_problems_label=&Ignore optional compile problems
+JavaCompilerPropertyPage_invalid_element_selection=Java Compiler settings cannot be changed for the selected element.
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ProblemSeveritiesConfigurationBlock.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ProblemSeveritiesConfigurationBlock.java
index ba441ff25a..3ed943ba66 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ProblemSeveritiesConfigurationBlock.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ProblemSeveritiesConfigurationBlock.java
@@ -415,6 +415,8 @@ public class ProblemSeveritiesConfigurationBlock extends OptionsConfigurationBlo
gridData.heightHint= fPixelConverter.convertHeightInCharsToPixels(30);
commonComposite.setLayoutData(gridData);
+ createIgnoreOptionalProblemsLink(parent);
+
validateSettings(null, null, null);
return mainComp;
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewSourceFolderWizardPage.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewSourceFolderWizardPage.java
index 8a054d29f9..6caa932434 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewSourceFolderWizardPage.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewSourceFolderWizardPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -52,6 +52,7 @@ import org.eclipse.ui.model.WorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
import org.eclipse.ui.views.navigator.ResourceComparator;
+import org.eclipse.jdt.core.IClasspathAttribute;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaModelStatus;
@@ -84,6 +85,7 @@ import org.eclipse.jdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
public class NewSourceFolderWizardPage extends NewElementWizardPage {
+ private static final IClasspathAttribute ATTR_IGNORE_OPTIONAL_PROBLEMS_TRUE= JavaCore.newClasspathAttribute(IClasspathAttribute.IGNORE_OPTIONAL_PROBLEMS, "true"); //$NON-NLS-1$
private static final String PAGE_NAME= "NewSourceFolderWizardPage"; //$NON-NLS-1$
@@ -94,6 +96,7 @@ public class NewSourceFolderWizardPage extends NewElementWizardPage {
private StatusInfo fRootStatus;
private SelectionButtonDialogField fExcludeInOthersFields;
+ private SelectionButtonDialogField fIgnoreOptionalProblemsField;
private IWorkspaceRoot fWorkspaceRoot;
@@ -131,9 +134,13 @@ public class NewSourceFolderWizardPage extends NewElementWizardPage {
fExcludeInOthersFields= new SelectionButtonDialogField(SWT.CHECK);
fExcludeInOthersFields.setDialogFieldListener(adapter);
fExcludeInOthersFields.setLabelText(NewWizardMessages.NewSourceFolderWizardPage_exclude_label);
-
fExcludeInOthersFields.setEnabled(JavaCore.ENABLED.equals(JavaCore.getOption(JavaCore.CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS)));
+ fIgnoreOptionalProblemsField= new SelectionButtonDialogField(SWT.CHECK);
+ fIgnoreOptionalProblemsField.setDialogFieldListener(adapter);
+ fIgnoreOptionalProblemsField.setLabelText(NewWizardMessages.NewSourceFolderWizardPage_ignore_optional_problems_label);
+ fIgnoreOptionalProblemsField.setSelection(false);
+
fRootStatus= new StatusInfo();
fProjectStatus= new StatusInfo();
}
@@ -186,6 +193,7 @@ public class NewSourceFolderWizardPage extends NewElementWizardPage {
fProjectField.doFillIntoGrid(composite, 3);
fRootDialogField.doFillIntoGrid(composite, 3);
fExcludeInOthersFields.doFillIntoGrid(composite, 3);
+ fIgnoreOptionalProblemsField.doFillIntoGrid(composite, 3);
int maxFieldWidth= convertWidthInCharsToPixels(40);
LayoutUtil.setWidthHint(fProjectField.getTextControl(null), maxFieldWidth);
@@ -250,6 +258,8 @@ public class NewSourceFolderWizardPage extends NewElementWizardPage {
updateRootStatus();
} else if (field == fExcludeInOthersFields) {
updateRootStatus();
+ } else if (field == fIgnoreOptionalProblemsField) {
+ updateRootStatus();
}
updateStatus(new IStatus[] { fProjectStatus, fRootStatus });
}
@@ -358,19 +368,25 @@ public class NewSourceFolderWizardPage extends NewElementWizardPage {
newEntries.add(curr);
}
- IClasspathEntry newEntry= JavaCore.newSourceEntry(path);
+ IClasspathAttribute[] attributes;
+ if (fIgnoreOptionalProblemsField.isSelected()) {
+ attributes= new IClasspathAttribute[] { ATTR_IGNORE_OPTIONAL_PROBLEMS_TRUE };
+ } else {
+ attributes= new IClasspathAttribute[] {};
+ }
+ IClasspathEntry newEntry= JavaCore.newSourceEntry(path, null, null, null, attributes);
Set modified= new HashSet();
if (fExcludeInOthersFields.isSelected()) {
addExclusionPatterns(newEntry, newEntries, modified);
- IClasspathEntry entry= JavaCore.newSourceEntry(path);
+ IClasspathEntry entry= JavaCore.newSourceEntry(path, null, null, null, attributes);
insertAtEndOfCategory(entry, newEntries);
} else {
if (projectEntryIndex != -1) {
fIsProjectAsSourceFolder= true;
newEntries.set(projectEntryIndex, newEntry);
} else {
- IClasspathEntry entry= JavaCore.newSourceEntry(path);
+ IClasspathEntry entry= JavaCore.newSourceEntry(path, null, null, null, attributes);
insertAtEndOfCategory(entry, newEntries);
}
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.java
index 5db0cf6c53..3ac020cd53 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -252,6 +252,7 @@ public final class NewWizardMessages extends NLS {
public static String NewSourceFolderWizardPage_project_button;
public static String NewSourceFolderWizardPage_operation;
public static String NewSourceFolderWizardPage_exclude_label;
+ public static String NewSourceFolderWizardPage_ignore_optional_problems_label;
public static String NewSourceFolderWizardPage_ChooseExistingRootDialog_title;
public static String NewSourceFolderWizardPage_ChooseExistingRootDialog_description;
public static String NewSourceFolderWizardPage_ChooseProjectDialog_title;
@@ -546,6 +547,9 @@ public final class NewWizardMessages extends NLS {
public static String FolderSelectionDialog_button;
public static String MultipleFolderSelectionDialog_button;
+ public static String CPListLabelProvider_ignore_optional_problems_label;
+ public static String CPListLabelProvider_ignore_optional_problems_yes;
+ public static String CPListLabelProvider_ignore_optional_problems_no;
public static String CPListLabelProvider_none;
public static String CPListLabelProvider_all;
public static String CPListLabelProvider_source_attachment_label;
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.properties b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.properties
index f7863f6746..edf053b425 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.properties
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2011 IBM Corporation and others.
+# Copyright (c) 2000, 2012 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
@@ -226,6 +226,7 @@ NewSourceFolderWizardPage_project_button=Bro&wse...
NewSourceFolderWizardPage_operation=Creating new source folder...
NewSourceFolderWizardPage_exclude_label=&Update exclusion filters in other source folders to solve nesting
+NewSourceFolderWizardPage_ignore_optional_problems_label=&Ignore optional compile problems
NewSourceFolderWizardPage_ChooseExistingRootDialog_title=Existing Folder Selection
NewSourceFolderWizardPage_ChooseExistingRootDialog_description=&Choose folder as source folder:
@@ -660,6 +661,9 @@ MultipleFolderSelectionDialog_button=Create &New Folder...
CPListLabelProvider_javadoc_location_label=Javadoc location
CPListLabelProvider_native_library_path=Native library location
+CPListLabelProvider_ignore_optional_problems_label=Ignore optional compile problems: {0}
+CPListLabelProvider_ignore_optional_problems_yes=Yes
+CPListLabelProvider_ignore_optional_problems_no=No
CPListLabelProvider_none=(None)
CPListLabelProvider_all=(All)
CPListLabelProvider_non_modifiable_attribute={0} - non modifiable
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/CPListElement.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/CPListElement.java
index fd0ef784ee..ef38fcdcf9 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/CPListElement.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/CPListElement.java
@@ -55,6 +55,7 @@ public class CPListElement {
public static final String JAVADOC= IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME;
public static final String SOURCE_ATTACHMENT_ENCODING= IClasspathAttribute.SOURCE_ATTACHMENT_ENCODING;
+ public static final String IGNORE_OPTIONAL_PROBLEMS= IClasspathAttribute.IGNORE_OPTIONAL_PROBLEMS;
public static final String NATIVE_LIB_PATH= JavaRuntime.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY;
private IJavaProject fProject;
@@ -114,6 +115,7 @@ public class CPListElement {
createAttributeElement(INCLUSION, new Path[0], true);
createAttributeElement(EXCLUSION, new Path[0], true);
createAttributeElement(NATIVE_LIB_PATH, null, false);
+ createAttributeElement(IGNORE_OPTIONAL_PROBLEMS, null, false);
break;
case IClasspathEntry.CPE_LIBRARY:
case IClasspathEntry.CPE_VARIABLE:
@@ -361,7 +363,7 @@ public class CPListElement {
if (curr.isNotSupported()) {
return true;
}
- if (!curr.isBuiltIn() && !key.equals(CPListElement.JAVADOC) && !key.equals(CPListElement.NATIVE_LIB_PATH)) {
+ if (!curr.isBuiltIn() && !key.equals(CPListElement.JAVADOC) && !key.equals(CPListElement.NATIVE_LIB_PATH) && !key.equals(CPListElement.IGNORE_OPTIONAL_PROBLEMS)) {
return !JavaPlugin.getDefault().getClasspathAttributeConfigurationDescriptors().containsKey(key);
}
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/CPListLabelProvider.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/CPListLabelProvider.java
index f6bbafce3d..ca2283719f 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/CPListLabelProvider.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/CPListLabelProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -217,6 +217,14 @@ public class CPListLabelProvider extends LabelProvider {
return NewWizardMessages.CPListLabelProvider_access_rules_disabled;
}
}
+ } else if (key.equals(CPListElement.IGNORE_OPTIONAL_PROBLEMS)) {
+ String arg;
+ if ("true".equals(attrib.getValue())) { //$NON-NLS-1$
+ arg= NewWizardMessages.CPListLabelProvider_ignore_optional_problems_yes;
+ } else {
+ arg= NewWizardMessages.CPListLabelProvider_ignore_optional_problems_no;
+ }
+ return Messages.format(NewWizardMessages.CPListLabelProvider_ignore_optional_problems_label, arg);
} else {
ClasspathAttributeConfiguration config= fAttributeDescriptors.get(key);
if (config != null) {
@@ -414,6 +422,8 @@ public class CPListLabelProvider extends LabelProvider {
return fRegistry.get(JavaPluginImages.DESC_OBJS_INCLUSION_FILTER_ATTRIB);
} else if (key.equals(CPListElement.ACCESSRULES)) {
return fRegistry.get(JavaPluginImages.DESC_OBJS_ACCESSRULES_ATTRIB);
+ } else if (key.equals(CPListElement.IGNORE_OPTIONAL_PROBLEMS)) {
+ return fRegistry.get(JavaPluginImages.DESC_OBJS_IGNORE_OPTIONAL_PROBLEMS_ATTRIB);
} else {
ClasspathAttributeConfiguration config= fAttributeDescriptors.get(key);
if (config != null) {
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/SourceContainerWorkbookPage.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/SourceContainerWorkbookPage.java
index 35b3f271df..2e2c9b12e1 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/SourceContainerWorkbookPage.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/SourceContainerWorkbookPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -424,6 +424,10 @@ public class SourceContainerWorkbookPage extends BuildPathBasePage {
EditFilterWizard wizard= newEditFilterWizard(elem.getParent(), fFoldersList.getElements(), fOutputLocationField.getText());
OpenBuildPathWizardAction action= new OpenBuildPathWizardAction(wizard);
action.run();
+ } else if (key.equals(CPListElement.IGNORE_OPTIONAL_PROBLEMS)) {
+ String newValue= "true".equals(elem.getValue()) ? null : "true"; //$NON-NLS-1$ //$NON-NLS-2$
+ elem.setValue(newValue);
+ fFoldersList.refresh(elem);
} else {
if (editCustomAttribute(getShell(), elem)) {
fFoldersList.refresh();
@@ -533,6 +537,8 @@ public class SourceContainerWorkbookPage extends BuildPathBasePage {
CPListElementAttribute attrib= (CPListElementAttribute) elem;
if (attrib.isBuiltIn()) {
return true;
+ } else if (CPListElement.IGNORE_OPTIONAL_PROBLEMS.equals(attrib.getKey())) {
+ return true;
} else {
return canEditCustomAttribute(attrib);
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/JavaElementImageDescriptor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/JavaElementImageDescriptor.java
index 1b701c5c7b..5eef26746e 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/JavaElementImageDescriptor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/JavaElementImageDescriptor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -97,6 +97,12 @@ public class JavaElementImageDescriptor extends CompositeImageDescriptor {
*/
public final static int NATIVE= 0x4000;
+ /**
+ * Flag to render ignore optional compile problems adornment.
+ * @since 3.8
+ */
+ public final static int IGNORE_OPTIONAL_PROBLEMS= 0x8000;
+
private ImageDescriptor fBaseImage;
private int fFlags;
private Point fSize;
@@ -320,6 +326,9 @@ public class JavaElementImageDescriptor extends CompositeImageDescriptor {
if ((fFlags & WARNING) != 0) {
addBottomLeftImage(JavaPluginImages.DESC_OVR_WARNING, pos);
}
+ if ((fFlags & IGNORE_OPTIONAL_PROBLEMS) != 0) {
+ addBottomLeftImage(JavaPluginImages.DESC_OVR_IGNORE_OPTIONAL_PROBLEMS, pos);
+ }
}
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/ProblemsLabelDecorator.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/ProblemsLabelDecorator.java
index ab1e62dffd..aecfd7c1e3 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/ProblemsLabelDecorator.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/ProblemsLabelDecorator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -41,9 +41,12 @@ import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.texteditor.MarkerAnnotation;
+import org.eclipse.jdt.core.IClasspathAttribute;
+import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaModelMarker;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.core.ISourceReference;
import org.eclipse.jdt.core.JavaModelException;
@@ -55,6 +58,7 @@ import org.eclipse.jdt.internal.ui.JavaPluginImages;
import org.eclipse.jdt.internal.ui.viewsupport.IProblemChangedListener;
import org.eclipse.jdt.internal.ui.viewsupport.ImageDescriptorRegistry;
import org.eclipse.jdt.internal.ui.viewsupport.ImageImageDescriptor;
+import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement;
/**
* LabelDecorator that decorates an element's image with error and warning overlays that
@@ -107,6 +111,7 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
}
+ private static final int ERRORTICK_IGNORE_OPTIONAL_PROBLEMS= JavaElementImageDescriptor.IGNORE_OPTIONAL_PROBLEMS;
private static final int ERRORTICK_WARNING= JavaElementImageDescriptor.WARNING;
private static final int ERRORTICK_ERROR= JavaElementImageDescriptor.ERROR;
private static final int ERRORTICK_BUILDPATH_ERROR= JavaElementImageDescriptor.BUILDPATH_ERROR;
@@ -185,7 +190,14 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
case IJavaElement.JAVA_MODEL:
case IJavaElement.JAVA_PROJECT:
case IJavaElement.PACKAGE_FRAGMENT_ROOT:
- return getErrorTicksFromMarkers(element.getResource(), IResource.DEPTH_INFINITE, null);
+ int flags= getErrorTicksFromMarkers(element.getResource(), IResource.DEPTH_INFINITE, null);
+ if (type == IJavaElement.PACKAGE_FRAGMENT_ROOT) {
+ IPackageFragmentRoot root= (IPackageFragmentRoot) element;
+ if (flags != ERRORTICK_ERROR && root.getKind() == IPackageFragmentRoot.K_SOURCE && isIgnoreOptionalProblems(root)) {
+ flags= ERRORTICK_IGNORE_OPTIONAL_PROBLEMS;
+ }
+ }
+ return flags;
case IJavaElement.PACKAGE_FRAGMENT:
case IJavaElement.COMPILATION_UNIT:
case IJavaElement.CLASS_FILE:
@@ -234,6 +246,24 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
return 0;
}
+ private boolean isIgnoreOptionalProblems(IPackageFragmentRoot root) {
+ try {
+ IClasspathEntry entry= root.getRawClasspathEntry();
+ if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
+ IClasspathAttribute[] extraAttributes= entry.getExtraAttributes();
+ for (int i= 0; i < extraAttributes.length; i++) {
+ IClasspathAttribute attrib= extraAttributes[i];
+ if (CPListElement.IGNORE_OPTIONAL_PROBLEMS.equals(attrib.getName())) {
+ return "true".equals(attrib.getValue()); //$NON-NLS-1$
+ }
+ }
+ }
+ } catch (JavaModelException e) {
+ return false;
+ }
+ return false;
+ }
+
private int getErrorTicksFromMarkers(IResource res, int depth, ISourceReference sourceElement) throws CoreException {
if (res == null || !res.isAccessible()) {
return 0;
--
cgit v1.2.3