} else if (action.equals("showdirs")) {
showdirs = true;
}
boolean no_entries = true;
HtmlGenerator g = getHtmlGenerator(this, "CVS for "+
getCvsManager().getDirectory());
addStyleSheet(g);
g.addLink(new HtmlLink(null, "made", "jigsaw@w3.org"));
String tablecolor = "white";
String parentpath = null;
ResourceReference rr_parent = resource.getParent();
try {
Resource parent = rr_parent.lock();
parentpath = parent.getURLPath();
} catch (InvalidResourceException ex) {
getServer().errlog(resource, "Invalid parent");
throw new RuntimeException("The server is misconfigured.");
} finally {
rr_parent.unlock();
}
//entries
boolean nofile = true;
boolean nodir = true;
Vector names = null;
Vector dirnames = null;
//javascript
g.addScript("JavaScript", "var submitOK = true;\n\n");
g.addScript("function SelectAll() {\n");
g.addScript(" len = document.liste.elements.length;\n");
g.addScript(" var i=0; var checked; var item;\n");
g.addScript(" if (document.liste.elements[i].checked == true)\n");
g.addScript(" checked = false;\n");
g.addScript(" else\n");
g.addScript(" checked = true;\n");
g.addScript(" for( i=0; i<len; i++) {\n");
g.addScript(" item = document.liste.elements[i].name;\n");
g.addScript(" if (item !='action' && item != 'scope')\n");
g.addScript(" document.liste.elements[i].checked=checked;");
g.addScript("\n }\n");
g.addScript("}\n\n");
g.addScript("function confirmDirAction() {\n");
g.addScript(" len = document.liste.elements.length;\n");
g.addScript(" var i=0; var item; var oneselected=false;\n");
g.addScript(" for( i=0; i<len; i++) {\n");
g.addScript(" item = document.liste.elements[i].name;\n");
g.addScript(" if (item !='action' && item != 'scope'){\n");
g.addScript(" if (document.liste.elements[i].checked\n");
g.addScript(" == true){\n");
g.addScript(" oneselected = true;\n");
g.addScript(" }\n");
g.addScript(" }\n");
g.addScript(" }\n");
g.addScript(" if (oneselected == false){\n");
g.addScript(" submitOK = false;\n");
g.addScript(" alert('No directory selected.');\n");
g.addScript(" } else {\n");
g.addScript(" submitOK = true;\n");
g.addScript(" }\n");
g.addScript("}\n\n");
g.addScript("function confirmFileAction() {\n");
g.addScript(" len = document.liste.elements.length;\n");
g.addScript(" var i=0; var item; var oneselected=false;\n");
g.addScript(" if (document.liste.scope[0].checked == true){\n");
g.addScript(" //Marked files\n");
g.addScript(" for( i=0; i<len; i++) {\n");
g.addScript(" item = document.liste.elements[i].name;\n");
g.addScript(" if (item !='action' && item != 'scope'){\n");
g.addScript(" if (document.liste.elements[i].checked\n");
g.addScript(" == true){\n");
g.addScript(" oneselected = true;\n");
g.addScript(" }\n");
g.addScript(" }\n");
g.addScript(" }\n");
g.addScript(" if (oneselected == false){\n");
g.addScript(" submitOK = false;\n");
g.addScript(" alert('No file selected.');\n");
g.addScript(" }\n");
g.addScript(" } else if (document.liste.scope[1].checked\n");
g.addScript(" == true){\n");
g.addScript(" //Directory\n");
g.addScript(" if (document.liste.action[1].checked == true\n");
g.addScript(" ||\n");
g.addScript(" document.liste.action[2].checked == true){\n");
g.addScript(" oneselected = true;\n");
g.addScript(" } else {\n");
g.addScript(" alert('Command not allowed on directory');\n");
g.addScript(" oneselected = false;\n");
g.addScript(" }\n");
g.addScript(" } else if (document.liste.scope[2].checked\n");
g.addScript(" == true){\n");
g.addScript(" //Matching files\n");
g.addScript(" if (document.liste.regval.value == ''){\n");
g.addScript(" alert('No regular expression specified.');\n");
g.addScript(" oneselected = false;\n");
g.addScript(" } else if (document.liste.action[3].checked "+
"== true || document.liste.action[4].checked == true){\n");
g.addScript(" alert('Command not allowed with regular "+
"expressions');\n");
g.addScript(" oneselected = false;\n");
g.addScript(" } else {\n");
g.addScript(" oneselected = true;\n");
g.addScript(" }\n");
g.addScript(" } else {\n");
g.addScript(" oneselected = true;\n");
g.addScript(" }\n");
g.addScript(" if (oneselected == false) {\n");
g.addScript(" submitOK = false;\n");
g.addScript(" } else if (document.liste.action[4].checked != \n");
g.addScript(" true){\n");
g.addScript(" submitOK = true;\n");
g.addScript(" } else if (confirm('Do you really want to remove "+
"these files ?')) {\n");
g.addScript(" submitOK = true;\n");
g.addScript(" } else {\n");
g.addScript(" submitOK = false;\n");
g.addScript(" }\n");
g.addScript("}\n\n");
g.addScript("function accFileSub() {\n");
g.addScript(" if (submitOK == false) {\n");
g.addScript(" submitOK = true;\n");
g.addScript(" return(false);\n");
g.addScript(" } else {\n");
g.addScript(" return(true);\n");
g.addScript(" }\n");
g.addScript("}\n");
g.addScript("function accDirSub() {\n");
g.addScript(" if (submitOK == false) {\n");
g.addScript(" submitOK = true;\n");
g.addScript(" return(false);\n");
g.addScript(" } else {\n");
g.addScript(" return(true);\n");
g.addScript(" }\n");
g.addScript("}\n");
// Dump all file entries:
Enumeration gen_enum = null;
try {
gen_enum = getCvsManager().listFiles() ;
names = Sorter.sortStringEnumeration(gen_enum);
nofile = (names.size() == 0);
} catch (CvsException ex) {
throw new HTTPException(error(this, request,
"unable to list files",ex));
}
// get a vector of directory entries
try {
gen_enum = getCvsManager().listDirectories();
dirnames = Sorter.sortStringEnumeration(gen_enum);
nodir = (dirnames.size() == 0);
} catch (CvsException ex) {
throw new HTTPException(error(this, request
, "unable to list directories"
, ex));
}
String head = " [ <a href=\"./\">Up to directory</A> ]";
if ( ! nofile ) {
head += " · [ <A HREF=\""+
resource.getURLPath()+"\">Files</A> ]";
if ( ! nodir )
head += " · [ <A HREF=\""+
resource.getURLPath()+
"?action=showdirs\">Directories</A> ]";
else
head += " · [ Directories ]";
} else if ( ! nodir ) {
head += " · [ Files ]";
head += " · [ <A HREF=\""+
resource.getURLPath()+
"?action=showdirs\">Directories</A> ]";
} else {
head += " · [ Files ]";
head += " · [ Directories ]";
}
head +=
" · [ <A HREF=\""+resource.getURLPath()+
"?action="+(showdirs? "refreshdirs" : "refreshfiles")+
"\">Refresh</A> ]";
g.append ("<A NAME=\"top\"></A>");
g.append("<center>",head,"<hr noshade width=\"80%\"></center>");
g.append("<center><div class=\"boxcenter\">");
g.append(" <a class=\"alphalink\" href=\"#"+
alphabet[0]+"\">"+alphabet[0]+"</a>");
for (int i = 1; i < alphabet.length; i++)
g.append(" · <a class=\"alphalink\" href=\"#"+alphabet[i]+
"\">"+alphabet[i]+"</a>");
g.append("</div></center>");
if (!nofile && !showdirs ) {
no_entries = false;
// now generate the form
g.append ("<center>");
g.append ("<form OnSubmit=\"return(accFileSub());\" "+
"name=\"liste\" action=\"", resource.getURLPath(),
"\" method=\"post\">\n");
g.append ("<table width=\"90%\" border=\"0\" cellspacing=\"0\"",
"cellpadding=\"0\" nosave>\n") ;
g.append ("<caption>FILES in ", parentpath, "</caption>\n");
// Dump entries, sorted:
int alphaidx = 0;
for (int i = 0 ; i < names.size() ; i++) {
String name = (String) names.elementAt(i);
char ch = name.charAt(0);
if (Character.isLetterOrDigit(ch)) {
if ((alphaidx == 0) || (ch != alphabet[alphaidx-1])) {
char alpha = alphabet[alphaidx];
while (ch != alpha) {
g.append("<a name=\""+alpha+"\"></a>\n");
alpha = alphabet[++alphaidx];
}
if (ch == alpha) {
g.append("<a name=\""+alpha+"\"></a>\n");
alphaidx++;
}
}
}
try {
dumpFileEntry (g, name) ;
} catch (CvsException ex) {
g.append ("<td>" + name +
"<strong>CVS Failed</strong>\n") ;
}
}
g.append ("<tr><td colspan=\"2\">");
g.append ("</center><a class=\"script\" "+
"href=\"javascript:SelectAll()\" "+
"onMouseOver=\"window.status="+
"'Select / Unselect all files';"+
"return true\">All/None</a><center>");
g.append ("</td></tr>");
g.append ("</table><p>\n") ;
// Dump the files command area:
g.append ("<hr noshade width=\"40%\">");
g.append ("<table cellpadding=\"10\" align=\"center\" "+
"width=\"90%\" border=\"0\" cellspacing=\"0\" "+
"cellpadding=\"0\">");
// add proposed actions
g.append ("<tr valign=\"top\"><td>");
g.append("<strong>Action:</strong><br>\n");
g.append("<input type=\"radio\" name=\"action\" value=\"addcom\">"
+ " Add into the repository <br>\n");
g.append("<input type=\"radio\" name=\"action\" value=\"commit\">"
+ " Incorporate changes into the repository <br>\n");
g.append("<input type=\"radio\" name=\"action\" value=\"update\" "
+ "checked = \"yes\"> Update <br>\n");
g.append("<input type=\"radio\" name=\"action\" value=\"revert\">"
+ " Revert to selected revision <br>\n");
g.append("<input type=\"radio\" name=\"action\" value=\"remove\">"+
" Remove from repository <br>\n");
g.append("</td>\n<td>\n");
// add proposed scopes:
g.append("<strong>Perform action on:</strong><br>\n\n");
g.append("<input type=\"radio\" name=\"scope\" value=\"mark\""
+ "checked=\"yes\"> Marked files<br>\n");
g.append("<input type=\"radio\" name=\"scope\" "
+ "value=\"directory\"> Directory<br>\n");
g.append("<input type=\"radio\" name=\"scope\" value=\"regexp\">"+
" Matching files <input type=\"text\" name=\"regval\">"+
"<br>\n");
g.append("</td></tr>");
// comments
g.append("<tr><td colspan=2 align=\"center\">\n");
g.append ("<p align=\"center\"><strong>Comments for " +
"add/remove/commit files<br>\n");
g.append ("<textarea wrap=\"soft\" name=\"comment\" rows=\"3\" "+
"cols=\"50\">\n") ;
g.append ("</textarea></td></tr>\n") ;
// and close the table and the first form
g.append ("<tr valign=\"top\"><td align=\"center\" " +
"colspan=\"2\">\n");
g.append ("<input type=\"submit\" name=\"submit\" " +
"value=\" Perform Action \" "+
"onClick=\"confirmFileAction();\">" );
g.append ("</table>");
g.append ("</form>\n\n");
g.append("</table>");
g.append("</center>\n");
}
if (!nodir && showdirs) {
no_entries = false;
// the next one is for stephan
g.append("<A NAME=\"dirs\"></A>");
// now generate the form
g.append ("<center>\n");
g.append("<form OnSubmit=\"return(accDirSub());\" name=\"liste\"",
" method=\"post\">\n");
//g.append("<table width=\"80%\">\n") ;
g.append ("<table width=\"90%\" border=\"0\" cellspacing=\"0\"",
"cellpadding=\"0\">\n") ;
g.append("<caption>SUBDIRECTORIES in ", parentpath,
"</caption>\n");
// Dump entries, sorted:
int alphaidx = 0;
for (int i = 0 ; i < dirnames.size() ; i++) {
String name = (String) dirnames.elementAt(i);
char ch = name.charAt(0);
if (Character.isLetterOrDigit(ch)) {
if ((alphaidx == 0) || (ch != alphabet[alphaidx-1])) {
char alpha = alphabet[alphaidx];
while (ch != alpha) {
g.append("<a name=\""+alpha+"\"></a>\n");
alpha = alphabet[++alphaidx];
}
if (ch == alpha) {
g.append("<a name=\""+alpha+"\"></a>\n");
alphaidx++;
}
}
}
try {
dumpDirectoryEntry (g, name) ;
} catch (CvsException e) {
g.append ("<td>" + name +
"<strong>CVS Failed</strong>\n") ;
}
}
g.append ("<tr><td colspan=\"2\">");
g.append ("</center><a class=\"script\" "+
"href=\"javascript:SelectAll()\" "+
"onMouseOver=\"window.status="+
"'Select / Unselect all files';"+
"return true\">All/None</a><center>");
g.append ("</td></tr>");
g.append ("</table><p>\n") ;
// Dump the dirs command area:
g.append ("<table align=\"center\" width=\"90%\" width=\"90%\" "+
"border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
g.append ("<input type=\"hidden\" name=\"action\" value=\"add\">");
//hidden scope
g.append ("<input type=\"hidden\" name=\"scope\""+
" value=\"subdir\">\n");
g.append ("<tr><td align=\"center\">",
"<input type=\"submit\" name=\"submit\" ",
"value=\"Add marked directories\" "+
"onClick=\"confirmDirAction();\">\n"+
"</td></tr>");
// and close the table and the first form
g.append ("</table></form>\n\n");
g.append("</center>\n");
}
if (no_entries) {
g.append("<center>No entries.</center><p>\n");
//new
g.append ("<form name=\"liste\""+
"action=\"", resource.getURLPath(),
"\" method=\"post\">\n");
g.append ("<table cellpadding=\"10\" align=\"center\" "+
"width=\"90%\" border=\"0\" cellspacing=\"0\" "+
"cellpadding=\"0\">");
// add proposed actions
g.append ("<tr valign=\"top\"><td>");
g.append("<input type=\"hidden\" name=\"action\" ",
"value=\"update\">");
// add proposed scopes:
g.append("<strong>Perform update on:</strong><br>\n\n");
g.append("<input type=\"radio\" name=\"scope\" "
+ "value=\"directory\"> Directory<br>\n");
g.append("<input type=\"radio\" name=\"scope\" value=\"regexp\">"+
" File <input type=\"text\" name=\"regval\">"+
"<br>\n");
g.append("</td></tr>");
// and close the table and the first form
g.append ("<tr valign=\"top\"><td align=\"center\" " +
"colspan=\"2\">\n");
g.append ("<input type=\"submit\" name=\"submit\" " +
"value=\" Update \">");
g.append ("</td></tr></table>");
g.append ("</form>\n\n");
//end new
} else {
g.append("<a name=\"bottom\"></a>");
g.append("<center><hr noshade width=\"80%\">",head,"</center>");
}
g.close() ;
// Send back the reply:
Reply reply = request.makeReply(HTTP.OK) ;
reply.setHeaderValue(reply.H_CACHE_CONTROL, CACHE_CONTROL_NOCACHE);
reply.setHeaderValue(reply.H_PRAGMA, PRAGMA_NOCACHE);
reply.setStream(g);