Skip to content

Commit

Permalink
Update state of currently selected resources (eclipse-che#4194)
Browse files Browse the repository at this point in the history
* Update state of currently selected resources

* Update maven compiler configuration to allow using lambdas

* Remove redundant plugin override
  • Loading branch information
Vladyslav Zhukovskyi authored Feb 22, 2017
1 parent 73bec71 commit 066fd5a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 33 deletions.
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

0 comments on commit 066fd5a

Please sign in to comment.