use of org.eclipse.ltk.core.refactoring.TextEditBasedChangeGroup 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.ltk.core.refactoring.TextEditBasedChangeGroup in project che by eclipse.
the class TextEditGroupNode method feedInput.
public ChangePreview feedInput(IChangePreviewViewer viewer, List categories) throws CoreException {
InternalTextEditChangeNode element = getTextEditChangeNode();
if (element != null) {
Change change = element.getChange();
if (change instanceof TextEditBasedChange) {
IRegion range = getTextRange(this);
ChangePreviewViewerInput input = null;
if (range != null) {
input = TextEditChangePreviewViewer.createInput(change, new TextEditBasedChangeGroup[] { fChangeGroup }, range);
} else {
input = TextEditChangePreviewViewer.createInput(change, fChangeGroup, 2);
}
return viewer.setInput(input);
}
} else {
return viewer.setInput(null);
}
return null;
}
use of org.eclipse.ltk.core.refactoring.TextEditBasedChangeGroup in project che by eclipse.
the class CompilationUnitChangeNode method createChildNodes.
@Override
protected ChildNode[] createChildNodes() {
TextEditBasedChange change = getTextEditBasedChange();
if (change instanceof MultiStateTextFileChange) {
// no edit preview & edit disabling possible in the MultiStateTextFileChange (edits must be applied
return new ChildNode[0];
// in sequence)
}
ICompilationUnit cunit = (ICompilationUnit) change.getAdapter(ICompilationUnit.class);
if (cunit != null) {
List<ChildNode> children = new ArrayList<ChildNode>(5);
Map<IJavaElement, JavaLanguageNode> map = new HashMap<IJavaElement, JavaLanguageNode>(20);
TextEditBasedChangeGroup[] changes = getSortedChangeGroups(change);
for (int i = 0; i < changes.length; i++) {
TextEditBasedChangeGroup tec = changes[i];
try {
IJavaElement element = getModifiedJavaElement(tec, cunit);
if (element.equals(cunit)) {
children.add(createTextEditGroupNode(this, tec));
} else {
JavaLanguageNode pjce = getChangeElement(map, element, children, this);
pjce.addChild(createTextEditGroupNode(pjce, tec));
}
} catch (JavaModelException e) {
children.add(createTextEditGroupNode(this, tec));
}
}
return children.toArray(new ChildNode[children.size()]);
} else {
return EMPTY_CHILDREN;
}
}
use of org.eclipse.ltk.core.refactoring.TextEditBasedChangeGroup in project che by eclipse.
the class InternalLanguageElementNode method collectTextEditBasedChangeGroups.
private List collectTextEditBasedChangeGroups(List categories) {
List result = new ArrayList(10);
PreviewNode[] children = getChildren();
for (int i = 0; i < children.length; i++) {
PreviewNode child = children[i];
if (child instanceof TextEditGroupNode) {
TextEditBasedChangeGroup changeGroup = ((TextEditGroupNode) child).getChangeGroup();
if (categories == null || changeGroup.getGroupCategorySet().containsOneCategory(categories))
result.add(changeGroup);
} else if (child instanceof InternalLanguageElementNode) {
result.addAll(((InternalLanguageElementNode) child).collectTextEditBasedChangeGroups(categories));
}
}
return result;
}
use of org.eclipse.ltk.core.refactoring.TextEditBasedChangeGroup in project che by eclipse.
the class TextEditChangeNode method getSortedChangeGroups.
private TextEditBasedChangeGroup[] getSortedChangeGroups(TextEditBasedChange change) {
TextEditBasedChangeGroup[] groups = change.getChangeGroups();
List result = new ArrayList(groups.length);
for (int i = 0; i < groups.length; i++) {
if (!groups[i].getTextEditGroup().isEmpty())
result.add(groups[i]);
}
Comparator comparator = new OffsetComparator();
Collections.sort(result, comparator);
return (TextEditBasedChangeGroup[]) result.toArray(new TextEditBasedChangeGroup[result.size()]);
}
Aggregations