Skip to content

Commit

Permalink
CHE-1444: fix problems with updating classpath
Browse files Browse the repository at this point in the history
Signed-off-by: Valeriy Svydenko <vsvydenko@codenvy.com>
  • Loading branch information
Valeriy Svydenko committed Jul 8, 2016
1 parent 5a77df2 commit 85c736e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
*/
@Singleton
public class MarkDirAsSourceAction extends AbstractPerspectiveAction {
private final AppContext appContext;
private final ClasspathServiceClient classpathService;
private final ClasspathResolver classpathResolver;
private final NotificationManager notificationManager;
private final AppContext appContext;
private final ClasspathServiceClient classpathService;
private final ClasspathResolver classpathResolver;
private final NotificationManager notificationManager;

@Inject
public MarkDirAsSourceAction(JavaResources javaResources,
Expand Down Expand Up @@ -99,8 +99,17 @@ public void apply(PromiseError arg) throws OperationException {
@Override
public void updateInPerspective(ActionEvent e) {
final Resource[] resources = appContext.getResources();
final boolean inJavaProject = resources != null && resources.length == 1 && isJavaProject(resources[0].getRelatedProject().get());

e.getPresentation().setEnabledAndVisible(inJavaProject && !resources[0].getMarker(SourceFolderMarker.ID).isPresent());
if (resources == null || resources.length != 1) {
e.getPresentation().setEnabledAndVisible(false);
return;
}

Resource resource = resources[0];
final boolean inJavaProject = isJavaProject(resource.getRelatedProject().get());

e.getPresentation().setEnabledAndVisible(inJavaProject &&
resource.isFolder() &&
!resource.getMarker(SourceFolderMarker.ID).isPresent());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import javax.validation.constraints.NotNull;
import java.util.Collections;

import static org.eclipse.che.ide.ext.java.client.resource.SourceFolderMarker.ID;
import static org.eclipse.che.ide.ext.java.client.util.JavaUtil.isJavaProject;
import static org.eclipse.che.ide.workspace.perspectives.project.ProjectPerspective.PROJECT_PERSPECTIVE_ID;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.google.common.base.Preconditions;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.google.web.bindery.event.shared.EventBus;

import org.eclipse.che.api.promises.client.Operation;
import org.eclipse.che.api.promises.client.OperationException;
Expand Down Expand Up @@ -50,6 +51,7 @@ public class ClasspathResolver {

private final ClasspathUpdaterServiceClient classpathUpdater;
private final NotificationManager notificationManager;
private final EventBus eventBus;
private final AppContext appContext;
private final DtoFactory dtoFactory;

Expand All @@ -61,10 +63,12 @@ public class ClasspathResolver {
@Inject
public ClasspathResolver(ClasspathUpdaterServiceClient classpathUpdater,
NotificationManager notificationManager,
EventBus eventBus,
AppContext appContext,
DtoFactory dtoFactory) {
this.classpathUpdater = classpathUpdater;
this.notificationManager = notificationManager;
this.eventBus = eventBus;
this.appContext = appContext;
this.dtoFactory = dtoFactory;
}
Expand Down Expand Up @@ -122,6 +126,7 @@ public Promise<Void> updateClasspath() {
promise.then(new Operation<Void>() {
@Override
public void apply(Void arg) throws OperationException {
eventBus.fireEvent(new ClasspathChangedEvent(project.get().getLocation().toString(), entries));
project.get().synchronize();
}
}).catchError(new Operation<PromiseError>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import com.google.gwt.user.client.ui.AcceptsOneWidget;
import com.google.gwtmockito.GwtMockitoTestRunner;

import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto;
import org.eclipse.che.ide.api.project.MutableProjectConfig;
import org.eclipse.che.ide.api.project.type.wizard.ProjectWizardRegistrar;
import org.eclipse.che.ide.api.wizard.Wizard;
import org.eclipse.che.plugin.java.plain.client.wizard.selector.SelectNodePresenter;
Expand Down Expand Up @@ -47,7 +47,7 @@ public class PlainJavaPagePresenterTest {
@Mock
private PlainJavaPageView view;
@Mock
private ProjectConfigDto dataObject;
private MutableProjectConfig dataObject;
@Mock
private AcceptsOneWidget container;
@Mock
Expand Down

0 comments on commit 85c736e

Please sign in to comment.