The Unified and Autonomous Development Platform
midwork
robin shine59a5089a2895
diff --git a/commons.lang/src/main/java/com/pmease/commons/lang/tokenizers/CmToken.java b/commons.lang/src/main/java/com/pmease/commons/lang/tokenizers/CmToken.javaindex aa56b7e4f7..99df7c22ca 100644--- a/commons.lang/src/main/java/com/pmease/commons/lang/tokenizers/CmToken.java+++ b/commons.lang/src/main/java/com/pmease/commons/lang/tokenizers/CmToken.java@@ -1,169 +1,173 @@-package com.pmease.commons.lang.tokenizers;--import java.io.Serializable;--import org.apache.commons.lang3.StringEscapeUtils;-import org.apache.commons.lang3.StringUtils;--import com.google.common.base.Objects;-import com.google.common.base.Splitter;-import com.pmease.commons.lang.diff.DiffMatchPatch.Operation;--/**- * Represents a CodeMirror token- *- * @author robin- *- */-public class CmToken implements Serializable {-- private static final long serialVersionUID = 1L;-- private final String type;-- private final String text;-- public CmToken(String type, String text) {- this.type = type;- this.text = text;- }-- public String getType() {- return type;- }-- public String getText() {- return text;- }-- public boolean isComment() {- return type.contains("comment");- }-- public boolean isKeyword() {- return type.contains("keyword");- }-- public boolean isNumber() {- return type.contains("number");- }-- public boolean isIdentifier() {- return type.contains("variable");- }-- public boolean isString() {- return type.contains("string");- }-- public boolean isMeta() {- return type.contains("meta");- }-- public boolean isTag() {- return type.contains("tag");- }-- public boolean isBracket() {- return type.contains("bracket");- }-- public boolean isOperator() {- return type.contains("operator");- }-- public boolean isAtom() {- return type.contains("atom");- }-- public boolean isDef() {- return type.contains("def");- }-- public boolean isQualifier() {- return type.contains("qualifier");- }-- public boolean isAttribute() {- return type.contains("attribute");- }-- public boolean isProperty() {- return type.contains("property");- }-- public boolean isBuiltin() {- return type.contains("builtin");- }-- public boolean isLink() {- return type.contains("link");- }-- public boolean isError() {- return type.contains("error");- }-- public boolean isNotCommentOrString() {- return !isComment() && !isString();- }-- public boolean isEof() {- return type.length() == 0 && text.length() == 0;- }-- public boolean isEol() {- return type.length() == 0 && text.equals("\n");- }-- public boolean isWhitespace() {- if (type.length() != 0)- return false;- for (char ch: text.toCharArray()) {- if (ch != ' ' && ch != '\n' && ch != '\r' && ch != '\t')- return false;- }- return true;- }-- public boolean equals(Object other) {- if (!(other instanceof CmToken))- return false;- if (this == other)- return true;- CmToken otherToken = (CmToken) other;- return Objects.equal(type, otherToken.type) && Objects.equal(text, otherToken.text);- }-- public int hashCode() {- return Objects.hashCode(type, text);- }-- public String toHtml(Operation operation) {- String escapedText = StringEscapeUtils.escapeHtml4(text);-- if (operation == Operation.EQUAL && StringUtils.isBlank(type)) {- return escapedText;- } else {- StringBuilder builder = new StringBuilder("<span class='");- for (String each: Splitter.on(" ").trimResults().omitEmptyStrings().split(type))- builder.append("cm-" + each + " ");- if (operation == Operation.DELETE)- builder.append("delete");- else if (operation == Operation.INSERT)- builder.append("insert");- builder.append("'>").append(escapedText).append("</span>");- return builder.toString();- }-- }-- @Override- public String toString() {- if (StringUtils.isNotBlank(type))- return text + "[" + type + "]";- else- return text;- }--}+package com.pmease.commons.lang.tokenizers;++import java.io.Serializable;++import org.apache.commons.lang3.StringEscapeUtils;+import org.apache.commons.lang3.StringUtils;++import com.google.common.base.Objects;+import com.google.common.base.Splitter;+import com.pmease.commons.lang.diff.DiffMatchPatch.Operation;++/**+ * Represents a CodeMirror token+ *+ * @author robin+ *+ */+public class CmToken implements Serializable {++ private static final long serialVersionUID = 1L;++ private final String type;++ private final String text;++ public CmToken(String type, String text) {+ this.type = type;+ this.text = text;+ }++ public String getType() {+ return type;+ }++ public String getText() {+ return text;+ }++ public boolean isComment() {+ return type.contains("comment");+ }++ public boolean isKeyword() {+ return type.contains("keyword");+ }++ public boolean isNumber() {+ return type.contains("number");+ }++ public boolean isIdentifier() {+ return type.contains("variable");+ }++ public boolean isString() {+ return type.contains("string");+ }++ public boolean isMeta() {+ return type.contains("meta");+ }++ public boolean isTag() {+ return type.contains("tag");+ }++ public boolean isBracket() {+ return type.contains("bracket");+ }++ public boolean isOperator() {+ return type.contains("operator");+ }++ public boolean isAtom() {+ return type.contains("atom");+ }++ public boolean isDef() {+ return type.contains("def");+ }++ public boolean isQualifier() {+ return type.contains("qualifier");+ }++ public boolean isAttribute() {+ return type.contains("attribute");+ }++ public boolean isProperty() {+ return type.contains("property");+ }++ public boolean isBuiltin() {+ return type.contains("builtin");+ }++ public boolean isLink() {+ return type.contains("link");+ }++ public boolean isError() {+ return type.contains("error");+ }++ public boolean isNotCommentOrString() {+ return !isComment() && !isString();+ }++ public boolean isEof() {+ return type.length() == 0 && text.length() == 0;+ }++ public boolean isEol() {+ return type.length() == 0 && text.equals("\n");+ }++ public boolean isWhitespace() {+ if (type.length() != 0)+ return false;+ for (char ch: text.toCharArray()) {+ if (ch != ' ' && ch != '\n' && ch != '\r' && ch != '\t')+ return false;+ }+ return true;+ }++ public boolean equals(Object other) {+ if (!(other instanceof CmToken))+ return false;+ if (this == other)+ return true;+ CmToken otherToken = (CmToken) other;+ return Objects.equal(type, otherToken.type) && Objects.equal(text, otherToken.text);+ }++ public int hashCode() {+ return Objects.hashCode(type, text);+ }++ public String toHtml(Operation operation) {+ String escapedText;+ if (text.equals("\f"))+ escapedText = "";+ else+ escapedText = StringEscapeUtils.escapeHtml4(text);++ if (operation == Operation.EQUAL && StringUtils.isBlank(type)) {+ return escapedText;+ } else {+ StringBuilder builder = new StringBuilder("<span class='");+ for (String each: Splitter.on(" ").trimResults().omitEmptyStrings().split(type))+ builder.append("cm-" + each + " ");+ if (operation == Operation.DELETE)+ builder.append("delete");+ else if (operation == Operation.INSERT)+ builder.append("insert");+ builder.append("'>").append(escapedText).append("</span>");+ return builder.toString();+ }++ }++ @Override+ public String toString() {+ if (StringUtils.isNotBlank(type))+ return text + "[" + type + "]";+ else+ return text;+ }++}diff --git a/gitplex.product/src/test/java/gitplex/product/Test.java b/gitplex.product/src/test/java/gitplex/product/Test.javaindex aa23c287ac..987a09f8d3 100644--- a/gitplex.product/src/test/java/gitplex/product/Test.java+++ b/gitplex.product/src/test/java/gitplex/product/Test.java@@ -1,11 +1,16 @@package gitplex.product;+import java.io.File;import java.io.IOException;+import com.pmease.commons.util.FileUtils;+public class Test {@org.junit.Testpublic void test() throws IOException {+ System.out.println("hello\fworld");+ FileUtils.writeFile(new File("w:\\temp\\formfeed"), "hello\fworld");}}\ No newline at end of filediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/RepoCommitPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/RepoCommitPage.javaindex 99fc6b8595..d15c190ba7 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/RepoCommitPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/RepoCommitPage.java@@ -224,7 +224,7 @@ public class RepoCommitPage extends RepositoryPage {}));} else {- add(new WebMarkupContainer("compareWith").setVisible(false));+ add(new WebMarkupContainer("parentChoice").setVisible(false));}if (getCommit().getParentCount() != 0) {diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/test/TestPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/test/TestPage.htmlindex f8e63ab583..f8fafd68ce 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/test/TestPage.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/test/TestPage.html@@ -1,3 +1,3 @@<wicket:extend>- <select wicket:id="choice"></select>+ <a wicket:id="test">test</a></wicket:extend>\ No newline at end of filediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/test/TestPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/test/TestPage.javaindex f5f60a6087..0cfaa2ebb7 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/test/TestPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/test/TestPage.java@@ -1,46 +1,29 @@package com.pmease.gitplex.web.page.test;-import org.apache.wicket.ajax.AjaxRequestTarget;-import org.apache.wicket.ajax.form.OnChangeAjaxBehavior;-import org.apache.wicket.markup.html.form.DropDownChoice;-import org.apache.wicket.model.IModel;+import org.apache.wicket.markup.html.link.Link;-import com.google.common.collect.Lists;+import com.pmease.commons.hibernate.dao.Dao;+import com.pmease.gitplex.core.GitPlex;+import com.pmease.gitplex.core.manager.AuxiliaryManager;+import com.pmease.gitplex.core.model.Repository;import com.pmease.gitplex.web.page.base.BasePage;@SuppressWarnings("serial")public class TestPage extends BasePage {- private String choice = "a";-@Overrideprotected void onInitialize() {super.onInitialize();- add(new DropDownChoice<String>("choice", new IModel<String>() {+ add(new Link<Void>("test") {@Override- public void detach() {- }-- @Override- public String getObject() {- return choice;- }-- @Override- public void setObject(String object) {- choice = object;- }-- }, Lists.newArrayList("a", "b")).add(new OnChangeAjaxBehavior() {-- @Override- protected void onUpdate(AjaxRequestTarget target) {- System.out.println(choice);+ public void onClick() {+ Repository repo = GitPlex.getInstance(Dao.class).load(Repository.class, 1L);+ GitPlex.getInstance(AuxiliaryManager.class).check(repo, "master");}- }));+ });}}