use of org.eclipse.che.ide.api.workspace.WorkspaceReadyEvent in project che by eclipse.
the class AppContextImpl method initResourceManager.
@Override
public void initResourceManager(final Callback<ResourceManager, Exception> callback) {
if (runtime.getDevMachine() == null) {
//should never happened, but anyway
callback.onFailure(new NullPointerException("Dev machine is not initialized"));
}
if (projects != null) {
for (Project project : projects) {
eventBus.fireEvent(new ResourceChangedEvent(new ResourceDeltaImpl(project, REMOVED)));
}
projects = null;
}
resourceManager = resourceManagerFactory.newResourceManager(runtime.getDevMachine());
resourceManager.getWorkspaceProjects().then(projects -> {
AppContextImpl.this.projects = projects;
java.util.Arrays.sort(AppContextImpl.this.projects, ResourcePathComparator.getInstance());
callback.onSuccess(resourceManager);
eventBus.fireEvent(new WorkspaceReadyEvent(projects));
}).catchError(error -> {
callback.onFailure((Exception) error.getCause());
});
}
use of org.eclipse.che.ide.api.workspace.WorkspaceReadyEvent in project che by eclipse.
the class BreakpointManagerImpl method registerEventHandlers.
/**
* Registers events handlers.
*/
private void registerEventHandlers(EventBus eventBus) {
eventBus.addHandler(WorkspaceReadyEvent.getType(), new WorkspaceReadyEvent.WorkspaceReadyHandler() {
@Override
public void onWorkspaceReady(WorkspaceReadyEvent event) {
restoreBreakpoints();
}
});
eventBus.addHandler(EditorOpenedEvent.TYPE, new EditorOpenedEventHandler() {
@Override
public void onEditorOpened(EditorOpenedEvent event) {
onOpenEditor(event.getFile().getLocation().toString(), event.getEditor());
}
});
eventBus.addHandler(DeleteProjectEvent.TYPE, new DeleteProjectHandler() {
@Override
public void onProjectDeleted(DeleteProjectEvent event) {
if (breakpoints.isEmpty()) {
return;
}
ProjectConfigDto config = event.getProjectConfig();
String path = config.getPath() + "/";
deleteBreakpoints(getBreakpointPaths(path));
}
});
eventBus.addHandler(ResourceChangedEvent.getType(), new ResourceChangedEvent.ResourceChangedHandler() {
@Override
public void onResourceChanged(ResourceChangedEvent event) {
if (event.getDelta().getKind() == ResourceDelta.REMOVED) {
if (breakpoints.isEmpty()) {
return;
}
final Resource resource = event.getDelta().getResource();
Path path = resource.getLocation();
if (resource.isFolder()) {
path.addTrailingSeparator();
deleteBreakpoints(getBreakpointPaths(path.toString()));
} else if (resource.isFile()) {
deleteBreakpoints(Collections.singleton(path.toString()));
}
}
}
});
}
Aggregations