org.eclipse.xtext.ui.editor.templates.XtextTemplateContextType Java Examples

The following examples show how to use org.eclipse.xtext.ui.editor.templates.XtextTemplateContextType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GamlEditor.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @see msi.gama.lang.gaml.ui.editor.IGamlEditor#applyTemplate(org.eclipse.jface.text.templates.Template)
 */

public void applyTemplateAtTheEnd(final Template t) {

	try {
		final IDocument doc = getDocument();
		int offset = doc.getLineOffset(doc.getNumberOfLines() - 1);
		doc.replace(offset, 0, "\n\n");
		offset += 2;
		final int length = 0;
		final Position pos = new Position(offset, length);
		final XtextTemplateContextType ct = new XtextTemplateContextType();
		final DocumentTemplateContext dtc = new DocumentTemplateContext(ct, doc, pos);
		final IRegion r = new Region(offset, length);
		final TemplateProposal tp = new TemplateProposal(t, dtc, r, null);
		tp.apply(getInternalSourceViewer(), (char) 0, 0, offset);
	} catch (final BadLocationException e) {
		e.printStackTrace();
	}
}
 
Example #2
Source File: XtextTemplateContextTypeRegistryTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Test public void testTypesAreSorted() {
	XtextTemplateContextTypeRegistry registry = new XtextTemplateContextTypeRegistry(grammarAccess, this, new ContextTypeIdHelper());
	String prevName = "";
	Iterator<?> iter = registry.contextTypes();
	assertTrue(iter.hasNext());
	while(iter.hasNext()) {
		XtextTemplateContextType next = (XtextTemplateContextType) iter.next();
		assertTrue(prevName.compareTo(next.getName()) < 0);
		prevName = next.getName();
	}
}
 
Example #3
Source File: GamlEditor.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
public void applyTemplate(final Template t) {
	// TODO Create a specific context type (with GAML specific variables ??)
	final XtextTemplateContextType ct = new XtextTemplateContextType();
	final IDocument doc = getDocument();
	final ITextSelection selection = (ITextSelection) getSelectionProvider().getSelection();
	final int offset = selection.getOffset();
	final int length = selection.getLength();
	final Position pos = new Position(offset, length);
	final DocumentTemplateContext dtc = new DocumentTemplateContext(ct, doc, pos);
	final IRegion r = new Region(offset, length);
	final TemplateProposal tp = new TemplateProposal(t, dtc, r, null);
	tp.apply(getInternalSourceViewer(), (char) 0, 0, offset);
}
 
Example #4
Source File: XtextTemplateContextTypeRegistryTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public XtextTemplateContextType get() {
	return new XtextTemplateContextType();
}
 
Example #5
Source File: AbstractDomainmodelUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends XtextTemplateContextType> bindXtextTemplateContextType() {
	return XbaseTemplateContextType.class;
}
 
Example #6
Source File: AbstractPureXbaseUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends XtextTemplateContextType> bindXtextTemplateContextType() {
	return XbaseTemplateContextType.class;
}
 
Example #7
Source File: AbstractXImportSectionTestLangUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends XtextTemplateContextType> bindXtextTemplateContextType() {
	return XbaseTemplateContextType.class;
}
 
Example #8
Source File: AbstractXtendUiModule.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends XtextTemplateContextType> bindXtextTemplateContextType() {
	return XbaseTemplateContextType.class;
}
 
Example #9
Source File: XtendUiModule.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public Class<? extends XtextTemplateContextType> bindXtextTemplateContextType() {
	return XtendTemplateContextType.class;
}
 
Example #10
Source File: CheckUiModule.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public Class<? extends XtextTemplateContextType> bindXtextTemplateContextType() {
  return CheckTemplateContextType.class;
}
 
Example #11
Source File: AbstractSARLUiModule.java    From sarl with Apache License 2.0 4 votes vote down vote up
public Class<? extends XtextTemplateContextType> bindXtextTemplateContextType() {
	return SARLTemplateContextType.class;
}
 
Example #12
Source File: CheckCfgUiModule.java    From dsl-devkit with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Binds a {@link XtextTemplateContextType} which adds
 * {@link com.avaloq.tools.ddk.xtext.ui.templates.ResourceNameTemplateVariableResolver ResourceNameTemplateVariableResolver} and
 * {@link com.avaloq.tools.ddk.xtext.ui.templates.SimpleEnumTemplateVariableResolver SimpleEnumTemplateVariableResolver}.
 *
 * @return {@link CheckCfgTemplateContextType}
 */
public Class<? extends XtextTemplateContextType> bindXtextTemplateContextType() {
  return CheckCfgTemplateContextType.class;
}