2828import com .intellij .ui .components .JBScrollPane ;
2929import com .intellij .util .ui .JBUI ;
3030import org .jetbrains .annotations .Nullable ;
31+ import spp .protocol .platform .general .Service ;
3132
3233import javax .swing .*;
3334import java .awt .*;
3435import java .util .*;
36+ import java .util .List ;
3537import java .util .stream .Collectors ;
3638
3739import static spp .jetbrains .sourcemarker .PluginBundle .message ;
38- import static spp .protocol .SourceServices .Instance .INSTANCE ;
3940
4041public class PluginConfigurationPanel {
4142 private JPanel myWholePanel ;
@@ -60,25 +61,19 @@ public class PluginConfigurationPanel {
6061 private SourceMarkerConfig config ;
6162 private CertificatePinPanel myCertificatePins ;
6263
63- public PluginConfigurationPanel (SourceMarkerConfig config ) {
64+ public PluginConfigurationPanel (SourceMarkerConfig config , List < Service > availableServices ) {
6465 this .config = config ;
6566 myServiceSettingsPanel .setBorder (IdeBorderFactory .createTitledBorder (message ("service_settings" )));
6667 myGlobalSettingsPanel .setBorder (IdeBorderFactory .createTitledBorder (message ("plugin_settings" )));
6768 myPortalSettingsPanel .setBorder (IdeBorderFactory .createTitledBorder (message ("portal_settings" )));
6869 portalZoomSpinner .setModel (new SpinnerNumberModel (1.0 , 0.5 , 2.0 , 0.1 ));
6970
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 ());
8277 }
8378
8479 //todo: shouldn't need to manually update locale text
@@ -110,7 +105,10 @@ public JComponent getContentPane() {
110105 boolean isModified () {
111106 if (config .getOverride ()) return false ;
112107
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+ ) {
114112 return true ;
115113 }
116114 if (!Objects .equals (autoResolveEndpointNamesCheckBox .isSelected (), config .getAutoResolveEndpointNames ())) {
0 commit comments