use of org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy in project che by eclipse.
the class RefactoringHistorySerializer method processHistoryNotification.
/**
* Processes the history event.
*
* @param store
* the file store
* @param event
* the history event
* @param name
* the project name, or <code>null</code>
* @throws CoreException
* if an error occurs
*/
private void processHistoryNotification(final IFileStore store, final RefactoringHistoryEvent event, final String name) throws CoreException {
final RefactoringDescriptorProxy proxy = event.getDescriptor();
final int type = event.getEventType();
final RefactoringHistoryManager manager = new RefactoringHistoryManager(store, name);
final NullProgressMonitor monitor = new NullProgressMonitor();
if (type == RefactoringHistoryEvent.PUSHED || type == RefactoringHistoryEvent.ADDED) {
final RefactoringDescriptor descriptor = proxy.requestDescriptor(monitor);
if (descriptor != null)
manager.addRefactoringDescriptor(descriptor, type == RefactoringHistoryEvent.ADDED, monitor);
} else if (type == RefactoringHistoryEvent.POPPED)
manager.removeRefactoringDescriptors(new RefactoringDescriptorProxy[] { proxy }, monitor, RefactoringCoreMessages.RefactoringHistoryService_updating_history);
}
use of org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy in project che by eclipse.
the class RefactoringHistoryService method deleteRefactoringDescriptors.
/**
* Deletes the specified refactoring descriptors from their associated
* refactoring histories.
*
* @param proxies
* the refactoring descriptor proxies
* @param query
* the refactoring descriptor delete query to use
* @param monitor
* the progress monitor to use, or <code>null</code>
* @throws CoreException
* if an error occurs while deleting the refactoring
* descriptors. Reasons include:
* <ul>
* <li>The refactoring history has an illegal format, contains
* illegal arguments or otherwise illegal information.</li>
* <li>An I/O error occurs while deleting the refactoring
* descriptors from the refactoring history.</li>
* </ul>
*
* @see IRefactoringCoreStatusCodes#REFACTORING_HISTORY_FORMAT_ERROR
* @see IRefactoringCoreStatusCodes#REFACTORING_HISTORY_IO_ERROR
*/
public void deleteRefactoringDescriptors(final RefactoringDescriptorProxy[] proxies, final IRefactoringDescriptorDeleteQuery query, IProgressMonitor monitor) throws CoreException {
Assert.isNotNull(proxies);
Assert.isNotNull(query);
if (monitor == null)
monitor = new NullProgressMonitor();
try {
monitor.beginTask(RefactoringCoreMessages.RefactoringHistoryService_deleting_refactorings, proxies.length + 300);
final Set set = new HashSet(proxies.length);
for (int index = 0; index < proxies.length; index++) {
if (query.proceed(proxies[index]).isOK())
set.add(proxies[index]);
monitor.worked(1);
}
if (!set.isEmpty()) {
final RefactoringDescriptorProxy[] delete = (RefactoringDescriptorProxy[]) set.toArray(new RefactoringDescriptorProxy[set.size()]);
deleteRefactoringDescriptors(delete, new SubProgressMonitor(monitor, 300));
for (int index = 0; index < delete.length; index++) fireRefactoringHistoryEvent(delete[index], RefactoringHistoryEvent.DELETED);
}
} finally {
monitor.done();
}
}
use of org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy in project che by eclipse.
the class RefactoringHistoryService method getRefactoringHistory.
/**
* {@inheritDoc}
*/
public RefactoringHistory getRefactoringHistory(final IProject[] projects, final long start, final long end, final int flags, IProgressMonitor monitor) {
Assert.isNotNull(projects);
Assert.isTrue(start >= 0);
Assert.isTrue(end >= start);
Assert.isTrue(flags >= RefactoringDescriptor.NONE);
if (monitor == null)
monitor = new NullProgressMonitor();
try {
monitor.beginTask(RefactoringCoreMessages.RefactoringHistoryService_retrieving_history, 3 * projects.length);
final Set set = new HashSet();
if (flags > RefactoringDescriptor.NONE) {
for (int index = 0; index < projects.length; index++) {
final IProject project = projects[index];
if (project.isAccessible()) {
final RefactoringDescriptorProxy[] proxies = getProjectHistory(project, start, end, flags, new SubProgressMonitor(monitor, 1)).getDescriptors();
filterRefactoringDescriptors(proxies, set, false, flags, new SubProgressMonitor(monitor, 2));
}
}
} else {
for (int index = 0; index < projects.length; index++) {
final IProject project = projects[index];
if (project.isAccessible()) {
final RefactoringDescriptorProxy[] proxies = getProjectHistory(project, start, end, RefactoringDescriptor.NONE, new SubProgressMonitor(monitor, 3)).getDescriptors();
for (int offset = 0; offset < proxies.length; offset++) set.add(proxies[offset]);
}
}
}
final RefactoringDescriptorProxy[] proxies = new RefactoringDescriptorProxy[set.size()];
set.toArray(proxies);
return new RefactoringHistoryImplementation(proxies);
} finally {
monitor.done();
}
}
use of org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy in project che by eclipse.
the class RefactoringHistoryService method getProjectHistory.
/**
* {@inheritDoc}
*/
public RefactoringHistory getProjectHistory(final IProject project, final long start, final long end, final int flags, IProgressMonitor monitor) {
Assert.isNotNull(project);
Assert.isTrue(project.exists());
Assert.isTrue(start >= 0);
Assert.isTrue(end >= 0);
Assert.isTrue(flags >= RefactoringDescriptor.NONE);
if (project.isOpen()) {
if (monitor == null)
monitor = new NullProgressMonitor();
try {
monitor.beginTask(RefactoringCoreMessages.RefactoringHistoryService_retrieving_history, 120);
final String name = project.getName();
final RefactoringHistoryManager manager = getManager(name);
if (manager != null) {
RefactoringHistory history = manager.readRefactoringHistory(start, end, new SubProgressMonitor(monitor, 20));
if (flags > RefactoringDescriptor.NONE) {
final Set set = new HashSet();
filterRefactoringDescriptors(history.getDescriptors(), set, false, flags, new SubProgressMonitor(monitor, 100));
history = new RefactoringHistoryImplementation((RefactoringDescriptorProxy[]) set.toArray(new RefactoringDescriptorProxy[set.size()]));
}
return history;
}
} finally {
monitor.done();
}
}
return NO_HISTORY;
}
use of org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy in project che by eclipse.
the class RefactoringHistoryService method deleteRefactoringDescriptors.
/**
* Deletes the specified refactoring descriptors from their associated
* refactoring histories.
*
* @param proxies
* the refactoring descriptor proxies
* @param monitor
* the progress monitor to use, or <code>null</code>
* @throws CoreException
* if an error occurs while deleting the refactoring
* descriptors. Reasons include:
* <ul>
* <li>The refactoring history has an illegal format, contains
* illegal arguments or otherwise illegal information.</li>
* <li>An I/O error occurs while deleting the refactoring
* descriptors from the refactoring history.</li>
* </ul>
*
* @see IRefactoringCoreStatusCodes#REFACTORING_HISTORY_FORMAT_ERROR
* @see IRefactoringCoreStatusCodes#REFACTORING_HISTORY_IO_ERROR
*/
public void deleteRefactoringDescriptors(final RefactoringDescriptorProxy[] proxies, IProgressMonitor monitor) throws CoreException {
Assert.isNotNull(proxies);
if (monitor == null)
monitor = new NullProgressMonitor();
try {
monitor.beginTask(RefactoringCoreMessages.RefactoringHistoryService_deleting_refactorings, proxies.length + 300);
final Map projects = new HashMap();
for (int index = 0; index < proxies.length; index++) {
String project = proxies[index].getProject();
if (//$NON-NLS-1$
project == null || "".equals(project))
project = RefactoringHistoryService.NAME_WORKSPACE_PROJECT;
Collection collection = (Collection) projects.get(project);
if (collection == null) {
collection = new ArrayList();
projects.put(project, collection);
}
collection.add(proxies[index]);
monitor.worked(1);
}
final SubProgressMonitor subMonitor = new SubProgressMonitor(monitor, 300);
try {
final Set entries = projects.entrySet();
subMonitor.beginTask(RefactoringCoreMessages.RefactoringHistoryService_deleting_refactorings, entries.size());
for (final Iterator iterator = entries.iterator(); iterator.hasNext(); ) {
final Map.Entry entry = (Map.Entry) iterator.next();
final Collection collection = (Collection) entry.getValue();
String project = (String) entry.getKey();
if (project.equals(RefactoringHistoryService.NAME_WORKSPACE_PROJECT))
project = null;
final RefactoringHistoryManager manager = getManager(project);
if (manager != null)
manager.removeRefactoringDescriptors((RefactoringDescriptorProxy[]) collection.toArray(new RefactoringDescriptorProxy[collection.size()]), new SubProgressMonitor(subMonitor, 1), RefactoringCoreMessages.RefactoringHistoryService_deleting_refactorings);
else
subMonitor.worked(1);
}
} finally {
subMonitor.done();
}
} finally {
monitor.done();
}
}
Aggregations