Skip to content

Commit

Permalink
PluginManager
Browse files Browse the repository at this point in the history
- Moved `PluginManager` into a separate library module [ #336 ]
- PluginManager.java, Plugin.java, DetectedPlugin.java - Proper checks for headless environment

Utilities
- SystemUtils.java - Added headless environment check method
- ImageUtils.java - Removed static icons initialization to avoid issues in headless environment

Build
- build.xml, build.properties - Updated ANT build with new `weblaf-plugin-xxx.jar` artifact
- build.xml, build.properties - Slightly reworked the way classpaths are defined to make them more convenient
- pom.xml - Added for plugin module, slightly updated for other modules
  • Loading branch information
mgarin committed Dec 6, 2016
1 parent 2b25090 commit 3ad2bd2
Show file tree
Hide file tree
Showing 34 changed files with 154 additions and 57 deletions.
19 changes: 14 additions & 5 deletions build/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,33 @@ svgsalamander.jar=svg-salamander-1.0.jar

# WebLaF core library
library.core.title=WebLaF core library
library.core.lib=${slf4j.api.jar} ${slf4j.binding.jar} ${imagescaling.jar} ${jericho.jar} ${xstream.jar}
library.core.jar.name=${library.name}-core-${version.info}.jar
library.core.jar=${artifacts.dir}/${library.core.jar.name}
library.core.src.dir=${modules.dir}/core/src
library.core.dist.dir=${dist.dir}/core

# WebLaF plugin library
library.plugin.title=WebLaF plugin library
library.plugin.jar.name=${library.name}-plugin-${version.info}.jar
library.plugin.jar=${artifacts.dir}/${library.plugin.jar.name}
library.plugin.src.dir=${modules.dir}/plugin/src
library.plugin.dist.dir=${dist.dir}/plugin

# WebLaF UI library
library.ui.title=WebLaF ui library
library.ui.main=com.alee.laf.LibraryInfoDialog
library.ui.lib=${library.core.lib} ${svgsalamander.jar} ${rsyntaxtextarea.jar}
library.ui.jar.name=${library.name}-ui-${version.info}.jar
library.ui.jar=${artifacts.dir}/${library.ui.jar.name}
library.ui.main=com.alee.laf.LibraryInfoDialog
library.ui.src.dir=${modules.dir}/ui/src
library.ui.dist.dir=${dist.dir}/ui

# WebLaF demo library
# library.demo.title=WebLaF demo library
# library.demo.main=com.alee.examples.WebLookAndFeelDemo
# library.demo.jar.name=${library.name}-demo-${version.info}.jar
# library.demo.jar=${artifacts.dir}/${library.demo.jar.name}
library.demo.title=WebLaF demo library
library.demo.main=com.alee.demo.DemoApplication
library.demo.jar.name=${library.name}-demo-${version.info}.jar
library.demo.jar=${artifacts.dir}/${library.demo.jar.name}
library.demo.src.dir=${modules.dir}/demo/src
library.demo.dist.dir=${dist.dir}/demo

Expand Down
65 changes: 50 additions & 15 deletions build/build.xml
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
<?xml version="1.0"?>
<project name="Web Look and Feel" basedir="../" default="build.basic.artifacts">

<!-- =========================== Includes ============================ -->

<!-- Property files -->
<property file="build/version.properties" />
<property file="build/build.properties" />

<!-- =========================== Base settings ============================ -->

<!-- Base classpaths -->
<property name="core.classpath" value="${slf4j.api.jar} ${slf4j.binding.jar} ${imagescaling.jar} ${jericho.jar} ${xstream.jar}" />
<property name="ui.classpath" value="${core.classpath} ${svgsalamander.jar} ${rsyntaxtextarea.jar}" />
<property name="demo.classpath" value="${ui.classpath}" />
<!-- Separate JAR classpaths -->
<property name="core.jar.classpath" value="${core.classpath}" />
<property name="ui.jar.classpath" value="${ui.classpath} ${library.core.jar.name}" />
<property name="demo.jar.classpath" value="${demo.classpath} ${library.core.jar.name} ${library.ui.jar.name}" />
<!-- Complete JAR classpaths -->
<property name="weblaf.jar.classpath" value="${ui.classpath}" />
<!-- =========================== Classpath settings ============================ -->

<!-- Classpath -->
<!-- Compile classpaths -->
<path id="core.classpath">
<fileset dir="${lib.dir}" includes="*.jar" />
</path>
<path id="plugin.classpath">
<fileset dir="${lib.dir}" includes="*.jar" />
<pathelement path="${library.core.dist.dir}" />
</path>
<path id="ui.classpath">
<fileset dir="${lib.dir}" includes="*.jar" />
<pathelement path="${library.core.dist.dir}" />
Expand All @@ -32,6 +27,13 @@
<pathelement path="${library.ui.dist.dir}" />
</path>

<!-- JAR classpaths -->
<property name="core.jar.classpath" value="${library.core.lib}" />
<property name="plugin.jar.classpath" value="${library.core.lib} ${library.core.jar.name}" />
<property name="ui.jar.classpath" value="${library.ui.lib} ${library.core.jar.name}" />
<property name="demo.jar.classpath" value="${library.ui.lib} ${library.core.jar.name} ${library.ui.jar.name}" />
<property name="weblaf.jar.classpath" value="${library.ui.lib}" />

<!-- =========================== Base targets ============================ -->

<!-- Dist directory -->
Expand All @@ -58,6 +60,13 @@
<classpath refid="core.classpath" />
</javac>
</target>
<target name="compile.plugin" depends="compile.core">
<mkdir dir="${library.plugin.dist.dir}" />
<javac debug="true" includeantruntime="false" destdir="${library.plugin.dist.dir}" encoding="utf-8" source="1.6" target="1.6">
<src path="${library.plugin.src.dir}" />
<classpath refid="plugin.classpath" />
</javac>
</target>
<target name="compile.ui" depends="compile.core">
<mkdir dir="${library.ui.dist.dir}" />
<javac debug="true" includeantruntime="false" destdir="${library.ui.dist.dir}" encoding="utf-8" source="1.6" target="1.6">
Expand All @@ -79,6 +88,11 @@
<fileset dir="${library.core.src.dir}" excludes="**/*.java" />
</copy>
</target>
<target name="copy.plugin.res" depends="copy.core.res">
<copy todir="${library.plugin.dist.dir}">
<fileset dir="${library.plugin.src.dir}" excludes="**/*.java" />
</copy>
</target>
<target name="copy.ui.res" depends="copy.core.res">
<copy todir="${library.ui.dist.dir}">
<fileset dir="${library.ui.src.dir}" excludes="**/*.java" />
Expand Down Expand Up @@ -137,6 +151,21 @@
</jar>
</target>

<!-- Assemble library plugin jar -->
<target name="build.plugin.jar" description="Build ${library.plugin.jar}" depends="clean.dist.dir,compile.plugin,copy.plugin.res,copy.lic,create.artifacts.dir">
<jar destfile="${library.plugin.jar}">
<fileset dir="${dist.dir}" includes="licenses/**" />
<fileset dir="${library.plugin.dist.dir}" />
<manifest>
<attribute name="Package-Title" value="${package}" />
<attribute name="Package-Vendor" value="${dev}" />
<attribute name="Package-Version" value="${version.info}" />
<attribute name="Product-Name" value="${library.plugin.title}" />
<attribute name="Class-Path" value="${plugin.jar.classpath}" />
</manifest>
</jar>
</target>

<!-- Assemble library ui jar -->
<target name="build.ui.jar" description="Build ${library.ui.jar}" depends="clean.dist.dir,compile.ui,copy.ui.res,copy.lic,create.artifacts.dir">
<jar destfile="${library.ui.jar}">
Expand All @@ -153,7 +182,7 @@
</jar>
</target>

<!-- Assemble library demo jar
<!-- Assemble library demo jar -->
<target name="build.demo.jar" description="Build ${library.demo.jar}" depends="compile.demo,copy.demo.res,copy.lic,create.artifacts.dir">
<jar destfile="${library.demo.jar}">
<fileset dir="${dist.dir}" includes="licenses/**" />
Expand All @@ -168,7 +197,6 @@
</manifest>
</jar>
</target>
-->

<!-- =========================== Complete binaries ============================ -->

Expand All @@ -177,6 +205,7 @@
<jar destfile="${library.jar}">
<fileset dir="${dist.dir}" includes="licenses/**" />
<fileset dir="${library.core.dist.dir}" />
<fileset dir="${library.plugin.dist.dir}" />
<fileset dir="${library.ui.dist.dir}" />
<manifest>
<attribute name="Package-Title" value="${package}" />
Expand All @@ -201,6 +230,7 @@
<zipfileset src="${lib.dir}/${rsyntaxtextarea.jar}" excludes="META-INF/**" />
<fileset dir="${dist.dir}" includes="licenses/**" />
<fileset dir="${library.core.dist.dir}" />
<fileset dir="${library.plugin.dist.dir}" />
<fileset dir="${library.ui.dist.dir}" />
<manifest>
<attribute name="Package-Title" value="${package}" />
Expand All @@ -227,6 +257,8 @@
<fileset dir="${dist.dir}" includes="licenses/**" />
<fileset dir="${library.core.dist.dir}" />
<fileset dir="${library.core.src.dir}" includes="**/*.java" />
<fileset dir="${library.plugin.dist.dir}" />
<fileset dir="${library.plugin.src.dir}" includes="**/*.java" />
<fileset dir="${library.ui.dist.dir}" />
<fileset dir="${library.ui.src.dir}" includes="**/*.java" />
<fileset dir="${library.demo.dist.dir}" />
Expand All @@ -253,6 +285,7 @@
<zipfileset src="${lib.dir}/${rsyntaxtextarea.jar}" excludes="META-INF/**" />
<fileset dir="${dist.dir}" includes="licenses/**" />
<fileset dir="${library.core.dist.dir}" />
<fileset dir="${library.plugin.dist.dir}" />
<fileset dir="${library.ui.dist.dir}" />
<manifest>
<attribute name="Package-Title" value="${package}" />
Expand Down Expand Up @@ -294,6 +327,7 @@
</copy>
<copy todir="${dist.dir}">
<fileset dir="${library.core.src.dir}" />
<fileset dir="${library.plugin.src.dir}" />
<fileset dir="${library.ui.src.dir}" />
<fileset dir="${library.demo.src.dir}" />
</copy>
Expand Down Expand Up @@ -418,6 +452,7 @@
<!-- Assembled build implementations -->
<target name="build.base.impl">
<antcall target="build.core.jar" />
<antcall target="build.plugin.jar" />
<antcall target="build.ui.jar" />
</target>
<target name="build.complete.impl">
Expand Down
2 changes: 1 addition & 1 deletion modules/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<packaging>jar</packaging>

<name>WebLaF-core</name>
<description>WebLaf core components</description>
<description>WebLaF core components</description>

<dependencies>
<dependency>
Expand Down
12 changes: 7 additions & 5 deletions modules/core/src/com/alee/utils/ImageUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -659,9 +659,6 @@ public static BufferedImage createColorImage ( final Color color, final int widt
* Creates color chooser icon
*/

public static final ImageIcon coloredChooserIcon = new ImageIcon ( ImageUtils.class.getResource ( "icons/color/color.png" ) );
public static final ImageIcon transparentChooserIcon = new ImageIcon ( ImageUtils.class.getResource ( "icons/color/transparent.png" ) );

public static ImageIcon createColorChooserIcon ( final Color color )
{
return new ImageIcon ( createColorChooserImage ( color ) );
Expand All @@ -671,16 +668,21 @@ public static BufferedImage createColorChooserImage ( final Color color )
{
final BufferedImage image = createCompatibleImage ( 16, 16, Transparency.TRANSLUCENT );
final Graphics2D g2d = image.createGraphics ();

if ( color == null || color.getAlpha () < 255 )
{
g2d.drawImage ( transparentChooserIcon.getImage (), 0, 0, null );
final ImageIcon transparentIcon = getImageIcon ( ImageUtils.class.getResource ( "icons/color/transparent.png" ) );
g2d.drawImage ( transparentIcon.getImage (), 0, 0, null );
}
if ( color != null )
{
g2d.setPaint ( color );
g2d.fillRect ( 2, 2, 13, 12 );
}
g2d.drawImage ( coloredChooserIcon.getImage (), 0, 0, null );

final ImageIcon colorIcon = getImageIcon ( ImageUtils.class.getResource ( "icons/color/color.png" ) );
g2d.drawImage ( colorIcon.getImage (), 0, 0, null );

g2d.dispose ();
return image;
}
Expand Down
16 changes: 13 additions & 3 deletions modules/core/src/com/alee/utils/SystemUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ public static boolean isWindows ()
*
* @return true if current OS is mac, false otherwise
*/
@SuppressWarnings ( "StringEquality" )
@SuppressWarnings ("StringEquality")
public static boolean isMac ()
{
return shortOsName == MAC;
Expand All @@ -348,7 +348,7 @@ public static boolean isMac ()
*
* @return true if current OS is unix, false otherwise
*/
@SuppressWarnings ( "StringEquality" )
@SuppressWarnings ("StringEquality")
public static boolean isUnix ()
{
return shortOsName == UNIX;
Expand All @@ -359,7 +359,7 @@ public static boolean isUnix ()
*
* @return true if current OS is solaris, false otherwise
*/
@SuppressWarnings ( "StringEquality" )
@SuppressWarnings ("StringEquality")
public static boolean isSolaris ()
{
return shortOsName == SOLARIS;
Expand Down Expand Up @@ -494,6 +494,16 @@ public static GraphicsEnvironment getGraphicsEnvironment ()
return GraphicsEnvironment.getLocalGraphicsEnvironment ();
}

/**
* Returns whether or not a display, keyboard, and mouse can be supported in this environment.
*
* @return {@code true} if display, keyboard, and mouse can be supported in this environment, {@code false} otherwise
*/
public static boolean isHeadlessEnvironment ()
{
return GraphicsEnvironment.isHeadless ();
}

/**
* Returns default screen device.
*
Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/com/alee/utils/ZipUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public static String getZipEntryFileLocation ( final ZipEntry zipEntry )
*
* @param in data input stream
* @param out data output stream
* @throws IOException
* @throws IOException when any IO exceptions occurs
*/
private static void copyInputStream ( final InputStream in, final OutputStream out ) throws IOException
{
Expand Down
2 changes: 1 addition & 1 deletion modules/demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<packaging>jar</packaging>

<name>WebLaF-demo</name>
<description>Executable WebLaf demo</description>
<description>Executable WebLaF demo</description>

<dependencies>
<dependency>
Expand Down
38 changes: 38 additions & 0 deletions modules/plugin/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<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/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.weblookandfeel</groupId>
<artifactId>weblaf-parent</artifactId>
<version>1.2.9-SNAPSHOT</version>
<relativePath>../../</relativePath>
</parent>

<artifactId>weblaf-plugin</artifactId>
<packaging>jar</packaging>

<name>WebLaF-plugin</name>
<description>WebLaF plugin manager</description>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>weblaf-core</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
<sourceDirectory>${basedir}/src</sourceDirectory>
<resources>
<resource>
<filtering>false</filtering>
<directory>${basedir}/src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import com.alee.managers.log.Log;
import com.alee.managers.plugin.data.*;
import com.alee.utils.SystemUtils;

import javax.swing.*;
import java.util.List;
Expand Down Expand Up @@ -111,7 +112,7 @@ public PluginInformation getPluginInformation ()
*/
public ImageIcon getPluginLogo ()
{
return detectedPlugin != null ? detectedPlugin.getLogo () : null;
return !SystemUtils.isHeadlessEnvironment () && detectedPlugin != null ? detectedPlugin.getLogo () : null;
}

/**
Expand Down
Loading

0 comments on commit 3ad2bd2

Please sign in to comment.