diff options
author | Jonathan Bauer | 2015-03-03 19:02:48 +0100 |
---|---|---|
committer | Jonathan Bauer | 2015-03-03 19:02:48 +0100 |
commit | 0447841f3a08890bf746625d0f17976adada6ac8 (patch) | |
tree | f63bd9f2ac8d77f4732b70cac8e5c0497f4d3a45 /dozentenmodul/src/main/java/util/OpenLinks.java | |
parent | warnings fix (diff) | |
download | tutor-module-0447841f3a08890bf746625d0f17976adada6ac8.tar.gz tutor-module-0447841f3a08890bf746625d0f17976adada6ac8.tar.xz tutor-module-0447841f3a08890bf746625d0f17976adada6ac8.zip |
bwIDM - Shibboleth login working for Freiburg's SP - more to come
rework GUI classes to work with GuiManager: use GuiManager.show(<GUI to show>) and GuiManager.openPopup(<popup like About_GUI or ListAllOtherUsers_GUI>) only!
static openlinks class (models/links.java deleted). There are keywords to open links, e.g. OpenLinks.openWebpage("faq"). Please see the class.
Diffstat (limited to 'dozentenmodul/src/main/java/util/OpenLinks.java')
-rw-r--r-- | dozentenmodul/src/main/java/util/OpenLinks.java | 61 |
1 files changed, 59 insertions, 2 deletions
diff --git a/dozentenmodul/src/main/java/util/OpenLinks.java b/dozentenmodul/src/main/java/util/OpenLinks.java index 2dd7b936..51695c96 100644 --- a/dozentenmodul/src/main/java/util/OpenLinks.java +++ b/dozentenmodul/src/main/java/util/OpenLinks.java @@ -2,17 +2,74 @@ package util; import java.awt.Desktop; import java.net.URI; +import java.net.URISyntaxException; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; import javax.swing.JOptionPane; +import org.apache.log4j.Logger; + public class OpenLinks { - public static void openWebpage(URI uri) { + /** + * Logger instance for this class + */ + private final static Logger LOGGER = Logger.getLogger(ShibbolethECP.class); + + /** + * Map containing the links + */ + @SuppressWarnings("serial") + private static Map<String, String> links = Collections.unmodifiableMap(new HashMap<String, String>(){{ + put("faq", "http://bwlehrpool.hs-offenburg.de"); + put("otrs", "http://bwlehrpool.hs-offenburg.de"); + put("vmware", "https://my.vmware.com/de/web/vmware/free#desktop_end_user_computing/vmware_player/6_0"); + put("intro", "http://www.hs-offenburg.de/fileadmin/Einrichtungen/hrz/Projekte/bwLehrpool/3_bwLehrpool_-_Image_einbinden_und_starten.pdf"); + + }}); + + /** + * Static URIs + */ + + private static Map<String, URI> uris; + static { + // temp map + Map<String, URI> tmpUris = new HashMap<String, URI>(); + for (String key : links.keySet()) { + URI tmp; + try { + tmp = new URI(links.get(key)); + } catch (URISyntaxException e) { + // should never happen! + LOGGER.error("Bad URI syntax of '" + key + "', see trace: ", e); + tmp = null; + } + tmpUris.put(key, tmp); + } + // check sizes of maps to be equal + if (links.size() != tmpUris.size()) { + LOGGER.error("Links and URIs have different sizes, this should not happen. Contact a developper."); + } + + // all good, save it to the actual 'uris' map + uris = Collections.unmodifiableMap(tmpUris); + } + + + public static void openWebpage(String key) { + // first check if we have the link for the request key + if (!uris.containsKey(key)) { + LOGGER.error("OpenLinks has to link to '" + key + "'. Check if the given key actually exists."); + return; + } Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null; if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) { try { - desktop.browse(uri); + desktop.browse(uris.get(key)); } catch (Exception e) { e.printStackTrace(); JOptionPane.showMessageDialog(null, |