@Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { if (monitor == null) { monitor= new NullProgressMonitor(); } monitor.beginTask(NewWizardMessages.ClasspathFixSelectionDialog_process_fix_description, 4); try { ClasspathFixProposal fix= dialog.getSelectedClasspathFix(); Change change= fix.createChange(new SubProgressMonitor(monitor, 1)); PerformChangeOperation op= new PerformChangeOperation(change); op.setUndoManager(RefactoringCore.getUndoManager(), change.getName()); op.run(new SubProgressMonitor(monitor, 1)); } catch (OperationCanceledException e) { throw new InterruptedException(); } catch (CoreException e) { throw new InvocationTargetException(e); } finally { monitor.done(); } } });
newEntry= JavaCore.newProjectEntry(other.getPath()); Change change= ClasspathFixProposal.newAddClasspathChange(project, newEntry); if (change != null) { String[] args= { BasicElementLabels.getResourceName(other.getElementName()), BasicElementLabels.getResourceName(project.getElementName()) };
private static void modifyClasspathProposal(IJavaProject project, IPackageFragmentRoot root, IClasspathEntry[] entries, int position, Collection<ICommandAccess> proposals) throws JavaModelException { IClasspathEntry[] existingEntries= Arrays.copyOf(entries, entries.length); IClasspathEntry entry= existingEntries[position]; String label= getModifyClasspathLabel(entry, root); if (label != null && position != -1) { IClasspathAttribute[] attributes= entry.getExtraAttributes(); IClasspathAttribute[] newAttributes= addModuleAttributeIfNeeded(attributes); if (newAttributes != null) { IClasspathEntry entryModular= addAttributes(entry, newAttributes); if (entryModular != null) { existingEntries[position]= entryModular; } Change change= ClasspathFixProposal.newClasspathChange(project, existingEntries, project.getOutputLocation()); if (change != null) { ModulepathFixProposal proposal= new ModulepathFixProposal(label, change, label, IProposalRelevance.ADD_TO_BUILDPATH); proposals.add(proposal); } } } }
newEntry= JavaCore.newProjectEntry(other.getPath()); Change change= ClasspathFixProposal.newAddClasspathChange(project, newEntry); if (change != null) { String[] args= { BasicElementLabels.getResourceName(other.getElementName()), BasicElementLabels.getResourceName(project.getElementName()) };
if ((entry.isExported() || entryKind == IClasspathEntry.CPE_SOURCE) && addedClaspaths.add(other)) { IClasspathEntry newEntry= JavaCore.newProjectEntry(other.getPath()); Change change= ClasspathFixProposal.newAddClasspathChange(project, newEntry); if (change != null) { String[] args= { BasicElementLabels.getResourceName(other.getElementName()), BasicElementLabels.getResourceName(project.getElementName()) };
@Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { if (monitor == null) { monitor= new NullProgressMonitor(); } monitor.beginTask(NewWizardMessages.ClasspathFixSelectionDialog_process_fix_description, 4); try { ClasspathFixProposal fix= dialog.getSelectedClasspathFix(); Change change= fix.createChange(new SubProgressMonitor(monitor, 1)); PerformChangeOperation op= new PerformChangeOperation(change); op.setUndoManager(RefactoringCore.getUndoManager(), change.getName()); op.run(new SubProgressMonitor(monitor, 1)); } catch (OperationCanceledException e) { throw new InterruptedException(); } catch (CoreException e) { throw new InvocationTargetException(e); } finally { monitor.done(); } } });
protected void addLibraryProposal(IJavaProject project, IPackageFragmentRoot root, IClasspathEntry entry, Collection<Object> addedClaspaths, Collection<DefaultClasspathFixProposal> proposals, Change additionalChange) throws JavaModelException { if (addedClaspaths.add(entry)) { String label= getAddClasspathLabel(entry, root, project); if (label != null) { Change change= ClasspathFixProposal.newAddClasspathChange(project, entry); if (change != null) { if (additionalChange != null) { String additionalLabel= additionalChange.getName(); additionalLabel= additionalLabel.substring(0, 1).toLowerCase() + additionalLabel.substring(1); String[] arguments= { label, additionalLabel }; label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_combine_two_proposals_info, arguments); change= new CompositeChange(change.getName(), new Change[] { change, additionalChange }); } DefaultClasspathFixProposal proposal= new DefaultClasspathFixProposal(label, change, label, IProposalRelevance.ADD_TO_BUILDPATH); proposals.add(proposal); } } } }
private void addLibraryProposal(IJavaProject project, IPackageFragmentRoot root, IClasspathEntry entry, Collection<Object> addedClaspaths, Collection<DefaultClasspathFixProposal> proposals) throws JavaModelException { if (addedClaspaths.add(entry)) { String label= getAddClasspathLabel(entry, root, project); if (label != null) { Change change= ClasspathFixProposal.newAddClasspathChange(project, entry); if (change != null) { DefaultClasspathFixProposal proposal= new DefaultClasspathFixProposal(label, change, label, IProposalRelevance.ADD_TO_BUILDPATH); proposals.add(proposal); } } } }
@Override public int category(Object element) { return - ((ClasspathFixProposal) element).getRelevance(); } });
@Override public int category(Object element) { return - ((ClasspathFixProposal) element).getRelevance(); } });
@Override public String getText(Object element) { if (element instanceof ClasspathFixProposal) { ClasspathFixProposal classpathFixProposal= (ClasspathFixProposal) element; return classpathFixProposal.getDisplayString(); } return null; } }
@Override public Image getImage(Object element) { if (element instanceof ClasspathFixProposal) { ClasspathFixProposal classpathFixProposal= (ClasspathFixProposal) element; return classpathFixProposal.getImage(); } return null; }
@Override public String getText(Object element) { if (element instanceof ClasspathFixProposal) { ClasspathFixProposal classpathFixProposal= (ClasspathFixProposal) element; return classpathFixProposal.getDisplayString(); } return null; } }
@Override public Image getImage(Object element) { if (element instanceof ClasspathFixProposal) { ClasspathFixProposal classpathFixProposal= (ClasspathFixProposal) element; return classpathFixProposal.getImage(); } return null; }