Author: cdupoirieux
Date: Fri Mar 23 08:48:03 2007
New Revision: 521779
URL: http://svn.apache.org/viewvc?view=rev&rev=521779
Log:
FOR-962 - Add an options window to set the localhost and the port.
These are saved in user preferences.
Added:
forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarSettings.xul
(with props)
Modified:
forrest/trunk/tools/forrestbar/xpi/chrome/content/contents.rdf
forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarOverlay.js
forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarOverlay.xul
forrest/trunk/tools/forrestbar/xpi/install.rdf
Modified: forrest/trunk/tools/forrestbar/xpi/chrome/content/contents.rdf
URL:
http://svn.apache.org/viewvc/forrest/trunk/tools/forrestbar/xpi/chrome/content/contents.rdf?view=diff&rev=521779&r1=521778&r2=521779
==============================================================================
--- forrest/trunk/tools/forrestbar/xpi/chrome/content/contents.rdf (original)
+++ forrest/trunk/tools/forrestbar/xpi/chrome/content/contents.rdf Fri Mar 23
08:48:03 2007
@@ -17,14 +17,15 @@
-->
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
+ xmlns:chrome="http://www.mozilla.org/rdf/chrome#"
+ chrome:settingsURL="chrome://forrestbar/content/forrestbarSettings.xul">
<RDF:Seq about="urn:mozilla:package:root">
<RDF:li resource="urn:mozilla:package:forrestbar"/>
</RDF:Seq>
<RDF:Description about="urn:mozilla:package:forrestbar"
- chrome:extension="true" chrome:name="forrestbar"
chrome:displayName="ForrestBar 0.7"/>
+ chrome:extension="true" chrome:name="forrestbar"
chrome:displayName="ForrestBar 0.8"/>
<RDF:Seq about="urn:mozilla:overlays">
<RDF:li resource="chrome://browser/content/browser.xul"/>
Modified: forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarOverlay.js
URL:
http://svn.apache.org/viewvc/forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarOverlay.js?view=diff&rev=521779&r1=521778&r2=521779
==============================================================================
--- forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarOverlay.js
(original)
+++ forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarOverlay.js Fri
Mar 23 08:48:03 2007
@@ -28,6 +28,12 @@
{
removeEventListener ("load",startforrestbar, true); // Keep the event from
firing a hundred more times.
}
+ setLocalHostMenuItemLabel();
+}
+
+function setLocalHostMenuItemLabel()
+{
+ document.getElementById("forrest.run.menuitem").label="Local Forrest (" +
getLocalWebServer() + ")";
}
addEventListener("load", startforrestbar, true); // Run the startup function
when the window loads
@@ -96,8 +102,11 @@
function contract(subUrl,searchID)
{
- var searchItem = document.getElementById(searchID);
- navigate('http://localhost:8888/'+subUrl + searchItem.value);
+ if( isLocalUrlOrWarnMe() )
+ {
+ var searchItem = document.getElementById(searchID);
+ navigate(getLocalWebServerUrl() + subUrl + searchItem.value);
+ }
}
function navProject(searchID) {
@@ -108,12 +117,10 @@
function viewXML(xmltype)
{
var href = gBrowser.currentURI.spec;
- if( ! isLocalUrl())
+ if( isLocalUrlOrWarnMe() )
{
- alert("This action is only available on Local Forrest (jetty) site...");
- return(false);
+
(dispatcherCall)?navigate(getLocalWebServerUrl()+xmltype+href.substring(getLocalWebServerUrl().length,
href.lastIndexOf('.') )):navigate(href.substring(0, href.lastIndexOf('.') ) +
xmltype);
}
-
(dispatcherCall)?navigate("http://localhost:8888/"+xmltype+href.substring(href.lastIndexOf('8888/')+5,
href.lastIndexOf('.') )):navigate(href.substring(0, href.lastIndexOf('.') ) +
xmltype);
}
function isLocalUrl ()
@@ -122,11 +129,114 @@
return( (typeof(href) != 'undefined') &&
(href.substr) &&
- (startsWith(href, 'http://127.0.0.1:8888/') || startsWith(href,
'http://localhost:8888/'))
+ (startsWith(href, getLocalWebServerUrl() ))
);
}
+function isLocalUrlOrWarnMe()
+{
+ var isIt = isLocalUrl();
+ if( ! isIt )
+ {
+ alert("This action is only available on Local Forrest (jetty) site...");
+ }
+ return isIt;
+}
+
function startsWith(st, pref)
{
return( (pref.length > 0) && (st.substring(0, pref.length) == pref) );
}
+
+/* ----------- */
+/* Forrest Run */
+/* ----------- */
+function navigateForrestRun() {
+ navigate( getLocalWebServerUrl() );
+}
+
+function getLocalWebServer() {
+ var localhost= getForrestRunHost() + ":" + getForrestRunPort() ;
+ return localhost;
+}
+
+function getLocalWebServerUrl() {
+ var Url= "http://" + getLocalWebServer() + "/" ;
+ return Url;
+}
+
+/* ----------------- */
+/* Options functions */
+/* ----------------- */
+
+/* Getting preferences */
+function getForrestRunHost()
+{
+ var prefservice =
Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
+ var prefs = prefservice.getBranch("");
+
+ var forrestHost = null;
+ if (prefs.getPrefType("forrestbar.run.host") == prefs.PREF_STRING)
+ {
+ forrestHost = prefs.getCharPref("forrestbar.run.host");
+ }
+ if ((forrestHost == null) || (forrestHost.length = 0))
+ {
+ forrestHost='localhost';
+ }
+ return forrestHost;
+}
+
+function getForrestRunPort()
+{
+ var prefservice =
Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
+ var prefs = prefservice.getBranch("");
+
+ var forrestPort = null;
+ if (prefs.getPrefType("forrestbar.run.port") == prefs.PREF_STRING)
+ {
+ forrestPort = prefs.getCharPref("forrestbar.run.port");
+ }
+ if ((forrestPort == null) || (forrestPort.length = 0))
+ {
+ forrestPort='8888';
+ }
+ return forrestPort;
+}
+
+/* Initialising Options Panel */
+function initForrestBarOptions()
+{
+ document.getElementById('forrestbar.run.host').value = getForrestRunHost();
+ document.getElementById('forrestbar.run.port').value = getForrestRunPort();
+}
+
+/* recording Options in prefs */
+function setForrestBarOptions()
+{
+ var prefService = Components.classes["@mozilla.org/preferences-service;1"]
+ .getService(Components.interfaces.nsIPrefService);
+ var prefs = prefService.getBranch("");
+
+ var oldHost=getForrestRunHost();
+ var oldPort=getForrestRunPort();
+ var newHost=document.getElementById('forrestbar.run.host').value;
+ var newPort=document.getElementById('forrestbar.run.port').value;
+ var change=false;
+
+ if( oldHost != newHost )
+ {
+ change=true;
+ prefs.setCharPref("forrestbar.run.host", newHost);
+ }
+ if( oldPort != newPort )
+ {
+ change=true;
+ prefs.setCharPref("forrestbar.run.port", newPort);
+ }
+ if( change )
+ alert("Warning! the label of the Local Forrest item will be refreshed at
the next start of your browser...");
+
+ window.close();
+}
+
Modified:
forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarOverlay.xul
URL:
http://svn.apache.org/viewvc/forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarOverlay.xul?view=diff&rev=521779&r1=521778&r2=521779
==============================================================================
--- forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarOverlay.xul
(original)
+++ forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarOverlay.xul Fri
Mar 23 08:48:03 2007
@@ -35,10 +35,7 @@
<menuitem label="Docs for development version"
onclick="navigate('http://forrest.apache.org/docs/dev/');" />
<menuitem label="Testing Zone"
onclick="navigate('http://forrest.zones.apache.org/');" />
<menuseparator />
- <menuitem label="Local Forrest (localhost:8888)"
onclick="navigate('http://localhost:8888/');" hidden="false" />
- <menuitem label="Local Forrest (127.0.0.1:8888)"
onclick="navigate('http://127.0.0.1:8888/');" hidden="false" />
- <menuseparator />
- <menuitem label="Local Forrest (127.0.0.1:8080)"
onclick="navigate('http://127.0.0.1:8080/');" hidden="false" />
+ <menuitem label="Local Forrest (localhost:8888)"
onclick="navigateForrestRun();" hidden="false" id="forrest.run.menuitem"/>
</menupopup>
</toolbarbutton>
Added: forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarSettings.xul
URL:
http://svn.apache.org/viewvc/forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarSettings.xul?view=auto&rev=521779
==============================================================================
--- forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarSettings.xul
(added)
+++ forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarSettings.xul
Fri Mar 23 08:48:03 2007
@@ -0,0 +1,65 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!-- FIXME - should be forrestbar.css ... -->
+<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
+
+<dialog xmlns:html="http://www.w3.org/1999/xhtml"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ onload="initForrestBarOptions();"
+ ondialogaccept="setForrestBarOptions();"
+ title="Forrest Bar Options">
+
+ <html:script language="javascript"
src="chrome://forrestbar/content/forrestbarOverlay.js" />
+
+ <tabbox>
+ <tabs>
+ <tab label="Forrest Run Options"/>
+ </tabs>
+
+ <tabpanels>
+ <tabpanel>
+ <vbox>
+ <groupbox>
+ <caption label="Host"/>
+ <description>Indicate here the name of the host runing Forrest
Run.</description>
+ <hbox align="center">
+ <label control="forresthost" value="Host"/>
+ <menulist id="forrestbar.run.host">
+ <menupopup>
+ <menuitem label="localhost" value="localhost"/>
+ <menuitem label="127.0.0.1" value="127.0.0.1"/>
+ </menupopup>
+ </menulist>
+ </hbox>
+ <hbox align="center">
+ <label control="forrestport" value="Port"/>
+ <textbox id="forrestbar.run.port"
+ pref="true"
+ preftype="string"
+ prefstring="forrestbar.run.port"
+ size="15"
+ />
+ </hbox>
+ </groupbox>
+ </vbox>
+ </tabpanel>
+ </tabpanels>
+ </tabbox>
+</dialog>
+
Propchange:
forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarSettings.xul
------------------------------------------------------------------------------
svn:eol-style = native
Modified: forrest/trunk/tools/forrestbar/xpi/install.rdf
URL:
http://svn.apache.org/viewvc/forrest/trunk/tools/forrestbar/xpi/install.rdf?view=diff&rev=521779&r1=521778&r2=521779
==============================================================================
--- forrest/trunk/tools/forrestbar/xpi/install.rdf (original)
+++ forrest/trunk/tools/forrestbar/xpi/install.rdf Fri Mar 23 08:48:03 2007
@@ -22,6 +22,12 @@
<Description about="urn:mozilla:install-manifest">
<em:id>{057e51a0-7e81-4749-ad58-d5e32a6084a9}</em:id> <!-- need guid for
1.0 -->
<em:version>0.8-dev</em:version>
+ <em:contributor>Nicola Ken Barozzi</em:contributor>
+ <em:contributor>Dave Brondsema</em:contributor>
+ <em:contributor>David Crossley</em:contributor>
+ <em:contributor>Cyriaque Dupoirieux</em:contributor>
+ <em:contributor>Ross Gardler</em:contributor>
+ <em:contributor>Thorsten Scherler</em:contributor>
<!-- <em:type>2</em:type> only used in 1.5 and not needed for extensions. -->
<!-- Target Applications with minimum and maximum supported versions. -->
@@ -58,7 +64,7 @@
<em:description>Navigation and developer assistance for Apache
Forrest-related documentation frameworks</em:description>
<em:creator>Apache Forrest community</em:creator>
<em:homepageURL>http://www.forrest.apache.org/</em:homepageURL>
-
+
<em:optionsURL>chrome://forrestbar/content/forrestbarSettings.xul</em:optionsURL>
<!-- Need this for 1.0 compatibility -->
<em:file>
<Description about="urn:mozilla:extension:file:forrestbar.jar">