aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch-protocol
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2015-11-09 11:00:21 +0100
committerJulien HENRY <julien.henry@sonarsource.com>2015-11-09 16:48:01 +0100
commit603295776739bbe6658786d2e677a3470fbd7544 (patch)
tree4a054f612c017efa9b364021c50730a3e7529ad5 /sonar-batch-protocol
parent46cdf6128ed90235d8c15c29519c97adb90bc30f (diff)
downloadsonarqube-603295776739bbe6658786d2e677a3470fbd7544.tar.gz
sonarqube-603295776739bbe6658786d2e677a3470fbd7544.zip
SONAR-6922 Fix some quality flaws and provide executable JAR
Diffstat (limited to 'sonar-batch-protocol')
-rw-r--r--sonar-batch-protocol/pom.xml22
-rw-r--r--sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/viewer/TextLineNumber.java27
-rw-r--r--sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/viewer/ViewerApplication.java23
-rw-r--r--sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/viewer/package-info.java24
4 files changed, 70 insertions, 26 deletions
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 @@
<skipTests>${skipBatchTests}</skipTests>
</configuration>
</plugin>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>org.sonar.batch.protocol.viewer.ViewerApplication</mainClass>
+ </manifest>
+ </archive>
+ <descriptorRefs>
+ <descriptorRef>jar-with-dependencies</descriptorRef>
+ </descriptorRefs>
+ </configuration>
+ <executions>
+ <execution>
+ <id>make-assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
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<String, FontMetrics> 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
* <li>TextLineNumber.LEFT
* <li>TextLineNumber.CENTER
* <li>TextLineNumber.RIGHT (default)
- * </ul>
+ * </ul>
* @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
@@ -74,10 +74,18 @@ public class ViewerApplication {
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:
@@ -220,13 +227,6 @@ public class ViewerApplication {
}
/**
- * Create the application.
- */
- public ViewerApplication() {
- initialize();
- }
-
- /**
* Initialize the contents of the frame.
*/
private void initialize() {
@@ -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;
+