Search in sources :

Example 1 with WorkspaceReadyEvent

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());
    });
}
Also used : ResourceDeltaImpl(org.eclipse.che.ide.resources.impl.ResourceDeltaImpl) WindowActionEvent(org.eclipse.che.ide.api.event.WindowActionEvent) Inject(com.google.inject.Inject) Arrays(org.eclipse.che.ide.util.Arrays) SelectionChangedEvent(org.eclipse.che.ide.api.event.SelectionChangedEvent) Arrays.sort(java.util.Arrays.sort) FactoryDto(org.eclipse.che.api.factory.shared.dto.FactoryDto) ResourceDeltaImpl(org.eclipse.che.ide.resources.impl.ResourceDeltaImpl) StartUpAction(org.eclipse.che.ide.api.app.StartUpAction) UPDATED(org.eclipse.che.ide.api.resources.ResourceDelta.UPDATED) ResourceManagerInitializer(org.eclipse.che.ide.resources.ResourceManagerInitializer) Arrays.copyOf(java.util.Arrays.copyOf) WorkspaceReadyEvent(org.eclipse.che.ide.api.workspace.WorkspaceReadyEvent) WorkspaceStartedEvent(org.eclipse.che.ide.api.workspace.event.WorkspaceStartedEvent) ResourceChangedHandler(org.eclipse.che.ide.api.resources.ResourceChangedEvent.ResourceChangedHandler) Set(java.util.Set) HasDataObject(org.eclipse.che.ide.api.data.HasDataObject) DevMachine(org.eclipse.che.ide.api.machine.DevMachine) Sets(com.google.common.collect.Sets) Preconditions.checkState(com.google.common.base.Preconditions.checkState) Callback(com.google.gwt.core.client.Callback) List(java.util.List) PROJECT(org.eclipse.che.ide.api.resources.Resource.PROJECT) MOVED_FROM(org.eclipse.che.ide.api.resources.ResourceDelta.MOVED_FROM) ADDED(org.eclipse.che.ide.api.resources.ResourceDelta.ADDED) Singleton(com.google.inject.Singleton) Workspace(org.eclipse.che.api.core.model.workspace.Workspace) Project(org.eclipse.che.ide.api.resources.Project) WindowActionHandler(org.eclipse.che.ide.api.event.WindowActionHandler) ResourcePathComparator(org.eclipse.che.ide.api.resources.ResourcePathComparator) ArrayList(java.util.ArrayList) ResourceChangedEvent(org.eclipse.che.ide.api.resources.ResourceChangedEvent) AppContext(org.eclipse.che.ide.api.app.AppContext) SYNCHRONIZED(org.eclipse.che.ide.api.resources.ResourceDelta.SYNCHRONIZED) EditorAgent(org.eclipse.che.ide.api.editor.EditorAgent) WorkspaceStoppedEvent(org.eclipse.che.ide.api.workspace.event.WorkspaceStoppedEvent) Arrays.binarySearch(java.util.Arrays.binarySearch) ActiveRuntime(org.eclipse.che.ide.api.machine.ActiveRuntime) Selection(org.eclipse.che.ide.api.selection.Selection) EventBus(com.google.web.bindery.event.shared.EventBus) SelectionChangedHandler(org.eclipse.che.ide.api.event.SelectionChangedHandler) SyntheticNode(org.eclipse.che.ide.project.node.SyntheticNode) ResourceManager(org.eclipse.che.ide.resources.impl.ResourceManager) Resource(org.eclipse.che.ide.api.resources.Resource) REMOVED(org.eclipse.che.ide.api.resources.ResourceDelta.REMOVED) ResourceDelta(org.eclipse.che.ide.api.resources.ResourceDelta) Provider(com.google.inject.Provider) Container(org.eclipse.che.ide.api.resources.Container) VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) CurrentUser(org.eclipse.che.ide.api.app.CurrentUser) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter) AppStateManager(org.eclipse.che.ide.statepersistance.AppStateManager) Path(org.eclipse.che.ide.resource.Path) Project(org.eclipse.che.ide.api.resources.Project) WorkspaceReadyEvent(org.eclipse.che.ide.api.workspace.WorkspaceReadyEvent) ResourceChangedEvent(org.eclipse.che.ide.api.resources.ResourceChangedEvent)

Example 2 with WorkspaceReadyEvent

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()));
                }
            }
        }
    });
}
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

Resource (org.eclipse.che.ide.api.resources.Resource)2 ResourceChangedEvent (org.eclipse.che.ide.api.resources.ResourceChangedEvent)2 WorkspaceReadyEvent (org.eclipse.che.ide.api.workspace.WorkspaceReadyEvent)2 Path (org.eclipse.che.ide.resource.Path)2 Preconditions.checkState (com.google.common.base.Preconditions.checkState)1 Sets (com.google.common.collect.Sets)1 Callback (com.google.gwt.core.client.Callback)1 Inject (com.google.inject.Inject)1 Provider (com.google.inject.Provider)1 Singleton (com.google.inject.Singleton)1 EventBus (com.google.web.bindery.event.shared.EventBus)1 ArrayList (java.util.ArrayList)1 Arrays.binarySearch (java.util.Arrays.binarySearch)1 Arrays.copyOf (java.util.Arrays.copyOf)1 Arrays.sort (java.util.Arrays.sort)1 List (java.util.List)1 Set (java.util.Set)1 Workspace (org.eclipse.che.api.core.model.workspace.Workspace)1 FactoryDto (org.eclipse.che.api.factory.shared.dto.FactoryDto)1 ProjectConfigDto (org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto)1