1 11 package org.eclipse.jdt.internal.ui.wizards.buildpaths; 12 13 import java.net.MalformedURLException ; 14 import java.net.URL ; 15 16 import org.eclipse.swt.widgets.Shell; 17 18 import org.eclipse.jface.resource.ImageDescriptor; 19 20 import org.eclipse.jdt.core.IClasspathAttribute; 21 import org.eclipse.jdt.core.JavaCore; 22 23 import org.eclipse.jdt.internal.corext.javadoc.JavaDocLocations; 24 import org.eclipse.jdt.internal.corext.util.Messages; 25 26 import org.eclipse.jdt.ui.wizards.BuildPathDialogAccess; 27 import org.eclipse.jdt.ui.wizards.ClasspathAttributeConfiguration; 28 29 import org.eclipse.jdt.internal.ui.JavaPluginImages; 30 import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages; 31 32 public class JavadocAttributeConfiguration extends ClasspathAttributeConfiguration { 33 34 37 public ImageDescriptor getImageDescriptor(ClasspathAttributeAccess attribute) { 38 return JavaPluginImages.DESC_OBJS_JAVADOC_LOCATION_ATTRIB; 39 } 40 41 44 public String getNameLabel(ClasspathAttributeAccess attribute) { 45 return NewWizardMessages.CPListLabelProvider_javadoc_location_label; 46 } 47 48 51 public String getValueLabel(ClasspathAttributeAccess access) { 52 String arg= null; 53 String str= access.getClasspathAttribute().getValue(); 54 if (str != null) { 55 String prefix= JavaDocLocations.ARCHIVE_PREFIX; 56 if (str.startsWith(prefix)) { 57 int sepIndex= str.lastIndexOf("!/"); if (sepIndex == -1) { 59 arg= str.substring(prefix.length()); 60 } else { 61 String archive= str.substring(prefix.length(), sepIndex); 62 String root= str.substring(sepIndex + 2); 63 if (root.length() > 0) { 64 arg= Messages.format(NewWizardMessages.CPListLabelProvider_twopart, new String [] { archive, root }); 65 } else { 66 arg= archive; 67 } 68 } 69 } else { 70 arg= str; 71 } 72 } else { 73 arg= NewWizardMessages.CPListLabelProvider_none; 74 } 75 return arg; 76 } 77 78 81 public IClasspathAttribute performEdit(Shell shell, ClasspathAttributeAccess attribute) { 82 String initialLocation= attribute.getClasspathAttribute().getValue(); 83 String elementName= attribute.getParentClasspassEntry().getPath().lastSegment(); 84 try { 85 URL locationURL= initialLocation != null ? new URL (initialLocation) : null; 86 URL [] result= BuildPathDialogAccess.configureJavadocLocation(shell, elementName, locationURL); 87 if (result != null) { 88 URL newURL= result[0]; 89 String string= newURL != null ? newURL.toExternalForm() : null; 90 return JavaCore.newClasspathAttribute(IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, string); 91 } 92 } catch (MalformedURLException e) { 93 } 95 return null; 96 } 97 98 101 public IClasspathAttribute performRemove(ClasspathAttributeAccess attribute) { 102 return JavaCore.newClasspathAttribute(IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, null); 103 } 104 105 108 public boolean canEdit(ClasspathAttributeAccess attribute) { 109 return true; 110 } 111 112 115 public boolean canRemove(ClasspathAttributeAccess attribute) { 116 return attribute.getClasspathAttribute().getValue() != null; 117 } 118 119 120 121 } 122 | Popular Tags |