Skip to content

Commit 0f15e78

Browse files
committed
Add possibility to set node address and username in preferences
Signed-off-by: Emilia Dominiak <emilia.dominiak@intel.com>
1 parent 0c3cea4 commit 0f15e78

File tree

7 files changed

+91
-2
lines changed

7 files changed

+91
-2
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.ui.preferences

org.sofproject.gst.topo/plugin.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,11 @@
4747
name="GStreamer commands">
4848
</page>
4949
</extension>
50+
<extension
51+
point = "org.eclipse.ui.preferencePages">
52+
<page id="org.sofproject.gst.topo.ui.preferences.connectionpreferences"
53+
class="org.sofproject.gst.topo.ui.preferences.ConnectionPreferences"
54+
name="Connection">
55+
</page>
56+
</extension>
5057
</plugin>
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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.gst.topo.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+
40+
public class ConnectionPreferences extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
41+
42+
StringFieldEditor ipFieldEditor;
43+
StringFieldEditor userFieldEditor;
44+
45+
@Override
46+
public void init(IWorkbench workbench) {
47+
IPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE,
48+
"org.sofproject.gst.topo.ui.preferences");
49+
setPreferenceStore(store);
50+
51+
}
52+
53+
@Override
54+
protected void createFieldEditors() {
55+
ipFieldEditor = new StringFieldEditor(ConnectionPreferencesConst.CONN_ADDR, "Address for all projects: ",
56+
getFieldEditorParent());
57+
addField(ipFieldEditor);
58+
59+
userFieldEditor = new StringFieldEditor(ConnectionPreferencesConst.CONN_USERNAME, "Username for all projects: ",
60+
getFieldEditorParent());
61+
addField(userFieldEditor);
62+
63+
}
64+
65+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package org.sofproject.gst.topo.ui.preferences;
2+
3+
public class ConnectionPreferencesConst {
4+
5+
public static final String CONN_ADDR = "connAddress";
6+
public static final String CONN_USERNAME = "connUsername";
7+
8+
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ 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.ui.preferences

org.sofproject.ui/src/org/sofproject/ui/handlers/AudioDevNodeLoginDialog.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
package org.sofproject.ui.handlers;
3131

32+
import org.eclipse.core.runtime.Platform;
3233
import org.eclipse.jface.dialogs.TrayDialog;
3334
import org.eclipse.swt.SWT;
3435
import org.eclipse.swt.layout.GridData;
@@ -38,6 +39,7 @@
3839
import org.eclipse.swt.widgets.Label;
3940
import org.eclipse.swt.widgets.Shell;
4041
import org.eclipse.swt.widgets.Text;
42+
import org.sofproject.gst.topo.ui.preferences.ConnectionPreferencesConst;
4143

4244
public class AudioDevNodeLoginDialog extends TrayDialog {
4345

@@ -89,13 +91,14 @@ protected Control createDialogArea(Composite parent) {
8991
data.grabExcessHorizontalSpace = true;
9092
loginField = new Text(loginGroup, SWT.BORDER);
9193
loginField.setLayoutData(data);
94+
loginField.setText(Platform.getPreferencesService().getString("org.sofproject.gst.topo.ui.preferences",
95+
ConnectionPreferencesConst.CONN_USERNAME, "", null));
9296

9397
new Label(loginGroup, SWT.NONE).setText("Password");
9498
data = new GridData(GridData.FILL_HORIZONTAL);
9599
data.grabExcessHorizontalSpace = true;
96100
passField = new Text(loginGroup, SWT.PASSWORD | SWT.BORDER);
97101
passField.setLayoutData(data);
98-
99102
loginField.setFocus();
100103

101104
return container;

org.sofproject.ui/src/org/sofproject/ui/wizards/NewAudioDevNodeCreationPage.java

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

3030
package org.sofproject.ui.wizards;
3131

32+
import org.eclipse.core.runtime.Platform;
3233
import org.eclipse.jface.viewers.IStructuredSelection;
3334
import org.eclipse.swt.SWT;
3435
import org.eclipse.swt.layout.GridData;
@@ -39,6 +40,7 @@
3940
import org.eclipse.swt.widgets.Text;
4041
import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
4142
import org.sofproject.core.AudioDevNodeProject;
43+
import org.sofproject.gst.topo.ui.preferences.ConnectionPreferencesConst;
4244

4345
public class NewAudioDevNodeCreationPage extends WizardNewProjectCreationPage {
4446

@@ -75,6 +77,8 @@ public void createControl(Composite parent) {
7577
addr = new Text(addrGroup, SWT.BORDER);
7678
addr.setLayoutData(data);
7779
addr.addListener(SWT.Modify, confModifyListener);
80+
addr.setText(Platform.getPreferencesService().getString("org.sofproject.gst.topo.ui.preferences",
81+
ConnectionPreferencesConst.CONN_ADDR, "", null));
7882
}
7983

8084
@Override

0 commit comments

Comments
 (0)