Example usage for org.eclipse.jdt.core IBuffer append

List of usage examples for org.eclipse.jdt.core IBuffer append

Introduction

In this page you can find the example usage for org.eclipse.jdt.core IBuffer append.

Prototype

public void append(String text);

Source Link

Document

Appends the given string to the contents of the buffer.

Usage

From source file:org.seasar.doma.extension.domax.ResourceFileChangeListener.java

License:Apache License

private void submitJob(final IResource resource, DaoMethod daoMethod) {
    IJavaProject javaProject = daoMethod.getJavaProject();
    try {//www  .j a  v  a2  s  .c  o m
        IType type = javaProject.findType(daoMethod.getClassName());
        if (type == null) {
            return;
        }
        final ICompilationUnit compilationUnit = type.getCompilationUnit();
        if (compilationUnit == null) {
            return;
        }

        WorkspaceJob job = new WorkspaceJob("building " + daoMethod.getClassName()) {

            @Override
            public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
                compilationUnit.becomeWorkingCopy(monitor);
                IBuffer buffer = compilationUnit.getBuffer();
                buffer.append("");
                buffer.save(monitor, true);
                buffer.close();
                compilationUnit.commitWorkingCopy(true, monitor);
                resource.getProject().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
                return Status.OK_STATUS;
            }
        };
        job.setPriority(Job.BUILD);
        job.schedule();
    } catch (JavaModelException e) {
        Logger.error(e);
    }
}