The Unified and Autonomous Development Platform
midwork
robin shine2f1d85988416
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeComment.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeComment.javaindex c67ece7809..7a336d0547 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeComment.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeComment.java@@ -21,7 +21,7 @@ import com.pmease.commons.git.BlobIdent;import com.pmease.commons.hibernate.AbstractEntity;import com.pmease.commons.hibernate.dao.Dao;import com.pmease.gitplex.core.GitPlex;-import com.pmease.gitplex.core.entity.component.TokenRange;+import com.pmease.gitplex.core.entity.component.TextRange;/** @DynamicUpdate annotation here along with various @OptimisticLock annotations@@ -65,7 +65,7 @@ public class CodeComment extends AbstractEntity {@OptimisticLock(excluded=true)@Embedded- private TokenRange textRange;+ private TextRange textRange;@OptimisticLock(excluded=true)private String compareCommit;@@ -130,14 +130,14 @@ public class CodeComment extends AbstractEntity {/*** @return the textRange*/- public TokenRange getTextRange() {+ public TextRange getTextRange() {return textRange;}/*** @param textRange the textRange to set*/- public void setTextRange(TokenRange textRange) {+ public void setTextRange(TextRange textRange) {this.textRange = textRange;}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/component/TokenRange.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/component/TextRange.javasimilarity index 52%rename from gitplex.core/src/main/java/com/pmease/gitplex/core/entity/component/TokenRange.javarename to gitplex.core/src/main/java/com/pmease/gitplex/core/entity/component/TextRange.javaindex ff9b7b343e..a6b1a7115e 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/component/TokenRange.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/component/TextRange.java@@ -1,14 +1,14 @@package com.pmease.gitplex.core.entity.component;-public class TokenRange {+public class TextRange {private Integer beginLine;- private Integer beginToken;+ private Integer beginChar;private Integer endLine;- private Integer endToken;+ private Integer endChar;/*** @return the beginLine@@ -25,17 +25,17 @@ public class TokenRange {}/**- * @return the beginToken+ * @return the beginChar*/- public Integer getBeginToken() {- return beginToken;+ public Integer getBeginChar() {+ return beginChar;}/**- * @param beginToken the beginToken to set+ * @param beginChar the beginChar to set*/- public void setBeginToken(Integer beginToken) {- this.beginToken = beginToken;+ public void setBeginChar(Integer beginChar) {+ this.beginChar = beginChar;}/**@@ -53,17 +53,17 @@ public class TokenRange {}/**- * @return the endToken+ * @return the endChar*/- public Integer getEndToken() {- return endToken;+ public Integer getEndChar() {+ return endChar;}/**- * @param endToken the endToken to set+ * @param endChar the endChar to set*/- public void setEndToken(Integer endToken) {- this.endToken = endToken;+ public void setEndChar(Integer endChar) {+ this.endChar = endChar;}}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/text-diff.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/text-diff.cssindex a4170a27f4..3a86ec1b41 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/text-diff.css+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/text-diff.css@@ -1,6 +1,8 @@.text-diff {border: 1px solid #D8D8D8;border-radius: 4px;+ z-index: 10;+ position: relative;}.text-diff>.head {padding: 8px;diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/text-diff.js b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/text-diff.jsindex 764f3b3c44..30539433ac 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/text-diff.js+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/text-diff.js@@ -22,3 +22,7 @@ gitplex.textdiff = {});}}+$(document).on("mouseup", function() {+ console.log(window.getSelection().anchorNode);+ console.log(window.getSelection().anchorOffset);+});diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/source/SourceViewPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/source/SourceViewPanel.javaindex 6383fc766d..534b3edc68 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/source/SourceViewPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/source/SourceViewPanel.java@@ -42,6 +42,7 @@ import com.pmease.commons.lang.extractors.Symbol;import com.pmease.commons.util.Range;import com.pmease.commons.wicket.assets.codemirror.CodeMirrorResourceReference;import com.pmease.commons.wicket.assets.cookies.CookiesResourceReference;+import com.pmease.commons.wicket.assets.uri.URIResourceReference;import com.pmease.commons.wicket.component.menu.MenuItem;import com.pmease.commons.wicket.component.menu.MenuLink;import com.pmease.gitplex.core.GitPlex;@@ -213,6 +214,8 @@ public class SourceViewPanel extends BlobViewPanel {public void renderHead(IHeaderResponse response) {super.renderHead(response);+ response.render(JavaScriptHeaderItem.forReference(URIResourceReference.INSTANCE));+response.render(JavaScriptHeaderItem.forReference(CookiesResourceReference.INSTANCE));response.render(JavaScriptHeaderItem.forReference(CodeMirrorResourceReference.INSTANCE));diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/source/source-view.js b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/source/source-view.jsindex 8cfcdbe3b3..9a03cdb87e 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/source/source-view.js+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/source/source-view.js@@ -65,6 +65,21 @@ gitplex.sourceview = {gitplex.sourceview.blame(cm, blameCommits);}, 10);}++ $code.on("mouseup keyup", function() {+ var from = cm.getCursor("from");+ var to = cm.getCursor("to");+ if (from.line != to.line || from.ch != to.ch) {+ var ch = (from.ch + to.ch)/2;+ var position = cm.charCoords({line:from.line, ch:ch});+ var uri = URI(window.location.href);+ uri.removeSearch("mark").addSearch("mark",+ (from.line+1) + "," + (from.ch+1) + "-" + (to.line+1) + "," + (to.ch+1));+ $("#selection-popup").data("show")(position, uri.toString(), function(){});+ } else {+ $("#selection-popup").hide();+ }+ });$code.mouseover(function(e) {var node = e.target || e.srcElement, $node = $(node);diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/depot-file.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/depot-file.cssindex 26f7c120f3..23375d927b 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/depot-file.css+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/depot-file.css@@ -125,3 +125,30 @@.floating>.content>ul.contributors>li>a:hover {background: #EEE;}++#selection-popup {+ z-index: 10000;+ position: absolute;+}+#selection-popup>.content {+ background: #333;+ border-radius: 6px;+ padding: 12px;+}+#selection-popup>.content a {+ color: white;+ display: block;+ white-space: nowrap;+}+#selection-popup>.content>a.link {+ margin-bottom: 8px;+}+#selection-popup>.triangle {+ position: relative;+ left: 50%;+ width: 0;+ height: 0;+ border-left: 6px solid transparent;+ border-right: 6px solid transparent;+ border-top: 6px solid #333;+}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/depot-file.js b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/depot-file.jsindex d08058cccb..77a2e2f290 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/depot-file.js+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/depot-file.js@@ -66,4 +66,23 @@ $(window).load(function() {$fileViewer.closestDescendant(".autofit:visible").trigger("autofit", [$fileViewer.width(), $fileViewer.height()]);});$(window).resize();++ $("body").append("" ++ "<div id='selection-popup'>" ++ "<div class='content'>" ++ "<a class='link'><i class='fa fa-link'></i> Permanent link of this selection</a>" ++ "<a class='comment'><i class='fa fa-comment'></i> Add comment for this selection</a>" ++ "</div>" ++ "<div class='triangle'></div>" ++ "</div>");++ var $selectionPopup = $("#selection-popup");+ $selectionPopup.data("show", function(position, selectionUrl, commentCallback) {+ var alignment = {+ target: {left: position.left, top: position.top, width: 0, height: 0},+ placement: {x: 50, y: 100, targetX: 0, targetY: 0}};+ $selectionPopup.show().align(alignment);+ $selectionPopup.find(".link").attr("href", selectionUrl);+ $selectionPopup.find(".comment").click(commentCallback);+ });});