mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 06:02:11 +02:00
Bug 558474 - CleanUp deprecated methods in org.eclipse.cdt.ui
Reworked deprecated usages of SubProgressMonitor by SubMonitor Change-Id: Ia67926e1273785d9688ca22c993f79ac3b3822f9 Signed-off-by: Sergey Kovalchuk <sergei.kovalchuk@arsysop.ru>
This commit is contained in:
parent
bacb42110e
commit
a7c5168c7a
5 changed files with 40 additions and 61 deletions
|
@ -36,9 +36,8 @@ import org.eclipse.core.resources.IResource;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Preferences;
|
||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||
import org.eclipse.core.runtime.SubMonitor;
|
||||
|
||||
/**
|
||||
* Abstract block for C/C++ Project Paths page for 3.X projects.
|
||||
|
@ -295,8 +294,8 @@ abstract public class AbstractPathOptionBlock extends TabFolderOptionBlock imple
|
|||
protected void internalConfigureCProject(List<CPElement> cPathEntries, IProgressMonitor monitor)
|
||||
throws CoreException, InterruptedException {
|
||||
// 10 monitor steps to go
|
||||
|
||||
monitor.worked(2);
|
||||
SubMonitor subMonitor = SubMonitor.convert(monitor, 10);
|
||||
subMonitor.worked(2);
|
||||
|
||||
IPathEntry[] entries = getCProject().getRawPathEntries();
|
||||
|
||||
|
@ -332,26 +331,15 @@ abstract public class AbstractPathOptionBlock extends TabFolderOptionBlock imple
|
|||
cpath.add(entrie);
|
||||
}
|
||||
}
|
||||
monitor.worked(1);
|
||||
|
||||
getCProject().setRawPathEntries(cpath.toArray(new IPathEntry[cpath.size()]),
|
||||
new SubProgressMonitor(monitor, 7));
|
||||
subMonitor.worked(1);
|
||||
getCProject().setRawPathEntries(cpath.toArray(new IPathEntry[cpath.size()]), subMonitor.split(7));
|
||||
}
|
||||
|
||||
// -------- creation -------------------------------
|
||||
|
||||
public void configureCProject(IProgressMonitor monitor) throws CoreException, InterruptedException {
|
||||
if (monitor == null) {
|
||||
monitor = new NullProgressMonitor();
|
||||
}
|
||||
monitor.setTaskName(CPathEntryMessages.CPathsBlock_operationdesc_c);
|
||||
monitor.beginTask("", 10); //$NON-NLS-1$
|
||||
|
||||
try {
|
||||
internalConfigureCProject(getCPaths(), monitor);
|
||||
initializeTimeStamps();
|
||||
} finally {
|
||||
monitor.done();
|
||||
}
|
||||
SubMonitor subMonitor = SubMonitor.convert(monitor, CPathEntryMessages.CPathsBlock_operationdesc_c, 10);
|
||||
internalConfigureCProject(getCPaths(), subMonitor.split(10));
|
||||
initializeTimeStamps();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.eclipse.core.runtime.IPath;
|
|||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.MultiStatus;
|
||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||
import org.eclipse.core.runtime.SubMonitor;
|
||||
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
|
@ -99,24 +99,21 @@ public class FileTransferDragAdapter implements TransferDragSourceListener {
|
|||
|
||||
@Override
|
||||
public void execute(IProgressMonitor monitor) throws CoreException {
|
||||
try {
|
||||
monitor.beginTask(CUIMessages.FileTransferDragAdapter_refreshing, roots.size());
|
||||
MultiStatus status = new MultiStatus(CUIPlugin.getPluginId(), IStatus.OK,
|
||||
CUIMessages.FileTransferDragAdapter_problem, null);
|
||||
SubMonitor subMonitor = SubMonitor.convert(monitor, CUIMessages.FileTransferDragAdapter_refreshing,
|
||||
roots.size());
|
||||
MultiStatus status = new MultiStatus(CUIPlugin.getPluginId(), IStatus.OK,
|
||||
CUIMessages.FileTransferDragAdapter_problem, null);
|
||||
|
||||
for (IResource resource : roots) {
|
||||
try {
|
||||
resource.refreshLocal(IResource.DEPTH_ONE, new SubProgressMonitor(monitor, 1));
|
||||
} catch (CoreException e) {
|
||||
status.add(e.getStatus());
|
||||
}
|
||||
for (IResource resource : roots) {
|
||||
try {
|
||||
resource.refreshLocal(IResource.DEPTH_ONE, subMonitor.split(1));
|
||||
} catch (CoreException e) {
|
||||
status.add(e.getStatus());
|
||||
}
|
||||
|
||||
if (!status.isOK())
|
||||
throw new CoreException(status);
|
||||
} finally {
|
||||
monitor.done();
|
||||
}
|
||||
|
||||
if (!status.isOK())
|
||||
throw new CoreException(status);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.eclipse.core.runtime.Assert;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||
import org.eclipse.core.runtime.SubMonitor;
|
||||
import org.eclipse.ltk.core.refactoring.Change;
|
||||
import org.eclipse.ltk.core.refactoring.resource.ResourceChange;
|
||||
|
||||
|
@ -78,19 +78,15 @@ public abstract class AbstractCElementRenameChange extends ResourceChange {
|
|||
|
||||
@Override
|
||||
public final Change perform(IProgressMonitor pm) throws CoreException {
|
||||
try {
|
||||
pm.beginTask(Messages.AbstractCElementRenameChange_renaming, 1);
|
||||
IResource resource = getResource();
|
||||
IPath newPath = createNewPath();
|
||||
Change result = createUndoChange(resource.getModificationStamp());
|
||||
doRename(new SubProgressMonitor(pm, 1));
|
||||
if (fStampToRestore != IResource.NULL_STAMP) {
|
||||
IResource newResource = ResourcesPlugin.getWorkspace().getRoot().findMember(newPath);
|
||||
newResource.revertModificationStamp(fStampToRestore);
|
||||
}
|
||||
return result;
|
||||
} finally {
|
||||
pm.done();
|
||||
SubMonitor subMonitor = SubMonitor.convert(pm, Messages.AbstractCElementRenameChange_renaming, 1);
|
||||
IResource resource = getResource();
|
||||
IPath newPath = createNewPath();
|
||||
Change result = createUndoChange(resource.getModificationStamp());
|
||||
doRename(subMonitor.split(1));
|
||||
if (fStampToRestore != IResource.NULL_STAMP) {
|
||||
IResource newResource = ResourcesPlugin.getWorkspace().getRoot().findMember(newPath);
|
||||
newResource.revertModificationStamp(fStampToRestore);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -26,7 +26,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||
import org.eclipse.core.runtime.SubMonitor;
|
||||
import org.eclipse.ltk.core.refactoring.Change;
|
||||
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
|
||||
import org.eclipse.ltk.core.refactoring.resource.ResourceChange;
|
||||
|
@ -93,11 +93,12 @@ public class CreateFileChange extends ResourceChange {
|
|||
|
||||
@Override
|
||||
public Change perform(IProgressMonitor pm) throws CoreException {
|
||||
SubMonitor subMonitor = SubMonitor.convert(pm, 2);
|
||||
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
|
||||
InputStream is = new ByteArrayInputStream(source.getBytes());
|
||||
file.create(is, false, new SubProgressMonitor(pm, 1));
|
||||
file.create(is, false, subMonitor.split(1));
|
||||
if (encoding != null) {
|
||||
file.setCharset(encoding, new SubProgressMonitor(pm, 1));
|
||||
file.setCharset(encoding, subMonitor.split(1));
|
||||
}
|
||||
return new DeleteFileChange(file.getFullPath());
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||
import org.eclipse.core.runtime.SubMonitor;
|
||||
import org.eclipse.ltk.core.refactoring.Change;
|
||||
import org.eclipse.ltk.core.refactoring.CompositeChange;
|
||||
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
|
||||
|
@ -209,7 +209,8 @@ public abstract class CRenameProcessorDelegate {
|
|||
public RefactoringStatus checkFinalConditions(IProgressMonitor monitor, CheckConditionsContext context)
|
||||
throws CoreException, OperationCanceledException {
|
||||
RefactoringStatus result = new RefactoringStatus();
|
||||
monitor.beginTask(RenameMessages.CRenameProcessorDelegate_task_checkFinalCondition, 2);
|
||||
SubMonitor subMonitor = SubMonitor.convert(monitor,
|
||||
RenameMessages.CRenameProcessorDelegate_task_checkFinalCondition, 2);
|
||||
IFile file = getArgument().getSourceFile();
|
||||
//assert file != null;
|
||||
|
||||
|
@ -224,16 +225,13 @@ public abstract class CRenameProcessorDelegate {
|
|||
}
|
||||
IStatus stat = txtSearch.searchWord(filesToSearch.toArray(new IFile[filesToSearch.size()]), getSearchScope(),
|
||||
file, getSelectedWorkingSet(), getManager().getCCppPatterns(), getArgument().getName(),
|
||||
new SubProgressMonitor(monitor, 1), fMatches);
|
||||
if (monitor.isCanceled()) {
|
||||
throw new OperationCanceledException();
|
||||
}
|
||||
subMonitor.split(1), fMatches);
|
||||
result.merge(RefactoringStatus.create(stat));
|
||||
if (result.hasFatalError()) {
|
||||
return result;
|
||||
}
|
||||
selectMatchesByLocation(fMatches);
|
||||
analyzeTextMatches(renameBindings, fMatches, new SubProgressMonitor(monitor, 1), result);
|
||||
analyzeTextMatches(renameBindings, fMatches, subMonitor.split(1), result);
|
||||
if (result.hasFatalError()) {
|
||||
return result;
|
||||
}
|
||||
|
@ -291,7 +289,6 @@ public abstract class CRenameProcessorDelegate {
|
|||
fRenameModifications.buildDelta(deltaFactory);
|
||||
fRenameModifications.buildValidateEdits(editChecker);
|
||||
}
|
||||
monitor.done();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue