Skip to content

Commit

Permalink
Removed non necessary utility class.
Browse files Browse the repository at this point in the history
  • Loading branch information
moacirrf committed Sep 22, 2023
1 parent d421ca8 commit 081e917
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,44 @@
*/
package org.netbeans.modules.markdown.ui.preview.views;

import javax.swing.text.AbstractDocument;
import javax.swing.text.AttributeSet;
import javax.swing.text.Element;
import javax.swing.text.StyleConstants;
import javax.swing.text.View;
import javax.swing.text.html.HTML;
import javax.swing.text.html.HTMLEditorKit;

/**
* This class creates Views for a JEditorPane, it receives and HTML element
* and you must create the most similar swing component to this html element.
* For example a HTML input type checkbox, its a JCheckBox, and image can be a JLabel
* and so on.
*
* This class creates Views for a JEditorPane, it receives and HTML element and
* you must create the most similar swing component to this html element. For
* example a HTML input type checkbox, its a JCheckBox, and image can be a
* JLabel and so on.
*
* @author moacirrf
*/
public class MarkdownViewFactory extends HTMLEditorKit.HTMLFactory {

@Override
public View create(Element elem) {

if (ViewUtils.isElementOfTag(elem, HTML.Tag.INPUT)) {
if (isElementOfTag(elem, HTML.Tag.INPUT)) {
return new CheckboxView(elem);
}

return super.create(elem);
}

public boolean isElementOfTag(Element elem, HTML.Tag tag) {

AttributeSet attrs = elem.getAttributes();
Object elementName
= attrs.getAttribute(AbstractDocument.ElementNameAttribute);
Object o = (elementName != null)
? null : attrs.getAttribute(StyleConstants.NameAttribute);
HTML.Tag kind = (HTML.Tag) o;

return (o instanceof HTML.Tag) && (kind == tag);

}
}

This file was deleted.

0 comments on commit 081e917

Please sign in to comment.