Skip to content

Commit

Permalink
Merge pull request #4 from fathzer/branch-next
Browse files Browse the repository at this point in the history
Bug fixes + moves to java 7 + Sonar complaints fixes
  • Loading branch information
fathzer authored May 23, 2024
2 parents 2996883 + e408fcc commit 302a10d
Show file tree
Hide file tree
Showing 39 changed files with 605 additions and 327 deletions.
4 changes: 3 additions & 1 deletion .classpath
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
Expand All @@ -20,6 +20,7 @@
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
Expand All @@ -33,6 +34,7 @@
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
Expand Down
15 changes: 8 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,22 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 11
uses: actions/setup-java@v1
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 11
java-version: 17
distribution: 'zulu' # Alternative distribution options are available.
- name: Cache SonarCloud packages
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
Expand All @@ -33,4 +34,4 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B org.jacoco:jacoco-maven-plugin:prepare-agent test org.jacoco:jacoco-maven-plugin:report org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dorg.slf4j.simpleLogger.log.org.mockserver.log=warn -Dsonar.projectKey=fathzer_ajlib
run: mvn -B -Dsonar.coverage.exclusions=**/WindowsShortcut.java,**/demo/** -P sonar org.jacoco:jacoco-maven-plugin:prepare-agent test org.jacoco:jacoco-maven-plugin:report org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dorg.slf4j.simpleLogger.log.org.mockserver.log=warn -Dsonar.projectKey=fathzer_ajlib
69 changes: 69 additions & 0 deletions .github/workflows/demo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Demo
on:
push:
branches:
- "master"

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build:
name: Demo
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Set up JDK 8
uses: actions/setup-java@v4
with:
java-version: 8
distribution: 'zulu' # Alternative distribution options are available.
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
run: |
mvn -P demo package
mkdir ./demo
mv ./target/ajlib-demo.jar ./demo
ls -l ./demo/*
- name: Build with Jekyll
uses: actions/jekyll-build-pages@v1
with:
source: ./demo
destination: ./_site
- name: Upload artifact
uses: actions/upload-pages-artifact@v3

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target/
dependency-reduced-pom.xml
1 change: 0 additions & 1 deletion .project
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
</buildCommand>
</buildSpec>
<natures>
<nature>org.sonar.ide.eclipse.core.sonarNature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
Expand Down
6 changes: 3 additions & 3 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
Expand Down Expand Up @@ -81,4 +81,4 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.6
org.eclipse.jdt.core.compiler.source=1.7
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,13 @@

A-JLib is a simple java library with Swing widgets, utilities and other stuff.

Please have a look at the javadoc [here](https://javadoc.io/doc/com.fathzer/ajlib/latest/index.html)
It tries to simplify the development of Swing applications ... which is, sometime, a nightmare!<br>
It contains the classes I developed during the <a href="https://www.yapbam.net">Yapbam project</a> in
order to deal with the problems I encountered.

It requires Java 7+ and is released under Apache 2 License.

A demonstration of Swing widgets is available at [https://fathzer.github.io/ajlib/ajlib-demo.jar](https://fathzer.github.io/ajlib/ajlib-demo.jar).
It is a runnable jar. After you've downloaded it, run it using:
`java -jar ajlib-demo.jar`
Javadoc is available [here](https://javadoc.io/doc/com.fathzer/ajlib).
16 changes: 9 additions & 7 deletions overview.html
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<html>
<head>
<title>Overview</title>
</head>
<body>
<span style="color: rgb(85, 85, 85); font-family: sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; background-color: rgb(255, 255, 255); display: inline ! important; float: none;">
AJlib is a simple java library with Swing widgets, utilities and other
stuff.<br>
AJlib is a simple java library with Swing widgets, utilities and other stuff.<br>
<br>
This library tries to simplify the development of Swing applications ... which is sometime a nightmare!<br>
It contains the classes I developed during the <a href="https://www.yapbam.net">Yapbam project</a> in
order to deal with the problems I encountered.<br>
<br>
The source code is available here: <a target="_top" href="https://github.com/fathzer/ajlib"></a>https://github.com/fathzer/ajlib<br>
For maven users, AJLib is also available in Maven central:<br>
The source code is available at <a target="_top" href="https://github.com/fathzer/ajlib">https://github.com/fathzer/ajlib</a><br>
<br>For maven users, AJLib is also available in <a href="https://search.maven.org/artifact/com.fathzer/ajlib">Maven central</a>:<br>
<i>&lt;dependency&gt;<br>
&nbsp;&nbsp;&lt;groupId&gt;com.fathzer&lt;/groupId&gt;<br>
&nbsp;&nbsp;&lt;artifactId&gt;ajlib&lt;/artifactId&gt;<br>
&nbsp;&nbsp;&lt;version&gt;0.3.14&lt;/version&gt;<br>
&nbsp;&nbsp;&lt;version&gt;0.3.16&lt;/version&gt;<br>
&lt;/dependency&gt;</i><br><br>

It is released under Apache 2 License (information is available <a href="../LICENSE">there</a>).
It is released under Apache 2 License (information is available <a href="../LICENSE">there</a>).<br>
It requires Java 7+.
</span>
</body></html>
115 changes: 76 additions & 39 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
<version>1.0.8</version>
</parent>
<artifactId>ajlib</artifactId>
<version>0.3.15</version>
<version>0.3.16</version>

<packaging>jar</packaging>

<name>A-JLib</name>
<description>A-Jlib is a simple java library with Swing widgets, utilities
and other stuff</description>
<url>http://ajlib.soft.fathzer.com</url>
<url>https://github.com/fathzer/ajlib</url>

<scm>
<url>https://github.com/fathzer/ajlib</url>
Expand All @@ -24,22 +24,87 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<sonar.organization>fathzer</sonar.organization>
<animal-sniffer-version>1.23</animal-sniffer-version>
<animal-sniffer-signature>java16</animal-sniffer-signature>
<animal-sniffer-signature>java17</animal-sniffer-signature>
<maven.compiler.source>1.7</maven.compiler.source>
</properties>

<profiles>
<profile>
<id>release</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
</profile>
<profile>
<id>sonar</id>
<properties>
<sonar.organization>fathzer</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<maven.javadoc.skip>true</maven.javadoc.skip>
</properties>
</profile>
<profile>
<id>demo</id>
<properties>
<maven.javadoc.skip>true</maven.javadoc.skip>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.1</version>
<configuration>
<excludes combine.self="override" />
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.3</version>
<configuration>
<finalName>ajlib-demo</finalName>
<minimizeJar>true</minimizeJar>
<filters>
<filter>
<artifact>*.*</artifact>
<excludes>
<exclude>META-INF/MANIFEST.MF</exclude>
</excludes>
</filter>
</filters>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>com.fathzer.soft.ajlib.swing.demo.AJLibDemo</Main-Class>
</manifestEntries>
</transformer>
</transformers>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>
</profile>
</profiles>

<dependencies>
<dependency>
<groupId>com.fathzer</groupId>
<artifactId>jlocal</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-annotations</artifactId>
<version>${animal-sniffer-version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand All @@ -63,41 +128,13 @@
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<version>3.4.1</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.fathzer.soft.ajlib.swing.demo.AJLibDemo</mainClass>
</manifest>
</archive>
<excludes>
<exclude>**/package.html</exclude>
<exclude>**/demo/**</exclude>
</excludes>
</configuration>
</plugin>

<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>install</phase>
<configuration>
<target>
<zip
destfile="${basedir}/A-JLib-v${project.version}.zip">
<zipfileset dir="." includes="license.html" />
<zipfileset dir="${project.build.directory}" includes="*.jar" />
</zip>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
4 changes: 1 addition & 3 deletions src/main/java/com/fathzer/soft/ajlib/swing/Browser.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ private Browser() {
public static void show(URI uri, Component parent, String errorDialogTitle) {
try {
Desktop.getDesktop().browse(uri);
} catch (IOException e) {
error(uri, parent, errorDialogTitle);
} catch (UnsupportedOperationException e) {
} catch (IOException | UnsupportedOperationException e) {
error(uri, parent, errorDialogTitle);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class ButtonGroup extends Observable {
*/
public ButtonGroup() {
this.autoDeselect = false;
this.buttons = new ArrayList<AbstractButton>();
this.buttons = new ArrayList<>();
this.selected = null;
this.listener = new ItemListener() {
@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/fathzer/soft/ajlib/swing/FontUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private FontUtils() {
* @return The list of fonts that are available and able to display text in the specified locale.
*/
public static List<Font> getAvailableTextFonts(Locale locale) {
ArrayList<Font> result = new ArrayList<Font>();
ArrayList<Font> result = new ArrayList<>();
Font[] allfonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
for (Font font : allfonts) {
if (font.canDisplayUpTo(font.getFontName(locale)) == -1) {
Expand Down
Loading

0 comments on commit 302a10d

Please sign in to comment.