Skip to content

The Unified and Autonomous Development Platform

Display search result in repo file page.

robin shine5162e8c88e59
diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/assets/codemirror/codemirror.css b/commons.wicket/src/main/java/com/pmease/commons/wicket/assets/codemirror/codemirror.css
index e4a9440cd0..e2b7d1a825 100644
--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/assets/codemirror/codemirror.css
+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/assets/codemirror/codemirror.css
@@ -1,13 +1,35 @@
-.cm-identifierhighlight {background: #D0D0D0;}
-.CodeMirror-selected {background-color: #3399FF !important;}
-.CodeMirror-selectedtext {color: white !important;}
-.CodeMirror-simplescroll-horizontal {height: 16px;}
-.CodeMirror-simplescroll-vertical {width: 16px;}
+.cm-identifierhighlight {
+ background: #D0D0D0;
+}
+.CodeMirror-selected {
+ background-color: #3399FF !important;
+}
+.CodeMirror-selectedtext {
+ color: white !important;
+}
.CodeMirror-simplescroll-horizontal div, .CodeMirror-simplescroll-vertical div {
- background: none repeat scroll 0 0 #bbb; border: 1px solid #aaa;}
-.cm-s-eclipse .CodeMirror-matchingbracket {outline: none; color: black !important; font-weight: bold;}
-.cm-s-eclipse span.cm-meta {color: #888;}
+ background: none repeat scroll 0 0 #bbb;
+ border: 1px solid #aaa;
+}
+.cm-s-eclipse .CodeMirror-matchingbracket {
+ outline: none;
+ color: black !important;
+ font-weight: bold;
+}
+.cm-s-eclipse span.cm-meta {
+ color: #888;
+}
-.CodeMirror-tokentooltip {background-color: infobackground; border: 1px solid black;
- border-radius: 4px; color: infotext; font-family: monospace; font-size: 10pt;
- overflow: auto; padding: 4px 8px; z-index: 100; max-width: 900px; max-height: 600px;}
+.CodeMirror-tokentooltip {
+ background-color: infobackground;
+ border: 1px solid black;
+ border-radius: 4px;
+ color: infotext;
+ font-family: monospace;
+ font-size: 10pt;
+ overflow: auto;
+ padding: 4px 8px;
+ z-index: 100;
+ max-width: 900px;
+ max-height: 600px;
+}
diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/RunTaskBehavior.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/RunTaskBehavior.java
index 9d5c7c8dbe..d9dc107429 100644
--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/RunTaskBehavior.java
+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/RunTaskBehavior.java
@@ -8,7 +8,7 @@ public abstract class RunTaskBehavior extends AbstractDefaultAjaxBehavior {
@Override
protected void respond(AjaxRequestTarget target) {
- target.appendJavaScript(String.format(""
+ target.prependJavaScript(String.format(""
+ "var $button = $('#%s');"
+ "$button.removeAttr('disabled');"
+ "$button.val($button[0].prevValue);"
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/blobsearch/BlobAdvancedSearchResultPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/blobsearch/BlobAdvancedSearchResultPanel.html
deleted file mode 100644
index f430b81f7e..0000000000
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/blobsearch/BlobAdvancedSearchResultPanel.html
+++ /dev/null
@@ -1,26 +0,0 @@
-<wicket:panel>
- <wicket:enclosure child="hasMoreMessage">
- <div class="blob-advanced-search-result-hasmore">
- <i class="fa fa-warning"></i> <span wicket:id="hasMoreMessage"></span>
- </div>
- </wicket:enclosure>
- <ul class="blob-advanced-search-result list-unstyled">
- <li wicket:id="blobs" class="blob">
- <a wicket:id="expandLink" class="expand"><i wicket:id="icon"></i></a>
- <i class="fa fa-file-o icon"></i>
- <a wicket:id="pathLink" class="path"><span wicket:id="label"></span></a>
- <ul wicket:id="hits" class="list-unstyled">
- <li wicket:id="hits" class="hit">
- <img wicket:id="icon"></img>
- <span wicket:id="lineNo" class="line-no"></span>
- <a wicket:id="lineLink"><span wicket:id="label"></span></a>
- <wicket:enclosure child="scope">
- <span class="scope">
- -- <span wicket:id="scope"></span>
- </span>
- </wicket:enclosure>
- </li>
- </ul>
- </li>
- </ul>
-</wicket:panel>
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/blobsearch/BlobAdvancedSearchResultPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/blobsearch/BlobAdvancedSearchResultPanel.java
deleted file mode 100644
index 9c26748a9f..0000000000
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/blobsearch/BlobAdvancedSearchResultPanel.java
+++ /dev/null
@@ -1,188 +0,0 @@
-package com.pmease.gitplex.web.component.blobsearch;
-
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.wicket.AttributeModifier;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.markup.html.AjaxLink;
-import org.apache.wicket.markup.head.CssHeaderItem;
-import org.apache.wicket.markup.head.IHeaderResponse;
-import org.apache.wicket.markup.html.WebMarkupContainer;
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.html.image.Image;
-import org.apache.wicket.markup.html.list.ListItem;
-import org.apache.wicket.markup.html.list.ListView;
-import org.apache.wicket.markup.html.panel.Panel;
-import org.apache.wicket.model.LoadableDetachableModel;
-import org.apache.wicket.request.resource.CssResourceReference;
-
-import com.pmease.gitplex.search.hit.FileHit;
-import com.pmease.gitplex.search.hit.MatchedBlob;
-import com.pmease.gitplex.search.hit.QueryHit;
-import com.pmease.gitplex.search.hit.TextHit;
-
-@SuppressWarnings("serial")
-public abstract class BlobAdvancedSearchResultPanel extends Panel {
-
- private final List<MatchedBlob> blobs;
-
- private final boolean hasMore;
-
- public BlobAdvancedSearchResultPanel(String id, List<QueryHit> hits) {
- super(id);
-
- hasMore = (hits.size() == BlobSearchPanel.MAX_ADVANCED_QUERY_ENTRIES);
-
- Map<String, MatchedBlob> hitsByBlob = new LinkedHashMap<>();
-
- for (QueryHit hit: hits) {
- MatchedBlob blob = hitsByBlob.get(hit.getBlobPath());
- if (blob == null) {
- blob = new MatchedBlob(hit.getBlobPath(), new ArrayList<QueryHit>());
- hitsByBlob.put(hit.getBlobPath(), blob);
- }
- if (!(hit instanceof FileHit))
- blob.getHits().add(hit);
- }
-
- blobs = new ArrayList<>(hitsByBlob.values());
- }
-
- @Override
- protected void onInitialize() {
- super.onInitialize();
-
- setOutputMarkupId(true);
-
- String hasMoreMessage = "Too many matches, displaying " + BlobSearchPanel.MAX_ADVANCED_QUERY_ENTRIES + " of them";
- add(new Label("hasMoreMessage", hasMoreMessage).setVisible(hasMore));
-
- add(new ListView<MatchedBlob>("blobs", blobs) {
-
- @Override
- protected void populateItem(final ListItem<MatchedBlob> item) {
- final WebMarkupContainer hitsContainer = new WebMarkupContainer("hits") {
-
- @Override
- protected void onConfigure() {
- super.onConfigure();
-
- setVisible(!item.getModelObject().getHits().isEmpty());
- }
-
- };
- hitsContainer.setVisibilityAllowed(false);
- hitsContainer.setOutputMarkupPlaceholderTag(true);
- item.add(hitsContainer);
-
- hitsContainer.add(new ListView<QueryHit>("hits", item.getModelObject().getHits()) {
-
- @Override
- protected void populateItem(ListItem<QueryHit> item) {
- final QueryHit hit = item.getModelObject();
- item.add(new Image("icon", hit.getIcon()) {
-
- @Override
- protected boolean shouldAddAntiCacheParameter() {
- return false;
- }
-
- });
- item.add(new Label("lineNo", String.valueOf(hit.getLineNo()+1) + ":"));
- item.add(new AjaxLink<Void>("lineLink") {
-
- @Override
- protected void onInitialize() {
- super.onInitialize();
- add(hit.render("label"));
- }
-
- @Override
- public void onClick(AjaxRequestTarget target) {
- onSelect(target, hit);
- }
-
- });
-
- item.add(new Label("scope", hit.getScope())
- .setVisible(!(hit instanceof TextHit) && hit.getScope()!=null));
- }
-
- });
-
- item.add(new AjaxLink<Void>("expandLink") {
-
- @Override
- public void onClick(AjaxRequestTarget target) {
- hitsContainer.setVisibilityAllowed(!hitsContainer.isVisibilityAllowed());
- target.add(hitsContainer);
- target.add(this);
- }
-
- @Override
- protected void onInitialize() {
- super.onInitialize();
-
- WebMarkupContainer icon = new WebMarkupContainer("icon");
- icon.add(AttributeModifier.append("class", new LoadableDetachableModel<String>() {
-
- @Override
- protected String load() {
- if (item.getModelObject().getHits().isEmpty())
- return "fa fa-fw fa-angle-right fa-none";
- else if (hitsContainer.isVisibilityAllowed())
- return "fa fa-fw fa-caret-down";
- else
- return "fa fa-fw fa-caret-right";
- }
-
- }));
-
- setOutputMarkupId(true);
-
- add(icon);
- }
-
- @Override
- protected void onConfigure() {
- super.onConfigure();
-
- setEnabled(!item.getModelObject().getHits().isEmpty());
- }
-
- });
-
- item.add(new AjaxLink<Void>("pathLink") {
-
- @Override
- protected void onInitialize() {
- super.onInitialize();
-
- add(new Label("label", item.getModelObject().getBlobPath()));
- }
-
- @Override
- public void onClick(AjaxRequestTarget target) {
- onSelect(target, new FileHit(item.getModelObject().getBlobPath()));
- }
-
- });
- }
-
- });
- }
-
- @Override
- public void renderHead(IHeaderResponse response) {
- super.renderHead(response);
-
- response.render(CssHeaderItem.forReference(
- new CssResourceReference(BlobSearchPanel.class, "blob-search.css")));
- }
-
- protected abstract void onSelect(AjaxRequestTarget target, QueryHit hit);
-
-}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/blobsearch/BlobSearchPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/blobsearch/BlobSearchPanel.html
index 3144f381ec..72124948b4 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/blobsearch/BlobSearchPanel.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/blobsearch/BlobSearchPanel.html
@@ -1,67 +1,69 @@
<wicket:panel>
<div class="blob-search form-inline">
<input wicket:id="instantSearchInput" placeholder="File names, symbols, contents" class="form-control input-sm"></input>
- <div class="btn btn-group">
+ <div class="btn-group">
<a title="Instant search" class="btn btn-default btn-sm" onclick="$(this).parent().prev().show().focus();"><i class="fa fa-search"></i></a>
<a wicket:id="advancedSearch" title="Advanced search" class="btn btn-default btn-sm"><i class="fa fa-binoculars"></i></a>
</div>
</div>
- <div wicket:id="instantSearchResult" class="blob-instant-search-result"></div>
- <div wicket:id="advancedSearchDlg" class="blob-advanced-search"></div>
+ <div wicket:id="instantSearchDropdown"></div>
+ <div wicket:id="advancedSearchDlg"></div>
<wicket:fragment wicket:id="instantSearchResultFrag">
- <div class="symbols section">
- <div class="title">File names and symbols</div>
- <wicket:enclosure child="symbolHits">
- <table>
- <tr wicket:id="symbolHits" class="hit">
- <td class="icon"><img wicket:id="icon"></img></td>
- <td class="content">
- <a wicket:id="link"><span wicket:id="label"></span></a>
- <wicket:enclosure child="scope">
- <span class="scope">
- -- <span wicket:id="scope"></span>
- </span>
- </wicket:enclosure>
- </td>
- </tr>
- <wicket:enclosure child="moreSymbolHits">
- <tr class="hit more-matches">
- <td class="icon"><i class="fa fa-arrow-circle-right"></i></td>
- <td><a wicket:id="moreSymbolHits">Show more</a></td>
- </tr>
+ <div class="instant-search-result">
+ <div class="symbols section">
+ <div class="title">File names and symbols</div>
+ <wicket:enclosure child="symbolHits">
+ <table>
+ <tr wicket:id="symbolHits" class="hit">
+ <td class="icon"><img wicket:id="icon"></img></td>
+ <td class="content">
+ <a wicket:id="link"><span wicket:id="label"></span></a>
+ <wicket:enclosure child="scope">
+ <span class="scope">
+ -- <span wicket:id="scope"></span>
+ </span>
+ </wicket:enclosure>
+ </td>
+ </tr>
+ <wicket:enclosure child="moreSymbolHits">
+ <tr class="hit more-matches">
+ <td class="icon"><i class="fa fa-arrow-circle-right"></i></td>
+ <td><a wicket:id="moreSymbolHits">Show more</a></td>
+ </tr>
+ </wicket:enclosure>
+ </table>
</wicket:enclosure>
- </table>
- </wicket:enclosure>
- <div wicket:id="noSymbolHits" class="no-matches"><i class="fa fa-info-circle"></i> No matches</div>
- </div>
- <div wicket:id="texts" class="texts section">
- <div class="title">Text occurrences</div>
- <wicket:enclosure child="textHits">
- <table>
- <tr wicket:id="textHits" class="hit">
- <td class="icon"><img wicket:id="icon"></img></td>
- <td class="content">
- <a wicket:id="link"><span wicket:id="label"></span></a>
- <wicket:enclosure child="scope">
- <span class="scope">
- -- <span wicket:id="scope"></span>
- </span>
- </wicket:enclosure>
- </td>
- </tr>
- <wicket:enclosure child="moreTextHits">
- <tr class="hit more-matches">
- <td class="icon"><i class="fa fa-arrow-circle-right fa-fw"></i></td>
- <td><a wicket:id="moreTextHits">Show more</a></td>
- </tr>
+ <div wicket:id="noSymbolHits" class="no-matches"><i class="fa fa-info-circle"></i> No matches</div>
+ </div>
+ <div wicket:id="texts" class="texts section">
+ <div class="title">Text occurrences</div>
+ <wicket:enclosure child="textHits">
+ <table>
+ <tr wicket:id="textHits" class="hit">
+ <td class="icon"><img wicket:id="icon"></img></td>
+ <td class="content">
+ <a wicket:id="link"><span wicket:id="label"></span></a>
+ <wicket:enclosure child="scope">
+ <span class="scope">
+ -- <span wicket:id="scope"></span>
+ </span>
+ </wicket:enclosure>
+ </td>
+ </tr>
+ <wicket:enclosure child="moreTextHits">
+ <tr class="hit more-matches">
+ <td class="icon"><i class="fa fa-arrow-circle-right fa-fw"></i></td>
+ <td><a wicket:id="moreTextHits">Show more</a></td>
+ </tr>
+ </wicket:enclosure>
+ </table>
</wicket:enclosure>
- </table>
- </wicket:enclosure>
- <div wicket:id="noTextHits" class="no-matches"><i class="fa fa-info-circle"></i> No matches</div>
+ <div wicket:id="noTextHits" class="no-matches"><i class="fa fa-info-circle"></i> No matches</div>
+ </div>
</div>
</wicket:fragment>
<wicket:fragment wicket:id="advancedSearchFrag">
- <form wicket:id="form">
+ <form wicket:id="form" class="advanced-search">
<div class="modal-header">
<h4 class="modal-title">Advanced Search</h4>
</div>
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/blobsearch/BlobSearchPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/blobsearch/BlobSearchPanel.java
index 2b5cb7fd83..d63e1f5caa 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/blobsearch/BlobSearchPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/blobsearch/BlobSearchPanel.java
@@ -72,13 +72,13 @@ public abstract class BlobSearchPanel extends Panel {
private final IModel<String> revisionModel;
- private TextField<String> instantSearchInput;
+ private TextField<String> instantSearchField;
- private String instantSearchFor;
+ private String instantSearchInput;
- private DropdownPanel instantSearchResultDropdown;
+ private DropdownPanel instantSearchDropdown;
- private WebMarkupContainer instantSearchResultContainer;
+ private WebMarkupContainer instantSearchResult;
private List<QueryHit> symbolHits;
@@ -101,14 +101,14 @@ public abstract class BlobSearchPanel extends Panel {
protected void onInitialize() {
super.onInitialize();
- instantSearchResultDropdown = new DropdownPanel("instantSearchResult") {
+ instantSearchDropdown = new DropdownPanel("instantSearchDropdown") {
@Override
protected Component newContent(String id) {
- instantSearchResultContainer = new Fragment(id, "instantSearchResultFrag", BlobSearchPanel.this);
- instantSearchResultContainer.setOutputMarkupId(true);
+ instantSearchResult = new Fragment(id, "instantSearchResultFrag", BlobSearchPanel.this);
+ instantSearchResult.setOutputMarkupId(true);
- instantSearchResultContainer.add(new ListView<QueryHit>("symbolHits", new AbstractReadOnlyModel<List<QueryHit>>() {
+ instantSearchResult.add(new ListView<QueryHit>("symbolHits", new AbstractReadOnlyModel<List<QueryHit>>() {
@Override
public List<QueryHit> getObject() {
@@ -152,7 +152,7 @@ public abstract class BlobSearchPanel extends Panel {
}
});
- instantSearchResultContainer.add(new AjaxLink<Void>("moreSymbolHits") {
+ instantSearchResult.add(new AjaxLink<Void>("moreSymbolHits") {
@Override
protected void onInitialize() {
@@ -162,15 +162,15 @@ public abstract class BlobSearchPanel extends Panel {
@Override
protected void runTask(AjaxRequestTarget target) {
SymbolQuery query = new SymbolQuery(
- instantSearchFor, false, false, false, MAX_ADVANCED_QUERY_ENTRIES);
+ instantSearchInput, false, false, false, MAX_ADVANCED_QUERY_ENTRIES);
try {
SearchManager searchManager = GitPlex.getInstance(SearchManager.class);
List<QueryHit> hits = searchManager.search(repoModel.getObject(), revisionModel.getObject(), query);
- onCompleteAdvancedSearch(target, hits);
+ renderQueryHits(target, hits);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
- instantSearchResultDropdown.hide(target);
+ instantSearchDropdown.hide(target);
}
});
@@ -188,7 +188,7 @@ public abstract class BlobSearchPanel extends Panel {
}
});
- instantSearchResultContainer.add(new WebMarkupContainer("noSymbolHits") {
+ instantSearchResult.add(new WebMarkupContainer("noSymbolHits") {
@Override
protected void onConfigure() {
@@ -203,11 +203,11 @@ public abstract class BlobSearchPanel extends Panel {
@Override
protected void onConfigure() {
super.onConfigure();
- setVisible(instantSearchFor != null && instantSearchFor.length() >= IndexConstants.NGRAM_SIZE);
+ setVisible(instantSearchInput != null && instantSearchInput.length() >= IndexConstants.NGRAM_SIZE);
}
};
- instantSearchResultContainer.add(textSection);
+ instantSearchResult.add(textSection);
textSection.add(new ListView<QueryHit>("textHits", new AbstractReadOnlyModel<List<QueryHit>>() {
@Override
@@ -261,15 +261,15 @@ public abstract class BlobSearchPanel extends Panel {
@Override
protected void runTask(AjaxRequestTarget target) {
TextQuery query = new TextQuery(
- instantSearchFor, false, false, false, MAX_ADVANCED_QUERY_ENTRIES);
+ instantSearchInput, false, false, false, MAX_ADVANCED_QUERY_ENTRIES);
try {
SearchManager searchManager = GitPlex.getInstance(SearchManager.class);
List<QueryHit> hits = searchManager.search(repoModel.getObject(), revisionModel.getObject(), query);
- onCompleteAdvancedSearch(target, hits);
+ renderQueryHits(target, hits);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
- instantSearchResultDropdown.hide(target);
+ instantSearchDropdown.hide(target);
}
});
@@ -297,25 +297,25 @@ public abstract class BlobSearchPanel extends Panel {
});
- return instantSearchResultContainer;
+ return instantSearchResult;
}
};
- add(instantSearchResultDropdown);
+ add(instantSearchDropdown);
- instantSearchInput = new TextField<>("instantSearchInput", Model.of(""));
- instantSearchInput.add(new AjaxFormComponentUpdatingBehavior("inputchange focus click") {
+ instantSearchField = new TextField<>("instantSearchInput", Model.of(""));
+ instantSearchField.add(new AjaxFormComponentUpdatingBehavior("inputchange focus click") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
- if (instantSearchResultContainer != null)
- target.add(instantSearchResultContainer);
+ if (instantSearchResult != null)
+ target.add(instantSearchResult);
- instantSearchFor = instantSearchInput.getInput();
- if (!Strings.isNullOrEmpty(instantSearchFor)) {
+ instantSearchInput = instantSearchField.getInput();
+ if (!Strings.isNullOrEmpty(instantSearchInput)) {
SearchManager searchManager = GitPlex.getInstance(SearchManager.class);
- BlobQuery blobQuery = new SymbolQuery(instantSearchInput.getInput(),
+ BlobQuery blobQuery = new SymbolQuery(instantSearchField.getInput(),
false, false, false, MAX_INSTANT_QUERY_ENTRIES);
try {
symbolHits = searchManager.search(repoModel.getObject(), revisionModel.getObject(), blobQuery);
@@ -323,8 +323,8 @@ public abstract class BlobSearchPanel extends Panel {
throw new RuntimeException(e);
}
- if (instantSearchFor.length() >= IndexConstants.NGRAM_SIZE) {
- TextQuery textQuery = new TextQuery(instantSearchInput.getInput(),
+ if (instantSearchInput.length() >= IndexConstants.NGRAM_SIZE) {
+ TextQuery textQuery = new TextQuery(instantSearchField.getInput(),
false, false, false, MAX_INSTANT_QUERY_ENTRIES);
try {
textHits = searchManager.search(repoModel.getObject(), revisionModel.getObject(), textQuery);
@@ -335,21 +335,23 @@ public abstract class BlobSearchPanel extends Panel {
textHits = new ArrayList<>();
}
- instantSearchResultDropdown.show(target);
+ instantSearchDropdown.show(target);
} else {
symbolHits = new ArrayList<>();
textHits = new ArrayList<>();
- instantSearchResultDropdown.hide(target);
+ instantSearchDropdown.hide(target);
}
activeHitIndex = 0;
- send(BlobSearchPanel.this, Broadcast.BREADTH, new InstantSearchInputUpdated(target));
+ send(BlobSearchPanel.this, Broadcast.BREADTH, new InstantSearchUpdated(target));
}
});
- instantSearchInput.add(new DropdownBehavior(instantSearchResultDropdown).mode(null));
- instantSearchInput.add(new AbstractDefaultAjaxBehavior() {
+ instantSearchField.add(new DropdownBehavior(instantSearchDropdown)
+ .mode(null)
+ .alignWithTrigger(100, 100, 100, 0, 6, true));
+ instantSearchField.add(new AbstractDefaultAjaxBehavior() {
@Override
protected void respond(AjaxRequestTarget target) {
@@ -385,14 +387,14 @@ public abstract class BlobSearchPanel extends Panel {
String script = String.format(
"gitplex.blobSearch.init('%s', '%s', %s);",
- instantSearchInput.getMarkupId(true), instantSearchResultDropdown.getMarkupId(true),
+ instantSearchField.getMarkupId(true), instantSearchDropdown.getMarkupId(true),
getCallbackFunction(CallbackParameter.explicit("key")));
response.render(OnDomReadyHeaderItem.forScript(script));
}
});
- add(instantSearchInput);
+ add(instantSearchField);
ModalPanel advancedSearchDlg = new AdvancedSearchDlg("advancedSearchDlg");
add(advancedSearchDlg);
@@ -433,14 +435,14 @@ public abstract class BlobSearchPanel extends Panel {
}
private void selectHit(AjaxRequestTarget target, QueryHit hit) {
- target.appendJavaScript(String.format("$('#%s').hide();", instantSearchInput.getMarkupId(true)));
- instantSearchResultDropdown.hide(target);
+ target.appendJavaScript(String.format("$('#%s').hide();", instantSearchField.getMarkupId(true)));
+ instantSearchDropdown.hide(target);
onSelect(target, hit);
}
protected abstract void onSelect(AjaxRequestTarget target, QueryHit hit);
- protected abstract void onCompleteAdvancedSearch(AjaxRequestTarget target, List<QueryHit> blobs);
+ protected abstract void renderQueryHits(AjaxRequestTarget target, List<QueryHit> hits);
private class AdvancedSearchDlg extends ModalPanel {
@@ -471,7 +473,7 @@ public abstract class BlobSearchPanel extends Panel {
form.setOutputMarkupId(true);
fragment.add(form);
- searchFor = instantSearchFor;
+ searchFor = instantSearchInput;
WebMarkupContainer searchForContainer = new WebMarkupContainer("searchFor");
form.add(searchForContainer);
@@ -480,10 +482,10 @@ public abstract class BlobSearchPanel extends Panel {
@Override
public void onEvent(IEvent<?> event) {
super.onEvent(event);
- if (event.getPayload() instanceof InstantSearchInputUpdated) {
- InstantSearchInputUpdated instantSearchInputUpdated = (InstantSearchInputUpdated) event.getPayload();
- searchFor = instantSearchFor;
- instantSearchInputUpdated.getTarget().add(this);
+ if (event.getPayload() instanceof InstantSearchUpdated) {
+ InstantSearchUpdated instantSearchUpdated = (InstantSearchUpdated) event.getPayload();
+ searchFor = instantSearchInput;
+ instantSearchUpdated.getTarget().add(this);
}
}
@@ -557,7 +559,7 @@ public abstract class BlobSearchPanel extends Panel {
try {
SearchManager searchManager = GitPlex.getInstance(SearchManager.class);
List<QueryHit> hits = searchManager.search(repoModel.getObject(), revisionModel.getObject(), query);
- onCompleteAdvancedSearch(target, hits);
+ renderQueryHits(target, hits);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
@@ -597,9 +599,9 @@ public abstract class BlobSearchPanel extends Panel {
};
- private static class InstantSearchInputUpdated extends AjaxEvent {
+ private static class InstantSearchUpdated extends AjaxEvent {
- public InstantSearchInputUpdated(AjaxRequestTarget target) {
+ public InstantSearchUpdated(AjaxRequestTarget target) {
super(target);
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/blobsearch/blob-search.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/blobsearch/blob-search.css
index 68462161a2..0f1facfe80 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/blobsearch/blob-search.css
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/blobsearch/blob-search.css
@@ -1,32 +1,72 @@
-.blob-search input.form-control {width: 300px; display: none; cursor: text;}
-.blob-search .btn-group {margin-left: -8px;}
-.blob-search a {color: #666;}
-.blob-search .input-group-addon {padding: 6px;}
-.blob-search .input-group-addon {padding: 6px;}
+.blob-search input.form-control {
+ width: 300px;
+ display: none;
+ cursor: text;
+}
+.blob-search a {
+ color: #666;
+}
+.instant-search-result .section {
+ margin-bottom: 8px;
+}
+.instant-search-result {
+ padding: 8px;
+ width: 600px;
+ max-height: 600px;
+ overflow: auto;
+}
+.instant-search-result a {
+ color: #444;
+}
+.instant-search-result .section>.title {
+ font-weight: bold;
+ margin-bottom: 4px;
+}
+.instant-search-result tr.hit>td {
+ vertical-align: top;
+ padding: 1px 0;
+}
+.instant-search-result tr.hit>td.icon {
+ width: 24px;
+}
+.instant-search-result tr.hit.active>td {
+ background: #E8E8E8;
+}
+.instant-search-result tr.more-matches .fa {
+ font-size: 16px;
+}
+.instant-search-result tr.more-matches>td {
+ padding: 8px 0;
+ font-style: italic;
+}
+.instant-search-result .no-matches {
+ font-style: italic;
+}
+.instant-search-result td.content .scope {
+ color: #666;
+ font-size: 12px;
+}
-.blob-instant-search-result .section {margin-bottom: 8px;}
-.blob-instant-search-result>.content {padding: 8px; min-width: 600px; max-width: 900px; max-height: 600px; overflow: auto;}
-.blob-instant-search-result a {color: #444;}
-.blob-instant-search-result .section>.title {font-weight: bold; margin-bottom: 4px;}
-.blob-instant-search-result tr.hit>td {vertical-align: top; padding: 1px 0;}
-.blob-instant-search-result tr.hit>td.icon {width: 24px;}
-.blob-instant-search-result tr.hit.active>td {background: #E8E8E8;}
-.blob-instant-search-result tr.more-matches .fa {font-size: 16px;}
-.blob-instant-search-result tr.more-matches>td {padding: 8px 0; font-style: italic;}
-.blob-instant-search-result .no-matches {font-style: italic;}
-.blob-instant-search-result td.content .scope {color: #666; font-size: 12px;}
-
-.blob-advanced-search label {font-weight: normal;}
-.blob-advanced-search .modal-footer {border-top: none;}
-.blob-advanced-search form fieldset {border: 1px solid #DDD; padding: 16px 12px;}
-.blob-advanced-search form fieldset legend {width: inherit; padding: 4px; margin: 0 0 0 -4px;
- border-bottom: none; font-size: 16px;}
-.blob-advanced-search form fieldset>div {margin-top: -12px;}
-.blob-advanced-search .feedbackPanelERROR {margin-top: 16px;}
-
-.blob-advanced-search-result-hasmore {font-size: 16px; margin-bottom: 8px; font-style: italic;}
-.blob-advanced-search-result>li {border: none; padding: 2px 0;}
-.blob-advanced-search-result a {color: #333; }
-.blob-advanced-search-result>li>ul {margin-left: 34px;}
-.blob-advanced-search-result>li .fa-none {color: white;}
-.blob-advanced-search-result>li .scope {color: #666; font-size: 12px;}
+.advanced-search label {
+ font-weight: normal;
+}
+.advanced-search .modal-footer {
+ border-top: none;
+}
+.advanced-search fieldset {
+ border: 1px solid #DDD;
+ padding: 16px 12px;
+}
+.advanced-search fieldset legend {
+ width: inherit;
+ padding: 4px;
+ margin: 0 0 0 -4px;
+ border-bottom: none;
+ font-size: 16px;
+}
+.advanced-search fieldset>div {
+ margin-top: -12px;
+}
+.advanced-search .feedbackPanelERROR {
+ margin-top: 16px;
+}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/blobsearch/blob-search.js b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/blobsearch/blob-search.js
index 7101a0d38a..97d48ded2e 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/blobsearch/blob-search.js
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/blobsearch/blob-search.js
@@ -30,17 +30,18 @@ gitplex.blobSearch = {
callback("return");
});
function scrollIfNecessary() {
- var margin = 25;
- var $content = $dropdown.find(">.content");
+ var margin = 36;
+ var $container = $dropdown.find(".instant-search-result");
var $active = $dropdown.find("tr.hit.active");
- var contentTop = $content.offset().top;
+ var containerTop = $container.offset().top;
var activeTop = $active.offset().top;
- if (activeTop-margin<contentTop)
- $content.scrollTop($content.scrollTop()-(contentTop-activeTop+margin));
- var contentBottom = contentTop + $content.height();
+ if (activeTop-margin<containerTop)
+ $container.scrollTop($container.scrollTop()-(containerTop-activeTop+margin));
+ var containerBottom = containerTop + $container.height();
var activeBottom = activeTop + $active.height();
- if (activeBottom+margin>contentBottom)
- $content.scrollTop($content.scrollTop()+(activeBottom+margin-contentBottom));
+
+ if (activeBottom+margin>containerBottom)
+ $container.scrollTop($container.scrollTop()+(activeBottom+margin-containerBottom));
};
function keyup() {
var $active = $dropdown.find("tr.hit.active");
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/filelist/FileListPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/filelist/FileListPanel.html
index a7677cc6b4..888f13d0ce 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/filelist/FileListPanel.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/filelist/FileListPanel.html
@@ -1,27 +1,23 @@
<wicket:panel>
- <div class="file-list">
- <table>
- <tr class="last-commit">
- <td colspan="3">
- <div wicket:id="lastCommit"></div>
- </td>
- </tr>
- <tr wicket:id="parent" class="parent">
- <td colspan="3">
- <a wicket:id="link"><i class="fa fa-level-up"></i> <span>..</span></a>
- </td>
- </tr>
- <tr wicket:id="children" class="child">
- <td class="path">
- <i wicket:id="pathIcon"></i>
- <a wicket:id="pathLink"><span wicket:id="label"></span></a>
- </td>
- <td wicket:id="lastCommitSummary" class="last-commit summary">
- </td>
- <td class="last-commit age">
- </td>
- </tr>
- </table>
+ <div class="file-list autofit">
+ <div wicket:id="lastCommit" class="head"></div>
+ <div class="body">
+ <table>
+ <tr wicket:id="parent" class="parent">
+ <td colspan="3">
+ <a wicket:id="link"><i class="fa fa-level-up"></i> <span>..</span></a>
+ </td>
+ </tr>
+ <tr wicket:id="children" class="child">
+ <td class="path">
+ <i wicket:id="pathIcon"></i>
+ <a wicket:id="pathLink"><span wicket:id="label"></span></a>
+ </td>
+ <td wicket:id="lastCommitSummary" class="last-commit summary"></td>
+ <td class="last-commit age"></td>
+ </tr>
+ </table>
+ </div>
</div>
<wicket:fragment wicket:id="lastCommitFrag">
<div wicket:id="message" class="message"></div>
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/filelist/FileListPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/filelist/FileListPanel.java
index 008a473b78..d53a69cc7f 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/filelist/FileListPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/filelist/FileListPanel.java
@@ -307,7 +307,7 @@ public abstract class FileListPanel extends Panel {
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
- String script = String.format("gitplex.treelist.renderLastCommits('%s', %s);",
+ String script = String.format("gitplex.filelist.renderLastCommits('%s', %s);",
getMarkupId(), json);
target.appendJavaScript(script);
}
@@ -316,8 +316,13 @@ public abstract class FileListPanel extends Panel {
public void renderHead(Component component, IHeaderResponse response) {
super.renderHead(component, response);
- response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(FileListPanel.class, "file-list.js")));
- response.render(CssHeaderItem.forReference(new CssResourceReference(FileListPanel.class, "file-list.css")));
+ response.render(JavaScriptHeaderItem.forReference(
+ new JavaScriptResourceReference(FileListPanel.class, "file-list.js")));
+ response.render(CssHeaderItem.forReference(
+ new CssResourceReference(FileListPanel.class, "file-list.css")));
+
+ response.render(OnDomReadyHeaderItem.forScript(
+ String.format("gitplex.filelist.init('%s')", getMarkupId())));
response.render(OnDomReadyHeaderItem.forScript(getCallbackScript()));
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/filelist/file-list.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/filelist/file-list.css
index 5ef3cfbfa6..566de1e2fc 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/filelist/file-list.css
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/filelist/file-list.css
@@ -1,47 +1,50 @@
.file-list {
border: 1px solid #DDD;
- border-radius: 4px;
+ border-radius: 4px 4px 0 0;
+}
+.file-list>.body {
+ overflow: auto;
}
-.file-list>table {
+.file-list>.body>table {
width: 100%;
}
-.file-list>table>tbody>tr>td {
- padding: 6px 8px;
+.file-list>.body>table>tbody>tr>td {
+ padding: 6px 10px;
border-top: 1px solid #EEE;
vertical-align: top;
}
-.file-list>table>tbody>tr:first-child>td {
+.file-list>.body>table>tbody>tr:first-child>td {
border-top: none;
}
-.file-list>table tr.child .last-commit a, .file-list>table .last-commit {
+.file-list>.body>table tr.child .last-commit a, .file-list>table .last-commit {
color: #666;
}
-.file-list>table tr.parent td {
+.file-list>.body>table tr.parent td {
padding: 3px 12px;
}
-.file-list>table tr.parent td a i {
+.file-list>.body>table tr.parent td a i {
margin-right: 2px;
}
-.file-list>table tr.parent td a span {
+.file-list>.body>table tr.parent td a span {
font-size: 18px;
}
-.file-list>table tr.last-commit td {
- padding: 0;
+.file-list>.head {
+ border-bottom: 1px solid #DDD;
}
-.file-list>table tr.last-commit td .message {
+.file-list>.head .message {
background: #F2F2F2;
border-radius: 4px 4px 0 0;
padding: 8px;
}
-.file-list>table tr.last-commit td .other-info {
+.file-list>.head .other-info {
color: #888;
padding: 6px 8px;
height: 36px;
}
-.file-list>table tr.last-commit td .other-info .name {
+.file-list>.head .other-info .name {
font-weight: bold;
color: #555;
}
-.file-list>table tr.last-commit td .other-info a {
+.file-list>.head .other-info a {
color: #555;
}
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/filelist/file-list.js b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/filelist/file-list.js
index 2eb9b139fa..febcf13906 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/filelist/file-list.js
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/filelist/file-list.js
@@ -1,6 +1,18 @@
-gitplex.treelist = {
+gitplex.filelist = {
+ init: function(containerId) {
+ var $container = $("#" + containerId);
+ var $fileList = $container.children();
+ $fileList.on("autofit", function(event, width, height) {
+ var $head = $fileList.find(">.head");
+ var $body = $fileList.find(">.body");
+ var $table = $body.children();
+ $body.outerHeight(height-$head.outerHeight());
+ if ($body.height()>$table.outerHeight())
+ $body.height($table.outerHeight());
+ });
+ },
renderLastCommits: function(containerId, lastCommits) {
- var $table = $("#" + containerId).find(".file-list>table");
+ var $table = $("#" + containerId).find(".file-list>.body>table");
$table.find("tr.child").each(function() {
var $row = $(this);
var path = $row.find("td.path span").text();
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/reposelector/repository-selector.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/reposelector/repository-selector.css
index 288bc82848..51167bd935 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/reposelector/repository-selector.css
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/reposelector/repository-selector.css
@@ -4,9 +4,6 @@
.repository-selector .search input {
border-radius: 0;
}
-.repository-selector .search .account input {
- border-right: none;
-}
.repository-selector ul.accounts {
max-width: 600px;
max-height: 600px;
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionselector/RevisionSelector.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionselector/RevisionSelector.html
index e2b73f8160..34991faf01 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionselector/RevisionSelector.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionselector/RevisionSelector.html
@@ -3,15 +3,17 @@
<i wicket:id="icon"></i> <span wicket:id="label"></span>
<i class="fa fa-caret-down"></i>
</button>
- <div wicket:id="dropdown" class="revision-selector-dropdown"></div>
+ <div wicket:id="dropdown"></div>
<wicket:fragment wicket:id="dropdownContentFrag">
- <input wicket:id="revision" class="form-control input-sm revision" placeholder="Input revision"></input>
- <div wicket:id="feedback" class="feedback"></div>
- <ul wicket:id="tabs" class="nav nav-tabs"></ul>
- <ul wicket:id="refs" class="refs list-unstyled">
- <li wicket:id="refs">
- <a wicket:id="link"><span wicket:id="label"></span></a>
- </li>
- </ul>
+ <div class="revision-selector">
+ <input wicket:id="revision" class="form-control input-sm revision" placeholder="Input revision"></input>
+ <div wicket:id="feedback" class="feedback"></div>
+ <ul wicket:id="tabs" class="nav nav-tabs"></ul>
+ <ul wicket:id="refs" class="refs list-unstyled">
+ <li wicket:id="refs">
+ <a wicket:id="link"><span wicket:id="label"></span></a>
+ </li>
+ </ul>
+ </div>
</wicket:fragment>
</wicket:panel>
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionselector/RevisionSelector.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionselector/RevisionSelector.java
index 7c96fab371..9514141a77 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionselector/RevisionSelector.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionselector/RevisionSelector.java
@@ -269,7 +269,7 @@ public abstract class RevisionSelector extends Panel {
};
add(dropdown);
- button.add(new DropdownBehavior(dropdown));
+ button.add(new DropdownBehavior(dropdown).alignWithTrigger(0, 100, 0, 0, 6, true));
setOutputMarkupId(true);
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionselector/revision-selector.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionselector/revision-selector.css
index 90b05ded92..acc4d41109 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionselector/revision-selector.css
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionselector/revision-selector.css
@@ -1,13 +1,51 @@
-.revision-selector-dropdown ul.refs {width: 400px; max-height: 200px; overflow: auto;}
-.revision-selector-dropdown input.revision {margin-bottom: 12px;}
-.revision-selector-dropdown .nav-tabs {margin-bottom: 8px;}
-.revision-selector-dropdown .nav-tabs>li>a {padding: 2px 4px; color: #666; font-size: 12px;}
-.revision-selector-dropdown .nav-tabs>li.active>a {color: #333; font-weight: bold;}
-.revision-selector-dropdown {padding: 12px;}
-.revision-selector-dropdown ul.refs {margin-bottom: 0;}
-.revision-selector-dropdown ul.refs li {padding: 2px 4px;}
-.revision-selector-dropdown ul.refs li:hover {background: #F0F0F0;}
-.revision-selector-dropdown ul.refs li a {color: #333; display: block; text-decoration: none;}
-.revision-selector-dropdown ul.refs li.active {background: #F0F0F0;}
-.revision-selector-dropdown .feedback {color: #F94949; margin-bottom: 12px;}
-.revision-selector-dropdown .feedback:before {font-family: "FontAwesome"; content: "\f071"; margin-right: 4px;}
\ No newline at end of file
+div.revision-selector ul.refs {
+ width: 400px;
+ max-height: 200px;
+ overflow: auto;
+}
+div.revision-selector input.revision {
+ margin-bottom: 12px;
+ background: url(search.gif) no-repeat right 6px center;
+ padding-right: 26px;
+}
+div.revision-selector .nav-tabs {
+ margin-bottom: 8px;
+}
+div.revision-selector .nav-tabs>li>a {
+ padding: 2px 4px;
+ color: #666;
+ font-size: 12px;
+}
+div.revision-selector .nav-tabs>li.active>a {
+ color: #333;
+ font-weight: bold;
+}
+div.revision-selector {
+ padding: 12px;
+}
+div.revision-selector ul.refs {
+ margin-bottom: 0;
+}
+div.revision-selector ul.refs li {
+ padding: 2px 4px;
+}
+div.revision-selector ul.refs li:hover {
+ background: #F0F0F0;
+}
+div.revision-selector ul.refs li a {
+ color: #333;
+ display: block;
+ text-decoration: none;
+}
+div.revision-selector ul.refs li.active {
+ background: #F0F0F0;
+}
+div.revision-selector .feedback {
+ color: #F94949;
+ margin-bottom: 12px;
+}
+div.revision-selector .feedback:before {
+ font-family: "FontAwesome";
+ content: "\f071";
+ margin-right: 4px;
+}
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/sourceview/SourceViewPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/sourceview/SourceViewPanel.html
index 5dd2c34133..ab69acedb5 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/sourceview/SourceViewPanel.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/sourceview/SourceViewPanel.html
@@ -1,5 +1,5 @@
<wicket:panel>
- <div class="source-view">
+ <div class="source-view autofit">
<div class="head clearfix">
<div class="pull-left">
<span wicket:id="title" class="title"></span>
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/sourceview/SourceViewPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/sourceview/SourceViewPanel.java
index 581f11030f..cb08ef9537 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/sourceview/SourceViewPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/sourceview/SourceViewPanel.java
@@ -189,7 +189,7 @@ public abstract class SourceViewPanel extends Panel {
SearchManager searchManager = GitPlex.getInstance(SearchManager.class);
List<QueryHit> hits = searchManager.search(repoModel.getObject(),
source.getRevision(), query);
- onCompleteOccurrencesSearch(target, hits);
+ renderQueryHits(target, hits);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
@@ -254,7 +254,7 @@ public abstract class SourceViewPanel extends Panel {
protected abstract void onSelect(AjaxRequestTarget target, QueryHit hit);
- protected abstract void onCompleteOccurrencesSearch(AjaxRequestTarget target, List<QueryHit> hits);
+ protected abstract void renderQueryHits(AjaxRequestTarget target, List<QueryHit> hits);
@Override
protected void onDetach() {
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/sourceview/source-view.js b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/sourceview/source-view.js
index 14922e129b..c72fa25f3d 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/sourceview/source-view.js
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/sourceview/source-view.js
@@ -34,7 +34,9 @@ gitplex.sourceview = {
}
var $sourceView = $code.closest(".source-view");
- $sourceView.on("resized", function() {
+ $sourceView.on("autofit", function(event, width, height) {
+ $sourceView.outerWidth(width);
+ $sourceView.outerHeight(height);
var $head = $sourceView.find(">.head");
var $body = $sourceView.find(">.body");
$body.outerHeight($sourceView.height()-$head.outerHeight());
@@ -48,6 +50,7 @@ gitplex.sourceview = {
$code.outerWidth($body.width());
$code.find(">.CodeMirror").outerHeight($body.height());
}
+ editor.refresh();
});
gitplex.sourceview.gotoLine(editor, activeLine);
@@ -70,7 +73,8 @@ gitplex.sourceview = {
outlineToggleBtn.addClass("active");
else
outlineToggleBtn.removeClass("active");
- $outline.closest(".source-view").trigger("resized");
+ var $sourceView = $outline.closest(".source-view");
+ $sourceView.trigger("autofit", [$sourceView.outerWidth(), $sourceView.outerHeight()]);
},
gotoSymbol: function(outlineId, line) {
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/RepoFilePage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/RepoFilePage.html
index d071721d15..d58537f5d6 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/RepoFilePage.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/RepoFilePage.html
@@ -4,9 +4,12 @@
<div class="head clearfix">
<div wicket:id="revisionSelector" class="pull-left"></div>
<div wicket:id="fileNavigator" class="pull-left"></div>
+ <div wicket:id="fileSearcher" class="pull-right"></div>
</div>
- <div class="body">
- <div wicket:id="fileViewer"></div>
+ <div wicket:id="fileViewer" class="file-viewer"></div>
+ <div class="search-result">
+ <div id="search-result-resize-handle" class="ui-resizable-handle ui-resizable-n"></div>
+ <div wicket:id="searchResult"></div>
</div>
</div>
</wicket:extend>
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/RepoFilePage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/RepoFilePage.java
index 9d04e76dc6..58c02f492e 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/RepoFilePage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/RepoFilePage.java
@@ -12,6 +12,7 @@ import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.head.CssHeaderItem;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
+import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.request.mapper.parameter.PageParameters;
@@ -29,6 +30,7 @@ import com.pmease.commons.git.GitPath;
import com.pmease.commons.wicket.behavior.HistoryBehavior;
import com.pmease.gitplex.core.model.Repository;
import com.pmease.gitplex.search.hit.QueryHit;
+import com.pmease.gitplex.web.component.blobsearch.BlobSearchPanel;
import com.pmease.gitplex.web.component.filelist.FileListPanel;
import com.pmease.gitplex.web.component.filenavigator.FileNavigator;
import com.pmease.gitplex.web.component.revisionselector.RevisionSelector;
@@ -37,6 +39,8 @@ import com.pmease.gitplex.web.component.sourceview.SourceViewPanel;
import com.pmease.gitplex.web.page.repository.NoCommitsPage;
import com.pmease.gitplex.web.page.repository.RepositoryPage;
+import de.agilecoders.wicket.extensions.markup.html.bootstrap.jqueryui.JQueryUIResizableJavaScriptReference;
+
@SuppressWarnings("serial")
public class RepoFilePage extends RepositoryPage {
@@ -49,11 +53,10 @@ public class RepoFilePage extends RepositoryPage {
private static final String FILE_NAVIGATOR_ID = "fileNavigator";
private static final String FILE_VIEWER_ID = "fileViewer";
-
- private String revision;
- @Nullable
- private GitPath file;
+ private static final String SEARCH_RESULD_ID = "searchResult";
+
+ private State state = new State();
private Component revisionSelector;
@@ -69,18 +72,18 @@ public class RepoFilePage extends RepositoryPage {
if (!getRepository().git().hasCommits())
throw new RestartResponseException(NoCommitsPage.class, paramsOf(getRepository()));
- revision = GitPath.normalize(params.get(PARAM_REVISION).toString());
- if (revision == null)
- revision = getRepository().getDefaultBranch().getName();
+ state.revision = GitPath.normalize(params.get(PARAM_REVISION).toString());
+ if (state.revision == null)
+ state.revision = getRepository().getDefaultBranch().getName();
String pathName = GitPath.normalize(params.get(PARAM_PATH).toString());
if (pathName != null) {
org.eclipse.jgit.lib.Repository jgitRepo = getRepository().openAsJGitRepo();
try {
- ObjectId commitId = Preconditions.checkNotNull(getRepository().resolveRevision(revision));
+ ObjectId commitId = Preconditions.checkNotNull(getRepository().resolveRevision(state.revision));
RevTree revTree = new RevWalk(jgitRepo).parseCommit(commitId).getTree();
TreeWalk treeWalk = Preconditions.checkNotNull(TreeWalk.forPath(jgitRepo, pathName, revTree));
- file = new GitPath(pathName, treeWalk.getRawMode(0));
+ state.file = new GitPath(pathName, treeWalk.getRawMode(0));
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
@@ -97,13 +100,40 @@ public class RepoFilePage extends RepositoryPage {
newFileNavigator(null);
newFileViewer(null);
+ add(new BlobSearchPanel("fileSearcher", repoModel, new AbstractReadOnlyModel<String>() {
+
+ @Override
+ public String getObject() {
+ return state.revision;
+ }
+
+ }) {
+
+ @Override
+ protected void onSelect(AjaxRequestTarget target, QueryHit hit) {
+ state.file = new GitPath(hit.getBlobPath(), FileMode.REGULAR_FILE.getBits());
+ state.line = hit.getLineNo();
+
+ newFileNavigator(target);
+ newFileViewer(target);
+
+ pushState(target);
+ }
+
+ @Override
+ protected void renderQueryHits(AjaxRequestTarget target, List<QueryHit> hits) {
+ renderSearchResult(target, hits);
+ }
+
+ });
+
+ add(new WebMarkupContainer(SEARCH_RESULD_ID).setOutputMarkupId(true));
+
add(historyBehavior = new HistoryBehavior() {
@Override
protected void onPopState(AjaxRequestTarget target, Serializable state) {
- HistoryState historyState = (HistoryState) state;
- revision = historyState.revision;
- file = historyState.path;
+ RepoFilePage.this.state = (State) state;
newRevisionSelector(target);
newFileNavigator(target);
@@ -114,25 +144,26 @@ public class RepoFilePage extends RepositoryPage {
}
private void newRevisionSelector(AjaxRequestTarget target) {
- revisionSelector = new RevisionSelector(REVISION_SELECTOR_ID, repoModel, revision) {
+ revisionSelector = new RevisionSelector(REVISION_SELECTOR_ID, repoModel, state.revision) {
@Override
protected void onSelect(AjaxRequestTarget target, String revision) {
- RepoFilePage.this.revision = revision;
- if (file != null) {
+ state.revision = revision;
+ if (state.file != null) {
org.eclipse.jgit.lib.Repository jgitRepo = getRepository().openAsJGitRepo();
try {
ObjectId commitId = Preconditions.checkNotNull(getRepository().resolveRevision(revision));
RevTree revTree = new RevWalk(jgitRepo).parseCommit(commitId).getTree();
- TreeWalk treeWalk = TreeWalk.forPath(jgitRepo, file.getName(), revTree);
+ TreeWalk treeWalk = TreeWalk.forPath(jgitRepo, state.file.getName(), revTree);
if (treeWalk == null)
- file = null;
+ state.file = null;
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
jgitRepo.close();
}
}
+ state.line = 0;
newRevisionSelector(target);
newFileNavigator(target);
@@ -156,14 +187,15 @@ public class RepoFilePage extends RepositoryPage {
@Override
public String getObject() {
- return revision;
+ return state.revision;
}
- }, file) {
+ }, state.file) {
@Override
protected void onSelect(AjaxRequestTarget target, GitPath file) {
- RepoFilePage.this.file = file;
+ state.file = file;
+ state.line = 0;
newFileNavigator(target);
newFileViewer(target);
@@ -181,19 +213,20 @@ public class RepoFilePage extends RepositoryPage {
}
private void newFileViewer(AjaxRequestTarget target) {
- if (file == null || file.isTree()) {
+ if (state.file == null || state.file.isTree()) {
fileViewer = new FileListPanel(FILE_VIEWER_ID, repoModel, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
- return revision;
+ return state.revision;
}
- }, file) {
+ }, state.file) {
@Override
protected void onSelect(AjaxRequestTarget target, GitPath file) {
- RepoFilePage.this.file = file;
+ state.file = file;
+ state.line = 0;
newFileViewer(target);
newFileNavigator(target);
@@ -205,17 +238,18 @@ public class RepoFilePage extends RepositoryPage {
} else {
org.eclipse.jgit.lib.Repository jgitRepo = getRepository().openAsJGitRepo();
try {
- ObjectId commitId = Preconditions.checkNotNull(getRepository().resolveRevision(revision));
+ ObjectId commitId = Preconditions.checkNotNull(getRepository().resolveRevision(state.revision));
RevTree revTree = new RevWalk(jgitRepo).parseCommit(commitId).getTree();
- TreeWalk treeWalk = Preconditions.checkNotNull(TreeWalk.forPath(jgitRepo, file.getName(), revTree));
+ TreeWalk treeWalk = Preconditions.checkNotNull(TreeWalk.forPath(jgitRepo, state.file.getName(), revTree));
ObjectLoader objectLoader = treeWalk.getObjectReader().open(treeWalk.getObjectId(0));
String content = new String(objectLoader.getCachedBytes());
- Source source = new Source(revision, file.getName(), content, 0);
+ Source source = new Source(state.revision, state.file.getName(), content, state.line);
fileViewer = new SourceViewPanel(FILE_VIEWER_ID, repoModel, source) {
@Override
protected void onSelect(AjaxRequestTarget target, QueryHit hit) {
- file = new GitPath(hit.getBlobPath(), FileMode.REGULAR_FILE.getBits());
+ state.file = new GitPath(hit.getBlobPath(), FileMode.REGULAR_FILE.getBits());
+ state.line = hit.getLineNo();
newFileNavigator(target);
newFileViewer(target);
@@ -224,8 +258,8 @@ public class RepoFilePage extends RepositoryPage {
}
@Override
- protected void onCompleteOccurrencesSearch(AjaxRequestTarget target, List<QueryHit> hits) {
-
+ protected void renderQueryHits(AjaxRequestTarget target, List<QueryHit> hits) {
+ renderSearchResult(target, hits);
}
};
@@ -246,10 +280,7 @@ public class RepoFilePage extends RepositoryPage {
}
private void pushState(AjaxRequestTarget target) {
- HistoryState state = new HistoryState();
- state.revision = revision;
- state.path = file;
- PageParameters params = paramsOf(getRepository(), revision, file!=null?file.getName():null);
+ PageParameters params = paramsOf(getRepository(), state.revision, state.file!=null?state.file.getName():null);
String url = RequestCycle.get().urlFor(RepoFilePage.class, params).toString();
historyBehavior.pushState(target, url, state);
}
@@ -257,9 +288,12 @@ public class RepoFilePage extends RepositoryPage {
@Override
public void renderHead(IHeaderResponse response) {
super.renderHead(response);
-
- response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(RepoFilePage.class, "repo-file.js")));
- response.render(CssHeaderItem.forReference(new CssResourceReference(RepoFilePage.class, "repo-file.css")));
+
+ response.render(JQueryUIResizableJavaScriptReference.asHeaderItem());
+ response.render(JavaScriptHeaderItem.forReference(
+ new JavaScriptResourceReference(RepoFilePage.class, "repo-file.js")));
+ response.render(CssHeaderItem.forReference(
+ new CssResourceReference(RepoFilePage.class, "repo-file.css")));
}
public static PageParameters paramsOf(Repository repository, @Nullable String revision, @Nullable String path) {
@@ -271,9 +305,41 @@ public class RepoFilePage extends RepositoryPage {
return params;
}
- private static class HistoryState implements Serializable {
+ private void renderSearchResult(AjaxRequestTarget target, List<QueryHit> hits) {
+ Component searchResult = new SearchResultPanel(SEARCH_RESULD_ID, hits) {
+
+ @Override
+ protected void onSelect(AjaxRequestTarget target, QueryHit hit) {
+ state.file = new GitPath(hit.getBlobPath(), FileMode.REGULAR_FILE.getBits());
+ state.line = hit.getLineNo();
+
+ newFileNavigator(target);
+ newFileViewer(target);
+
+ pushState(target);
+ }
+
+ @Override
+ protected void onClose(AjaxRequestTarget target) {
+ WebMarkupContainer searchResult = new WebMarkupContainer(SEARCH_RESULD_ID);
+ searchResult.setOutputMarkupId(true);
+ getPage().replace(searchResult);
+ target.add(searchResult);
+ target.appendJavaScript("$('#repo-file>.search-result').hide(); $(window).resize();");
+ }
+
+ };
+ replace(searchResult);
+ target.add(searchResult);
+ target.appendJavaScript("$('#repo-file>.search-result').show(); $(window).resize();");
+ }
+
+ private static class State implements Serializable {
String revision;
- GitPath path;
+ @Nullable
+ GitPath file;
+
+ int line;
}
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/repo-file.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/repo-file.css
index a193a91ddb..717271b4f0 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/repo-file.css
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/repo-file.css
@@ -6,4 +6,54 @@
}
#repo-file>.head .file-navigator {
margin-top: 3px;
-}
\ No newline at end of file
+}
+#repo-file>.search-result {
+ height: 200px;
+ border: 1px solid #DDD;
+ border-radius: 0 0 4px 4px;
+ display: none;
+}
+#repo-file>.search-result>.ui-resizable-handle {
+ background: #EEE url("hgrabber.gif") no-repeat scroll center top;
+ cursor: n-resize;
+ height: 4px;
+}
+#repo-file>.search-result>div>.head {
+ padding: 4px 10px;
+ font-size: 16px;
+ border-bottom: 1px solid #DDD;
+}
+#repo-file>.search-result>div>.head .warning {
+ margin-left: 8px;
+ font-size: 13px;
+ vertical-align: middle;
+ color: #666;
+}
+#repo-file>.search-result>div>.head a {
+ color: #666;
+}
+#repo-file>.search-result>div>.body {
+ overflow: auto;
+ padding: 0 10px;
+ margin-bottom: 0;
+}
+#repo-file>.search-result>div>.body>li {
+ border: none;
+ padding: 2px 0;
+}
+#repo-file>.search-result>div>.body>li a {
+ color: #333;
+}
+#repo-file>.search-result>div>.body>li>ul {
+ margin-left: 34px;
+}
+#repo-file>.search-result>div>.body>li .fa-none {
+ color: white;
+}
+#repo-file>.search-result>div>.body>li .scope {
+ color: #666;
+ font-size: 12px;
+}
+#repo-file>.search-result>div>.body>li.no-matching-result {
+ margin-top: 10px;
+}
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.html
index ce2b62bb25..0a6fc454bc 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,10 +1,6 @@
<wicket:extend>
- <div class="test" style="border: 1px solid red; margin-top: 10px; padding-top: 10px;">
- hello world
+ <div class="test" style="color: white; height: 400px;">
+ <div>hello</div>
+ <div>world</div>
</div>
- <script type="text/javascript">
- $(function() {
- console.log($(".test").offset().top);
- });
- </script>
</wicket:extend>