/
SARLValidatorConfigurationBlock.java
87 lines (78 loc) · 3.23 KB
/
SARLValidatorConfigurationBlock.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
* $Id$
*
* File is automatically generated by the Xtext language generator.
* Do not change it.
*
* SARL is an general-purpose agent programming language.
* More details on http://www.sarl.io
*
* Copyright (C) 2014-2018 the original authors or authors.
*
* 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.validation;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.xtext.ui.preferences.OptionsConfigurationBlock;
import org.eclipse.xtext.validation.SeverityConverter;
import org.eclipse.xtext.xbase.ui.validation.XbaseValidationConfigurationBlock;
@SuppressWarnings("restriction")
public class SARLValidatorConfigurationBlock extends XbaseValidationConfigurationBlock {
@Override
protected void fillSettingsPage(Composite composite, int nColumns, int defaultIndent) {
addComboBox(SARLConfigurableIssueCodesProvider.DEPRECATED_MODEL_PART, "Deprecated Model Part", composite, defaultIndent);
super.fillSettingsPage(composite, nColumns, defaultIndent);
}
@Override
protected Job getBuildJob(IProject project) {
Job buildJob = new OptionsConfigurationBlock.BuildJob("Validation Settings Changed", project);
buildJob.setRule(ResourcesPlugin.getWorkspace().getRuleFactory().buildRule());
buildJob.setUser(true);
return buildJob;
}
@Override
protected String[] getFullBuildDialogStrings(boolean workspaceSettings) {
return new String[] { "Validation Settings Changed",
"Validation settings have changed. A full rebuild is required for changes to take effect. Do the full build now?" };
}
@Override
protected void validateSettings(String changedKey, String oldValue, String newValue) {
super.validateSettings(changedKey, oldValue, newValue);
}
protected Combo addComboBox(String prefKey, String label, Composite parent, int indent) {
String[] values = new String[] { SeverityConverter.SEVERITY_ERROR, SeverityConverter.SEVERITY_WARNING,
SeverityConverter.SEVERITY_INFO, SeverityConverter.SEVERITY_IGNORE };
String[] valueLabels = new String[] { "Error", "Warning", "Info", "Ignore" };
Combo comboBox = addComboBox(parent, label, prefKey, indent, values, valueLabels);
return comboBox;
}
@Override
public void dispose() {
storeSectionExpansionStates(getDialogSettings());
super.dispose();
}
@Override
protected IDialogSettings getDialogSettings() {
IDialogSettings dialogSettings = super.getDialogSettings();
IDialogSettings section = dialogSettings.getSection("SARL");
if (section == null) {
return dialogSettings.addNewSection("SARL");
}
return section;
}
}