From: Julien HENRY Date: Mon, 9 Nov 2015 10:00:21 +0000 (+0100) Subject: SONAR-6922 Fix some quality flaws and provide executable JAR X-Git-Tag: 5.3-RC1~345 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=603295776739bbe6658786d2e677a3470fbd7544;p=sonarqube.git SONAR-6922 Fix some quality flaws and provide executable JAR --- diff --git a/sonar-batch-protocol/pom.xml b/sonar-batch-protocol/pom.xml index add1b341cc5..d7dd35788b9 100644 --- a/sonar-batch-protocol/pom.xml +++ b/sonar-batch-protocol/pom.xml @@ -61,6 +61,28 @@ ${skipBatchTests} + + maven-assembly-plugin + + + + org.sonar.batch.protocol.viewer.ViewerApplication + + + + jar-with-dependencies + + + + + make-assembly + package + + single + + + + diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/viewer/TextLineNumber.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/viewer/TextLineNumber.java index f0aa1e3215b..b84ae5003cc 100644 --- a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/viewer/TextLineNumber.java +++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/viewer/TextLineNumber.java @@ -56,15 +56,14 @@ import javax.swing.text.Utilities; * This class was designed to be used as a component added to the row header * of a JScrollPane. */ -public class TextLineNumber extends JPanel - implements CaretListener, DocumentListener, PropertyChangeListener { - public final static float LEFT = 0.0f; - public final static float CENTER = 0.5f; - public final static float RIGHT = 1.0f; +public class TextLineNumber extends JPanel implements CaretListener, DocumentListener, PropertyChangeListener { + public static final float LEFT = 0.0f; + public static final float CENTER = 0.5f; + public static final float RIGHT = 1.0f; - private final static Border OUTER = new MatteBorder(0, 0, 0, 2, Color.GRAY); + private static final Border OUTER = new MatteBorder(0, 0, 0, 2, Color.GRAY); - private final static int HEIGHT = Integer.MAX_VALUE - 1000000; + private static final int HEIGHT = Integer.MAX_VALUE - 1000000; // Text component this TextTextLineNumber component is in sync with @@ -88,7 +87,7 @@ public class TextLineNumber extends JPanel private HashMap fonts; /** - * Create a line number component for a text component. This minimum + * Create a line number component for a text component. This minimum * display width will be based on 3 digits. * * @param component the related text component @@ -98,7 +97,7 @@ public class TextLineNumber extends JPanel } /** - * Create a line number component for a text component. + * Create a line number component for a text component. * * @param component the related text component * @param minimumDisplayDigits the number of digits used to calculate @@ -197,7 +196,7 @@ public class TextLineNumber extends JPanel *
  • TextLineNumber.LEFT *
  • TextLineNumber.CENTER *
  • TextLineNumber.RIGHT (default) - * + * * @param currentLineForeground the Color used to render the current line */ public void setDigitAlignment(float digitAlignment) { @@ -301,10 +300,7 @@ public class TextLineNumber extends JPanel int caretPosition = component.getCaretPosition(); Element root = component.getDocument().getDefaultRootElement(); - if (root.getElementIndex(rowStartOffset) == root.getElementIndex(caretPosition)) - return true; - else - return false; + return root.getElementIndex(rowStartOffset) == root.getElementIndex(caretPosition); } /* @@ -436,7 +432,8 @@ public class TextLineNumber extends JPanel lastHeight = rect.y; } } catch (BadLocationException ex) { - /* nothing to do */ } + /* nothing to do */ + } } }); } diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/viewer/ViewerApplication.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/viewer/ViewerApplication.java index 410cb6110a5..bd082f1dd88 100644 --- a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/viewer/ViewerApplication.java +++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/viewer/ViewerApplication.java @@ -73,11 +73,19 @@ public class ViewerApplication { private JEditorPane coverageEditor; private TextLineNumber textLineNumber; + /** + * Create the application. + */ + public ViewerApplication() { + initialize(); + } + /** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { + @Override public void run() { try { ViewerApplication window = new ViewerApplication(); @@ -132,17 +140,16 @@ public class ViewerApplication { getComponentTree().setModel(new DefaultTreeModel(project)); } - private DefaultMutableTreeNode createNode(Component component) { - DefaultMutableTreeNode node = new DefaultMutableTreeNode(component) { + private static DefaultMutableTreeNode createNode(Component component) { + return new DefaultMutableTreeNode(component) { @Override public String toString() { return getNodeName((Component) getUserObject()); } }; - return node; } - private String getNodeName(Component component) { + private static String getNodeName(Component component) { switch (component.getType()) { case PROJECT: case MODULE: @@ -219,13 +226,6 @@ public class ViewerApplication { } } - /** - * Create the application. - */ - public ViewerApplication() { - initialize(); - } - /** * Initialize the contents of the frame. */ @@ -291,6 +291,7 @@ public class ViewerApplication { treeScrollPane.setViewportView(componentTree); componentTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); componentTree.addTreeSelectionListener(new TreeSelectionListener() { + @Override public void valueChanged(TreeSelectionEvent e) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) componentTree.getLastSelectedPathComponent(); diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/viewer/package-info.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/viewer/package-info.java new file mode 100644 index 00000000000..18a61aeb018 --- /dev/null +++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/viewer/package-info.java @@ -0,0 +1,24 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +@ParametersAreNonnullByDefault +package org.sonar.batch.protocol.viewer; + +import javax.annotation.ParametersAreNonnullByDefault; +