本文整理了Java中org.eclipse.ui.ide.IDE.setDefaultEditor()
方法的一些代码示例,展示了IDE.setDefaultEditor()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IDE.setDefaultEditor()
方法的具体详情如下:
包路径:org.eclipse.ui.ide.IDE
类名称:IDE
方法名:setDefaultEditor
[英]Sets the default editor id for a given file. This value will be used to determine the default editor descriptor for the file in future calls to getDefaultEditor(IFile)
.
[中]设置给定文件的默认编辑器id。此值将用于在将来调用getDefaultEditor(IFile)
时确定文件的默认编辑器描述符。
代码示例来源:origin: org.eclipse.pde/org.eclipse.pde.ui
private IFile createSiteManifest() {
IPath fFilePath = fPath.append(fFileName);
IFile categoryFile = PDECore.getWorkspace().getRoot().getFile(fFilePath);
if (categoryFile.exists())
return categoryFile;
WorkspaceSiteModel model = new WorkspaceSiteModel(categoryFile);
model.getSite();
// Save the model
model.save();
model.dispose();
// Set the default editor
IDE.setDefaultEditor(categoryFile, IPDEUIConstants.CATEGORY_EDITOR_ID);
return categoryFile;
}
代码示例来源:origin: org.eclipse.pde/org.eclipse.pde.ui
/**
* @return location of the created site.xml
* @throws CoreException
*/
private IFile createSiteManifest() throws CoreException {
IFile file = fProject.getFile("site.xml"); //$NON-NLS-1$
if (file.exists())
return file;
WorkspaceSiteModel model = new WorkspaceSiteModel(file);
model.getSite();
// Save the model
model.save();
model.dispose();
// Set the default editor
IDE.setDefaultEditor(file, IPDEUIConstants.SITE_EDITOR_ID);
return file;
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ant.ui
@Override
public void handleEvent(Event event) {
switch (event.type) {
case SWT.Selection:
if (menuItem.getSelection()) {
IDE.setDefaultEditor(fileResource, null);
try {
IDE.openEditor(fPage, fileResource, true);
}
catch (PartInitException e) {
AntUIPlugin.log(MessageFormat.format(AntViewActionMessages.AntViewOpenWithMenu_Editor_failed, new Object[] { fileResource.getLocation().toOSString() }), e);
}
}
break;
default:
break;
}
}
};
代码示例来源:origin: org.eclipse.pde/org.eclipse.pde.ui
private IFile generateSchemaFile(String pluginId, String id, String name, boolean shared, String schema, IProgressMonitor monitor) throws CoreException {
IFile schemaFile = null;
IWorkspace workspace = fContainer.getWorkspace();
IPath schemaPath = new Path(schema).removeLastSegments(1);
IPath newSchemaPath = fContainer.getProjectRelativePath().append(schemaPath);
monitor.subTask(PDEUIMessages.BaseExtensionPoint_generating);
if (newSchemaPath.isEmpty() == false) {
IFolder folder = fContainer.getProject().getFolder(newSchemaPath);
CoreUtility.createFolder(folder);
}
IPath filePath = fContainer.getFullPath().append(schema);
schemaFile = workspace.getRoot().getFile(filePath);
InputStream source = createSchemaStream(pluginId, id, name, shared, schemaFile);
if (!schemaFile.exists()) {
// create for the first time
schemaFile.create(source, true, monitor);
} else {
schemaFile.setContents(source, true, false, monitor);
}
IDE.setDefaultEditor(schemaFile, IPDEUIConstants.SCHEMA_EDITOR_ID);
return schemaFile;
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide
/**
* Opens the given editor on the selected file.
*
* @param editorDescriptor the editor descriptor, or null for the system editor
* @param openUsingDescriptor use the descriptor's editor ID for opening if false (normal case),
* or use the descriptor itself if true (needed to fix bug 178235).
*
* @since 3.5
*/
protected void openEditor(IEditorDescriptor editorDescriptor, boolean openUsingDescriptor) {
IFile file = getFileResource();
if (file == null) {
return;
}
try {
if (openUsingDescriptor) {
((WorkbenchPage) page).openEditorFromDescriptor(new FileEditorInput(file), editorDescriptor, true, null);
} else {
String editorId = editorDescriptor == null ? IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID
: editorDescriptor.getId();
page.openEditor(new FileEditorInput(file), editorId, true, MATCH_BOTH);
// only remember the default editor if the open succeeds
IDE.setDefaultEditor(file, editorId);
}
} catch (PartInitException e) {
DialogUtil.openError(page.getWorkbenchWindow().getShell(),
IDEWorkbenchMessages.OpenWithMenu_dialogTitle,
e.getMessage(), e);
}
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide
case SWT.Selection:
if (menuItem.getSelection()) {
IDE.setDefaultEditor(file, null);
try {
openEditor(IDE.getEditorDescriptor(file, true, true), false);
代码示例来源:origin: org.eclipse.pde/org.eclipse.pde.ui
model.save();
IDE.setDefaultEditor(file, IPDEUIConstants.BUILD_EDITOR_ID);
代码示例来源:origin: org.eclipse.pde/org.eclipse.pde.ui
IDE.setDefaultEditor(file, IPDEUIConstants.FEATURE_EDITOR_ID);
return file;
内容来源于网络,如有侵权,请联系作者删除!