Search in sources :

Example 1 with ResourceManager

use of org.eclipse.che.ide.resources.impl.ResourceManager 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)

Aggregations

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 AppContext (org.eclipse.che.ide.api.app.AppContext)1 CurrentUser (org.eclipse.che.ide.api.app.CurrentUser)1 StartUpAction (org.eclipse.che.ide.api.app.StartUpAction)1 HasDataObject (org.eclipse.che.ide.api.data.HasDataObject)1 EditorAgent (org.eclipse.che.ide.api.editor.EditorAgent)1