Eclipse Spring preferences re-organization

This commit is contained in:
aboyko
2023-02-13 12:27:22 -05:00
parent 11e6a31ef3
commit fbbb6fbcfd
23 changed files with 203 additions and 460 deletions

View File

@@ -234,18 +234,12 @@
</extension>
<extension point="org.eclipse.ui.preferencePages">
<page
category="org.springsource.ide.eclipse.commons.preferencePage"
class="org.springframework.ide.eclipse.boot.dash.ngrok.NGROKInstallPreferencePage"
id="org.springframework.ide.eclipse.boot.dash.ngrok.NGROKInstallPreferencePage"
name="ngrok">
</page>
<page
category="org.springframework.ide.eclipse.boot.ui.preferences.BootPreferencePage"
category="org.springsource.ide.eclipse.commons.preferencePage"
class="org.springframework.ide.eclipse.boot.dash.prefs.BootDashPrefsPage"
id="org.springframework.ide.eclipse.boot.dash.prefs.BootDashPrefsPage"
name="Boot Dash">
name="Boot Dashboard">
</page>
</extension>

View File

@@ -1,155 +0,0 @@
/*******************************************************************************
* Copyright (c) 2015 Pivotal Software, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Pivotal Software, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.eclipse.boot.dash.ngrok;
import java.util.LinkedHashSet;
import java.util.Set;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.springframework.ide.eclipse.boot.core.BootActivator;
import org.springframework.ide.eclipse.boot.util.SWTFactory;
import org.springsource.ide.eclipse.commons.frameworks.core.ExceptionUtil;
/**
* @author Christian Dupuis
* @author Steffen Pingel
* @author Kris De Volder
*/
public class NGROKInstallPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
private static final String NGROK_DIALOGSETTINGS = "org.springframework.ide.eclipse.boot.dash.ngrok.dialogsettings";
private NGROKInstallBlock ngrokBlock;
private NGROKInstallManager installManager;
public NGROKInstallPreferencePage() {
super("ngrok installation");
}
public void init(IWorkbench workbench) {
try {
installManager = NGROKInstallManager.getInstance();
} catch (Exception e) {
throw ExceptionUtil.unchecked(e);
}
}
@Override
public boolean isValid() {
// if (super.isValid()) {
// if (getCurrentDefaultVM() == null && fJREBlock.getJREs().length > 0) {
// setErrorMessage("Select a default Boot installation");
// return false;
// }
// }
return true;
}
private String getCurrentDefaultNGROK() {
return ngrokBlock.getCheckedNGROK();
}
@Override
public boolean performOk() {
final boolean[] canceled = new boolean[] { false };
BusyIndicator.showWhile(null, new Runnable() {
public void run() {
Set<String> newInstalls = new LinkedHashSet<String>();
String defaultNgrok = getCurrentDefaultNGROK();
String[] ngroks = ngrokBlock.getNGROKs();
for (String ngrok : ngroks) {
try {
newInstalls.add(ngrok);
} catch (Exception e) {
BootActivator.log(e);
}
}
installManager.setDefaultInstall(defaultNgrok);
installManager.setInstalls(newInstalls);
installManager.save();
}
});
if (canceled[0]) {
return false;
}
// save column widths
IDialogSettings settings = BootActivator.getDefault().getDialogSettings();
ngrokBlock.saveColumnSettings(settings, NGROK_DIALOGSETTINGS);
return super.performOk();
}
@Override
protected Control createContents(Composite ancestor) {
initializeDialogUnits(ancestor);
noDefaultAndApplyButton();
GridLayout layout = new GridLayout();
layout.numColumns = 1;
layout.marginHeight = 0;
layout.marginWidth = 0;
ancestor.setLayout(layout);
SWTFactory
.createWrapLabel(
ancestor,
"Add, edit or remove ngrok installations. By default the checked ngrok installation will be used to expose apps",
1, 300);
SWTFactory.createVerticalSpacer(ancestor, 1);
ngrokBlock = new NGROKInstallBlock(installManager);
ngrokBlock.createControl(ancestor);
ngrokBlock.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
isValid();
}
});
Control control = ngrokBlock.getControl();
GridData data = new GridData(GridData.FILL_BOTH);
data.horizontalSpan = 1;
control.setLayoutData(data);
ngrokBlock.restoreColumnSettings(BootActivator.getDefault().getDialogSettings(),
NGROK_DIALOGSETTINGS);
ngrokBlock.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
setValid(false);
String install = getCurrentDefaultNGROK();
if (install == null) {
setErrorMessage("Select a default ngrok installation");
}
else {
setErrorMessage(null);
setValid(true);
}
}
});
applyDialogFont(ancestor);
return ancestor;
}
}

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020, 2022 Pivotal, Inc.
* Copyright (c) 2020, 2023 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,14 +10,19 @@
*******************************************************************************/
package org.springframework.ide.eclipse.boot.dash.prefs;
import static org.springframework.ide.eclipse.boot.core.BootPreferences.PREF_BOOT_PROJECT_EXCLUDE;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.springframework.ide.eclipse.boot.core.BootActivator;
import org.springframework.ide.eclipse.boot.dash.BootDashActivator;
import org.springframework.ide.eclipse.boot.dash.api.RunTargetType;
import org.springframework.ide.eclipse.boot.dash.views.DeleteElementsAction;
import org.springframework.ide.eclipse.boot.ui.preferences.RegExpFieldEditor;
/**
* @author Kris De Volder
@@ -36,7 +41,14 @@ public class BootDashPrefsPage extends FieldEditorPreferencePage implements IWor
@Override
protected void createFieldEditors() {
Composite parent = getFieldEditorParent();
for (RunTargetType rtt : BootDashActivator.getDefault().getModel().getRunTargetTypes()) {
StringFieldEditor projectExclude = new RegExpFieldEditor(PREF_BOOT_PROJECT_EXCLUDE, "Exclude Projects", parent);
setTooltip(parent, projectExclude, "Any project who's name matches this regexp will NOT be treated as a Spring Boot App");
projectExclude.setPreferenceStore(BootActivator.getDefault().getPreferenceStore());
addField(projectExclude);
for (RunTargetType<?> rtt : BootDashActivator.getDefault().getModel().getRunTargetTypes()) {
if (rtt.supportsDeletion()) {
addField(new BooleanFieldEditor(DeleteElementsAction.PREF_SKIP_CONFIRM_DELETE(rtt), "Skip Delete Element Confirmation ("+rtt.getName()+")", parent));
}
@@ -48,10 +60,10 @@ public class BootDashPrefsPage extends FieldEditorPreferencePage implements IWor
// // Do nothing. Page offers one column grid layout. Group controls layout fields appropriately.
// }
// private void setTooltip(Composite parent, StringFieldEditor fe, String tooltip) {
// fe.getLabelControl(parent).setToolTipText(tooltip);
// fe.getTextControl(parent).setToolTipText(tooltip);
// }
private void setTooltip(Composite parent, StringFieldEditor fe, String tooltip) {
fe.getLabelControl(parent).setToolTipText(tooltip);
fe.getTextControl(parent).setToolTipText(tooltip);
}
//
// private void setTooltip(Composite parent, BooleanFieldEditor2 fe, String tooltip) {
// fe.getChangeControl(parent).setToolTipText(tooltip);

View File

@@ -40,10 +40,10 @@
<extension
point="org.eclipse.ui.preferencePages">
<page
name="Java Editor"
category="org.springframework.ide.eclipse.boot.ui.preferences.BootPreferencePage"
class="org.springframework.ide.eclipse.boot.validation.preferences.BootValidationPreferencesPage"
id="org.springframework.ide.eclipse.boot.validation.preferences.BootValidationPreferencesPage">
name="Configuration Processing"
category="org.springframework.tooling.boot.validation"
class="org.springframework.ide.eclipse.boot.validation.preferences.ConfigProcessingPreferencesPage"
id="org.springframework.ide.eclipse.boot.validation.preferences.ConfigurationProcessingPreferencesPage">
</page>
</extension>

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2012,2015 Spring IDE Developers
* Copyright (c) 2012, 2023 Spring IDE Developers
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -30,7 +30,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.springframework.ide.eclipse.boot.core.BootPropertyTester;
import org.springframework.ide.eclipse.boot.validation.BootValidationActivator;
import org.springframework.ide.eclipse.boot.validation.preferences.BootValidationPreferencesPage;
import org.springframework.ide.eclipse.boot.validation.preferences.ConfigProcessingPreferencesPage;
import org.springframework.ide.eclipse.boot.validation.rules.ValidationRuleDefinitions;
import org.springframework.ide.eclipse.editor.support.preferences.EditorType;
import org.springframework.ide.eclipse.editor.support.preferences.PreferencesBasedSeverityProvider;
@@ -112,7 +112,7 @@ public class SpringBootProjectBuilder extends IncrementalProjectBuilder {
}
private IValidationContext validationContext(IResource rsrc, IValidationRule rule) {
SeverityProvider severityProvider = new PreferencesBasedSeverityProvider(BootValidationPreferencesPage.util, rsrc.getProject(), BootValidationActivator.PLUGIN_ID, EditorType.JAVA);
SeverityProvider severityProvider = new PreferencesBasedSeverityProvider(ConfigProcessingPreferencesPage.util, rsrc.getProject(), BootValidationActivator.PLUGIN_ID, EditorType.JAVA);
return (IResource cu, ProblemType problemId, String msg, int offset, int end) -> {
ProblemSeverity severity = severityProvider.getSeverity(problemId);
if (severity==ProblemSeverity.IGNORE) {

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 Pivotal, Inc.
* Copyright (c) 2015, 2023 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -24,7 +24,7 @@ import org.springframework.ide.eclipse.editor.support.reconcile.ProblemType;
public class BootValidationProjectPropertyPage extends AbstractProblemSeverityPreferencesPage {
public BootValidationProjectPropertyPage() {
super(BootValidationPreferencesPage.util);
super(ConfigProcessingPreferencesPage.util);
}
protected List<ProblemType> getProblemTypes() {
@@ -33,7 +33,7 @@ public class BootValidationProjectPropertyPage extends AbstractProblemSeverityPr
@Override
protected String getEnableProjectPreferencesKey() {
return BootValidationPreferencesPage.util.ENABLE_PROJECT_PREFERENCES(EditorType.JAVA);
return ConfigProcessingPreferencesPage.util.ENABLE_PROJECT_PREFERENCES(EditorType.JAVA);
}
@Override

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017 Spring IDE Developers
* Copyright (c) 2017, 2023 Spring IDE Developers
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,7 +12,6 @@ package org.springframework.ide.eclipse.boot.validation.preferences;
import java.util.List;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.springframework.ide.eclipse.boot.validation.BootValidationActivator;
import org.springframework.ide.eclipse.boot.validation.rules.BootValidationProblemType;
import org.springframework.ide.eclipse.editor.support.preferences.AbstractProblemSeverityPreferencesPage;
@@ -23,11 +22,11 @@ import org.springframework.ide.eclipse.editor.support.reconcile.ProblemType;
/**
* @author Kris De Volder
*/
public class BootValidationPreferencesPage extends AbstractProblemSeverityPreferencesPage {
public class ConfigProcessingPreferencesPage extends AbstractProblemSeverityPreferencesPage {
public static final ProblemSeverityPreferencesUtil util = new ProblemSeverityPreferencesUtil("boot.project.validation.builder.");
public BootValidationPreferencesPage() {
public ConfigProcessingPreferencesPage() {
super(util);
}

View File

@@ -47,6 +47,7 @@ Export-Package: org.springframework.ide.eclipse.boot.core,
org.springframework.ide.eclipse.boot.core.initializr,
org.springframework.ide.eclipse.boot.core.internal,
org.springframework.ide.eclipse.boot.ui,
org.springframework.ide.eclipse.boot.ui.preferences,
org.springframework.ide.eclipse.boot.util,
org.springframework.ide.eclipse.boot.util.version
Import-Package: org.apache.commons.lang;version="2.6.0",

View File

@@ -30,25 +30,23 @@
category="org.springsource.ide.eclipse.commons.preferencePage"
class="org.springframework.ide.eclipse.boot.ui.preferences.BootPreferencePage"
id="org.springframework.ide.eclipse.boot.ui.preferences.BootPreferencePage"
name="Boot">
</page>
</extension>
<extension point="org.eclipse.ui.preferencePages">
<page
category="org.springframework.ide.eclipse.boot.ui.preferences.BootPreferencePage"
class="org.springframework.ide.eclipse.boot.ui.preferences.BootInstallPreferencePage"
id="org.springframework.ide.eclipse.boot.ui.preferences.BootInstallPreferencePage"
name="CLI">
name="Boot Launch Support">
</page>
<page
category="org.springframework.ide.eclipse.boot.ui.preferences.BootPreferencePage"
category="org.springsource.ide.eclipse.commons.preferencePage"
class="org.springframework.ide.eclipse.boot.ui.preferences.InitializrPreferencePage"
id="org.springframework.ide.eclipse.boot.ui.preferences.InitializrPreferencePage"
name="Initializr">
name="Initializr Integration - start.spring.io">
</page>
<page
category="org.springframework.ide.eclipse.boot.dash.prefs.BootDashPrefsPage"
class="org.springframework.ide.eclipse.boot.ui.preferences.BootInstallPreferencePage"
id="org.springframework.ide.eclipse.boot.ui.preferences.BootInstallPreferencePage"
name="Boot CLI Integration">
</page>
</extension>
<extension point="org.eclipse.ui.decorators">
<decorator
id="org.springframework.ide.eclipse.boot.ui.DevtoolsProjectDecorator"

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015, 2017 Pivotal, Inc.
* Copyright (c) 2015, 2023 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,10 +10,10 @@
*******************************************************************************/
package org.springframework.ide.eclipse.boot.ui.preferences;
import static org.springframework.ide.eclipse.boot.core.BootPreferences.*;
import static org.springframework.ide.eclipse.boot.core.BootPreferences.PREF_BOOT_FAST_STARTUP_DEFAULT;
import static org.springframework.ide.eclipse.boot.core.BootPreferences.PREF_BOOT_FAST_STARTUP_JVM_ARGS;
import static org.springframework.ide.eclipse.boot.core.BootPreferences.PREF_BOOT_FAST_STARTUP_REMIND_MESSAGE;
import static org.springframework.ide.eclipse.boot.core.BootPreferences.PREF_BOOT_PROJECT_EXCLUDE;
import static org.springframework.ide.eclipse.boot.core.BootPreferences.PREF_BOOT_THIN_WRAPPER;
import static org.springframework.ide.eclipse.boot.core.BootPreferences.PREF_IGNORE_SILENT_EXIT;
import org.eclipse.debug.internal.ui.preferences.BooleanFieldEditor2;
@@ -48,17 +48,8 @@ public class BootPreferencePage extends FieldEditorPreferencePage implements IWo
protected void createFieldEditors() {
Composite parent = getFieldEditorParent();
Group generalGroup = new Group(parent, SWT.NONE);
generalGroup.setText("General");
generalGroup.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
generalGroup.setLayout(GridLayoutFactory.fillDefaults().create());
StringFieldEditor projectExclude = new RegExpFieldEditor(PREF_BOOT_PROJECT_EXCLUDE, "Exclude Projects", generalGroup);
setTooltip(generalGroup, projectExclude, "Any project who's name matches this regexp will NOT be treated as a Spring Boot App");
addField(projectExclude);
BooleanFieldEditor2 ignoreSilentExit = new BooleanFieldEditor2(PREF_IGNORE_SILENT_EXIT, "Ignore Silent Exit", SWT.CHECK, generalGroup);
setTooltip(generalGroup, ignoreSilentExit, "When debugging a Boot App, do not suspend when 'SilentExitException' is raised. "
BooleanFieldEditor2 ignoreSilentExit = new BooleanFieldEditor2(PREF_IGNORE_SILENT_EXIT, "Ignore Silent Exit", SWT.CHECK, parent);
setTooltip(parent, ignoreSilentExit, "When debugging a Boot App, do not suspend when 'SilentExitException' is raised. "
+ "(This exception is raised by spring-boot-devtools as part of its normal operation)");
addField(ignoreSilentExit);

View File

@@ -40,9 +40,9 @@
<extension point="org.eclipse.ui.preferencePages">
<page id="org.springframework.ide.eclipse.beans.ui.namespaces.preferencePage"
name="Namespaces"
name="Namespace Support"
class="org.springframework.ide.eclipse.xml.namespaces.ui.preferences.NamespaceVersionPreferencePage"
category="org.springsource.ide.eclipse.commons.preferencePage">
category="org.springframework.tooling.boot.xml.ls.preferences">
</page>
</extension>