Improve media management in DocBook.
[gpl/argeo-suite.git] / publishing / org.argeo.publishing.ui / src / org / argeo / docbook / ui / DbkContextMenu.java
index 24a759c60ff06c963f2511da6e3fcd1f09ef99a6..77248d6f140fa065ed6a30e7c7f4bcfedea449d5 100644 (file)
@@ -15,7 +15,6 @@ import org.argeo.cms.ui.viewers.Section;
 import org.argeo.cms.ui.viewers.SectionPart;
 import org.argeo.cms.ui.widgets.EditableText;
 import org.argeo.cms.ui.widgets.Img;
-import org.argeo.cms.ui.widgets.TextStyles;
 import org.argeo.docbook.DbkMsg;
 import org.argeo.docbook.DbkUtils;
 import org.argeo.eclipse.ui.MouseDown;
@@ -33,7 +32,7 @@ import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Shell;
 
 /** Dialog to edit a text part. */
-class DbkContextMenu implements TextStyles {
+class DbkContextMenu {
        private final AbstractDbkViewer textViewer;
 
        private Shell shell;
@@ -67,6 +66,7 @@ class DbkContextMenu implements TextStyles {
                        Img img = (Img) editablePart;
                        deletePartB(parent, DbkMsg.deleteMedia.lead(), img);
                        insertMediaB(parent, DbkMsg.insertMedia.lead(), img);
+                       insertParagraphB(parent, DbkMsg.insertParagraph.lead(), img);
 
                } else if (editablePart instanceof DocBookSectionTitle) {
                        DocBookSectionTitle sectionTitle = (DocBookSectionTitle) editablePart;
@@ -146,6 +146,15 @@ class DbkContextMenu implements TextStyles {
 
        }
 
+       protected void insertParagraphB(Composite parent, String msg, SectionPart sectionPart) {
+               Label insertMediaB = new Label(parent, SWT.NONE);
+               insertMediaB.setText(msg);
+               insertMediaB.addMouseListener((MouseDown) (e) -> {
+                       textViewer.addParagraph(sectionPart, null);
+                       hide();
+               });
+       }
+
        protected void deletePartB(Composite parent, String msg, SectionPart sectionPart) {
                Label deleteB = new Label(shell, SWT.NONE);
                deleteB.setText(msg);