1 package org.catacomb.druid.gui.base; 2 3 import org.catacomb.interlish.structure.*; 4 import org.catacomb.report.E; 5 6 7 import java.net.URL; 8 9 public class DruLinkHandler implements HyperlinkHandler { 10 11 12 PageSupplier pageSupplier; 13 PageDisplay pageDisplay; 14 15 String currentAddress; 16 17 18 public DruLinkHandler(PageSupplier ps, PageDisplay pd) { 19 pageSupplier = ps; 20 pageDisplay = pd; 21 22 } 23 24 25 public void hyperlinkClicked(String sin) { 26 String s = sin; 27 if (currentAddress != null) { 28 29 if (s.equals("...")) { 30 s = ""; 31 32 } else if (s.equals(".")) { 33 if (currentAddress.endsWith("/")) { 34 s = currentAddress.substring(0, currentAddress.length()-1); 35 } else { 36 s = currentAddress; 37 } 38 39 } else if (s.startsWith("./")) { 40 if (currentAddress.endsWith("/")) { 41 s = currentAddress + s.substring(2, s.length()); 42 } else { 43 s = currentAddress + s.substring(1, s.length()); 44 } 45 46 } else { 47 if (currentAddress.endsWith("/")) { 48 s = currentAddress + s; 49 } else { 50 s = currentAddress + "/" + s; 51 } 52 } 53 } 54 55 56 57 if (pageSupplier.canGet(s)) { 58 pageDisplay.showPage(pageSupplier.getPage(s)); 59 currentAddress = s; 60 61 } else { 62 E.warning("page supplier cant get " + s); 63 } 64 } 65 66 67 public void follow(URL u) { 68 E.error("dru link handler wont follow urls " + u); 69 } 70 71 }