Skip to content

Commit fa95b86

Browse files
author
Vladyslav Zhukovskyi
authored
Update state of currently selected resources (eclipse-che#4194)
* Update state of currently selected resources * Update maven compiler configuration to allow using lambdas * Remove redundant plugin override
1 parent 6edd8f8 commit fa95b86

2 files changed

Lines changed: 26 additions & 33 deletions

File tree

ide/che-core-ide-app/pom.xml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -328,14 +328,6 @@
328328
</excludes>
329329
</configuration>
330330
</plugin>
331-
<plugin>
332-
<groupId>org.apache.maven.plugins</groupId>
333-
<artifactId>maven-compiler-plugin</artifactId>
334-
<configuration>
335-
<source>1.7</source>
336-
<target>1.7</target>
337-
</configuration>
338-
</plugin>
339331
</plugins>
340332
</build>
341333
</project>

ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/context/AppContextImpl.java

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919

2020
import org.eclipse.che.api.core.model.workspace.Workspace;
2121
import org.eclipse.che.api.factory.shared.dto.FactoryDto;
22-
import org.eclipse.che.api.promises.client.Operation;
23-
import org.eclipse.che.api.promises.client.OperationException;
24-
import org.eclipse.che.api.promises.client.PromiseError;
2522
import org.eclipse.che.ide.api.app.AppContext;
2623
import org.eclipse.che.ide.api.app.CurrentUser;
2724
import org.eclipse.che.ide.api.app.StartUpAction;
@@ -214,19 +211,13 @@ public void initResourceManager(final Callback<ResourceManager, Exception> callb
214211
}
215212

216213
resourceManager = resourceManagerFactory.newResourceManager(runtime.getDevMachine());
217-
resourceManager.getWorkspaceProjects().then(new Operation<Project[]>() {
218-
@Override
219-
public void apply(Project[] projects) throws OperationException {
220-
AppContextImpl.this.projects = projects;
221-
java.util.Arrays.sort(AppContextImpl.this.projects, ResourcePathComparator.getInstance());
222-
callback.onSuccess(resourceManager);
223-
eventBus.fireEvent(new WorkspaceReadyEvent(projects));
224-
}
225-
}).catchError(new Operation<PromiseError>() {
226-
@Override
227-
public void apply(PromiseError error) throws OperationException {
228-
callback.onFailure((Exception)error.getCause());
229-
}
214+
resourceManager.getWorkspaceProjects().then(projects -> {
215+
AppContextImpl.this.projects = projects;
216+
java.util.Arrays.sort(AppContextImpl.this.projects, ResourcePathComparator.getInstance());
217+
callback.onSuccess(resourceManager);
218+
eventBus.fireEvent(new WorkspaceReadyEvent(projects));
219+
}).catchError(error -> {
220+
callback.onFailure((Exception)error.getCause());
230221
});
231222
}
232223

@@ -304,6 +295,19 @@ public void onResourceChanged(ResourceChangedEvent event) {
304295
projects[i] = (Project)resource;
305296
}
306297
}
298+
299+
if (currentResources != null) {
300+
for (int i = 0; i < currentResources.length; i++) {
301+
if (currentResources[i].getLocation().equals(resource.getLocation())) {
302+
currentResources[i] = resource;
303+
break;
304+
}
305+
}
306+
}
307+
308+
if (currentResource != null && currentResource.getLocation().equals(resource.getLocation())) {
309+
currentResource = resource;
310+
}
307311
}
308312
}
309313

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

458462
@Override
459463
public void onWorkspaceStopped(WorkspaceStoppedEvent event) {
460-
appStateManager.get().persistWorkspaceState(getWorkspaceId()).then(new Operation<Void>() {
461-
@Override
462-
public void apply(Void arg) throws OperationException {
463-
for (Project project : projects) {
464-
eventBus.fireEvent(new ResourceChangedEvent(new ResourceDeltaImpl(project, REMOVED)));
465-
}
466-
467-
projects = NO_PROJECTS; //avoid NPE
468-
resourceManager = null;
464+
appStateManager.get().persistWorkspaceState(getWorkspaceId()).then(ignored -> {
465+
for (Project project : projects) {
466+
eventBus.fireEvent(new ResourceChangedEvent(new ResourceDeltaImpl(project, REMOVED)));
469467
}
468+
469+
projects = NO_PROJECTS;
470+
resourceManager = null;
470471
});
471472

472473
//goto close all editors

0 commit comments

Comments
 (0)