Search in sources :

Example 1 with BuckTreeNodeDetail

use of com.facebook.buck.intellij.ideabuck.ui.tree.BuckTreeNodeDetail in project buck by facebook.

the class BuckEventsConsumer method consumeBuildEnd.

@Override
public void consumeBuildEnd(final long timestamp) {
    mMainBuildEndTimestamp = timestamp;
    float duration = (mMainBuildEndTimestamp - mMainBuildStartTimestamp) / 1000;
    final String message = "Build ended, took " + duration + " seconds!";
    int errors = 0;
    int warnings = 0;
    for (String cTarget : mErrors.keySet()) {
        List<String> currentErrorMessages = mErrors.get(cTarget);
        for (String currentErrorMessage : currentErrorMessages) {
            ErrorExtractor errorExtractor = new ErrorExtractor(currentErrorMessage);
            for (CompilerErrorItem currentErrorItem : errorExtractor.getErrors()) {
                if (currentErrorItem.getType() == CompilerErrorItem.Type.ERROR) {
                    errors++;
                } else {
                    warnings++;
                }
            }
        }
    }
    String errorsMessage = "";
    if (errors != 0) {
        errorsMessage = "Found " + errors + " errors";
    }
    if (warnings != 0) {
        if (errors != 0) {
            errorsMessage += " and " + warnings + " warnings";
        } else {
            errorsMessage = "Found " + warnings + " warnings";
        }
    }
    if (errorsMessage.length() > 0) {
        errorsMessage += "!";
    }
    final String errorsMessageToUse = errorsMessage;
    //set progress to 100%
    consumeBuckBuildProgressUpdate(timestamp, 1f);
    if (errorsMessageToUse.length() > 0) {
        clearDisplay();
        BuckTreeNodeDetail errorsMessageNode = new BuckTreeNodeDetail(BuckEventsConsumer.this.mCurrentBuildRootElement, BuckTreeNodeDetail.DetailType.ERROR, errorsMessageToUse);
        BuckEventsConsumer.this.mCurrentBuildRootElement.addChild(errorsMessageNode);
        // Display errors
        BuckEventsConsumer.this.displayErrors();
    }
    BuckEventsConsumer.this.mBuildProgress.setDetail(message);
    ApplicationManager.getApplication().invokeLater(new Runnable() {

        @Override
        public void run() {
            BuckEventsConsumer.this.mTreeModel.reload();
        }
    });
}
Also used : CompilerErrorItem(com.facebook.buck.intellij.ideabuck.ui.utils.CompilerErrorItem) ErrorExtractor(com.facebook.buck.intellij.ideabuck.ui.utils.ErrorExtractor) BuckTreeNodeDetail(com.facebook.buck.intellij.ideabuck.ui.tree.BuckTreeNodeDetail)

Example 2 with BuckTreeNodeDetail

use of com.facebook.buck.intellij.ideabuck.ui.tree.BuckTreeNodeDetail in project buck by facebook.

the class BuckEventsConsumer method consumeBuckProjectGenerationStarted.

@Override
public void consumeBuckProjectGenerationStarted(long timestamp) {
    mProjectGenerationStartTimestamp = timestamp;
    // start may be called before of after progress update
    if (BuckEventsConsumer.this.mProjectGenerationProgress == null) {
        BuckEventsConsumer.this.mProjectGenerationProgress = new BuckTreeNodeDetail(BuckEventsConsumer.this.mCurrentBuildRootElement, BuckTreeNodeDetail.DetailType.INFO, "Current project generation progress: " + Math.round(BuckEventsConsumer.this.mProjectGenerationProgressValue * 100) + "%");
        BuckEventsConsumer.this.mCurrentBuildRootElement.addChild(mProjectGenerationProgress);
        ApplicationManager.getApplication().invokeLater(new Runnable() {

            @Override
            public void run() {
                BuckEventsConsumer.this.mTreeModel.reload();
            }
        });
    }
}
Also used : BuckTreeNodeDetail(com.facebook.buck.intellij.ideabuck.ui.tree.BuckTreeNodeDetail)

Example 3 with BuckTreeNodeDetail

use of com.facebook.buck.intellij.ideabuck.ui.tree.BuckTreeNodeDetail in project buck by facebook.

the class BuckEventsConsumer method consumeTestRunStarted.

@Override
public void consumeTestRunStarted(long timestamp) {
    mTestingStartTimestamp = timestamp;
    // start may be called before of after progress update
    if (BuckEventsConsumer.this.mTestResults == null) {
        BuckEventsConsumer.this.mTestResults = new BuckTreeNodeDetail(mCurrentBuildRootElement, BuckTreeNodeDetail.DetailType.INFO, "Running tests");
        BuckEventsConsumer.this.mCurrentBuildRootElement.addChild(mTestResults);
        ApplicationManager.getApplication().invokeLater(new Runnable() {

            @Override
            public void run() {
                BuckEventsConsumer.this.mTreeModel.reload();
            }
        });
    }
}
Also used : BuckTreeNodeDetail(com.facebook.buck.intellij.ideabuck.ui.tree.BuckTreeNodeDetail)

Example 4 with BuckTreeNodeDetail

use of com.facebook.buck.intellij.ideabuck.ui.tree.BuckTreeNodeDetail in project buck by facebook.

the class BuckEventsConsumer method consumeConsoleEvent.

@Override
public void consumeConsoleEvent(final String message) {
    if (!BuckToolWindowFactory.isToolWindowInstantiated(mProject)) {
        return;
    }
    if (!BuckToolWindowFactory.isToolWindowVisible(mProject)) {
        BuckToolWindowFactory.showToolWindow(mProject);
    }
    if (mCurrentBuildRootElement == null) {
        return;
    }
    mCurrentBuildRootElement.addChild(new BuckTreeNodeDetail(mCurrentBuildRootElement, BuckTreeNodeDetail.DetailType.ERROR, message));
    ApplicationManager.getApplication().invokeLater(new Runnable() {

        @Override
        public void run() {
            BuckEventsConsumer.this.mTreeModel.reload();
        }
    });
}
Also used : BuckTreeNodeDetail(com.facebook.buck.intellij.ideabuck.ui.tree.BuckTreeNodeDetail)

Example 5 with BuckTreeNodeDetail

use of com.facebook.buck.intellij.ideabuck.ui.tree.BuckTreeNodeDetail in project buck by facebook.

the class BuckToolWindowFactory method createBuildInfoPanel.

private JComponent createBuildInfoPanel(Project project) {
    Tree result = new Tree(BuckUIManager.getInstance(project).getTreeModel());
    result.addMouseListener(new MouseListener() {

        @Override
        public void mouseClicked(MouseEvent e) {
            Tree tree = (Tree) e.getComponent();
            int selRow = tree.getRowForLocation(e.getX(), e.getY());
            TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());
            if (selRow != -1 && e.getClickCount() == 2) {
                TreeNode node = (TreeNode) selPath.getLastPathComponent();
                if (node.isLeaf()) {
                    BuckTreeNodeDetail buckNode = (BuckTreeNodeDetail) node;
                    if (buckNode instanceof BuckTreeNodeDetailError) {
                        BuckToolWindowFactory.this.handleClickOnError((BuckTreeNodeDetailError) buckNode);
                    }
                }
            }
        }

        @Override
        public void mousePressed(MouseEvent e) {
        }

        @Override
        public void mouseReleased(MouseEvent e) {
        }

        @Override
        public void mouseEntered(MouseEvent e) {
        }

        @Override
        public void mouseExited(MouseEvent e) {
        }
    });
    result.setCellRenderer(new BuckTreeCellRenderer());
    result.setShowsRootHandles(false);
    result.setRowHeight(0);
    JBScrollPane treeView = new JBScrollPane(result);
    return treeView;
}
Also used : MouseListener(java.awt.event.MouseListener) MouseEvent(java.awt.event.MouseEvent) TreePath(javax.swing.tree.TreePath) TreeNode(javax.swing.tree.TreeNode) Tree(com.intellij.ui.treeStructure.Tree) BuckTreeNodeDetailError(com.facebook.buck.intellij.ideabuck.ui.tree.BuckTreeNodeDetailError) BuckTreeCellRenderer(com.facebook.buck.intellij.ideabuck.ui.tree.renderers.BuckTreeCellRenderer) JBScrollPane(com.intellij.ui.components.JBScrollPane) BuckTreeNodeDetail(com.facebook.buck.intellij.ideabuck.ui.tree.BuckTreeNodeDetail)

Aggregations

BuckTreeNodeDetail (com.facebook.buck.intellij.ideabuck.ui.tree.BuckTreeNodeDetail)9 JBLabel (com.intellij.ui.components.JBLabel)2 BuckTreeNodeDetailError (com.facebook.buck.intellij.ideabuck.ui.tree.BuckTreeNodeDetailError)1 BuckTreeNodeFileError (com.facebook.buck.intellij.ideabuck.ui.tree.BuckTreeNodeFileError)1 BuckTreeCellRenderer (com.facebook.buck.intellij.ideabuck.ui.tree.renderers.BuckTreeCellRenderer)1 CompilerErrorItem (com.facebook.buck.intellij.ideabuck.ui.utils.CompilerErrorItem)1 ErrorExtractor (com.facebook.buck.intellij.ideabuck.ui.utils.ErrorExtractor)1 JBScrollPane (com.intellij.ui.components.JBScrollPane)1 Tree (com.intellij.ui.treeStructure.Tree)1 MouseEvent (java.awt.event.MouseEvent)1 MouseListener (java.awt.event.MouseListener)1 Icon (javax.swing.Icon)1 TreeNode (javax.swing.tree.TreeNode)1 TreePath (javax.swing.tree.TreePath)1