Révision 3097
tmp/org.txm.backtomedia.rcp/plugin.xml (revision 3097) | ||
---|---|---|
76 | 76 |
<extension |
77 | 77 |
point="org.eclipse.ui.commands"> |
78 | 78 |
<command |
79 |
defaultHandler="org.txm.backtomedia.commands.function.OpenVLCPlayer"
|
|
79 |
defaultHandler="org.txm.backtomedia.commands.function.OpenMediaPlayer"
|
|
80 | 80 |
description="%command.description" |
81 | 81 |
id="org.txm.backtomedia.commands.function.OpenVLCPlayer" |
82 | 82 |
name="%command.name"> |
... | ... | |
125 | 125 |
<extension |
126 | 126 |
point="org.eclipse.ui.editors"> |
127 | 127 |
<editor |
128 |
class="org.txm.backtomedia.editors.vlcplayer.VLCPlayerEditor"
|
|
128 |
class="org.txm.backtomedia.editors.vlcplayer.MediaPlayerEditor"
|
|
129 | 129 |
default="false" |
130 | 130 |
id="org.txm.backtomedia.editors.vlcplayer.VLCPlayerEditor" |
131 | 131 |
name="%editor.name"> |
tmp/org.txm.backtomedia.rcp/src/org/txm/backtomedia/editors/input/VLCPlayerEditorInput.java (revision 3097) | ||
---|---|---|
1 |
// Copyright © 2010-2020 ENS de Lyon., University of Franche-Comté |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate:$ |
|
25 |
// $LastChangedRevision:$ |
|
26 |
// $LastChangedBy:$ |
|
27 |
// |
|
28 |
package org.txm.backtomedia.editors.input; |
|
29 |
|
|
30 |
import org.eclipse.jface.resource.ImageDescriptor; |
|
31 |
import org.eclipse.ui.IEditorInput; |
|
32 |
import org.eclipse.ui.IPersistableElement; |
|
33 |
import org.eclipse.ui.plugin.AbstractUIPlugin; |
|
34 |
import org.txm.rcp.Application; |
|
35 |
import org.txm.rcp.IImageKeys; |
|
36 |
|
|
37 |
// TODO: Auto-generated Javadoc |
|
38 |
/** |
|
39 |
* VLCEditor input |
|
40 |
* |
|
41 |
* @author mdecorde |
|
42 |
*/ |
|
43 |
public class VLCPlayerEditorInput implements IEditorInput { |
|
44 |
|
|
45 |
/** |
|
46 |
* Instantiates a new VLC player editor input. |
|
47 |
* |
|
48 |
* @param src the source |
|
49 |
*/ |
|
50 |
public VLCPlayerEditorInput() { |
|
51 |
super(); |
|
52 |
} |
|
53 |
|
|
54 |
/** |
|
55 |
* Exists. |
|
56 |
* |
|
57 |
* @return true, if successful |
|
58 |
* @see org.eclipse.ui.IEditorInput#exists() |
|
59 |
*/ |
|
60 |
@Override |
|
61 |
public boolean exists() { |
|
62 |
return false; |
|
63 |
} |
|
64 |
|
|
65 |
/** |
|
66 |
* Gets the image descriptor. |
|
67 |
* |
|
68 |
* @return the image descriptor |
|
69 |
* @see org.eclipse.ui.IEditorInput#getImageDescriptor() |
|
70 |
*/ |
|
71 |
@Override |
|
72 |
public ImageDescriptor getImageDescriptor() { |
|
73 |
return AbstractUIPlugin.imageDescriptorFromPlugin( |
|
74 |
Application.PLUGIN_ID, |
|
75 |
IImageKeys.ACTION_WORDCLOUD); |
|
76 |
} |
|
77 |
|
|
78 |
/** |
|
79 |
* Gets the name. |
|
80 |
* |
|
81 |
* @return the name |
|
82 |
* @see org.eclipse.ui.IEditorInput#getName() |
|
83 |
*/ |
|
84 |
@Override |
|
85 |
public String getName() { |
|
86 |
return "VLCPlayer"; //$NON-NLS-1$ |
|
87 |
} |
|
88 |
|
|
89 |
/** |
|
90 |
* Gets the persistable. |
|
91 |
* |
|
92 |
* @return the persistable |
|
93 |
* @see org.eclipse.ui.IEditorInput#getPersistable() |
|
94 |
*/ |
|
95 |
@Override |
|
96 |
public IPersistableElement getPersistable() { |
|
97 |
return null; |
|
98 |
} |
|
99 |
|
|
100 |
/** |
|
101 |
* Gets the tool tip text. |
|
102 |
* |
|
103 |
* @return the tool tip text |
|
104 |
* @see org.eclipse.ui.IEditorInput#getToolTipText() |
|
105 |
*/ |
|
106 |
@Override |
|
107 |
public String getToolTipText() { |
|
108 |
return getName(); |
|
109 |
} |
|
110 |
|
|
111 |
/** |
|
112 |
* Gets the adapter. |
|
113 |
* |
|
114 |
* @param arg0 the arg0 |
|
115 |
* @return the adapter |
|
116 |
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) |
|
117 |
*/ |
|
118 |
@Override |
|
119 |
public Object getAdapter(@SuppressWarnings("rawtypes") Class arg0) { |
|
120 |
return null; |
|
121 |
} |
|
122 |
|
|
123 |
/** |
|
124 |
* Gets the source. |
|
125 |
* |
|
126 |
* @return the Correspondance analysis underlying object |
|
127 |
*/ |
|
128 |
public Object getSource() { |
|
129 |
return ""; //$NON-NLS-1$ |
|
130 |
} |
|
131 |
} |
tmp/org.txm.backtomedia.rcp/src/org/txm/backtomedia/editors/input/MediaPlayerEditorInput.java (revision 3097) | ||
---|---|---|
1 |
// Copyright © 2010-2020 ENS de Lyon., University of Franche-Comté |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate:$ |
|
25 |
// $LastChangedRevision:$ |
|
26 |
// $LastChangedBy:$ |
|
27 |
// |
|
28 |
package org.txm.backtomedia.editors.input; |
|
29 |
|
|
30 |
import org.eclipse.jface.resource.ImageDescriptor; |
|
31 |
import org.eclipse.ui.IEditorInput; |
|
32 |
import org.eclipse.ui.IPersistableElement; |
|
33 |
import org.eclipse.ui.plugin.AbstractUIPlugin; |
|
34 |
import org.txm.rcp.Application; |
|
35 |
import org.txm.rcp.IImageKeys; |
|
36 |
|
|
37 |
/** |
|
38 |
* MEdia player editor input |
|
39 |
* |
|
40 |
* @author mdecorde |
|
41 |
*/ |
|
42 |
public class MediaPlayerEditorInput implements IEditorInput { |
|
43 |
|
|
44 |
/** |
|
45 |
* Instantiates a new Media player editor input. |
|
46 |
* |
|
47 |
* @param src the source |
|
48 |
*/ |
|
49 |
public MediaPlayerEditorInput() { |
|
50 |
super(); |
|
51 |
} |
|
52 |
|
|
53 |
/** |
|
54 |
* Exists. |
|
55 |
* |
|
56 |
* @return true, if successful |
|
57 |
* @see org.eclipse.ui.IEditorInput#exists() |
|
58 |
*/ |
|
59 |
@Override |
|
60 |
public boolean exists() { |
|
61 |
return false; |
|
62 |
} |
|
63 |
|
|
64 |
/** |
|
65 |
* Gets the image descriptor. |
|
66 |
* |
|
67 |
* @return the image descriptor |
|
68 |
* @see org.eclipse.ui.IEditorInput#getImageDescriptor() |
|
69 |
*/ |
|
70 |
@Override |
|
71 |
public ImageDescriptor getImageDescriptor() { |
|
72 |
return AbstractUIPlugin.imageDescriptorFromPlugin( |
|
73 |
Application.PLUGIN_ID, |
|
74 |
IImageKeys.ACTION_WORDCLOUD); |
|
75 |
} |
|
76 |
|
|
77 |
/** |
|
78 |
* Gets the name. |
|
79 |
* |
|
80 |
* @return the name |
|
81 |
* @see org.eclipse.ui.IEditorInput#getName() |
|
82 |
*/ |
|
83 |
@Override |
|
84 |
public String getName() { |
|
85 |
return "Media Player"; //$NON-NLS-1$ |
|
86 |
} |
|
87 |
|
|
88 |
/** |
|
89 |
* Gets the persistable. |
|
90 |
* |
|
91 |
* @return the persistable |
|
92 |
* @see org.eclipse.ui.IEditorInput#getPersistable() |
|
93 |
*/ |
|
94 |
@Override |
|
95 |
public IPersistableElement getPersistable() { |
|
96 |
return null; |
|
97 |
} |
|
98 |
|
|
99 |
/** |
|
100 |
* Gets the tool tip text. |
|
101 |
* |
|
102 |
* @return the tool tip text |
|
103 |
* @see org.eclipse.ui.IEditorInput#getToolTipText() |
|
104 |
*/ |
|
105 |
@Override |
|
106 |
public String getToolTipText() { |
|
107 |
return getName(); |
|
108 |
} |
|
109 |
|
|
110 |
/** |
|
111 |
* Gets the adapter. |
|
112 |
* |
|
113 |
* @param arg0 the arg0 |
|
114 |
* @return the adapter |
|
115 |
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) |
|
116 |
*/ |
|
117 |
@Override |
|
118 |
public Object getAdapter(@SuppressWarnings("rawtypes") Class arg0) { |
|
119 |
return null; |
|
120 |
} |
|
121 |
|
|
122 |
/** |
|
123 |
* Gets the source. |
|
124 |
* |
|
125 |
* @return the Correspondance analysis underlying object |
|
126 |
*/ |
|
127 |
public Object getSource() { |
|
128 |
return ""; //$NON-NLS-1$ |
|
129 |
} |
|
130 |
} |
|
0 | 131 |
tmp/org.txm.backtomedia.rcp/src/org/txm/backtomedia/editors/vlcplayer/VLCPlayerEditor.java (revision 3097) | ||
---|---|---|
1 |
package org.txm.backtomedia.editors.vlcplayer; |
|
2 |
|
|
3 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
4 |
import org.eclipse.swt.SWT; |
|
5 |
import org.eclipse.swt.widgets.Composite; |
|
6 |
import org.eclipse.ui.IEditorInput; |
|
7 |
import org.eclipse.ui.IEditorSite; |
|
8 |
import org.eclipse.ui.PartInitException; |
|
9 |
import org.eclipse.ui.part.EditorPart; |
|
10 |
import org.txm.backtomedia.commands.function.MediaPreferences; |
|
11 |
import org.txm.backtomedia.preferences.BackToMediaPreferences; |
|
12 |
|
|
13 |
public class VLCPlayerEditor extends EditorPart { |
|
14 |
|
|
15 |
/** The Constant ID. */ |
|
16 |
public static final String ID = VLCPlayerEditor.class.getCanonicalName(); // $NON-NLS-1$ |
|
17 |
|
|
18 |
IPlayer player; |
|
19 |
|
|
20 |
@Override |
|
21 |
public void createPartControl(Composite parent) { |
|
22 |
if ("JFX".equals(BackToMediaPreferences.getInstance().getString(BackToMediaPreferences.PLAYER))) { |
|
23 |
player = new JFXPlayer(parent, SWT.NONE); |
|
24 |
} |
|
25 |
else if ("VLC".equals(BackToMediaPreferences.getInstance().getString(BackToMediaPreferences.PLAYER))) { |
|
26 |
player = new VLCPlayer(parent, SWT.NONE); |
|
27 |
} |
|
28 |
else { |
|
29 |
player = new JFXPlayer(parent, SWT.NONE); |
|
30 |
} |
|
31 |
} |
|
32 |
|
|
33 |
public void init() { |
|
34 |
|
|
35 |
} |
|
36 |
|
|
37 |
@Override |
|
38 |
public void setFocus() { |
|
39 |
|
|
40 |
} |
|
41 |
|
|
42 |
@Override |
|
43 |
public void dispose() { |
|
44 |
try { |
|
45 |
if (player != null) player.stop(); |
|
46 |
} |
|
47 |
catch (Exception e) { |
|
48 |
e.printStackTrace(); |
|
49 |
} |
|
50 |
|
|
51 |
super.dispose(); |
|
52 |
} |
|
53 |
|
|
54 |
/* |
|
55 |
* (non-Javadoc) |
|
56 |
* @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor) |
|
57 |
*/ |
|
58 |
@Override |
|
59 |
public void doSave(IProgressMonitor monitor) {} |
|
60 |
|
|
61 |
/* |
|
62 |
* (non-Javadoc) |
|
63 |
* @see org.eclipse.ui.part.EditorPart#doSaveAs() |
|
64 |
*/ |
|
65 |
@Override |
|
66 |
public void doSaveAs() {} |
|
67 |
|
|
68 |
/* |
|
69 |
* (non-Javadoc) |
|
70 |
* @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput) |
|
71 |
*/ |
|
72 |
@Override |
|
73 |
public void init(IEditorSite site, IEditorInput input) |
|
74 |
throws PartInitException { |
|
75 |
setSite(site); |
|
76 |
setInput(input); |
|
77 |
// VLCPlayerEditorInput ii = (VLCPlayerEditorInput) input; |
|
78 |
} |
|
79 |
|
|
80 |
/* |
|
81 |
* (non-Javadoc) |
|
82 |
* @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed() |
|
83 |
*/ |
|
84 |
@Override |
|
85 |
public boolean isSaveAsAllowed() { |
|
86 |
return false; |
|
87 |
} |
|
88 |
|
|
89 |
public IPlayer getPlayer() { |
|
90 |
return player; |
|
91 |
} |
|
92 |
|
|
93 |
@Override |
|
94 |
public void setPartName(String partName) { |
|
95 |
super.setPartName(partName); |
|
96 |
} |
|
97 |
|
|
98 |
@Override |
|
99 |
public boolean isDirty() { |
|
100 |
return false; |
|
101 |
} |
|
102 |
|
|
103 |
/** |
|
104 |
* for more test use "player.getEmbeddedMediaPlayer()" |
|
105 |
* |
|
106 |
* @return false if the media could not be loaded (file not found, access error...) |
|
107 |
*/ |
|
108 |
public boolean isMediaLoaded() { |
|
109 |
return player.isMediaLoaded(); |
|
110 |
} |
|
111 |
} |
tmp/org.txm.backtomedia.rcp/src/org/txm/backtomedia/editors/vlcplayer/MediaPlayerEditor.java (revision 3097) | ||
---|---|---|
1 |
package org.txm.backtomedia.editors.vlcplayer; |
|
2 |
|
|
3 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
4 |
import org.eclipse.swt.SWT; |
|
5 |
import org.eclipse.swt.widgets.Composite; |
|
6 |
import org.eclipse.ui.IEditorInput; |
|
7 |
import org.eclipse.ui.IEditorSite; |
|
8 |
import org.eclipse.ui.PartInitException; |
|
9 |
import org.eclipse.ui.part.EditorPart; |
|
10 |
import org.txm.backtomedia.preferences.BackToMediaPreferences; |
|
11 |
|
|
12 |
public class MediaPlayerEditor extends EditorPart { |
|
13 |
|
|
14 |
/** The Constant ID. */ |
|
15 |
public static final String ID = MediaPlayerEditor.class.getCanonicalName(); // $NON-NLS-1$ |
|
16 |
|
|
17 |
IPlayer player; |
|
18 |
|
|
19 |
@Override |
|
20 |
public void createPartControl(Composite parent) { |
|
21 |
if ("JFX".equals(BackToMediaPreferences.getInstance().getString(BackToMediaPreferences.PLAYER))) { |
|
22 |
player = new JFXPlayer(parent, SWT.NONE); |
|
23 |
} |
|
24 |
else if ("VLC".equals(BackToMediaPreferences.getInstance().getString(BackToMediaPreferences.PLAYER))) { |
|
25 |
player = new VLCPlayer(parent, SWT.NONE); |
|
26 |
} |
|
27 |
else { |
|
28 |
player = new JFXPlayer(parent, SWT.NONE); |
|
29 |
} |
|
30 |
} |
|
31 |
|
|
32 |
public void init() { |
|
33 |
|
|
34 |
} |
|
35 |
|
|
36 |
@Override |
|
37 |
public void setFocus() { |
|
38 |
|
|
39 |
} |
|
40 |
|
|
41 |
@Override |
|
42 |
public void dispose() { |
|
43 |
try { |
|
44 |
if (player != null) player.stop(); |
|
45 |
} |
|
46 |
catch (Exception e) { |
|
47 |
e.printStackTrace(); |
|
48 |
} |
|
49 |
|
|
50 |
super.dispose(); |
|
51 |
} |
|
52 |
|
|
53 |
/* |
|
54 |
* (non-Javadoc) |
|
55 |
* @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor) |
|
56 |
*/ |
|
57 |
@Override |
|
58 |
public void doSave(IProgressMonitor monitor) {} |
|
59 |
|
|
60 |
/* |
|
61 |
* (non-Javadoc) |
|
62 |
* @see org.eclipse.ui.part.EditorPart#doSaveAs() |
|
63 |
*/ |
|
64 |
@Override |
|
65 |
public void doSaveAs() {} |
|
66 |
|
|
67 |
/* |
|
68 |
* (non-Javadoc) |
|
69 |
* @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput) |
|
70 |
*/ |
|
71 |
@Override |
|
72 |
public void init(IEditorSite site, IEditorInput input) |
|
73 |
throws PartInitException { |
|
74 |
setSite(site); |
|
75 |
setInput(input); |
|
76 |
// VLCPlayerEditorInput ii = (VLCPlayerEditorInput) input; |
|
77 |
} |
|
78 |
|
|
79 |
/* |
|
80 |
* (non-Javadoc) |
|
81 |
* @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed() |
|
82 |
*/ |
|
83 |
@Override |
|
84 |
public boolean isSaveAsAllowed() { |
|
85 |
return false; |
|
86 |
} |
|
87 |
|
|
88 |
public IPlayer getPlayer() { |
|
89 |
return player; |
|
90 |
} |
|
91 |
|
|
92 |
@Override |
|
93 |
public void setPartName(String partName) { |
|
94 |
super.setPartName(partName); |
|
95 |
} |
|
96 |
|
|
97 |
@Override |
|
98 |
public boolean isDirty() { |
|
99 |
return false; |
|
100 |
} |
|
101 |
|
|
102 |
/** |
|
103 |
* for more test use "player.getEmbeddedMediaPlayer()" |
|
104 |
* |
|
105 |
* @return false if the media could not be loaded (file not found, access error...) |
|
106 |
*/ |
|
107 |
public boolean isMediaLoaded() { |
|
108 |
return player.isMediaLoaded(); |
|
109 |
} |
|
110 |
} |
|
0 | 111 |
tmp/org.txm.backtomedia.rcp/src/org/txm/backtomedia/commands/function/OpenVLCPlayer.java (revision 3097) | ||
---|---|---|
1 |
// Copyright © 2010-2020 ENS de Lyon., University of Franche-Comté |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate:$ |
|
25 |
// $LastChangedRevision:$ |
|
26 |
// $LastChangedBy:$ |
|
27 |
// |
|
28 |
package org.txm.backtomedia.commands.function; |
|
29 |
|
|
30 |
import java.io.File; |
|
31 |
import java.io.UnsupportedEncodingException; |
|
32 |
import java.net.MalformedURLException; |
|
33 |
import java.net.URLEncoder; |
|
34 |
|
|
35 |
import org.eclipse.core.commands.AbstractHandler; |
|
36 |
import org.eclipse.core.commands.ExecutionEvent; |
|
37 |
import org.eclipse.core.commands.ExecutionException; |
|
38 |
import org.eclipse.jface.dialogs.InputDialog; |
|
39 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
40 |
import org.eclipse.swt.SWT; |
|
41 |
import org.eclipse.swt.events.SelectionEvent; |
|
42 |
import org.eclipse.swt.events.SelectionListener; |
|
43 |
import org.eclipse.swt.widgets.Button; |
|
44 |
import org.eclipse.swt.widgets.Composite; |
|
45 |
import org.eclipse.swt.widgets.Control; |
|
46 |
import org.eclipse.swt.widgets.FileDialog; |
|
47 |
import org.eclipse.swt.widgets.Shell; |
|
48 |
import org.eclipse.ui.IEditorPart; |
|
49 |
import org.eclipse.ui.IWorkbenchPage; |
|
50 |
import org.eclipse.ui.PartInitException; |
|
51 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
52 |
import org.txm.backtomedia.editors.input.VLCPlayerEditorInput; |
|
53 |
import org.txm.backtomedia.editors.vlcplayer.VLCPlayerEditor; |
|
54 |
import org.txm.rcp.StatusLine; |
|
55 |
import org.txm.rcp.TXMWindows; |
|
56 |
|
|
57 |
import vlcplayerrcp.MessagesMP; |
|
58 |
|
|
59 |
/** |
|
60 |
* open the VLCPlayer Editor with a selected media file. Path or URL |
|
61 |
* |
|
62 |
* @author mdecorde. |
|
63 |
*/ |
|
64 |
public class OpenVLCPlayer extends AbstractHandler { |
|
65 |
|
|
66 |
/** The ID. */ |
|
67 |
public static String ID = "org.txm.rcp.commands.BackToMedia"; //$NON-NLS-1$ |
|
68 |
|
|
69 |
/* |
|
70 |
* (non-Javadoc) |
|
71 |
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
72 |
*/ |
|
73 |
@Override |
|
74 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
75 |
|
|
76 |
Object o = HandlerUtil.getCurrentSelection(event); |
|
77 |
IStructuredSelection selection; |
|
78 |
if (o instanceof IStructuredSelection) { |
|
79 |
selection = (IStructuredSelection) o; |
|
80 |
Object s = selection.getFirstElement(); |
|
81 |
if (s instanceof File) { |
|
82 |
File f = (File) s; |
|
83 |
|
|
84 |
try { |
|
85 |
return openEditor(f.toURI().toURL().toString(), 0); |
|
86 |
} |
|
87 |
catch (MalformedURLException e) { |
|
88 |
// TODO Auto-generated catch block |
|
89 |
e.printStackTrace(); |
|
90 |
} |
|
91 |
} |
|
92 |
} |
|
93 |
|
|
94 |
Shell sh = HandlerUtil.getActiveShell(event); |
|
95 |
SimpleFileDialog fd = new SimpleFileDialog(sh, "Opening media file...", "Enter file path or URL", "", null); |
|
96 |
// FileDialog fd = new FileDialog(new Shell(), SWT.SAVE); |
|
97 |
// fd.setText(MessagesMP.select_file); |
|
98 |
|
|
99 |
// String[] filterExt = { "*.*", "*.mp3", "*.ogg", "*.avi", "*.mp4", "*.mov"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ |
|
100 |
// fd.setFilterExtensions(filterExt); |
|
101 |
if (fd.open() == fd.OK) { |
|
102 |
String mrl = fd.getValue(); |
|
103 |
|
|
104 |
if (mrl != null) { |
|
105 |
File f = new File(mrl); |
|
106 |
if (f.exists()) { |
|
107 |
mrl = new File(mrl).toURI().toString(); |
|
108 |
} |
|
109 |
else { |
|
110 |
|
|
111 |
} |
|
112 |
return openEditor(mrl, 0); |
|
113 |
} |
|
114 |
} |
|
115 |
|
|
116 |
return null; |
|
117 |
} |
|
118 |
|
|
119 |
public static VLCPlayerEditor openEditor() { |
|
120 |
IWorkbenchPage page = TXMWindows.getActiveWindow().getActivePage(); |
|
121 |
VLCPlayerEditorInput editorInput = new VLCPlayerEditorInput(); |
|
122 |
StatusLine.setMessage(MessagesMP.opening_media); |
|
123 |
try { |
|
124 |
IEditorPart editor = page.openEditor(editorInput, VLCPlayerEditor.ID); |
|
125 |
if (editor != null && editor instanceof VLCPlayerEditor) { |
|
126 |
return (VLCPlayerEditor) editor; |
|
127 |
} |
|
128 |
else { |
|
129 |
return null; |
|
130 |
} |
|
131 |
} |
|
132 |
catch (PartInitException e) { |
|
133 |
e.printStackTrace(); |
|
134 |
} |
|
135 |
return null; |
|
136 |
} |
|
137 |
|
|
138 |
public static VLCPlayerEditor openEditor(String mrl, int time) { |
|
139 |
IWorkbenchPage page = TXMWindows.getActiveWindow().getActivePage(); |
|
140 |
VLCPlayerEditorInput editorInput = new VLCPlayerEditorInput(); |
|
141 |
StatusLine.setMessage(MessagesMP.opening_media); |
|
142 |
try { |
|
143 |
VLCPlayerEditor player = (VLCPlayerEditor) page.openEditor(editorInput, VLCPlayerEditor.ID); |
|
144 |
if (player != null) { |
|
145 |
player.getPlayer().play(mrl, time); |
|
146 |
StatusLine.setMessage(""); |
|
147 |
if (mrl != null) { |
|
148 |
player.setPartName(new File(mrl).getName()); |
|
149 |
} |
|
150 |
|
|
151 |
return player; |
|
152 |
} |
|
153 |
else { |
|
154 |
System.out.println(MessagesMP.error_open_media); |
|
155 |
} |
|
156 |
} |
|
157 |
catch (PartInitException e) { |
|
158 |
e.printStackTrace(); |
|
159 |
} |
|
160 |
return null; |
|
161 |
} |
|
162 |
|
|
163 |
public static VLCPlayerEditor openEditor(String mrl, int time, int endtime) { |
|
164 |
IWorkbenchPage page = TXMWindows.getActiveWindow().getActivePage(); |
|
165 |
VLCPlayerEditorInput editorInput = new VLCPlayerEditorInput(); |
|
166 |
StatusLine.setMessage(MessagesMP.opening_media); |
|
167 |
try { |
|
168 |
VLCPlayerEditor player = (VLCPlayerEditor) page.openEditor(editorInput, VLCPlayerEditor.ID); |
|
169 |
|
|
170 |
// boolean isAudio = mrl.matches(".+\\.(mp3|ogg|wav|wpa)"); //$NON-NLS-1$ |
|
171 |
if (player != null) { |
|
172 |
player.getPlayer().play(mrl, time, endtime); |
|
173 |
StatusLine.setMessage(""); |
|
174 |
} |
|
175 |
else { |
|
176 |
System.out.println(MessagesMP.error_open_media); |
|
177 |
return null; |
|
178 |
} |
|
179 |
return player; |
|
180 |
} |
|
181 |
catch (PartInitException e) { |
|
182 |
e.printStackTrace(); |
|
183 |
} |
|
184 |
|
|
185 |
return null; |
|
186 |
} |
|
187 |
|
|
188 |
public static VLCPlayerEditor openEditor(String path, String sStartTime, |
|
189 |
String sEndTime) { |
|
190 |
IWorkbenchPage page = TXMWindows.getActiveWindow().getActivePage(); |
|
191 |
VLCPlayerEditorInput editorInput = new VLCPlayerEditorInput(); |
|
192 |
StatusLine.setMessage(MessagesMP.opening_media); |
|
193 |
try { |
|
194 |
IEditorPart editor = page.openEditor(editorInput, VLCPlayerEditor.ID); |
|
195 |
if (editor == null) { |
|
196 |
return null; |
|
197 |
} |
|
198 |
|
|
199 |
VLCPlayerEditor player = (VLCPlayerEditor) editor; |
|
200 |
// boolean isAudio = mrl.matches(".+\\.(mp3|ogg|wav|wpa)"); |
|
201 |
if (player != null) { |
|
202 |
player.getPlayer().play(path, sStartTime, sEndTime); |
|
203 |
StatusLine.setMessage(""); |
|
204 |
} |
|
205 |
return player; |
|
206 |
} |
|
207 |
catch (PartInitException e) { |
|
208 |
e.printStackTrace(); |
|
209 |
} |
|
210 |
|
|
211 |
return null; |
|
212 |
} |
|
213 |
} |
tmp/org.txm.backtomedia.rcp/src/org/txm/backtomedia/commands/function/BackToMedia.java (revision 3097) | ||
---|---|---|
46 | 46 |
import org.eclipse.ui.handlers.HandlerUtil; |
47 | 47 |
import org.eclipse.ui.part.EditorPart; |
48 | 48 |
import org.txm.backtomedia.editors.vlcplayer.VLCPlayer; |
49 |
import org.txm.backtomedia.editors.vlcplayer.VLCPlayerEditor;
|
|
49 |
import org.txm.backtomedia.editors.vlcplayer.MediaPlayerEditor;
|
|
50 | 50 |
import org.txm.backtomedia.preferences.BackToMediaPreferences; |
51 | 51 |
import org.txm.concordance.core.functions.Line; |
52 | 52 |
import org.txm.concordance.rcp.editors.ConcordanceEditor; |
... | ... | |
90 | 90 |
/** The selection. */ |
91 | 91 |
private IStructuredSelection selection; |
92 | 92 |
|
93 |
private static HashMap<IWorkbenchPart, VLCPlayerEditor> associatedEditors = new HashMap<>();
|
|
93 |
private static HashMap<IWorkbenchPart, MediaPlayerEditor> associatedEditors = new HashMap<>();
|
|
94 | 94 |
|
95 | 95 |
/* |
96 | 96 |
* (non-Javadoc) |
... | ... | |
508 | 508 |
Log.fine(MessagesMP.BackToMedia_25 + path); |
509 | 509 |
|
510 | 510 |
// System.out.println("Linked editors: "+associatedEditors); |
511 |
VLCPlayerEditor vlcEditor = null;
|
|
511 |
MediaPlayerEditor vlcEditor = null;
|
|
512 | 512 |
if (editor != null) { |
513 | 513 |
vlcEditor = associatedEditors.get(editor); |
514 | 514 |
} |
515 | 515 |
|
516 | 516 |
if (vlcEditor == null || vlcEditor.getPlayer().isDisposed()) { |
517 | 517 |
// System.out.println("new editor linked to "+ce); |
518 |
vlcEditor = OpenVLCPlayer.openEditor();
|
|
518 |
vlcEditor = OpenMediaPlayer.openEditor();
|
|
519 | 519 |
|
520 | 520 |
// editor.getPlayer().setRepeat(true); |
521 | 521 |
if (vlcEditor == null) { |
tmp/org.txm.backtomedia.rcp/src/org/txm/backtomedia/commands/function/OpenMediaPlayer.java (revision 3097) | ||
---|---|---|
1 |
// Copyright © 2010-2020 ENS de Lyon., University of Franche-Comté |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate:$ |
|
25 |
// $LastChangedRevision:$ |
|
26 |
// $LastChangedBy:$ |
|
27 |
// |
|
28 |
package org.txm.backtomedia.commands.function; |
|
29 |
|
|
30 |
import java.io.File; |
|
31 |
import java.io.UnsupportedEncodingException; |
|
32 |
import java.net.MalformedURLException; |
|
33 |
import java.net.URLEncoder; |
|
34 |
|
|
35 |
import org.eclipse.core.commands.AbstractHandler; |
|
36 |
import org.eclipse.core.commands.ExecutionEvent; |
|
37 |
import org.eclipse.core.commands.ExecutionException; |
|
38 |
import org.eclipse.jface.dialogs.InputDialog; |
|
39 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
40 |
import org.eclipse.swt.SWT; |
|
41 |
import org.eclipse.swt.events.SelectionEvent; |
|
42 |
import org.eclipse.swt.events.SelectionListener; |
|
43 |
import org.eclipse.swt.widgets.Button; |
|
44 |
import org.eclipse.swt.widgets.Composite; |
|
45 |
import org.eclipse.swt.widgets.Control; |
|
46 |
import org.eclipse.swt.widgets.FileDialog; |
|
47 |
import org.eclipse.swt.widgets.Shell; |
|
48 |
import org.eclipse.ui.IEditorPart; |
|
49 |
import org.eclipse.ui.IWorkbenchPage; |
|
50 |
import org.eclipse.ui.PartInitException; |
|
51 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
52 |
import org.txm.backtomedia.editors.input.MediaPlayerEditorInput; |
|
53 |
import org.txm.backtomedia.editors.vlcplayer.MediaPlayerEditor; |
|
54 |
import org.txm.rcp.StatusLine; |
|
55 |
import org.txm.rcp.TXMWindows; |
|
56 |
|
|
57 |
import vlcplayerrcp.MessagesMP; |
|
58 |
|
|
59 |
/** |
|
60 |
* open the Media player Editor with a selected media file. Path or URL |
|
61 |
* |
|
62 |
* @author mdecorde. |
|
63 |
*/ |
|
64 |
public class OpenMediaPlayer extends AbstractHandler { |
|
65 |
|
|
66 |
/** The ID. */ |
|
67 |
public static String ID = "org.txm.rcp.commands.BackToMedia"; //$NON-NLS-1$ |
|
68 |
|
|
69 |
/* |
|
70 |
* (non-Javadoc) |
|
71 |
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
72 |
*/ |
|
73 |
@Override |
|
74 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
75 |
|
|
76 |
Object o = HandlerUtil.getCurrentSelection(event); |
|
77 |
IStructuredSelection selection; |
|
78 |
if (o instanceof IStructuredSelection) { |
|
79 |
selection = (IStructuredSelection) o; |
|
80 |
Object s = selection.getFirstElement(); |
|
81 |
if (s instanceof File) { |
|
82 |
File f = (File) s; |
|
83 |
|
|
84 |
try { |
|
85 |
return openEditor(f.toURI().toURL().toString(), 0); |
|
86 |
} |
|
87 |
catch (MalformedURLException e) { |
|
88 |
// TODO Auto-generated catch block |
|
89 |
e.printStackTrace(); |
|
90 |
} |
|
91 |
} |
|
92 |
} |
|
93 |
|
|
94 |
Shell sh = HandlerUtil.getActiveShell(event); |
|
95 |
SimpleFileDialog fd = new SimpleFileDialog(sh, "Opening media file...", "Enter file path or URL", "", null); |
|
96 |
// FileDialog fd = new FileDialog(new Shell(), SWT.SAVE); |
|
97 |
// fd.setText(MessagesMP.select_file); |
|
98 |
|
|
99 |
// String[] filterExt = { "*.*", "*.mp3", "*.ogg", "*.avi", "*.mp4", "*.mov"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ |
|
100 |
// fd.setFilterExtensions(filterExt); |
|
101 |
if (fd.open() == fd.OK) { |
|
102 |
String mrl = fd.getValue(); |
|
103 |
|
|
104 |
if (mrl != null) { |
|
105 |
File f = new File(mrl); |
|
106 |
if (f.exists()) { |
|
107 |
mrl = new File(mrl).toURI().toString(); |
|
108 |
} |
|
109 |
else { |
|
110 |
|
|
111 |
} |
|
112 |
return openEditor(mrl, 0); |
|
113 |
} |
|
114 |
} |
|
115 |
|
|
116 |
return null; |
|
117 |
} |
|
118 |
|
|
119 |
public static MediaPlayerEditor openEditor() { |
|
120 |
IWorkbenchPage page = TXMWindows.getActiveWindow().getActivePage(); |
|
121 |
MediaPlayerEditorInput editorInput = new MediaPlayerEditorInput(); |
|
122 |
StatusLine.setMessage(MessagesMP.opening_media); |
|
123 |
try { |
|
124 |
IEditorPart editor = page.openEditor(editorInput, MediaPlayerEditor.ID); |
|
125 |
if (editor != null && editor instanceof MediaPlayerEditor) { |
|
126 |
return (MediaPlayerEditor) editor; |
|
127 |
} |
|
128 |
else { |
|
129 |
return null; |
|
130 |
} |
|
131 |
} |
|
132 |
catch (PartInitException e) { |
|
133 |
e.printStackTrace(); |
|
134 |
} |
|
135 |
return null; |
|
136 |
} |
|
137 |
|
|
138 |
public static MediaPlayerEditor openEditor(String mrl, int time) { |
|
139 |
IWorkbenchPage page = TXMWindows.getActiveWindow().getActivePage(); |
|
140 |
MediaPlayerEditorInput editorInput = new MediaPlayerEditorInput(); |
|
141 |
StatusLine.setMessage(MessagesMP.opening_media); |
|
142 |
try { |
|
143 |
MediaPlayerEditor player = (MediaPlayerEditor) page.openEditor(editorInput, MediaPlayerEditor.ID); |
|
144 |
if (player != null) { |
|
145 |
player.getPlayer().play(mrl, time); |
|
146 |
StatusLine.setMessage(""); |
|
147 |
if (mrl != null) { |
|
148 |
player.setPartName(new File(mrl).getName()); |
|
149 |
} |
|
150 |
|
|
151 |
return player; |
|
152 |
} |
|
153 |
else { |
|
154 |
System.out.println(MessagesMP.error_open_media); |
|
155 |
} |
|
156 |
} |
|
157 |
catch (PartInitException e) { |
|
158 |
e.printStackTrace(); |
|
159 |
} |
|
160 |
return null; |
|
161 |
} |
|
162 |
|
|
163 |
public static MediaPlayerEditor openEditor(String mrl, int time, int endtime) { |
|
164 |
IWorkbenchPage page = TXMWindows.getActiveWindow().getActivePage(); |
|
165 |
MediaPlayerEditorInput editorInput = new MediaPlayerEditorInput(); |
|
166 |
StatusLine.setMessage(MessagesMP.opening_media); |
|
167 |
try { |
|
168 |
MediaPlayerEditor player = (MediaPlayerEditor) page.openEditor(editorInput, MediaPlayerEditor.ID); |
|
169 |
|
|
170 |
// boolean isAudio = mrl.matches(".+\\.(mp3|ogg|wav|wpa)"); //$NON-NLS-1$ |
|
171 |
if (player != null) { |
|
172 |
player.getPlayer().play(mrl, time, endtime); |
|
173 |
StatusLine.setMessage(""); |
|
174 |
} |
|
175 |
else { |
|
176 |
System.out.println(MessagesMP.error_open_media); |
|
177 |
return null; |
|
178 |
} |
|
179 |
return player; |
|
180 |
} |
|
181 |
catch (PartInitException e) { |
|
182 |
e.printStackTrace(); |
|
183 |
} |
|
184 |
|
|
185 |
return null; |
|
186 |
} |
|
187 |
|
|
188 |
public static MediaPlayerEditor openEditor(String path, String sStartTime, |
|
189 |
String sEndTime) { |
|
190 |
IWorkbenchPage page = TXMWindows.getActiveWindow().getActivePage(); |
|
191 |
MediaPlayerEditorInput editorInput = new MediaPlayerEditorInput(); |
|
192 |
StatusLine.setMessage(MessagesMP.opening_media); |
|
193 |
try { |
|
194 |
IEditorPart editor = page.openEditor(editorInput, MediaPlayerEditor.ID); |
|
195 |
if (editor == null) { |
|
196 |
return null; |
|
197 |
} |
|
198 |
|
|
199 |
MediaPlayerEditor player = (MediaPlayerEditor) editor; |
|
200 |
// boolean isAudio = mrl.matches(".+\\.(mp3|ogg|wav|wpa)"); |
|
201 |
if (player != null) { |
|
202 |
player.getPlayer().play(path, sStartTime, sEndTime); |
|
203 |
StatusLine.setMessage(""); |
|
204 |
} |
|
205 |
return player; |
|
206 |
} |
|
207 |
catch (PartInitException e) { |
|
208 |
e.printStackTrace(); |
|
209 |
} |
|
210 |
|
|
211 |
return null; |
|
212 |
} |
|
213 |
} |
|
0 | 214 |
Formats disponibles : Unified diff