• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TemplatePersistenceData类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: applyData

import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入依赖的package包/类
public void applyData(Object data) {
	if (data instanceof Map) {
		Object id = ((Map) data).get(DATA_SELECT_TEMPLATE);
		if (id instanceof String) {
			final TemplatePersistenceData[] templates = fCodeTemplateConfigurationBlock.fTemplateStore
					.getTemplateData();
			TemplatePersistenceData template = null;
			for (int index = 0; index < templates.length; index++) {
				template = templates[index];
				if (template.getId().equals(id)) {
					fCodeTemplateConfigurationBlock.postSetSelection(template);
					break;
				}
			}
		}
	}
	super.applyData(data);
}
 
开发者ID:angelozerr,项目名称:typescript.java,代码行数:19,代码来源:CodeTemplatePreferencePage.java


示例2: 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


示例3: updateButtons

import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入依赖的package包/类
/**
 * Updates the buttons.
 */
protected void updateButtons() {
	IStructuredSelection selection= (IStructuredSelection) fTableViewer.getSelection();
	int selectionCount= selection.size();
	int itemCount= fTableViewer.getTable().getItemCount();
	boolean canRestore= fTemplateStore.getTemplateData(true).length != fTemplateStore.getTemplateData(false).length;
	boolean canRevert= false;
	for (Iterator it= selection.iterator(); it.hasNext();) {
		TemplatePersistenceData data= (TemplatePersistenceData) it.next();
		if (data.isModified()) {
			canRevert= true;
			break;
		}
	}

	fEditButton.setEnabled(selectionCount == 1);
	fExportButton.setEnabled(selectionCount > 0);
	fRemoveButton.setEnabled(selectionCount > 0 && selectionCount <= itemCount);
	fRestoreButton.setEnabled(canRestore);
	fRevertButton.setEnabled(canRevert);
}
 
开发者ID:cplutte,项目名称:bts,代码行数:24,代码来源:E4TemplatePreferencePage.java


示例4: add

import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入依赖的package包/类
private void add() {

		Iterator it= fContextTypeRegistry.contextTypes();
		if (it.hasNext()) {
			Template template= new Template("", "", ((TemplateContextType) it.next()).getId(), "", true);   //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

			Template newTemplate= editTemplate(template, false, true);
			if (newTemplate != null) {
				TemplatePersistenceData data= new TemplatePersistenceData(newTemplate, true);
				fTemplateStore.add(data);
				fTableViewer.refresh();
				fTableViewer.setChecked(data, true);
				fTableViewer.setSelection(new StructuredSelection(data));
			}
		}
	}
 
开发者ID:cplutte,项目名称:bts,代码行数:17,代码来源:E4TemplatePreferencePage.java


示例5: loadContributedTemplates

import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入依赖的package包/类
@Override
protected void loadContributedTemplates() throws IOException {
	if (res==null)
		return;
	TemplateReaderWriter reader = new TemplateReaderWriter();
	InputStream openStream = null;
	try {
		openStream = res.openStream();
		try {
			TemplatePersistenceData[] read = reader.read(openStream, null);
			for (TemplatePersistenceData templatePersistenceData : read) {
				internalAdd(templatePersistenceData);
			}
		} finally {
			openStream.close();
		}
	} catch (IOException e) {
		log.error(e);
	}
}
 
开发者ID:cplutte,项目名称:bts,代码行数:21,代码来源:XtextTemplateStore.java


示例6: 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


示例7: add

import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入依赖的package包/类
void add(final TemplatePersistenceData t, final List<String> path) {
	if (path.size() == 0) {
		children.add(new TemplateNode(this, t, 1));
	} else if (path.size() == 1 && Strings.isGamaNumber(path.get(0))) {
		children.add(new TemplateNode(this, t, Integer.decode(path.get(0))));
	} else {
		final String name = path.remove(0);
		Node node = childWithName(name);
		if (node == null) {
			node = new TemplateTree(this, name);
			children.add(node);
		}
		((TemplateTree) node).add(t, path);
	}

}
 
开发者ID:gama-platform,项目名称:gama,代码行数:17,代码来源:TemplateReferenceMenu.java


示例8: pruneDuplicates

import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入依赖的package包/类
/**
 * Removes any duplicates from a template store. Duplicate user added templates
 * are copied over their contributed siblings. If isCodeTemplates is true,
 * any user added templates are then removed.
 *
 * @param store
 * @param isCodeTemplates
 */
public static void pruneDuplicates(TemplateStore store, boolean isCodeTemplates) {
	TemplatePersistenceData[] datas= store.getTemplateData(true);
	for (int i= datas.length - 1; i >= 0; i--) {
		TemplatePersistenceData data= datas[i];
		if (data.isUserAdded()) {
			// find a contributed template that is similar and check it
			TemplatePersistenceData similar= findSimilarTemplate(datas, data.getTemplate(), isCodeTemplates);
			if (similar != data && !similar.isUserAdded()) {
				similar.setTemplate(data.getTemplate());
				store.delete(data);
			}
		}
	}

	if (isCodeTemplates) {
		datas= store.getTemplateData(true);
		for (int i= datas.length - 1; i >= 0; i--) {
			if (datas[i].isUserAdded())
				store.delete(datas[i]);
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:31,代码来源:CompatibilityTemplateStore.java


示例9: 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


示例10: performOk

import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入依赖的package包/类
public boolean performOk(boolean enabled) {
	boolean res= super.performOk();
	if (!res)
		return false;

	if (fProject != null) {
		TemplatePersistenceData[] templateData= fTemplateStore.getTemplateData();
		for (int i= 0; i < templateData.length; i++) {
			fTemplateStore.setProjectSpecific(templateData[i].getId(), enabled);
		}
	}
	try {
		fTemplateStore.save();
	} catch (IOException e) {
		JavaPlugin.log(e);
		openWriteErrorDialog();
	}
	return true;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:CodeTemplateBlock.java


示例11: applyData

import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入依赖的package包/类
@Override
public void applyData(Object data) {
	if (data instanceof Map) {
		Object id= ((Map<?, ?>) data).get(DATA_SELECT_TEMPLATE);
		if (id instanceof String) {
			final TemplatePersistenceData[] templates= fCodeTemplateConfigurationBlock.fTemplateStore.getTemplateData();
			TemplatePersistenceData template= null;
			for (int index= 0; index < templates.length; index++) {
				template= templates[index];
				if (template.getId().equals(id)) {
					fCodeTemplateConfigurationBlock.postSetSelection(template);
					break;
				}
			}
		}
	}
	super.applyData(data);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:CodeTemplatePreferencePage.java


示例12: fillTemplateOptions

import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入依赖的package包/类
/**
 * Sets the template options in the passed list (swt)
 */
private void fillTemplateOptions(TemplatePersistenceData[] templateData, Table list) {
    nameToTemplateData = new TreeMap<String, TemplatePersistenceData>();

    for (TemplatePersistenceData data : templateData) {
        if (PyContextType.PY_MODULES_CONTEXT_TYPE.equals(data.getTemplate().getContextTypeId())) {
            String name = data.getTemplate().getName();
            nameToTemplateData.put(name, data);
        }
    }
    ArrayList<String> lst = new ArrayList<String>(nameToTemplateData.keySet());
    for (String string : lst) {
        new TableItem(list, SWT.NONE).setText(string);
    }
    list.setSelection(0);
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:19,代码来源:TemplateSelectDialog.java


示例13: save

import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入依赖的package包/类
/**
 * Saves the templates to the preferences.
 *
 * @throws IOException if the templates cannot be written
 */
public void save() throws IOException {
	ArrayList custom= new ArrayList();
	List<TemplatePersistenceData> fTemplates=Arrays.asList(this.getTemplateData(true));
	for (Iterator it= fTemplates.iterator(); it.hasNext();) {
		TemplatePersistenceData data= (TemplatePersistenceData) it.next();
		if (data.isCustom() && !(data.isUserAdded() && data.isDeleted())) // don't save deleted user-added templates
			custom.add(data);
	}

	StringWriter output= new StringWriter();
	TemplateReaderWriter writer= new SilverStripeTemplateReaderWriter();
	writer.save((TemplatePersistenceData[]) custom.toArray(new TemplatePersistenceData[custom.size()]), output);

	this.stopListeningForPreferenceChanges();
	try {
		fPreferenceStore.setValue(fKey, output.toString());
		if (fPreferenceStore instanceof IPersistentPreferenceStore)
			((IPersistentPreferenceStore)fPreferenceStore).save();
	} finally {
		this.startListeningForPreferenceChanges();
	}
}
 
开发者ID:UndefinedOffset,项目名称:eclipse-silverstripedt,代码行数:28,代码来源:SilverStripeTemplateStore.java


示例14: 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


示例15: 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


示例16: 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


示例17: getParent

import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入依赖的package包/类
public Object getParent(TreeListDialogField field, Object element) {
	if (element instanceof TemplatePersistenceData) {
		TemplatePersistenceData data = (TemplatePersistenceData) element;
		if (data.getTemplate().getName().endsWith(CodeTemplateContextType.COMMENT_SUFFIX)) {
			return COMMENT_NODE;
		}
		return CODE_NODE;
	}
	return null;
}
 
开发者ID:angelozerr,项目名称:typescript.java,代码行数:11,代码来源:CodeTemplateBlock.java


示例18: getTemplateOfCategory

import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入依赖的package包/类
protected TemplatePersistenceData[] getTemplateOfCategory(boolean isComment) {
	ArrayList res = new ArrayList();
	TemplatePersistenceData[] templates = fTemplateStore.getTemplateData();
	for (int i = 0; i < templates.length; i++) {
		TemplatePersistenceData curr = templates[i];
		if (isComment == curr.getTemplate().getName().endsWith(CodeTemplateContextType.COMMENT_SUFFIX)) {
			res.add(curr);
		}
	}
	return (TemplatePersistenceData[]) res.toArray(new TemplatePersistenceData[res.size()]);
}
 
开发者ID:angelozerr,项目名称:typescript.java,代码行数:12,代码来源:CodeTemplateBlock.java


示例19: 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


示例20: doButtonPressed

import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入依赖的package包/类
protected void doButtonPressed(int buttonIndex, List selected) {
	if (buttonIndex == IDX_EDIT) {
		edit((TemplatePersistenceData) selected.get(0));
	} else if (buttonIndex == IDX_EXPORT) {
		export(selected);
	} else if (buttonIndex == IDX_EXPORTALL) {
		exportAll();
	} else if (buttonIndex == IDX_IMPORT) {
		import_();
	}
}
 
开发者ID:angelozerr,项目名称:typescript.java,代码行数:12,代码来源:CodeTemplateBlock.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SnmpPduPacket类代码示例发布时间:2022-05-22
下一篇:
Java XIfExpression类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap