org.eclipse.ui.ide.IDE.setDefaultEditor()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(4.3k)|赞(0)|评价(0)|浏览(319)

本文整理了Java中org.eclipse.ui.ide.IDE.setDefaultEditor()方法的一些代码示例,展示了IDE.setDefaultEditor()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IDE.setDefaultEditor()方法的具体详情如下:
包路径:org.eclipse.ui.ide.IDE
类名称:IDE
方法名:setDefaultEditor

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

  1. private IFile createSiteManifest() {
  2. IPath fFilePath = fPath.append(fFileName);
  3. IFile categoryFile = PDECore.getWorkspace().getRoot().getFile(fFilePath);
  4. if (categoryFile.exists())
  5. return categoryFile;
  6. WorkspaceSiteModel model = new WorkspaceSiteModel(categoryFile);
  7. model.getSite();
  8. // Save the model
  9. model.save();
  10. model.dispose();
  11. // Set the default editor
  12. IDE.setDefaultEditor(categoryFile, IPDEUIConstants.CATEGORY_EDITOR_ID);
  13. return categoryFile;
  14. }

代码示例来源:origin: org.eclipse.pde/org.eclipse.pde.ui

  1. /**
  2. * @return location of the created site.xml
  3. * @throws CoreException
  4. */
  5. private IFile createSiteManifest() throws CoreException {
  6. IFile file = fProject.getFile("site.xml"); //$NON-NLS-1$
  7. if (file.exists())
  8. return file;
  9. WorkspaceSiteModel model = new WorkspaceSiteModel(file);
  10. model.getSite();
  11. // Save the model
  12. model.save();
  13. model.dispose();
  14. // Set the default editor
  15. IDE.setDefaultEditor(file, IPDEUIConstants.SITE_EDITOR_ID);
  16. return file;
  17. }

代码示例来源:origin: org.eclipse.platform/org.eclipse.ant.ui

  1. @Override
  2. public void handleEvent(Event event) {
  3. switch (event.type) {
  4. case SWT.Selection:
  5. if (menuItem.getSelection()) {
  6. IDE.setDefaultEditor(fileResource, null);
  7. try {
  8. IDE.openEditor(fPage, fileResource, true);
  9. }
  10. catch (PartInitException e) {
  11. AntUIPlugin.log(MessageFormat.format(AntViewActionMessages.AntViewOpenWithMenu_Editor_failed, new Object[] { fileResource.getLocation().toOSString() }), e);
  12. }
  13. }
  14. break;
  15. default:
  16. break;
  17. }
  18. }
  19. };

代码示例来源:origin: org.eclipse.pde/org.eclipse.pde.ui

  1. private IFile generateSchemaFile(String pluginId, String id, String name, boolean shared, String schema, IProgressMonitor monitor) throws CoreException {
  2. IFile schemaFile = null;
  3. IWorkspace workspace = fContainer.getWorkspace();
  4. IPath schemaPath = new Path(schema).removeLastSegments(1);
  5. IPath newSchemaPath = fContainer.getProjectRelativePath().append(schemaPath);
  6. monitor.subTask(PDEUIMessages.BaseExtensionPoint_generating);
  7. if (newSchemaPath.isEmpty() == false) {
  8. IFolder folder = fContainer.getProject().getFolder(newSchemaPath);
  9. CoreUtility.createFolder(folder);
  10. }
  11. IPath filePath = fContainer.getFullPath().append(schema);
  12. schemaFile = workspace.getRoot().getFile(filePath);
  13. InputStream source = createSchemaStream(pluginId, id, name, shared, schemaFile);
  14. if (!schemaFile.exists()) {
  15. // create for the first time
  16. schemaFile.create(source, true, monitor);
  17. } else {
  18. schemaFile.setContents(source, true, false, monitor);
  19. }
  20. IDE.setDefaultEditor(schemaFile, IPDEUIConstants.SCHEMA_EDITOR_ID);
  21. return schemaFile;
  22. }

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide

  1. /**
  2. * Opens the given editor on the selected file.
  3. *
  4. * @param editorDescriptor the editor descriptor, or null for the system editor
  5. * @param openUsingDescriptor use the descriptor's editor ID for opening if false (normal case),
  6. * or use the descriptor itself if true (needed to fix bug 178235).
  7. *
  8. * @since 3.5
  9. */
  10. protected void openEditor(IEditorDescriptor editorDescriptor, boolean openUsingDescriptor) {
  11. IFile file = getFileResource();
  12. if (file == null) {
  13. return;
  14. }
  15. try {
  16. if (openUsingDescriptor) {
  17. ((WorkbenchPage) page).openEditorFromDescriptor(new FileEditorInput(file), editorDescriptor, true, null);
  18. } else {
  19. String editorId = editorDescriptor == null ? IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID
  20. : editorDescriptor.getId();
  21. page.openEditor(new FileEditorInput(file), editorId, true, MATCH_BOTH);
  22. // only remember the default editor if the open succeeds
  23. IDE.setDefaultEditor(file, editorId);
  24. }
  25. } catch (PartInitException e) {
  26. DialogUtil.openError(page.getWorkbenchWindow().getShell(),
  27. IDEWorkbenchMessages.OpenWithMenu_dialogTitle,
  28. e.getMessage(), e);
  29. }
  30. }

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide

  1. case SWT.Selection:
  2. if (menuItem.getSelection()) {
  3. IDE.setDefaultEditor(file, null);
  4. try {
  5. openEditor(IDE.getEditorDescriptor(file, true, true), false);

代码示例来源:origin: org.eclipse.pde/org.eclipse.pde.ui

  1. model.save();
  2. IDE.setDefaultEditor(file, IPDEUIConstants.BUILD_EDITOR_ID);

代码示例来源:origin: org.eclipse.pde/org.eclipse.pde.ui

  1. IDE.setDefaultEditor(file, IPDEUIConstants.FEATURE_EDITOR_ID);
  2. return file;

相关文章