Search in sources :

Example 1 with ICheckCfgPropertySpecification

use of com.avaloq.tools.ddk.checkcfg.ICheckCfgPropertySpecification in project dsl-devkit by dsldevkit.

the class CheckCfgProposalProvider method completeConfiguredParameter_NewValue.

@Override
public // CHECKSTYLE:OFF
void completeConfiguredParameter_NewValue(final EObject model, final Assignment assignment, final ContentAssistContext context, final ICompletionProposalAcceptor acceptor) {
    // CHECKSTYLE:ON
    // TODO filter depending on type of linked parameter
    FormalParameter parameter = ((ConfiguredParameter) model).getParameter();
    ICheckCfgPropertySpecification propertySpecification = null;
    String[] validValues = null;
    if (parameter != null) {
        propertySpecification = CheckCfgUtil.getPropertySpecification(parameter.getName());
        if (propertySpecification != null) {
            validValues = propertySpecification.getExpectedValues();
        }
    }
    if (validValues != null && validValues.length > 0) {
        String info = propertySpecification.getInfo();
        for (String validValue : validValues) {
            ICompletionProposal proposal = createCompletionProposal(String.format("\"%s\"", validValue), new StyledString(validValue), getImage(model), 0, context.getPrefix(), context);
            if (proposal instanceof ConfigurableCompletionProposal) {
                ((ConfigurableCompletionProposal) proposal).setAdditionalProposalInfo(info);
            }
            acceptor.accept(proposal);
        }
        return;
    }
    super.completeConfiguredParameter_NewValue(model, assignment, context, acceptor);
}
Also used : FormalParameter(com.avaloq.tools.ddk.check.check.FormalParameter) ConfiguredParameter(com.avaloq.tools.ddk.checkcfg.checkcfg.ConfiguredParameter) ConfigurableCompletionProposal(org.eclipse.xtext.ui.editor.contentassist.ConfigurableCompletionProposal) ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString) ICheckCfgPropertySpecification(com.avaloq.tools.ddk.checkcfg.ICheckCfgPropertySpecification)

Aggregations

FormalParameter (com.avaloq.tools.ddk.check.check.FormalParameter)1 ICheckCfgPropertySpecification (com.avaloq.tools.ddk.checkcfg.ICheckCfgPropertySpecification)1 ConfiguredParameter (com.avaloq.tools.ddk.checkcfg.checkcfg.ConfiguredParameter)1 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)1 StyledString (org.eclipse.jface.viewers.StyledString)1 ConfigurableCompletionProposal (org.eclipse.xtext.ui.editor.contentassist.ConfigurableCompletionProposal)1