Search in sources :

Example 1 with FileNode

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);
            }
        });
    }
}
Also used : VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) HashMap(java.util.HashMap) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) TestResult(org.eclipse.che.api.testing.shared.TestResult) Operation(org.eclipse.che.api.promises.client.Operation) Project(org.eclipse.che.ide.api.resources.Project) PromiseError(org.eclipse.che.api.promises.client.PromiseError) FileNode(org.eclipse.che.ide.resources.tree.FileNode) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 2 with FileNode

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);
}
Also used : NodePresentation(org.eclipse.che.ide.ui.smartTree.presentation.NodePresentation) FileNode(org.eclipse.che.ide.resources.tree.FileNode) Node(org.eclipse.che.ide.api.data.tree.Node) ResourceNode(org.eclipse.che.ide.resources.tree.ResourceNode) AbstractTreeNode(org.eclipse.che.ide.api.data.tree.AbstractTreeNode) ArrayList(java.util.ArrayList) Resource(org.eclipse.che.ide.api.resources.Resource) FileNode(org.eclipse.che.ide.resources.tree.FileNode) NameComparator(org.eclipse.che.ide.ui.smartTree.compare.NameComparator)

Example 3 with FileNode

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);
}
Also used : File(org.eclipse.che.ide.api.resources.File) FileNode(org.eclipse.che.ide.resources.tree.FileNode)

Example 4 with FileNode

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);
    }
}
Also used : VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) HashMap(java.util.HashMap) FileNode(org.eclipse.che.ide.resources.tree.FileNode)

Aggregations

FileNode (org.eclipse.che.ide.resources.tree.FileNode)4 HashMap (java.util.HashMap)2 VirtualFile (org.eclipse.che.ide.api.resources.VirtualFile)2 ArrayList (java.util.ArrayList)1 Operation (org.eclipse.che.api.promises.client.Operation)1 OperationException (org.eclipse.che.api.promises.client.OperationException)1 PromiseError (org.eclipse.che.api.promises.client.PromiseError)1 TestResult (org.eclipse.che.api.testing.shared.TestResult)1 AbstractTreeNode (org.eclipse.che.ide.api.data.tree.AbstractTreeNode)1 Node (org.eclipse.che.ide.api.data.tree.Node)1 StatusNotification (org.eclipse.che.ide.api.notification.StatusNotification)1 File (org.eclipse.che.ide.api.resources.File)1 Project (org.eclipse.che.ide.api.resources.Project)1 Resource (org.eclipse.che.ide.api.resources.Resource)1 ResourceNode (org.eclipse.che.ide.resources.tree.ResourceNode)1 NameComparator (org.eclipse.che.ide.ui.smartTree.compare.NameComparator)1 NodePresentation (org.eclipse.che.ide.ui.smartTree.presentation.NodePresentation)1