diff options
author | James Moger <james.moger@gitblit.com> | 2011-10-05 22:22:43 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2011-10-05 22:22:43 -0400 |
commit | 841651baee2181c1543555d1eabcd0e4fee48827 (patch) | |
tree | f6a60ba2f468c52e983f051e6fe30c9178ea696e /src/com/gitblit/client/GitblitClientLauncher.java | |
parent | 4b0e0641076f802e8da1695fe8a40ff7646b811a (diff) | |
download | gitblit-841651baee2181c1543555d1eabcd0e4fee48827.tar.gz gitblit-841651baee2181c1543555d1eabcd0e4fee48827.zip |
New setting to disable RPC administration. Advancing the RPC client.
Diffstat (limited to 'src/com/gitblit/client/GitblitClientLauncher.java')
-rw-r--r-- | src/com/gitblit/client/GitblitClientLauncher.java | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/src/com/gitblit/client/GitblitClientLauncher.java b/src/com/gitblit/client/GitblitClientLauncher.java new file mode 100644 index 00000000..19e9efd8 --- /dev/null +++ b/src/com/gitblit/client/GitblitClientLauncher.java @@ -0,0 +1,105 @@ +/*
+ * Copyright 2011 gitblit.com.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gitblit.client;
+
+import java.awt.Color;
+import java.awt.EventQueue;
+import java.awt.FontMetrics;
+import java.awt.Graphics2D;
+import java.awt.SplashScreen;
+import java.io.File;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+
+import com.gitblit.Launcher;
+import com.gitblit.build.Build;
+import com.gitblit.build.Build.DownloadListener;
+
+/**
+ * Downloads dependencies and launches RPC client.
+ *
+ * @author James Moger
+ *
+ */
+public class GitblitClientLauncher {
+
+ public static void main(String[] args) {
+ final SplashScreen splash = SplashScreen.getSplashScreen();
+
+ DownloadListener downloadListener = new DownloadListener() {
+ @Override
+ public void downloading(String name) {
+ updateSplash(splash, "Downloading " + name + "...");
+ }
+ };
+
+ // download rpc client runtime dependencies
+ Build.rpcClient(downloadListener);
+
+ updateSplash(splash, "Scanning Library Folder...");
+ File libFolder = new File("ext");
+ List<File> jars = Launcher.findJars(libFolder.getAbsoluteFile());
+
+ // sort the jars by name and then reverse the order so the newer version
+ // of the library gets loaded in the event that this is an upgrade
+ Collections.sort(jars);
+ Collections.reverse(jars);
+ for (File jar : jars) {
+ try {
+ updateSplash(splash, "Loading " + jar.getName() + "...");
+ Launcher.addJarFile(jar);
+ } catch (IOException e) {
+
+ }
+ }
+
+ updateSplash(splash, "Starting Gitblit RPC Client...");
+ GitblitClient.main(args);
+ }
+
+ private static void updateSplash(final SplashScreen splash, final String string) {
+ if (splash == null) {
+ return;
+ }
+ try {
+ EventQueue.invokeAndWait(new Runnable() {
+ public void run() {
+ Graphics2D g = splash.createGraphics();
+ if (g != null) {
+ // Splash is 320x120
+ FontMetrics fm = g.getFontMetrics();
+ g.setColor(Color.darkGray);
+ int h = fm.getHeight() + fm.getMaxDescent();
+ int x = 5;
+ int y = 115;
+ int w = 320 - 2 * x;
+ g.fillRect(x, y - h, w, h);
+ g.setColor(Color.lightGray);
+ g.drawRect(x, y - h, w, h);
+ g.setColor(Color.WHITE);
+ int xw = fm.stringWidth(string);
+ g.drawString(string, x + ((w - xw) / 2), y - 5);
+ g.dispose();
+ splash.update();
+ }
+ }
+ });
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
+}
|