/** Resets the parser configuration. */ protected void reset() throws XMLConfigurationException { // reset components int size = fHTMLComponents.size(); for (int i = 0; i < size; i++) { HTMLComponent component = (HTMLComponent) fHTMLComponents.elementAt(i); component.reset(this); } // configure pipeline XMLDocumentSource lastSource = fDocumentScanner; if (getFeature(NAMESPACES)) { lastSource.setDocumentHandler(fNamespaceBinder); fNamespaceBinder.setDocumentSource(fTagBalancer); lastSource = fNamespaceBinder; } if (getFeature(BALANCE_TAGS)) { lastSource.setDocumentHandler(fTagBalancer); fTagBalancer.setDocumentSource(fDocumentScanner); lastSource = fTagBalancer; } XMLDocumentFilter[] filters = (XMLDocumentFilter[]) getProperty(FILTERS); if (filters != null) { for (int i = 0; i < filters.length; i++) { XMLDocumentFilter filter = filters[i]; XercesBridge.getInstance().XMLDocumentFilter_setDocumentSource(filter, lastSource); lastSource.setDocumentHandler(filter); lastSource = filter; } } lastSource.setDocumentHandler(fDocumentHandler); } // reset()
/** Adds a component. */ protected void addComponent(HTMLComponent component) { // add component to list fHTMLComponents.addElement(component); // add recognized features and set default states String[] features = component.getRecognizedFeatures(); addRecognizedFeatures(features); int featureCount = features != null ? features.length : 0; for (int i = 0; i < featureCount; i++) { Boolean state = component.getFeatureDefault(features[i]); if (state != null) { setFeature(features[i], state.booleanValue()); } } // add recognized properties and set default values String[] properties = component.getRecognizedProperties(); addRecognizedProperties(properties); int propertyCount = properties != null ? properties.length : 0; for (int i = 0; i < propertyCount; i++) { Object value = component.getPropertyDefault(properties[i]); if (value != null) { setProperty(properties[i], value); } } } // addComponent(HTMLComponent)
/** Sets a feature. */ public void setFeature(String featureId, boolean state) throws XMLConfigurationException { super.setFeature(featureId, state); int size = fHTMLComponents.size(); for (int i = 0; i < size; i++) { HTMLComponent component = (HTMLComponent) fHTMLComponents.elementAt(i); component.setFeature(featureId, state); } } // setFeature(String,boolean)
/** Sets a property. */ public void setProperty(String propertyId, Object value) throws XMLConfigurationException { super.setProperty(propertyId, value); if (propertyId.equals(FILTERS)) { XMLDocumentFilter[] filters = (XMLDocumentFilter[]) getProperty(FILTERS); if (filters != null) { for (int i = 0; i < filters.length; i++) { XMLDocumentFilter filter = filters[i]; if (filter instanceof HTMLComponent) { addComponent((HTMLComponent) filter); } } } } int size = fHTMLComponents.size(); for (int i = 0; i < size; i++) { HTMLComponent component = (HTMLComponent) fHTMLComponents.elementAt(i); component.setProperty(propertyId, value); } } // setProperty(String,Object)
static void processLink(HTMLComponent htmlC, String link) { boolean process = true; if (htmlC.getHTMLCallback() != null) { process = htmlC.getHTMLCallback().linkClicked(htmlC, htmlC.convertURL(link)); } if (process) { if (!link.startsWith("#")) { htmlC.setPage(htmlC.convertURL(link)); } else { // local anchor String anchorName = link.substring(1); htmlC.goToAnchor(anchorName); } } }
/** * Constructs the HTMLLink * * @param text The link's text * @param link The link URL * @param htmlC The HTMLComponent this link is in * @param parentLink THis link's parent if available */ HTMLLink( String text, String link, HTMLComponent htmlC, HTMLLink parentLink, boolean linkVisited) { super(text); setUIID("HTMLLink"); this.link = link; this.htmlC = htmlC; this.parentLink = parentLink; this.linkVisited = linkVisited; setTickerEnabled(false); addActionListener(this); if (parentLink != null) { setFocusable(false); parentLink.addChildLink(this); } if (htmlC.firstFocusable == null) { htmlC.firstFocusable = this; } }