projects
/
gpl
/
argeo-suite.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Improve DocBook titles management.
[gpl/argeo-suite.git]
/
publishing
/
org.argeo.publishing.ui
/
src
/
org
/
argeo
/
docbook
/
ui
/
AbstractDbkViewer.java
diff --git
a/publishing/org.argeo.publishing.ui/src/org/argeo/docbook/ui/AbstractDbkViewer.java
b/publishing/org.argeo.publishing.ui/src/org/argeo/docbook/ui/AbstractDbkViewer.java
index d886b143bde568b1bc31172023eb0c323a1a6ae5..f2fa79903b2e65a09e80f3984b77843480e220dd 100644
(file)
--- a/
publishing/org.argeo.publishing.ui/src/org/argeo/docbook/ui/AbstractDbkViewer.java
+++ b/
publishing/org.argeo.publishing.ui/src/org/argeo/docbook/ui/AbstractDbkViewer.java
@@
-19,9
+19,6
@@
import javax.jcr.Session;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.argeo.cms.text.Paragraph;
-import org.argeo.cms.text.TextInterpreter;
-import org.argeo.cms.text.TextSection;
import org.argeo.cms.ui.CmsEditable;
import org.argeo.cms.ui.util.CmsUiUtils;
import org.argeo.cms.ui.viewers.AbstractPageViewer;
import org.argeo.cms.ui.CmsEditable;
import org.argeo.cms.ui.util.CmsUiUtils;
import org.argeo.cms.ui.viewers.AbstractPageViewer;
@@
-112,18
+109,27
@@
public abstract class AbstractDbkViewer extends AbstractPageViewer implements Ke
if (style != null)
CmsUiUtils.style(textSection, style);
if (style != null)
CmsUiUtils.style(textSection, style);
+ // Title
+ Node titleNode = null;
+ // We give priority to ./title vs ./info/title, like the DocBook XSL
if (node.hasNode(DbkType.title.get())) {
if (node.hasNode(DbkType.title.get())) {
+ titleNode = node.getNode(DbkType.title.get());
+ } else if (node.hasNode(DbkType.info.get() + '/' + DbkType.title.get())) {
+ titleNode = node.getNode(DbkType.info.get() + '/' + DbkType.title.get());
+ }
+
+ if (titleNode != null) {
boolean showTitle = getMainSection() == section ? showMainTitle : true;
if (showTitle) {
if (section.getHeader() == null)
section.createHeader();
boolean showTitle = getMainSection() == section ? showMainTitle : true;
if (showTitle) {
if (section.getHeader() == null)
section.createHeader();
- Node titleNode = node.getNode(DbkType.title.get());
DocBookSectionTitle title = newSectionTitle(textSection, titleNode);
title.setLayoutData(CmsUiUtils.fillWidth());
updateContent(title);
}
}
DocBookSectionTitle title = newSectionTitle(textSection, titleNode);
title.setLayoutData(CmsUiUtils.fillWidth());
updateContent(title);
}
}
+ // content
for (NodeIterator ni = node.getNodes(); ni.hasNext();) {
Node child = ni.nextNode();
SectionPart sectionPart = null;
for (NodeIterator ni = node.getNodes(); ni.hasNext();) {
Node child = ni.nextNode();
SectionPart sectionPart = null;
@@
-133,13
+139,19
@@
public abstract class AbstractDbkViewer extends AbstractPageViewer implements Ke
// Node imageDataNode = child.getNode(DbkType.imageobject.get()).getNode(DbkType.imagedata.get());
// sectionPart = newImg(textSection, imageDataNode);
// }
// Node imageDataNode = child.getNode(DbkType.imageobject.get()).getNode(DbkType.imagedata.get());
// sectionPart = newImg(textSection, imageDataNode);
// }
+ } else if (isDbk(child, DbkType.info)) {
+ // TODO enrich UI based on info
+ } else if (isDbk(child, DbkType.title)) {
+ // already managed
} else if (isDbk(child, para)) {
sectionPart = newParagraph(textSection, child);
} else if (isDbk(child, para)) {
sectionPart = newParagraph(textSection, child);
- } else {
+ } else
if (isDbk(child, DbkType.section))
{
sectionPart = newSectionPart(textSection, child);
// if (sectionPart == null)
// throw new IllegalArgumentException("Unsupported node " + child);
// TODO list node types in exception
sectionPart = newSectionPart(textSection, child);
// if (sectionPart == null)
// throw new IllegalArgumentException("Unsupported node " + child);
// TODO list node types in exception
+ } else {
+ throw new IllegalArgumentException("Unsupported node type for "+child);
}
if (sectionPart != null && sectionPart instanceof Control)
((Control) sectionPart).setLayoutData(CmsUiUtils.fillWidth());
}
if (sectionPart != null && sectionPart instanceof Control)
((Control) sectionPart).setLayoutData(CmsUiUtils.fillWidth());
@@
-149,7
+161,7
@@
public abstract class AbstractDbkViewer extends AbstractPageViewer implements Ke
for (NodeIterator ni = section.getNode().getNodes(DbkType.section.get()); ni.hasNext();) {
Node child = ni.nextNode();
if (isDbk(child, DbkType.section)) {
for (NodeIterator ni = section.getNode().getNodes(DbkType.section.get()); ni.hasNext();) {
Node child = ni.nextNode();
if (isDbk(child, DbkType.section)) {
- TextSection newSection = new
TextSection(section, SWT.NONE
, child);
+ TextSection newSection = new
TextSection(section
, child);
newSection.setLayoutData(CmsUiUtils.fillWidth());
refresh(newSection);
}
newSection.setLayoutData(CmsUiUtils.fillWidth());
refresh(newSection);
}
@@
-161,6
+173,11
@@
public abstract class AbstractDbkViewer extends AbstractPageViewer implements Ke
// section.layout(true, true);
}
// section.layout(true, true);
}
+ /** To be overridden in order to provide additional SectionPart types */
+ protected TextSection newTextSection(Section section, Node node) {
+ return new TextSection(section, SWT.NONE, node);
+ }
+
/** To be overridden in order to provide additional SectionPart types */
protected SectionPart newSectionPart(TextSection textSection, Node node) {
return null;
/** To be overridden in order to provide additional SectionPart types */
protected SectionPart newSectionPart(TextSection textSection, Node node) {
return null;
@@
-264,7
+281,7
@@
public abstract class AbstractDbkViewer extends AbstractPageViewer implements Ke
if (title == getEdited())
title.setText(textInterpreter.read(title.getNode()));
else
if (title == getEdited())
title.setText(textInterpreter.read(title.getNode()));
else
- title.setText(textInterpreter.r
aw
(title.getNode()));
+ title.setText(textInterpreter.r
eadSimpleHtml
(title.getNode()));
}
}
}
}