Search in sources :

Example 1 with HTMLPage

use of com.ramussoft.core.attribute.simple.HTMLPage in project ramus by Vitaliy-Yakovchuk.

the class Out method print.

@SuppressWarnings("unchecked")
@Override
public void print(Object object) {
    if (object == null)
        return;
    if (object instanceof Number) {
        print(numberFormat.format(object));
        return;
    }
    if (object instanceof Date) {
        print(dateFormat.format(object));
        return;
    }
    if (object instanceof List) {
        List list = (List) object;
        boolean first = true;
        for (Object obj : list) {
            if (first)
                first = false;
            else
                print("; ");
            print(obj);
        }
        return;
    }
    if (object instanceof HTMLPage) {
        try {
            printHTMLPage((HTMLPage) object);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return;
    }
    if (object instanceof Source) {
        try {
            printHTMLPage((Source) object);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return;
    }
    if (object instanceof Object[]) {
        Object[] objects = (Object[]) object;
        boolean first = true;
        for (Object object2 : objects) {
            if (first)
                first = false;
            else
                print("; ");
            print(object2);
        }
    } else
        super.print(object);
}
Also used : HTMLPage(com.ramussoft.core.attribute.simple.HTMLPage) UnsupportedEncodingException(java.io.UnsupportedEncodingException) List(java.util.List) IOException(java.io.IOException) Date(java.util.Date) Source(net.htmlparser.jericho.Source)

Example 2 with HTMLPage

use of com.ramussoft.core.attribute.simple.HTMLPage in project ramus by Vitaliy-Yakovchuk.

the class HTMLEditPanel method getValue.

@Override
public Object getValue() {
    String text = jTextPane.getText();
    if (emptyValue.equals(text)) {
        if ((page == null) || (page.isEmpty()))
            return null;
        return page;
    }
    HTMLPage p;
    try {
        p = new HTMLPage(text.getBytes("UTF8"), (page != null) ? page.getPath() : null);
        return p;
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    return null;
}
Also used : HTMLPage(com.ramussoft.core.attribute.simple.HTMLPage) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 3 with HTMLPage

use of com.ramussoft.core.attribute.simple.HTMLPage in project ramus by Vitaliy-Yakovchuk.

the class HTMLEditPanel method createHtmlEditor.

private void createHtmlEditor() {
    if (page == null) {
        String text = jTextPane.getText();
        try {
            page = new HTMLPage(text.getBytes("UTF8"), (page != null) ? page.getPath() : null);
            ((Journaled) engine).startUserTransaction();
            engine.setAttribute(element, attribute, page);
            ((Journaled) engine).commitUserTransaction();
            HTMLPage page = (HTMLPage) engine.getAttribute(element, attribute);
            page.setEmpty(true);
            setValue(page);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    }
    if (openEditor()) {
        updateEditing();
    }
}
Also used : HTMLPage(com.ramussoft.core.attribute.simple.HTMLPage) Journaled(com.ramussoft.common.journal.Journaled) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Aggregations

HTMLPage (com.ramussoft.core.attribute.simple.HTMLPage)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 Journaled (com.ramussoft.common.journal.Journaled)1 IOException (java.io.IOException)1 Date (java.util.Date)1 List (java.util.List)1 Source (net.htmlparser.jericho.Source)1