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


Java TemplatePersistenceData.getTemplate方法代码示例

本文整理汇总了Java中org.eclipse.jface.text.templates.persistence.TemplatePersistenceData.getTemplate方法的典型用法代码示例。如果您正苦于以下问题:Java TemplatePersistenceData.getTemplate方法的具体用法?Java TemplatePersistenceData.getTemplate怎么用?Java TemplatePersistenceData.getTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jface.text.templates.persistence.TemplatePersistenceData的用法示例。


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

示例1: getColumnText

import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入方法依赖的package包/类
public String getColumnText(Object element, int columnIndex) {
	TemplatePersistenceData data = (TemplatePersistenceData) element;
	Template template= data.getTemplate();

	switch (columnIndex) {
		case 0:
			return template.getName();
		case 1:
			TemplateContextType type= fContextTypeRegistry.getContextType(template.getContextTypeId());
			if (type != null)
				return type.getName();
			return template.getContextTypeId();
		case 2:
			return template.getDescription();
		case 3:
			return template.isAutoInsertable() ? TemplatesMessages.TemplatePreferencePage_on : "";  //$NON-NLS-1$
		default:
			return ""; //$NON-NLS-1$
	}
}
 
开发者ID:cplutte,项目名称:bts,代码行数:21,代码来源:E4TemplatePreferencePage.java

示例2: directAdd

import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入方法依赖的package包/类
public void directAdd(final TemplatePersistenceData data, final boolean isEdited) {
	if (isEdited) {
		add(data);
	} else {
		// Trick the template store so that (1) the template is considered
		// as "user added" while (2) maintaining a proper id
		final String id = data.getId();
		final TemplatePersistenceData d2 = new TemplatePersistenceData(data.getTemplate(), true) {

			@Override
			public String getId() {
				return id;
			}

		};
		add(d2);
	}
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:19,代码来源:GamlTemplateStore.java

示例3: load

import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入方法依赖的package包/类
public void load() throws IOException {
	if (fProjectStore != null) {
		fProjectStore.load();

		Set<String> datas= new HashSet<String>();
		TemplatePersistenceData[] data= fProjectStore.getTemplateData(false);
		for (int i= 0; i < data.length; i++) {
			datas.add(data[i].getId());
		}

		data= fInstanceStore.getTemplateData(false);
		for (int i= 0; i < data.length; i++) {
			TemplatePersistenceData orig= data[i];
			if (!datas.contains(orig.getId())) {
				TemplatePersistenceData copy= new TemplatePersistenceData(new Template(orig.getTemplate()), orig.isEnabled(), orig.getId());
				fProjectStore.add(copy);
				copy.setDeleted(true);
			}
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:22,代码来源:ProjectTemplateStore.java

示例4: editTemplate

import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入方法依赖的package包/类
/**
 * Creates the edit dialog. Subclasses may override this method to provide a
 * custom dialog.
 *
 * @param template the template being edited
 * @param edit whether the dialog should be editable
 * @param isNameModifiable whether the template name may be modified
 * @return the created or modified template, or <code>null</code> if the edition failed
 * @since 3.1
 */
protected Template editTemplate(Template template, boolean edit, boolean isNameModifiable) {
	IStructuredSelection selection= (IStructuredSelection) this.getTableViewer().getSelection();

	Object[] objects= selection.toArray();
	if ((objects != null) || (objects.length == 1)) {
		TemplatePersistenceData data=(TemplatePersistenceData) selection.getFirstElement();
		if(data.getTemplate() instanceof SilverStripeTemplate) {
			template=new SilverStripeTemplate((SilverStripeTemplate) data.getTemplate());
		}
	}
	
	EditTemplateDialog dialog= new SSEditTemplateDialog(getShell(), template, edit, isNameModifiable, this.getContextTypeRegistry());
	if (dialog.open() == Window.OK) {
		return dialog.getTemplate();
	}
	return null;
}
 
开发者ID:UndefinedOffset,项目名称:eclipse-silverstripedt,代码行数:28,代码来源:SilverStripeTemplatesPreferencePage.java

示例5: addTemplatesFromFile

import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入方法依赖的package包/类
/**
 * Contribute templates defined in file with the give URL.
 * 
 * @param templates
 *          the URL of the file with templates
 */
private void addTemplatesFromFile(final URL templates) {
  if (templates != null) {
    TemplateReaderWriter reader = new TemplateReaderWriter();
    try {
      InputStream openStream = templates.openStream();
      try {
        TemplatePersistenceData[] datas = reader.read(openStream, null);
        int templateCounter = 0;
        for (TemplatePersistenceData data : datas) {
          if (data.getId() == null) {
            templateCounter++;
            TemplatePersistenceData dataWithGenId = new TemplatePersistenceData(data.getTemplate(), data.isEnabled(), templates.getPath() + "." //$NON-NLS-1$
                + templateCounter);
            dataWithGenId.setDeleted(data.isDeleted());
            internalAdd(dataWithGenId);
          } else {
            // if contributed template has an id
            internalAdd(data);
          }
        }
      } finally {
        openStream.close();
      }
    } catch (IOException e) {
      LOG.error(e);
    }
  }
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:35,代码来源:ConfigurableTemplateStore.java

示例6: updateViewerInput

import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入方法依赖的package包/类
protected void updateViewerInput() {
	IStructuredSelection selection= (IStructuredSelection) getTableViewer().getSelection();
	SourceViewer viewer= getViewer();
	
	if (selection.size() == 1 && selection.getFirstElement() instanceof TemplatePersistenceData) {
		TemplatePersistenceData data= (TemplatePersistenceData) selection.getFirstElement();
		Template template= data.getTemplate();
		String contextId= template.getContextTypeId();
		TemplateContextType type= JSDTTypeScriptUIPlugin.getDefault().getTemplateContextRegistry().getContextType(contextId);
		fTemplateProcessor.setContextType(type);
		
		IDocument doc= viewer.getDocument();
		
		String start= null;
		if ("javadoc".equals(contextId)) { //$NON-NLS-1$
			start= "/**" + doc.getLegalLineDelimiters()[0]; //$NON-NLS-1$
		} else
			start= ""; //$NON-NLS-1$
		
		doc.set(start + template.getPattern());
		int startLen= start.length();
		viewer.setDocument(doc, startLen, doc.getLength() - startLen);

	} else {
		viewer.getDocument().set(""); //$NON-NLS-1$
	}		
}
 
开发者ID:angelozerr,项目名称:typescript.java,代码行数:28,代码来源:TypeScriptTemplatePreferencePage.java

示例7: updateSourceViewerInput

import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入方法依赖的package包/类
protected void updateSourceViewerInput(List selection) {
	if (fPatternViewer == null || fPatternViewer.getTextWidget().isDisposed()) {
		return;
	}
	if (selection.size() == 1 && selection.get(0) instanceof TemplatePersistenceData) {
		TemplatePersistenceData data = (TemplatePersistenceData) selection.get(0);
		Template template = data.getTemplate();
		TemplateContextType type = JavaScriptPlugin.getDefault().getCodeTemplateContextRegistry()
				.getContextType(template.getContextTypeId());
		fTemplateProcessor.setContextType(type);
		fPatternViewer.getDocument().set(template.getPattern());
	} else {
		fPatternViewer.getDocument().set(""); //$NON-NLS-1$
	}
}
 
开发者ID:angelozerr,项目名称:typescript.java,代码行数:16,代码来源:CodeTemplateBlock.java

示例8: edit

import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入方法依赖的package包/类
private void edit(TemplatePersistenceData data) {
	Template newTemplate = new Template(data.getTemplate());
	EditTemplateDialog dialog = new EditTemplateDialog(getShell(), newTemplate, true, false,
			JavaScriptPlugin.getDefault().getCodeTemplateContextRegistry());
	if (dialog.open() == Window.OK) {
		// changed
		data.setTemplate(dialog.getTemplate());
		fCodeTemplateTree.refresh(data);
		fCodeTemplateTree.selectElements(new StructuredSelection(data));
	}
}
 
开发者ID:angelozerr,项目名称:typescript.java,代码行数:12,代码来源:CodeTemplateBlock.java

示例9: updateViewerInput

import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入方法依赖的package包/类
/**
 * Updates the pattern viewer.
 */
protected void updateViewerInput() {
	IStructuredSelection selection= (IStructuredSelection) fTableViewer.getSelection();

	if (selection.size() == 1) {
		TemplatePersistenceData data= (TemplatePersistenceData) selection.getFirstElement();
		Template template= data.getTemplate();
		fPatternViewer.getDocument().set(template.getPattern());
	} else {
		fPatternViewer.getDocument().set(""); //$NON-NLS-1$
	}
}
 
开发者ID:cplutte,项目名称:bts,代码行数:15,代码来源:E4TemplatePreferencePage.java

示例10: internalAdd

import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入方法依赖的package包/类
/**
 * Adds a template to the internal store. The added templates must have a
 * unique id.
 * 
 * @param data
 *            the template data to add
 */
@Override
protected void internalAdd(final TemplatePersistenceData data) {
	if (!data.isCustom()) {
		// give the data a new unique id
		final String id = getNewIdFromId(data.getId());
		final TemplatePersistenceData d2 = new TemplatePersistenceData(data.getTemplate(), true, id);
		super.internalAdd(d2);
	}
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:17,代码来源:GamlTemplateStore.java

示例11: setCodeTemplate

import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入方法依赖的package包/类
/**
 * Only to be used by tests
 * 
 * @param templateId the template id
 * @param pattern the new pattern
 * @param project not used
 */
public static void setCodeTemplate(String templateId, String pattern, IJavaProject project) {
	TemplateStore codeTemplateStore= JavaPlugin.getDefault().getCodeTemplateStore();
	TemplatePersistenceData data= codeTemplateStore.getTemplateData(templateId);
	Template orig= data.getTemplate();
	Template copy= new Template(orig.getName(), orig.getDescription(), orig.getContextTypeId(), pattern, true);
	data.setTemplate(copy);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:15,代码来源:StubUtility.java

示例12: findSimilarTemplate

import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入方法依赖的package包/类
private static TemplatePersistenceData findSimilarTemplate(TemplatePersistenceData[] datas, Template template, boolean isCodeTemplates) {
	 for (int i= 0; i < datas.length; i++) {
		TemplatePersistenceData data= datas[i];
		Template orig= data.getTemplate();
		if (isSimilar(template, orig, isCodeTemplates))
			return data;
	 }

	 return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:11,代码来源:CompatibilityTemplateStore.java

示例13: updateViewerInput

import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入方法依赖的package包/类
@Override
protected void updateViewerInput() {
	IStructuredSelection selection= (IStructuredSelection) getTableViewer().getSelection();
	SourceViewer viewer= getViewer();

	if (selection.size() == 1 && selection.getFirstElement() instanceof TemplatePersistenceData) {
		TemplatePersistenceData data= (TemplatePersistenceData) selection.getFirstElement();
		Template template= data.getTemplate();
		String contextId= template.getContextTypeId();
		TemplateContextType type= JavaPlugin.getDefault().getTemplateContextRegistry().getContextType(contextId);
		fTemplateProcessor.setContextType(type);

		IDocument doc= viewer.getDocument();

		String start= null;
		if ("javadoc".equals(contextId)) { //$NON-NLS-1$
			start= "/**" + doc.getLegalLineDelimiters()[0]; //$NON-NLS-1$
		} else
			start= ""; //$NON-NLS-1$

		doc.set(start + template.getPattern());
		int startLen= start.length();
		viewer.setDocument(doc, startLen, doc.getLength() - startLen);

	} else {
		viewer.getDocument().set(""); //$NON-NLS-1$
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:29,代码来源:JavaTemplatePreferencePage.java

示例14: updateSourceViewerInput

import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入方法依赖的package包/类
protected void updateSourceViewerInput(List<Object> selection) {
	if (fPatternViewer == null || fPatternViewer.getTextWidget().isDisposed()) {
		return;
	}
	if (selection.size() == 1 && selection.get(0) instanceof TemplatePersistenceData) {
		TemplatePersistenceData data= (TemplatePersistenceData) selection.get(0);
		Template template= data.getTemplate();
		TemplateContextType type= JavaPlugin.getDefault().getCodeTemplateContextRegistry().getContextType(template.getContextTypeId());
		fTemplateProcessor.setContextType(type);
		fPatternViewer.getDocument().set(template.getPattern());
	} else {
		fPatternViewer.getDocument().set(""); //$NON-NLS-1$
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:15,代码来源:CodeTemplateBlock.java

示例15: edit

import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入方法依赖的package包/类
private void edit(TemplatePersistenceData data) {
	Template newTemplate= new Template(data.getTemplate());
	EditTemplateDialog dialog= new EditTemplateDialog(getShell(), newTemplate, true, false, JavaPlugin.getDefault().getCodeTemplateContextRegistry());
	if (dialog.open() == Window.OK) {
		// changed
		data.setTemplate(dialog.getTemplate());
		fCodeTemplateTree.refresh(data);
		fCodeTemplateTree.selectElements(new StructuredSelection(data));
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:11,代码来源:CodeTemplateBlock.java


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