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 a682c75d
authored
Jul 05, 2017
by
Jessica Hawkwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Got some things working, now to link the vitals with Configuration
😺
👏
1 parent
94e85d49
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
428 additions
and
58 deletions
apps/bootstrap/src/main/java/me/felinewith/lang_toolkit/apps/bootstrap/Bootstrap.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/util/LoaderHelper.java
apps/bootstrap/src/main/java/me/felinewith/lang_toolkit/apps/bootstrap/util/MavenArtifact.java
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/LangBuilder.java
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/ListenWindow.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/window/WindowAdapterListener.java
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/window/WindowComponentListener.java
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/window/WindowPropertyChangeListener.java
pom.xml
run.sh
apps/bootstrap/src/main/java/me/felinewith/lang_toolkit/apps/bootstrap/Bootstrap.java
View file @
a682c75
...
...
@@ -25,9 +25,18 @@ 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
;
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
();
File
folder
=
new
File
(
SETTINGS
);
if
(
!
folder
.
exists
()
)
{
folder
.
mkdirs
();
}
boolean
mvn
=
false
;
try
{
mvn
=
check_maven
();
}
catch
(
IOException
|
InterruptedException
ex
)
{
}
...
...
@@ -38,21 +47,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 +81,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 +106,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
{
...
...
@@ -166,12 +170,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
;
}
...
...
apps/bootstrap/src/main/java/me/felinewith/lang_toolkit/apps/bootstrap/BootstrapClassLoader.java
View file @
a682c75
...
...
@@ -134,6 +134,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 +155,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 +170,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
()
)
{
...
...
@@ -231,7 +236,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
;
...
...
apps/bootstrap/src/main/java/me/felinewith/lang_toolkit/apps/bootstrap/util/LoaderHelper.java
View file @
a682c75
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package
me
.
felinewith
.
lang_toolkit
.
apps
.
bootstrap
.
util
;
/**
...
...
apps/bootstrap/src/main/java/me/felinewith/lang_toolkit/apps/bootstrap/util/MavenArtifact.java
View file @
a682c75
...
...
@@ -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/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/LangBuilder.java
View file @
a682c75
package
me
.
felinewith
.
lang_toolkit
.
apps
.
langbuilder
;
import
me.felinewith.lang_toolkit.apps.langbuilder.window.WindowAdapterListener
;
import
java.awt.Dimension
;
import
java.awt.DisplayMode
;
import
java.awt.GraphicsDevice
;
import
java.awt.GraphicsEnvironment
;
import
java.io.File
;
import
java.util.HashMap
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
javax.swing.JDesktopPane
;
import
javax.swing.JFrame
;
import
javax.swing.JScrollPane
;
...
...
@@ -13,9 +16,14 @@ import javax.swing.JSplitPane;
import
javax.swing.JTree
;
import
me.felinewith.lang_toolkit.apps.bootstrap.IStrappedApp
;
import
me.felinewith.lang_toolkit.apps.bootstrap.IStrappedPlugin
;
import
org.apache.commons.configuration2.HierarchicalConfiguration
;
import
org.apache.commons.configuration2.builder.BasicConfigurationBuilder
;
import
me.felinewith.lang_toolkit.apps.langbuilder.util.ConfigHelper
;
import
me.felinewith.lang_toolkit.apps.langbuilder.window.WindowComponentListener
;
import
me.felinewith.lang_toolkit.apps.langbuilder.window.WindowPropertyChangeListener
;
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
;
/**
*
...
...
@@ -31,15 +39,57 @@ public class LangBuilder implements IStrappedApp {
private
JScrollPane
jScrollPane
;
private
JTree
jTree
;
private
JDesktopPane
jDesktopPane
;
private
Configuration
config
;
private
WindowAdapterListener
adapterListener
;
private
WindowComponentListener
componentListener
;
private
WindowPropertyChangeListener
propertyChangeListener
;
@Override
public
void
preStart
(
String
[]
argsStrings
)
{
args
=
argsStrings
;
// configuration!
System
.
out
.
println
(
"[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
>(
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
)
{
Logger
.
getLogger
(
LangBuilder
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
"Config setup FAILED!"
,
ex
);
}
if
(
!
f
.
exists
()
)
{
if
(
!
builder
.
getFileHandler
().
isLocationDefined
()
)
{
builder
.
getFileHandler
().
setFileName
(
sb
.
toString
());
}
}
//builder.setAutoSave(true);
System
.
out
.
println
(
"[Desktop] Setting up window..."
);
plugins
=
new
HashMap
<>();
jFrame
=
new
JFrame
(
"LangBuilder"
);
// TODO: toolbar menu
jSplitPane
=
new
JSplitPane
(
JSplitPane
.
HORIZONTAL_SPLIT
);
jSplitPane
.
setContinuousLayout
(
true
);
jTree
=
new
JTree
();
jScrollPane
=
new
JScrollPane
(
jTree
,
...
...
@@ -51,9 +101,16 @@ public class LangBuilder implements IStrappedApp {
jSplitPane
.
setRightComponent
(
jDesktopPane
);
jFrame
.
add
(
jSplitPane
);
// set component names
jFrame
.
setName
(
"window"
);
jSplitPane
.
setName
(
"window.splitter"
);
jTree
.
setName
(
"window.tree"
);
jDesktopPane
.
setName
(
"window.desktop"
);
// configure the window
// set some sensible defaults
System
.
out
.
println
(
"[Desktop] Detecting screen sizes..."
);
GraphicsEnvironment
ge
=
GraphicsEnvironment
.
getLocalGraphicsEnvironment
();
DisplayMode
dm
;
int
sx
=
0
,
sy
=
0
;
...
...
@@ -76,20 +133,32 @@ public class LangBuilder implements IStrappedApp {
jFrame
.
setMinimumSize
(
new
Dimension
(
sx
/
2
,
sy
/
2
));
jFrame
.
setMaximumSize
(
new
Dimension
(
bx
,
by
));
jFrame
.
setPreferredSize
(
new
Dimension
(
sx
/
2
,
sy
/
2
));
// configuration!
StringBuilder
sb
=
new
StringBuilder
(
System
.
getProperty
(
"user.home"
));
sb
.
append
(
"/.local/share/lang-toolkit/config/"
);
File
f
=
new
File
(
sb
.
toString
());
if
(
!
f
.
exists
()
)
{
f
.
mkdirs
();
}
Parameters
param
=
new
Parameters
();
param
.
basic
().
setThrowExceptionOnMissing
(
false
);
param
.
hierarchical
().
setBasePath
(
f
.
getAbsolutePath
());
jFrame
.
setPreferredSize
(
new
Dimension
(
config
.
getInt
(
"window.preferredSize.x"
,
sx
/
2
),
config
.
getInt
(
"window.preferredSize.y"
,
sy
/
2
)
)
);
jSplitPane
.
setDividerLocation
(
config
.
getInt
(
"window.splitter.dividerLocation"
,
sx
/
8
));
adapterListener
=
new
WindowAdapterListener
(
this
,
config
);
jFrame
.
addWindowListener
(
adapterListener
);
jFrame
.
addWindowStateListener
(
adapterListener
);
jFrame
.
addWindowFocusListener
(
adapterListener
);
componentListener
=
new
WindowComponentListener
(
this
,
config
);
jFrame
.
addComponentListener
(
componentListener
);
jSplitPane
.
addComponentListener
(
componentListener
);
jTree
.
addComponentListener
(
componentListener
);
jDesktopPane
.
addComponentListener
(
componentListener
);
jFrame
.
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
propertyChangeListener
=
new
WindowPropertyChangeListener
(
this
,
config
);
jFrame
.
addPropertyChangeListener
(
propertyChangeListener
);
jSplitPane
.
addPropertyChangeListener
(
propertyChangeListener
);
jTree
.
addPropertyChangeListener
(
propertyChangeListener
);
jDesktopPane
.
addPropertyChangeListener
(
propertyChangeListener
);
BasicConfigurationBuilder
<
HierarchicalConfiguration
>
bcb
=
new
BasicConfigurationBuilder
<
HierarchicalConfiguration
>(
HierarchicalConfiguration
.
class
);
}
@Override
public
void
registerPlugin
(
IStrappedPlugin
plugin
)
{
...
...
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/ListenWindow.java
deleted
100644 → 0
View file @
94e85d4
package
me
.
felinewith
.
lang_toolkit
.
apps
.
langbuilder
;
import
java.awt.event.WindowAdapter
;
/**
*
* @author jlhawkwell
*/
public
class
ListenWindow
extends
WindowAdapter
{
LangBuilder
lb
;
public
ListenWindow
(
LangBuilder
langbuilder
)
{
lb
=
langbuilder
;
}
}
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/util/ConfigHelper.java
0 → 100644
View file @
a682c75
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
java.util.logging.Level
;
import
java.util.logging.Logger
;
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
;
/**
*
* @author jlhawkwell
*/
public
class
ConfigHelper
implements
Configuration
{
Configuration
config
;
FileBasedConfigurationBuilder
<?>
builder
;
Timer
saver
;
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
;
}
@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
);
}
@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
();
System
.
out
.
println
(
"[autoSave] Configuration saved."
);
}
catch
(
ConfigurationException
ex
)
{
Logger
.
getLogger
(
ConfigHelper
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
}
},
5000L
);
}
}
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/window/WindowAdapterListener.java
0 → 100644
View file @
a682c75
package
me
.
felinewith
.
lang_toolkit
.
apps
.
langbuilder
.
window
;
import
java.awt.event.WindowAdapter
;
import
java.awt.event.WindowEvent
;
import
me.felinewith.lang_toolkit.apps.langbuilder.LangBuilder
;
import
org.apache.commons.configuration2.Configuration
;
/**
*
* @author jlhawkwell
*/
public
class
WindowAdapterListener
extends
WindowAdapter
{
private
LangBuilder
lb
;
private
Configuration
config
;
public
WindowAdapterListener
(
LangBuilder
langbuilder
,
Configuration
configuration
)
{
lb
=
langbuilder
;
config
=
configuration
;
}
@Override
public
void
windowStateChanged
(
WindowEvent
e
)
{
super
.
windowStateChanged
(
e
);
System
.
out
.
println
(
"[windowStateChanged] "
.
concat
(
e
.
paramString
()));
}
private
void
printChange
(
WindowEvent
e
)
{
System
.
out
.
print
(
"[windowChanged]"
);
System
.
out
.
println
(
e
.
paramString
());
}
}
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/window/WindowComponentListener.java
0 → 100644
View file @
a682c75
package
me
.
felinewith
.
lang_toolkit
.
apps
.
langbuilder
.
window
;
import
java.awt.Dimension
;
import
java.awt.event.ComponentEvent
;
import
java.awt.event.ComponentListener
;
import
javax.swing.JFrame
;
import
me.felinewith.lang_toolkit.apps.langbuilder.LangBuilder
;
import
org.apache.commons.configuration2.Configuration
;
/**
*
* @author jlhawkwell
*/
public
class
WindowComponentListener
implements
ComponentListener
{
private
LangBuilder
lb
;
private
Configuration
config
;
public
WindowComponentListener
(
LangBuilder
langbuilder
,
Configuration
configuration
)
{
lb
=
langbuilder
;
config
=
configuration
;
}
@Override
public
void
componentResized
(
ComponentEvent
e
)
{
if
(
e
.
getComponent
()
instanceof
JFrame
)
{
Dimension
size
=
e
.
getComponent
().
getSize
();
config
.
setProperty
(
"window.preferredSize.x"
,
size
.
width
);
config
.
setProperty
(
"window.preferredSize.y"
,
size
.
height
);
}
}
@Override
public
void
componentMoved
(
ComponentEvent
e
)
{
}
@Override
public
void
componentShown
(
ComponentEvent
e
)
{
}
@Override
public
void
componentHidden
(
ComponentEvent
e
)
{
}
private
void
printChange
(
ComponentEvent
e
)
{
System
.
out
.
print
(
"[componentChanged] "
);
System
.
out
.
println
(
e
.
paramString
());
}
}
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/window/WindowPropertyChangeListener.java
0 → 100644
View file @
a682c75
package
me
.
felinewith
.
lang_toolkit
.
apps
.
langbuilder
.
window
;
import
java.awt.Component
;
import
java.beans.PropertyChangeEvent
;
import
java.beans.PropertyChangeListener
;
import
me.felinewith.lang_toolkit.apps.langbuilder.LangBuilder
;
import
org.apache.commons.configuration2.Configuration
;
/**
*
* @author jlhawkwell
*/
public
class
WindowPropertyChangeListener
implements
PropertyChangeListener
{
private
LangBuilder
lb
;
private
Configuration
config
;
public
WindowPropertyChangeListener
(
LangBuilder
langBuilder
,
Configuration
configuration
)
{
lb
=
langBuilder
;
config
=
configuration
;
}
@Override
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
String
className
=
evt
.
getSource
().
getClass
().
getSimpleName
();
if
(
className
.
equals
(
"JSplitPane"
)
)
{
switch
(
evt
.
getPropertyName
()
)
{
case
"dividerLocation"
:
saveHelper
(
evt
);
break
;
}
}
else
{
printChange
(
evt
);
}
}
private
void
printChange
(
PropertyChangeEvent
evt
)
{
StringBuilder
sb
=
new
StringBuilder
(
"[propertyChange] "
);
sb
.
append
(
evt
.
getSource
().
getClass
().
getSimpleName
());
sb
.
append
(
"/"
);
sb
.
append
(
evt
.
getPropertyName
());
sb
.
append
(
"/"
);
sb
.
append
(
evt
.
getNewValue
());
System
.
out
.
println
(
sb
.
toString
());
}
private
void
saveHelper
(
PropertyChangeEvent
evt
)
{
String
name
=
null
;
if
(
evt
.
getSource
()
instanceof
Component
)
{
name
=
((
Component
)
evt
.
getSource
()).
getName
();
}
if
(
name
==
null
)
{
name
=
evt
.
getSource
().
getClass
().
getSimpleName
();
}
String
propertyName
=
evt
.
getPropertyName
();
StringBuilder
sb
=
new
StringBuilder
(
name
);
sb
.
append
(
"."
);
sb
.
append
(
propertyName
);
config
.
setProperty
(
sb
.
toString
(),
evt
.
getNewValue
());
}
}
pom.xml
View file @
a682c75
...
...
@@ -128,6 +128,12 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
<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>
...
...
@@ -154,7 +160,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
<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>
...
...
@@ -169,7 +175,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
</dependencies>
<build>
<defaultGoal>
clean test package
</defaultGoal>
<defaultGoal>
clean test package
install
</defaultGoal>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
...
...
run.sh
0 → 100755
View file @
a682c75
#!/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