Search in sources :

Example 1 with DeleteProjectHandler

use of org.eclipse.che.ide.api.event.project.DeleteProjectHandler 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()));
                }
            }
        }
    });
}
Also used : Path(org.eclipse.che.ide.resource.Path) DeleteProjectEvent(org.eclipse.che.ide.api.event.project.DeleteProjectEvent) EditorOpenedEvent(org.eclipse.che.ide.api.editor.EditorOpenedEvent) ProjectConfigDto(org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto) Resource(org.eclipse.che.ide.api.resources.Resource) DeleteProjectHandler(org.eclipse.che.ide.api.event.project.DeleteProjectHandler) EditorOpenedEventHandler(org.eclipse.che.ide.api.editor.EditorOpenedEventHandler) WorkspaceReadyEvent(org.eclipse.che.ide.api.workspace.WorkspaceReadyEvent) ResourceChangedEvent(org.eclipse.che.ide.api.resources.ResourceChangedEvent)

Aggregations

ProjectConfigDto (org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto)1 EditorOpenedEvent (org.eclipse.che.ide.api.editor.EditorOpenedEvent)1 EditorOpenedEventHandler (org.eclipse.che.ide.api.editor.EditorOpenedEventHandler)1 DeleteProjectEvent (org.eclipse.che.ide.api.event.project.DeleteProjectEvent)1 DeleteProjectHandler (org.eclipse.che.ide.api.event.project.DeleteProjectHandler)1 Resource (org.eclipse.che.ide.api.resources.Resource)1 ResourceChangedEvent (org.eclipse.che.ide.api.resources.ResourceChangedEvent)1 WorkspaceReadyEvent (org.eclipse.che.ide.api.workspace.WorkspaceReadyEvent)1 Path (org.eclipse.che.ide.resource.Path)1