summaryrefslogtreecommitdiff
path: root/BKULocal/src/main/java
diff options
context:
space:
mode:
authorclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2008-11-03 09:37:14 +0000
committerclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2008-11-03 09:37:14 +0000
commit9829de9c9b19dcca15676aaf9737195cc059a66c (patch)
tree46f1061f8b586a35965bf81e7f50c864437dae45 /BKULocal/src/main/java
parent4032e46810c24dc3f013de296a2133f4651696b9 (diff)
downloadmocca-9829de9c9b19dcca15676aaf9737195cc059a66c.tar.gz
mocca-9829de9c9b19dcca15676aaf9737195cc059a66c.tar.bz2
mocca-9829de9c9b19dcca15676aaf9737195cc059a66c.zip
local HelpListener DesktopAPI
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@138 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'BKULocal/src/main/java')
-rw-r--r--BKULocal/src/main/java/at/gv/egiz/bku/local/gui/LocalHelpListener.java20
-rw-r--r--BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTALFactory.java30
-rw-r--r--BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/BKURequestHandler.java5
3 files changed, 40 insertions, 15 deletions
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/gui/LocalHelpListener.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/gui/LocalHelpListener.java
index ebec9c65..e32c9c3d 100644
--- a/BKULocal/src/main/java/at/gv/egiz/bku/local/gui/LocalHelpListener.java
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/gui/LocalHelpListener.java
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package at.gv.egiz.bku.local.gui;
import at.gv.egiz.bku.gui.AbstractHelpListener;
@@ -22,6 +21,7 @@ import java.awt.Desktop;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
+import java.util.Locale;
/**
*
@@ -29,13 +29,25 @@ import java.net.URL;
*/
public class LocalHelpListener extends AbstractHelpListener {
- public LocalHelpListener(URL baseURL, String locale) {
+ protected Desktop desktop;
+
+ public LocalHelpListener(URL baseURL, Locale locale) {
super(baseURL, locale);
+ if (Desktop.isDesktopSupported()) {
+ desktop = Desktop.getDesktop();
+ }
}
@Override
public void showDocument(URL helpDocument) throws IOException, URISyntaxException {
- Desktop.getDesktop().browse(helpDocument.toURI());
+ if (desktop == null) {
+ log.error("Failed to open default browser: Desktop API not available (libgnome installed?)");
+ } else {
+ if (!desktop.isSupported(Desktop.Action.BROWSE)) {
+ log.error("Failed to open default browser: The system provides the Desktop API, but does not support the BROWSE action");
+ } else {
+ Desktop.getDesktop().browse(helpDocument.toURI());
+ }
+ }
}
-
}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTALFactory.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTALFactory.java
index d3530332..4cc7bcd3 100644
--- a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTALFactory.java
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTALFactory.java
@@ -32,30 +32,38 @@ import at.gv.egiz.bku.online.applet.BKUApplet;
import at.gv.egiz.stal.STAL;
import at.gv.egiz.stal.STALFactory;
import java.net.URL;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
public class SMCCSTALFactory implements STALFactory {
- private Locale locale;
+ protected static final Log log = LogFactory.getLog(SMCCSTALFactory.class);
+ protected String helpURL;
+ protected Locale locale;
@Override
public STAL createSTAL() {
-
+
SMCCSTAL stal;
JDialog dialog;
ResourceBundle resourceBundle;
if (locale != null) {
resourceBundle = ResourceBundle.getBundle(BKUApplet.RESOURCE_BUNDLE_BASE,
- locale);
+ locale);
} else {
resourceBundle = ResourceBundle.getBundle(BKUApplet.RESOURCE_BUNDLE_BASE);
}
dialog = new JDialog();
BKUGUIFacade gui = BKUGUIFactory.createGUI(BKUGUIFactory.ADVANCED_GUI);
- LocalHelpListener helpListener =null;
+ LocalHelpListener helpListener = null;
try {
- helpListener = new LocalHelpListener(new URL("http://localhost:3495/help"), "en");
+ if (helpURL != null) {
+ helpListener = new LocalHelpListener(new URL(helpURL), locale);
+ } else {
+ log.warn("no HELP URL configured, help system disabled");
+ }
} catch (MalformedURLException ex) {
- ex.printStackTrace();
+ log.error("failed to configure help listener: " + ex.getMessage(), ex);
}
gui.init(dialog.getContentPane(), locale.toString(), null, helpListener);
stal = new SMCCSTAL(new BKUGuiProxy(dialog, gui), dialog, resourceBundle);
@@ -72,7 +80,7 @@ public class SMCCSTALFactory implements STALFactory {
frameSize.width = screenSize.width;
}
dialog.setLocation((screenSize.width - frameSize.width) / 2,
- (screenSize.height - frameSize.height) / 2);
+ (screenSize.height - frameSize.height) / 2);
return stal;
}
@@ -80,4 +88,12 @@ public class SMCCSTALFactory implements STALFactory {
public void setLocale(Locale locale) {
this.locale = locale;
}
+
+ public String getHelpURL() {
+ return helpURL;
+ }
+
+ public void setHelpURL(String helpURL) {
+ this.helpURL = helpURL;
+ }
}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/BKURequestHandler.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/BKURequestHandler.java
index f19b86b5..62705d1e 100644
--- a/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/BKURequestHandler.java
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/BKURequestHandler.java
@@ -16,7 +16,6 @@
*/
package at.gv.egiz.bku.local.webapp;
-import java.io.IOException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
@@ -30,12 +29,10 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.springframework.web.HttpRequestHandler;
import at.gv.egiz.bku.binding.BindingProcessorManager;
import at.gv.egiz.bku.binding.HTTPBindingProcessor;
import at.gv.egiz.bku.binding.HttpUtil;
-import at.gv.egiz.bku.utils.StreamUtil;
import at.gv.egiz.org.apache.tomcat.util.http.AcceptLanguage;
public abstract class BKURequestHandler extends HttpServlet {
@@ -68,7 +65,7 @@ public abstract class BKURequestHandler extends HttpServlet {
bindingProcessor.setHTTPHeaders(headerMap);
bindingProcessor.consumeRequestStream(req.getInputStream());
- // fixxme just for testing
+ // fixxme just for testing
bindingProcessor.run();
if (bindingProcessor.getRedirectURL() != null) {
resp.sendRedirect(bindingProcessor.getRedirectURL());