Prompt to enable Spring Boot Java source reconciling
This commit is contained in:
@@ -33,6 +33,8 @@ public class Constants {
|
||||
|
||||
public static final String PREF_REWRITE_RECONCILE = "boot-java.rewrite.reconcile";
|
||||
|
||||
public static final String PREF_REWRITE_RECONCILE_PROMPT = "rewrite.reconcile-prompt";
|
||||
|
||||
public static final String PREF_REWRITE_RECIPE_FILTERS = "boot-java.rewrite.recipe-filters";
|
||||
|
||||
public static final String PREF_REWRITE_RECIPES_SCAN_FILES = "boot-java.rewrite.scan-files";
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.Map;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.util.IPropertyChangeListener;
|
||||
import org.eclipse.lsp4e.server.StreamConnectionProvider;
|
||||
@@ -32,6 +33,9 @@ import org.eclipse.lsp4j.InitializeResult;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Message;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.ResponseMessage;
|
||||
import org.eclipse.lsp4j.services.LanguageServer;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.springframework.tooling.boot.ls.prefs.CategoryProblemsSeverityPrefsPage;
|
||||
import org.springframework.tooling.boot.ls.prefs.FileListEditor;
|
||||
import org.springframework.tooling.boot.ls.prefs.ProblemCategoryData;
|
||||
@@ -155,6 +159,25 @@ public class DelegatingStreamConnectionProvider implements StreamConnectionProvi
|
||||
|
||||
//Add remote boot apps listener
|
||||
RemoteBootAppsDataHolder.getDefault().getRemoteApps().addListener(remoteAppsListener);
|
||||
|
||||
IPreferenceStore preferenceStore = BootLanguageServerPlugin.getDefault().getPreferenceStore();
|
||||
|
||||
if (preferenceStore.getBoolean(Constants.PREF_REWRITE_RECONCILE_PROMPT) && !preferenceStore.getBoolean(Constants.PREF_REWRITE_RECONCILE)) {
|
||||
PlatformUI.getWorkbench().getDisplay().asyncExec(() -> {
|
||||
int result = MessageDialog.open(MessageDialog.INFORMATION, Display.getCurrent().getActiveShell(),
|
||||
"Spring Boot Java Reconciling", "Do you wish to enable Spring Boot Java Reconciling?", SWT.NONE, "Yes", "No", "Do not show again");
|
||||
switch (result) {
|
||||
case 0:
|
||||
preferenceStore.setValue(Constants.PREF_REWRITE_RECONCILE, true);
|
||||
break;
|
||||
case 2:
|
||||
preferenceStore.setValue(Constants.PREF_REWRITE_RECONCILE_PROMPT, false);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ public class PrefsInitializer extends AbstractPreferenceInitializer {
|
||||
|
||||
preferenceStore.setDefault(Constants.PREF_SCAN_JAVA_TEST_SOURCES, false);
|
||||
|
||||
preferenceStore.setDefault(Constants.PREF_REWRITE_RECONCILE_PROMPT, true);
|
||||
preferenceStore.setDefault(Constants.PREF_REWRITE_RECONCILE, false);
|
||||
preferenceStore.setDefault(Constants.PREF_REWRITE_PROJECT_REFACTORINGS, true);
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ public class RewritePreferencePage extends FieldEditorPreferencePage implements
|
||||
addField(new BooleanFieldEditor(Constants.PREF_REWRITE_RECONCILE,
|
||||
"Reconciling of Java Sources", fieldEditorParent));
|
||||
|
||||
addField(new BooleanFieldEditor(Constants.PREF_REWRITE_RECONCILE_PROMPT,
|
||||
"Prompt for Reconciling of Java Sources", fieldEditorParent));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,7 +18,11 @@ const JAVA_LANGUAGE_ID = "java";
|
||||
const XML_LANGUAGE_ID = "xml";
|
||||
const FACTORIES_LANGUAGE_ID = "spring-factories";
|
||||
|
||||
const YES = 'Yes';
|
||||
const NO = 'No';
|
||||
const NEVER_SHOW_AGAIN = "Do not show again";
|
||||
const RECONCILING_PREF_KEY = 'boot-java.rewrite.reconcile';
|
||||
const RECONCILING_PROMPT_PREF_KEY = 'vscode-spring-boot.rewrite.reconcile-prompt';
|
||||
|
||||
/** Called when extension is activated */
|
||||
export function activate(context: VSCode.ExtensionContext): Thenable<ExtensionAPI> {
|
||||
@@ -120,7 +124,22 @@ export function activate(context: VSCode.ExtensionContext): Thenable<ExtensionAP
|
||||
context.subscriptions.push(startDebugSupport());
|
||||
|
||||
return commons.activate(options, context).then(client => {
|
||||
VSCode.commands.registerCommand('vscode-spring-boot.ls.start', () => client.start());
|
||||
VSCode.commands.registerCommand('vscode-spring-boot.ls.start', () => client.start().then(() => {
|
||||
if (VSCode.workspace.getConfiguration().get(RECONCILING_PROMPT_PREF_KEY) && !VSCode.workspace.getConfiguration().get(RECONCILING_PREF_KEY)) {
|
||||
VSCode.window.showInformationMessage('Do you wish to enable Spring Boot Java sources reconciling?', YES, NO, NEVER_SHOW_AGAIN).then(answer => {
|
||||
switch (answer) {
|
||||
case YES:
|
||||
VSCode.workspace.getConfiguration().update(RECONCILING_PREF_KEY, true, true);
|
||||
break;
|
||||
case NEVER_SHOW_AGAIN:
|
||||
VSCode.workspace.getConfiguration().update(RECONCILING_PROMPT_PREF_KEY, false, true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
}));
|
||||
VSCode.commands.registerCommand('vscode-spring-boot.ls.stop', () => client.stop());
|
||||
liveHoverUi.activate(client, options, context);
|
||||
rewrite.activate(client, options, context);
|
||||
|
||||
@@ -239,6 +239,11 @@
|
||||
"default": false,
|
||||
"description": "Reconciling Java Sources"
|
||||
},
|
||||
"vscode-spring-boot.rewrite.reconcile-prompt": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Reconciling Java Sources Prompt enabled"
|
||||
},
|
||||
"boot-java.rewrite.recipe-filters": {
|
||||
"type": "array",
|
||||
"default": [
|
||||
|
||||
Reference in New Issue
Block a user