use of org.eclipse.core.runtime.AssertionFailedException in project che by eclipse.
the class RefactoringManager method applyLinkedRename.
/**
* Apply linked mode rename refactoring.
*
* @param apply
* contains new element name
* @return refactoring result
* @throws RefactoringException
* when refactoring session not found.
* @throws CoreException
* when impossible to apply rename refactoring
*/
public RefactoringResult applyLinkedRename(LinkedRenameRefactoringApply apply) throws RefactoringException, CoreException {
RefactoringSession session = getRefactoringSession(apply.getSessionId());
if (session instanceof RenameLinkedModeRefactoringSession) {
RenameLinkedModeRefactoringSession renameSession = (RenameLinkedModeRefactoringSession) session;
try {
RefactoringResult refactoringResult = renameSession.doRename(apply.getNewName());
deleteRefactoringSession(apply.getSessionId());
return refactoringResult;
} catch (InvocationTargetException | InterruptedException | AssertionFailedException e) {
LOG.error(e.getMessage(), e);
return DtoConverter.toRefactoringResultDto(org.eclipse.ltk.core.refactoring.RefactoringStatus.createFatalErrorStatus(e.getMessage()));
}
}
throw new RefactoringException("There is no RenameLinkedModeRefactoringSession.");
}
use of org.eclipse.core.runtime.AssertionFailedException in project che by eclipse.
the class TextEditChangePreviewViewer method setInput.
// public void createControl(Composite parent) {
// fViewer = new ComparePreviewer(parent);
// }
//
// public Control getControl() {
// return fViewer;
// }
public ChangePreview setInput(ChangePreviewViewerInput input) {
try {
Change change = input.getChange();
if (input instanceof TextEditBasedChangeInput) {
TextEditBasedChangeInput extended = (TextEditBasedChangeInput) input;
if (extended.group != null && extended.surroundingLines >= 0) {
TextEditBasedChangeGroup group = extended.group;
TextEditBasedChange editChange = group.getTextEditChange();
// setInput(editChange, editChange.getCurrentContent(group.getRegion(), true, 2, new NullProgressMonitor()),
// editChange.getPreviewContent(new TextEditBasedChangeGroup[]{group}, group.getRegion(), true, 2,
// new NullProgressMonitor()),
// editChange.getTextType());
ChangePreview preview = DtoFactory.newDto(ChangePreview.class);
preview.setFileName(getFileName(editChange));
preview.setOldContent(editChange.getCurrentContent(group.getRegion(), true, 2, new NullProgressMonitor()));
preview.setNewContent(editChange.getPreviewContent(new TextEditBasedChangeGroup[] { group }, group.getRegion(), true, 2, new NullProgressMonitor()));
return preview;
} else if (extended.groups != null && extended.groups.length > 0 && extended.range != null) {
TextEditBasedChange editChange = extended.groups[0].getTextEditChange();
TextEditBasedChangeGroup[] groups = extended.groups;
// if (extended.groupCategory != null) {
//
// }
// setInput(editChange, editChange.getCurrentContent(extended.range, true, 0, new NullProgressMonitor()),
// editChange.getPreviewContent(groups, extended.range, true, 0, new NullProgressMonitor()),
// editChange.getTextType());
ChangePreview preview = DtoFactory.newDto(ChangePreview.class);
preview.setFileName(getFileName(editChange));
preview.setOldContent(editChange.getCurrentContent(extended.range, true, 0, new NullProgressMonitor()));
preview.setNewContent(editChange.getPreviewContent(groups, extended.range, true, 0, new NullProgressMonitor()));
return preview;
}
} else if (change instanceof TextEditBasedChange) {
TextEditBasedChange editChange = (TextEditBasedChange) change;
// setInput(editChange, editChange.getCurrentContent(new NullProgressMonitor()),
// editChange.getPreviewContent(new NullProgressMonitor()), editChange.getTextType());
ChangePreview preview = DtoFactory.newDto(ChangePreview.class);
preview.setFileName(getFileName(editChange));
preview.setOldContent(editChange.getCurrentContent(new NullProgressMonitor()));
preview.setNewContent(editChange.getPreviewContent(new NullProgressMonitor()));
return preview;
} else {
// fViewer.setInput(null);
return null;
}
} catch (CoreException | AssertionFailedException e) {
JavaPlugin.log(e);
// fViewer.setInput(null);
return null;
}
// }
return null;
}
use of org.eclipse.core.runtime.AssertionFailedException in project tdi-studio-se by Talend.
the class PaletteItemHelper method getRootPaletteItem.
/**
* DOC nrousseau Comment method "getRootPaletteItem".
*
* @param valueOf
* @param paletteItems
* @return
*/
private static IPaletteItem getRootPaletteItem(ComponentCategory category, List<IPaletteItem> paletteItems) {
for (IPaletteItem paletteItem : paletteItems) {
if (paletteItem.getPaletteType() == category) {
return paletteItem;
}
}
try {
IPaletteItem rootPaletteItem = new RootPaletteItem(category);
paletteItems.add(rootPaletteItem);
return rootPaletteItem;
} catch (AssertionFailedException e) {
// if go here,means can not get the paletteItem for the componentCatgory,just return null
return null;
}
}
Aggregations