Révision 2240

tmp/org.txm.backtomedia.rcp/src/vlcplayerrcp/messages.properties (revision 2240)
16 16
BackToMedia_17              = Error: this is not a transcription corpus: no ''{0}'' structure properties
17 17
BackToMedia_19              = ENDTIME: 
18 18
BackToMedia_25              = AUDIO/VIDEO FILE: 
19
BackToMedia_26              = Error: no media file (mp3, wav, mp4 or avi) found for name: 
20
BackToMedia_27              = All media files should be stored in the ''
21
BackToMedia_28              = '' directory.
19
BackToMedia_26              = Error: no media file (mp3, wav, mp4 or avi) found for name: {0}
20
BackToMedia_27              = All media files should be stored in the ''{0}'' directory.
22 21
BackToMedia_29              = Media file names should be ''<transcription ID>.<supported format>''
23 22
BackToMedia_30              = Unexpected error: 
24 23
BackToMedia_7               = TEXT ID: 
tmp/org.txm.backtomedia.rcp/src/vlcplayerrcp/MessagesMP.java (revision 2240)
18 18
	public static String BackToMedia_25;
19 19
	public static String BackToMedia_26;
20 20
	public static String BackToMedia_27;
21
	public static String BackToMedia_28;
22 21
	public static String BackToMedia_29;
23 22
	public static String BackToMedia_30;
24 23
	public static String BackToMedia_7;
tmp/org.txm.backtomedia.rcp/src/vlcplayerrcp/messages_fr.properties (revision 2240)
16 16
BackToMedia_17              = Erreur : pas de propriété de structure ''{0}'' trouvée
17 17
BackToMedia_19              = TEMPS FIN : 
18 18
BackToMedia_25              = Fichier AUDIO/VIDEO : 
19
BackToMedia_26              = Error: no media file (mp3, wav, mp4 or avi) found for name: 
20
BackToMedia_27              = All media files should be stored in the ''
21
BackToMedia_28              = '' directory.
19
BackToMedia_26              = Error: no media file (mp3, wav, mp4 or avi) found for name: {0}
20
BackToMedia_27              = All media files should be stored in the ''{0}'' directory.
22 21
BackToMedia_29              = Le nom du fichier média doit être ''<transcription ID>.<format supporté>''
23 22
BackToMedia_30              = Erreur : 
24 23
BackToMedia_7               = Identifiant de texte : 
tmp/org.txm.backtomedia.rcp/src/org/txm/backtomedia/commands/function/MediaPreferences.java (revision 2240)
39 39
		Shell s = d.getActiveShell();
40 40
		MediaPreferencesDialog dialog = new MediaPreferencesDialog(s, corpus);
41 41
		if (dialog.open() == MediaPreferencesDialog.OK) {
42
			CorpusCommandPreferences commandPreferences = corpus.getProject().getCommandPreferences("backtomedia");
42
			CorpusCommandPreferences commandPreferences = corpus.getProject().getCommandPreferences("backtomedia");//$NON-NLS-1$
43 43
			for (String p : MediaPreferencesDialog.properties) {
44 44
				commandPreferences.set(p, dialog.getProperty(p));
45 45
			}
tmp/org.txm.backtomedia.rcp/src/org/txm/backtomedia/commands/function/MediaPreferencesDialog.java (revision 2240)
55 55
        Composite c = new Composite(container, SWT.NONE);
56 56
        c.setLayout(new GridLayout(3, false));
57 57
        
58
        CorpusCommandPreferences commandPreferences = corpus.getProject().getCommandPreferences("backtomedia");
58
        CorpusCommandPreferences commandPreferences = corpus.getProject().getCommandPreferences("backtomedia");//$NON-NLS-1$
59 59
        TXMPreferences alternative = BackToMediaPreferences.getInstance();
60 60
        
61 61
        for (String p : properties) {
tmp/org.txm.backtomedia.rcp/src/org/txm/backtomedia/commands/function/BackToMedia.java (revision 2240)
28 28
package org.txm.backtomedia.commands.function;
29 29

  
30 30
import java.io.File;
31
import java.io.InputStream;
31 32
import java.util.HashMap;
32 33

  
33 34
import org.eclipse.core.commands.AbstractHandler;
......
35 36
import org.eclipse.core.commands.ExecutionException;
36 37
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
37 38
import org.eclipse.jface.viewers.IStructuredSelection;
39
import org.eclipse.osgi.util.NLS;
38 40
import org.eclipse.ui.IWorkbenchPart;
39 41
import org.eclipse.ui.handlers.HandlerUtil;
40 42
import org.txm.backtomedia.editors.vlcplayer.VLCPlayer;
......
44 46
import org.txm.concordance.rcp.editors.ConcordanceEditor;
45 47
import org.txm.core.preferences.TXMPreferences;
46 48
import org.txm.objects.CorpusCommandPreferences;
49
import org.txm.rcp.utils.SWTEditorsUtils;
47 50
import org.txm.searchengine.core.SearchEngine;
48 51
import org.txm.searchengine.cqp.AbstractCqiClient;
49 52
import org.txm.searchengine.cqp.CQPSearchEngine;
50
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
51 53
import org.txm.searchengine.cqp.corpus.CQPCorpus;
52 54
import org.txm.searchengine.cqp.corpus.CorpusManager;
53 55
import org.txm.searchengine.cqp.corpus.Property;
......
58 60

  
59 61
import vlcplayerrcp.MessagesMP;
60 62

  
61
// TODO: Auto-generated Javadoc
62 63
/**
63 64
 * open the VLCPlayer Editor and go back to time 
64 65
 * @author mdecorde.
......
88 89

  
89 90
		if (!(page instanceof ConcordanceEditor)) {
90 91
			Log.fine(MessagesMP.BackToMedia_1);
91
			System.out.println("Active page is not a ConcordanceEditor");
92
			System.out.println("Active page is not a ConcordanceEditor"); //$NON-NLS-1$
92 93
			return null;
93 94
		}
94 95
		ConcordanceEditor ce = (ConcordanceEditor) page;
......
108 109

  
109 110
		// try reading project specific preferences
110 111
		//TODO see with SJ how to implement the "command > project > preferences > default preferences" preference order
111
		CorpusCommandPreferences commandPreferences = corpus.getProject().getCommandPreferences("backtomedia");
112
		String structurePropertyName = commandPreferences.get(BackToMediaPreferences.STRUCTURE, alternative); //$NON-NLS-1$
113
		String startPropertyName = commandPreferences.get(BackToMediaPreferences.STRUCTURE_START_PROPERTY, alternative); //$NON-NLS-1$
114
		String endPropertyName = commandPreferences.get(BackToMediaPreferences.STRUCTURE_END_PROPERTY, alternative); //$NON-NLS-1$
112
		CorpusCommandPreferences commandPreferences = corpus.getProject().getCommandPreferences("backtomedia"); //$NON-NLS-1$
113
		String structurePropertyName = commandPreferences.get(BackToMediaPreferences.STRUCTURE, alternative);
114
		String startPropertyName = commandPreferences.get(BackToMediaPreferences.STRUCTURE_START_PROPERTY, alternative);
115
		String endPropertyName = commandPreferences.get(BackToMediaPreferences.STRUCTURE_END_PROPERTY, alternative);
115 116
		String sync_mode = commandPreferences.get(BackToMediaPreferences.SYNCMODE, alternative);
116 117
		String media_directory = commandPreferences.get(BackToMediaPreferences.MEDIA_DIRECTORY, alternative);
117 118
		String media_format = commandPreferences.get(BackToMediaPreferences.MEDIA_FORMAT, alternative);
......
199 200
				}
200 201
			}
201 202

  
202
			//				try {
203
			//					startTime = (int)Float.parseFloat(sStartTime);
204
			//					endTime = (int)Float.parseFloat(sEndTime);
205
			//				} catch(Exception e2) {
206
			//					System.out.println("Error: time format must be an Integer, unit is second. Found "+sStartTime);
207
			//					return null;
208
			//				}
203
			//try {
204
			//	startTime = (int)Float.parseFloat(sStartTime);
205
			//	endTime = (int)Float.parseFloat(sEndTime);
206
			//} catch(Exception e2) {
207
			//	System.out.println("Error: time format must be an Integer, unit is second. Found "+sStartTime);
208
			//	return null;
209
			//}
209 210

  
210 211
			File binDir = corpus.getProject().getProjectDirectory();
211 212
			File audioFile = null;
......
213 214
				IEclipsePreferences node = corpus.getProject().getPreferencesScope().getNode(media_index);
214 215
				String path = node.get(textid, null);
215 216
				audioFile = new File(path);
217
				if (path.startsWith("http:/")) {
218
					try {
219
						InputStream conn = audioFile.toURI().toURL().openStream();
220
						conn.close();
221
					} catch(Exception e) {
222
						Log.info("Could not open media file: "+path);
223
					}
224
				} else if (!audioFile.exists()) {
225
					Log.info("Media file register in the index not found: "+audioFile);
226
					return null;
227
				}
216 228
			} else if (media_directory != null && media_directory.length() > 0 && media_format != null && media_format.length() > 0) {
217 229
				audioFile = new File(media_directory, textid+"."+media_format); //$NON-NLS-1$
230
				if (media_directory.startsWith("http:/")) {
231
					try {
232
						InputStream conn = audioFile.toURI().toURL().openStream();
233
						conn.close();
234
					} catch(Exception e) {
235
						Log.info("Could not open media file: "+audioFile);
236
					}
237
				} else { // local
238
					if (!new File(media_directory).exists()) {
239
						Log.info("Media directory not found: "+media_directory);
240
						return null;
241
					} else if (!audioFile.exists()) {
242
						Log.info("Media file not found: "+audioFile);
243
						return null;
244
					}
245
				}
218 246
			} else {
219 247
				File mediaDir = new File(binDir, "media"); //$NON-NLS-1$
220 248
				audioFile = new File(mediaDir, textid+".mp3"); //$NON-NLS-1$
......
224 252
				if (!audioFile.exists()) audioFile = new File(mediaDir, textid+".avi"); //$NON-NLS-1$
225 253
				if (!audioFile.exists()) audioFile = new File(mediaDir, textid+".mov"); //$NON-NLS-1$
226 254
				if (!audioFile.exists()) {
227
					System.out.println(MessagesMP.BackToMedia_26+textid);
228
					System.out.println(MessagesMP.BackToMedia_27+mediaDir+MessagesMP.BackToMedia_28);
255
					System.out.println(NLS.bind(MessagesMP.BackToMedia_26, textid));
256
					System.out.println(NLS.bind(MessagesMP.BackToMedia_27, mediaDir));
229 257
					System.out.println(MessagesMP.BackToMedia_29);
258
					return null;
230 259
				}
231 260
			}
232 261

  
233 262
			Log.fine(MessagesMP.BackToMedia_25+audioFile);
234

  
263
			
235 264
			//System.out.println("Linked editors: "+associatedEditors);
236 265
			VLCPlayerEditor editor = associatedEditors.get(ce); 
237 266
			String path = audioFile.getPath();
......
241 270
			} else {
242 271
				//System.out.println("new editor linked to "+ce);
243 272
				editor = OpenVLCPlayer.openEditor(path, sStartTime, sEndTime);
273
				
244 274
				//editor.getPlayer().setRepeat(true);
245 275
				if (editor == null) {
246 276
					return null;
247 277
				}
278
				
279
				// move the editor in the window
280
				int position = BackToMediaPreferences.getInstance().getInt(BackToMediaPreferences.BACKTOMEDIA_POSITION);
281
				SWTEditorsUtils.addEditor(editor, ce, position);
282
				
248 283
				VLCPlayer player = editor.getPlayer();
249 284
				if (player != null) {
250 285
					player.hideStopButton();
251 286
					associatedEditors.put(ce, editor);
252 287
				}
253 288
			}
254
			if (audioFile != null)
289
			
290
			if (audioFile != null) {
255 291
				editor.setPartName(audioFile.getName());
292
			}
256 293
			return null;
257 294

  
258 295
		} catch (Exception e2) {
tmp/org.txm.backtomedia.rcp/src/org/txm/backtomedia/commands/function/OpenVLCPlayer.java (revision 2240)
32 32
import org.eclipse.core.commands.AbstractHandler;
33 33
import org.eclipse.core.commands.ExecutionEvent;
34 34
import org.eclipse.core.commands.ExecutionException;
35
import org.eclipse.jface.dialogs.InputDialog;
35 36
import org.eclipse.jface.viewers.IStructuredSelection;
36 37
import org.eclipse.swt.SWT;
37 38
import org.eclipse.swt.widgets.FileDialog;
......
73 74
			System.out.println(MessagesMP.select_object+s);
74 75
		}
75 76

  
76
		FileDialog fd = new FileDialog(new Shell(), SWT.SAVE);
77
		fd.setText(MessagesMP.select_file);
77
		Shell sh = HandlerUtil.getActiveShell(event);
78
		InputDialog fd = new InputDialog(sh, "Opening media file...", "Enter file path or URL", "", null);
79
		//FileDialog fd = new FileDialog(new Shell(), SWT.SAVE);
80
		//fd.setText(MessagesMP.select_file);
78 81

  
79
		String[] filterExt = { "*.*", "*.mp3", "*.ogg", "*.avi", "*.mp4", "*.mov"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
80
		fd.setFilterExtensions(filterExt);
81
		String mrl = fd.open();
82
		if (mrl != null)
83
			openEditor(mrl, 0);
82
		//String[] filterExt = { "*.*", "*.mp3", "*.ogg", "*.avi", "*.mp4", "*.mov"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
83
		//fd.setFilterExtensions(filterExt);
84
		if (fd.open() == fd.OK) {
85
			 String mrl = fd.getValue();
86
						if (mrl != null)
87
							openEditor(mrl, 0);
88
		}
89
		
84 90
		return null;
85 91
	}
86 92

  
......
149 155
		
150 156
		return null;
151 157
	}
152

  
153 158
}
tmp/org.txm.backtomedia.rcp/src/org/txm/backtomedia/preferences/BackToMediaPreferences.java (revision 2240)
1 1
package org.txm.backtomedia.preferences;
2 2

  
3 3
import org.eclipse.core.runtime.preferences.DefaultScope;
4
import org.eclipse.e4.ui.workbench.modeling.EModelService;
4 5
import org.osgi.framework.FrameworkUtil;
5 6
import org.osgi.service.prefs.Preferences;
6 7
import org.txm.core.preferences.TXMPreferences;
......
30 31

  
31 32
	public static final String MEDIA_INDEX_NODE = "media_index_node";
32 33
	
34
	/**
35
	 * one of the EModelService position constant to use when opening editor: 	ABOVE = 0 BELOW = 1 LEFT_OF = 2 RIGHT_OF = 3
36
	 */
37
	public static final String BACKTOMEDIA_POSITION = "backtomedia_position"; //$NON-NLS-1$
33 38
	
34 39
	public BackToMediaPreferences() {
35 40
		// TODO Auto-generated constructor stub
......
46 51
		preferences.put(STRUCTURE_START_PROPERTY, "start");
47 52
		preferences.put(STRUCTURE_END_PROPERTY, "end");
48 53
		preferences.put(WORD_PROPERTY, "time");
54
		preferences.putInt(BACKTOMEDIA_POSITION, EModelService.ABOVE);
49 55
	}
50 56
	
51 57
	/**
tmp/org.txm.backtomedia.rcp/src/org/txm/backtomedia/preferences/BackToMediaPreferencePage.java (revision 2240)
27 27
//
28 28
package org.txm.backtomedia.preferences;
29 29

  
30
import org.eclipse.e4.ui.workbench.modeling.EModelService;
30 31
import org.eclipse.jface.preference.BooleanFieldEditor;
31 32
import org.eclipse.jface.preference.FieldEditor;
32 33
import org.eclipse.jface.preference.StringFieldEditor;
......
62 63
	 * The display parts count in chart title state.
63 64
	 */
64 65
	private BooleanFieldEditor loopProperty;
66
	private ComboFieldEditor backtotext_position;
65 67
	private ComboFieldEditor useWordProperty;
66 68
	private StringFieldEditor defaultStructure;
67 69
	private StringFieldEditor defaultStructureStartProperty;
......
107 109
		
108 110
		addField(useWordProperty);
109 111
		
112
		String[][] values = {{"ABOVE", ""+EModelService.ABOVE}, {"BELOW", ""+EModelService.BELOW}, {"LEFT_OF", ""+EModelService.LEFT_OF}, {"RIGHT_OF", ""+EModelService.RIGHT_OF}};
113
		backtotext_position = new ComboFieldEditor(BackToMediaPreferences.BACKTOMEDIA_POSITION, "new editor position", values, getFieldEditorParent());
114
		addField(backtotext_position);
115
		
110 116
		spanGroup = new Group(getFieldEditorParent(), SWT.NONE);
111 117
		spanGroup.setText(MessagesMP.BackToMediaPreferencePage_3);
112 118
		GridData gridData2 = new GridData(SWT.FILL, SWT.FILL, true, false);
tmp/org.txm.backtomedia.rcp/src/org/txm/backtomedia/editors/vlcplayer/VLCPlayer.java (revision 2240)
263 263
		});
264 264

  
265 265
		rateValueLabel = new Label(this, SWT.NONE);
266
		rateValueLabel.setText("100%");
266
		rateValueLabel.setText("100%");//$NON-NLS-1$
267 267
		
268 268
		l = new Label(this, SWT.NONE);
269 269
		l.setText(MessagesMP.volume);

Formats disponibles : Unified diff