### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.ui Index: ui/org/eclipse/jdt/internal/ui/preferences/JavadocConfigurationPropertyPage.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavadocConfigurationPropertyPage.java,v retrieving revision 1.37 diff -u -r1.37 JavadocConfigurationPropertyPage.java --- ui/org/eclipse/jdt/internal/ui/preferences/JavadocConfigurationPropertyPage.java 8 Mar 2010 20:23:48 -0000 1.37 +++ ui/org/eclipse/jdt/internal/ui/preferences/JavadocConfigurationPropertyPage.java 3 Feb 2011 18:23:33 -0000 @@ -14,9 +14,13 @@ import java.net.URL; import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.CoreException; @@ -45,6 +49,7 @@ import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jdt.internal.corext.javadoc.JavaDocLocations; import org.eclipse.jdt.internal.corext.util.JavaModelUtil; import org.eclipse.jdt.internal.corext.util.Messages; @@ -69,6 +74,7 @@ private JavadocConfigurationBlock fJavadocConfigurationBlock; private boolean fIsValidElement; + private boolean fIsReadOnly; private IPath fContainerPath; private IClasspathEntry fEntry; @@ -131,11 +137,12 @@ setDescription(Messages.format(PreferencesMessages.JavadocConfigurationPropertyPage_not_supported, containerName)); return null; } + IClasspathEntry entry= JavaModelUtil.findEntryInContainer(container, jarPath); if (status.getCode() == ClasspathContainerInitializer.ATTRIBUTE_READ_ONLY) { setDescription(Messages.format(PreferencesMessages.JavadocConfigurationPropertyPage_read_only, containerName)); - return null; + fIsReadOnly= true; + return entry; } - IClasspathEntry entry= JavaModelUtil.findEntryInContainer(container, jarPath); Assert.isNotNull(entry); setDescription(PreferencesMessages.JavadocConfigurationPropertyPage_IsPackageFragmentRoot_description); return entry; @@ -145,8 +152,32 @@ * @see PreferencePage#createContents(Composite) */ protected Control createContents(Composite parent) { - if (!fIsValidElement) { - return new Composite(parent, SWT.NONE); + if (!fIsValidElement || fIsReadOnly) { + Composite inner= new Composite(parent, SWT.NONE); + + if (fIsReadOnly) { + GridLayout layout= new GridLayout(); + layout.marginWidth= 0; + inner.setLayout(layout); + + Label label= new Label(inner, SWT.WRAP); + label.setText(PreferencesMessages.JavadocConfigurationPropertyPage_location_path); + + Text location= new Text(inner, SWT.READ_ONLY | SWT.WRAP); + GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); + gd.widthHint= convertWidthInCharsToPixels(80); + location.setLayoutData(gd); + String locationPath= PreferencesMessages.JavadocConfigurationPropertyPage_locationPath_none; + if (fEntry != null) { + URL javadocUrl= JavaDocLocations.getLibraryJavadocLocation(fEntry); + if (javadocUrl != null) { + locationPath= javadocUrl.toExternalForm(); + } + } + location.setText(locationPath); + Dialog.applyDialogFont(inner); + } + return inner; } IJavaElement elem= getJavaElement(); Index: ui/org/eclipse/jdt/internal/ui/preferences/NativeLibrariesPropertyPage.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/NativeLibrariesPropertyPage.java,v retrieving revision 1.10 diff -u -r1.10 NativeLibrariesPropertyPage.java --- ui/org/eclipse/jdt/internal/ui/preferences/NativeLibrariesPropertyPage.java 8 Mar 2010 20:23:48 -0000 1.10 +++ ui/org/eclipse/jdt/internal/ui/preferences/NativeLibrariesPropertyPage.java 3 Feb 2011 18:23:34 -0000 @@ -13,9 +13,13 @@ import java.lang.reflect.InvocationTargetException; import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.CoreException; @@ -62,6 +66,7 @@ private NativeLibrariesConfigurationBlock fConfigurationBlock; private boolean fIsValidElement; + private boolean fIsReadOnly; private IClasspathEntry fEntry; private IPath fContainerPath; private String fInitialNativeLibPath; @@ -83,7 +88,7 @@ if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { fContainerPath= entry.getPath(); fEntry= handleContainerEntry(fContainerPath, elem.getJavaProject(), root.getPath()); - fIsValidElement= fEntry != null; + fIsValidElement= fEntry != null && !fIsReadOnly; } else { fContainerPath= null; fEntry= entry; @@ -114,11 +119,12 @@ setDescription(Messages.format(PreferencesMessages.NativeLibrariesPropertyPage_not_supported, containerName)); return null; } + IClasspathEntry entry= JavaModelUtil.findEntryInContainer(container, jarPath); if (status.getCode() == ClasspathContainerInitializer.ATTRIBUTE_READ_ONLY) { setDescription(Messages.format(PreferencesMessages.NativeLibrariesPropertyPage_read_only, containerName)); - return null; + fIsReadOnly= true; + return entry; } - IClasspathEntry entry= JavaModelUtil.findEntryInContainer(container, jarPath); Assert.isNotNull(entry); return entry; } @@ -127,21 +133,38 @@ * {@inheritDoc} */ protected Control createContents(Composite parent) { - if (!fIsValidElement) - return new Composite(parent, SWT.NONE); + if (!fIsValidElement || fIsReadOnly) { + Composite inner= new Composite(parent, SWT.NONE); + + if (fIsReadOnly) { + GridLayout layout= new GridLayout(); + layout.marginWidth= 0; + inner.setLayout(layout); + + Label label= new Label(inner, SWT.WRAP); + label.setText(PreferencesMessages.NativeLibrariesPropertyPage_location_path); + + Text location= new Text(inner, SWT.READ_ONLY | SWT.WRAP); + GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); + gd.widthHint= convertWidthInCharsToPixels(80); + location.setLayoutData(gd); + String locationPath= PreferencesMessages.NativeLibrariesPropertyPage_locationPath_none; + if (fEntry != null) { + String nativeLibrariesPath= getNativeLibrariesPath(fEntry); + if (nativeLibrariesPath != null) + locationPath= nativeLibrariesPath; + } + location.setText(locationPath); + Dialog.applyDialogFont(inner); + } + return inner; + } IJavaElement elem= getJavaElement(); if (elem == null) return new Composite(parent, SWT.NONE); - fInitialNativeLibPath= null; - IClasspathAttribute[] extraAttributes= fEntry.getExtraAttributes(); - for (int i= 0; i < extraAttributes.length; i++) { - if (extraAttributes[i].getName().equals(JavaRuntime.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY)) { - fInitialNativeLibPath= extraAttributes[i].getValue(); - break; - } - } + fInitialNativeLibPath= getNativeLibrariesPath(fEntry); fConfigurationBlock= new NativeLibrariesConfigurationBlock(this, getShell(), fInitialNativeLibPath, fEntry); Control control= fConfigurationBlock.createContents(parent); @@ -149,6 +172,16 @@ return control; } + private static String getNativeLibrariesPath(IClasspathEntry entry) { + IClasspathAttribute[] extraAttributes= entry.getExtraAttributes(); + for (int i= 0; i < extraAttributes.length; i++) { + if (extraAttributes[i].getName().equals(JavaRuntime.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY)) { + return extraAttributes[i].getValue(); + } + } + return null; + } + /** * {@inheritDoc} */ Index: ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java,v retrieving revision 1.140 diff -u -r1.140 PreferencesMessages.java --- ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java 24 Jan 2011 20:30:40 -0000 1.140 +++ ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java 3 Feb 2011 18:23:34 -0000 @@ -232,6 +232,8 @@ public static String JavadocConfigurationPropertyPage_IsPackageFragmentRoot_description; public static String JavadocConfigurationPropertyPage_IsIncorrectElement_description; public static String JavadocConfigurationPropertyPage_IsJavaProject_description; + public static String JavadocConfigurationPropertyPage_location_path; + public static String JavadocConfigurationPropertyPage_locationPath_none; public static String JavadocConfigurationBlock_browse_folder_button; public static String JavadocConfigurationBlock_error_notafolder; public static String JavadocConfigurationBlock_javadocFolderDialog_label; @@ -267,10 +269,14 @@ public static String SourceAttachmentPropertyPage_error_title; public static String SourceAttachmentPropertyPage_error_message; public static String SourceAttachmentPropertyPage_invalid_container; + public static String SourceAttachmentPropertyPage_location_path; + public static String SourceAttachmentPropertyPage_locationPath_none; public static String SourceAttachmentPropertyPage_noarchive_message; public static String NativeLibrariesPropertyPage_invalidElementSelection_desription; public static String NativeLibrariesPropertyPage_errorAttaching_title; public static String NativeLibrariesPropertyPage_errorAttaching_message; + public static String NativeLibrariesPropertyPage_location_path; + public static String NativeLibrariesPropertyPage_locationPath_none; public static String AppearancePreferencePage_description; public static String AppearancePreferencePage_methodreturntype_label; public static String AppearancePreferencePage_showCategory_label; Index: ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties,v retrieving revision 1.526 diff -u -r1.526 PreferencesMessages.properties --- ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties 24 Jan 2011 21:10:58 -0000 1.526 +++ ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties 3 Feb 2011 18:23:34 -0000 @@ -235,6 +235,8 @@ JavadocConfigurationPropertyPage_IsIncorrectElement_description=Javadoc location can only be attached to Java projects or archives and class folders in Java projects. Source folders use the location specified at their project. JavadocConfigurationPropertyPage_IsJavaProject_description=Specify the location of the project\'s Javadoc documentation. This location is used by the Javadoc export wizard as the default value and by the \'Open Attached Javadoc\' action. For example: \'file:/c:/myworkspace/myproject/doc\'. JavadocConfigurationPropertyPage_invalid_container=The current class path entry belongs to container ''{0}'' which can not be configured. +JavadocConfigurationPropertyPage_location_path=&Location path: +JavadocConfigurationPropertyPage_locationPath_none=(none) JavadocConfigurationPropertyPage_not_supported=The current class path entry belongs to container ''{0}'' which does not support the attachment of Javadoc to its entries. JavadocConfigurationBlock_browse_archive_button=&Browse... @@ -274,6 +276,8 @@ SourceAttachmentPropertyPage_not_supported=The current class path entry belongs to container ''{0}'' which does not support the attachment of sources to its entries. SourceAttachmentPropertyPage_noarchive_message=Source can only be attached to archive and class folders in Java projects. SourceAttachmentPropertyPage_invalid_container=The current class path entry belongs to container ''{0}'' which can not be configured. +SourceAttachmentPropertyPage_location_path=&Location path: +SourceAttachmentPropertyPage_locationPath_none=(none) NativeLibrariesPropertyPage_invalidElementSelection_desription=Native libraries can not be attached to the selected element. NativeLibrariesPropertyPage_errorAttaching_message=An error occurred while associating the library. @@ -888,6 +892,8 @@ ProjectSelectionDialog_filter=Show only &projects with project specific settings NativeLibrariesPropertyPage_errorAttaching_title=Error Attaching native library NativeLibrariesPropertyPage_invalid_container=The current class path entry belongs to container ''{0}'' which can not be configured. +NativeLibrariesPropertyPage_location_path=&Location path: +NativeLibrariesPropertyPage_locationPath_none=(none) NativeLibrariesPropertyPage_not_supported=The current class path entry belongs to container ''{0}'' which does not support the attachment of native libraries to its entries. NativeLibrariesPropertyPage_read_only=The current class path entry belongs to container ''{0}'' which does not allow user modifications to native libraries on its entries. Index: ui/org/eclipse/jdt/internal/ui/preferences/SourceAttachmentPropertyPage.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/SourceAttachmentPropertyPage.java,v retrieving revision 1.44 diff -u -r1.44 SourceAttachmentPropertyPage.java --- ui/org/eclipse/jdt/internal/ui/preferences/SourceAttachmentPropertyPage.java 8 Mar 2010 20:23:48 -0000 1.44 +++ ui/org/eclipse/jdt/internal/ui/preferences/SourceAttachmentPropertyPage.java 3 Feb 2011 18:23:34 -0000 @@ -18,6 +18,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; @@ -41,6 +42,7 @@ import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.jdt.core.JavaCore; +import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.internal.corext.util.JavaModelUtil; import org.eclipse.jdt.internal.corext.util.Messages; @@ -90,7 +92,7 @@ fEntry= null; fRoot= getJARPackageFragmentRoot(); if (fRoot == null || fRoot.getKind() != IPackageFragmentRoot.K_BINARY) { - return createMessageContent(composite, PreferencesMessages.SourceAttachmentPropertyPage_noarchive_message); + return createMessageContent(composite, PreferencesMessages.SourceAttachmentPropertyPage_noarchive_message, null); } IPath containerPath= null; @@ -101,16 +103,16 @@ ClasspathContainerInitializer initializer= JavaCore.getClasspathContainerInitializer(containerPath.segment(0)); IClasspathContainer container= JavaCore.getClasspathContainer(containerPath, jproject); if (initializer == null || container == null) { - return createMessageContent(composite, Messages.format(PreferencesMessages.SourceAttachmentPropertyPage_invalid_container, BasicElementLabels.getPathLabel(containerPath, false))); + return createMessageContent(composite, Messages.format(PreferencesMessages.SourceAttachmentPropertyPage_invalid_container, BasicElementLabels.getPathLabel(containerPath, false)), fRoot); } String containerName= container.getDescription(); IStatus status= initializer.getSourceAttachmentStatus(containerPath, jproject); if (status.getCode() == ClasspathContainerInitializer.ATTRIBUTE_NOT_SUPPORTED) { - return createMessageContent(composite, Messages.format(PreferencesMessages.SourceAttachmentPropertyPage_not_supported, containerName)); + return createMessageContent(composite, Messages.format(PreferencesMessages.SourceAttachmentPropertyPage_not_supported, containerName), null); } if (status.getCode() == ClasspathContainerInitializer.ATTRIBUTE_READ_ONLY) { - return createMessageContent(composite, Messages.format(PreferencesMessages.SourceAttachmentPropertyPage_read_only, containerName)); + return createMessageContent(composite, Messages.format(PreferencesMessages.SourceAttachmentPropertyPage_read_only, containerName), fRoot); } entry= JavaModelUtil.findEntryInContainer(container, fRoot.getPath()); } @@ -121,12 +123,12 @@ return fSourceAttachmentBlock.createControl(composite); } catch (CoreException e) { JavaPlugin.log(e); - return createMessageContent(composite, PreferencesMessages.SourceAttachmentPropertyPage_noarchive_message); + return createMessageContent(composite, PreferencesMessages.SourceAttachmentPropertyPage_noarchive_message, null); } } - private Control createMessageContent(Composite composite, String message) { + private Control createMessageContent(Composite composite, String message, IPackageFragmentRoot root) { Composite inner= new Composite(composite, SWT.NONE); GridLayout layout= new GridLayout(); layout.marginHeight= 0; @@ -137,8 +139,28 @@ gd.widthHint= convertWidthInCharsToPixels(80); Label label= new Label(inner, SWT.LEFT + SWT.WRAP); - label.setText(message); label.setLayoutData(gd); + + try { + if (root != null) { + message= message + "\n\n" + PreferencesMessages.SourceAttachmentPropertyPage_location_path; //$NON-NLS-1$ + + Text location= new Text(inner, SWT.READ_ONLY | SWT.WRAP); + gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); + gd.widthHint= convertWidthInCharsToPixels(80); + location.setLayoutData(gd); + IPath sourceAttachmentPath= root.getSourceAttachmentPath(); + String locationPath= PreferencesMessages.SourceAttachmentPropertyPage_locationPath_none; + if (sourceAttachmentPath != null) + locationPath= sourceAttachmentPath.toString(); + location.setText(locationPath); + } + } catch (JavaModelException e) { + JavaPlugin.log(e); + // don't show location + } + + label.setText(message); return inner; }