Permalink
Browse files

* add batch console

  • Loading branch information...
1 parent 9b0c1bd commit 777d5c1ff15df91c6ec9996cb7816e443a8465a1 @argan committed Apr 28, 2012
View
5 TODO
@@ -12,4 +12,7 @@
* modify all method name in class/interface hiberarchy
* delete upload files _done_
* BUG: doesn't show JDK class as base class _done_
-
+* compare to class trees and modify classes associate the tree
+* integrate a decompiler
+* add a rename script console _done_
+*
View
10 pom.xml
@@ -99,10 +99,14 @@
<url>http://scala-tools.org/repo-releases</url>
</repository>
<repository>
- <id>maven-repos</id>
+ <id>maven-repos1</id>
<url>http://repo1.maven.org/maven2/</url>
</repository>
<repository>
+ <id>maven-repos2</id>
+ <url>http://repo2.maven.org/maven2/</url>
+ </repository>
+ <repository>
<id>spring-milestone</id>
<url>http://repo.springsource.org/release</url>
</repository>
@@ -168,9 +172,9 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>bouncycastle</groupId>
+ <groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk14</artifactId>
- <version>136</version>
+ <version>1.38</version>
<scope>test</scope>
</dependency>
</dependencies>
@@ -8,6 +8,7 @@
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
@Controller
@@ -36,8 +37,37 @@ public String editClass(Model model, @RequestParam("id") String jar, @RequestPar
renameConfig = renameConfig.trim();
renameConfig = "class: " + clazzName + " to " + newClassName + "\n" + renameConfig;
- Database.save("changelog-" + jar, Database.Util.nextId(), renameConfig);
+ executeRename(jar, renameConfig);
+ return "redirect:/jarviewer/view.htm";// ?id=" + jar + "&clz=" +
+ // newClassName;
+ }
+
+ @RequestMapping(value = "/script", method = RequestMethod.GET)
+ public void script(Model model, @RequestParam("id") String jar) {
+ model.addAttribute("id", jar);
+ if (Database.get(jar) != null) {
+ FileItem path = (FileItem) Database.get(jar).getObj();
+ model.addAttribute("jarFile", path);
+ }
+ }
+
+ @RequestMapping(value = "/batch", method = RequestMethod.POST)
+ public String batch(Model model, @RequestParam("id") String jar, @RequestParam("renameConfig") String renameConfig) {
+ model.addAttribute("id", jar);
+
+ if (Database.get(jar) != null) {
+ FileItem path = (FileItem) Database.get(jar).getObj();
+ model.addAttribute("jarFile", path);
+ }
+ if (renameConfig != null && renameConfig.length() > 0) {
+ RenameConfig config = executeRename(jar, renameConfig);
+ model.addAttribute("renameConfig", config);
+ }
+ return "/renamer/script";
+ }
+
+ private RenameConfig executeRename(String jar, String renameConfig) {
RenameConfig config = RenameConfig.loadFromString(renameConfig);
FileItem path = (FileItem) Database.get(jar).getObj();
@@ -55,8 +85,9 @@ public String editClass(Model model, @RequestParam("id") String jar, @RequestPar
}
Renamer.rename(config, oldjar, filePath);
path.setFulleName(filePath);
+ Database.save("changelog-" + jar, Database.Util.nextId(), renameConfig);
Database.save("file", jar, path);
- return "redirect:/jarviewer/view.htm";// ?id=" + jar + "&clz=" +
- // newClassName;
+
+ return config;
}
}
@@ -136,7 +136,8 @@ private static void parse(RenameConfig config, Reader readerx) {
String line = null;
String currentClass = null;
while ((line = reader.readLine()) != null) {
- line = line.trim();
+ line = line.trim().replace('.', '/');
+
if (line.length() == 0)
continue;
String[] tokens = Utils.tokens(line);
@@ -29,7 +29,7 @@
<h3>Please upload a file</h3>
<form method="post" action="/jarviewer/upload.htm" enctype="multipart/form-data">
<input type="file" name="file"/>
- <input type="submit" class="btn primary" value="上传"/>
+ <input type="submit" class="btn primary" value="Upload File"/>
</form>
</div>
#include("/footer.vm")
@@ -69,6 +69,7 @@
<a href="/jarviewer/download.htm?id=$f.id">下载</a>&nbsp;
<a href="/jarviewer/graph.htm?id=$f.id" target="blank">依赖图</a>&nbsp;
<a href="/jarviewer/delete.htm?id=$f.id" onclick="return confirm('真的要删除$!f.obj.origName么?');">删除</a>&nbsp;
+ <a href="/renamer/script.htm?id=$f.id" target="blank">执行脚本</a>&nbsp;
</td>
</tr>
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Batch Rename Script</title>
+ <meta name="author" content="Argan Wang">
+
+ <!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
+ <!--[if lt IE 9]>
+ <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
+ <![endif]-->
+ <!-- Le styles -->
+ <link href="/static/css/bootstrap-1.4.0.css" rel="stylesheet">
+ <style type="text/css">
+ body {
+ padding-top: 60px;
+ }
+ #fromJar { float: right; width: 300px; height: 50px; background: #ccc; font-size:16px}
+ #libJars { float: right; width: 300px; height: 100px; border: 1px solid #999; font-size:16px}
+ #btnSubmit {float:right}
+ </style>
+ <!-- Le fav and touch icons -->
+ <link rel="shortcut icon" href="images/favicon.ico">
+ </head>
+#macro(esc $name)
+$name.replace("<","&lt;").replace(">","&gt;")
+#end
+ <body>
+ #include("/menu.vm")
+ <div class="content">
+ <div class="row">
+ <!-- Main hero unit for a primary marketing message or call to action -->
+ <div class="hero-unit">
+ <h3>在$jarFile.origName 中执行Rename Script:</h3>
+ <form id="batch_form" method="POST" action="/renamer/batch.htm?id=$id">
+ <textarea name="renameConfig" ></textarea>
+ <input type="submit" name="submit" value="Execute Script" class="btn primary">
+ </form>
+ #if ($renameConfig)
+ Done.
+ #end
+ </div>
+ </div>
+ </div>
+
+ #include("/footer.vm")
+ </body>
+</html>

0 comments on commit 777d5c1

Please sign in to comment.