Skip to content

Commit b434118

Browse files
committed
Add possibility to set gstreamer commands in preferences.
If there is a need to add more arguments to gstreamer default commands user has to add them to every new created project in proper wizard window. It improves user experience by creating a possiblity to set additional gstreamer commands in preferences window as they are common for all project and user doesn't need to repeat them every time during creating new project Signed-off-by: Emilia Dominiak <emilia.dominiak@intel.com>
1 parent c454589 commit b434118

File tree

6 files changed

+108
-3
lines changed

6 files changed

+108
-3
lines changed

org.sofproject.gst.topo/META-INF/MANIFEST.MF

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ Require-Bundle: org.sofproject.core,
1010
org.sofproject.ui,
1111
org.sofproject.topo.ui,
1212
com.jcraft.jsch
13+
Export-Package: org.sofproject.gst.topo

org.sofproject.gst.topo/src/org/sofproject/gst/topo/IGstNodeConst.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,16 @@
3131

3232
public interface IGstNodeConst {
3333
String GST_NODE_CORE_ID = "org.sofproject.gst.topo";
34+
String GST_NODE_PREFERENCES_ID = "org.sofproject.ui.preferences";
35+
3436
String GST_NODE_EXTENSION_ID = GST_NODE_CORE_ID + ".gstextension";
3537

3638
String GST_PROJ_DEFAULT_GST_INSPECT_TOOL_CMD = "gst-inspect-1.0";
3739
String GST_PROJ_DEFAULT_GST_LAUNCH_TOOL_CMD = "gst-launch-1.0";
3840

3941
String GST_PROJ_PROP_GST_INSPECT_TOOL_CMD = "gstInspectToolCmd";
4042
String GST_PROJ_PROP_GST_LAUNCH_TOOL_CMD = "gstLaunchToolCmd";
43+
44+
String GST_LAUNCH_PREF_NAME = "gstLaunch";
45+
String GST_INSPECT_PREF_NAME = "gstInspect";
4146
}

org.sofproject.gst.topo/src/org/sofproject/gst/topo/ui/wizards/GstNodeNewPage.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
package org.sofproject.gst.topo.ui.wizards;
3131

32+
import org.eclipse.core.runtime.Platform;
3233
import org.eclipse.jface.dialogs.Dialog;
3334
import org.eclipse.jface.wizard.WizardPage;
3435
import org.eclipse.swt.SWT;
@@ -39,6 +40,7 @@
3940
import org.eclipse.swt.widgets.Listener;
4041
import org.eclipse.swt.widgets.Text;
4142
import org.sofproject.gst.topo.GstNodeExtension;
43+
import org.sofproject.gst.topo.IGstNodeConst;
4244
import org.sofproject.ui.wizards.INewNodeExtensionPage;
4345

4446
public class GstNodeNewPage extends WizardPage implements INewNodeExtensionPage {
@@ -78,7 +80,8 @@ public void createControl(Composite parent) {
7880
data.grabExcessHorizontalSpace = true;
7981
gstInspectToolCmd = new Text(inspectGroup, SWT.BORDER);
8082
gstInspectToolCmd.setLayoutData(data);
81-
gstInspectToolCmd.setText(gstNode.getGstInspectToolCmd());
83+
gstInspectToolCmd.setText(Platform.getPreferencesService().getString(IGstNodeConst.GST_NODE_PREFERENCES_ID,
84+
IGstNodeConst.GST_INSPECT_PREF_NAME, gstNode.getGstInspectToolCmd(), null));
8285
gstInspectToolCmd.addListener(SWT.Modify, confModifyListener);
8386

8487
Composite launchGroup = new Composite(control, SWT.NONE);
@@ -91,7 +94,8 @@ public void createControl(Composite parent) {
9194
data.grabExcessHorizontalSpace = true;
9295
gstLaunchToolCmd = new Text(launchGroup, SWT.BORDER);
9396
gstLaunchToolCmd.setLayoutData(data);
94-
gstLaunchToolCmd.setText(gstNode.getGstLaunchToolCmd());
97+
gstLaunchToolCmd.setText(Platform.getPreferencesService().getString(IGstNodeConst.GST_NODE_PREFERENCES_ID,
98+
IGstNodeConst.GST_LAUNCH_PREF_NAME, gstNode.getGstLaunchToolCmd(), null));
9599
gstLaunchToolCmd.addListener(SWT.Modify, confModifyListener);
96100

97101
setControl(control);

org.sofproject.ui/META-INF/MANIFEST.MF

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ Export-Package: org.sofproject.ui.editor,
2525
org.sofproject.ui.properties,
2626
org.sofproject.ui.wizards
2727
Bundle-Vendor: Intel Corporation
28-
Import-Package: com.google.common.collect;version="21.0.0"
28+
Import-Package: com.google.common.collect;version="21.0.0",
29+
org.sofproject.gst.topo
30+

org.sofproject.ui/plugin.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,11 @@
101101
name="Audio Development">
102102
</perspective>
103103
</extension>
104+
<extension
105+
point="org.eclipse.ui.preferencePages">
106+
<page id="org.sofproject.ui.preferences.gstcommandspreferences"
107+
class="org.sofproject.ui.preferences.GstCommandsPreferences"
108+
name="GStreamer commands">
109+
</page>
110+
</extension>
104111
</plugin>
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
* Copyright (c) 2019, Intel Corporation
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
* * Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* * Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
* * Neither the name of the Intel Corporation nor the
13+
* names of its contributors may be used to endorse or promote products
14+
* derived from this software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
* POSSIBILITY OF SUCH DAMAGE.
27+
*
28+
*/
29+
30+
package org.sofproject.ui.preferences;
31+
32+
import org.eclipse.core.runtime.preferences.InstanceScope;
33+
import org.eclipse.jface.preference.FieldEditorPreferencePage;
34+
import org.eclipse.jface.preference.IPreferenceStore;
35+
import org.eclipse.jface.preference.StringFieldEditor;
36+
import org.eclipse.ui.IWorkbench;
37+
import org.eclipse.ui.IWorkbenchPreferencePage;
38+
import org.eclipse.ui.preferences.ScopedPreferenceStore;
39+
import org.sofproject.gst.topo.IGstNodeConst;
40+
41+
public class GstCommandsPreferences extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
42+
43+
private StringFieldEditor gstInspectfieldEditor;
44+
private StringFieldEditor gstLaunchfieldEditor;
45+
46+
public GstCommandsPreferences() {
47+
super(GRID);
48+
setDescription("Set custom GStreamer commands");
49+
}
50+
51+
@Override
52+
public boolean performOk() {
53+
if (gstLaunchfieldEditor.getStringValue().equals("")) {
54+
setErrorMessage("gst-launch command cannot be empty");
55+
return false;
56+
}
57+
58+
if (gstInspectfieldEditor.getStringValue().equals("")) {
59+
setErrorMessage("gst-inspect command cannot be empty");
60+
return false;
61+
}
62+
return super.performOk();
63+
}
64+
65+
@Override
66+
public void init(IWorkbench workbench) {
67+
IPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE,
68+
IGstNodeConst.GST_NODE_PREFERENCES_ID);
69+
70+
store.setDefault(IGstNodeConst.GST_INSPECT_PREF_NAME, IGstNodeConst.GST_PROJ_DEFAULT_GST_INSPECT_TOOL_CMD);
71+
store.setDefault(IGstNodeConst.GST_LAUNCH_PREF_NAME, IGstNodeConst.GST_PROJ_DEFAULT_GST_LAUNCH_TOOL_CMD);
72+
73+
setPreferenceStore(store);
74+
}
75+
76+
@Override
77+
protected void createFieldEditors() {
78+
gstInspectfieldEditor = new StringFieldEditor(IGstNodeConst.GST_INSPECT_PREF_NAME, "Gst-inspect command: ",
79+
getFieldEditorParent());
80+
addField(gstInspectfieldEditor);
81+
82+
gstLaunchfieldEditor = new StringFieldEditor(IGstNodeConst.GST_LAUNCH_PREF_NAME, "Gst-launch command: ",
83+
getFieldEditorParent());
84+
addField(gstLaunchfieldEditor);
85+
}
86+
}

0 commit comments

Comments
 (0)