Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2000, 2010 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2011 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
Lines 12-17
Link Here
|
12 |
|
12 |
|
13 |
import java.lang.reflect.InvocationTargetException; |
13 |
import java.lang.reflect.InvocationTargetException; |
14 |
import java.net.URL; |
14 |
import java.net.URL; |
|
|
15 |
import java.util.ArrayList; |
15 |
|
16 |
|
16 |
import org.eclipse.swt.SWT; |
17 |
import org.eclipse.swt.SWT; |
17 |
import org.eclipse.swt.layout.GridData; |
18 |
import org.eclipse.swt.layout.GridData; |
Lines 58-63
Link Here
|
58 |
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; |
59 |
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; |
59 |
import org.eclipse.jdt.internal.ui.JavaPlugin; |
60 |
import org.eclipse.jdt.internal.ui.JavaPlugin; |
60 |
import org.eclipse.jdt.internal.ui.dialogs.StatusUtil; |
61 |
import org.eclipse.jdt.internal.ui.dialogs.StatusUtil; |
|
|
62 |
import org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2; |
61 |
import org.eclipse.jdt.internal.ui.util.ExceptionHandler; |
63 |
import org.eclipse.jdt.internal.ui.util.ExceptionHandler; |
62 |
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; |
64 |
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; |
63 |
import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener; |
65 |
import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener; |
Lines 79-84
Link Here
|
79 |
private IPath fContainerPath; |
81 |
private IPath fContainerPath; |
80 |
private IClasspathEntry fEntry; |
82 |
private IClasspathEntry fEntry; |
81 |
private URL fInitalLocation; |
83 |
private URL fInitalLocation; |
|
|
84 |
private boolean finitialPreferAttachedJavadoc; |
82 |
|
85 |
|
83 |
public JavadocConfigurationPropertyPage() { |
86 |
public JavadocConfigurationPropertyPage() { |
84 |
} |
87 |
} |
Lines 185-197
Link Here
|
185 |
if (elem != null) { |
188 |
if (elem != null) { |
186 |
try { |
189 |
try { |
187 |
fInitalLocation= JavaUI.getJavadocBaseLocation(elem); |
190 |
fInitalLocation= JavaUI.getJavadocBaseLocation(elem); |
|
|
191 |
finitialPreferAttachedJavadoc= JavadocContentAccess2.getPreferAttachedJavadoc(elem); |
188 |
} catch (JavaModelException e) { |
192 |
} catch (JavaModelException e) { |
189 |
JavaPlugin.log(e); |
193 |
JavaPlugin.log(e); |
190 |
} |
194 |
} |
191 |
} |
195 |
} |
192 |
|
196 |
|
193 |
boolean isProject= (elem instanceof IJavaProject); |
197 |
boolean isProject= (elem instanceof IJavaProject); |
194 |
fJavadocConfigurationBlock= new JavadocConfigurationBlock(getShell(), this, fInitalLocation, isProject); |
198 |
fJavadocConfigurationBlock= new JavadocConfigurationBlock(getShell(), this, fInitalLocation, finitialPreferAttachedJavadoc, isProject); |
195 |
Control control= fJavadocConfigurationBlock.createContents(parent); |
199 |
Control control= fJavadocConfigurationBlock.createContents(parent); |
196 |
control.setVisible(elem != null); |
200 |
control.setVisible(elem != null); |
197 |
|
201 |
|
Lines 236-251
Link Here
|
236 |
*/ |
240 |
*/ |
237 |
public boolean performOk() { |
241 |
public boolean performOk() { |
238 |
if (fJavadocConfigurationBlock != null) { |
242 |
if (fJavadocConfigurationBlock != null) { |
239 |
URL javadocLocation= fJavadocConfigurationBlock.getJavadocLocation(); |
243 |
final URL javadocLocation= fJavadocConfigurationBlock.getJavadocLocation(); |
240 |
if (javadocLocation == null && fInitalLocation == null |
244 |
final boolean preferAttachedJavadoc= fJavadocConfigurationBlock.getPreferJavadocLocation(); |
241 |
|| javadocLocation != null && fInitalLocation != null && javadocLocation.toExternalForm().equals(fInitalLocation.toExternalForm())) { |
245 |
|
|
|
246 |
final boolean javadocLocationModified= !(javadocLocation == null && fInitalLocation == null |
247 |
|| javadocLocation != null && fInitalLocation != null && javadocLocation.toExternalForm().equals(fInitalLocation.toExternalForm())); |
248 |
final boolean preferAttachedJavadocModified= preferAttachedJavadoc != finitialPreferAttachedJavadoc; |
249 |
if (javadocLocationModified && preferAttachedJavadocModified) |
242 |
return true; // no change |
250 |
return true; // no change |
243 |
} |
|
|
244 |
|
245 |
|
251 |
|
246 |
IJavaElement elem= getJavaElement(); |
252 |
final Shell shell= getShell(); |
|
|
253 |
final IJavaElement elem= getJavaElement(); |
247 |
try { |
254 |
try { |
248 |
IRunnableWithProgress runnable= getRunnable(getShell(), elem, javadocLocation, fEntry, fContainerPath); |
255 |
IRunnableWithProgress runnable= new IRunnableWithProgress() { |
|
|
256 |
public void run(IProgressMonitor monitor) throws InvocationTargetException { |
257 |
try { |
258 |
IJavaProject project= elem.getJavaProject(); |
259 |
if (elem instanceof IPackageFragmentRoot) { |
260 |
ArrayList changedAttributes= new ArrayList(2); |
261 |
CPListElement cpElem= CPListElement.createFromExisting(fEntry, project); |
262 |
IClasspathEntry newEntry= cpElem.getClasspathEntry(); |
263 |
if (javadocLocationModified) { |
264 |
String loc= javadocLocation != null ? javadocLocation.toExternalForm() : null; |
265 |
cpElem.setAttribute(CPListElement.JAVADOC, loc); |
266 |
changedAttributes.add(CPListElement.JAVADOC); |
267 |
} |
268 |
if (preferAttachedJavadocModified) { |
269 |
cpElem.setAttribute(CPListElement.PREFER_JAVADOC, Boolean.valueOf(preferAttachedJavadoc)); |
270 |
changedAttributes.add(CPListElement.PREFER_JAVADOC); |
271 |
} |
272 |
String[] changedAttributes2= (String[]) changedAttributes.toArray(new String[changedAttributes.size()]); |
273 |
BuildPathSupport.modifyClasspathEntry(shell, newEntry, changedAttributes2, project, fContainerPath, fEntry.getReferencingEntry() != null, monitor); |
274 |
} else { |
275 |
JavaUI.setProjectJavadocLocation(project, javadocLocation); |
276 |
} |
277 |
} catch (CoreException e) { |
278 |
throw new InvocationTargetException(e); |
279 |
} |
280 |
} |
281 |
}; |
249 |
PlatformUI.getWorkbench().getProgressService().run(true, true, runnable); |
282 |
PlatformUI.getWorkbench().getProgressService().run(true, true, runnable); |
250 |
} catch (InvocationTargetException e) { |
283 |
} catch (InvocationTargetException e) { |
251 |
String title= PreferencesMessages.SourceAttachmentPropertyPage_error_title; |
284 |
String title= PreferencesMessages.SourceAttachmentPropertyPage_error_title; |
Lines 261-289
Link Here
|
261 |
} |
294 |
} |
262 |
|
295 |
|
263 |
|
296 |
|
264 |
private static IRunnableWithProgress getRunnable(final Shell shell, final IJavaElement elem, final URL javadocLocation, final IClasspathEntry entry, final IPath containerPath) { |
|
|
265 |
return new IRunnableWithProgress() { |
266 |
public void run(IProgressMonitor monitor) throws InvocationTargetException { |
267 |
try { |
268 |
IJavaProject project= elem.getJavaProject(); |
269 |
if (elem instanceof IPackageFragmentRoot) { |
270 |
CPListElement cpElem= CPListElement.createFromExisting(entry, project); |
271 |
String loc= javadocLocation != null ? javadocLocation.toExternalForm() : null; |
272 |
cpElem.setAttribute(CPListElement.JAVADOC, loc); |
273 |
IClasspathEntry newEntry= cpElem.getClasspathEntry(); |
274 |
String[] changedAttributes= { CPListElement.JAVADOC }; |
275 |
BuildPathSupport.modifyClasspathEntry(shell, newEntry, changedAttributes, project, containerPath, entry.getReferencingEntry() != null, monitor); |
276 |
} else { |
277 |
JavaUI.setProjectJavadocLocation(project, javadocLocation); |
278 |
} |
279 |
} catch (CoreException e) { |
280 |
throw new InvocationTargetException(e); |
281 |
} |
282 |
} |
283 |
}; |
284 |
} |
285 |
|
286 |
|
287 |
/** |
297 |
/** |
288 |
* @see IStatusChangeListener#statusChanged(IStatus) |
298 |
* @see IStatusChangeListener#statusChanged(IStatus) |
289 |
*/ |
299 |
*/ |