super(parent, style);
editable = !(SWT.READ_ONLY == (style & SWT.READ_ONLY));
this.section = section;
- setStyle(DbkType.videoobject.name());
+ // set data before setting style since it creates the control
setData(node);
+ setStyle(DbkType.videoobject.name());
}
@Override
protected Control createControl(Composite box, String style) {
- Content mediaobject = getNode();
+ Content mediaobject = getContent();
Composite wrapper = new Composite(box, SWT.NONE);
wrapper.setLayout(CmsSwtUtils.noSpaceGridLayout());
updateB.setText("Update");
updateB.addSelectionListener(new Selected() {
+ private static final long serialVersionUID = -8234047511858456222L;
+
@Override
public void widgetSelected(SelectionEvent e) {
Content videodata = mediaobject.child(DbkType.videoobject).child(DbkType.videodata);
deleteB.setText("Delete");
deleteB.addSelectionListener(new Selected() {
+ private static final long serialVersionUID = -7552456185687361642L;
+
@Override
public void widgetSelected(SelectionEvent e) {
mediaobject.remove();
import static org.argeo.app.docbook.DbkAcrUtils.isDbk;
import static org.argeo.app.docbook.DbkType.para;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Optional;
import org.argeo.api.acr.Content;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+/** Displays DocBook content. */
public class DocBookViewer extends AbstractPageViewer {
private TextInterpreter textInterpreter = new DbkTextInterpreter();
protected void refresh(Control control) {
if (!(control instanceof SwtSection))
return;
- long begin = System.currentTimeMillis();
+// long begin = System.currentTimeMillis();
SwtSection section = (SwtSection) control;
if (section instanceof TextSection) {
CmsSwtUtils.clear(mainSection);
refreshTextSection(mainSection);
}
- long duration = System.currentTimeMillis() - begin;
+// long duration = System.currentTimeMillis() - begin;
// System.out.println(duration + " ms - " + DbkUtils.getTitle(section.getNode()));
}
for (Content child : section.getContent()) {
if (child.hasContentClass(DbkType.section)) {
processingSubSections = true;
- TextSection childSection = new TextSection(section, 0, child);
+ TextSection childSection = newTextSection(section, child); // new TextSection(section, 0, child);
childSection.setLayoutData(CmsSwtUtils.fillWidth());
refreshTextSection(childSection);
} else {
} else {
throw new IllegalArgumentException("Unsupported media object " + child);
}
+ } else if (isDbk(child, DbkType.info)) {
+ // TODO enrich UI based on info
} else if (isDbk(child, DbkType.title)) {
// already managed
// TODO check that it is first?
} else if (part instanceof DbkImg) {
DbkImg editableImage = (DbkImg) part;
-// imageManager.load(partContent, part.getControl(), editableImage.getPreferredImageSize());
+ imageManager.load(partContent, part.getControl(), editableImage.getPreferredImageSize());
} else if (part instanceof DbkVideo) {
DbkVideo video = (DbkVideo) part;
video.load(part.getControl());
}
}
+ /** To be overridden in order to provide additional SectionPart types */
+ protected TextSection newTextSection(SwtSection section, Content node) {
+ return new TextSection(section, SWT.NONE, node);
+ }
+
protected Paragraph newParagraph(TextSection parent, Content node) {
Paragraph paragraph = new Paragraph(parent, parent.getStyle(), node);
updateContent(paragraph);
* level.
*
* @return the parent to use for the {@link DbkSectionTitle}, by default
- * {@link Section#getHeader()}
+ * {@link SwtSection#getHeader()}
*/
protected Composite newSectionHeader(TextSection section) {
return section.getHeader();
}
+ protected List<String> getAvailableStyles(SwtEditablePart editablePart) {
+ return new ArrayList<>();
+ }
+
public TextSection getMainSection() {
return mainSection;
}