use of org.eclipse.core.runtime.CoreException in project che by eclipse.
the class ProcessorBasedRefactoring method createChange.
/**
* {@inheritDoc}
*/
public Change createChange(IProgressMonitor pm) throws CoreException {
if (pm == null)
pm = new NullProgressMonitor();
//$NON-NLS-1$
pm.beginTask("", fParticipants.size() + 3);
pm.setTaskName(RefactoringCoreMessages.ProcessorBasedRefactoring_create_change);
Change processorChange = getProcessor().createChange(new SubProgressMonitor(pm, 1));
if (pm.isCanceled())
throw new OperationCanceledException();
fTextChangeMap = new HashMap();
addToTextChangeMap(processorChange);
List /*<Change>*/
changes = new ArrayList();
List /*<Change>*/
preChanges = new ArrayList();
Map /*<Change, RefactoringParticipant>*/
participantMap = new HashMap();
for (Iterator iter = fParticipants.iterator(); iter.hasNext(); ) {
final RefactoringParticipant participant = (RefactoringParticipant) iter.next();
try {
//$NON-NLS-1$
final PerformanceStats stats = PerformanceStats.getStats(PERF_CREATE_CHANGES, getName() + ", " + participant.getName());
stats.startRun();
Change preChange = participant.createPreChange(new SubProgressMonitor(pm, 1));
Change change = participant.createChange(new SubProgressMonitor(pm, 1));
stats.endRun();
if (preChange != null) {
if (fPreChangeParticipants == null)
fPreChangeParticipants = new ArrayList();
fPreChangeParticipants.add(participant);
preChanges.add(preChange);
participantMap.put(preChange, participant);
addToTextChangeMap(preChange);
}
if (change != null) {
changes.add(change);
participantMap.put(change, participant);
addToTextChangeMap(change);
}
} catch (CoreException e) {
disableParticipant(participant, e);
throw e;
} catch (OperationCanceledException e) {
throw e;
} catch (RuntimeException e) {
disableParticipant(participant, e);
throw e;
}
if (pm.isCanceled())
throw new OperationCanceledException();
}
fTextChangeMap = null;
Change postChange = getProcessor().postCreateChange((Change[]) changes.toArray(new Change[changes.size()]), new SubProgressMonitor(pm, 1));
ProcessorChange result = new ProcessorChange(getName());
result.addAll((Change[]) preChanges.toArray(new Change[preChanges.size()]));
result.add(processorChange);
result.addAll((Change[]) changes.toArray(new Change[changes.size()]));
result.setParticipantMap(participantMap);
result.setPreChangeParticipants(fPreChangeParticipants);
if (postChange != null)
result.add(postChange);
return result;
}
use of org.eclipse.core.runtime.CoreException in project che by eclipse.
the class RefactoringHistoryService method moveHistory.
/**
* Moves the project history from the old project to the new one.
*
* @param oldProject
* the old project, which does not exist anymore
* @param newProject
* the new project, which already exists
* @param monitor
* the progress monitor to use
*/
private void moveHistory(final IProject oldProject, final IProject newProject, final IProgressMonitor monitor) {
try {
monitor.beginTask(RefactoringCoreMessages.RefactoringHistoryService_updating_history, 60);
final IFileStore historyStore = EFS.getLocalFileSystem().getStore(RefactoringCorePlugin.getDefault().getStateLocation()).getChild(NAME_HISTORY_FOLDER);
final String oldName = oldProject.getName();
final String newName = newProject.getName();
final IFileStore oldStore = historyStore.getChild(oldName);
if (oldStore.fetchInfo(EFS.NONE, new SubProgressMonitor(monitor, 10, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)).exists()) {
final IFileStore newStore = historyStore.getChild(newName);
if (newStore.fetchInfo(EFS.NONE, new SubProgressMonitor(monitor, 10, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)).exists())
newStore.delete(EFS.NONE, new SubProgressMonitor(monitor, 20, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
oldStore.move(newStore, EFS.OVERWRITE, new SubProgressMonitor(monitor, 20, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
}
} catch (CoreException exception) {
RefactoringCorePlugin.log(exception);
} finally {
monitor.done();
}
}
use of org.eclipse.core.runtime.CoreException in project che by eclipse.
the class UndoManager2 method performRedo.
public void performRedo(IValidationCheckResultQuery query, IProgressMonitor pm) throws CoreException {
IUndoableOperation redo = fOperationHistory.getRedoOperation(RefactoringCorePlugin.getUndoContext());
UndoableOperation2ChangeAdapter changeOperation = getUnwrappedOperation(redo);
if (changeOperation == null)
throw new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), IStatus.ERROR, RefactoringCoreMessages.UndoManager2_no_change, null));
if (query == null)
query = new NullQuery();
try {
fOperationHistory.redoOperation(redo, pm, new QueryAdapter(query));
} catch (ExecutionException e) {
handleException(e);
}
}
use of org.eclipse.core.runtime.CoreException in project che by eclipse.
the class UndoManager2 method performUndo.
public void performUndo(IValidationCheckResultQuery query, IProgressMonitor pm) throws CoreException {
IUndoableOperation undo = fOperationHistory.getUndoOperation(RefactoringCorePlugin.getUndoContext());
UndoableOperation2ChangeAdapter changeOperation = getUnwrappedOperation(undo);
if (changeOperation == null)
throw new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), IStatus.ERROR, RefactoringCoreMessages.UndoManager2_no_change, null));
if (query == null)
query = new NullQuery();
try {
fOperationHistory.undoOperation(undo, pm, new QueryAdapter(query));
} catch (ExecutionException e) {
handleException(e);
}
}
use of org.eclipse.core.runtime.CoreException in project che by eclipse.
the class UndoableOperation2ChangeAdapter method execute.
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
if (monitor == null)
monitor = new NullProgressMonitor();
try {
ExecuteResult result = executeChange(getQuery(info, RefactoringCoreMessages.Refactoring_execute_label), monitor);
if (!result.changeExecuted) {
return createStatus(result);
}
fUndoChange = result.reverseChange;
fActiveChange = fUndoChange;
fExecuteChange = null;
return Status.OK_STATUS;
} catch (CoreException e) {
throw new ExecutionException(e.getStatus().getMessage(), e);
}
}
Aggregations