Search in sources :

Example 6 with HTMLPart

use of org.olat.modules.portfolio.model.HTMLPart in project OpenOLAT by OpenOLAT.

the class HTMLRawPageElementHandler method getContent.

@Override
public PageRunElement getContent(UserRequest ureq, WindowControl wControl, PageElement element, PageElementRenderingHints options) {
    String content = "";
    if (element instanceof HTMLPart) {
        content = ((HTMLPart) element).getContent();
        content = Formatter.formatLatexFormulas(content);
    }
    TextComponent cmp = TextFactory.createTextComponentFromString("htmlRawCmp" + CodeHelper.getRAMUniqueID(), content, null, false, null);
    cmp.setElementCssClass("o_pf_html_raw");
    return new PageRunComponent(cmp);
}
Also used : TextComponent(org.olat.core.gui.components.text.TextComponent) PageRunComponent(org.olat.modules.portfolio.ui.editor.PageRunComponent) HTMLPart(org.olat.modules.portfolio.model.HTMLPart)

Example 7 with HTMLPart

use of org.olat.modules.portfolio.model.HTMLPart in project openolat by klemens.

the class PageDAOTest method moveParts.

@Test
public void moveParts() {
    Page page = pageDao.createAndPersist("Page 1", "A page with content.", null, null, true, null, null);
    dbInstance.commitAndCloseSession();
    HTMLPart htmlPart = new HTMLPart();
    PageBody reloadedBody = pageDao.loadPageBodyByKey(page.getBody().getKey());
    pageDao.persistPart(reloadedBody, htmlPart);
    dbInstance.commitAndCloseSession();
    TitlePart titlePart = new TitlePart();
    reloadedBody = pageDao.loadPageBodyByKey(page.getBody().getKey());
    pageDao.persistPart(reloadedBody, titlePart, 0);
    dbInstance.commitAndCloseSession();
    SpacerPart spacePart = new SpacerPart();
    reloadedBody = pageDao.loadPageBodyByKey(page.getBody().getKey());
    pageDao.persistPart(reloadedBody, spacePart, 0);
    dbInstance.commitAndCloseSession();
    // check the order
    List<PagePart> reloadedPageParts = pageDao.getParts(reloadedBody);
    Assert.assertNotNull(reloadedPageParts);
    Assert.assertEquals(3, reloadedPageParts.size());
    Assert.assertEquals(spacePart, reloadedPageParts.get(0));
    Assert.assertEquals(titlePart, reloadedPageParts.get(1));
    Assert.assertEquals(htmlPart, reloadedPageParts.get(2));
    // move title part up
    reloadedBody = pageDao.loadPageBodyByKey(page.getBody().getKey());
    pageDao.moveUpPart(reloadedBody, titlePart);
    dbInstance.commitAndCloseSession();
    List<PagePart> moveUpPageParts = pageDao.getParts(reloadedBody);
    Assert.assertNotNull(moveUpPageParts);
    Assert.assertEquals(3, moveUpPageParts.size());
    Assert.assertEquals(titlePart, moveUpPageParts.get(0));
    Assert.assertEquals(spacePart, moveUpPageParts.get(1));
    Assert.assertEquals(htmlPart, moveUpPageParts.get(2));
    // move space part down
    reloadedBody = pageDao.loadPageBodyByKey(page.getBody().getKey());
    pageDao.moveDownPart(reloadedBody, spacePart);
    dbInstance.commitAndCloseSession();
    List<PagePart> moveDownPageParts = pageDao.getParts(reloadedBody);
    Assert.assertNotNull(moveDownPageParts);
    Assert.assertEquals(3, moveDownPageParts.size());
    Assert.assertEquals(titlePart, moveDownPageParts.get(0));
    Assert.assertEquals(htmlPart, moveDownPageParts.get(1));
    Assert.assertEquals(spacePart, moveDownPageParts.get(2));
    // not useful move space part down
    reloadedBody = pageDao.loadPageBodyByKey(page.getBody().getKey());
    pageDao.moveDownPart(reloadedBody, spacePart);
    dbInstance.commitAndCloseSession();
    List<PagePart> moveDownPageParts2 = pageDao.getParts(reloadedBody);
    Assert.assertNotNull(moveDownPageParts2);
    Assert.assertEquals(3, moveDownPageParts2.size());
    Assert.assertEquals(titlePart, moveDownPageParts2.get(0));
    Assert.assertEquals(htmlPart, moveDownPageParts2.get(1));
    Assert.assertEquals(spacePart, moveDownPageParts2.get(2));
}
Also used : PagePart(org.olat.modules.portfolio.PagePart) HTMLPart(org.olat.modules.portfolio.model.HTMLPart) TitlePart(org.olat.modules.portfolio.model.TitlePart) Page(org.olat.modules.portfolio.Page) PageBody(org.olat.modules.portfolio.PageBody) SpacerPart(org.olat.modules.portfolio.model.SpacerPart) Test(org.junit.Test)

Example 8 with HTMLPart

use of org.olat.modules.portfolio.model.HTMLPart in project openolat by klemens.

the class PageDAOTest method persistPart.

@Test
public void persistPart() {
    Page page = pageDao.createAndPersist("Page 1", "A page with content.", null, null, true, null, null);
    dbInstance.commitAndCloseSession();
    HTMLPart htmlPart = new HTMLPart();
    PageBody reloadedBody = pageDao.loadPageBodyByKey(page.getBody().getKey());
    pageDao.persistPart(reloadedBody, htmlPart);
    dbInstance.commitAndCloseSession();
    TitlePart titlePart = new TitlePart();
    reloadedBody = pageDao.loadPageBodyByKey(page.getBody().getKey());
    pageDao.persistPart(reloadedBody, titlePart, 0);
    dbInstance.commitAndCloseSession();
    // reload
    List<PagePart> reloadedPageParts = pageDao.getParts(reloadedBody);
    Assert.assertNotNull(reloadedPageParts);
    Assert.assertEquals(2, reloadedPageParts.size());
    Assert.assertEquals(titlePart, reloadedPageParts.get(0));
    Assert.assertEquals(htmlPart, reloadedPageParts.get(1));
}
Also used : PagePart(org.olat.modules.portfolio.PagePart) HTMLPart(org.olat.modules.portfolio.model.HTMLPart) TitlePart(org.olat.modules.portfolio.model.TitlePart) Page(org.olat.modules.portfolio.Page) PageBody(org.olat.modules.portfolio.PageBody) Test(org.junit.Test)

Example 9 with HTMLPart

use of org.olat.modules.portfolio.model.HTMLPart in project openolat by klemens.

the class PageDAOTest method deletePart.

@Test
public void deletePart() {
    Page page = pageDao.createAndPersist("Page 10", "A page with content.", null, null, true, null, null);
    dbInstance.commitAndCloseSession();
    HTMLPart htmlPart = new HTMLPart();
    PageBody reloadedBody = pageDao.loadPageBodyByKey(page.getBody().getKey());
    pageDao.persistPart(reloadedBody, htmlPart);
    dbInstance.commitAndCloseSession();
    TitlePart titlePart = new TitlePart();
    reloadedBody = pageDao.loadPageBodyByKey(page.getBody().getKey());
    pageDao.persistPart(reloadedBody, titlePart, 0);
    dbInstance.commitAndCloseSession();
    // reload
    Page reloadedPage = pageDao.loadByKey(page.getKey());
    pageDao.deletePage(reloadedPage);
    dbInstance.commit();
}
Also used : HTMLPart(org.olat.modules.portfolio.model.HTMLPart) TitlePart(org.olat.modules.portfolio.model.TitlePart) Page(org.olat.modules.portfolio.Page) PageBody(org.olat.modules.portfolio.PageBody) Test(org.junit.Test)

Example 10 with HTMLPart

use of org.olat.modules.portfolio.model.HTMLPart in project openolat by klemens.

the class HTMLRawPageElementHandler method getContent.

@Override
public PageRunElement getContent(UserRequest ureq, WindowControl wControl, PageElement element, PageElementRenderingHints options) {
    String content = "";
    if (element instanceof HTMLPart) {
        content = ((HTMLPart) element).getContent();
        content = Formatter.formatLatexFormulas(content);
    }
    TextComponent cmp = TextFactory.createTextComponentFromString("htmlRawCmp" + CodeHelper.getRAMUniqueID(), content, null, false, null);
    cmp.setElementCssClass("o_pf_html_raw");
    return new PageRunComponent(cmp);
}
Also used : TextComponent(org.olat.core.gui.components.text.TextComponent) PageRunComponent(org.olat.modules.portfolio.ui.editor.PageRunComponent) HTMLPart(org.olat.modules.portfolio.model.HTMLPart)

Aggregations

HTMLPart (org.olat.modules.portfolio.model.HTMLPart)10 Test (org.junit.Test)8 Page (org.olat.modules.portfolio.Page)8 PageBody (org.olat.modules.portfolio.PageBody)8 PagePart (org.olat.modules.portfolio.PagePart)6 TitlePart (org.olat.modules.portfolio.model.TitlePart)6 TextComponent (org.olat.core.gui.components.text.TextComponent)2 Section (org.olat.modules.portfolio.Section)2 BinderImpl (org.olat.modules.portfolio.model.BinderImpl)2 SpacerPart (org.olat.modules.portfolio.model.SpacerPart)2 PageRunComponent (org.olat.modules.portfolio.ui.editor.PageRunComponent)2