当前位置: 首页>>代码示例>>Java>>正文


Java TemplateProposal类代码示例

本文整理汇总了Java中org.eclipse.jface.text.templates.TemplateProposal的典型用法代码示例。如果您正苦于以下问题:Java TemplateProposal类的具体用法?Java TemplateProposal怎么用?Java TemplateProposal使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TemplateProposal类属于org.eclipse.jface.text.templates包,在下文中一共展示了TemplateProposal类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: compare

import org.eclipse.jface.text.templates.TemplateProposal; //导入依赖的package包/类
/** {@inheritDoc} */
@SuppressWarnings({"rawtypes", "unchecked"})
public int compare(final ICompletionProposal o1, final ICompletionProposal o2) {

  // Template sorting by relevance and then alphabetically by name
  if (o1 instanceof TemplateProposal && o2 instanceof TemplateProposal) {
    TemplateProposal t1 = (TemplateProposal) o1;
    TemplateProposal t2 = (TemplateProposal) o2;
    if (t1.getRelevance() == t2.getRelevance()) {
      return o1.getDisplayString().compareTo(o2.getDisplayString());
    }
    return ((Integer) t1.getRelevance()).compareTo(t1.getRelevance());
  }
  // Templates always first
  if (o1 instanceof TemplateProposal) {
    return -1;
  } else if (o2 instanceof TemplateProposal) {
    return 1;
  }
  // Fallback
  if ((o1 instanceof Comparable) && (o2 instanceof Comparable)) {
    return ((Comparable) o1).compareTo(o2);
  }
  return o1.getDisplayString().compareTo(o2.getDisplayString());
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:26,代码来源:TemplatesFirstCompletionProposalComparator.java

示例2: applyTemplateAtTheEnd

import org.eclipse.jface.text.templates.TemplateProposal; //导入依赖的package包/类
/**
 * @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();
	}
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:23,代码来源:GamlEditor.java

示例3: createProposal

import org.eclipse.jface.text.templates.TemplateProposal; //导入依赖的package包/类
private ICompletionProposal createProposal(PySelection ps, ImageCache imageCache, PyEdit edit,
        final String startIndent, IRegion region, int iComp, String comp, TemplateContext context) {
    Template t = new Template("Surround with", SURROUND_WITH_COMPLETIONS[iComp + 1], "", comp, false);
    if (context != null) {
        TemplateProposal proposal = new TemplateProposal(t, context, region,
                imageCache.get(UIConstants.COMPLETION_TEMPLATE), 5) {
            @Override
            public String getAdditionalProposalInfo() {
                return startIndent + super.getAdditionalProposalInfo();
            }
        };
        return proposal;
    } else {
        //In tests
        return new CompletionProposal(comp, region.getOffset(), region.getLength(), 0);
    }
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:18,代码来源:AssistSurroundWith.java

示例4: applyProposal

import org.eclipse.jface.text.templates.TemplateProposal; //导入依赖的package包/类
private String applyProposal(ICompletionProposal proposal, IXtextDocument document) {
	return document.modify(
			state -> {
				state.setValidationDisabled(false);
				if (!(proposal instanceof TemplateProposal)) {
					proposal.apply(document);
				}
				return document.get();
			});
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:11,代码来源:ContentAssistXpectMethod.java

示例5: applyProposal

import org.eclipse.jface.text.templates.TemplateProposal; //导入依赖的package包/类
private String applyProposal(ICompletionProposal proposal, IXtextDocument document) {
	return document.modify(
			new IUnitOfWork<String, XtextResource>() {
				@Override
				public String exec(XtextResource state) throws Exception {
					state.setValidationDisabled(false);
					if (!(proposal instanceof TemplateProposal)) {
						proposal.apply(document);
					}
					return document.get();
				}
			});
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:14,代码来源:ProposalXpectMethod.java

示例6: applyTemplateProposal

import org.eclipse.jface.text.templates.TemplateProposal; //导入依赖的package包/类
/**
 * Apply template proposal.
 *
 * @param templateProposal
 *          the template proposal, must not be {@code null}
 * @param offset
 *          offset in test file
 * @return the document text after application of the template proposal, never {@code null}
 */
private String applyTemplateProposal(final TemplateProposal templateProposal, final int offset) {
  // Apply proposal
  UiThreadDispatcher.dispatchAndWait(new Runnable() {
    @Override
    public void run() {
      Assert.assertNotNull(EDITOR_HAS_NO_VIEWER, getViewer());
      templateProposal.apply(getViewer(), ' ', 0, offset);
    }
  });

  waitForValidation();
  return getDocument().get();
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:23,代码来源:AbstractContentAssistUiTest.java

示例7: getRelevance

import org.eclipse.jface.text.templates.TemplateProposal; //导入依赖的package包/类
/**
 * Returns relevance of given proposal.
 * 
 * @param proposal either a {@link ConfigurableCompletionProposal} or a {@link TemplateProposal}
 * @return relevance (higher value indicates higher relevance) or <code>null</code>
 * @since 2.3
 */
protected Integer getRelevance(ICompletionProposal proposal) {
	if (proposal instanceof ConfigurableCompletionProposal) {
		return ((ConfigurableCompletionProposal) proposal).getPriority();
	} else if (proposal instanceof TemplateProposal) {
		return ((TemplateProposal) proposal).getRelevance();
	} else if (proposal instanceof QuickAssistCompletionProposal) {
		return ((QuickAssistCompletionProposal) proposal).getRelevance();
	}
	return null;
}
 
开发者ID:cplutte,项目名称:bts,代码行数:18,代码来源:ICompletionProposalComparator.java

示例8: createFeatureConfigurationTemplates

import org.eclipse.jface.text.templates.TemplateProposal; //导入依赖的package包/类
private void createFeatureConfigurationTemplates(TemplateContext templateContext, ContentAssistContext context,
		ITemplateAcceptor acceptor) {
	GeneratorModel model = (GeneratorModel) EcoreUtil2.getRootContainer(context.getCurrentModel());

	IGeneratorDescriptor generatorDescriptor = GeneratorExtensions.getGeneratorDescriptor(model.getGeneratorId());

	Iterable<ILibraryDescriptor> libraryDescriptor = LibraryExtensions
			.getLibraryDescriptors(generatorDescriptor.getLibraryIDs());

	for (ILibraryDescriptor desc : libraryDescriptor) {
		ResourceSet set = new ResourceSetImpl();
		Resource resource = set.getResource(desc.getURI(), true);
		FeatureTypeLibrary lib = (FeatureTypeLibrary) resource.getContents().get(0);
		EList<FeatureType> types = lib.getTypes();

		for (FeatureType featureType : types) {
			Template template = new Template(featureType.getName() + " feature",
					"Creates feature " + featureType.getName(), featureType.getName(),
					creator.createProposal(featureType,
							desc.createFeatureValueProvider(SGenActivator.getInstance()
									.getInjector(SGenActivator.ORG_YAKINDU_SCT_GENERATOR_GENMODEL_SGEN)),
							context.getCurrentModel()),
					false);
			TemplateProposal proposal = createProposal(template, templateContext, context, getImage(template),
					getRelevance(template));
			acceptor.accept(proposal);
		}
	}
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:30,代码来源:SGenTemplateProposalProvider.java

示例9: createProposal

import org.eclipse.jface.text.templates.TemplateProposal; //导入依赖的package包/类
@Override
protected ICompletionProposal createProposal(Template template,
		TemplateContext context, IRegion region, int relevance) {
	TemplateProposal proposal = new BfTemplateProposal(template, context, region, getImage(template), relevance);
	proposal.setInformationControlCreator(informationControlCreator);
	return proposal;
}
 
开发者ID:RichardBirenheide,项目名称:brainfuck,代码行数:8,代码来源:BfTemplateCompletionProcessor.java

示例10: applyTemplate

import org.eclipse.jface.text.templates.TemplateProposal; //导入依赖的package包/类
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);
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:14,代码来源:GamlEditor.java

示例11: getRelevance

import org.eclipse.jface.text.templates.TemplateProposal; //导入依赖的package包/类
private int getRelevance(ICompletionProposal obj) {
	if (obj instanceof IJavaCompletionProposal) {
		IJavaCompletionProposal jcp= (IJavaCompletionProposal) obj;
		return jcp.getRelevance();
	} else if (obj instanceof TemplateProposal) {
		TemplateProposal tp= (TemplateProposal) obj;
		return tp.getRelevance();
	}
	// catch all
	return 0;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:12,代码来源:CompletionProposalComparator.java

示例12: getSelection

import org.eclipse.jface.text.templates.TemplateProposal; //导入依赖的package包/类
@Override
public Point getSelection(IDocument document) {
    TemplateProposal executed2 = getExecuted();
    if (executed2 != null) {
        return executed2.getSelection(document);
    }
    return null;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:9,代码来源:TddRefactorCompletion.java

示例13: apply

import org.eclipse.jface.text.templates.TemplateProposal; //导入依赖的package包/类
@Override
public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
    if (edit != null) {
        //We have to reparse to make sure that we'll have an accurate AST.
        edit.getParser().reparseDocument();
    }
    TemplateProposal executed2 = getExecuted();
    if (executed2 != null) {
        executed2.apply(viewer, trigger, stateMask, 0);
        forceReparseInBaseEditorAnd();
    }
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:13,代码来源:TddRefactorCompletion.java

示例14: afterEditorCreated

import org.eclipse.jface.text.templates.TemplateProposal; //导入依赖的package包/类
/**
 * Applies the template if one was specified.
 */
@Override
protected void afterEditorCreated(final IEditorPart openEditor) {
    if (!(openEditor instanceof PyEdit)) {
        return; //only works for PyEdit...
    }

    RunInUiThread.async(new Runnable() {

        @Override
        public void run() {
            PyEdit pyEdit = (PyEdit) openEditor;
            if (pyEdit.isDisposed()) {
                return;
            }
            TemplateSelectDialog dialog = new TemplateSelectDialog(Display.getCurrent().getActiveShell());
            dialog.open();
            TemplatePersistenceData selectedTemplate = dialog.getSelectedTemplate();
            if (selectedTemplate == null) {
                return; //no template selected, nothing to apply!
            }

            Template template = selectedTemplate.getTemplate();

            Region region = new Region(0, 0);
            PyDocumentTemplateContext context = PyTemplateCompletionProcessor.createContext(new PyContextType(),
                    pyEdit.getPySourceViewer(), region);

            TemplateProposal templateProposal = new TemplateProposal(template, context, region, null);
            templateProposal.apply(pyEdit.getPySourceViewer(), '\n', 0, 0);
        }
    });
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:36,代码来源:PythonModuleWizard.java

示例15: _getRelevance

import org.eclipse.jface.text.templates.TemplateProposal; //导入依赖的package包/类
protected Integer _getRelevance(final TemplateProposal proposal) {
  Integer _xifexpression = null;
  String _displayString = proposal.getDisplayString();
  boolean _startsWith = _displayString.startsWith("template: ");
  if (_startsWith) {
    _xifexpression = TemplatePreferringCompletionProposalProvider.PREMIUM_RELEVANCE;
  } else {
    _xifexpression = TemplatePreferringCompletionProposalProvider.HIGH_RELEVANCE;
  }
  return _xifexpression;
}
 
开发者ID:RobertWalter83,项目名称:DialogScriptDSL,代码行数:12,代码来源:TemplatePreferringCompletionProposalProvider.java


注:本文中的org.eclipse.jface.text.templates.TemplateProposal类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。