1 11 package org.eclipse.ui.internal.intro.impl.presentations; 12 13 import org.eclipse.swt.browser.Browser; 14 import org.eclipse.swt.browser.LocationEvent; 15 import org.eclipse.swt.browser.LocationListener; 16 import org.eclipse.ui.internal.intro.impl.model.AbstractIntroPage; 17 import org.eclipse.ui.internal.intro.impl.model.IntroModelRoot; 18 import org.eclipse.ui.internal.intro.impl.model.url.IntroURL; 19 import org.eclipse.ui.internal.intro.impl.model.url.IntroURLParser; 20 21 25 public class BrowserIntroPartLocationListener implements LocationListener { 26 27 private BrowserIntroPartImplementation implementation; 28 29 32 public BrowserIntroPartLocationListener( 33 BrowserIntroPartImplementation implementation) { 34 this.implementation = implementation; 35 } 36 37 42 public void changed(LocationEvent event) { 43 String url = event.location; 44 if (url == null) 45 return; 46 47 Browser browser = (Browser) event.getSource(); 49 if (browser.getData("navigation") != null && browser.getData("navigation").equals("true")) return; 52 53 IntroModelRoot model = implementation.getModel(); 54 IntroURLParser parser = new IntroURLParser(url); 55 if (!parser.hasProtocol() || parser.getHost() == null 56 || parser.getHost().equals("")) return; 62 63 if (model.isDynamic()) { 64 if (browser.getData("frameNavigation") != null) { if (event.top == false && browser.getData("tempUrl") != null && browser.getData("tempUrl").equals("true")) { implementation.getHistory().removeLastHistory(); 76 flagRemovedTempUrl(); 77 } 78 } 79 80 if (event.top == true) { 81 flagStartOfFrameNavigation(); 84 implementation.updateHistory(url); 85 } 86 87 if (browser.getData("frameNavigation") == null && event.top == false) { 89 AbstractIntroPage currentPage = model.getCurrentPage(); 94 if (currentPage.isIFramePage()) { 95 currentPage.setIFrameURL(url); 101 implementation.updateHistory(currentPage); 102 } else { 103 flagStartOfFrameNavigation(); 104 flagStoredTempUrl(); 105 implementation.updateHistory(url); 106 } 107 } 108 109 } 110 return; 111 } 112 113 118 public void changing(LocationEvent event) { 119 String url = event.location; 120 if (url == null) 121 return; 122 123 IntroModelRoot model = implementation.getModel(); 124 IntroURLParser parser = new IntroURLParser(url); 125 if (parser.hasIntroUrl()) { 126 event.doit = false; 128 IntroURL introURL = parser.getIntroURL(); 130 introURL.execute(); 131 132 if (model.isDynamic()) { 138 if ((introURL.getParameter(IntroURL.KEY_EMBED_TARGET) != null) 139 && introURL.getAction().equals(IntroURL.SHOW_PAGE)) 140 flagStartOfNavigation(); 141 } 142 return; 143 } 144 145 146 } 147 148 149 150 151 public void flagStartOfFrameNavigation() { 152 if (implementation.getBrowser().getData("frameNavigation") == null) implementation.getBrowser().setData("frameNavigation", "true"); } 155 156 public void flagEndOfFrameNavigation() { 157 implementation.getBrowser().setData("frameNavigation", null); } 159 160 161 public void flagStartOfNavigation() { 162 if (implementation.getBrowser().getData("navigation") == null) implementation.getBrowser().setData("navigation", "true"); } 165 166 public void flagEndOfNavigation() { 167 implementation.getBrowser().setData("navigation", null); } 169 170 171 public void flagStoredTempUrl() { 172 if (implementation.getBrowser().getData("tempUrl") == null) implementation.getBrowser().setData("tempUrl", "true"); } 175 176 public void flagRemovedTempUrl() { 177 implementation.getBrowser().setData("tempUrl", null); } 179 180 181 } 182 | Popular Tags |