@Test
  public void testSubtitlesWithInitialFilenameAbsoluteSuccess() throws Exception {
    IProject project = ProjectFactory.createNew();
    IVideo video = DOFactory.createVideo(DOFactory.getEmptyPNGFile(parentDir));
    File subtitleFile = File.createTempFile("subtitle", ".txt", parentDir);
    video.setSubtitles(subtitleFile.getAbsolutePath());

    UoW.getCurrent().commit();
    UoW.newCurrent();

    final String basePath = dataFile.getParentFile().getAbsolutePath();

    Request request = new Request();
    request.set("id", project.getId());
    Response response = new Response();
    new AdjustToAbsolutePathsCommand(request, response).execute();
    Collection<IMedia> actualMedia = (Collection<IMedia>) response.get("media");
    IVideo actualVideo = (IVideo) actualMedia.iterator().next();
    Assert.assertEquals(subtitleFile.getAbsolutePath(), actualVideo.getSubtitles());
  }
Ejemplo n.º 2
0
 @Override
 protected WidgetModel getTransferWidget(DropTargetDragEvent dtde) {
   try {
     IVideo video =
         VideoInputMapper.map(
             (Long) dtde.getTransferable().getTransferData(DataFlavors.VideoFlavor));
     MediaArea widget = new MediaArea();
     Playable playable = MediaFactory.getMediaNoThrow(video);
     Dimension preferredSize = playable.getComponent().getPreferredSize();
     widget.setWidth(preferredSize.width);
     widget.setHeight(preferredSize.height);
     widget.setMedia(VideoInputMapper.map(video.getId()));
     return widget;
   } catch (UnsupportedFlavorException e) {
     Logger.getLogger(WidgetCanvas.class).error(e);
     return null;
   } catch (IOException e) {
     Logger.getLogger(WidgetCanvas.class).error(e);
     return null;
   } catch (MapperException e) {
     Application.getInstance().showUnhandledErrorDialog(e);
     return null;
   }
 }