protected DbkVideo newVideo(TextSection parent, Node node) {
try {
- DbkVideo video = new DbkVideo(parent,getCmsEditable().canEdit()?SWT.NONE : SWT.READ_ONLY, node);
+ DbkVideo video = new DbkVideo(parent, getCmsEditable().canEdit() ? SWT.NONE : SWT.READ_ONLY, node);
GridData gd;
if (maxMediaWidth != null) {
gd = new GridData(SWT.CENTER, SWT.FILL, false, false);
// TODO, manage size
- gd.widthHint = maxMediaWidth;
- gd.heightHint = (int) (gd.heightHint * 0.5625);
+// gd.widthHint = maxMediaWidth;
+// gd.heightHint = (int) (gd.heightHint * 0.5625);
} else {
gd = new GridData(SWT.CENTER, SWT.FILL, false, false);
// gd.widthHint = video.getWidth();
}
video.setLayoutData(gd);
updateContent(video);
- return null;
+ return video;
} catch (RepositoryException e) {
throw new JcrException("Cannot add new image " + node, e);
}
return newParagraph;
}
- protected Paragraph sectionTitleSplitted(DbkSectionTitle sectionTitle, Node newNode)
- throws RepositoryException {
+ protected Paragraph sectionTitleSplitted(DbkSectionTitle sectionTitle, Node newNode) throws RepositoryException {
updateContent(sectionTitle);
Paragraph newParagraph = newParagraph(sectionTitle.getSection(), newNode);
// we assume beforeFirst is not null since there was a sectionTitle
Composite browserC = new Composite(wrapper, SWT.NONE);
browserC.setLayout(CmsUiUtils.noSpaceGridLayout());
-// wrapper.setLayoutData(CmsUiUtils.fillAll());
- Browser browser = new Browser(browserC, SWT.NONE);
- GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ GridData gd = new GridData(SWT.CENTER, SWT.FILL, true, true);
gd.widthHint = getWidth();
gd.heightHint = getHeight();
browserC.setLayoutData(gd);
+// wrapper.setLayoutData(CmsUiUtils.fillAll());
+ Browser browser = new Browser(browserC, SWT.NONE);
if (editable) {
- Composite editor = new Composite(wrapper, SWT.NONE);
+ Composite editor = new Composite(wrapper, SWT.BORDER);
editor.setLayout(new GridLayout(3, false));
editor.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
String fileref = DbkUtils.getMediaFileref(mediaobject);
if (fileref != null)
text.setText(fileref);
else
- text.setMessage("Embed URL of the video.");
+ text.setMessage("Embed URL of the video");
text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
Button updateB = new Button(editor, SWT.FLAT);
updateB.setText("Update");
return;
}
- // transform YouTube watch URL in embed
- String youTubeVideoId = null;
- if ("www.youtube.com".equals(uri.getHost()) || "youtube.com".equals(uri.getHost())) {
- if ("/watch".equals(uri.getPath())) {
- Map<String, List<String>> map = NamingUtils.queryToMap(uri);
- youTubeVideoId = map.get("v").get(0);
+ // Transform watch URL in embed
+ // YouTube
+ String videoId = null;
+ if ("www.youtube.com".equals(uri.getHost()) || "youtube.com".equals(uri.getHost())
+ || "youtu.be".equals(uri.getHost())) {
+ if ("www.youtube.com".equals(uri.getHost()) || "youtube.com".equals(uri.getHost())) {
+ if ("/watch".equals(uri.getPath())) {
+ Map<String, List<String>> map = NamingUtils.queryToMap(uri);
+ videoId = map.get("v").get(0);
+ }
+ } else if ("youtu.be".equals(uri.getHost())) {
+ videoId = uri.getPath().substring(1);
+ }
+ if (videoId != null) {
+ try {
+ uri = new URI("https://www.youtube.com/embed/" + videoId);
+ text.setText(uri.toString());
+ } catch (URISyntaxException e1) {
+ throw new IllegalStateException(e1);
+ }
}
- } else if ("youtu.be".equals(uri.getHost())) {
- youTubeVideoId = uri.getPath().substring(1);
}
- if (youTubeVideoId != null) {
- try {
- uri = new URI("https://www.youtube.com/embed/" + youTubeVideoId);
- text.setText(uri.toString());
- } catch (URISyntaxException e1) {
- throw new IllegalStateException(e1);
+
+ // Vimeo
+ if ("vimeo.com".equals(uri.getHost())) {
+ videoId = uri.getPath().substring(1);
+ if (videoId != null) {
+ try {
+ uri = new URI("https://player.vimeo.com/video/" + videoId);
+ text.setText(uri.toString());
+ } catch (URISyntaxException e1) {
+ throw new IllegalStateException(e1);
+ }
}
}
@Override
protected void setContainerLayoutData(Composite composite) {
- composite.setLayoutData(CmsUiUtils.fillAll());
+ composite.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, true, true));
}
@Override