Search in sources :

Example 26 with HTMLDocument

use of javax.swing.text.html.HTMLDocument in project android by JetBrains.

the class LintNotificationPanel method hyperlinkUpdate.

// ---- Implements HyperlinkListener ----
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
    if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
        JEditorPane pane = (JEditorPane) e.getSource();
        if (e instanceof HTMLFrameHyperlinkEvent) {
            HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent) e;
            HTMLDocument doc = (HTMLDocument) pane.getDocument();
            doc.processHTMLFrameHyperlinkEvent(evt);
            return;
        }
        String url = e.getDescription();
        NlModel model = myScreenView.getModel();
        Module module = model.getModule();
        PsiFile file = model.getFile();
        DataContext dataContext = DataManager.getInstance().getDataContext(myScreenView.getSurface());
        assert dataContext != null;
        myLinkManager.handleUrl(url, module, file, dataContext, null);
    }
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) HTMLFrameHyperlinkEvent(javax.swing.text.html.HTMLFrameHyperlinkEvent) HTMLDocument(javax.swing.text.html.HTMLDocument) NlModel(com.android.tools.idea.uibuilder.model.NlModel) PsiFile(com.intellij.psi.PsiFile) Module(com.intellij.openapi.module.Module)

Example 27 with HTMLDocument

use of javax.swing.text.html.HTMLDocument in project jdk8u_jdk by JetBrains.

the class bug8028616 method main.

public static void main(String[] args) throws Exception {
    ParserCB cb = new ParserCB();
    HTMLEditorKit htmlKit = new HTMLEditorKit();
    HTMLDocument htmlDoc = (HTMLDocument) htmlKit.createDefaultDocument();
    htmlDoc.getParser().parse(new StringReader(text), cb, true);
    synchronized (lock) {
        if (!isCallbackInvoked) {
            lock.wait(5000);
        }
    }
    if (!isCallbackInvoked) {
        throw new RuntimeException("Test Failed: ParserCallback.handleText() is not invoked for text - " + text);
    }
    if (exception != null) {
        throw exception;
    }
}
Also used : HTMLDocument(javax.swing.text.html.HTMLDocument) StringReader(java.io.StringReader) HTMLEditorKit(javax.swing.text.html.HTMLEditorKit)

Example 28 with HTMLDocument

use of javax.swing.text.html.HTMLDocument in project adempiere by adempiere.

the class Help method loadInfo.

//	jbInit
/*************************************************************************
	 *	Load Info - Windows Help
	 *  @param mWindow window model
	 */
private void loadInfo(GridWindow mWindow) {
    WebDoc doc = mWindow.getHelpDoc(true);
    HTMLDocument htmlDoc = (HTMLDocument) info.getEditorKit().createDefaultDocument();
    htmlDoc.getDocumentProperties().put("IgnoreCharsetDirective", true);
    info.setDocument(htmlDoc);
    info.setText(doc.toString());
}
Also used : WebDoc(org.compiere.util.WebDoc) HTMLDocument(javax.swing.text.html.HTMLDocument)

Example 29 with HTMLDocument

use of javax.swing.text.html.HTMLDocument in project adempiere by adempiere.

the class Worker method dumpTags.

//  run
/**
	 * 	Diagnostics
	 * 	@param doc html document
	 * 	@param tag html tag
	 */
private void dumpTags(HTMLDocument doc, HTML.Tag tag) {
    System.out.println("Doc=" + doc.getBase() + ", Tag=" + tag);
    HTMLDocument.Iterator it = doc.getIterator(tag);
    while (it != null && it.isValid()) {
        AttributeSet as = it.getAttributes();
        System.out.println("~ " + as);
        it.next();
    }
}
Also used : AttributeSet(javax.swing.text.AttributeSet) HTMLDocument(javax.swing.text.html.HTMLDocument)

Example 30 with HTMLDocument

use of javax.swing.text.html.HTMLDocument in project adempiere by adempiere.

the class Worker method hyperlinkUpdate.

/**************************************************************************
	 *	Hyperlink Listener
	 *  @param e event
	 */
public void hyperlinkUpdate(HyperlinkEvent e) {
    //	System.out.println("OnlineHelp.hyperlinkUpdate - " + e.getDescription() + " " + e.getURL());
    if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED)
        return;
    this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    //
    if (e instanceof HTMLFrameHyperlinkEvent) {
        HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent) e;
        HTMLDocument doc = (HTMLDocument) getDocument();
        doc.processHTMLFrameHyperlinkEvent(evt);
    } else if (e.getURL() == null)
        //	remove # of the reference
        scrollToReference(e.getDescription().substring(1));
    else {
        try {
            setPage(e.getURL());
        } catch (Throwable t) {
            System.err.println("Help.hyperlinkUpdate - " + t.toString());
            displayError("Error", e.getURL(), t);
        }
    }
    this.setCursor(Cursor.getDefaultCursor());
}
Also used : HTMLFrameHyperlinkEvent(javax.swing.text.html.HTMLFrameHyperlinkEvent) HTMLDocument(javax.swing.text.html.HTMLDocument)

Aggregations

HTMLDocument (javax.swing.text.html.HTMLDocument)30 HTMLEditorKit (javax.swing.text.html.HTMLEditorKit)10 Element (javax.swing.text.Element)6 StyleSheet (javax.swing.text.html.StyleSheet)6 URL (java.net.URL)5 AttributeSet (javax.swing.text.AttributeSet)5 BadLocationException (javax.swing.text.BadLocationException)5 IOException (java.io.IOException)4 Document (javax.swing.text.Document)4 Style (javax.swing.text.Style)3 InputStream (java.io.InputStream)2 InputStreamReader (java.io.InputStreamReader)2 StringReader (java.io.StringReader)2 URLConnection (java.net.URLConnection)2 ArrayList (java.util.ArrayList)2 HyperlinkEvent (javax.swing.event.HyperlinkEvent)2 SimpleAttributeSet (javax.swing.text.SimpleAttributeSet)2 HTMLFrameHyperlinkEvent (javax.swing.text.html.HTMLFrameHyperlinkEvent)2 NlModel (com.android.tools.idea.uibuilder.model.NlModel)1 DataContext (com.intellij.openapi.actionSystem.DataContext)1