diff --git a/org.sofproject.gst.topo/META-INF/MANIFEST.MF b/org.sofproject.gst.topo/META-INF/MANIFEST.MF index dd4cd5d..50f78f1 100644 --- a/org.sofproject.gst.topo/META-INF/MANIFEST.MF +++ b/org.sofproject.gst.topo/META-INF/MANIFEST.MF @@ -10,3 +10,4 @@ Require-Bundle: org.sofproject.core, org.sofproject.ui, org.sofproject.topo.ui, com.jcraft.jsch +Export-Package: org.sofproject.gst.topo diff --git a/org.sofproject.gst.topo/src/org/sofproject/gst/topo/IGstNodeConst.java b/org.sofproject.gst.topo/src/org/sofproject/gst/topo/IGstNodeConst.java index d2caa85..e49674e 100644 --- a/org.sofproject.gst.topo/src/org/sofproject/gst/topo/IGstNodeConst.java +++ b/org.sofproject.gst.topo/src/org/sofproject/gst/topo/IGstNodeConst.java @@ -31,6 +31,8 @@ public interface IGstNodeConst { String GST_NODE_CORE_ID = "org.sofproject.gst.topo"; + String GST_NODE_PREFERENCES_ID = "org.sofproject.ui.preferences"; + String GST_NODE_EXTENSION_ID = GST_NODE_CORE_ID + ".gstextension"; String GST_PROJ_DEFAULT_GST_INSPECT_TOOL_CMD = "gst-inspect-1.0"; @@ -38,4 +40,7 @@ public interface IGstNodeConst { String GST_PROJ_PROP_GST_INSPECT_TOOL_CMD = "gstInspectToolCmd"; String GST_PROJ_PROP_GST_LAUNCH_TOOL_CMD = "gstLaunchToolCmd"; + + String GST_LAUNCH_PREF_NAME = "gstLaunch"; + String GST_INSPECT_PREF_NAME = "gstInspect"; } diff --git a/org.sofproject.gst.topo/src/org/sofproject/gst/topo/ui/wizards/GstNodeNewPage.java b/org.sofproject.gst.topo/src/org/sofproject/gst/topo/ui/wizards/GstNodeNewPage.java index 01730c3..ceed399 100644 --- a/org.sofproject.gst.topo/src/org/sofproject/gst/topo/ui/wizards/GstNodeNewPage.java +++ b/org.sofproject.gst.topo/src/org/sofproject/gst/topo/ui/wizards/GstNodeNewPage.java @@ -29,6 +29,7 @@ package org.sofproject.gst.topo.ui.wizards; +import org.eclipse.core.runtime.Platform; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; @@ -39,6 +40,7 @@ import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Text; import org.sofproject.gst.topo.GstNodeExtension; +import org.sofproject.gst.topo.IGstNodeConst; import org.sofproject.ui.wizards.INewNodeExtensionPage; public class GstNodeNewPage extends WizardPage implements INewNodeExtensionPage { @@ -64,22 +66,23 @@ public GstNodeNewPage(GstNodeExtension gstNode) { @Override public void createControl(Composite parent) { Composite control = new Composite(parent, SWT.NULL); - initializeDialogUnits(parent); - control.setLayout(new GridLayout()); - control.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Composite inspectGroup = new Composite(control, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - inspectGroup.setLayout(layout); - inspectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - new Label(inspectGroup, SWT.NONE).setText("gst-inspect command"); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.grabExcessHorizontalSpace = true; - gstInspectToolCmd = new Text(inspectGroup, SWT.BORDER); - gstInspectToolCmd.setLayoutData(data); - gstInspectToolCmd.setText(gstNode.getGstInspectToolCmd()); - gstInspectToolCmd.addListener(SWT.Modify, confModifyListener); + initializeDialogUnits(parent); + control.setLayout(new GridLayout()); + control.setLayoutData(new GridData(GridData.FILL_BOTH)); + + Composite inspectGroup = new Composite(control, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + inspectGroup.setLayout(layout); + inspectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + new Label(inspectGroup, SWT.NONE).setText("gst-inspect command"); + GridData data = new GridData(GridData.FILL_HORIZONTAL); + data.grabExcessHorizontalSpace = true; + gstInspectToolCmd = new Text(inspectGroup, SWT.BORDER); + gstInspectToolCmd.setLayoutData(data); + gstInspectToolCmd.setText(Platform.getPreferencesService().getString(IGstNodeConst.GST_NODE_PREFERENCES_ID, + IGstNodeConst.GST_INSPECT_PREF_NAME, gstNode.getGstInspectToolCmd(), null)); + gstInspectToolCmd.addListener(SWT.Modify, confModifyListener); Composite launchGroup = new Composite(control, SWT.NONE); layout = new GridLayout(); @@ -91,11 +94,12 @@ public void createControl(Composite parent) { data.grabExcessHorizontalSpace = true; gstLaunchToolCmd = new Text(launchGroup, SWT.BORDER); gstLaunchToolCmd.setLayoutData(data); - gstLaunchToolCmd.setText(gstNode.getGstLaunchToolCmd()); + gstLaunchToolCmd.setText(Platform.getPreferencesService().getString(IGstNodeConst.GST_NODE_PREFERENCES_ID, + IGstNodeConst.GST_LAUNCH_PREF_NAME, gstNode.getGstLaunchToolCmd(), null)); gstLaunchToolCmd.addListener(SWT.Modify, confModifyListener); setControl(control); - Dialog.applyDialogFont(control); + Dialog.applyDialogFont(control); } protected boolean validatePage() { diff --git a/org.sofproject.ui/META-INF/MANIFEST.MF b/org.sofproject.ui/META-INF/MANIFEST.MF index 184223c..32c91f0 100644 --- a/org.sofproject.ui/META-INF/MANIFEST.MF +++ b/org.sofproject.ui/META-INF/MANIFEST.MF @@ -25,4 +25,6 @@ Export-Package: org.sofproject.ui.editor, org.sofproject.ui.properties, org.sofproject.ui.wizards Bundle-Vendor: Intel Corporation -Import-Package: com.google.common.collect;version="21.0.0" +Import-Package: com.google.common.collect;version="21.0.0", + org.sofproject.gst.topo + diff --git a/org.sofproject.ui/plugin.xml b/org.sofproject.ui/plugin.xml index 30c5c19..c380df9 100644 --- a/org.sofproject.ui/plugin.xml +++ b/org.sofproject.ui/plugin.xml @@ -101,4 +101,11 @@ name="Audio Development"> + + + + diff --git a/org.sofproject.ui/src/org/sofproject/ui/preferences/GstCommandsPreferences.java b/org.sofproject.ui/src/org/sofproject/ui/preferences/GstCommandsPreferences.java new file mode 100644 index 0000000..0d7e36d --- /dev/null +++ b/org.sofproject.ui/src/org/sofproject/ui/preferences/GstCommandsPreferences.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2019, Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Intel Corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ + +package org.sofproject.ui.preferences; + +import org.eclipse.core.runtime.preferences.InstanceScope; +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.StringFieldEditor; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.ui.preferences.ScopedPreferenceStore; +import org.sofproject.gst.topo.IGstNodeConst; + +public class GstCommandsPreferences extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { + + private StringFieldEditor gstInspectfieldEditor; + private StringFieldEditor gstLaunchfieldEditor; + + public GstCommandsPreferences() { + super(GRID); + setDescription("Set custom GStreamer commands"); + } + + @Override + public boolean performOk() { + if (gstLaunchfieldEditor.getStringValue().equals("")) { + setErrorMessage("gst-launch command cannot be empty"); + return false; + } + + if (gstInspectfieldEditor.getStringValue().equals("")) { + setErrorMessage("gst-inspect command cannot be empty"); + return false; + } + return super.performOk(); + } + + @Override + public void init(IWorkbench workbench) { + IPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE, + IGstNodeConst.GST_NODE_PREFERENCES_ID); + + store.setDefault(IGstNodeConst.GST_INSPECT_PREF_NAME, IGstNodeConst.GST_PROJ_DEFAULT_GST_INSPECT_TOOL_CMD); + store.setDefault(IGstNodeConst.GST_LAUNCH_PREF_NAME, IGstNodeConst.GST_PROJ_DEFAULT_GST_LAUNCH_TOOL_CMD); + + setPreferenceStore(store); + } + + @Override + protected void createFieldEditors() { + gstInspectfieldEditor = new StringFieldEditor(IGstNodeConst.GST_INSPECT_PREF_NAME, "Gst-inspect command: ", + getFieldEditorParent()); + addField(gstInspectfieldEditor); + + gstLaunchfieldEditor = new StringFieldEditor(IGstNodeConst.GST_LAUNCH_PREF_NAME, "Gst-launch command: ", + getFieldEditorParent()); + addField(gstLaunchfieldEditor); + } +}