Skip to content

Commit

Permalink
Put demo in a separate module
Browse files Browse the repository at this point in the history
  • Loading branch information
fathzer committed May 21, 2024
1 parent e91f67c commit c5653dd
Show file tree
Hide file tree
Showing 110 changed files with 7,109 additions and 6,999 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,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 -Dsonar.coverage.exclusions=**/WindowsShortcut.java -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
run: mvn -B -Dsonar.coverage.exclusions=**/WindowsShortcut.java,com/fathzer/soft/ajlib/swing/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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target/
*/target/
*/dependency-reduced-pom.xml
4 changes: 0 additions & 4 deletions .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8
34 changes: 17 additions & 17 deletions overview.html → ajlib/overview.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<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>
<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">https://github.com/fathzer/ajlib</a><br>
For maven users, AJLib is also available in <a href="https://search.maven.org/artifact/com.fathzer/ajlib">Maven central</a>:<br>
<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>
<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">https://github.com/fathzer/ajlib</a><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.16&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 requires Java 7+.
It is released under Apache 2 License (information is available <a href="../LICENSE">there</a>).
It requires Java 7+.
</span>
</body></html>
30 changes: 30 additions & 0 deletions ajlib/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.fathzer</groupId>
<artifactId>ajlib-parent-pom</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>ajlib</artifactId>
<version>0.3.16</version>

<packaging>jar</packaging>

<name>A-JLib</name>

<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>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
package com.fathzer.soft.ajlib.swing;

import java.awt.Component;
import java.awt.Desktop;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.io.IOException;
import java.net.URI;

import javax.swing.JOptionPane;

import com.fathzer.jlocal.Formatter;
import com.fathzer.soft.ajlib.swing.framework.Application;


/** A class that is able to open a web browser to display an URI.
*<br>The main advantage of this class is to display an alert dialog if java is not able to open the browser.
*/
public abstract class Browser {
private Browser() {
//To prevent instance to be constructed
}

/** Displays an URI in a browser.
* @param uri The uri to display
* @param parent The parent component of the dialog displayed if browser is not available.
* @param errorDialogTitle The title of the dialog displayed if browser is not available.
*/
public static void show(URI uri, Component parent, String errorDialogTitle) {
try {
Desktop.getDesktop().browse(uri);
} catch (IOException | UnsupportedOperationException e) {
error(uri, parent, errorDialogTitle);
}
}

private static void error(URI uri, Component parent, String errorDialogTitle) {
String url = uri.toString();
String message = Formatter.format(Application.getString("Browser.unsupported.message", parent.getLocale()), url); //$NON-NLS-1$
StringSelection stringSelection = new StringSelection(url);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(stringSelection, null);
if (errorDialogTitle == null) {
errorDialogTitle = "";
}
JOptionPane.showMessageDialog(Utils.getOwnerWindow(parent), message, errorDialogTitle, JOptionPane.WARNING_MESSAGE); //$NON-NLS-1$
}
}
package com.fathzer.soft.ajlib.swing;

import java.awt.Component;
import java.awt.Desktop;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.io.IOException;
import java.net.URI;

import javax.swing.JOptionPane;

import com.fathzer.jlocal.Formatter;
import com.fathzer.soft.ajlib.swing.framework.Application;


/** A class that is able to open a web browser to display an URI.
*<br>The main advantage of this class is to display an alert dialog if java is not able to open the browser.
*/
public abstract class Browser {
private Browser() {
//To prevent instance to be constructed
}

/** Displays an URI in a browser.
* @param uri The uri to display
* @param parent The parent component of the dialog displayed if browser is not available.
* @param errorDialogTitle The title of the dialog displayed if browser is not available.
*/
public static void show(URI uri, Component parent, String errorDialogTitle) {
try {
Desktop.getDesktop().browse(uri);
} catch (IOException | UnsupportedOperationException e) {
error(uri, parent, errorDialogTitle);
}
}

private static void error(URI uri, Component parent, String errorDialogTitle) {
String url = uri.toString();
String message = Formatter.format(Application.getString("Browser.unsupported.message", parent.getLocale()), url); //$NON-NLS-1$
StringSelection stringSelection = new StringSelection(url);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(stringSelection, null);
if (errorDialogTitle == null) {
errorDialogTitle = "";
}
JOptionPane.showMessageDialog(Utils.getOwnerWindow(parent), message, errorDialogTitle, JOptionPane.WARNING_MESSAGE); //$NON-NLS-1$
}
}
Loading

0 comments on commit c5653dd

Please sign in to comment.