use of org.eclipse.ltk.core.refactoring.TextEditBasedChange in project che by eclipse.
the class JavaMoveProcessor method createChange.
@Override
public Change createChange(IProgressMonitor pm) throws CoreException {
Assert.isTrue(fMovePolicy.getJavaElementDestination() == null || fMovePolicy.getResourceDestination() == null);
Assert.isTrue(fMovePolicy.getJavaElementDestination() != null || fMovePolicy.getResourceDestination() != null);
try {
final DynamicValidationStateChange result = new DynamicValidationStateChange(RefactoringCoreMessages.JavaMoveProcessor_change_name) {
@Override
public ChangeDescriptor getDescriptor() {
return fMovePolicy.getDescriptor();
}
@Override
public Change perform(IProgressMonitor pm2) throws CoreException {
Change change = super.perform(pm2);
Change[] changes = getChildren();
for (int index = 0; index < changes.length; index++) {
if (!(changes[index] instanceof TextEditBasedChange))
return null;
}
return change;
}
};
CreateTargetExecutionLog log = null;
if (fCreateTargetQueries instanceof MonitoringCreateTargetQueries) {
final MonitoringCreateTargetQueries queries = (MonitoringCreateTargetQueries) fCreateTargetQueries;
final ICreateTargetQueries delegate = queries.getDelegate();
if (delegate instanceof LoggedCreateTargetQueries)
log = queries.getCreateTargetExecutionLog();
}
if (log != null) {
final Object[] selected = log.getSelectedElements();
for (int index = 0; index < selected.length; index++) {
result.add(new LoggedCreateTargetChange(selected[index], fCreateTargetQueries));
}
}
Change change = fMovePolicy.createChange(pm);
if (change instanceof CompositeChange) {
CompositeChange subComposite = (CompositeChange) change;
result.merge(subComposite);
} else {
result.add(change);
}
return result;
} finally {
pm.done();
}
}
use of org.eclipse.ltk.core.refactoring.TextEditBasedChange 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.TextEditBasedChange 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.TextEditBasedChange 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.TextEditBasedChange in project che by eclipse.
the class TextEditChangeNode method createChildNodes.
protected ChildNode[] createChildNodes() {
TextEditBasedChange change = getTextEditBasedChange();
if (change instanceof MultiStateTextFileChange) {
// no edit preview & edit disabling possible in the MultiStateTextFileChange (edits must be applied in sequence)
return new ChildNode[0];
}
TextEditBasedChangeGroup[] groups = getSortedChangeGroups(change);
ChildNode[] result = new ChildNode[groups.length];
for (int i = 0; i < groups.length; i++) {
result[i] = new TextEditGroupNode(this, groups[i]);
}
return result;
}
Aggregations