The Unified and Autonomous Development Platform
fix the slowly eat issue when switching between edit file and other tabs
robin shine4d5cae8a062d
diff --git a/commons.jetty/src/main/java/com/pmease/commons/jetty/JettyPlugin.java b/commons.jetty/src/main/java/com/pmease/commons/jetty/JettyPlugin.javaindex d9b72c3711..3c6286f530 100644--- a/commons.jetty/src/main/java/com/pmease/commons/jetty/JettyPlugin.java+++ b/commons.jetty/src/main/java/com/pmease/commons/jetty/JettyPlugin.java@@ -20,6 +20,8 @@ import com.pmease.commons.loader.AbstractPlugin;public class JettyPlugin extends AbstractPlugin {+ private static final int MAX_CONTENT_SIZE = 5000000;+private Server server;private ServletContextHandler contextHandler;@@ -71,6 +73,7 @@ public class JettyPlugin extends AbstractPlugin {server = new Server();contextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);+ contextHandler.setMaxFormContentSize(MAX_CONTENT_SIZE);contextHandler.setClassLoader(JettyPlugin.class.getClassLoader());diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/fileedit/FileEditPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/fileedit/FileEditPanel.htmlindex 44f5327728..977f376f30 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/fileedit/FileEditPanel.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/fileedit/FileEditPanel.html@@ -4,7 +4,7 @@<a class="active tab edit pull-left"><i class="fa fa-pencil"></i> Edit file</a><a wicket:id="previewLink" class="tab preview pull-left"><i class="fa fa-eye"></i> Preview changes</a><a wicket:id="saveLink" class="tab save pull-left"><i class="fa fa-floppy-o"></i> Save</a>- <a wicket:id="cancelLink" class="cancel pull-left">Cancel</a>+ <a wicket:id="cancelLink" class="cancel pull-left" tabindex="-1">Cancel</a></div><div class="body"><!-- below form is for dirty checking purpose and we can not use it as containingdiff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/fileedit/file-edit.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/fileedit/file-edit.cssindex 042f487370..a43f34ccce 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/fileedit/file-edit.css+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/fileedit/file-edit.css@@ -5,7 +5,7 @@}.file-edit>.head a.tab {color: #666;- margin-top: 6px;+ margin-top: 7px;padding: 4px 12px;text-decoration: none;}@@ -21,11 +21,11 @@color: #333;}.file-edit>.head a.cancel {- margin-top: 10px;+ margin-top: 11px;margin-left: 12px;}.file-edit>.body {- overflow: auto;+ overflow: hidden;}.file-edit>.body>.preview, .file-edit>.body>.save {display: none;diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/fileedit/file-edit.js b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/fileedit/file-edit.jsindex 6e5f628b19..b9fd2dc29f 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/fileedit/file-edit.js+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/fileedit/file-edit.js@@ -35,24 +35,16 @@ gitplex.fileEdit = {gitplex.fileEdit.setMode(cm, filePath);$head.find("a.edit").click(function() {- $head.find("a.tab").removeClass("active");- $(this).addClass("active");- $body.find(".preview").hide();- $body.find(".save").hide();- $edit.show();- $(window).resize();+ gitplex.fileEdit.selectTab($(this));});$head.find("a.preview").click(function() {previewCallback(cm.getValue());});$head.find("a.save").click(function() {saveCallback(cm.getValue());- $head.find("a.tab").removeClass("active");- $(this).addClass("active");});$fileEdit.on("autofit", function(event, width, height) {- console.log("autofit");event.stopPropagation();$fileEdit.outerWidth(width);$fileEdit.outerHeight(height);@@ -86,26 +78,10 @@ gitplex.fileEdit = {},save: function(containerId) {- var $container = $("#" + containerId);-- $container.find(">.file-edit>.head a.tab").removeClass("active");- $container.find(">.file-edit>.head a.save").addClass("active");-- $container.find(">.file-edit>.body>div.edit").hide();- $container.find(">.file-edit>.body>.preview").hide();- $container.find(">.file-edit>.body>.save").show();- $(window).resize();+ gitplex.fileEdit.selectTab($("#" + containerId + ">.file-edit>.head>.save"));},preview: function(containerId) {- var $container = $("#" + containerId);-- $container.find(">.file-edit>.head a.tab").removeClass("active");- $container.find(">.file-edit>.head a.preview").addClass("active");-- $container.find(">.file-edit>.body>div.edit").hide();- $container.find(">.file-edit>.body>.save").hide();- $container.find(">.file-edit>.body>.preview").show();- $(window).resize();+ gitplex.fileEdit.selectTab($("#" + containerId + ">.file-edit>.head>.preview"));},setMode: function(cm, filePath) {if (typeof cm === "string")@@ -120,5 +96,26 @@ gitplex.fileEdit = {cm.setOption("mode", modeInfo.mime);CodeMirror.autoLoadMode(cm, modeInfo.mode);}+ },+ selectTab: function($tab) {+ var $active = $tab.parent().find("a.tab.active");+ $active[0].hideableVisible = $(".hideable").is(":visible");+ $active.removeClass("active");+ $tab.addClass("active");+ if ($tab[0].hideableVisible != undefined) {+ if ($tab[0].hideableVisible)+ $(".hideable").show();+ else+ $(".hideable").hide();+ }+ var $body = $tab.closest(".file-edit").find(">.body");+ $body.find(">div").hide();+ if ($tab.hasClass("edit"))+ $body.find(">div.edit").show().find(">.CodeMirror")[0].CodeMirror.focus();+ else if ($tab.hasClass("preview"))+ $body.find(">div.preview").show();+ else+ $body.find(">div.save").show();+ $(window).resize();}}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/LastCommitPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/LastCommitPanel.javaindex e52f0fb91d..0351da2425 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/LastCommitPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/LastCommitPanel.java@@ -3,11 +3,8 @@ package com.pmease.gitplex.web.page.repository.file;import org.apache.wicket.markup.html.basic.Label;import org.apache.wicket.markup.html.form.TextField;import org.apache.wicket.markup.html.panel.Panel;-import org.apache.wicket.model.AbstractReadOnlyModel;import org.apache.wicket.model.IModel;-import org.apache.wicket.model.LoadableDetachableModel;import org.apache.wicket.model.Model;-import org.eclipse.jgit.lib.PersonIdent;import com.pmease.commons.git.BlobIdent;import com.pmease.commons.git.Commit;@@ -21,50 +18,28 @@ class LastCommitPanel extends Panel {private final IModel<Repository> repoModel;- private final BlobIdent blob;-- private final IModel<Commit> commitModel = new LoadableDetachableModel<Commit>() {-- @Override- protected Commit load() {- // call git command line for performance reason- return repoModel.getObject().git().log(null, blob.revision, blob.path, 1, 0).iterator().next();- }-- };+ private final Commit commit;public LastCommitPanel(String id, IModel<Repository> repoModel, BlobIdent blob) {super(id);this.repoModel = repoModel;- this.blob = blob;++ // call git command line for performance reason+ commit = repoModel.getObject().git().log(null, blob.revision, blob.path, 1, 0).iterator().next();}@Overrideprotected void onInitialize() {super.onInitialize();- add(new PersonLink("author", new AbstractReadOnlyModel<PersonIdent>() {-- @Override- public PersonIdent getObject() {- return commitModel.getObject().getAuthor();- }-- }));+ add(new PersonLink("author", Model.of(commit.getAuthor())));- add(new Label("date", new AbstractReadOnlyModel<String>() {-- @Override- public String getObject() {- return DateUtils.formatAge(commitModel.getObject().getAuthor().getWhen());- }-- }));+ add(new Label("date", Model.of(DateUtils.formatAge(commit.getAuthor().getWhen()))));- add(new CommitMessagePanel("message", repoModel, commitModel));+ add(new CommitMessagePanel("message", repoModel, Model.of(commit)));- add(new TextField<String>("hash", Model.of(commitModel.getObject().getHash())));+ add(new TextField<String>("hash", Model.of(commit.getHash())));setOutputMarkupId(true);}@@ -72,7 +47,6 @@ class LastCommitPanel extends Panel {@Overrideprotected void onDetach() {repoModel.detach();- commitModel.detach();super.onDetach();}