-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Andreas Reichel <[email protected]>
- Loading branch information
1 parent
5142a51
commit e7bc122
Showing
3 changed files
with
124 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<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> | ||
|
||
<!-- Define the project's coordinates --> | ||
<groupId>com.manticore-projects.tools</groupId> | ||
<artifactId>H2MigrationTool</artifactId> | ||
<version>1.4.0</version> | ||
|
||
<!-- Define project properties --> | ||
<properties> | ||
<maven.compiler.source>11</maven.compiler.source> | ||
<maven.compiler.target>11</maven.compiler.target> | ||
</properties> | ||
|
||
<!-- Define the project's dependencies (if any) --> | ||
<dependencies> | ||
<!-- https://mvnrepository.com/artifact/commons-io/commons-io --> | ||
<dependency> | ||
<groupId>commons-io</groupId> | ||
<artifactId>commons-io</artifactId> | ||
<version>2.15.1</version> | ||
</dependency> | ||
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 --> | ||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-lang3</artifactId> | ||
<version>3.14.0</version> | ||
</dependency> | ||
<!-- https://mvnrepository.com/artifact/commons-cli/commons-cli --> | ||
<dependency> | ||
<groupId>commons-cli</groupId> | ||
<artifactId>commons-cli</artifactId> | ||
<version>1.6.0</version> | ||
</dependency> | ||
|
||
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api --> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<version>5.8.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<!-- https://mvnrepository.com/artifact/com.h2database/h2 --> | ||
<dependency> | ||
<groupId>com.h2database</groupId> | ||
<artifactId>h2</artifactId> | ||
<version>2.2.222</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<!-- Define the project's build configuration --> | ||
<build> | ||
<!-- Define the source and resource directories --> | ||
<sourceDirectory>src/main/java</sourceDirectory> | ||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
</resource> | ||
</resources> | ||
|
||
<!-- Define the plugins used in the build process --> | ||
<plugins> | ||
<!-- Define the Maven Compiler Plugin --> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.8.1</version> | ||
<configuration> | ||
<source>11</source> | ||
<target>11</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>3.2.4</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
<configuration> | ||
<transformers> | ||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> | ||
<mainClass>com.manticore.h2.H2MigrationTool</mainClass> | ||
</transformer> | ||
</transformers> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
|
||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,6 @@ | |
package com.manticore.h2; | ||
|
||
import com.manticore.h2.H2MigrationTool.ScriptResult; | ||
import org.webswing.toolkit.api.WebswingUtil; | ||
|
||
import javax.swing.*; | ||
import javax.swing.border.EmptyBorder; | ||
|
@@ -27,6 +26,8 @@ | |
import java.beans.PropertyChangeListener; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.lang.reflect.InvocationTargetException; | ||
import java.lang.reflect.Method; | ||
import java.nio.file.Path; | ||
import java.sql.Connection; | ||
import java.sql.Driver; | ||
|
@@ -48,7 +49,6 @@ | |
* @author Andreas Reichel <[email protected]> | ||
*/ | ||
public class H2MigrationUI extends JFrame { | ||
|
||
public static final ImageIcon LIST_ADD_ICON = | ||
new ImageIcon( | ||
ClassLoader.getSystemResource("com/manticore/icons/16/list-add.png"), | ||
|
@@ -89,6 +89,22 @@ public class H2MigrationUI extends JFrame { | |
ClassLoader.getSystemResource("com/manticore/icons/64/dialog-question.png"), | ||
"Dialog Question."); | ||
private static final Logger LOGGER = Logger.getLogger(H2MigrationUI.class.getName()); | ||
|
||
private static boolean isWebSwing() { | ||
try { | ||
Class<?> clazz = H2MigrationUI.class.getClassLoader().loadClass("org.webswing.toolkit.api.WebswingUtil"); | ||
Method method =clazz.getMethod("isWebswing"); | ||
return (boolean) method.invoke(null); | ||
} catch (ClassNotFoundException ex) { | ||
LOGGER.log(Level.FINE, "Could not load the WebswingUtil", ex); | ||
} catch (NoSuchMethodException |InvocationTargetException | IllegalAccessException ex) { | ||
LOGGER.log(Level.FINE, "Failed to call the WebswingUtil.isWebswing() method", ex); | ||
} | ||
return false; | ||
} | ||
|
||
private final static boolean IS_WEBSWING = isWebSwing(); | ||
|
||
private static final Font MONOSPACED_FONT = new Font(Font.MONOSPACED, Font.PLAIN, 10); | ||
private final DefaultListModel<File> databaseFileModel = new DefaultListModel<>(); | ||
private final JList<File> databaseFileList = new JList<>(databaseFileModel); | ||
|
@@ -176,7 +192,7 @@ protected void process(List<Entry<File, String>> entries) { | |
|
||
if (Desktop.isDesktopSupported()) { | ||
Desktop desktop = Desktop.getDesktop(); | ||
if (WebswingUtil.isWebswing() | ||
if (IS_WEBSWING | ||
&& desktop | ||
.isSupported(Desktop.Action.OPEN)) { | ||
try { | ||
|
@@ -381,7 +397,7 @@ protected void process(List<Entry<File, String>> entries) { | |
|
||
if (Desktop.isDesktopSupported()) { | ||
Desktop desktop = Desktop.getDesktop(); | ||
if (WebswingUtil.isWebswing() | ||
if (IS_WEBSWING | ||
&& desktop | ||
.isSupported(Desktop.Action.OPEN)) { | ||
try { | ||
|
@@ -1148,7 +1164,7 @@ public void windowClosed(WindowEvent e) { | |
pack(); | ||
setMinimumSize(getSize()); | ||
|
||
if (WebswingUtil.isWebswing()) { | ||
if (IS_WEBSWING) { | ||
setExtendedState(MAXIMIZED_BOTH); | ||
} | ||
|
||
|