@Override public void run(IProgressMonitor monitor) throws CoreException { String[] changedAttributes= { CPListElement.IGNORE_OPTIONAL_PROBLEMS }; BuildPathSupport.modifyClasspathEntry(shell, entry, changedAttributes, project, null, entry.getReferencingEntry() != null, monitor); } };
@Override public void run(IProgressMonitor monitor) throws CoreException { String[] changedAttributes= { CPListElement.IGNORE_OPTIONAL_PROBLEMS }; BuildPathSupport.modifyClasspathEntry(shell, entry, changedAttributes, project, null, entry.getReferencingEntry() != null, monitor); } };
public String encodeClasspathEntry(IClasspathEntry classpathEntry) { try { ByteArrayOutputStream s = new ByteArrayOutputStream(); OutputStreamWriter writer = new OutputStreamWriter(s, "UTF8"); //$NON-NLS-1$ XMLWriter xmlWriter = new XMLWriter(writer, this, false/*don't print XML version*/); ((ClasspathEntry)classpathEntry).elementEncode(xmlWriter, this.project.getFullPath(), true/*indent*/, true/*insert new line*/, null/*not interested in unknown elements*/, (classpathEntry.getReferencingEntry() != null)); writer.flush(); writer.close(); return s.toString("UTF8");//$NON-NLS-1$ } catch (IOException e) { return null; // never happens since all is done in memory } }
public String encodeClasspathEntry(IClasspathEntry classpathEntry) { try { ByteArrayOutputStream s = new ByteArrayOutputStream(); OutputStreamWriter writer = new OutputStreamWriter(s, "UTF8"); //$NON-NLS-1$ XMLWriter xmlWriter = new XMLWriter(writer, this, false/*don't print XML version*/); ((ClasspathEntry)classpathEntry).elementEncode(xmlWriter, this.project.getFullPath(), true/*indent*/, true/*insert new line*/, null/*not interested in unknown elements*/, (classpathEntry.getReferencingEntry() != null)); writer.flush(); writer.close(); return s.toString("UTF8");//$NON-NLS-1$ } catch (IOException e) { return null; // never happens since all is done in memory } }
public String encodeClasspathEntry(IClasspathEntry classpathEntry) { try { ByteArrayOutputStream s = new ByteArrayOutputStream(); OutputStreamWriter writer = new OutputStreamWriter(s, "UTF8"); //$NON-NLS-1$ XMLWriter xmlWriter = new XMLWriter(writer, this, false/*don't print XML version*/); ((ClasspathEntry)classpathEntry).elementEncode(xmlWriter, this.project.getFullPath(), true/*indent*/, true/*insert new line*/, null/*not interested in unknown elements*/, (classpathEntry.getReferencingEntry() != null)); writer.flush(); writer.close(); return s.toString("UTF8");//$NON-NLS-1$ } catch (IOException e) { return null; // never happens since all is done in memory } }
public String encodeClasspathEntry(IClasspathEntry classpathEntry) { try { ByteArrayOutputStream s = new ByteArrayOutputStream(); OutputStreamWriter writer = new OutputStreamWriter(s, "UTF8"); //$NON-NLS-1$ XMLWriter xmlWriter = new XMLWriter(writer, this, false/*don't print XML version*/); ((ClasspathEntry)classpathEntry).elementEncode(xmlWriter, this.project.getFullPath(), true/*indent*/, true/*insert new line*/, null/*not interested in unknown elements*/, (classpathEntry.getReferencingEntry() != null)); writer.flush(); writer.close(); return s.toString("UTF8");//$NON-NLS-1$ } catch (IOException e) { return null; // never happens since all is done in memory } }
public String encodeClasspathEntry(IClasspathEntry classpathEntry) { try { ByteArrayOutputStream s = new ByteArrayOutputStream(); OutputStreamWriter writer = new OutputStreamWriter(s, "UTF8"); //$NON-NLS-1$ XMLWriter xmlWriter = new XMLWriter(writer, this, false/*don't print XML version*/); ((ClasspathEntry)classpathEntry).elementEncode(xmlWriter, this.project.getFullPath(), true/*indent*/, true/*insert new line*/, null/*not interested in unknown elements*/, (classpathEntry.getReferencingEntry() != null)); writer.flush(); writer.close(); return s.toString("UTF8");//$NON-NLS-1$ } catch (IOException e) { return null; // never happens since all is done in memory } }
@Override public String encodeClasspathEntry(IClasspathEntry classpathEntry) { try { ByteArrayOutputStream s = new ByteArrayOutputStream(); OutputStreamWriter writer = new OutputStreamWriter(s, "UTF8"); //$NON-NLS-1$ XMLWriter xmlWriter = new XMLWriter(writer, this, false/*don't print XML version*/); ((ClasspathEntry)classpathEntry).elementEncode(xmlWriter, this.project.getFullPath(), true/*indent*/, true/*insert new line*/, null/*not interested in unknown elements*/, (classpathEntry.getReferencingEntry() != null)); writer.flush(); writer.close(); return s.toString("UTF8");//$NON-NLS-1$ } catch (IOException e) { return null; // never happens since all is done in memory } }
@Override protected Object[] getPackageFragmentRoots(final IJavaProject project) throws JavaModelException { final Set<IPackageFragmentRoot> set= new HashSet<>(); final IPackageFragmentRoot[] roots= project.getPackageFragmentRoots(); for (int offset= 0; offset < roots.length; offset++) { IPackageFragmentRoot root= roots[offset]; IClasspathEntry entry= root.getRawClasspathEntry(); if (JarImportWizard.isValidClassPathEntry(entry) && root.getResolvedClasspathEntry().getReferencingEntry() == null) set.add(root); } return set.toArray(); }
@Override protected Object[] getPackageFragmentRoots(final IJavaProject project) throws JavaModelException { final Set<IPackageFragmentRoot> set= new HashSet<>(); final IPackageFragmentRoot[] roots= project.getPackageFragmentRoots(); for (int offset= 0; offset < roots.length; offset++) { IPackageFragmentRoot root= roots[offset]; IClasspathEntry entry= root.getRawClasspathEntry(); if (JarImportWizard.isValidClassPathEntry(entry) && root.getResolvedClasspathEntry().getReferencingEntry() == null) set.add(root); } return set.toArray(); }
@Override public void run(IProgressMonitor monitor) throws InvocationTargetException { try { IJavaProject project= elem.getJavaProject(); if (elem instanceof IPackageFragmentRoot) { CPListElement cpElem= CPListElement.createFromExisting(entry, project); String loc= javadocLocation != null ? javadocLocation.toExternalForm() : null; cpElem.setAttribute(CPListElement.JAVADOC, loc); IClasspathEntry newEntry= cpElem.getClasspathEntry(); String[] changedAttributes= { CPListElement.JAVADOC }; BuildPathSupport.modifyClasspathEntry(shell, newEntry, changedAttributes, project, containerPath, entry.getReferencingEntry() != null, monitor); } else { JavaUI.setProjectJavadocLocation(project, javadocLocation); } } catch (CoreException e) { throw new InvocationTargetException(e); } } };
@Override public void run(IProgressMonitor monitor) throws InvocationTargetException { try { IJavaProject project= elem.getJavaProject(); if (elem instanceof IPackageFragmentRoot) { CPListElement cpElem= CPListElement.createFromExisting(entry, project); String loc= javadocLocation != null ? javadocLocation.toExternalForm() : null; cpElem.setAttribute(CPListElement.JAVADOC, loc); IClasspathEntry newEntry= cpElem.getClasspathEntry(); String[] changedAttributes= { CPListElement.JAVADOC }; BuildPathSupport.modifyClasspathEntry(shell, newEntry, changedAttributes, project, containerPath, entry.getReferencingEntry() != null, monitor); } else { JavaUI.setProjectJavadocLocation(project, javadocLocation); } } catch (CoreException e) { throw new InvocationTargetException(e); } } };
public void setURL(URL url, IProgressMonitor monitor) throws CoreException { if (isProjectRef()) { JavaUI.setProjectJavadocLocation(fProject, url); } else { CPListElement element= CPListElement.createFromExisting(fClasspathEntry, fProject); String location= url != null ? url.toExternalForm() : null; element.setAttribute(CPListElement.JAVADOC, location); String[] changedAttributes= { CPListElement.JAVADOC }; BuildPathSupport.modifyClasspathEntry(null, element.getClasspathEntry(), changedAttributes, fProject, fContainerPath, fClasspathEntry.getReferencingEntry() != null, monitor); fClasspathEntry= element.getClasspathEntry(); } }
public void setURL(URL url, IProgressMonitor monitor) throws CoreException { if (isProjectRef()) { JavaUI.setProjectJavadocLocation(fProject, url); } else { CPListElement element= CPListElement.createFromExisting(fClasspathEntry, fProject); String location= url != null ? url.toExternalForm() : null; element.setAttribute(CPListElement.JAVADOC, location); String[] changedAttributes= { CPListElement.JAVADOC }; BuildPathSupport.modifyClasspathEntry(null, element.getClasspathEntry(), changedAttributes, fProject, fContainerPath, fClasspathEntry.getReferencingEntry() != null, monitor); fClasspathEntry= element.getClasspathEntry(); } }
@Override public void widgetSelected(SelectionEvent event) { Shell shell= getSite().getShell(); try { IClasspathEntry result= BuildPathDialogAccess.configureSourceAttachment(shell, entry, canEditEncoding); if (result != null) { applySourceAttachment(shell, result, jproject, containerPath, entry.getReferencingEntry() != null); verifyInput(getEditorInput()); } } catch (CoreException e) { String title= JavaEditorMessages.SourceAttachmentForm_error_title; String message= JavaEditorMessages.SourceAttachmentForm_error_message; ExceptionHandler.handle(e, shell, title, message); } }
@Override public void widgetSelected(SelectionEvent event) { Shell shell= getSite().getShell(); try { IClasspathEntry result= BuildPathDialogAccess.configureSourceAttachment(shell, entry, canEditEncoding); if (result != null) { applySourceAttachment(shell, result, jproject, containerPath, entry.getReferencingEntry() != null); verifyInput(getEditorInput()); } } catch (CoreException e) { String title= JavaEditorMessages.SourceAttachmentForm_error_title; String message= JavaEditorMessages.SourceAttachmentForm_error_message; ExceptionHandler.handle(e, shell, title, message); } }
@Override public void init(final IWorkbench workbench, final IStructuredSelection selection) { if (selection != null && selection.size() == 1) { final Object element= selection.getFirstElement(); if (element instanceof IPackageFragmentRoot) { final IPackageFragmentRoot root= (IPackageFragmentRoot) element; try { final IClasspathEntry entry= root.getRawClasspathEntry(); if (isValidClassPathEntry(entry) && root.getResolvedClasspathEntry().getReferencingEntry() == null) fImportData.setPackageFragmentRoot(root); } catch (JavaModelException exception) { JavaPlugin.log(exception); } } } }
@Override public void init(final IWorkbench workbench, final IStructuredSelection selection) { if (selection != null && selection.size() == 1) { final Object element= selection.getFirstElement(); if (element instanceof IPackageFragmentRoot) { final IPackageFragmentRoot root= (IPackageFragmentRoot) element; try { final IClasspathEntry entry= root.getRawClasspathEntry(); if (isValidClassPathEntry(entry) && root.getResolvedClasspathEntry().getReferencingEntry() == null) fImportData.setPackageFragmentRoot(root); } catch (JavaModelException exception) { JavaPlugin.log(exception); } } } }
@Override public boolean performOk() { if (fSourceAttachmentBlock != null) { try { IClasspathEntry entry= fSourceAttachmentBlock.getNewEntry(); if (entry.equals(fEntry)) { return true; // no change } IRunnableWithProgress runnable= SourceAttachmentBlock.getRunnable(getShell(), entry, fRoot.getJavaProject(), fContainerPath, fEntry.getReferencingEntry() != null); PlatformUI.getWorkbench().getProgressService().run(true, true, runnable); } catch (InvocationTargetException e) { String title= PreferencesMessages.SourceAttachmentPropertyPage_error_title; String message= PreferencesMessages.SourceAttachmentPropertyPage_error_message; ExceptionHandler.handle(e, getShell(), title, message); return false; } catch (InterruptedException e) { // cancelled return false; } } return true; }
@Override public void selectionChanged(final IAction action, final ISelection selection) { fSelection= null; if (selection instanceof IStructuredSelection) { final IStructuredSelection structured= (IStructuredSelection) selection; if (structured.size() == 1) { final Object element= structured.getFirstElement(); if (element instanceof IPackageFragmentRoot) { final IPackageFragmentRoot root= (IPackageFragmentRoot) element; try { final IClasspathEntry entry= root.getRawClasspathEntry(); if (JarImportWizard.isValidClassPathEntry(entry) && JarImportWizard.isValidJavaProject(root.getJavaProject()) && root.getResolvedClasspathEntry().getReferencingEntry() == null) { fSelection= structured; } } catch (JavaModelException exception) { JavaPlugin.log(exception); } } } } action.setEnabled(fSelection != null); }