Skip to content

Commit 3ef7a06

Browse files
tulinkryVladimir Kotal
authored andcommitted
introducing a project tunable to open navigate window by default (#1685)
approaches #1636
1 parent 160fd27 commit 3ef7a06

File tree

4 files changed

+41
-5
lines changed

4 files changed

+41
-5
lines changed

src/org/opensolaris/opengrok/configuration/Project.java

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,17 @@
2525
import java.io.File;
2626
import java.io.FileNotFoundException;
2727
import java.io.IOException;
28+
import java.io.Serializable;
2829
import java.util.Locale;
2930
import java.util.Set;
3031
import java.util.TreeSet;
3132

3233
/**
3334
* Placeholder for the information that builds up a project
3435
*/
35-
public class Project implements Comparable<Project>, Nameable {
36+
public class Project implements Comparable<Project>, Nameable, Serializable {
37+
38+
private static final long serialVersionUID = 1L;
3639

3740
private String path;
3841

@@ -48,6 +51,12 @@ public class Project implements Comparable<Project>, Nameable {
4851
*/
4952
private int tabSize;
5053

54+
/**
55+
* A flag if the navigate window should be opened by default when browsing
56+
* the source code of this project.
57+
*/
58+
private boolean navigateWindowEnabled = false;
59+
5160
/**
5261
* This marks the project as (not)ready before initial index is done.
5362
* this is to avoid all/multi-project searches referencing this project
@@ -165,6 +174,25 @@ public boolean hasTabSizeSetting() {
165174
return tabSize > 0;
166175
}
167176

177+
/**
178+
* Indicate whether the navigate window should be opened by default when
179+
* browsing a source code from this project.
180+
*
181+
* @return true if yes; false otherwise
182+
*/
183+
public boolean isNavigateWindowEnabled() {
184+
return navigateWindowEnabled;
185+
}
186+
187+
/**
188+
* Set the value of navigateWindowEnabled
189+
*
190+
* @param navigateWindowEnabled new value of navigateWindowEnabled
191+
*/
192+
public void setNavigateWindowEnabled(boolean navigateWindowEnabled) {
193+
this.navigateWindowEnabled = navigateWindowEnabled;
194+
}
195+
168196
/**
169197
* Return groups where this project belongs
170198
*

src/org/opensolaris/opengrok/web/Scripts.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public String toHtml() {
125125
SCRIPTS.put("jquery-tablesorter", new FileScript("js/jquery-tablesorter-2.26.6.min.js", 12));
126126
SCRIPTS.put("tablesorter-parsers", new FileScript("js/tablesorter-parsers-0.0.1.js", 13));
127127
SCRIPTS.put("searchable-option-list", new FileScript("js/searchable-option-list-2.0.3.min.js", 14));
128-
SCRIPTS.put("utils", new FileScript("js/utils-0.0.12.js", 15));
128+
SCRIPTS.put("utils", new FileScript("js/utils-0.0.13.js", 15));
129129
SCRIPTS.put("repos", new FileScript("js/repos-0.0.1.js", 20));
130130
SCRIPTS.put("diff", new FileScript("js/diff-0.0.2.js", 20));
131131
}

web/js/utils-0.0.12.js renamed to web/js/utils-0.0.13.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1197,6 +1197,7 @@
11971197
load: function ($window) {
11981198
var that = this
11991199
$window.css('top', this.getTopOffset() + 10 + 'px')
1200+
12001201
if ($.scopesWindow && $.scopesWindow.initialized) {
12011202
$.scopesWindow.on('show', function () {
12021203
setTimeout(function () {
@@ -1215,6 +1216,10 @@
12151216
}
12161217
}
12171218

1219+
if ($('[data-navigate-window-enabled="true"]').length) {
1220+
$window.show();
1221+
}
1222+
12181223
// override and show to throw an event and update position
12191224
$.each(['show'], function () {
12201225
var event = this
@@ -1241,7 +1246,7 @@
12411246
for (var j = 0; j < data[i][2].length; j ++)
12421247
$ul.append($('<li>').append(this.buildLink(data[i][2][j][1], data[i][2][j][0], data[i][1])));
12431248
}
1244-
1249+
this.updatePosition(this.$window)
12451250
}
12461251
}, options || {
12471252
}), $.extend({

web/list.jsp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ document.pageReady.push(function() { pageReadyList();});
8080
PageConfig cfg = PageConfig.get(request);
8181
String rev = cfg.getRequestedRevision();
8282
83+
String navigateWindowEnabled = cfg.getProject() != null
84+
? Boolean.toString(cfg.getProject().isNavigateWindowEnabled())
85+
: "false";
8386
File resourceFile = cfg.getResourceFile();
8487
String path = cfg.getPath();
8588
String basename = resourceFile.getName();
@@ -236,7 +239,7 @@ Binary file [Click <a href="<%= rawPath %>?r=<%= Util.URIEncode(rev) %>">here</a
236239
}
237240
if (xrefFile != null) {
238241
%>
239-
<div id="src">
242+
<div id="src" data-navigate-window-enabled="<%= navigateWindowEnabled %>">
240243
<pre><%
241244
Util.dump(out, xrefFile, xrefFile.getName().endsWith(".gz"));
242245
%></pre>
@@ -262,7 +265,7 @@ Binary file [Click <a href="<%= rawPath %>?r=<%= Util.URIEncode(rev) %>">here</a
262265
Util.dump(out, r);
263266
} else if (g == Genre.PLAIN) {
264267
%>
265-
<div id="src">
268+
<div id="src" data-navigate-window-enabled="<%= navigateWindowEnabled %>">
266269
<pre><%
267270
// We're generating xref for the latest revision, so we can
268271
// find the definitions in the index.

0 commit comments

Comments
 (0)