Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Jessica Hawkwell
/
lang-toolkit
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
2
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit b55921a7
authored
Jul 06, 2017
by
Jessica Hawkwell
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev-desktop' into 'master'
Dev desktop Closes
#1
and
#3
See merge request
!2
2 parents
fca8b3a4
75d33d19
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
1206 additions
and
58 deletions
apps/bootstrap/pom.xml
apps/bootstrap/src/main/java/me/felinewith/lang_toolkit/apps/bootstrap/Bootstrap.java
apps/bootstrap/src/main/java/me/felinewith/lang_toolkit/apps/bootstrap/BootstrapApp.java
apps/bootstrap/src/main/java/me/felinewith/lang_toolkit/apps/bootstrap/BootstrapClassLoader.java
apps/bootstrap/src/main/java/me/felinewith/lang_toolkit/apps/bootstrap/IStrappedApp.java
apps/bootstrap/src/main/java/me/felinewith/lang_toolkit/apps/bootstrap/util/LoaderHelper.java
apps/bootstrap/src/main/java/me/felinewith/lang_toolkit/apps/bootstrap/util/Log4jConfig.java
apps/bootstrap/src/main/java/me/felinewith/lang_toolkit/apps/bootstrap/util/MavenArtifact.java
apps/langbuilder/pom.xml
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/LangBuilder.java
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/actions/ActionAccept.java
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/actions/ActionHandle.java
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/actions/ActionSource.java
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/actions/ActionTypes.java
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/actions/ListenAttach.java
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/actions/UnifiedListener.java
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/actions/UnifiedRepeater.java
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/util/ConfigHelper.java
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/util/DesktopMenu.java
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/window/WindowUnifiedListener.java
pom.xml
run.sh
apps/bootstrap/pom.xml
View file @
b55921a
<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>
<groupId>
me.felinewith.lang
_
toolkit.apps
</groupId>
<groupId>
me.felinewith.lang
-
toolkit.apps
</groupId>
<artifactId>
bootstrap
</artifactId>
<packaging>
jar
</packaging>
<name>
Bootstrap
</name>
...
...
@@ -16,6 +16,17 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
<relativePath>
../..
</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>
org.apache.logging.log4j
</groupId>
<artifactId>
log4j-api
</artifactId>
</dependency>
<dependency>
<groupId>
org.apache.logging.log4j
</groupId>
<artifactId>
log4j-core
</artifactId>
</dependency>
</dependencies>
<build>
<resources>
<resource>
...
...
apps/bootstrap/src/main/java/me/felinewith/lang_toolkit/apps/bootstrap/Bootstrap.java
View file @
b55921a
...
...
@@ -25,9 +25,20 @@ import me.felinewith.lang_toolkit.apps.bootstrap.util.MavenArtifact;
* @author jlhawkwell
*/
public
class
Bootstrap
{
private
static
String
PROPERTIES
=
"META-INF/maven/me.felinewith.lang_toolkit.apps/bootstrap/pom.properties"
;
private
static
String
PROPERTIES
=
"META-INF/maven/me.felinewith.lang-toolkit.apps/bootstrap/pom.properties"
;
private
static
String
SETTINGS
;
private
static
Logger
log
;
public
static
void
main
(
String
[]
args
)
throws
IOException
{
StringBuilder
sb
=
new
StringBuilder
(
System
.
getProperty
(
"user.home"
));
sb
.
append
(
"/.local/share/lang-toolkit/"
);
SETTINGS
=
sb
.
toString
();
log
=
Logger
.
getGlobal
();
File
folder
=
new
File
(
SETTINGS
);
if
(
!
folder
.
exists
()
)
{
folder
.
mkdirs
();
}
boolean
mvn
=
false
;
try
{
mvn
=
check_maven
();
}
catch
(
IOException
|
InterruptedException
ex
)
{
}
...
...
@@ -38,21 +49,16 @@ public class Bootstrap {
}
File
mavenFile
;
if
(
System
.
getProperty
(
"os.name"
).
equals
(
"Windows"
)
)
{
mavenFile
=
new
File
(
"./maven/bin/mvn.cmd"
);
}
else
{
mavenFile
=
new
File
(
"./maven/bin/mvn"
);
}
if
(
System
.
getProperty
(
"os.name"
).
equals
(
"Windows"
)
)
{
mavenFile
=
new
File
(
SETTINGS
.
concat
(
"maven/bin/mvn.cmd"
));
}
else
{
mavenFile
=
new
File
(
SETTINGS
.
concat
(
"maven/bin/mvn"
));
}
mvn
=
mavenFile
.
exists
();
StringBuilder
sb
=
new
StringBuilder
(
System
.
getProperty
(
"user.home"
));
sb
.
append
(
"/.local/share/lang-toolkit/"
);
File
folder
=
new
File
(
sb
.
toString
());
if
(
!
folder
.
exists
()
)
{
folder
.
mkdirs
();
}
boolean
installed
=
false
;
try
{
installed
=
checkProperties
(
sb
.
toString
()
);
}
try
{
installed
=
checkProperties
();
}
catch
(
IOException
ex
)
{
}
File
pomFile
=
new
File
(
sb
.
toString
()
.
concat
(
"pom.xml"
));
File
pomFile
=
new
File
(
SETTINGS
.
concat
(
"pom.xml"
));
MavenArtifact
[]
deps
;
ClassLoader
cl
=
Bootstrap
.
class
.
getClassLoader
();
...
...
@@ -77,7 +83,7 @@ public class Bootstrap {
for
(
MavenArtifact
ma
:
deps
)
{
test
=
new
File
(
ma
.
getFileLocation
());
if
(
test
.
exists
()
)
{
if
(
!
test
.
exists
()
)
{
try
{
exec
(
folder
,
command
.
toString
().
concat
(
ma
.
getLocation
()));
}
catch
(
InterruptedException
ex
)
{
}
}
...
...
@@ -102,11 +108,11 @@ public class Bootstrap {
}
private
static
boolean
check_maven
()
throws
IOException
,
InterruptedException
{
File
mvn_folder
=
new
File
(
"./maven/"
);
File
mvn_folder
=
new
File
(
SETTINGS
.
concat
(
"maven/"
)
);
File
test
;
if
(
mvn_folder
.
exists
()
)
{
test
=
new
File
(
"./maven/bin/mvn"
);
test
=
new
File
(
SETTINGS
.
concat
(
"maven/bin/mvn"
)
);
return
test
.
exists
();
}
else
{
...
...
@@ -123,7 +129,7 @@ public class Bootstrap {
pt
=
ze
.
getName
().
replaceFirst
(
"[^/]+"
,
""
);
f
=
new
File
(
mvn_folder
.
getCanonicalPath
().
concat
(
pt
));
System
.
out
.
println
(
pt
);
log
.
info
(
pt
);
if
(
ze
.
isDirectory
()
)
{
f
.
mkdirs
();
}
...
...
@@ -166,12 +172,12 @@ public class Bootstrap {
output
.
close
();
}
private
static
boolean
checkProperties
(
String
folder
)
throws
FileNotFoundException
,
IOException
{
private
static
boolean
checkProperties
()
throws
FileNotFoundException
,
IOException
{
Properties
pomProps
=
new
Properties
();
pomProps
.
load
(
Bootstrap
.
class
.
getClassLoader
().
getResourceAsStream
(
PROPERTIES
));
Properties
pomTest
=
new
Properties
();
File
test
=
new
File
(
folder
.
concat
(
"pom.properties"
));
File
test
=
new
File
(
SETTINGS
.
concat
(
"pom.properties"
));
if
(
test
.
exists
()
)
{
pomTest
.
load
(
new
FileInputStream
(
test
));
}
else
{
return
false
;
}
...
...
@@ -245,8 +251,7 @@ public class Bootstrap {
}
private
static
void
exec
(
File
pwd
,
String
command
)
throws
IOException
,
InterruptedException
{
System
.
out
.
print
(
"[shell]\t"
);
System
.
out
.
println
(
command
);
log
.
info
(
"[shell]\t"
.
concat
(
command
));
ProcessBuilder
pb
=
new
ProcessBuilder
();
//pb.inheritIO();
...
...
@@ -260,7 +265,7 @@ public class Bootstrap {
Thread
t
=
new
Thread
()
{
@Override@SuppressWarnings
(
"unchecked"
)
public
void
run
()
{
System
.
out
.
println
(
"Booting..."
);
log
.
info
(
"Booting..."
);
Class
<?>
cls
=
null
;
try
{
cls
=
bcl
.
loadClass
(
"me.felinewith.lang_toolkit.apps.bootstrap.BootstrapApp"
);
}
catch
(
ClassNotFoundException
ex
)
{
...
...
apps/bootstrap/src/main/java/me/felinewith/lang_toolkit/apps/bootstrap/BootstrapApp.java
View file @
b55921a
...
...
@@ -3,9 +3,12 @@ package me.felinewith.lang_toolkit.apps.bootstrap;
import
java.io.IOException
;
import
java.net.URL
;
import
java.util.Enumeration
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.Properties
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
me.felinewith.lang_toolkit.apps.bootstrap.util.LoaderHelper
;
/**
*
...
...
@@ -15,33 +18,90 @@ public class BootstrapApp {
private
ClassLoader
cl
;
String
[]
args
;
static
Logger
log
;
public
static
void
init
(
String
[]
args
)
{
log
=
LogManager
.
getLogger
();
ClassLoader
cl
=
BootstrapApp
.
class
.
getClassLoader
();
log
.
info
(
"ClassLoader: "
.
concat
(
cl
.
getClass
().
getCanonicalName
()));
// fetch all available bootstrap descriptors
Enumeration
<
URL
>
urls
=
null
;
try
{
urls
=
cl
.
getResources
(
"bootstrap/bootstrap.properties"
);
}
catch
(
IOException
ex
)
{
Logger
.
getLogger
(
BootstrapApp
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
catch
(
IOException
ex
)
{
log
.
fatal
(
ex
.
getMessage
()
,
ex
);
}
Properties
props
=
new
Properties
();
URL
u
;
if
(
urls
!=
null
)
{
// load up all the descriptors
while
(
urls
.
hasMoreElements
()
)
{
u
=
urls
.
nextElement
();
try
{
props
.
load
(
u
.
openStream
());
}
catch
(
IOException
ex
)
{
Logger
.
getLogger
(
BootstrapApp
.
class
.
getName
()).
log
(
Level
.
WARNING
,
null
,
ex
);
log
.
warn
(
ex
.
getMessage
()
,
ex
);
}
}
// TODO: initialize app then iterate plugins
}
}
LoaderHelper
<
IStrappedApp
>
appHelper
=
new
LoaderHelper
<>(
cl
,
IStrappedApp
.
class
);
LoaderHelper
<
IStrappedPlugin
>
plugHelper
=
new
LoaderHelper
<>(
cl
,
IStrappedPlugin
.
class
);
public
BootstrapApp
(
ClassLoader
classloader
,
String
[]
arguments
)
{
cl
=
classloader
;
args
=
arguments
;
}
IStrappedApp
app
=
null
;
IStrappedPlugin
plug
=
null
;
HashMap
<
String
,
IStrappedPlugin
>
plugins
=
new
HashMap
<>();
// get the app
if
(
props
.
containsKey
(
"app"
)
)
{
try
{
app
=
appHelper
.
fetchClass
(
props
.
getProperty
(
"app"
));
}
catch
(
ClassNotFoundException
|
InstantiationException
|
IllegalAccessException
ex
)
{
log
.
fatal
(
ex
.
getMessage
(),
ex
);
return
;
}
}
else
{
log
.
fatal
(
"Class not found."
,
new
NoClassDefFoundError
(
"Application did not provide an application class."
));
return
;
}
if
(
app
==
null
)
{
log
.
fatal
(
"Can not load!"
,
new
ClassNotFoundException
(
"Application class could not be loaded."
));
return
;
}
// run through plugins
Iterator
<
String
>
it
=
props
.
stringPropertyNames
().
iterator
();
String
name
;
while
(
it
.
hasNext
()
)
{
name
=
it
.
next
();
if
(
!
name
.
equals
(
"app"
)
)
{
try
{
plug
=
plugHelper
.
fetchClass
(
props
.
getProperty
(
name
));
}
catch
(
ClassNotFoundException
|
InstantiationException
|
IllegalAccessException
ex
)
{
log
.
warn
(
ex
.
getMessage
(),
ex
);
}
if
(
plug
!=
null
)
{
plugins
.
put
(
plug
.
getName
(),
plug
);
}
plug
=
null
;
}
}
// start it up
app
.
preStart
(
args
);
// check plugins
if
(
!
plugins
.
isEmpty
()
)
{
// register all the plugins
Iterator
<
IStrappedPlugin
>
itp
=
plugins
.
values
().
iterator
();
while
(
itp
.
hasNext
()
)
{
plug
=
itp
.
next
();
app
.
registerPlugin
(
plug
);
}
}
// readySetGO!
app
.
start
();
}
}
}
apps/bootstrap/src/main/java/me/felinewith/lang_toolkit/apps/bootstrap/BootstrapClassLoader.java
View file @
b55921a
...
...
@@ -60,6 +60,8 @@ public class BootstrapClassLoader extends ClassLoader
*/
private
final
ClassLoader
parent
;
private
Logger
log
;
/**
* Constructor.
*/
...
...
@@ -71,6 +73,7 @@ public class BootstrapClassLoader extends ClassLoader
pkgs
=
new
HashMap
<>();
clss
=
new
HashMap
<>();
maps
=
new
HashMap
<>();
log
=
Logger
.
getGlobal
();
}
/**
...
...
@@ -85,6 +88,7 @@ public class BootstrapClassLoader extends ClassLoader
pkgs
=
new
HashMap
<>();
clss
=
new
HashMap
<>();
maps
=
new
HashMap
<>();
log
=
Logger
.
getGlobal
();
}
/** Initialize this ClassLoader.
...
...
@@ -92,7 +96,7 @@ public class BootstrapClassLoader extends ClassLoader
public
void
init
()
{
Iterator
<
String
>
paths
;
paths
=
cpDirs
(
System
.
getProperty
(
"java.class.path"
));
paths
=
cpDirs
(
System
.
getProperty
(
"java.class.path"
)
.
concat
(
" ./libs"
)
);
File
f
;
String
s
;
...
...
@@ -134,6 +138,11 @@ public class BootstrapClassLoader extends ClassLoader
Iterator
<
File
>
it
;
File
f
;
// FAST failure for certain groups
String
[]
fail
=
{
"java/"
,
"javax/"
,
"com/sun"
,
"sun/"
,
"jdk/"
};
for
(
String
s
:
fail
)
{
if
(
path
.
startsWith
(
s
)
)
{
return
null
;
}
}
// FAST search
if
(
!
maps
.
isEmpty
()
)
{
...
...
@@ -150,7 +159,7 @@ public class BootstrapClassLoader extends ClassLoader
// slow search
if
(
!
jars
.
isEmpty
()
)
{
System
.
err
.
println
(
"
Warning:
Slow search: "
.
concat
(
path
));
System
.
err
.
println
(
"
[WARNING]
Slow search: "
.
concat
(
path
));
it
=
jars
.
values
().
iterator
();
while
(
it
.
hasNext
()
)
{
...
...
@@ -165,7 +174,7 @@ public class BootstrapClassLoader extends ClassLoader
File
t
;
if
(
!
flds
.
isEmpty
()
)
{
System
.
err
.
println
(
"
Warning:
Slow search: "
.
concat
(
path
));
System
.
err
.
println
(
"
[WARNING]
Slow search: "
.
concat
(
path
));
it
=
flds
.
values
().
iterator
();
while
(
it
.
hasNext
()
)
{
...
...
@@ -198,15 +207,17 @@ public class BootstrapClassLoader extends ClassLoader
Iterator
<
File
>
it
=
jars
.
values
().
iterator
();
File
f
;
JarFile
jf
;
ZipEntry
z
e
;
JarEntry
j
e
;
while
(
it
.
hasNext
()
)
{
f
=
it
.
next
();
jf
=
new
JarFile
(
f
);
ze
=
jf
.
getEntry
(
name
);
je
=
jf
.
getJarEntry
(
name
);
if
(
je
!=
null
)
{
ar
.
add
(
new
URL
(
"jar:file:"
.
concat
(
f
.
getCanonicalPath
()).
concat
(
"!/"
).
concat
(
name
)));
}
jf
.
close
();
if
(
ze
!=
null
)
{
ar
.
add
(
new
URL
(
"jar:file:"
.
concat
(
f
.
getCanonicalPath
()).
concat
(
"!/"
).
concat
(
name
)));
}
}
return
new
Iterator2Enum
<>(
ar
.
iterator
());
...
...
@@ -229,7 +240,7 @@ public class BootstrapClassLoader extends ClassLoader
else
{
try
{
return
loadClassWorker
(
name
,
resolve
,
is
);
}
catch
(
IOException
ex
)
{
throw
new
ClassNotFoundException
(
"Couln't load "
.
concat
(
name
));
}
catch
(
IOException
ex
)
{
throw
new
ClassNotFoundException
(
"Coul
d
n't load "
.
concat
(
name
));
}
}
return
cls
;
...
...
@@ -324,7 +335,7 @@ public class BootstrapClassLoader extends ClassLoader
if
(
mf
.
getMainAttributes
().
containsKey
(
Name
.
CLASS_PATH
)
)
{
addClassPath
(
mf
.
getMainAttributes
().
getValue
(
Name
.
CLASS_PATH
));
}
addDirHelper
(
dir
,
null
,
""
,
mf
);
System
.
out
.
println
(
"Added Dir "
.
concat
(
pt
));
log
.
info
(
"Added Dir "
.
concat
(
pt
));
}
catch
(
IOException
x
)
{}
}
...
...
@@ -389,7 +400,7 @@ public class BootstrapClassLoader extends ClassLoader
defPkg
(
tp
,
jf
.
getName
(),
msf
,
je
.
getAttributes
());
}
}
System
.
out
.
println
(
"Added Jar "
.
concat
(
pt
));
log
.
info
(
"Added Jar "
.
concat
(
pt
));
}
catch
(
IOException
x
)
{}
}
...
...
apps/bootstrap/src/main/java/me/felinewith/lang_toolkit/apps/bootstrap/IStrappedApp.java
View file @
b55921a
...
...
@@ -5,7 +5,7 @@ package me.felinewith.lang_toolkit.apps.bootstrap;
* @author jlhawkwell
*/
public
interface
IStrappedApp
{
public
void
preStart
();
public
void
preStart
(
String
[]
args
);
public
void
registerPlugin
(
IStrappedPlugin
plugin
);
public
void
start
();
}
apps/bootstrap/src/main/java/me/felinewith/lang_toolkit/apps/bootstrap/util/LoaderHelper.java
0 → 100644
View file @
b55921a
package
me
.
felinewith
.
lang_toolkit
.
apps
.
bootstrap
.
util
;
/**
*
* @author jlhawkwell
*/
public
class
LoaderHelper
<
T
>
{
ClassLoader
cl
;
Class
<
T
>
t
;
public
LoaderHelper
(
ClassLoader
classLoader
,
Class
<
T
>
test
)
{
cl
=
classLoader
;
t
=
test
;
}
public
T
fetchClass
(
String
className
)
throws
ClassNotFoundException
,
InstantiationException
,
IllegalAccessException
{
Class
<?>
clz
=
null
;
Object
o
=
null
;
clz
=
cl
.
loadClass
(
className
);
if
(
clz
==
null
)
{
return
null
;
}
o
=
clz
.
newInstance
();
if
(
o
==
null
)
{
return
null
;
}
if
(
!
t
.
isInstance
(
o
)
)
{
throw
new
ClassCastException
(
"Discovered class does not match type"
);
}
return
t
.
cast
(
o
);
}
}
apps/bootstrap/src/main/java/me/felinewith/lang_toolkit/apps/bootstrap/util/Log4jConfig.java
0 → 100644
View file @
b55921a
package
me
.
felinewith
.
lang_toolkit
.
apps
.
bootstrap
.
util
;
import
java.net.URI
;
import
org.apache.logging.log4j.Level
;
import
org.apache.logging.log4j.core.Filter
;
import
org.apache.logging.log4j.core.LoggerContext
;
import
org.apache.logging.log4j.core.appender.ConsoleAppender
;
import
org.apache.logging.log4j.core.config.Configuration
;
import
org.apache.logging.log4j.core.config.ConfigurationFactory
;
import
org.apache.logging.log4j.core.config.ConfigurationSource
;
import
org.apache.logging.log4j.core.config.Order
;
import
org.apache.logging.log4j.core.config.builder.api.AppenderComponentBuilder
;
import
org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilder
;
import
org.apache.logging.log4j.core.config.builder.impl.BuiltConfiguration
;
import
org.apache.logging.log4j.core.config.plugins.Plugin
;
/**
*
* @author jlhawkwell
*/
@Plugin
(
name
=
"CustomConfigurationFactory"
,
category
=
ConfigurationFactory
.
CATEGORY
)
@Order
(
50
)
public
class
Log4jConfig
extends
ConfigurationFactory
{
public
static
Configuration
createConfiguration
(
final
String
name
,
ConfigurationBuilder
<
BuiltConfiguration
>
builder
)
{
builder
.
setConfigurationName
(
name
);
builder
.
setStatusLevel
(
Level
.
DEBUG
);
builder
.
add
(
builder
.
newFilter
(
"ThresholdFilter"
,
Filter
.
Result
.
ACCEPT
,
Filter
.
Result
.
NEUTRAL
).
addAttribute
(
"level"
,
Level
.
DEBUG
));
AppenderComponentBuilder
appenderBuilder
=
builder
.
newAppender
(
"Stdout"
,
"CONSOLE"
).
addAttribute
(
"target"
,
ConsoleAppender
.
Target
.
SYSTEM_OUT
);
appenderBuilder
.
add
(
builder
.
newLayout
(
"PatternLayout"
).
addAttribute
(
"pattern"
,
"%d{UNIX_MILLIS} [%style{%t}{cyan}/%style{%c{1}}{yellow}] %highlight{%-5level}: %msg%n%throwable"
));
appenderBuilder
.
add
(
builder
.
newFilter
(
"MarkerFilter"
,
Filter
.
Result
.
DENY
,
Filter
.
Result
.
NEUTRAL
).
addAttribute
(
"marker"
,
"FLOW"
));
builder
.
add
(
appenderBuilder
);
builder
.
add
(
builder
.
newLogger
(
"org.apache.logging.log4j"
,
Level
.
DEBUG
).
add
(
builder
.
newAppenderRef
(
"Stdout"
)).
addAttribute
(
"additivity"
,
false
));
builder
.
add
(
builder
.
newRootLogger
(
Level
.
ERROR
).
add
(
builder
.
newAppenderRef
(
"Stdout"
)));
return
builder
.
build
();
}
@Override
protected
String
[]
getSupportedTypes
()
{
return
new
String
[]{
"*"
};
}
@Override
public
Configuration
getConfiguration
(
LoggerContext
lc
,
ConfigurationSource
cs
)
{
return
getConfiguration
(
lc
,
cs
.
toString
(),
null
);
}
@Override
public
Configuration
getConfiguration
(
LoggerContext
loggerContext
,
String
name
,
URI
configLocation
)
{
ConfigurationBuilder
<
BuiltConfiguration
>
builder
=
newConfigurationBuilder
();
return
createConfiguration
(
name
,
builder
);
}
}
apps/bootstrap/src/main/java/me/felinewith/lang_toolkit/apps/bootstrap/util/MavenArtifact.java
View file @
b55921a
...
...
@@ -66,7 +66,7 @@ public class MavenArtifact {
StringBuilder
sb
=
new
StringBuilder
(
System
.
getProperty
(
"user.home"
));
sb
.
append
(
"/.m2/repository/"
);
sb
.
append
(
g
.
replaceAll
(
"."
,
"/"
));
sb
.
append
(
g
.
replaceAll
(
"
\\
."
,
"/"
));
sb
.
append
(
"/"
);
sb
.
append
(
a
);
sb
.
append
(
"/"
);
...
...
apps/langbuilder/pom.xml
View file @
b55921a
<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>
<groupId>
me.felinewith.lang
_
toolkit.apps
</groupId>
<groupId>
me.felinewith.lang
-
toolkit.apps
</groupId>
<artifactId>
langbuilder
</artifactId>
<packaging>
jar
</packaging>
<name>
LangBuilder
</name>
...
...
@@ -18,7 +18,19 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
<dependencies>
<dependency>
<groupId>
me.felinewith.lang_toolkit.apps
</groupId>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-configuration2
</artifactId>
</dependency>
<dependency>
<groupId>
org.apache.logging.log4j
</groupId>
<artifactId>
log4j-core
</artifactId>
</dependency>
<dependency>
<groupId>
org.freedesktop.tango
</groupId>
<artifactId>
tango-icon-theme
</artifactId>
</dependency>
<dependency>
<groupId>
me.felinewith.lang-toolkit.apps
</groupId>
<artifactId>
bootstrap
</artifactId>
</dependency>
</dependencies>
...
...
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/LangBuilder.java
View file @
b55921a
package
me
.
felinewith
.
lang_toolkit
.
apps
.
langbuilder
;
import
java.awt.BorderLayout
;
import
java.awt.Component
;
import
java.awt.Dimension
;
import
java.awt.DisplayMode
;
import
java.awt.GraphicsDevice
;
import
java.awt.GraphicsEnvironment
;
import
java.awt.Point
;
import
java.io.File
;
import
java.net.URL
;
import
java.util.HashMap
;
import
javax.swing.ImageIcon
;
import
javax.swing.JDesktopPane
;
import
javax.swing.JFrame
;
import
javax.swing.JScrollPane
;
import
javax.swing.JSplitPane
;
import
javax.swing.JTabbedPane
;
import
javax.swing.JToolBar
;
import
javax.swing.JTree
;
import
javax.swing.UIManager
;
import
javax.swing.UnsupportedLookAndFeelException
;
import
me.felinewith.lang_toolkit.apps.bootstrap.IStrappedApp
;
import
me.felinewith.lang_toolkit.apps.bootstrap.IStrappedPlugin
;
import
me.felinewith.lang_toolkit.apps.langbuilder.actions.ListenAttach
;
import
me.felinewith.lang_toolkit.apps.langbuilder.util.ConfigHelper
;
import
me.felinewith.lang_toolkit.apps.langbuilder.util.DesktopMenu
;
import
me.felinewith.lang_toolkit.apps.langbuilder.window.WindowUnifiedListener
;
import
org.apache.commons.configuration2.Configuration
;
import
org.apache.commons.configuration2.XMLConfiguration
;
import
org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder
;
import
org.apache.commons.configuration2.builder.fluent.Parameters
;
import
org.apache.commons.configuration2.ex.ConfigurationException
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
/**
*
...
...
@@ -11,20 +40,180 @@ import me.felinewith.lang_toolkit.apps.bootstrap.IStrappedPlugin;
*/
public
class
LangBuilder
implements
IStrappedApp
{
private
String
[]
args
;
private
HashMap
<
String
,
IStrappedPlugin
>
plugins
;
private
JFrame
window
;
@Override
public
void
preStart
()
{
private
JFrame
jFrame
;
private
JTabbedPane
jTabbedPane
;
private
JSplitPane
jSplitPane
;
private
JScrollPane
jScrollPane
;
private
JTree
jTree
;
private
JDesktopPane
jDesktopPane
;
private
Configuration
config
;
private
Logger
log
;
WindowUnifiedListener
unifiedListener
;
@Override
public
void
preStart
(
String
[]
argsStrings
)
{
args
=
argsStrings
;
log
=
LogManager
.
getLogger
();
try
{
UIManager
.
setLookAndFeel
(
UIManager
.
getCrossPlatformLookAndFeelClassName
());
}
catch
(
ClassNotFoundException
|
InstantiationException
|
IllegalAccessException
|
UnsupportedLookAndFeelException
ex
)
{
}
// configuration!
log
.
info
(
"[Desktop] Setting up configuration..."
);
StringBuilder
sb
=
new
StringBuilder
(
System
.
getProperty
(
"user.home"
));
sb
.
append
(
"/.local/share/lang-toolkit/config/desktop.xml"
);
File
f
=
new
File
(
sb
.
toString
());
if
(
!
f
.
getParentFile
().
exists
()
)
{
f
.
getParentFile
().
mkdirs
();
}
Parameters
params
=
new
Parameters
();
params
.
xml
().
setThrowExceptionOnMissing
(
false
);
params
.
xml
().
setFileName
(
sb
.
toString
());
params
.
xml
().
setEncoding
(
"UTF-8"
);
params
.
xml
().
setValidating
(
false
);
FileBasedConfigurationBuilder
<
XMLConfiguration
>
builder
=
new
FileBasedConfigurationBuilder
<>(
XMLConfiguration
.
class
);
builder
.
configure
(
params
.
xml
());
if
(
f
.
exists
()
)
{
if
(
!
builder
.
getFileHandler
().
isLocationDefined
()
)
{
builder
.
getFileHandler
().
setFileName
(
sb
.
toString
());
}
}
builder
.
getFileHandler
().
setEncoding
(
"UTF-8"
);
config
=
null
;
try
{
config
=
new
ConfigHelper
(
builder
.
getConfiguration
(),
builder
);
}
catch
(
ConfigurationException
ex
)
{
log
.
fatal
(
"Config setup FAILED!"
,
ex
);
}
if
(
!
f
.
exists
()
)
{
if
(
!
builder
.
getFileHandler
().
isLocationDefined
()
)
{
builder
.
getFileHandler
().
setFileName
(
sb
.
toString
());
}
}
log
.
info
(
"[Desktop] Setting up window..."
);
plugins
=
new
HashMap
<>();
window
=
new
JFrame
(
"LangBuilder"
);
// TODO: app settings, main window, toolbar menu
jFrame
=
new
JFrame
(
"LangBuilder"
);
jFrame
.
setLayout
(
new
BorderLayout
());
jFrame
.
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
unifiedListener
=
new
WindowUnifiedListener
(
jFrame
,
config
);
// TODO: toolbar menu
jTabbedPane
=
new
JTabbedPane
(
JTabbedPane
.
TOP
);
jTabbedPane
.
setTabLayoutPolicy
(
JTabbedPane
.
SCROLL_TAB_LAYOUT
);
JToolBar
toolBar
=
new
JToolBar
(
"LangBuilder Desktop"
,
JToolBar
.
HORIZONTAL
);
toolBar
.
setFloatable
(
false
);
DesktopMenu
tdm
=
new
DesktopMenu
(
toolBar
,
unifiedListener
);
tdm
.
addButton
(
"New"
,
"new"
,
null
,
"16x16/actions/document-new.png"
);
tdm
.
addButton
(
"Load"
,
"load"
,
null
,
"16x16/actions/document-open.png"
);
tdm
.
addButton
(
"Save"
,
"save"
,
null
,
"16x16/actions/document-save.png"
);
tdm
.
addButton
(
"Save As"
,
"saveas"
,
null
,
"16x16/actions/document-save-as.png"
);
tdm
.
addButton
(
"Exit"
,
"exit"
,
null
,
"16x16/actions/system-log-out.png"
);
URL
u
=
this
.
getClass
().
getResource
(
"/org/freedesktop/tango/16x16/places/user-desktop.png"
);
jTabbedPane
.
addTab
(
"LangBuilder Desktop"
,
new
ImageIcon
(
u
),
toolBar
);
jFrame
.
add
(
jTabbedPane
,
BorderLayout
.
PAGE_START
);
jSplitPane
=
new
JSplitPane
(
JSplitPane
.
HORIZONTAL_SPLIT
);
jSplitPane
.
setContinuousLayout
(
true
);
jTree
=
new
JTree
();
jScrollPane
=
new
JScrollPane
(
jTree
,
JScrollPane
.
VERTICAL_SCROLLBAR_ALWAYS
,
JScrollPane
.
HORIZONTAL_SCROLLBAR_AS_NEEDED
);
jDesktopPane
=
new
JDesktopPane
();
jSplitPane
.
setLeftComponent
(
jScrollPane
);
jSplitPane
.
setRightComponent
(
jDesktopPane
);
jFrame
.
add
(
jSplitPane
,
BorderLayout
.
CENTER
);
// set component names
jFrame
.
setName
(
"window"
);
jTabbedPane
.
setName
(
"window.menu"
);
jSplitPane
.
setName
(
"window.splitter"
);
jTree
.
setName
(
"window.tree"
);
jDesktopPane
.
setName
(
"window.desktop"
);
// configure the window
// set some sensible defaults
log
.
info
(
"[Desktop] Detecting screen sizes..."
);
GraphicsEnvironment
ge
=
GraphicsEnvironment
.
getLocalGraphicsEnvironment
();
DisplayMode
dm
;
int
sx
=
0
,
sy
=
0
;
int
bx
=
0
,
by
=
0
;
int
tx
,
ty
;
for
(
GraphicsDevice
gd
:
ge
.
getScreenDevices
()
)
{
dm
=
gd
.
getDisplayMode
();
tx
=
dm
.
getWidth
();
ty
=
dm
.
getHeight
();
// we want the SMALLEST display in a multi-display environment
if
(
(
tx
<
sx
)
||
(
sx
==
0
)
)
{
sx
=
tx
;
}
if
(
(
ty
<
sy
)
||
(
sy
==
0
)
)
{
sy
=
ty
;
}
// and here we want the BIGGEST
if
(
tx
>
bx
)
{
bx
=
tx
;
}
if
(
ty
>
by
)
{
by
=
ty
;
}
}
jFrame
.
setMinimumSize
(
new
Dimension
(
sx
/
2
,
sy
/
2
));
jFrame
.
setMaximumSize
(
new
Dimension
(
bx
,
by
));
jFrame
.
setPreferredSize
(
new
Dimension
(
config
.
getInt
(
"window.preferredSize.x"
,
sx
/
2
),
config
.
getInt
(
"window.preferredSize.y"
,
sy
/
2
)
)
);
jFrame
.
setLocation
(
new
Point
(
config
.
getInt
(
"window.location.x"
,
sx
/
8
),
config
.
getInt
(
"window.location.y"
,
sy
/
8
)
)
);
jSplitPane
.
setDividerLocation
(
config
.
getInt
(
"window.splitter.dividerLocation"
,
sx
/
8
));
Component
[]
comps
=
{
jFrame
,
jTabbedPane
,
jSplitPane
,
jTree
,
jDesktopPane
};
for
(
Component
c
:
comps
)
{
ListenAttach
.
attach
(
c
,
unifiedListener
,
"addWindowFocusListener"
);
}
/*jFrame.addWindowListener(unifiedListener);
jFrame.addWindowStateListener(unifiedListener);
jTabbedPane.addChangeListener(unifiedListener);
jFrame.addComponentListener(unifiedListener);
jTabbedPane.addComponentListener(unifiedListener);
jSplitPane.addComponentListener(unifiedListener);
jTree.addComponentListener(unifiedListener);
jDesktopPane.addComponentListener(unifiedListener);
jFrame.addPropertyChangeListener(unifiedListener);
jTabbedPane.addPropertyChangeListener(unifiedListener);
jSplitPane.addPropertyChangeListener(unifiedListener);
jTree.addPropertyChangeListener(unifiedListener);
jDesktopPane.addPropertyChangeListener(unifiedListener); // */
}
@Override
public
void
registerPlugin
(
IStrappedPlugin
plugin
)
{
}
@Override
public
void
start
()
{
jFrame
.
pack
();
jFrame
.
setVisible
(
true
);
}
}
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/actions/ActionAccept.java
0 → 100644
View file @
b55921a
package
me
.
felinewith
.
lang_toolkit
.
apps
.
langbuilder
.
actions
;
/**
*
* @author jlhawkwell
*/
public
abstract
class
ActionAccept
{
public
void
handleAction
(
ActionHandle
action
)
{
handleEvent
(
action
);
}
public
void
handleChange
(
ActionHandle
action
)
{
handleEvent
(
action
);
}
public
void
handleComponent
(
ActionHandle
action
)
{
handleEvent
(
action
);
}
public
void
handleProperty
(
ActionHandle
action
)
{
handleEvent
(
action
);
}
public
void
handleWindow
(
ActionHandle
action
)
{
handleEvent
(
action
);
}
public
abstract
void
handleEvent
(
ActionHandle
action
);
}
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/actions/ActionHandle.java
0 → 100644
View file @
b55921a
package
me
.
felinewith
.
lang_toolkit
.
apps
.
langbuilder
.
actions
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ComponentEvent
;
import
java.awt.event.WindowEvent
;
import
java.beans.PropertyChangeEvent
;
import
javax.swing.event.ChangeEvent
;
/**
*
* @author jlhawkwell
*/
public
class
ActionHandle
{
private
Object
source
;
private
String
name
;
private
int
intval
;
private
Object
obval
;
private
ActionSource
as
;
public
ActionHandle
(
ActionEvent
actionEvent
)
{
source
=
actionEvent
.
getSource
();
name
=
actionEvent
.
getActionCommand
();
intval
=
actionEvent
.
getModifiers
();
obval
=
source
;
as
=
ActionSource
.
EVENT_ACTION
;
}
public
ActionHandle
(
ChangeEvent
changeEvent
)
{
source
=
changeEvent
.
getSource
();
name
=
changeEvent
.
toString
();
intval
=
0
;
obval
=
source
;
as
=
ActionSource
.
EVENT_CHANGE
;
}
public
ActionHandle
(
ComponentEvent
componentEvent
)
{
source
=
componentEvent
.
getComponent
();
name
=
componentEvent
.
paramString
();
intval
=
componentEvent
.
getID
();
obval
=
source
;
as
=
ActionSource
.
EVENT_COMPONENT
;
}
public
ActionHandle
(
PropertyChangeEvent
propertyChangeEvent
)
{
source
=
propertyChangeEvent
.
getSource
();
name
=
propertyChangeEvent
.
getPropertyName
();
intval
=
0
;
obval
=
propertyChangeEvent
.
getNewValue
();
as
=
ActionSource
.
EVENT_PROPERTY
;
}
public
ActionHandle
(
WindowEvent
windowEvent
)
{
source
=
windowEvent
.
getWindow
();
name
=
windowEvent
.
paramString
();
intval
=
windowEvent
.
getID
();
obval
=
windowEvent
.
getOppositeWindow
();
as
=
ActionSource
.
EVENT_WINDOW
;
}
public
Object
getSource
()
{
return
source
;
}
public
String
getName
()
{
return
name
;
}
public
int
getIntValue
()
{
return
intval
;
}
public
Object
getObjectValue
()
{
return
obval
;
}
public
ActionSource
getActionSource
()
{
return
as
;
}
public
ActionTypes
getActionType
()
{
return
ActionTypes
.
valueOf
(
intval
);
}
}
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/actions/ActionSource.java
0 → 100644
View file @
b55921a
package
me
.
felinewith
.
lang_toolkit
.
apps
.
langbuilder
.
actions
;
/**
*
* @author jlhawkwell
*/
public
enum
ActionSource
{
EVENT_ACTION
(
true
,
true
,
true
,
false
),
EVENT_CHANGE
(
true
,
false
,
false
,
false
),
EVENT_COMPONENT
(
true
,
false
,
true
,
false
),
EVENT_PROPERTY
(
true
,
true
,
false
,
true
),
EVENT_WINDOW
(
true
,
true
,
true
,
true
);
private
boolean
source
;
private
boolean
name
;
private
boolean
intval
;
private
boolean
obval
;
private
ActionSource
(
boolean
source
,
boolean
name
,
boolean
intval
,
boolean
obval
)
{
this
.
source
=
source
;
this
.
name
=
name
;
this
.
intval
=
intval
;
this
.
obval
=
obval
;
}
public
boolean
getSource
()
{
return
source
;
}
public
boolean
getName
()
{
return
name
;
}
public
boolean
getIntValue
()
{
return
intval
;
}
public
boolean
getObjectValue
()
{
return
obval
;
}
}
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/actions/ActionTypes.java
0 → 100644
View file @
b55921a
package
me
.
felinewith
.
lang_toolkit
.
apps
.
langbuilder
.
actions
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ComponentEvent
;
import
java.awt.event.WindowEvent
;
/**
*
* @author jlhawkwell
*/
public
enum
ActionTypes
{
UNKNOWN
(-
1
),
// ActionEvent/ActionListener
ACTION_SHIFT
(
TypeAction
.
SHIFT
),
ACTION_CONTROL
(
TypeAction
.
CONTROL
),
ACTION_META
(
TypeAction
.
META
),
ACTION_ALT
(
TypeAction
.
ALT
),
// ChangeEvent/ChangeListener
CHANGE
(
0
),
// ComponentEvent/ComponentListener
COMPONENT_MOVED
(
TypeComponent
.
MOVED
),
// 100
COMPONENT_RESIZED
(
TypeComponent
.
RESIZED
),
// 101
COMPONENT_SHOWN
(
TypeComponent
.
SHOWN
),
// 102
COMPONENT_HIDDEN
(
TypeComponent
.
HIDDEN
),
// 103
// PropertyChangeEvent/PropertyChangeListener
PROPERTY
(
0
),
// WindowEvent/WindowAdapter
WINDOW_OPENED
(
TypeWindow
.
OPENED
),
//200
WINDOW_CLOSING
(
TypeWindow
.
CLOSING
),
// 201
WINDOW_CLOSED
(
TypeWindow
.
CLOSED
),
// 202
WINDOW_ICONIFIED
(
TypeWindow
.
ICONIFIED
),
//203
WINDOW_DEICONIFIED
(
TypeWindow
.
DEICONIFIED
),
// 204
WINDOW_ACTIVATED
(
TypeWindow
.
ACTIVATED
),
// 205
WINDOW_DEACTIVATED
(
TypeWindow
.
DEACTIVATED
),
// 206
WINDOW_GAINED_FOCUS
(
TypeWindow
.
GAINED_FOCUS
),
// 207
WINDOW_LOST_FOCUS
(
TypeWindow
.
LOST_FOCUS
),
// 208
WINDOW_STATE_CHANGED
(
TypeWindow
.
STATE_CHANGED
)
// 209
;
public
enum
TypeAction
implements
IntEnum
{
SHIFT
(
ActionEvent
.
SHIFT_MASK
),
// 1
CONTROL
(
ActionEvent
.
CTRL_MASK
),
// 2
META
(
ActionEvent
.
META_MASK
),
// 4
ALT
(
ActionEvent
.
ALT_MASK
);
// 8
private
int
i
;
private
TypeAction
(
int
value
)
{
i
=
value
;
}
@Override
public
int
getValue
()
{
return
i
;
}
}
public
enum
TypeComponent
implements
IntEnum
{
MOVED
(
ComponentEvent
.
COMPONENT_MOVED
),
// 100
RESIZED
(
ComponentEvent
.
COMPONENT_RESIZED
),
// 101
SHOWN
(
ComponentEvent
.
COMPONENT_SHOWN
),
// 102
HIDDEN
(
ComponentEvent
.
COMPONENT_HIDDEN
);
// 103
private
int
i
;
private
TypeComponent
(
int
value
)
{
i
=
value
;
}
@Override
public
int
getValue
()
{
return
i
;
}
}
public
enum
TypeWindow
implements
IntEnum
{
OPENED
(
WindowEvent
.
WINDOW_OPENED
),
//200
CLOSING
(
WindowEvent
.
WINDOW_CLOSING
),
// 201
CLOSED
(
WindowEvent
.
WINDOW_CLOSED
),
// 202
ICONIFIED
(
WindowEvent
.
WINDOW_ICONIFIED
),
//203
DEICONIFIED
(
WindowEvent
.
WINDOW_DEICONIFIED
),
// 204
ACTIVATED
(
WindowEvent
.
WINDOW_ACTIVATED
),
// 205
DEACTIVATED
(
WindowEvent
.
WINDOW_DEACTIVATED
),
// 206
GAINED_FOCUS
(
WindowEvent
.
WINDOW_GAINED_FOCUS
),
// 207
LOST_FOCUS
(
WindowEvent
.
WINDOW_LOST_FOCUS
),
// 208
STATE_CHANGED
(
WindowEvent
.
WINDOW_STATE_CHANGED
);
// 209
private
int
i
;
private
TypeWindow
(
int
value
)
{
i
=
value
;
}
@Override
public
int
getValue
()
{
return
i
;
}
}
private
int
i
;
private
ActionTypes
(
int
value
)
{
i
=
value
;
}
private
ActionTypes
(
IntEnum
v
)
{
i
=
v
.
getValue
();
}
public
int
getValue
()
{
return
i
;
}
public
static
ActionTypes
valueOf
(
int
value
)
{
for
(
ActionTypes
at
:
ActionTypes
.
values
()
)
{
if
(
at
.
i
==
value
)
{
return
at
;
}
}
return
ActionTypes
.
UNKNOWN
;
}
private
interface
IntEnum
{
public
int
getValue
();
}
}
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/actions/ListenAttach.java
0 → 100644
View file @
b55921a
package
me
.
felinewith
.
lang_toolkit
.
apps
.
langbuilder
.
actions
;
import
java.awt.Component
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
/**
*
* @author jlhawkwell
*/
public
class
ListenAttach
{
private
static
ArrayList
<
Class
<?>>
types
;
private
static
Logger
log
;
public
static
void
attach
(
Component
comp
,
UnifiedListener
listener
,
String
...
excludeMembers
)
{
if
(
types
==
null
)
{
Class
<?>[]
ts
=
UnifiedListener
.
class
.
getInterfaces
();
types
=
new
ArrayList
<>();
types
.
addAll
(
Arrays
.
asList
(
ts
));
}
if
(
log
==
null
)
{
log
=
LogManager
.
getLogger
();
}
ArrayList
<
String
>
exList
=
new
ArrayList
<>();
if
(
(
excludeMembers
!=
null
)
&&
(
excludeMembers
.
length
!=
0
)
)
{
exList
.
addAll
(
Arrays
.
asList
(
excludeMembers
));
}
StringBuilder
sb
;
Class
<?>[]
params
;
Method
[]
methods
=
comp
.
getClass
().
getMethods
();
for
(
Method
m
:
methods
)
{
if
(
m
.
getName
().
startsWith
(
"add"
)
&&
(
m
.
getParameterCount
()
==
1
)
)
{
params
=
m
.
getParameterTypes
();
if
(
types
.
contains
(
params
[
0
])
)
{
if
(
!
exList
.
contains
(
m
.
getName
())
)
{
try
{
m
.
invoke
(
comp
,
listener
);
}
catch
(
IllegalAccessException
|
IllegalArgumentException
|
InvocationTargetException
ex
)
{
sb
=
new
StringBuilder
(
comp
.
getClass
().
getSimpleName
());
sb
.
append
(
"."
);
sb
.
append
(
m
.
getName
().
concat
(
"("
));
sb
.
append
(
params
[
0
]);
sb
.
append
(
")\n\tFAILED: "
);
sb
.
append
(
ex
);
log
.
warn
(
sb
.
toString
());
}
}
}
}
}
}
}
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/actions/UnifiedListener.java
0 → 100644
View file @
b55921a
package
me
.
felinewith
.
lang_toolkit
.
apps
.
langbuilder
.
actions
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
import
java.awt.event.ComponentEvent
;
import
java.awt.event.ComponentListener
;
import
java.awt.event.WindowEvent
;
import
java.awt.event.WindowFocusListener
;
import
java.awt.event.WindowListener
;
import
java.awt.event.WindowStateListener
;
import
java.beans.PropertyChangeEvent
;
import
java.beans.PropertyChangeListener
;
import
javax.swing.event.ChangeEvent
;
import
javax.swing.event.ChangeListener
;
/**
*
* @author jlhawkwell
*/
public
abstract
class
UnifiedListener
extends
ActionAccept
implements
ActionListener
,
ChangeListener
,
ComponentListener
,
PropertyChangeListener
,
WindowFocusListener
,
WindowListener
,
WindowStateListener
{
@Override
final
public
void
actionPerformed
(
ActionEvent
e
)
{
handleAction
(
new
ActionHandle
(
e
));
}
@Override
final
public
void
stateChanged
(
ChangeEvent
e
)
{
handleChange
(
new
ActionHandle
(
e
));
}
@Override
final
public
void
componentHidden
(
ComponentEvent
e
)
{
handleComponent
(
new
ActionHandle
(
e
));
}
@Override
final
public
void
componentMoved
(
ComponentEvent
e
)
{
handleComponent
(
new
ActionHandle
(
e
));
}
@Override
final
public
void
componentResized
(
ComponentEvent
e
)
{
handleComponent
(
new
ActionHandle
(
e
));
}
@Override
final
public
void
componentShown
(
ComponentEvent
e
)
{
handleComponent
(
new
ActionHandle
(
e
));
}
@Override
final
public
void
propertyChange
(
PropertyChangeEvent
e
)
{
handleProperty
(
new
ActionHandle
(
e
));
}
@Override
final
public
void
windowActivated
(
WindowEvent
e
)
{
handleWindow
(
new
ActionHandle
(
e
));
}
@Override
final
public
void
windowClosed
(
WindowEvent
e
)
{
handleWindow
(
new
ActionHandle
(
e
));
}
@Override
final
public
void
windowClosing
(
WindowEvent
e
)
{
handleWindow
(
new
ActionHandle
(
e
));
}
@Override
final
public
void
windowDeactivated
(
WindowEvent
e
)
{
handleWindow
(
new
ActionHandle
(
e
));
}
@Override
final
public
void
windowDeiconified
(
WindowEvent
e
)
{
handleWindow
(
new
ActionHandle
(
e
));
}
@Override
final
public
void
windowGainedFocus
(
WindowEvent
e
)
{
handleWindow
(
new
ActionHandle
(
e
));
}
@Override
final
public
void
windowIconified
(
WindowEvent
e
)
{
handleWindow
(
new
ActionHandle
(
e
));
}
@Override
final
public
void
windowLostFocus
(
WindowEvent
e
)
{
handleWindow
(
new
ActionHandle
(
e
));
}
@Override
final
public
void
windowOpened
(
WindowEvent
e
)
{
handleWindow
(
new
ActionHandle
(
e
));
}
@Override
final
public
void
windowStateChanged
(
WindowEvent
e
)
{
handleWindow
(
new
ActionHandle
(
e
));
}
}
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/actions/UnifiedRepeater.java
0 → 100644
View file @
b55921a
package
me
.
felinewith
.
lang_toolkit
.
apps
.
langbuilder
.
actions
;
import
java.util.ArrayList
;
import
java.util.function.Consumer
;
/**
*
* @author jlhawkwell
*/
public
final
class
UnifiedRepeater
extends
UnifiedListener
{
//implements ActionListener, ChangeListener, ComponentListener, PropertyChangeListener, WindowListener {
private
ArrayList
<
ActionAccept
>
list
;
public
UnifiedRepeater
()
{
list
=
new
ArrayList
<>();
}
public
void
addActionAccept
(
ActionAccept
actionAccept
)
{
list
.
add
(
actionAccept
);
}
public
void
removeActionAccept
(
ActionAccept
actionAccept
)
{
list
.
remove
(
actionAccept
);
}
public
void
clear
()
{
list
.
clear
();
}
private
void
exec
(
Consumer
<
ActionAccept
>
con
)
{
if
(
list
.
isEmpty
()
)
{
return
;
}
list
.
forEach
(
con
);
}
@Override
public
void
handleAction
(
ActionHandle
action
)
{
exec
(
new
LooperAction
(
action
));
}
@Override
public
void
handleChange
(
ActionHandle
action
)
{
exec
(
new
LooperChange
(
action
));
}
@Override
public
void
handleComponent
(
ActionHandle
action
)
{
exec
(
new
LooperComponent
(
action
));
}
@Override
public
void
handleProperty
(
ActionHandle
action
)
{
exec
(
new
LooperProperty
(
action
));
}
@Override
public
void
handleWindow
(
ActionHandle
action
)
{
exec
(
new
LooperWindow
(
action
));
}
@Override
public
void
handleEvent
(
ActionHandle
action
)
{
}
private
abstract
class
Looper
implements
Consumer
<
ActionAccept
>
{
ActionHandle
handle
;
public
Looper
(
ActionHandle
actionHandle
)
{
handle
=
actionHandle
;
}
}
private
class
LooperAction
extends
Looper
{
public
LooperAction
(
ActionHandle
actionHandle
)
{
super
(
actionHandle
);
}
@Override
public
void
accept
(
ActionAccept
t
)
{
t
.
handleAction
(
handle
);
}
}
private
class
LooperChange
extends
Looper
{
public
LooperChange
(
ActionHandle
actionHandle
)
{
super
(
actionHandle
);
}
@Override
public
void
accept
(
ActionAccept
t
)
{
t
.
handleChange
(
handle
);
}
}
private
class
LooperComponent
extends
Looper
{
public
LooperComponent
(
ActionHandle
actionHandle
)
{
super
(
actionHandle
);
}
@Override
public
void
accept
(
ActionAccept
t
)
{
t
.
handleComponent
(
handle
);
}
}
private
class
LooperProperty
extends
Looper
{
public
LooperProperty
(
ActionHandle
actionHandle
)
{
super
(
actionHandle
);
}
@Override
public
void
accept
(
ActionAccept
t
)
{
t
.
handleProperty
(
handle
);
}
}
private
class
LooperWindow
extends
Looper
{
public
LooperWindow
(
ActionHandle
actionHandle
)
{
super
(
actionHandle
);
}
@Override
public
void
accept
(
ActionAccept
t
)
{
t
.
handleWindow
(
handle
);
}
}
}
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/util/ConfigHelper.java
0 → 100644
View file @
b55921a
package
me
.
felinewith
.
lang_toolkit
.
apps
.
langbuilder
.
util
;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
import
java.util.Collection
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Properties
;
import
java.util.Timer
;
import
java.util.TimerTask
;
import
org.apache.commons.configuration2.Configuration
;
import
org.apache.commons.configuration2.ConfigurationDecoder
;
import
org.apache.commons.configuration2.ImmutableConfiguration
;
import
org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder
;
import
org.apache.commons.configuration2.ex.ConfigurationException
;
import
org.apache.commons.configuration2.interpol.ConfigurationInterpolator
;
import
org.apache.commons.configuration2.interpol.Lookup
;
import
org.apache.commons.configuration2.sync.LockMode
;
import
org.apache.commons.configuration2.sync.Synchronizer
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
/**
*
* @author jlhawkwell
*/
public
class
ConfigHelper
implements
Configuration
{
Configuration
config
;
FileBasedConfigurationBuilder
<?>
builder
;
Timer
saver
;
Logger
log
;
public
ConfigHelper
(
Configuration
configuration
,
FileBasedConfigurationBuilder
<?>
configBuilder
)
{
if
(
configuration
==
null
)
{
throw
new
NullPointerException
(
"Should never be null!"
);
}
if
(
configBuilder
==
null
)
{
throw
new
NullPointerException
(
"Should never be null!"
);
}
config
=
configuration
;
builder
=
configBuilder
;
log
=
LogManager
.
getLogger
();
}
@Override
public
Configuration
subset
(
String
prefix
)
{
return
config
.
subset
(
prefix
);
}
@Override
public
void
addProperty
(
String
key
,
Object
value
)
{
config
.
addProperty
(
key
,
value
);
autoSave
();
}
@Override
public
void
setProperty
(
String
key
,
Object
value
)
{
config
.
setProperty
(
key
,
value
);
autoSave
();
}
@Override
public
void
clearProperty
(
String
key
)
{
config
.
clearProperty
(
key
);
autoSave
();
}
@Override
public
void
clear
()
{
config
.
clear
();
autoSave
();
}
@Override
public
ConfigurationInterpolator
getInterpolator
()
{
return
config
.
getInterpolator
();
}
@Override
public
void
setInterpolator
(
ConfigurationInterpolator
ci
)
{
config
.
setInterpolator
(
ci
);
}
@Override
public
void
installInterpolator
(
Map
<
String
,
?
extends
Lookup
>
prefixLookups
,
Collection
<?
extends
Lookup
>
defLookups
)
{
config
.
installInterpolator
(
prefixLookups
,
defLookups
);
}
@Override
public
boolean
isEmpty
()
{
return
config
.
isEmpty
();
}
@Override
public
int
size
()
{
return
config
.
size
();
}
@Override
public
boolean
containsKey
(
String
key
)
{
return
config
.
containsKey
(
key
);
}
@Override
public
Object
getProperty
(
String
key
)
{
return
config
.
getProperty
(
key
);
}
@Override
public
Iterator
<
String
>
getKeys
(
String
prefix
)
{
return
config
.
getKeys
();
}
@Override
public
Iterator
<
String
>
getKeys
()
{
return
config
.
getKeys
();
}
@Override
public
Properties
getProperties
(
String
key
)
{
return
config
.
getProperties
(
key
);
}
@Override
public
boolean
getBoolean
(
String
key
)
{
return
config
.
getBoolean
(
key
);
}
@Override
public
boolean
getBoolean
(
String
key
,
boolean
defaultValue
)
{
return
config
.
getBoolean
(
key
,
defaultValue
);
}
@Override
public
Boolean
getBoolean
(
String
key
,
Boolean
defaultValue
)
{
return
config
.
getBoolean
(
key
,
defaultValue
);
}
@Override
public
byte
getByte
(
String
key
)
{
return
config
.
getByte
(
key
);
}
@Override
public
byte
getByte
(
String
key
,
byte
defaultValue
)
{
return
config
.
getByte
(
key
,
defaultValue
);
}
@Override
public
Byte
getByte
(
String
key
,
Byte
defaultValue
)
{
return
config
.
getByte
(
key
,
defaultValue
);
}
@Override
public
double
getDouble
(
String
key
)
{
return
config
.
getDouble
(
key
);
}
@Override
public
double
getDouble
(
String
key
,
double
defaultValue
)
{
return
config
.
getDouble
(
key
,
defaultValue
);
}
@Override
public
Double
getDouble
(
String
key
,
Double
defaultValue
)
{
return
config
.
getDouble
(
key
,
defaultValue
);
}
@Override
public
float
getFloat
(
String
key
)
{
return
config
.
getFloat
(
key
);
}
@Override
public
float
getFloat
(
String
key
,
float
defaultValue
)
{
return
config
.
getFloat
(
key
,
defaultValue
);
}
@Override
public
Float
getFloat
(
String
key
,
Float
defaultValue
)
{
return
config
.
getFloat
(
key
,
defaultValue
);
}
@Override
public
int
getInt
(
String
key
)
{
return
config
.
getInt
(
key
);
}
@Override
public
int
getInt
(
String
key
,
int
defaultValue
)
{
return
config
.
getInteger
(
key
,
defaultValue
);
}
@Override
public
Integer
getInteger
(
String
key
,
Integer
defaultValue
)
{
return
config
.
getInt
(
key
,
defaultValue
);
}
@Override
public
long
getLong
(
String
key
)
{
return
config
.
getLong
(
key
);
}
@Override
public
long
getLong
(
String
key
,
long
defaultValue
)
{
return
config
.
getLong
(
key
,
defaultValue
);
}
@Override
public
Long
getLong
(
String
key
,
Long
defaultValue
)
{
return
config
.
getLong
(
key
,
defaultValue
);
}
@Override
public
short
getShort
(
String
key
)
{
return
config
.
getShort
(
key
);
}
@Override
public
short
getShort
(
String
key
,
short
defaultValue
)
{
return
config
.
getShort
(
key
,
defaultValue
);
}
@Override
public
Short
getShort
(
String
key
,
Short
defaultValue
)
{
return
config
.
getShort
(
key
,
defaultValue
);
}
@Override
public
BigDecimal
getBigDecimal
(
String
key
)
{
return
config
.
getBigDecimal
(
key
);
}
@Override
public
BigDecimal
getBigDecimal
(
String
key
,
BigDecimal
defaultValue
)
{
return
config
.
getBigDecimal
(
key
,
defaultValue
);
}
@Override
public
BigInteger
getBigInteger
(
String
key
)
{
return
config
.
getBigInteger
(
key
);
}
@Override
public
BigInteger
getBigInteger
(
String
key
,
BigInteger
defaultValue
)
{
return
config
.
getBigInteger
(
key
,
defaultValue
);
}
@Override
public
String
getString
(
String
key
)
{
return
config
.
getString
(
key
);
}
@Override
public
String
getString
(
String
key
,
String
defaultValue
)
{
return
config
.
getString
(
key
,
defaultValue
);
}
@Override
public
String
getEncodedString
(
String
key
,
ConfigurationDecoder
decoder
)
{
return
config
.
getEncodedString
(
key
,
decoder
);
}
@Override
public
String
getEncodedString
(
String
key
)
{
return
config
.
getEncodedString
(
key
);
}
@Override
public
String
[]
getStringArray
(
String
key
)
{
return
config
.
getStringArray
(
key
);
}
@Override
public
List
<
Object
>
getList
(
String
key
)
{
return
config
.
getList
(
key
);
}
@Override
public
List
<
Object
>
getList
(
String
key
,
List
<?>
defaultValue
)
{
return
config
.
getList
(
key
,
defaultValue
);
}
@Override
public
<
T
>
T
get
(
Class
<
T
>
cls
,
String
key
)
{
return
config
.
get
(
cls
,
key
);
}
@Override
public
<
T
>
T
get
(
Class
<
T
>
cls
,
String
key
,
T
defaultValue
)
{
return
config
.
get
(
cls
,
key
,
defaultValue
);
}
@Override
public
Object
getArray
(
Class
<?>
cls
,
String
key
)
{
return
config
.
getArray
(
cls
,
key
);
}
@SuppressWarnings
(
"deprecation"
)
@Override
public
Object
getArray
(
Class
<?>
cls
,
String
key
,
Object
defaultValue
)
{
return
config
.
getArray
(
cls
,
key
,
defaultValue
);
}
@Override
public
<
T
>
List
<
T
>
getList
(
Class
<
T
>
cls
,
String
key
)
{
return
config
.
getList
(
cls
,
key
);
}
@Override
public
<
T
>
List
<
T
>
getList
(
Class
<
T
>
cls
,
String
key
,
List
<
T
>
defaultValue
)
{
return
config
.
getList
(
cls
,
key
,
defaultValue
);
}
@Override
public
<
T
>
Collection
<
T
>
getCollection
(
Class
<
T
>
cls
,
String
key
,
Collection
<
T
>
target
)
{
return
config
.
getCollection
(
cls
,
key
,
target
);
}
@Override
public
<
T
>
Collection
<
T
>
getCollection
(
Class
<
T
>
cls
,
String
key
,
Collection
<
T
>
target
,
Collection
<
T
>
defaultValue
)
{
return
config
.
getCollection
(
cls
,
key
,
target
,
defaultValue
);
}
@Override
public
ImmutableConfiguration
immutableSubset
(
String
prefix
)
{
return
config
.
immutableSubset
(
prefix
);
}
@Override
public
Synchronizer
getSynchronizer
()
{
return
config
.
getSynchronizer
();
}
@Override
public
void
setSynchronizer
(
Synchronizer
sync
)
{
config
.
setSynchronizer
(
sync
);
}
@Override
public
void
lock
(
LockMode
mode
)
{
config
.
lock
(
mode
);
}
@Override
public
void
unlock
(
LockMode
mode
)
{
config
.
unlock
(
mode
);
}
private
void
autoSave
()
{
if
(
saver
!=
null
)
{
saver
.
cancel
();
saver
.
purge
();
}
saver
=
new
Timer
();
saver
.
schedule
(
new
TimerTask
()
{
@Override
public
void
run
()
{
try
{
builder
.
save
();
log
.
info
(
"[autoSave] Configuration saved."
);
}
catch
(
ConfigurationException
ex
)
{
log
.
fatal
(
"Unable to save config!"
,
ex
);
}
}
},
5000L
);
}
}
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/util/DesktopMenu.java
0 → 100644
View file @
b55921a
package
me
.
felinewith
.
lang_toolkit
.
apps
.
langbuilder
.
util
;
import
java.awt.Component
;
import
java.awt.Dimension
;
import
java.awt.event.ActionListener
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.net.URL
;
import
java.util.HashMap
;
import
javax.swing.Icon
;
import
javax.swing.ImageIcon
;
import
javax.swing.JButton
;
import
javax.swing.JToolBar
;
/**
*
* @author jlhawkwell
*/
public
class
DesktopMenu
{
private
JToolBar
toolBar
;
private
HashMap
<
String
,
Component
>
tbItems
;
private
ActionListener
al
;
public
DesktopMenu
()
{
toolBar
=
new
JToolBar
();
}
public
DesktopMenu
(
JToolBar
jToolBar
)
{
toolBar
=
jToolBar
;
tbItems
=
new
HashMap
<>();
}
public
DesktopMenu
(
JToolBar
jToolBar
,
ActionListener
actions
)
{
toolBar
=
jToolBar
;
tbItems
=
new
HashMap
<>();
al
=
actions
;
}
public
void
addButton
(
String
text
)
{
addButton
(
text
,
text
,
null
,
null
,
true
);
}
public
void
addButton
(
String
text
,
String
name
)
{
addButton
(
text
,
name
,
null
,
null
,
true
);
}
public
void
addButton
(
String
text
,
String
name
,
String
toolTip
)
{
addButton
(
text
,
name
,
toolTip
,
null
,
true
);
}
public
void
addButton
(
String
text
,
String
name
,
String
toolTip
,
String
icon
)
{
URL
u
=
this
.
getClass
().
getResource
(
"/org/freedesktop/tango/"
.
concat
(
icon
));
addButton
(
text
,
name
,
toolTip
,
u
);
}
public
void
addButton
(
String
text
,
URL
icon
)
{
addButton
(
text
,
text
,
null
,
icon
);
}
public
void
addButton
(
String
text
,
String
name
,
URL
icon
)
{
addButton
(
text
,
name
,
null
,
icon
);
}
public
void
addButton
(
String
text
,
String
name
,
String
toolTip
,
URL
icon
)
{
ImageIcon
i
=
new
ImageIcon
(
icon
);
addButton
(
text
,
name
,
toolTip
,
i
,
true
);
}
public
void
addButton
(
String
text
,
Icon
icon
)
{
addButton
(
text
,
text
,
null
,
icon
,
true
);
}
public
void
addButton
(
String
text
,
String
name
,
Icon
icon
)
{
addButton
(
text
,
name
,
null
,
icon
,
true
);
}
public
void
addButton
(
String
text
,
String
name
,
String
toolTip
,
Icon
icon
)
{
addButton
(
text
,
name
,
toolTip
,
icon
,
true
);
}
private
void
addButton
(
String
text
,
String
name
,
String
toolTip
,
Icon
icon
,
boolean
rawr
)
{
JButton
b
=
new
JButton
(
text
);
b
.
setName
(
name
);
if
(
toolTip
!=
null
)
{
if
(
!
toolTip
.
isEmpty
()
)
{
b
.
setToolTipText
(
toolTip
);
}
}
if
(
icon
!=
null
)
{
b
.
setIcon
(
icon
);
}
addComponent
(
b
);
}
public
void
addSeparator
()
{
toolBar
.
addSeparator
();
}
public
void
addSeparator
(
Dimension
size
)
{
toolBar
.
addSeparator
(
size
);
}
public
void
addComponent
(
Component
component
)
{
if
(
component
.
getName
()
==
null
)
{
return
;
}
addComponent
(
component
.
getName
(),
component
);
}
public
void
addComponent
(
String
name
,
Component
component
)
{
tbItems
.
put
(
name
,
component
);
toolBar
.
add
(
name
,
component
);
if
(
al
==
null
)
{
return
;
}
try
{
Method
m
=
component
.
getClass
().
getMethod
(
"addActionListener"
,
ActionListener
.
class
);
m
.
invoke
(
component
,
al
);
}
catch
(
NoSuchMethodException
|
SecurityException
|
IllegalAccessException
|
IllegalArgumentException
|
InvocationTargetException
ex
)
{}
try
{
Method
m
=
component
.
getClass
().
getMethod
(
"setActionCommand"
,
String
.
class
);
m
.
invoke
(
component
,
name
);
}
catch
(
NoSuchMethodException
|
SecurityException
|
IllegalAccessException
|
IllegalArgumentException
|
InvocationTargetException
ex
)
{}
}
public
Component
getComponent
(
String
name
)
{
return
tbItems
.
get
(
name
);
}
}
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/window/WindowUnifiedListener.java
0 → 100644
View file @
b55921a
package
me
.
felinewith
.
lang_toolkit
.
apps
.
langbuilder
.
window
;
import
java.awt.Component
;
import
java.awt.Rectangle
;
import
java.awt.event.WindowEvent
;
import
javax.swing.JFrame
;
import
me.felinewith.lang_toolkit.apps.langbuilder.actions.ActionHandle
;
import
me.felinewith.lang_toolkit.apps.langbuilder.actions.UnifiedListener
;
import
org.apache.commons.configuration2.Configuration
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
/**
*
* @author jlhawkwell
*/
public
class
WindowUnifiedListener
extends
UnifiedListener
{
JFrame
frame
;
Configuration
config
;
Logger
log
;
public
WindowUnifiedListener
(
JFrame
jFrame
,
Configuration
configuration
)
{
frame
=
jFrame
;
config
=
configuration
;
log
=
LogManager
.
getLogger
();
}
@Override
public
void
handleAction
(
ActionHandle
action
)
{
if
(
action
.
getName
().
equals
(
"exit"
)
)
{
frame
.
dispatchEvent
(
new
WindowEvent
(
frame
,
WindowEvent
.
WINDOW_CLOSING
));
return
;
}
super
.
handleAction
(
action
);
}
@Override
public
void
handleComponent
(
ActionHandle
action
)
{
if
(
action
.
getSource
()
instanceof
JFrame
)
{
JFrame
jFrame
=
(
JFrame
)
action
.
getSource
();
Rectangle
bounds
=
jFrame
.
getBounds
();
switch
(
action
.
getActionType
()
)
{
case
COMPONENT_RESIZED:
config
.
setProperty
(
"window.preferredSize.x"
,
bounds
.
width
);
config
.
setProperty
(
"window.preferredSize.y"
,
bounds
.
height
);
return
;
case
COMPONENT_MOVED:
config
.
setProperty
(
"window.location.x"
,
bounds
.
x
);
config
.
setProperty
(
"window.location.y"
,
bounds
.
y
);
return
;
default
:
super
.
handleComponent
(
action
);
}
}
super
.
handleComponent
(
action
);
}
@Override
public
void
handleProperty
(
ActionHandle
action
)
{
String
className
=
action
.
getSource
().
getClass
().
getSimpleName
();
if
(
className
.
equals
(
"JSplitPane"
)
)
{
switch
(
action
.
getName
()
)
{
case
"dividerLocation"
:
saveHelper
(
action
);
return
;
default
:
super
.
handleProperty
(
action
);
}
}
super
.
handleProperty
(
action
);
}
@Override
public
void
handleEvent
(
ActionHandle
action
)
{
StringBuilder
sb
=
new
StringBuilder
(
"["
);
sb
.
append
(
action
.
getActionSource
().
toString
());
sb
.
append
(
"/"
);
sb
.
append
(
action
.
getActionType
().
toString
());
sb
.
append
(
"] "
);
sb
.
append
(
action
.
getSource
().
getClass
().
getSimpleName
());
sb
.
append
(
"/"
);
sb
.
append
(
action
.
getName
());
sb
.
append
(
"/"
);
sb
.
append
(
action
.
getIntValue
());
sb
.
append
(
"/"
);
sb
.
append
(
action
.
getObjectValue
());
log
.
debug
(
sb
.
toString
());
}
private
void
saveHelper
(
ActionHandle
action
)
{
String
name
=
null
;
if
(
action
.
getSource
()
instanceof
Component
)
{
name
=
((
Component
)
action
.
getSource
()).
getName
();
}
if
(
name
==
null
)
{
name
=
action
.
getSource
().
getClass
().
getSimpleName
();
}
String
propertyName
=
action
.
getName
();
StringBuilder
sb
=
new
StringBuilder
(
name
);
sb
.
append
(
"."
);
sb
.
append
(
propertyName
);
config
.
setProperty
(
sb
.
toString
(),
action
.
getObjectValue
());
}
}
pom.xml
View file @
b55921a
...
...
@@ -50,7 +50,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
</snapshotRepository>
<site>
<id>
Main
</id>
<name>
Candle POS
</name>
<name>
${project.name}
</name>
<url>
${gl.pages}
</url>
</site>
</distributionManagement>
...
...
@@ -111,40 +111,66 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
<enabled>
true
</enabled>
</snapshots>
</repository>
<repository>
<id>
in
ternal
</id>
<name>
SPM
Internal
</name>
<url>
https://mvn.felinewith.me/repository/
in
ternal
</url>
<
!--
repository>
<id>
ex
ternal</id>
<name>SPM
Externals
</name>
<url>https://mvn.felinewith.me/repository/
ex
ternal</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repository
--
>
</repositories>
<dependencyManagement>
<dependencies>
<!-- PROJECT DEPENDENCIES ********************************************************************* PROJECT DEPENDENCIES -->
<dependency>
<groupId>
commons-beanutils
</groupId>
<artifactId>
commons-beanutils
</artifactId>
<version>
1.9.3
</version>
<scope>
runtime
</scope>
</dependency>
<dependency>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-configuration2
</artifactId>
<version>
2.1.1
</version>
</dependency>
<dependency>
<groupId>
org.apache.logging.log4j
</groupId>
<artifactId>
log4j-api
</artifactId>
<version>
2.8.2
</version>
</dependency>
<dependency>
<groupId>
org.apache.logging.log4j
</groupId>
<artifactId>
log4j-core
</artifactId>
<version>
2.8.2
</version>
</dependency>
<dependency>
<groupId>
org.apache.velocity
</groupId>
<artifactId>
velocity
</artifactId>
<version>
1.7
</version>
</dependency>
<dependency>
<groupId>
org.freedesktop.tango
</groupId>
<artifactId>
tango-icon-theme
</artifactId>
<version>
0.8.90
</version>
</dependency>
<dependency>
<groupId>
org.testng
</groupId>
<artifactId>
testng
</artifactId>
<version>
6.8.7
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
me.felinewith.lang
_
toolkit.apps
</groupId>
<groupId>
me.felinewith.lang
-
toolkit.apps
</groupId>
<artifactId>
bootstrap
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
me.felinewith.lang
_
toolkit.apps
</groupId>
<groupId>
me.felinewith.lang
-
toolkit.apps
</groupId>
<artifactId>
langbuilder
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
...
...
@@ -159,7 +185,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
</dependencies>
<build>
<defaultGoal>
clean test package
site
</defaultGoal>
<defaultGoal>
clean test package
install
</defaultGoal>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
...
...
run.sh
0 → 100755
View file @
b55921a
#!/bin/sh
rm -rf libs/
*
find
*
-type f -name
"*-SNAPSHOT.jar"
-exec cp
{}
libs
\;
java -jar libs/bootstrap-1.0-SNAPSHOT.jar
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment