Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jdt-core-dev] Batching java model operations

In the same spirit of IWorkspace.run(IWorkspaceRunnable, IProgressMonitor),
last integration build contains the following new API:

      JavaCore.run(IWorkspaceRunnable, IProgressMonitor)

This API allows batching  of java model operations. Only one Java element
changed event is reported at the end of the batch. This can greatly improve
performance as listeners to Java element changed events are notified only
once and thus they need to take action (like a UI refresh) only once.

For example the following code snippet notifies listeners twice:
      ICompilationUnit unit = ...;
      unit.createType("class B {}", null, false, monitor);
      unit.getType("A").createField("int i;", null, false, monitor);

To notify listeners only once, use the following:
      JavaCore.run(
            new IWorkspaceRunnable() {
                  public void run(IProgressMonitor monitor) throws
CoreException {
                        ICompilationUnit unit = ...;
                        unit.createType("class B {}", null, false,
monitor);
                        unit.getType("A").createField("int i;", null,
false, monitor);
                  }
            },
            monitor);

Clients of JDT-Core (like JDT-UI or PDE) are encouraged to use this API.

Please report any problems with this new API using bugzilla, component
JDT-Core.

Jerome



Back to the top