Skip to content

Commit

Permalink
Rework top test menu items
Browse files Browse the repository at this point in the history
https://issues.jboss.org/browse/CHE-227


Signed-off-by: David Festal <dfestal@redhat.com>
  • Loading branch information
davidfestal authored and benoitf committed May 31, 2017
1 parent b37b576 commit d082b32
Show file tree
Hide file tree
Showing 18 changed files with 298 additions and 895 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-ide-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-ide-app</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-java-ext-lang-client</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
import org.eclipse.che.ide.api.keybinding.KeyBuilder;
import org.eclipse.che.ide.util.browser.UserAgent;
import org.eclipse.che.plugin.testing.ide.TestAction;
import org.eclipse.che.plugin.testing.junit.ide.action.RunAllContextTestAction;
import org.eclipse.che.plugin.testing.junit.ide.action.RunAllTestAction;
import org.eclipse.che.plugin.testing.junit.ide.action.RunClassContextTestAction;
import org.eclipse.che.plugin.testing.junit.ide.action.RunClassTestAction;

import com.google.inject.Inject;
Expand All @@ -30,27 +28,18 @@
* @author Mirage Abeysekara
*/
public class JUnitTestAction implements TestAction {

public static final String TEST_ACTION_RUN_ALL = "TestActionRunAll";
public static final String TEST_ACTION_RUN_CLASS = "TestActionRunClass";
public static final String TEST_ACTION_RUN_CLASS_CONTEXT = "TestActionRunClassContext";
public static final String TEST_ACTION_RUN_ALL_CONTEXT = "TestActionRunAllContext";
private final Action runClassTestAction;
private final Action runAllTestAction;
public static final String TEST_ACTION_RUN_CLASS = "TestJUnitActionRunClassContext";
public static final String TEST_ACTION_RUN_ALL = "TestJUnitActionRunAllContext";
private final Action runClassContextTestAction;
private final Action runAllContextTestAction;

@Inject
public JUnitTestAction(ActionManager actionManager,
RunClassTestAction runClassTestAction,
RunAllTestAction runAllTestAction,
RunClassContextTestAction runClassContextTestAction,
RunAllContextTestAction runAllContextTestAction,
RunClassTestAction runClassContextTestAction,
RunAllTestAction runAllContextTestAction,
KeyBindingAgent keyBinding) {
actionManager.registerAction(TEST_ACTION_RUN_CLASS, runClassTestAction);
actionManager.registerAction(TEST_ACTION_RUN_ALL, runAllTestAction);
actionManager.registerAction(TEST_ACTION_RUN_CLASS_CONTEXT, runClassContextTestAction);
actionManager.registerAction(TEST_ACTION_RUN_ALL_CONTEXT, runAllContextTestAction);
actionManager.registerAction(TEST_ACTION_RUN_CLASS, runClassContextTestAction);
actionManager.registerAction(TEST_ACTION_RUN_ALL, runAllContextTestAction);

if (UserAgent.isMac()) {
keyBinding.getGlobal().addKey(new KeyBuilder().control().alt().charCode('z').build(), TEST_ACTION_RUN_ALL);
Expand All @@ -60,17 +49,15 @@ public JUnitTestAction(ActionManager actionManager,
keyBinding.getGlobal().addKey(new KeyBuilder().action().shift().charCode('z').build(), TEST_ACTION_RUN_CLASS);
}

this.runAllTestAction = runAllTestAction;
this.runClassContextTestAction = runClassContextTestAction;
this.runClassTestAction = runClassTestAction;
this.runAllContextTestAction = runAllContextTestAction;
}


@Override
public void addMainMenuItems(DefaultActionGroup testMainMenu) {
testMainMenu.add(runClassTestAction);
testMainMenu.add(runAllTestAction);
testMainMenu.add(runClassContextTestAction);
testMainMenu.add(runAllContextTestAction);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ public interface JUnitTestLocalizationConstant extends Messages {
@Key("action.runClass.description")
String actionRunClassDescription();

@Key("action.runClassContext.title")
String actionRunClassContextTitle();

@Key("action.runClassContext.description")
String actionRunClassContextDescription();

@Key("action.runAll.title")
String actionRunAllTitle();

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,28 @@
*******************************************************************************/
package org.eclipse.che.plugin.testing.junit.ide.action;

import static org.eclipse.che.ide.workspace.perspectives.project.ProjectPerspective.PROJECT_PERSPECTIVE_ID;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

import javax.validation.constraints.NotNull;

import org.eclipse.che.ide.api.action.AbstractPerspectiveAction;
import org.eclipse.che.ide.api.action.ActionEvent;
import org.eclipse.che.ide.api.app.AppContext;
import org.eclipse.che.ide.api.editor.EditorAgent;
import org.eclipse.che.ide.api.filetypes.FileTypeRegistry;
import org.eclipse.che.ide.api.notification.NotificationManager;
import org.eclipse.che.ide.ext.java.client.action.JavaEditorAction;
import org.eclipse.che.ide.api.resources.Container;
import org.eclipse.che.ide.api.resources.File;
import org.eclipse.che.ide.api.resources.Project;
import org.eclipse.che.ide.api.resources.Resource;
import org.eclipse.che.ide.api.resources.VirtualFile;
import org.eclipse.che.ide.api.selection.Selection;
import org.eclipse.che.ide.api.selection.SelectionAgent;
import org.eclipse.che.ide.ext.java.client.util.JavaUtil;
import org.eclipse.che.ide.resources.tree.ContainerNode;
import org.eclipse.che.ide.resources.tree.FileNode;
import org.eclipse.che.plugin.testing.ide.TestServiceClient;
import org.eclipse.che.plugin.testing.ide.action.RunTestActionDelegate;
import org.eclipse.che.plugin.testing.ide.view.TestResultPresenter;
Expand All @@ -31,35 +44,63 @@
* @author Mirage Abeysekara
* @author David Festal
*/
public class RunAllTestAction extends JavaEditorAction
implements RunTestActionDelegate.Source {
public class RunAllTestAction extends AbstractPerspectiveAction
implements RunTestActionDelegate.Source {

private final NotificationManager notificationManager;
private final TestResultPresenter presenter;
private final TestServiceClient service;
private final AppContext appContext;
private final SelectionAgent selectionAgent;
private final RunTestActionDelegate delegate;

@Inject
public RunAllTestAction(JUnitTestResources resources,
NotificationManager notificationManager,
EditorAgent editorAgent,
TestResultPresenter presenter,
FileTypeRegistry fileTypeRegistry,
TestServiceClient service,
JUnitTestLocalizationConstant localization) {
super(localization.actionRunAllTitle(), localization.actionRunAllDescription(), resources.testAllIcon(),
editorAgent, fileTypeRegistry);
NotificationManager notificationManager,
AppContext appContext,
TestResultPresenter presenter,
TestServiceClient service,
SelectionAgent selectionAgent,
JUnitTestLocalizationConstant localization) {
super(Arrays.asList(PROJECT_PERSPECTIVE_ID), localization.actionRunAllTitle(),
localization.actionRunAllDescription(), null, resources.testAllIcon());
this.notificationManager = notificationManager;
this.editorAgent = editorAgent;
this.presenter = presenter;
this.service = service;
this.appContext = appContext;
this.selectionAgent = selectionAgent;
this.delegate = new RunTestActionDelegate(this);
}

@Override
public void actionPerformed(ActionEvent e) {
Map<String, String> parameters = new HashMap<>();
delegate.doRunTests(e, parameters);
Resource resource = appContext.getResource();
if (resource != null) {
Project project = resource.getProject();
if (project != null) {
Map<String, String> parameters = new HashMap<>();
delegate.doRunTests(e, parameters);
}
}
}

@Override
public void updateInPerspective(@NotNull ActionEvent e) {
Resource resource = appContext.getResource();
if (resource == null) {
e.getPresentation().setEnabledAndVisible(false);
}

Project project = resource.getProject();
if (project == null) {
e.getPresentation().setEnabledAndVisible(false);
}

e.getPresentation().setVisible(true);

String projectType = project.getType();
boolean enable = "maven".equals(projectType);
e.getPresentation().setEnabled(enable);
}

@Override
Expand All @@ -81,7 +122,7 @@ public TestServiceClient getService() {
public TestResultPresenter getPresenter() {
return presenter;
}

@Override
public String getTestingFramework() {
return "junit";
Expand Down
Loading

0 comments on commit d082b32

Please sign in to comment.