Lines 18-23
Link Here
|
18 |
import org.eclipse.swt.widgets.Composite; |
18 |
import org.eclipse.swt.widgets.Composite; |
19 |
import org.eclipse.swt.widgets.Control; |
19 |
import org.eclipse.swt.widgets.Control; |
20 |
import org.eclipse.swt.widgets.Label; |
20 |
import org.eclipse.swt.widgets.Label; |
|
|
21 |
import org.eclipse.swt.widgets.Text; |
21 |
|
22 |
|
22 |
import org.eclipse.core.runtime.CoreException; |
23 |
import org.eclipse.core.runtime.CoreException; |
23 |
import org.eclipse.core.runtime.IAdaptable; |
24 |
import org.eclipse.core.runtime.IAdaptable; |
Lines 41-46
Link Here
|
41 |
import org.eclipse.jdt.core.IJavaProject; |
42 |
import org.eclipse.jdt.core.IJavaProject; |
42 |
import org.eclipse.jdt.core.IPackageFragmentRoot; |
43 |
import org.eclipse.jdt.core.IPackageFragmentRoot; |
43 |
import org.eclipse.jdt.core.JavaCore; |
44 |
import org.eclipse.jdt.core.JavaCore; |
|
|
45 |
import org.eclipse.jdt.core.JavaModelException; |
44 |
|
46 |
|
45 |
import org.eclipse.jdt.internal.corext.util.JavaModelUtil; |
47 |
import org.eclipse.jdt.internal.corext.util.JavaModelUtil; |
46 |
import org.eclipse.jdt.internal.corext.util.Messages; |
48 |
import org.eclipse.jdt.internal.corext.util.Messages; |
Lines 90-96
Link Here
|
90 |
fEntry= null; |
92 |
fEntry= null; |
91 |
fRoot= getJARPackageFragmentRoot(); |
93 |
fRoot= getJARPackageFragmentRoot(); |
92 |
if (fRoot == null || fRoot.getKind() != IPackageFragmentRoot.K_BINARY) { |
94 |
if (fRoot == null || fRoot.getKind() != IPackageFragmentRoot.K_BINARY) { |
93 |
return createMessageContent(composite, PreferencesMessages.SourceAttachmentPropertyPage_noarchive_message); |
95 |
return createMessageContent(composite, PreferencesMessages.SourceAttachmentPropertyPage_noarchive_message, null); |
94 |
} |
96 |
} |
95 |
|
97 |
|
96 |
IPath containerPath= null; |
98 |
IPath containerPath= null; |
Lines 101-116
Link Here
|
101 |
ClasspathContainerInitializer initializer= JavaCore.getClasspathContainerInitializer(containerPath.segment(0)); |
103 |
ClasspathContainerInitializer initializer= JavaCore.getClasspathContainerInitializer(containerPath.segment(0)); |
102 |
IClasspathContainer container= JavaCore.getClasspathContainer(containerPath, jproject); |
104 |
IClasspathContainer container= JavaCore.getClasspathContainer(containerPath, jproject); |
103 |
if (initializer == null || container == null) { |
105 |
if (initializer == null || container == null) { |
104 |
return createMessageContent(composite, Messages.format(PreferencesMessages.SourceAttachmentPropertyPage_invalid_container, BasicElementLabels.getPathLabel(containerPath, false))); |
106 |
return createMessageContent(composite, Messages.format(PreferencesMessages.SourceAttachmentPropertyPage_invalid_container, BasicElementLabels.getPathLabel(containerPath, false)), fRoot); |
105 |
} |
107 |
} |
106 |
String containerName= container.getDescription(); |
108 |
String containerName= container.getDescription(); |
107 |
|
109 |
|
108 |
IStatus status= initializer.getSourceAttachmentStatus(containerPath, jproject); |
110 |
IStatus status= initializer.getSourceAttachmentStatus(containerPath, jproject); |
109 |
if (status.getCode() == ClasspathContainerInitializer.ATTRIBUTE_NOT_SUPPORTED) { |
111 |
if (status.getCode() == ClasspathContainerInitializer.ATTRIBUTE_NOT_SUPPORTED) { |
110 |
return createMessageContent(composite, Messages.format(PreferencesMessages.SourceAttachmentPropertyPage_not_supported, containerName)); |
112 |
return createMessageContent(composite, Messages.format(PreferencesMessages.SourceAttachmentPropertyPage_not_supported, containerName), null); |
111 |
} |
113 |
} |
112 |
if (status.getCode() == ClasspathContainerInitializer.ATTRIBUTE_READ_ONLY) { |
114 |
if (status.getCode() == ClasspathContainerInitializer.ATTRIBUTE_READ_ONLY) { |
113 |
return createMessageContent(composite, Messages.format(PreferencesMessages.SourceAttachmentPropertyPage_read_only, containerName)); |
115 |
return createMessageContent(composite, Messages.format(PreferencesMessages.SourceAttachmentPropertyPage_read_only, containerName), fRoot); |
114 |
} |
116 |
} |
115 |
entry= JavaModelUtil.findEntryInContainer(container, fRoot.getPath()); |
117 |
entry= JavaModelUtil.findEntryInContainer(container, fRoot.getPath()); |
116 |
} |
118 |
} |
Lines 121-132
Link Here
|
121 |
return fSourceAttachmentBlock.createControl(composite); |
123 |
return fSourceAttachmentBlock.createControl(composite); |
122 |
} catch (CoreException e) { |
124 |
} catch (CoreException e) { |
123 |
JavaPlugin.log(e); |
125 |
JavaPlugin.log(e); |
124 |
return createMessageContent(composite, PreferencesMessages.SourceAttachmentPropertyPage_noarchive_message); |
126 |
return createMessageContent(composite, PreferencesMessages.SourceAttachmentPropertyPage_noarchive_message, null); |
125 |
} |
127 |
} |
126 |
} |
128 |
} |
127 |
|
129 |
|
128 |
|
130 |
|
129 |
private Control createMessageContent(Composite composite, String message) { |
131 |
private Control createMessageContent(Composite composite, String message, IPackageFragmentRoot root) { |
130 |
Composite inner= new Composite(composite, SWT.NONE); |
132 |
Composite inner= new Composite(composite, SWT.NONE); |
131 |
GridLayout layout= new GridLayout(); |
133 |
GridLayout layout= new GridLayout(); |
132 |
layout.marginHeight= 0; |
134 |
layout.marginHeight= 0; |
Lines 137-144
Link Here
|
137 |
gd.widthHint= convertWidthInCharsToPixels(80); |
139 |
gd.widthHint= convertWidthInCharsToPixels(80); |
138 |
|
140 |
|
139 |
Label label= new Label(inner, SWT.LEFT + SWT.WRAP); |
141 |
Label label= new Label(inner, SWT.LEFT + SWT.WRAP); |
140 |
label.setText(message); |
|
|
141 |
label.setLayoutData(gd); |
142 |
label.setLayoutData(gd); |
|
|
143 |
|
144 |
try { |
145 |
if (root != null) { |
146 |
message= message + "\n\n" + PreferencesMessages.SourceAttachmentPropertyPage_location_path; //$NON-NLS-1$ |
147 |
|
148 |
Text location= new Text(inner, SWT.READ_ONLY | SWT.WRAP); |
149 |
gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); |
150 |
gd.widthHint= convertWidthInCharsToPixels(80); |
151 |
location.setLayoutData(gd); |
152 |
IPath sourceAttachmentPath= root.getSourceAttachmentPath(); |
153 |
String locationPath= PreferencesMessages.SourceAttachmentPropertyPage_locationPath_none; |
154 |
if (sourceAttachmentPath != null) |
155 |
locationPath= sourceAttachmentPath.toString(); |
156 |
location.setText(locationPath); |
157 |
} |
158 |
} catch (JavaModelException e) { |
159 |
JavaPlugin.log(e); |
160 |
// don't show location |
161 |
} |
162 |
|
163 |
label.setText(message); |
142 |
return inner; |
164 |
return inner; |
143 |
} |
165 |
} |
144 |
|
166 |
|