diff options
Diffstat (limited to 'org.eclipse.jdt.ui')
20 files changed, 346 insertions, 18 deletions
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 Binary files differnew file mode 100644 index 0000000000..f68c6d4cf4 --- /dev/null +++ b/org.eclipse.jdt.ui/icons/full/obj16/ignore_optional_problems_attrib.gif 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 Binary files differnew file mode 100644 index 0000000000..0962018c2b --- /dev/null +++ b/org.eclipse.jdt.ui/icons/full/ovr16/ignore_optional_problems_co.gif 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 @@ </enabledWhen> <keywordReference id="org.eclipse.jdt.ui.classpathcontainer" /> </page> + <page + class="org.eclipse.jdt.internal.ui.preferences.JavaCompilerPropertyPage" + id="org.eclipse.jdt.ui.propertyPages.JavaCompilerPropertyPage" + name="%javaCompilerPageName"> + <enabledWhen> + <and> + <instanceof + value="org.eclipse.jdt.core.IPackageFragmentRoot"> + </instanceof> + <test + property="org.eclipse.jdt.core.inSourceFolder"> + </test> + </and> + </enabledWhen> + </page> </extension> <extension diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPluginImages.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPluginImages.java index c07f9400fa..85239d876b 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPluginImages.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPluginImages.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 @@ -152,6 +152,8 @@ public class JavaPluginImages { public static final String IMG_OBJS_ACCESSRULES_ATTRIB= NAME_PREFIX + "access_restriction_attrib.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_IGNORE_OPTIONAL_PROBLEMS_ATTRIB= NAME_PREFIX + "ignore_optional_problems_attrib.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_REFACTORING_FATAL= NAME_PREFIX + "fatalerror_obj.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_REFACTORING_ERROR= NAME_PREFIX + "error_obj.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_REFACTORING_WARNING= NAME_PREFIX + "warning_obj.gif"; //$NON-NLS-1$ @@ -294,6 +296,8 @@ public class JavaPluginImages { public static final ImageDescriptor DESC_OBJS_ACCESSRULES_ATTRIB= createManagedFromKey(T_OBJ, IMG_OBJS_ACCESSRULES_ATTRIB); public static final ImageDescriptor DESC_OBJS_NATIVE_LIB_PATH_ATTRIB= createUnManaged(T_OBJ, "native_lib_path_attrib.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_OBJS_IGNORE_OPTIONAL_PROBLEMS_ATTRIB= createManagedFromKey(T_OBJ, IMG_OBJS_IGNORE_OPTIONAL_PROBLEMS_ATTRIB); + public static final ImageDescriptor DESC_OBJS_REFACTORING_FATAL= createManagedFromKey(T_OBJ, IMG_OBJS_REFACTORING_FATAL); public static final ImageDescriptor DESC_OBJS_REFACTORING_ERROR= createManagedFromKey(T_OBJ, IMG_OBJS_REFACTORING_ERROR); public static final ImageDescriptor DESC_OBJS_REFACTORING_WARNING= createManagedFromKey(T_OBJ, IMG_OBJS_REFACTORING_WARNING); @@ -380,6 +384,7 @@ public class JavaPluginImages { public static final ImageDescriptor DESC_OVR_RUN= createUnManagedCached(T_OVR, "run_co.gif"); //$NON-NLS-1$ public static final ImageDescriptor DESC_OVR_WARNING= createUnManagedCached(T_OVR, "warning_co.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_OVR_IGNORE_OPTIONAL_PROBLEMS= createUnManagedCached(T_OVR, "ignore_optional_problems_co.gif"); //$NON-NLS-1$ public static final ImageDescriptor DESC_OVR_ERROR= createUnManagedCached(T_OVR, "error_co.gif"); //$NON-NLS-1$ public static final ImageDescriptor DESC_OVR_BUILDPATH_ERROR= createUnManagedCached(T_OVR, "error_co_buildpath.gif"); //$NON-NLS-1$ public static final ImageDescriptor DESC_OVR_OVERRIDES= createUnManagedCached(T_OVR, "over_co.gif"); //$NON-NLS-1$ diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/BuildPathsPropertyPage.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/BuildPathsPropertyPage.java index 65f3a54f0c..a1eeb63664 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/BuildPathsPropertyPage.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/BuildPathsPropertyPage.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 @@ -28,6 +28,7 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.ProgressMonitorDialog; @@ -45,6 +46,7 @@ import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter; import org.eclipse.jdt.internal.ui.dialogs.StatusUtil; import org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext; +import org.eclipse.jdt.internal.ui.util.CoreUtility; import org.eclipse.jdt.internal.ui.util.ExceptionHandler; import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener; import org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathsBlock; @@ -214,6 +216,16 @@ public class BuildPathsPropertyPage extends PropertyPage implements IStatusChang if (fBuildPathsBlock != null) { getSettings().put(INDEX, fBuildPathsBlock.getPageIndex()); if (fBuildPathsBlock.hasChangesInDialog() || fBuildPathsBlock.isClassfileMissing()) { + boolean doBuild= false; + MessageDialog dialog= new MessageDialog(getShell(), PreferencesMessages.ComplianceConfigurationBlock_needsbuild_title, null, + PreferencesMessages.ComplianceConfigurationBlock_needsprojectbuild_message, MessageDialog.QUESTION, + new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2); + int res= dialog.open(); + if (res == 0) { + doBuild= true; + } else if (res != 1) { + return false; // cancel pressed + } IWorkspaceRunnable runnable= new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException, OperationCanceledException { fBuildPathsBlock.configureJavaProject(monitor); @@ -232,6 +244,9 @@ public class BuildPathsPropertyPage extends PropertyPage implements IStatusChang } else { op.runAsUserJob(PreferencesMessages.BuildPathsPropertyPage_job_title, null); } + if (doBuild) { + CoreUtility.getBuildJob(fBuildPathsBlock.getJavaProject().getProject()).schedule(); + } } } return true; diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaCompilerPropertyPage.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaCompilerPropertyPage.java new file mode 100644 index 0000000000..4a9f0ff919 --- /dev/null +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaCompilerPropertyPage.java @@ -0,0 +1,148 @@ +/******************************************************************************* + * Copyright (c) 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.jdt.internal.ui.preferences; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; + +import org.eclipse.core.resources.IWorkspaceRunnable; + +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.MessageDialog; + +import org.eclipse.ui.dialogs.PropertyPage; + +import org.eclipse.jdt.core.IClasspathEntry; +import org.eclipse.jdt.core.IJavaElement; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.core.IPackageFragmentRoot; +import org.eclipse.jdt.core.JavaModelException; + +import org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter; +import org.eclipse.jdt.internal.ui.util.CoreUtility; +import org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathSupport; +import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement; +import org.eclipse.jdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField; + +public class JavaCompilerPropertyPage extends PropertyPage { + + public static final String PROP_ID= "org.eclipse.jdt.ui.propertyPages.JavaCompilerPropertyPage"; //$NON-NLS-1$ + + private IJavaProject fProject; + + private CPListElement fElement; + + private boolean fIsValidElement; + + private SelectionButtonDialogField fIgnoreOptionalProblemsField; + + /** + * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) + */ + @Override + public void createControl(Composite parent) { + IAdaptable adaptable= getElement(); + IJavaElement elem= (IJavaElement) adaptable.getAdapter(IJavaElement.class); + try { + if (elem instanceof IPackageFragmentRoot) { + fProject= elem.getJavaProject(); + fElement= CPListElement.createFromExisting(((IPackageFragmentRoot) elem).getRawClasspathEntry(), fProject); + fIsValidElement= fElement != null; + } else { + fIsValidElement= false; + setDescription(PreferencesMessages.JavaCompilerPropertyPage_invalid_element_selection); + } + } catch (JavaModelException e) { + fIsValidElement= false; + setDescription(PreferencesMessages.JavaCompilerPropertyPage_invalid_element_selection); + } + super.createControl(parent); + } + + /** + * @see org.eclipse.jface.preference.IPreferencePage#performOk() + */ + @Override + public boolean performOk() { + if (fIsValidElement && fIgnoreOptionalProblemsField.isSelected() != isIgnoreOptionalProblems()) { + boolean doBuild= false; + MessageDialog dialog= new MessageDialog(getShell(), PreferencesMessages.ComplianceConfigurationBlock_needsbuild_title, null, + PreferencesMessages.ComplianceConfigurationBlock_needsprojectbuild_message, MessageDialog.QUESTION, + new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2); + int res= dialog.open(); + if (res == 0) { + doBuild= true; + } else if (res != 1) { + return false; // cancel pressed + } + String newValue= fIgnoreOptionalProblemsField.isSelected() ? "true" : null; //$NON-NLS-1$ + fElement.setAttribute(CPListElement.IGNORE_OPTIONAL_PROBLEMS, newValue); + IWorkspaceRunnable runnable= getRunnable(getShell(), fProject, fElement.getClasspathEntry()); + WorkbenchRunnableAdapter op= new WorkbenchRunnableAdapter(runnable); + op.runAsUserJob(PreferencesMessages.BuildPathsPropertyPage_job_title, null); + if (doBuild) { + CoreUtility.getBuildJob(fProject.getProject()).schedule(); + } + } + return true; + } + + /* + * @see PreferencePage#createContents(Composite) + */ + @Override + protected Control createContents(Composite parent) { + if (!fIsValidElement) { + return new Composite(parent, SWT.NONE); + } + Composite composite= new Composite(parent, SWT.NONE); + GridLayout topLayout= new GridLayout(); + topLayout.numColumns= 1; + topLayout.marginWidth= 0; + topLayout.marginHeight= 0; + composite.setLayout(topLayout); + + fIgnoreOptionalProblemsField= new SelectionButtonDialogField(SWT.CHECK); + fIgnoreOptionalProblemsField.setLabelText(PreferencesMessages.JavaCompilerPropertyPage_ignore_optional_problems_label); + fIgnoreOptionalProblemsField.setSelection(isIgnoreOptionalProblems()); + fIgnoreOptionalProblemsField.doFillIntoGrid(composite, 1); + return composite; + } + + /* + * @see PreferencePage#performDefaults() + */ + @Override + protected void performDefaults() { + fIgnoreOptionalProblemsField.setSelection(false); + super.performDefaults(); + } + + private static IWorkspaceRunnable getRunnable(final Shell shell, final IJavaProject project, final IClasspathEntry entry) { + return new IWorkspaceRunnable() { + public void run(IProgressMonitor monitor) throws CoreException { + String[] changedAttributes= { CPListElement.IGNORE_OPTIONAL_PROBLEMS }; + BuildPathSupport.modifyClasspathEntry(shell, entry, changedAttributes, project, null, entry.getReferencingEntry() != null, monitor); + } + }; + } + + private boolean isIgnoreOptionalProblems() { + return "true".equals(fElement.getAttribute(CPListElement.IGNORE_OPTIONAL_PROBLEMS)); //$NON-NLS-1$ + } +} diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavadocProblemsConfigurationBlock.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavadocProblemsConfigurationBlock.java index 60e157ac17..b1394967d9 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavadocProblemsConfigurationBlock.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavadocProblemsConfigurationBlock.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 @@ -109,6 +109,8 @@ public class JavadocProblemsConfigurationBlock extends OptionsConfigurationBlock Composite javadocComposite= createJavadocTabContent(parent); + createIgnoreOptionalProblemsLink(parent); + validateSettings(null, null, null); return javadocComposite; diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/OptionsConfigurationBlock.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/OptionsConfigurationBlock.java index 6d72a82036..f238c8db42 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/OptionsConfigurationBlock.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/OptionsConfigurationBlock.java @@ -74,7 +74,11 @@ import org.eclipse.ui.preferences.IWorkingCopyManager; import org.eclipse.ui.preferences.WorkingCopyManager; import org.eclipse.ui.progress.WorkbenchJob; +import org.eclipse.jdt.core.IClasspathAttribute; +import org.eclipse.jdt.core.IClasspathEntry; +import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.JavaCore; +import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.launching.JavaRuntime; @@ -85,6 +89,7 @@ import org.eclipse.jdt.internal.ui.util.CoreUtility; import org.eclipse.jdt.internal.ui.util.SWTUtil; import org.eclipse.jdt.internal.ui.util.StringMatcher; import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener; +import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement; /** * Abstract options configuration block providing a general implementation for setting up @@ -1623,7 +1628,54 @@ public abstract class OptionsConfigurationBlock { combo.setEnabled(enabled); label.setEnabled(enabled); } - + + protected void createIgnoreOptionalProblemsLink(Composite parent) { + if (isIgnoreOptionalProblems()) { + Link link= new Link(parent, SWT.NONE); + GridData data= new GridData(); + data.verticalIndent= 5; + link.setLayoutData(data); + link.setText(PreferencesMessages.OptionsConfigurationBlock_IgnoreOptionalProblemsLink); + link.addSelectionListener(new SelectionListener() { + public void widgetSelected(SelectionEvent arg0) { + getPreferenceContainer().openPage(BuildPathsPropertyPage.PROP_ID, null); + } + + public void widgetDefaultSelected(SelectionEvent arg0) { + getPreferenceContainer().openPage(BuildPathsPropertyPage.PROP_ID, null); + } + }); + } + } + + private boolean isIgnoreOptionalProblems() { + if (fProject == null) { + return false; + } + IJavaProject javaProject= JavaCore.create(fProject); + if (javaProject == null) { + return false; + } + try { + IClasspathEntry[] classpathEntries= javaProject.getRawClasspath(); + for (int i= 0; i < classpathEntries.length; i++) { + IClasspathEntry entry= classpathEntries[i]; + if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { + IClasspathAttribute[] extraAttributes= entry.getExtraAttributes(); + for (int j= 0; j < extraAttributes.length; j++) { + IClasspathAttribute attrib= extraAttributes[j]; + if (CPListElement.IGNORE_OPTIONAL_PROBLEMS.equals(attrib.getName())) { + return "true".equals(attrib.getValue()); //$NON-NLS-1$ + } + } + } + } + } catch (JavaModelException e) { + return false; + } + return false; + } + protected void setTextFieldEnabled(Key key, boolean enabled) { Text text= getTextControl(key); Label label= fLabels.get(text); diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java index b4b022eba0..4e9f8534b4 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java @@ -739,6 +739,8 @@ public final class PreferencesMessages extends NLS { public static String ProjectSelectionDialog_title; public static String ProjectSelectionDialog_desciption; public static String ProjectSelectionDialog_filter; + public static String JavaCompilerPropertyPage_ignore_optional_problems_label; + public static String JavaCompilerPropertyPage_invalid_element_selection; static { NLS.initializeMessages(BUNDLE_NAME, PreferencesMessages.class); @@ -819,6 +821,7 @@ public final class PreferencesMessages extends NLS { public static String OptionsConfigurationBlock_On; public static String OptionsConfigurationBlock_RefreshFilter; public static String OptionsConfigurationBlock_TypeFilterText; + public static String OptionsConfigurationBlock_IgnoreOptionalProblemsLink; public static String FilterTextControl_Clear; public static String FilterTextControl_ClearFilterField; diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties index 199c7ef9e4..319d111ca6 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties @@ -940,6 +940,10 @@ OptionsConfigurationBlock_Off=off OptionsConfigurationBlock_On=on OptionsConfigurationBlock_RefreshFilter=Refresh Filter OptionsConfigurationBlock_TypeFilterText=type filter text (use ~ to filter on preference values, e.g. ~ignore or ~off) +OptionsConfigurationBlock_IgnoreOptionalProblemsLink=At least one of source folders ignores optional compile problems (configure it <a>here</a>) 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<IClasspathEntry> modified= new HashSet<IClasspathEntry>(); 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; |