Skip to content

Commit c8c51b6

Browse files
committed
add restart dialog for the users convenience when enabling or disabling the mcp server settings
1 parent 76f6fd9 commit c8c51b6

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

eclipse-language-servers/org.springframework.tooling.boot.ls/src/org/springframework/tooling/boot/ls/prefs/AiConfigPreferencePage.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@
1010
*******************************************************************************/
1111
package org.springframework.tooling.boot.ls.prefs;
1212

13+
import java.util.Objects;
14+
15+
import org.eclipse.jface.dialogs.MessageDialog;
1316
import org.eclipse.jface.preference.BooleanFieldEditor;
1417
import org.eclipse.jface.preference.FieldEditorPreferencePage;
1518
import org.eclipse.jface.preference.StringFieldEditor;
1619
import org.eclipse.jface.util.PropertyChangeEvent;
1720
import org.eclipse.swt.widgets.Composite;
1821
import org.eclipse.ui.IWorkbench;
1922
import org.eclipse.ui.IWorkbenchPreferencePage;
23+
import org.eclipse.ui.PlatformUI;
2024
import org.springframework.tooling.boot.ls.BootLanguageServerPlugin;
2125
import org.springframework.tooling.boot.ls.Constants;
2226

@@ -25,13 +29,21 @@ public class AiConfigPreferencePage extends FieldEditorPreferencePage implements
2529
private BooleanFieldEditor mcpEnabledEditor;
2630
private StringFieldEditor mcpPortEditor;
2731

32+
// Track stored values to detect changes
33+
private boolean storedStateMcpEnabled;
34+
private String storedStateMcpPort;
35+
2836
public AiConfigPreferencePage() {
2937
super(GRID);
3038
}
3139

3240
@Override
3341
public void init(IWorkbench workbench) {
3442
setPreferenceStore(BootLanguageServerPlugin.getDefault().getPreferenceStore());
43+
44+
// Store initial preference values
45+
storedStateMcpEnabled = getPreferenceStore().getBoolean(Constants.PREF_AI_MCP_ENABLED);
46+
storedStateMcpPort = getPreferenceStore().getString(Constants.PREF_AI_MCP_PORT);
3547
}
3648

3749
@Override
@@ -64,5 +76,39 @@ private void updateMcpPortFieldState() {
6476
mcpPortEditor.setEnabled(mcpEnabled, getFieldEditorParent());
6577
}
6678
}
79+
80+
@Override
81+
public boolean performOk() {
82+
boolean result = super.performOk();
83+
84+
if (result) {
85+
// Check if any AI configuration preferences have changed
86+
boolean currentMcpEnabled = getPreferenceStore().getBoolean(Constants.PREF_AI_MCP_ENABLED);
87+
String currentMcpPort = getPreferenceStore().getString(Constants.PREF_AI_MCP_PORT);
88+
89+
boolean hasChanges = (storedStateMcpEnabled != currentMcpEnabled) ||
90+
!Objects.equals(storedStateMcpPort, currentMcpPort);
91+
92+
if (hasChanges) {
93+
showRestartDialog();
94+
}
95+
96+
storedStateMcpEnabled = currentMcpEnabled;
97+
storedStateMcpPort = currentMcpPort;
98+
}
99+
100+
return result;
101+
}
102+
103+
private void showRestartDialog() {
104+
boolean restart = MessageDialog.openQuestion(getShell(),
105+
"Restart Required",
106+
"The AI configuration changes will take effect after restarting the IDE.\n\n" +
107+
"Do you want to restart now?");
108+
109+
if (restart) {
110+
PlatformUI.getWorkbench().restart();
111+
}
112+
}
67113

68114
}

0 commit comments

Comments
 (0)