use of org.eclipse.che.ide.resources.tree.FileNode in project che by eclipse.
the class RunClassContextTestAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
final StatusNotification notification = new StatusNotification("Running Tests...", PROGRESS, FLOAT_MODE);
notificationManager.notify(notification);
final Selection<?> selection = selectionAgent.getSelection();
final Object possibleNode = selection.getHeadElement();
if (possibleNode instanceof FileNode) {
VirtualFile file = ((FileNode) possibleNode).getData();
final Project project = appContext.getRootProject();
String fqn = JavaUtil.resolveFQN(file);
Map<String, String> parameters = new HashMap<>();
parameters.put("fqn", fqn);
parameters.put("runClass", "true");
parameters.put("updateClasspath", "true");
Promise<TestResult> testResultPromise = service.getTestResult(project.getPath(), "testng", parameters);
testResultPromise.then(new Operation<TestResult>() {
@Override
public void apply(TestResult result) throws OperationException {
notification.setStatus(SUCCESS);
if (result.isSuccess()) {
notification.setTitle("Test runner executed successfully");
notification.setContent("All tests are passed");
} else {
notification.setTitle("Test runner executed successfully with test failures.");
notification.setContent(result.getFailureCount() + " test(s) failed.\n");
}
presenter.handleResponse(result);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError exception) throws OperationException {
final String errorMessage = (exception.getMessage() != null) ? exception.getMessage() : "Failed to run test cases";
notification.setContent(errorMessage);
notification.setStatus(FAIL);
}
});
}
}
use of org.eclipse.che.ide.resources.tree.FileNode in project che by eclipse.
the class FindResultGroupNode method getChildrenImpl.
/** {@inheritDoc} */
@Override
protected Promise<List<Node>> getChildrenImpl() {
List<Node> fileNodes = new ArrayList<>();
for (Resource resource : findResults) {
if (resource.getResourceType() != FILE) {
continue;
}
FileNode node = nodeFactory.newFileNode((File) resource, null);
NodePresentation presentation = node.getPresentation(true);
presentation.setInfoText(resource.getLocation().toString());
presentation.setInfoTextWrapper(Pair.of("(", ")"));
presentation.setInfoTextCss("color:" + getEditorInfoTextColor() + ";font-size: 11px");
fileNodes.add(node);
}
//sort nodes by file name
Collections.sort(fileNodes, new NameComparator());
return Promises.resolve(fileNodes);
}
use of org.eclipse.che.ide.resources.tree.FileNode in project che by eclipse.
the class OpenRecentFilesPresenter method setRecentFiles.
/**
* Set recent file list.
*
* @param recentFiles
* recent file list
*/
public void setRecentFiles(List<File> recentFiles) {
final List<FileNode> nodes = newArrayListWithCapacity(recentFiles.size());
for (File recentFile : recentFiles) {
nodes.add(nodeFactory.newFileNode(recentFile, settingsProvider.getSettings()));
}
view.setRecentFiles(nodes);
}
use of org.eclipse.che.ide.resources.tree.FileNode in project che by eclipse.
the class RunClassContextTestAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
final Selection<?> selection = selectionAgent.getSelection();
final Object possibleNode = selection.getHeadElement();
if (possibleNode instanceof FileNode) {
VirtualFile file = ((FileNode) possibleNode).getData();
String fqn = JavaUtil.resolveFQN(file);
Map<String, String> parameters = new HashMap<>();
parameters.put("fqn", fqn);
parameters.put("runClass", "true");
delegate.doRunTests(e, parameters);
}
}
Aggregations