use of org.eclipse.core.resources.IResourceChangeListener in project che by eclipse.
the class RefactoringTest method performRefactoring.
protected final RefactoringStatus performRefactoring(Refactoring ref, boolean providesUndo) throws Exception {
performDummySearch();
IUndoManager undoManager = getUndoManager();
if (DESCRIPTOR_TEST) {
final CreateChangeOperation create = new CreateChangeOperation(new CheckConditionsOperation(ref, CheckConditionsOperation.ALL_CONDITIONS), RefactoringStatus.FATAL);
create.run(new NullProgressMonitor());
RefactoringStatus checkingStatus = create.getConditionCheckingStatus();
if (!checkingStatus.isOK())
return checkingStatus;
Change change = create.getChange();
ChangeDescriptor descriptor = change.getDescriptor();
if (descriptor instanceof RefactoringChangeDescriptor) {
RefactoringChangeDescriptor rcd = (RefactoringChangeDescriptor) descriptor;
RefactoringDescriptor refactoringDescriptor = rcd.getRefactoringDescriptor();
if (refactoringDescriptor instanceof JavaRefactoringDescriptor) {
JavaRefactoringDescriptor jrd = (JavaRefactoringDescriptor) refactoringDescriptor;
RefactoringStatus validation = jrd.validateDescriptor();
if (!validation.isOK())
return validation;
RefactoringStatus refactoringStatus = new RefactoringStatus();
Class expected = jrd.getClass();
RefactoringContribution contribution = RefactoringCore.getRefactoringContribution(jrd.getID());
jrd = (JavaRefactoringDescriptor) contribution.createDescriptor(jrd.getID(), jrd.getProject(), jrd.getDescription(), jrd.getComment(), contribution.retrieveArgumentMap(jrd), jrd.getFlags());
assertEquals(expected, jrd.getClass());
ref = jrd.createRefactoring(refactoringStatus);
if (!refactoringStatus.isOK())
return refactoringStatus;
TestRenameParticipantSingle.reset();
TestCreateParticipantSingle.reset();
TestMoveParticipantSingle.reset();
TestDeleteParticipantSingle.reset();
}
}
}
final CreateChangeOperation create = new CreateChangeOperation(new CheckConditionsOperation(ref, CheckConditionsOperation.ALL_CONDITIONS), RefactoringStatus.FATAL);
final PerformChangeOperation perform = new PerformChangeOperation(create);
perform.setUndoManager(undoManager, ref.getName());
IWorkspace workspace = ResourcesPlugin.getWorkspace();
if (fIsPreDeltaTest) {
IResourceChangeListener listener = new IResourceChangeListener() {
public void resourceChanged(IResourceChangeEvent event) {
if (create.getConditionCheckingStatus().isOK() && perform.changeExecuted()) {
TestModelProvider.assertTrue(event.getDelta());
}
}
};
try {
TestModelProvider.clearDelta();
workspace.checkpoint(false);
workspace.addResourceChangeListener(listener);
executePerformOperation(perform, workspace);
} finally {
workspace.removeResourceChangeListener(listener);
}
} else {
executePerformOperation(perform, workspace);
}
RefactoringStatus status = create.getConditionCheckingStatus();
if (!status.isOK())
return status;
assertTrue("Change wasn't executed", perform.changeExecuted());
Change undo = perform.getUndoChange();
if (providesUndo) {
assertNotNull("Undo doesn't exist", undo);
assertTrue("Undo manager is empty", undoManager.anythingToUndo());
} else {
assertNull("Undo manager contains undo but shouldn't", undo);
}
return null;
}
use of org.eclipse.core.resources.IResourceChangeListener in project tesb-studio-se by Talend.
the class ResourceEditorListener method partClosed.
@Override
public void partClosed(IWorkbenchPartReference partRef) {
IWorkbenchPart part = partRef.getPart(true);
if (part instanceof IEditorPart) {
IEditorInput input = ((IEditorPart) part).getEditorInput();
if (input instanceof RouteResourceInput) {
Item item = ((RouteResourceInput) input).getItem();
if (item.getProperty().getId().equals(editorInput.getItem().getProperty().getId())) {
try {
ProxyRepositoryFactory.getInstance().unlock(item);
page.getWorkbenchWindow().getPartService().removePartListener(this);
IResourceChangeListener l = editorInput.getListener();
if (null != l) {
ResourcesPlugin.getWorkspace().removeResourceChangeListener(l);
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
}
}
}
use of org.eclipse.core.resources.IResourceChangeListener in project translationstudio8 by heartsome.
the class ApplicationWorkbenchWindowAdvisor method addWorkplaceListener.
public void addWorkplaceListener() {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
workspace.addResourceChangeListener(new IResourceChangeListener() {
public void resourceChanged(IResourceChangeEvent event) {
//刷新项目导航视图
Display.getDefault().syncExec(new Runnable() {
public void run() {
IViewPart findView = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView("net.heartsome.cat.common.ui.navigator.view");
if (null == findView) {
return;
}
IAction refreshActionHandler = findView.getViewSite().getActionBars().getGlobalActionHandler(ActionFactory.REFRESH.getId());
if (null == refreshActionHandler) {
return;
}
refreshActionHandler.run();
}
});
}
});
}
use of org.eclipse.core.resources.IResourceChangeListener in project xtext-eclipse by eclipse.
the class Bug486584Test method tearDown.
@Override
@After
public void tearDown() throws Exception {
super.tearDown();
for (IResourceChangeListener l : resourceChangeListeners) {
ResourcesPlugin.getWorkspace().removeResourceChangeListener(l);
}
resourceChangeListeners.clear();
}
use of org.eclipse.core.resources.IResourceChangeListener in project erlide_eclipse by erlang.
the class ErlModel method setupWorkspaceListeners.
public final void setupWorkspaceListeners() {
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
final IPathVariableManager pvm = workspace.getPathVariableManager();
pvm.addChangeListener(fPathVariableChangeListener);
final IResourceChangeListener listener = new ResourceChangeListener();
workspace.addResourceChangeListener(listener);
}
Aggregations