Revision 2372

tmp/org.txm.backtomedia.rcp/src/org/txm/backtomedia/editors/vlcplayer/VLCPlayer.java (revision 2372)
357 357
					timeRange.getDisplay().syncExec(new Runnable() {
358 358
						@Override
359 359
						public void run() {
360
							if (timeRange.isDisposed()) return;
360 361
							timeRange.setMaximum((int)arg1);
361 362
							//if (start == end) end = (int)arg1;
362 363
							
tmp/org.txm.backtomedia.rcp/src/org/txm/backtomedia/editors/vlcplayer/VLCPlayerEditor.java (revision 2372)
86 86
	 * @return false if the media could not be loaded (file not found, access error...)
87 87
	 */
88 88
	public boolean isMediaLoaded() {
89
		return player.getEmbeddedMediaPlayer().isMediaParsed() 
90
				&& player.getEmbeddedMediaPlayer().isPlayable();
89
		return player.getEmbeddedMediaPlayer().isPlayable();
91 90
	}
92 91
}
tmp/org.txm.backtomedia.rcp/src/org/txm/backtomedia/commands/function/MediaPreferencesDialog.java (revision 2372)
27 27
	public static String[] properties = {BackToMediaPreferences.STRUCTURE_START_PROPERTY, 
28 28
			BackToMediaPreferences.STRUCTURE_END_PROPERTY, 
29 29
			BackToMediaPreferences.STRUCTURE, 
30
			BackToMediaPreferences.WORD_PROPERTY, 
30
			BackToMediaPreferences.WORD_PROPERTY,
31
			BackToMediaPreferences.WORD_CONTEXT_LEFT_DISTANCE,
32
			BackToMediaPreferences.WORD_CONTEXT_RIGHT_DISTANCE,
31 33
			BackToMediaPreferences.SYNCMODE, 
32 34
			BackToMediaPreferences.MEDIA_PATH_PREFIX, 
33 35
			BackToMediaPreferences.MEDIA_EXTENSION,
tmp/org.txm.backtomedia.rcp/src/org/txm/backtomedia/commands/function/BackToMedia.java (revision 2372)
84 84
	/** The selection. */
85 85
	private IStructuredSelection selection;
86 86
	
87
	private static HashMap<ITXMResultEditor<?>, VLCPlayerEditor> associatedEditors = new HashMap<ITXMResultEditor<?>, VLCPlayerEditor>();
87
	private static HashMap<IWorkbenchPart, VLCPlayerEditor> associatedEditors = new HashMap<IWorkbenchPart, VLCPlayerEditor>();
88 88
	
89 89
	/*
90 90
	 * (non-Javadoc)
......
109 109
					return null;
110 110
				}
111 111
				
112
				IWorkbenchPart editor = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getActivePart();
113
				
112 114
				if (time_parameter != null) {
113
					return backToMedia(cqpCorpus, text_parameter, 0, 0, 0, 0, time_parameter, time_parameter, null, HandlerUtil.getActiveWorkbenchWindow(event).getShell());
115
					return backToMedia(cqpCorpus, text_parameter, 0, 0, time_parameter, time_parameter, editor, HandlerUtil.getActiveWorkbenchWindow(event).getShell());
114 116
				}
115 117
				else {
116 118
					CQLQuery query = new CQLQuery(NLS.bind("[id=\"{0}\" & _.text_id=\"{1}\"]", word_parameter, text_parameter));
117 119
					QueryResult rez = cqpCorpus.query(query, "TMP", false);
118 120
					if (rez.getNMatch() == 1) {
119 121
						Match m = rez.getMatch(0);
120
						return backToMedia(cqpCorpus, text_parameter, m.getStart(), m.getEnd(), 10, 10, null, null, null, HandlerUtil.getActiveWorkbenchWindow(event).getShell());
122
						
123
						return backToMedia(cqpCorpus, text_parameter, m.getStart(), m.getEnd(), null, null, (EditorPart) editor, HandlerUtil.getActiveWorkbenchWindow(event).getShell());
121 124
					}
122 125
					else {
123 126
						Log.warning(NLS.bind("Fail to find word with id={0} in text with id={1}", word_parameter, text_parameter));
......
157 160
			String textid = line.getTextId();// line.getMatch().getValueForProperty(textP);// get text via text struc property id
158 161
			CQPCorpus corpus = line.getConcordance().getCorpus();
159 162
			
160
			return backToMedia(corpus, textid, m.getStart(), m.getEnd(), line.getConcordance().getLeftContextSize(), line.getConcordance().getRightContextSize(), null, null, ce, ce.getContainer()
163
			return backToMedia(corpus, textid, m.getStart(), m.getEnd(), null, null, ce, ce.getContainer()
161 164
					.getShell());
162 165
		}
163 166
	}
164 167
	
165
	public static Object backToMedia(CQPCorpus corpus, String textid, int keywordPosition, int keywordEndPosition, int leftContext, int rightContext, String sStartTime, String sEndTime,
166
			ITXMResultEditor<?> editor, Shell shell) {
168
	public static Object backToMedia(CQPCorpus corpus, String textid, int keywordPosition, int keywordEndPosition, String sStartTime, String sEndTime,
169
			IWorkbenchPart editor, Shell shell) {
167 170
		
168 171
		TXMPreferences alternative = BackToMediaPreferences.getInstance();
169 172
		
......
181 184
		String secured_media_password = System.getProperty(BackToMediaPreferences.MEDIA_AUTH_PASSWORD);
182 185
		String media_format = commandPreferences.get(BackToMediaPreferences.MEDIA_EXTENSION, alternative);
183 186
		String media_index = commandPreferences.get(BackToMediaPreferences.MEDIA_INDEX_NODE, alternative);
187
		String pTimeName = commandPreferences.get(BackToMediaPreferences.WORD_PROPERTY, alternative);
188
		int leftContext = commandPreferences.getInt(BackToMediaPreferences.WORD_CONTEXT_LEFT_DISTANCE, alternative);
189
		int rightContext = commandPreferences.getInt(BackToMediaPreferences.WORD_CONTEXT_RIGHT_DISTANCE, alternative);
184 190
		
185 191
		try {
186 192
			
......
189 195
			if (sStartTime == null || sEndTime == null) { // we need to find out the time to play
190 196
				
191 197
				if (BackToMediaPreferences.WORDMODE.equals(sync_mode)) {
192
					String pTimeName = BackToMediaPreferences.getInstance().getString(BackToMediaPreferences.WORD_PROPERTY);
198
					
193 199
					if ("".equals(pTimeName)) pTimeName = "time"; //$NON-NLS-1$ //$NON-NLS-2$
194 200
					
195 201
					Property timeP = corpus.getProperty(pTimeName);
......
357 363
			if (editor != null) {
358 364
				vlcEditor = associatedEditors.get(editor);
359 365
			}
360
			if (vlcEditor != null && !editor.isDirty() && !vlcEditor.getPlayer().isDisposed()) {
366
			if (vlcEditor != null && !vlcEditor.getPlayer().isDisposed()) {
361 367
				vlcEditor.getPlayer().play(path, sStartTime, sEndTime);
362 368
				vlcEditor.getPlayer().setRepeat(true);
363 369
			}
......
366 372
				vlcEditor = OpenVLCPlayer.openEditor(path, sStartTime, sEndTime);
367 373
				
368 374
				// editor.getPlayer().setRepeat(true);
369
				if (vlcEditor == null) { return null; }
375
				if (vlcEditor == null) { 
376
					Log.warning("Error: could not open the MediaPlayer.");
377
					return null; 
378
				}
370 379
				
371 380
				if (!vlcEditor.isMediaLoaded()) {
381
					
382
					vlcEditor.getSite().getPage().closeEditor(vlcEditor, false);
372 383
					if (media_auth) {
384
						Log.warning("The MediaPlayer could not open the media: "+media_directory); // don't show credentials
373 385
						System.clearProperty(BackToMediaPreferences.MEDIA_AUTH_PASSWORD);
386
						System.clearProperty(BackToMediaPreferences.MEDIA_AUTH_LOGIN);
387
					} else {
388
						Log.warning("The MediaPlayer could not open the media: "+path);
374 389
					}
375
					vlcEditor.getSite().getPage().closeEditor(vlcEditor, false);
376 390
				}
377 391
				
378 392
				// move the editor in the window
tmp/org.txm.backtomedia.rcp/src/org/txm/backtomedia/preferences/BackToMediaPreferences.java (revision 2372)
19 19
	public static final String STRUCTURE = "backtomedia_structure"; //$NON-NLS-1$
20 20
	public static final String STRUCTURE_START_PROPERTY = "backtomedia_startproperty"; //$NON-NLS-1$
21 21
	public static final String STRUCTURE_END_PROPERTY = "backtomedia_endproperty"; //$NON-NLS-1$
22
	public static final String WORD_PROPERTY = "backtomedia_time_property"; //$NON-NLS-1$
22
	public static final String WORD_PROPERTY = "backtomedia_wordtime_property"; //$NON-NLS-1$
23
	public static final String WORD_CONTEXT_LEFT_DISTANCE = "backtomedia_word_context_left_distance"; //$NON-NLS-1$
24
	public static final String WORD_CONTEXT_RIGHT_DISTANCE = "backtomedia_word_context_right_distance"; //$NON-NLS-1$
23 25

  
24 26
	// the sync modes
25 27
	public static final String WORDMODE = "Word";
......
58 60
		preferences.put(STRUCTURE_START_PROPERTY, "start");
59 61
		preferences.put(STRUCTURE_END_PROPERTY, "end");
60 62
		preferences.put(WORD_PROPERTY, "time");
63
		preferences.putInt(WORD_CONTEXT_LEFT_DISTANCE, 10); // conc + 2
64
		preferences.putInt(WORD_CONTEXT_RIGHT_DISTANCE, 15); // conc + 2
61 65
		preferences.putInt(BACKTOMEDIA_POSITION, EModelService.ABOVE);
62 66
	}
63 67
	
......
72 76
		return TXMPreferences.instances.get(BackToMediaPreferences.class);
73 77
	}
74 78
}
79

  

Also available in: Unified diff