Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update state of currently selected resources #4194

Merged
merged 3 commits into from
Feb 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions ide/che-core-ide-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -328,14 +328,6 @@
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@

import org.eclipse.che.api.core.model.workspace.Workspace;
import org.eclipse.che.api.factory.shared.dto.FactoryDto;
import org.eclipse.che.api.promises.client.Operation;
import org.eclipse.che.api.promises.client.OperationException;
import org.eclipse.che.api.promises.client.PromiseError;
import org.eclipse.che.ide.api.app.AppContext;
import org.eclipse.che.ide.api.app.CurrentUser;
import org.eclipse.che.ide.api.app.StartUpAction;
Expand Down Expand Up @@ -214,19 +211,13 @@ public void initResourceManager(final Callback<ResourceManager, Exception> callb
}

resourceManager = resourceManagerFactory.newResourceManager(runtime.getDevMachine());
resourceManager.getWorkspaceProjects().then(new Operation<Project[]>() {
@Override
public void apply(Project[] projects) throws OperationException {
AppContextImpl.this.projects = projects;
java.util.Arrays.sort(AppContextImpl.this.projects, ResourcePathComparator.getInstance());
callback.onSuccess(resourceManager);
eventBus.fireEvent(new WorkspaceReadyEvent(projects));
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
callback.onFailure((Exception)error.getCause());
}
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());
});
}

Expand Down Expand Up @@ -304,6 +295,19 @@ public void onResourceChanged(ResourceChangedEvent event) {
projects[i] = (Project)resource;
}
}

if (currentResources != null) {
for (int i = 0; i < currentResources.length; i++) {
if (currentResources[i].getLocation().equals(resource.getLocation())) {
currentResources[i] = resource;
break;
}
}
}

if (currentResource != null && currentResource.getLocation().equals(resource.getLocation())) {
currentResource = resource;
}
}
}

Expand Down Expand Up @@ -457,16 +461,13 @@ public void onWorkspaceStarted(WorkspaceStartedEvent event) {

@Override
public void onWorkspaceStopped(WorkspaceStoppedEvent event) {
appStateManager.get().persistWorkspaceState(getWorkspaceId()).then(new Operation<Void>() {
@Override
public void apply(Void arg) throws OperationException {
for (Project project : projects) {
eventBus.fireEvent(new ResourceChangedEvent(new ResourceDeltaImpl(project, REMOVED)));
}

projects = NO_PROJECTS; //avoid NPE
resourceManager = null;
appStateManager.get().persistWorkspaceState(getWorkspaceId()).then(ignored -> {
for (Project project : projects) {
eventBus.fireEvent(new ResourceChangedEvent(new ResourceDeltaImpl(project, REMOVED)));
}

projects = NO_PROJECTS;
resourceManager = null;
});

//goto close all editors
Expand Down