1 11 12 13 package org.eclipse.ui.internal.intro.impl.model.url; 14 15 import org.eclipse.ui.PlatformUI; 16 import org.eclipse.ui.internal.intro.impl.IntroPlugin; 17 import org.eclipse.ui.internal.intro.impl.model.AbstractIntroElement; 18 import org.eclipse.ui.internal.intro.impl.model.AbstractIntroPage; 19 import org.eclipse.ui.internal.intro.impl.model.IntroModelRoot; 20 import org.eclipse.ui.internal.intro.impl.model.IntroPartPresentation; 21 import org.eclipse.ui.internal.intro.impl.presentations.BrowserIntroPartImplementation; 22 import org.eclipse.ui.internal.intro.impl.util.Log; 23 24 public class ShowHelpURLHandler { 25 private IntroURL introURL = null; 26 27 ShowHelpURLHandler(IntroURL url) { 28 this.introURL = url; 29 } 30 31 32 33 public boolean showHelpTopic(String href, String embed, String embedTarget) { 34 if (href == null) 35 return false; 36 37 boolean isEmbedded = (embed != null && embed 38 .equals(IntroURL.VALUE_TRUE)) ? true : false; 39 if (isEmbedded == false) 40 isEmbedded = (embedTarget != null) ? true : false; 44 45 IntroPartPresentation presentation = IntroPlugin.getDefault() 46 .getIntroModelRoot().getPresentation(); 47 String presentationStyle = presentation.getImplementationKind(); 48 49 if (isEmbedded 50 && presentationStyle 51 .equals(IntroPartPresentation.BROWSER_IMPL_KIND)) { 52 53 BrowserIntroPartImplementation impl = (BrowserIntroPartImplementation) presentation 56 .getIntroPartImplementation(); 57 href = PlatformUI.getWorkbench().getHelpSystem() 59 .resolve(href, true).toExternalForm(); 60 61 if (embedTarget == null) 62 return impl.getBrowser().setUrl(href); 63 64 IntroModelRoot model = IntroPlugin.getDefault().getIntroModelRoot(); 66 return handleEmbedURLInDiv(href, embedTarget, model 67 .getCurrentPage()); 68 } 69 70 PlatformUI.getWorkbench().getHelpSystem().displayHelpResource(href); 73 return true; 74 } 75 76 77 83 private boolean handleEmbedURLInDiv(String href, String embedTarget, 84 AbstractIntroPage currentPage) { 85 86 IntroModelRoot model = (IntroModelRoot) currentPage.getParentPage() 89 .getParent(); 90 String currentPageId = null; 91 if (currentPage.isIFramePage()) 92 currentPageId = currentPage.getUnmangledId(); 93 else 94 currentPageId = currentPage.getId(); 95 String mangledPageId = currentPageId + "_" + "WITH_IFRAME"; 97 boolean standby = IntroPlugin.isIntroStandby(); 99 String standbyAsString = standby ? IntroURL.VALUE_TRUE : "false"; 101 AbstractIntroPage pageWithIFrame = (AbstractIntroPage) model.findChild( 102 mangledPageId, AbstractIntroElement.ABSTRACT_PAGE); 103 if (pageWithIFrame != null) { 104 pageWithIFrame.setIFrameURL(href); 105 return introURL.showPage(mangledPageId, standbyAsString); 106 } 107 108 AbstractIntroPage clonedPage = null; 110 try { 111 clonedPage = (AbstractIntroPage) currentPage.clone(); 112 } catch (CloneNotSupportedException ex) { 113 Log.error("Failed to clone Intro page: " + currentPage.getId(), ex); return false; 116 } 117 118 boolean canInjectFrame = clonedPage.injectIFrame(href, embedTarget); 121 if (!canInjectFrame) 122 return false; 124 125 clonedPage.setId(mangledPageId); 126 model.addChild(clonedPage); 127 return introURL.showPage(clonedPage.getId(), standbyAsString); 128 } 129 130 } 131 | Popular Tags |