use of org.eclipse.core.runtime.OperationCanceledException 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.OperationCanceledException in project tdi-studio-se by Talend.
the class ComponentChooseDialog method chooseOneComponent.
/**
* Let the user choose which component he would like to create.
*
* @param neededComponents
* @param name
* @param quickCreateInput
* @param quickCreateOutput
*/
private IComponent chooseOneComponent(List<IComponent> neededComponents, IComponentName name, boolean quickCreateInput, boolean quickCreateOutput) {
if (neededComponents.isEmpty()) {
return null;
}
if (neededComponents.size() == 1) {
return neededComponents.get(0);
}
IComponent inputComponent = getComponentByName(name.getInputComponentName(), quickCreateInput, neededComponents);
if (inputComponent != null) {
return inputComponent;
}
IComponent outputComponent = getComponentByName(name.getOutPutComponentName(), quickCreateOutput, neededComponents);
if (outputComponent != null) {
return outputComponent;
}
ComponentChooseDialog dialog = new ComponentChooseDialog(editor.getSite().getShell(), neededComponents);
IComponent defaultComponent = getComponentByName(name.getDefaultComponentName(), true, neededComponents);
if (defaultComponent != null) {
dialog.setInitialSelections(new Object[] { defaultComponent });
} else {
dialog.setInitialSelections(new Object[] { neededComponents.get(0) });
}
if (dialog.open() == IDialogConstants.OK_ID) {
return dialog.getResultComponent();
}
//$NON-NLS-1$
throw new OperationCanceledException(Messages.getString("TalendEditorDropTargetListener.cancelOperation"));
}
use of org.eclipse.core.runtime.OperationCanceledException in project tesb-studio-se by Talend.
the class CamelEditorDropTargetListener method handleDrop.
@Override
protected void handleDrop() {
if (!checkSelectionSource()) {
return;
}
updateTargetRequest();
updateTargetEditPart();
if (selectSourceList.get(0) instanceof PaletteEditPart && getTargetRequest() instanceof CreateRequest) {
if (getTargetEditPart() instanceof ProcessPart) {
Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
if (newObject != null) {
Command command = getCommand();
if (command != null) {
execCommandStack(command);
}
}
}
return;
}
if (isContextSource) {
createContext();
} else {
if (!(getTargetEditPart() instanceof NodeContainerPart)) {
try {
createNewComponent(getCurrentEvent());
} catch (OperationCanceledException e) {
return;
}
}
}
// in case after drag/drop the editor is dirty but can not get focus
if (editor.isDirty()) {
editor.setFocus();
}
this.eraseTargetFeedback();
}
use of org.eclipse.core.runtime.OperationCanceledException in project tdi-studio-se by Talend.
the class JobHierarchyLifeCycle method ensureRefreshedTypeHierarchy.
public void ensureRefreshedTypeHierarchy(final IProcess2 element, IRunnableContext context) throws InvocationTargetException, InterruptedException {
if (element == null) {
freeHierarchy();
return;
}
// boolean hierachyCreationNeeded = (fHierarchy == null || !element.equals(inputProcess));
boolean hierachyCreationNeeded = true;
if (hierachyCreationNeeded || fHierarchyRefreshNeeded) {
IRunnableWithProgress op = new IRunnableWithProgress() {
public void run(IProgressMonitor pm) throws InvocationTargetException, InterruptedException {
try {
doHierarchyRefresh(element, pm);
} catch (JavaModelException e) {
throw new InvocationTargetException(e);
} catch (OperationCanceledException e) {
throw new InterruptedException();
}
}
};
fHierarchyRefreshNeeded = true;
context.run(true, true, op);
fHierarchyRefreshNeeded = false;
}
}
use of org.eclipse.core.runtime.OperationCanceledException in project tdi-studio-se by Talend.
the class HeapDumpSaxEventHandler method startElement.
/*
* @see DefaultHandler#startElement(String, String, String, Attributes)
*/
@Override
public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException {
if (monitor.isCanceled()) {
throw new OperationCanceledException();
}
// memory-profile
if ("heap-profile".equals(name)) {
//$NON-NLS-1$
//$NON-NLS-1$
String date = attributes.getValue("date");
//$NON-NLS-1$
String runtime = attributes.getValue("runtime");
//$NON-NLS-1$
String mainClass = attributes.getValue("mainClass");
//$NON-NLS-1$
String arguments = attributes.getValue("arguments");
//$NON-NLS-1$
String comments = attributes.getValue("comments");
info = new ProfileInfo(date, runtime, mainClass, arguments, comments);
}
// class
if ("class".equals(name)) {
//$NON-NLS-1$
//$NON-NLS-1$
String className = attributes.getValue("name");
//$NON-NLS-1$
String size = attributes.getValue("size");
//$NON-NLS-1$
String count = attributes.getValue("count");
//$NON-NLS-1$
String baseSize = attributes.getValue("baseSize");
HeapElement element = new HeapElement(className, Long.parseLong(size), Long.parseLong(count), Long.parseLong(baseSize));
heapListElements.add((IHeapElement) element);
}
}
Aggregations