use of org.eclipse.ltk.core.refactoring.CompositeChange in project jbosstools-hibernate by jbosstools.
the class NewHibernateMappingPreviewPage method performCommit.
protected void performCommit() {
final CompositeChange cc = (CompositeChange) getChange();
if (cc == null) {
return;
}
final ITextFileBufferManager bufferManager = FileBuffers.getTextFileBufferManager();
Change[] changes = cc.getChildren();
for (int i = 0; i < changes.length; i++) {
Change change = changes[i];
if (!(change instanceof TextFileChange)) {
continue;
}
TextFileChange tfc = (TextFileChange) change;
if (tfc.isEnabled() && tfc.getEdit() != null) {
IPath path = new Path(tfc.getName());
ITextFileBuffer textFileBuffer = bufferManager.getTextFileBuffer(path, LocationKind.IFILE);
IDocument document = textFileBuffer.getDocument();
try {
tfc.getEdit().apply(document);
} catch (MalformedTreeException e) {
// $NON-NLS-1$
HibernateConsolePlugin.getDefault().logErrorMessage("MalformedTreeException: ", e);
} catch (BadLocationException e) {
// $NON-NLS-1$
HibernateConsolePlugin.getDefault().logErrorMessage("BadLocationException: ", e);
}
try {
// commit changes to underlying file
textFileBuffer.commit(null, true);
} catch (CoreException e) {
// $NON-NLS-1$
HibernateConsolePlugin.getDefault().logErrorMessage("CoreException: ", e);
}
}
}
}
use of org.eclipse.ltk.core.refactoring.CompositeChange in project titan.EclipsePlug-ins by eclipse.
the class InsertFieldRefactoring method createChange.
@Override
public Change createChange(final IProgressMonitor pm) throws CoreException, OperationCanceledException {
if (iselection == null) {
return null;
}
final CompositeChange cchange = new CompositeChange("InsertFieldRefactoring");
final Iterator<?> it = iselection.iterator();
while (it.hasNext()) {
final Object o = it.next();
if (!(o instanceof IResource)) {
continue;
}
final IResource res = (IResource) o;
final ResourceVisitor vis = new ResourceVisitor();
res.getProject().accept(vis);
cchange.add(vis.getChange());
}
affectedObjects = cchange.getAffectedObjects();
return cchange;
}
use of org.eclipse.ltk.core.refactoring.CompositeChange in project titan.EclipsePlug-ins by eclipse.
the class ContextLoggingRefactoring method createChange.
@Override
public Change createChange(final IProgressMonitor pm) throws CoreException, OperationCanceledException {
if (selection == null) {
ErrorReporter.logError("ContextLoggingRefactoring: Selection is null! ");
return null;
}
if (selection instanceof IStructuredSelection) {
final CompositeChange cchange = new CompositeChange("ContextLoggingRefactoring");
final IStructuredSelection ssel = (IStructuredSelection) selection;
final Iterator<?> it = ssel.iterator();
while (it.hasNext()) {
final Object o = it.next();
if (!(o instanceof IResource)) {
continue;
}
final IResource res = (IResource) o;
final ResourceVisitor vis = new ResourceVisitor();
res.accept(vis);
cchange.add(vis.getChange());
}
affectedObjects = cchange.getAffectedObjects();
return cchange;
} else if (selection instanceof TextSelection) {
final ChangeCreator chCreator = new ChangeCreator(selectedFile, (TextSelection) selection, settings);
chCreator.perform();
final Change ch = chCreator.getChange();
if (ch == null) {
affectedObjects = new Object[] {};
return new CompositeChange("EmptyLoggingRefactoring");
} else {
affectedObjects = ch.getAffectedObjects();
}
return ch;
}
return null;
}
use of org.eclipse.ltk.core.refactoring.CompositeChange in project titan.EclipsePlug-ins by eclipse.
the class LazyficationRefactoring method createChange.
@Override
public Change createChange(final IProgressMonitor pm) throws CoreException, OperationCanceledException {
if (selection == null) {
return null;
}
final CompositeChange cchange = new CompositeChange("LazyficationRefactoring");
final Iterator<?> it = selection.iterator();
while (it.hasNext()) {
final Object o = it.next();
if (!(o instanceof IResource)) {
continue;
}
final IResource res = (IResource) o;
final ResourceVisitor vis = new ResourceVisitor();
res.accept(vis);
cchange.add(vis.getChange());
}
affectedObjects = cchange.getAffectedObjects();
return cchange;
}
use of org.eclipse.ltk.core.refactoring.CompositeChange in project titan.EclipsePlug-ins by eclipse.
the class MinimizeVisibilityRefactoring method createChange.
@Override
public Change createChange(final IProgressMonitor pm) throws CoreException, OperationCanceledException {
if (selection == null) {
return null;
}
final CompositeChange cchange = new CompositeChange("MinimizeVisibilityRefactoring");
final Iterator<?> it = selection.iterator();
while (it.hasNext()) {
final Object o = it.next();
if (!(o instanceof IResource)) {
continue;
}
final IResource res = (IResource) o;
final ResourceVisitor vis = new ResourceVisitor();
res.accept(vis);
cchange.add(vis.getChange());
}
affectedObjects = cchange.getAffectedObjects();
return cchange;
}
Aggregations