Package org.sonar.wsclient.services

Examples of org.sonar.wsclient.services.Violation


            @Override
            public void valueChanged(ListSelectionEvent e) {
                ListSelectionModel listSelectionModel = (ListSelectionModel) e.getSource();
                if (!listSelectionModel.isSelectionEmpty()) {
                    Integer selectionIndex = listSelectionModel.getMinSelectionIndex();
                    final Violation violation = violationTableModel.getViolation(violationsTable.convertRowIndexToModel(selectionIndex));

                    if (violation.getLine() != null) {
                        DataManager.getInstance().getDataContextFromFocus().doWhenDone(new AsyncResult.Handler<DataContext>() {
                            @Override
                            public void run(DataContext dataContext) {
                                OpenFileDescriptor descriptor = new OpenFileDescriptor(project, violationTableModel.getCurrentVirtualFile(), violation.getLine() - 1, 0);
                                descriptor.navigate(false);
                            }
                        });
                    }
                }
View Full Code Here


        return 5;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Violation violation = violations.get(rowIndex);
        switch (columnIndex) {
            case 0:
                return violation.getSeverity();
            case 1:
                return violation.getRuleName();
            case 2:
                return violation.getLine();
            case 3:
                if (this.source == null || violation.getLine() == null) {
                    return "UNKNOWN";
                } else {
                    int lineNumber = violation.getLine();
                    return this.source.getLine(lineNumber);
                }
            case 4:
                return violation.getMessage();
            default:
                return "";
        }
    }
View Full Code Here

        List<Violation> violations = new ArrayList<Violation>();
        model.setViolations(file, violations);

        Assert.assertEquals(0, model.getRowCount());

        violations.add(new Violation());
        Assert.assertEquals(1, model.getRowCount());

        violations.add(new Violation());
        Assert.assertEquals(2, model.getRowCount());
    }
View Full Code Here

    public void settingViolationsOrSourceWithADifferentVirtualFileResetsOther() {
        VirtualFile file1 = new LightVirtualFile("file1.txt");
        VirtualFile file2 = new LightVirtualFile("file1.txt");

        ArrayList<Violation> violations = new ArrayList<Violation>();
        violations.add(new Violation());
        model.setViolations(file1, violations);
        Assert.assertSame(violations, model.violations);
        Assert.assertNull(model.source);

        Source source = new Source();
View Full Code Here

    @Test
    public void testValueAt() {
        VirtualFile file = new LightVirtualFile("file.txt");

        // Add violations
        Violation violation1 = new Violation();
        violation1.setSeverity("Major");
        violation1.setRuleName("A rule");
        violation1.setLine(null);
        violation1.setMessage("This violation has no line associated with it");

        Violation violation2 = new Violation();
        violation2.setSeverity("Minor");
        violation2.setRuleName("Another rule");
        violation2.setLine(10);
        violation2.setMessage("This violation has a line associated with it");

        List<Violation> violations = new ArrayList<Violation>();
        violations.add(violation1);
        violations.add(violation2);
View Full Code Here

TOP

Related Classes of org.sonar.wsclient.services.Violation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.