use of net.sf.eclipsecs.core.config.ResolvableProperty in project eclipse-cs by checkstyle.
the class CheckConfigurationPropertiesDialog method okPressed.
/**
* @see org.eclipse.jface.dialogs.Dialog#okPressed()
*/
@Override
protected void okPressed() {
try {
// Check if the configuration is valid
mCheckConfig = mConfigurationEditor.getEditedWorkingCopy();
CheckConfigurationTester tester = new CheckConfigurationTester(mCheckConfig);
List<ResolvableProperty> unresolvedProps = tester.getUnresolvedProperties();
if (!unresolvedProps.isEmpty()) {
MessageDialog dialog = new MessageDialog(getShell(), Messages.CheckConfigurationPropertiesDialog_titleUnresolvedProps, null, NLS.bind(Messages.CheckConfigurationPropertiesDialog_msgUnresolvedProps, // $NON-NLS-1$
"" + unresolvedProps.size()), MessageDialog.WARNING, new String[] { Messages.CheckConfigurationPropertiesDialog_btnEditProps, Messages.CheckConfigurationPropertiesDialog_btnContinue, Messages.CheckConfigurationPropertiesDialog_btnCancel }, 0);
int result = dialog.open();
if (0 == result) {
ResolvablePropertiesDialog propsDialog = new ResolvablePropertiesDialog(getShell(), mCheckConfig);
propsDialog.open();
return;
} else if (1 == result) {
super.okPressed();
} else if (2 == result) {
return;
}
} else {
super.okPressed();
}
} catch (CheckstylePluginException e) {
CheckstyleLog.log(e);
this.setErrorMessage(e.getLocalizedMessage());
}
}
use of net.sf.eclipsecs.core.config.ResolvableProperty in project eclipse-cs by checkstyle.
the class ResolvablePropertiesDialog method okPressed.
/**
* {@inheritDoc}
*/
@Override
protected void okPressed() {
// OK'ing
for (ResolvableProperty prop : mResolvableProperties) {
if (Strings.emptyToNull(prop.getValue()) == null) {
this.setErrorMessage(NLS.bind(Messages.ResolvablePropertiesDialog_msgMissingPropertyValue, prop.getPropertyName()));
return;
}
}
mCheckConfig.getResolvableProperties().clear();
mCheckConfig.getResolvableProperties().addAll(mResolvableProperties);
super.okPressed();
}
use of net.sf.eclipsecs.core.config.ResolvableProperty in project eclipse-cs by checkstyle.
the class ResolvablePropertiesDialog method initialize.
/**
* Initialize the dialogs controls with the data.
*/
private void initialize() {
// clone the properties so that changes don't directly reflect back into
// the configuration
mResolvableProperties = new ArrayList<>();
for (ResolvableProperty prop : mCheckConfig.getResolvableProperties()) {
mResolvableProperties.add(prop.clone());
}
mTableViewer.setInput(mResolvableProperties);
}
use of net.sf.eclipsecs.core.config.ResolvableProperty in project eclipse-cs by checkstyle.
the class ProjectConfigurationFactory method getLocalCheckConfigs.
@SuppressWarnings("unchecked")
private static List<ICheckConfiguration> getLocalCheckConfigs(Element root, IProject project) {
List<ICheckConfiguration> configurations = new ArrayList<>();
List<Element> configElements = root.elements(XMLTags.CHECK_CONFIG_TAG);
for (Element configEl : configElements) {
final String name = configEl.attributeValue(XMLTags.NAME_TAG);
final String description = configEl.attributeValue(XMLTags.DESCRIPTION_TAG);
String location = configEl.attributeValue(XMLTags.LOCATION_TAG);
String type = configEl.attributeValue(XMLTags.TYPE_TAG);
IConfigurationType configType = ConfigurationTypes.getByInternalName(type);
if (configType instanceof ProjectConfigurationType) {
// RFE 1420212
// treat config files relative to *THIS* project
IWorkspaceRoot workspaceRoot = project.getWorkspace().getRoot();
// test if the location contains the project name
if (workspaceRoot.findMember(location) == null) {
location = project.getFullPath().append(location).toString();
}
}
// get resolvable properties
List<ResolvableProperty> props = new ArrayList<>();
List<Element> propertiesElements = configEl.elements(XMLTags.PROPERTY_TAG);
for (Element propsEl : propertiesElements) {
ResolvableProperty prop = new ResolvableProperty(propsEl.attributeValue(XMLTags.NAME_TAG), propsEl.attributeValue(XMLTags.VALUE_TAG));
props.add(prop);
}
// get additional data
Map<String, String> additionalData = new HashMap<>();
List<Element> dataElements = configEl.elements(XMLTags.ADDITIONAL_DATA_TAG);
for (Element dataEl : dataElements) {
additionalData.put(dataEl.attributeValue(XMLTags.NAME_TAG), dataEl.attributeValue(XMLTags.VALUE_TAG));
}
ICheckConfiguration checkConfig = new CheckConfiguration(name, location, description, configType, false, props, additionalData);
configurations.add(checkConfig);
}
return configurations;
}
use of net.sf.eclipsecs.core.config.ResolvableProperty in project eclipse-cs by checkstyle.
the class ResolvablePropertyResolver method resolve.
@Override
public String resolve(String aName) {
String value = null;
List<ResolvableProperty> resolvableProperties = mCheckConfiguration.getResolvableProperties();
for (ResolvableProperty prop : resolvableProperties) {
if (aName.equals(prop.getPropertyName())) {
value = prop.getValue();
break;
}
}
return value;
}
Aggregations