本文整理汇总了Java中org.eclipse.ui.internal.registry.FileEditorMapping类的典型用法代码示例。如果您正苦于以下问题:Java FileEditorMapping类的具体用法?Java FileEditorMapping怎么用?Java FileEditorMapping使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileEditorMapping类属于org.eclipse.ui.internal.registry包,在下文中一共展示了FileEditorMapping类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: updateDefaultEditorMappingIfAbsent
import org.eclipse.ui.internal.registry.FileEditorMapping; //导入依赖的package包/类
private void updateDefaultEditorMappingIfAbsent() {
final EditorRegistry registry = (EditorRegistry) WorkbenchPlugin.getDefault().getEditorRegistry();
for (final IFileEditorMapping editorMapping : registry.getFileEditorMappings()) {
final IEditorDescriptor defaultEditor = editorMapping.getDefaultEditor();
if (null == defaultEditor) {
final String extension = editorMapping.getExtension();
LOGGER.info("No default editor is associated with files with extension: '." + extension + "'.");
final IEditorDescriptor defaultTextEditor = registry.findEditor(DEFAULT_TEXT_EDITOR_ID);
if (null != defaultTextEditor) {
((FileEditorMapping) editorMapping).setDefaultEditor(defaultTextEditor);
String editorName = defaultTextEditor.getLabel();
if (null == editorName) {
editorName = defaultTextEditor.getId();
}
if (null != editorName) {
LOGGER.info("Associated files with extension " + extension + " with '" + editorName + "'.");
}
}
}
}
registry.saveAssociations();
PrefUtil.savePrefs();
}
开发者ID:eclipse,项目名称:n4js,代码行数:25,代码来源:N4JSApplicationWorkbenchWindowAdvisor.java
示例2: earlyStartup
import org.eclipse.ui.internal.registry.FileEditorMapping; //导入依赖的package包/类
@Override
public void earlyStartup() {
EditorRegistry editorReg = (EditorRegistry)PlatformUI.getWorkbench().getEditorRegistry();
EditorDescriptor editor = (EditorDescriptor)editorReg.findEditor("org.eclipse.ui.DefaultTextEditor");
FileEditorMapping mapping = new FileEditorMapping("inf");
mapping.addEditor(editor);
mapping.setDefaultEditor(editor);
IFileEditorMapping[] mappings = editorReg.getFileEditorMappings();
FileEditorMapping[] newMappings = new FileEditorMapping[mappings.length+1];
for (int i = 0; i < mappings.length; i++) {
newMappings[i] = (FileEditorMapping) mappings[i];
}
newMappings[mappings.length] = mapping;
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
editorReg.setFileEditorMappings(newMappings);
}
});
//reg.setDefaultEditor("inf", "org.eclipse.ui.DefaultTextEditor");
}
开发者ID:ffmmjj,项目名称:uefi_edk2_wizards_plugin,代码行数:25,代码来源:SetDefaultEditorsStartup.java
示例3: resetDefaultEditor
import org.eclipse.ui.internal.registry.FileEditorMapping; //导入依赖的package包/类
public static void resetDefaultEditor(String extension) {
EditorRegistry editorRegistry = (EditorRegistry) PlatformUI.getWorkbench().getEditorRegistry();
IFileEditorMapping[] editorMappings = editorRegistry.getFileEditorMappings();
// Search the file=>editor mappings for the specified extension
for (IFileEditorMapping editorMapping : editorMappings) {
if (extension.equals(editorMapping.getExtension())) {
FileEditorMapping internalMapping = (FileEditorMapping) editorMapping;
// Only need to do anything if there's an explicit default set
if (internalMapping.getDeclaredDefaultEditors().length > 0) {
// Clear any default editor associations for this extension
List<IEditorDescriptor> list = new ArrayList<IEditorDescriptor>();
internalMapping.setDefaultEditors(list);
// Save the updated editor registry to disk
editorRegistry.saveAssociations();
// TODO: remove
GWTPluginLog.logInfo("Reset default editor for extension: "
+ extension);
}
break;
}
}
}
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:27,代码来源:Util.java
示例4: setAnATLyzerDefaultEditor
import org.eclipse.ui.internal.registry.FileEditorMapping; //导入依赖的package包/类
private void setAnATLyzerDefaultEditor() {
String extension = "atl";
String editorId = "org.eclipse.m2m.atl.adt.editor.AtlEditor";
EditorRegistry editorReg = (EditorRegistry)PlatformUI.getWorkbench().getEditorRegistry();
//EditorDescriptor editor = (EditorDescriptor) editorReg.findEditor(editorId);
//editor.
IFileEditorMapping[] mappings = editorReg.getFileEditorMappings();
for (IFileEditorMapping mapping : mappings) {
if ( "atl".equals(mapping.getExtension()) ) {
IEditorDescriptor[] descriptors = mapping.getEditors();
IEditorDescriptor anatlyzerEditor = null;
for (IEditorDescriptor editorDesc : descriptors) {
if ( "anatlyzer.atl.editor.AtlEditorExt".equals( ((EditorDescriptor) editorDesc).getClassName()) ) {
anatlyzerEditor = editorDesc;
break;
}
}
if ( anatlyzerEditor != null ) {
((FileEditorMapping) mapping).setDefaultEditor((EditorDescriptor) anatlyzerEditor);
break;
}
}
}
}
开发者ID:anatlyzer,项目名称:anatlyzer,代码行数:27,代码来源:AnATLyzerNature.java
示例5: register
import org.eclipse.ui.internal.registry.FileEditorMapping; //导入依赖的package包/类
@Override
public void register(IVizService service) {
if (service != null) {
String name = service.getName();
// Put the service in service map so it can be retrieved later
serviceMap.put(name, service);
// Register the plot editor as default editor for all file
// extensions handled by the new viz service
for (String ext : service.getSupportedExtensions()) {
EditorRegistry editorReg = (EditorRegistry) PlatformUI
.getWorkbench().getEditorRegistry();
EditorDescriptor editor = (EditorDescriptor) editorReg
.findEditor("org.eclipse.eavp.viz.service.PlotEditor");
FileEditorMapping mapping = new FileEditorMapping(ext);
mapping.addEditor(editor);
mapping.setDefaultEditor(editor);
IFileEditorMapping[] mappings = editorReg
.getFileEditorMappings();
FileEditorMapping[] newMappings = new FileEditorMapping[mappings.length
+ 1];
for (int i = 0; i < mappings.length; i++) {
newMappings[i] = (FileEditorMapping) mappings[i];
}
newMappings[mappings.length] = mapping;
editorReg.setFileEditorMappings(newMappings);
}
logger.info("VizServiceFactory message: " + "Viz service \"" + name
+ "\" registered.");
}
return;
}
开发者ID:eclipse,项目名称:eavp,代码行数:37,代码来源:BasicVizServiceFactory.java
示例6: run
import org.eclipse.ui.internal.registry.FileEditorMapping; //导入依赖的package包/类
public void run()
{
EditorRegistry registry = (EditorRegistry)
WorkbenchPlugin.getDefault().getEditorRegistry();
IFileEditorMapping[] mappings = registry.getFileEditorMappings();
IFileEditorMapping c = null;
IFileEditorMapping cws = null;
// Search Class file editor mappings
for (IFileEditorMapping mapping : mappings)
{
if (mapping.getExtension().equals("class"))
{
// ... Helios 3.6, Indigo 3.7, Juno 4.2, Kepler 4.3, ...
c = mapping;
}
else if (mapping.getExtension().equals("class without source"))
{
// Juno 4.2, Kepler 4.3, ...
cws = mapping;
}
}
if ((c != null) && (cws != null))
{
// Search JD editor descriptor on "class" extension
for (IEditorDescriptor descriptor : c.getEditors())
{
if (descriptor.getId().equals(EDITOR_ID))
{
// Remove JD editor on "class" extension
//((FileEditorMapping)c).removeEditor((EditorDescriptor)descriptor);
// Set JD as default editor on "class without source" extension
registry.setDefaultEditor(
"." + cws.getExtension(), descriptor.getId());
break;
}
}
// Restore the default editor for "class" extension
IEditorDescriptor defaultClassFileEditor =
registry.findEditor(JavaUI.ID_CF_EDITOR);
if (defaultClassFileEditor != null)
{
registry.setDefaultEditor(
"." + c.getExtension(), JavaUI.ID_CF_EDITOR);
}
registry.setFileEditorMappings((FileEditorMapping[]) mappings);
registry.saveAssociations();
}
}
开发者ID:java-decompiler,项目名称:jd-eclipse,代码行数:55,代码来源:JavaDecompilerPlugin.java
注:本文中的org.eclipse.ui.internal.registry.FileEditorMapping类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论