+ if (editablePart instanceof Control) {
+ int height = shell.getSize().y;
+ int parentShellHeight = shell.getShell().getSize().y;
+ if ((location.y + height) < parentShellHeight) {
+ shell.setLocation(((Control) editablePart).toDisplay(location.x, location.y));
+ } else {
+ shell.setLocation(((Control) editablePart).toDisplay(location.x, location.y - parentShellHeight));
+ }
+ }
+
+ if (shell.getChildren().length != 0)
+ shell.open();
+ }
+
+ void hide() {
+ shell.setVisible(false);
+ }
+
+ protected void insertMediaB(Composite parent, String msg, SectionPart sectionPart) {
+ insertMediaB(parent, msg, sectionPart.getSection(), sectionPart);
+ }
+
+ protected void insertMediaB(Composite parent, String msg, Section section, NodePart nodePart) {
+ Label insertMediaB = new Label(parent, SWT.NONE);
+ insertMediaB.setText(DbkMsg.insertMedia.lead());
+ insertMediaB.addMouseListener((MouseDown) (e) -> {
+ Node newNode = DbkUtils.insertImageAfter(nodePart.getNode());
+ Jcr.save(newNode);
+ textViewer.insertPart(section, newNode);
+ hide();
+ });
+
+ }
+
+ 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();
+ });