28
28
import com .intellij .ui .components .JBScrollPane ;
29
29
import com .intellij .util .ui .JBUI ;
30
30
import org .jetbrains .annotations .Nullable ;
31
+ import spp .protocol .platform .general .Service ;
31
32
32
33
import javax .swing .*;
33
34
import java .awt .*;
34
35
import java .util .*;
36
+ import java .util .List ;
35
37
import java .util .stream .Collectors ;
36
38
37
39
import static spp .jetbrains .sourcemarker .PluginBundle .message ;
38
- import static spp .protocol .SourceServices .Instance .INSTANCE ;
39
40
40
41
public class PluginConfigurationPanel {
41
42
private JPanel myWholePanel ;
@@ -60,25 +61,19 @@ public class PluginConfigurationPanel {
60
61
private SourceMarkerConfig config ;
61
62
private CertificatePinPanel myCertificatePins ;
62
63
63
- public PluginConfigurationPanel (SourceMarkerConfig config ) {
64
+ public PluginConfigurationPanel (SourceMarkerConfig config , List < Service > availableServices ) {
64
65
this .config = config ;
65
66
myServiceSettingsPanel .setBorder (IdeBorderFactory .createTitledBorder (message ("service_settings" )));
66
67
myGlobalSettingsPanel .setBorder (IdeBorderFactory .createTitledBorder (message ("plugin_settings" )));
67
68
myPortalSettingsPanel .setBorder (IdeBorderFactory .createTitledBorder (message ("portal_settings" )));
68
69
portalZoomSpinner .setModel (new SpinnerNumberModel (1.0 , 0.5 , 2.0 , 0.1 ));
69
70
70
- if (INSTANCE .getLiveService () != null ) {
71
- INSTANCE .getLiveService ().getServices ().onComplete (it -> {
72
- if (it .succeeded ()) {
73
- it .result ().forEach (service -> serviceComboBox .addItem (service .getName ()));
74
-
75
- if (config .getServiceName () != null ) {
76
- serviceComboBox .setSelectedItem (config .getServiceName ());
77
- }
78
- } else {
79
- it .cause ().printStackTrace ();
80
- }
81
- });
71
+ availableServices .forEach (service -> serviceComboBox .addItem (service .getName ()));
72
+ if (config .getServiceName () != null ) {
73
+ if (availableServices .stream ().noneMatch (service -> service .getName ().equals (config .getServiceName ()))) {
74
+ serviceComboBox .addItem (config .getServiceName ());
75
+ }
76
+ serviceComboBox .setSelectedItem (config .getServiceName ());
82
77
}
83
78
84
79
//todo: shouldn't need to manually update locale text
@@ -110,7 +105,10 @@ public JComponent getContentPane() {
110
105
boolean isModified () {
111
106
if (config .getOverride ()) return false ;
112
107
113
- if (!Arrays .equals (Arrays .stream (rootSourcePackageTextField .getText ().split ("," )).filter (s -> !s .isEmpty ()).toArray (), config .getRootSourcePackages ().toArray ())) {
108
+ if (!Arrays .equals (
109
+ Arrays .stream (rootSourcePackageTextField .getText ().split ("," )).filter (s -> !s .isEmpty ()).toArray (),
110
+ config .getRootSourcePackages ().stream ().filter (s -> !s .isEmpty ()).toArray ())
111
+ ) {
114
112
return true ;
115
113
}
116
114
if (!Objects .equals (autoResolveEndpointNamesCheckBox .isSelected (), config .getAutoResolveEndpointNames ())) {
0 commit comments