commit | author | age
|
841651
|
1 |
/*
|
JM |
2 |
* Copyright 2011 gitblit.com.
|
|
3 |
*
|
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5 |
* you may not use this file except in compliance with the License.
|
|
6 |
* You may obtain a copy of the License at
|
|
7 |
*
|
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9 |
*
|
|
10 |
* Unless required by applicable law or agreed to in writing, software
|
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13 |
* See the License for the specific language governing permissions and
|
|
14 |
* limitations under the License.
|
|
15 |
*/
|
|
16 |
package com.gitblit.client;
|
|
17 |
|
|
18 |
import java.awt.Color;
|
|
19 |
import java.awt.EventQueue;
|
|
20 |
import java.awt.FontMetrics;
|
|
21 |
import java.awt.Graphics2D;
|
|
22 |
import java.awt.SplashScreen;
|
|
23 |
import java.io.File;
|
|
24 |
import java.io.IOException;
|
|
25 |
import java.util.Collections;
|
|
26 |
import java.util.List;
|
|
27 |
|
da0269
|
28 |
import com.gitblit.Constants;
|
841651
|
29 |
import com.gitblit.Launcher;
|
JM |
30 |
import com.gitblit.build.Build;
|
|
31 |
import com.gitblit.build.Build.DownloadListener;
|
|
32 |
|
|
33 |
/**
|
a7a9f7
|
34 |
* Downloads dependencies and launches Gitblit Manager.
|
841651
|
35 |
*
|
JM |
36 |
* @author James Moger
|
|
37 |
*
|
|
38 |
*/
|
a7a9f7
|
39 |
public class GitblitManagerLauncher {
|
841651
|
40 |
|
JM |
41 |
public static void main(String[] args) {
|
|
42 |
final SplashScreen splash = SplashScreen.getSplashScreen();
|
|
43 |
|
|
44 |
DownloadListener downloadListener = new DownloadListener() {
|
|
45 |
@Override
|
|
46 |
public void downloading(String name) {
|
b2fde8
|
47 |
updateSplash(splash, Translation.get("gb.downloading") + " " + name);
|
841651
|
48 |
}
|
JM |
49 |
};
|
|
50 |
|
|
51 |
// download rpc client runtime dependencies
|
a7a9f7
|
52 |
Build.manager(downloadListener);
|
841651
|
53 |
|
JM |
54 |
File libFolder = new File("ext");
|
|
55 |
List<File> jars = Launcher.findJars(libFolder.getAbsoluteFile());
|
|
56 |
|
|
57 |
// sort the jars by name and then reverse the order so the newer version
|
|
58 |
// of the library gets loaded in the event that this is an upgrade
|
|
59 |
Collections.sort(jars);
|
|
60 |
Collections.reverse(jars);
|
|
61 |
for (File jar : jars) {
|
|
62 |
try {
|
b7f591
|
63 |
updateSplash(splash, Translation.get("gb.loading") + " " + jar.getName() + "...");
|
841651
|
64 |
Launcher.addJarFile(jar);
|
JM |
65 |
} catch (IOException e) {
|
|
66 |
|
|
67 |
}
|
|
68 |
}
|
|
69 |
|
a7a9f7
|
70 |
updateSplash(splash, Translation.get("gb.starting") + " Gitblit Manager...");
|
JM |
71 |
GitblitManager.main(args);
|
841651
|
72 |
}
|
JM |
73 |
|
|
74 |
private static void updateSplash(final SplashScreen splash, final String string) {
|
|
75 |
if (splash == null) {
|
|
76 |
return;
|
|
77 |
}
|
|
78 |
try {
|
|
79 |
EventQueue.invokeAndWait(new Runnable() {
|
|
80 |
public void run() {
|
|
81 |
Graphics2D g = splash.createGraphics();
|
|
82 |
if (g != null) {
|
|
83 |
// Splash is 320x120
|
|
84 |
FontMetrics fm = g.getFontMetrics();
|
da0269
|
85 |
|
JM |
86 |
// paint startup status
|
841651
|
87 |
g.setColor(Color.darkGray);
|
JM |
88 |
int h = fm.getHeight() + fm.getMaxDescent();
|
|
89 |
int x = 5;
|
|
90 |
int y = 115;
|
|
91 |
int w = 320 - 2 * x;
|
|
92 |
g.fillRect(x, y - h, w, h);
|
|
93 |
g.setColor(Color.lightGray);
|
|
94 |
g.drawRect(x, y - h, w, h);
|
|
95 |
g.setColor(Color.WHITE);
|
|
96 |
int xw = fm.stringWidth(string);
|
|
97 |
g.drawString(string, x + ((w - xw) / 2), y - 5);
|
da0269
|
98 |
|
JM |
99 |
// paint version
|
|
100 |
String ver = "v" + Constants.VERSION;
|
|
101 |
int vw = g.getFontMetrics().stringWidth(ver);
|
|
102 |
g.drawString(ver, 320 - vw - 5, 34);
|
841651
|
103 |
g.dispose();
|
JM |
104 |
splash.update();
|
|
105 |
}
|
|
106 |
}
|
|
107 |
});
|
|
108 |
} catch (Throwable t) {
|
|
109 |
t.printStackTrace();
|
|
110 |
}
|
|
111 |
}
|
|
112 |
}
|