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 975a3e52
authored
Jul 04, 2017
by
Jessica Hawkwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lots of work today.
😺
1 parent
c6f99429
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
238 additions
and
14 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/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/IStrappedPlugin.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/resources/bootstrap/bootstrap.properties
pom.xml
apps/bootstrap/src/main/java/me/felinewith/lang_toolkit/apps/bootstrap/Bootstrap.java
View file @
975a3e5
...
...
@@ -9,6 +9,8 @@ import java.io.FileReader;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
import
java.util.Properties
;
...
...
@@ -50,13 +52,17 @@ public class Bootstrap {
try
{
installed
=
checkProperties
(
sb
.
toString
());
}
catch
(
IOException
ex
)
{
}
File
pomFile
=
new
File
(
sb
.
toString
().
concat
(
"pom.xml"
));
MavenArtifact
[]
deps
;
ClassLoader
cl
=
Bootstrap
.
class
.
getClassLoader
();
if
(
!
installed
)
{
File
test
=
new
File
(
sb
.
toString
().
concat
(
"pom.xml"
));
String
pt
=
"DEPS/pom.xml"
;
try
{
copyContents
(
Bootstrap
.
class
.
getClassLoader
().
getResourceAsStream
(
pt
),
new
FileOutputStream
(
test
));
}
try
{
copyContents
(
cl
.
getResourceAsStream
(
pt
),
new
FileOutputStream
(
pomFile
));
}
catch
(
FileNotFoundException
ex
)
{
Logger
.
getLogger
(
Bootstrap
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
String
[]
deps
=
getDepList
(
test
);
deps
=
getDepList
(
pomFile
);
StringBuilder
command
=
new
StringBuilder
();
if
(
mvn
)
{
command
.
append
(
mavenFile
.
getAbsolutePath
());
}
...
...
@@ -67,17 +73,32 @@ public class Bootstrap {
catch
(
InterruptedException
ex
)
{
}
command
.
append
(
"dependency:get -Dartifact="
);
for
(
String
s
:
deps
)
File
test
;
for
(
MavenArtifact
ma
:
deps
)
{
try
{
exec
(
folder
,
command
.
toString
().
concat
(
s
));
}
catch
(
InterruptedException
ex
)
{
}
test
=
new
File
(
ma
.
getFileLocation
());
if
(
test
.
exists
()
)
{
try
{
exec
(
folder
,
command
.
toString
().
concat
(
ma
.
getLocation
()));
}
catch
(
InterruptedException
ex
)
{
}
}
}
test
=
new
File
(
sb
.
toString
().
concat
(
"pom.properties"
));
try
{
copyContents
(
Bootstrap
.
class
.
getClassLoader
()
.
getResourceAsStream
(
PROPERTIES
),
new
FileOutputStream
(
test
));
}
try
{
copyContents
(
cl
.
getResourceAsStream
(
PROPERTIES
),
new
FileOutputStream
(
test
));
}
catch
(
FileNotFoundException
ex
)
{}
}
BootstrapClassLoader
bcl
=
new
BootstrapClassLoader
(
cl
);
bcl
.
init
();
deps
=
getDepList
(
pomFile
);
File
jar
;
for
(
MavenArtifact
ma
:
deps
)
{
jar
=
new
File
(
ma
.
getFileLocation
());
if
(
jar
.
exists
()
)
{
bcl
.
addJar
(
jar
);
}
}
startUp
(
bcl
,
args
);
}
private
static
boolean
check_maven
()
throws
IOException
,
InterruptedException
{
...
...
@@ -184,8 +205,8 @@ public class Bootstrap {
return
true
;
}
private
static
String
[]
getDepList
(
File
pomFile
)
throws
FileNotFoundException
,
IOException
{
ArrayList
<
String
>
builder
=
new
ArrayList
<>();
private
static
MavenArtifact
[]
getDepList
(
File
pomFile
)
throws
FileNotFoundException
,
IOException
{
ArrayList
<
MavenArtifact
>
builder
=
new
ArrayList
<>();
FileReader
fr
=
new
FileReader
(
pomFile
);
BufferedReader
br
=
new
BufferedReader
(
fr
);
...
...
@@ -202,7 +223,7 @@ public class Bootstrap {
else
if
(
pt
.
startsWith
(
"<artifactId>"
)
)
{
ma
.
setArtifact
(
lineFix
(
pt
));
}
else
if
(
pt
.
startsWith
(
"<version>"
)
)
{
ma
.
setVersion
(
lineFix
(
pt
));
}
else
if
(
pt
.
startsWith
(
"</dependency>"
)
)
{
if
(
ma
.
isReady
()
)
{
builder
.
add
(
ma
.
getLocation
()
);
}
if
(
ma
.
isReady
()
)
{
builder
.
add
(
ma
);
}
inDep
=
false
;
}
}
...
...
@@ -215,7 +236,7 @@ public class Bootstrap {
line
=
br
.
readLine
();
}
return
builder
.
toArray
(
new
String
[
builder
.
size
()]);
return
builder
.
toArray
(
new
MavenArtifact
[
builder
.
size
()]);
}
private
static
String
lineFix
(
String
input
)
{
...
...
@@ -234,4 +255,47 @@ public class Bootstrap {
Process
p
=
pb
.
start
();
p
.
waitFor
();
}
private
static
void
startUp
(
BootstrapClassLoader
bcl
,
String
[]
args
)
{
Thread
t
=
new
Thread
()
{
@Override@SuppressWarnings
(
"unchecked"
)
public
void
run
()
{
System
.
out
.
println
(
"Booting..."
);
Class
<?>
cls
=
null
;
try
{
cls
=
bcl
.
loadClass
(
"me.felinewith.lang_toolkit.apps.bootstrap.BootstrapApp"
);
}
catch
(
ClassNotFoundException
ex
)
{
Logger
.
getLogger
(
Bootstrap
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
return
;
}
Method
m
=
null
;
try
{
m
=
cls
.
getMethod
(
"init"
,
String
[].
class
);
}
catch
(
NoSuchMethodException
|
SecurityException
ex
)
{
Logger
.
getLogger
(
Bootstrap
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
return
;
}
Object
o
=
null
;
try
{
o
=
cls
.
newInstance
();
}
catch
(
InstantiationException
|
IllegalAccessException
ex
)
{
Logger
.
getLogger
(
Bootstrap
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
if
(
(
m
!=
null
)
&&
(
o
!=
null
)
)
{
try
{
m
.
invoke
(
o
,
(
Object
)
args
);
}
catch
(
IllegalAccessException
|
IllegalArgumentException
|
InvocationTargetException
ex
)
{
if
(
(
ex
instanceof
InvocationTargetException
)
&&
(
ex
.
getCause
()
!=
null
)
)
{
Logger
.
getLogger
(
Bootstrap
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
.
getCause
());
}
else
{
Logger
.
getLogger
(
Bootstrap
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
}
}
}
};
t
.
setName
(
"Bootstrap-Main"
);
t
.
setContextClassLoader
(
bcl
);
t
.
setDaemon
(
false
);
t
.
start
();
}
}
apps/bootstrap/src/main/java/me/felinewith/lang_toolkit/apps/bootstrap/BootstrapApp.java
0 → 100644
View file @
975a3e5
package
me
.
felinewith
.
lang_toolkit
.
apps
.
bootstrap
;
import
java.io.IOException
;
import
java.net.URL
;
import
java.util.Enumeration
;
import
java.util.Properties
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
/**
*
* @author jlhawkwell
*/
public
class
BootstrapApp
{
private
ClassLoader
cl
;
String
[]
args
;
public
static
void
init
(
String
[]
args
)
{
ClassLoader
cl
=
BootstrapApp
.
class
.
getClassLoader
();
Enumeration
<
URL
>
urls
=
null
;
try
{
urls
=
cl
.
getResources
(
"bootstrap/bootstrap.properties"
);
}
catch
(
IOException
ex
)
{
Logger
.
getLogger
(
BootstrapApp
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
Properties
props
=
new
Properties
();
URL
u
;
if
(
urls
!=
null
)
{
while
(
urls
.
hasMoreElements
()
)
{
u
=
urls
.
nextElement
();
try
{
props
.
load
(
u
.
openStream
());
}
catch
(
IOException
ex
)
{
Logger
.
getLogger
(
BootstrapApp
.
class
.
getName
()).
log
(
Level
.
WARNING
,
null
,
ex
);
}
}
// TODO: initialize app then iterate plugins
}
}
public
BootstrapApp
(
ClassLoader
classloader
,
String
[]
arguments
)
{
cl
=
classloader
;
args
=
arguments
;
}
}
apps/bootstrap/src/main/java/me/felinewith/lang_toolkit/apps/bootstrap/BootstrapClassLoader.java
View file @
975a3e5
This diff is collapsed.
Click to expand it.
apps/bootstrap/src/main/java/me/felinewith/lang_toolkit/apps/bootstrap/IStrappedApp.java
0 → 100644
View file @
975a3e5
package
me
.
felinewith
.
lang_toolkit
.
apps
.
bootstrap
;
/**
*
* @author jlhawkwell
*/
public
interface
IStrappedApp
{
public
void
preStart
();
public
void
registerPlugin
(
IStrappedPlugin
plugin
);
public
void
start
();
}
apps/bootstrap/src/main/java/me/felinewith/lang_toolkit/apps/bootstrap/IStrappedPlugin.java
0 → 100644
View file @
975a3e5
package
me
.
felinewith
.
lang_toolkit
.
apps
.
bootstrap
;
import
javax.swing.JButton
;
import
javax.swing.JFrame
;
import
javax.swing.JToolBar
;
/**
*
* @author jlhawkwell
*/
public
interface
IStrappedPlugin
{
public
String
getName
();
public
boolean
hasButton
();
public
boolean
hasToolBar
();
public
boolean
hasWindow
();
public
JButton
getButton
();
public
JToolBar
getToolBar
();
public
JFrame
getFrame
();
}
apps/bootstrap/src/main/java/me/felinewith/lang_toolkit/apps/bootstrap/util/MavenArtifact.java
View file @
975a3e5
...
...
@@ -50,7 +50,7 @@ public class MavenArtifact {
public
String
getLocation
()
{
if
(
!
isReady
(
)
)
{
return
""
;
}
if
(
!
isReady
()
)
{
return
""
;
}
StringBuilder
sb
=
new
StringBuilder
(
g
);
sb
.
append
(
":"
);
...
...
@@ -60,4 +60,23 @@ public class MavenArtifact {
return
sb
.
toString
();
}
public
String
getFileLocation
()
{
if
(
!
isReady
()
)
{
return
""
;
}
StringBuilder
sb
=
new
StringBuilder
(
System
.
getProperty
(
"user.home"
));
sb
.
append
(
"/.m2/repository/"
);
sb
.
append
(
g
.
replaceAll
(
"."
,
"/"
));
sb
.
append
(
"/"
);
sb
.
append
(
a
);
sb
.
append
(
"/"
);
sb
.
append
(
v
);
sb
.
append
(
"/"
);
sb
.
append
(
a
);
sb
.
append
(
"-"
);
sb
.
append
(
v
);
sb
.
append
(
".jar"
);
return
sb
.
toString
();
}
}
apps/langbuilder/pom.xml
0 → 100644
View file @
975a3e5
<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>
<artifactId>
langbuilder
</artifactId>
<packaging>
jar
</packaging>
<name>
LangBuilder
</name>
<version>
1.0-SNAPSHOT
</version>
<inceptionYear>
2017
</inceptionYear>
<description>
Language builder desktop app.
</description>
<parent>
<groupId>
me.felinewith
</groupId>
<artifactId>
lang-toolkit
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<relativePath>
../..
</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>
me.felinewith.lang_toolkit.apps
</groupId>
<artifactId>
bootstrap
</artifactId>
</dependency>
</dependencies>
</project>
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/LangBuilder.java
0 → 100644
View file @
975a3e5
package
me
.
felinewith
.
lang_toolkit
.
apps
.
langbuilder
;
import
java.util.HashMap
;
import
javax.swing.JFrame
;
import
me.felinewith.lang_toolkit.apps.bootstrap.IStrappedApp
;
import
me.felinewith.lang_toolkit.apps.bootstrap.IStrappedPlugin
;
/**
*
* @author jlhawkwell
*/
public
class
LangBuilder
implements
IStrappedApp
{
private
HashMap
<
String
,
IStrappedPlugin
>
plugins
;
private
JFrame
window
;
@Override
public
void
preStart
()
{
plugins
=
new
HashMap
<>();
window
=
new
JFrame
(
"LangBuilder"
);
// TODO: app settings, main window, toolbar menu
}
@Override
public
void
registerPlugin
(
IStrappedPlugin
plugin
)
{
}
@Override
public
void
start
()
{
}
}
apps/langbuilder/src/main/resources/bootstrap/bootstrap.properties
0 → 100644
View file @
975a3e5
app
=
me.felinewith.lang_toolkit.apps.langbuilder.LangBuilder
pom.xml
View file @
975a3e5
...
...
@@ -74,6 +74,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
<modules>
<module>
apps/bootstrap
</module>
<module>
apps/langbuilder
</module>
</modules>
<developers>
...
...
@@ -130,8 +131,6 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
<groupId>
org.apache.velocity
</groupId>
<artifactId>
velocity
</artifactId>
<version>
1.7
</version>
<scope>
runtime
</scope>
<type>
jar
</type>
</dependency>
<dependency>
<groupId>
org.testng
</groupId>
...
...
@@ -144,6 +143,11 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
<artifactId>
bootstrap
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
me.felinewith.lang_toolkit.apps
</groupId>
<artifactId>
langbuilder
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
</dependencies>
</dependencyManagement>
...
...
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