Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[eclipse] Add the preference page for the "errors/warnings" of SARL.
see #125 Signed-off-by: Stéphane Galland <galland@arakhne.org>
- Loading branch information
1 parent
42a87aa
commit b99d673
Showing
7 changed files
with
325 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
plugins/io.sarl.lang.ui/src/io/sarl/lang/ui/preferences/Messages.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* $Id$ | ||
* | ||
* SARL is an general-purpose agent programming language. | ||
* More details on http://www.sarl.io | ||
* | ||
* Copyright (C) 2014 Sebastian RODRIGUEZ, Nicolas GAUD, Stéphane GALLAND. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.sarl.lang.ui.preferences; | ||
|
||
import org.eclipse.osgi.util.NLS; | ||
|
||
/** Localized Messages. | ||
* @author $Author: sgalland$ | ||
* @version $FullVersion$ | ||
* @mavengroupid $GroupId$ | ||
* @mavenartifactid $ArtifactId$ | ||
*/ | ||
@SuppressWarnings("all") | ||
public class Messages extends NLS { | ||
private static final String BUNDLE_NAME = "io.sarl.lang.ui.preferences.messages"; //$NON-NLS-1$ | ||
static { | ||
// initialize resource bundle | ||
NLS.initializeMessages(BUNDLE_NAME, Messages.class); | ||
} | ||
|
||
private Messages() { | ||
} | ||
|
||
public static String SARLValidatorConfigurationBlock_0; | ||
public static String SARLValidatorConfigurationBlock_1; | ||
public static String SARLValidatorConfigurationBlock_2; | ||
public static String SARLValidatorConfigurationBlock_3; | ||
public static String SARLValidatorConfigurationBlock_4; | ||
public static String SARLValidatorConfigurationBlock_5; | ||
public static String SARLValidatorConfigurationBlock_6; | ||
public static String SARLValidatorConfigurationBlock_7; | ||
public static String SARLValidatorConfigurationBlock_8; | ||
public static String SARLValidatorConfigurationBlock_9; | ||
} |
81 changes: 81 additions & 0 deletions
81
plugins/io.sarl.lang.ui/src/io/sarl/lang/ui/preferences/SARLPreferenceStoreInitializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* $Id$ | ||
* | ||
* SARL is an general-purpose agent programming language. | ||
* More details on http://www.sarl.io | ||
* | ||
* Copyright (C) 2014 Sebastian RODRIGUEZ, Nicolas GAUD, Stéphane GALLAND. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.sarl.lang.ui.preferences; | ||
|
||
import org.eclipse.jface.preference.IPreferenceStore; | ||
import org.eclipse.jface.util.IPropertyChangeListener; | ||
import org.eclipse.jface.util.PropertyChangeEvent; | ||
import org.eclipse.xtext.preferences.PreferenceKey; | ||
import org.eclipse.xtext.ui.editor.preferences.IPreferenceStoreAccess; | ||
import org.eclipse.xtext.ui.editor.preferences.IPreferenceStoreInitializer; | ||
import org.eclipse.xtext.ui.editor.preferences.PreferenceConstants; | ||
import org.eclipse.xtext.validation.ConfigurableIssueCodesProvider; | ||
|
||
import com.google.inject.Inject; | ||
import com.google.inject.Singleton; | ||
|
||
/** Initialize the preference store with SARL specific information. | ||
* | ||
* @author $Author: sgalland$ | ||
* @version $FullVersion$ | ||
* @mavengroupid $GroupId$ | ||
* @mavenartifactid $ArtifactId$ | ||
*/ | ||
@Singleton | ||
public class SARLPreferenceStoreInitializer implements IPreferenceStoreInitializer, IPropertyChangeListener { | ||
|
||
private IPreferenceStoreAccess preferenceStoreAccess; | ||
|
||
@Inject | ||
private ConfigurableIssueCodesProvider issueCodes; | ||
|
||
@Override | ||
public void initialize(IPreferenceStoreAccess preferenceStoreAccess) { | ||
this.preferenceStoreAccess = preferenceStoreAccess; | ||
setupIssueCodesDefaults(preferenceStoreAccess); | ||
|
||
IPreferenceStore preferenceStore = org.eclipse.jdt.ui.PreferenceConstants.getPreferenceStore(); | ||
preferenceStore.addPropertyChangeListener(this); | ||
preferenceStoreAccess.getWritablePreferenceStore().setDefault( | ||
PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION, | ||
preferenceStore.getBoolean(org.eclipse.jdt.ui.PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION)); | ||
|
||
} | ||
|
||
private void setupIssueCodesDefaults(IPreferenceStoreAccess preferenceStoreAccess) { | ||
for (PreferenceKey prefKey : this.issueCodes.getConfigurableIssueCodes().values()) { | ||
preferenceStoreAccess.getWritablePreferenceStore().setDefault(prefKey.getId(), prefKey.getDefaultValue()); | ||
} | ||
} | ||
|
||
@Override | ||
public void propertyChange(PropertyChangeEvent event) { | ||
if (this.preferenceStoreAccess == null) { | ||
return; | ||
} | ||
if (org.eclipse.jdt.ui.PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION.equalsIgnoreCase(event.getProperty())) { | ||
this.preferenceStoreAccess.getWritablePreferenceStore().setValue(PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION, | ||
Boolean.valueOf(event.getNewValue().toString())); | ||
} | ||
|
||
} | ||
|
||
} |
114 changes: 114 additions & 0 deletions
114
plugins/io.sarl.lang.ui/src/io/sarl/lang/ui/preferences/SARLValidatorConfigurationBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/* | ||
* $Id$ | ||
* | ||
* SARL is an general-purpose agent programming language. | ||
* More details on http://www.sarl.io | ||
* | ||
* Copyright (C) 2014 Sebastian RODRIGUEZ, Nicolas GAUD, Stéphane GALLAND. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.sarl.lang.ui.preferences; | ||
|
||
import io.sarl.lang.validation.IssueCodes; | ||
|
||
import org.eclipse.jface.dialogs.IDialogSettings; | ||
import org.eclipse.swt.SWT; | ||
import org.eclipse.swt.layout.GridData; | ||
import org.eclipse.swt.layout.GridLayout; | ||
import org.eclipse.swt.widgets.Composite; | ||
import org.eclipse.swt.widgets.Label; | ||
import org.eclipse.xtext.validation.SeverityConverter; | ||
import org.eclipse.xtext.xbase.ui.validation.XbaseValidationConfigurationBlock; | ||
|
||
/** Preference page that permits to configure the SARL validator. | ||
* | ||
* @author $Author: sgalland$ | ||
* @version $FullVersion$ | ||
* @mavengroupid $GroupId$ | ||
* @mavenartifactid $ArtifactId$ | ||
*/ | ||
public class SARLValidatorConfigurationBlock extends XbaseValidationConfigurationBlock { | ||
|
||
private static final String SECTION_NAME = SARLValidatorConfigurationBlock.class.getName(); | ||
|
||
@Override | ||
public void dispose() { | ||
storeSectionExpansionStates(getDialogSettings()); | ||
super.dispose(); | ||
} | ||
|
||
@Override | ||
protected IDialogSettings getDialogSettings() { | ||
IDialogSettings dialogSettings = super.getDialogSettings(); | ||
IDialogSettings section = dialogSettings.getSection(SECTION_NAME); | ||
if (section == null) { | ||
return dialogSettings.addNewSection(SECTION_NAME); | ||
} | ||
return section; | ||
} | ||
|
||
@Override | ||
protected void addAdditionalComponentsToSettingsPage(Composite settingsPage, int nColumns, int defaultIndent) { | ||
super.addAdditionalComponentsToSettingsPage(settingsPage, nColumns, defaultIndent); | ||
createHorizontalLine(settingsPage, nColumns); | ||
String[] values = new String[] { | ||
SeverityConverter.SEVERITY_ERROR, | ||
SeverityConverter.SEVERITY_WARNING, | ||
SeverityConverter.SEVERITY_IGNORE, | ||
}; | ||
String[] valueLabels = new String[] { | ||
Messages.SARLValidatorConfigurationBlock_6, | ||
Messages.SARLValidatorConfigurationBlock_7, | ||
Messages.SARLValidatorConfigurationBlock_8, | ||
}; | ||
Composite composite = new Composite(settingsPage, SWT.NONE); | ||
GridLayout layout = new GridLayout(nColumns, false); | ||
layout.marginHeight = 0; | ||
composite.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, nColumns, 1)); | ||
composite.setLayout(layout); | ||
addComboBox(composite, | ||
Messages.SARLValidatorConfigurationBlock_9, | ||
org.eclipse.xtext.xbase.validation.IssueCodes.COPY_JAVA_PROBLEMS, | ||
defaultIndent, values, valueLabels); | ||
} | ||
|
||
private static void createHorizontalLine(Composite settingsPage, int nColumns) { | ||
Label horizontalLine = new Label(settingsPage, SWT.SEPARATOR | SWT.HORIZONTAL); | ||
horizontalLine.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, nColumns, 1)); | ||
horizontalLine.setFont(settingsPage.getFont()); | ||
} | ||
|
||
@Override | ||
protected void fillCodingStyleSection(ComboBoxBuilder builder) { | ||
super.fillCodingStyleSection(builder); | ||
builder.addComboBox(IssueCodes.REDUNDANT_INTERFACE_IMPLEMENTATION, Messages.SARLValidatorConfigurationBlock_0); | ||
builder.addComboBox(IssueCodes.WRONG_PACKAGE, Messages.SARLValidatorConfigurationBlock_1); | ||
} | ||
|
||
@Override | ||
protected void fillPotentialProgrammingProblemsSection(ComboBoxBuilder builder) { | ||
super.fillPotentialProgrammingProblemsSection(builder); | ||
builder.addComboBox(org.eclipse.xtext.xbase.validation.IssueCodes.VARIABLE_NAME_SHADOWING, | ||
Messages.SARLValidatorConfigurationBlock_2); | ||
builder.addComboBox(IssueCodes.DISCOURAGED_BOOLEAN_EXPRESSION, Messages.SARLValidatorConfigurationBlock_3); | ||
} | ||
|
||
@Override | ||
protected void fillUnusedCodeSection(ComboBoxBuilder builder) { | ||
super.fillUnusedCodeSection(builder); | ||
builder.addComboBox(IssueCodes.DISCOURAGED_CAPACITY_DEFINITION, Messages.SARLValidatorConfigurationBlock_4); | ||
builder.addComboBox(IssueCodes.UNREACHABLE_BEHAVIOR_UNIT, Messages.SARLValidatorConfigurationBlock_5); | ||
} | ||
|
||
} |
Oops, something went wrong.