use of org.eclipse.jface.text.templates.Template in project titan.EclipsePlug-ins by eclipse.
the class PortTypeBody method addGetreplyProposals.
/**
* Adds the "getreply" related operations of port types, to the completion
* list.
*
* @param propCollector the proposal collector
* @param i index, not used
*/
public static void addGetreplyProposals(final ProposalCollector propCollector, final int i) {
propCollector.addProposal("getreply", "getreply", ImageCache.getImage("port.gif"), "");
propCollector.addTemplateProposal("getreply", new Template("getreply from myPartner", "from clause", propCollector.getContextIdentifier(), "getreply from ${myPartner};", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
propCollector.addTemplateProposal("getreply", new Template("getreply( templateInstance ) -> value myReturnValue param(parameters) sender mySenderVar", "value, parameters and sender clause", propCollector.getContextIdentifier(), "getreply( ${templateInstance} ) -> value ${myReturnValue} param( ${parameters} ) sender ${mySenderVar};", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
}
use of org.eclipse.jface.text.templates.Template in project titan.EclipsePlug-ins by eclipse.
the class PortTypeBody method addCheckProposals.
/**
* Adds the "check" related operations of port types, to the completion
* list.
*
* @param propCollector the proposal collector
* @param i index, not used
*/
public static void addCheckProposals(final ProposalCollector propCollector, final int i) {
propCollector.addProposal("check", "check", ImageCache.getImage("port.gif"), "");
propCollector.addTemplateProposal("check", new Template("check( portOperation )", "", propCollector.getContextIdentifier(), "check( ${portOperation} );", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
propCollector.addTemplateProposal("check", new Template("check( from myPeer)", "form clause", propCollector.getContextIdentifier(), "check( from ${myPeer});", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
propCollector.addTemplateProposal("check", new Template("check( from myPeer -> value myVar)", "form and value clause", propCollector.getContextIdentifier(), "check( from ${myPeer} -> value ${myVar});", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
propCollector.addTemplateProposal("check", new Template("check( -> value myVar)", "value clause", propCollector.getContextIdentifier(), "check( -> value ${myVar} );", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
propCollector.addTemplateProposal("check", new Template("check( -> value myVar sender myPeer)", "value and sender clause", propCollector.getContextIdentifier(), "check( -> value ${myVar} sender ${myPeer} );", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
}
use of org.eclipse.jface.text.templates.Template in project titan.EclipsePlug-ins by eclipse.
the class Testcase_Type method addProposal.
@Override
public /**
* {@inheritDoc}
*/
void addProposal(final ProposalCollector propCollector, final int i) {
final List<ISubReference> subrefs = propCollector.getReference().getSubreferences();
if (subrefs.size() != i + 1 || Subreference_type.arraySubReference.equals(subrefs.get(i).getReferenceType())) {
return;
}
propCollector.addTemplateProposal("apply", new Template("apply( parameters )", "", propCollector.getContextIdentifier(), "apply( ${parameters} )", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
}
use of org.eclipse.jface.text.templates.Template in project dsl-devkit by dsldevkit.
the class CheckCfgTemplateProposalProvider method createTemplates.
@Override
protected void createTemplates(final TemplateContext templateContext, final ContentAssistContext context, final ITemplateAcceptor acceptor) {
if (templateContext.getContextType().getId().equals("com.avaloq.tools.ddk.checkcfg.CheckCfg.ConfiguredCheck")) {
// $NON-NLS-1$
addConfiguredCheckTemplates(templateContext, context, acceptor);
return;
} else if (templateContext.getContextType().getId().equals("com.avaloq.tools.ddk.checkcfg.CheckCfg.kw_catalog")) {
// $NON-NLS-1$
addCatalogConfigurations(templateContext, context, acceptor);
}
TemplateContextType contextType = templateContext.getContextType();
Template[] templates = templateStore.getTemplates(contextType.getId());
for (Template template : templates) {
if (!acceptor.canAcceptMoreTemplates()) {
return;
}
if (validate(template, templateContext)) {
acceptor.accept(createProposal(template, templateContext, context, getImage(template), getRelevance(template)));
}
}
}
use of org.eclipse.jface.text.templates.Template in project dsl-devkit by dsldevkit.
the class CheckCfgTemplateProposalProvider method addCatalogConfigurations.
/**
* Adds the populated check configuration.
*
* @param templateContext
* the template context
* @param context
* the context
* @param acceptor
* the acceptor
*/
@SuppressWarnings("all")
private void addCatalogConfigurations(final TemplateContext templateContext, final ContentAssistContext context, final ITemplateAcceptor acceptor) {
// $NON-NLS-1$
final String templateName = "Add all registered catalogs";
// $NON-NLS-1$
final String templateDescription = "configures all missing catalogs";
final String contextTypeId = templateContext.getContextType().getId();
if (context.getRootModel() instanceof CheckConfiguration) {
final CheckConfiguration conf = (CheckConfiguration) context.getRootModel();
List<IEObjectDescription> allElements = Lists.newArrayList(scopeProvider.getScope(conf, CheckcfgPackage.Literals.CONFIGURED_CATALOG__CATALOG).getAllElements());
StringBuilder builder = new StringBuilder();
for (IEObjectDescription description : allElements) {
if (description.getEObjectOrProxy() instanceof CheckCatalog) {
CheckCatalog catalog = (CheckCatalog) description.getEObjectOrProxy();
if (catalog.eIsProxy()) {
catalog = (CheckCatalog) EcoreUtil.resolve(catalog, conf);
}
if (isCatalogConfigured(conf, catalog)) {
continue;
} else if (allElements.indexOf(description) > 0) {
builder.append(Strings.newLine());
}
final String catalogName = qualifiedNameValueConverter.toString(description.getQualifiedName().toString());
// $NON-NLS-1$ //$NON-NLS-2$
builder.append("catalog ").append(catalogName).append(" {}").append(Strings.newLine());
}
}
if (builder.length() > 0) {
// $NON-NLS-1$
builder.append("${cursor}");
Template t = new Template(templateName, templateDescription, contextTypeId, builder.toString(), true);
TemplateProposal tp = createProposal(t, templateContext, context, images.forConfiguredCatalog(), getRelevance(t));
acceptor.accept(tp);
}
}
}
Aggregations