+ 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, SectionPart sectionPart) {
+ insertMediaB(parent, sectionPart.getSection(), sectionPart);
+ }
+
+ protected void insertMediaB(Composite parent, Section section, NodePart nodePart) {
+ Label insertPictureB = new Label(parent, SWT.NONE);
+ insertPictureB.setText(DbkMsg.insertPicture.lead());
+ insertPictureB.addMouseListener((MouseDown) (e) -> {
+ Node newNode = DbkUtils.insertImageAfter(nodePart.getNode());
+ Jcr.save(newNode);
+ textViewer.insertPart(section, newNode);
+ hide();
+ });
+ Label insertVideoB = new Label(parent, SWT.NONE);
+ insertVideoB.setText(DbkMsg.insertVideo.lead());
+ insertVideoB.addMouseListener((MouseDown) (e) -> {
+ Node newNode = DbkUtils.insertVideoAfter(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();
+ });