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


Java IEditorDescriptor类代码示例

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


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

示例1: updateDefaultEditorMappingIfAbsent

import org.eclipse.ui.IEditorDescriptor; //导入依赖的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: getEditorID

import org.eclipse.ui.IEditorDescriptor; //导入依赖的package包/类
/**
 * Gets the default editor ID for the given {@link IEditorInput} and element.
 * 
 * @param input
 *            the {@link IEditorInput}
 * @param element
 *            the element
 * @return the default editor ID for the given {@link IEditorInput} and element if any, <code>null</code>
 *         otherwise
 */
public static String getEditorID(IEditorInput input, Object element) {
	final String res;
	if (input instanceof URIEditorInput) {
		res = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(
				((URIEditorInput)input).getURI().lastSegment()).getId();
	} else if (input instanceof IFileEditorInput) {
		IEditorDescriptor defaultEditor = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(
				((IFileEditorInput)input).getFile().getName());
		if (defaultEditor != null) {
			res = defaultEditor.getId();
		} else {
			res = "org.eclipse.emf.ecore.presentation.ReflectiveEditorID";
		}
	} else {
		res = null;
	}
	return res;
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:29,代码来源:EMFEditorUtils.java

示例3: editFile

import org.eclipse.ui.IEditorDescriptor; //导入依赖的package包/类
public static IEditorPart editFile(File file, boolean preferIdeEditor) throws IOException, PartInitException {

        if (file == null || !file.exists() || !file.isFile() || !file.canRead()) {
            throw new IOException("Invalid file: '" + file + "'");
        }

        IWorkbench workBench = PlatformUI.getWorkbench();
        IWorkbenchPage page = workBench.getActiveWorkbenchWindow().getActivePage();
        IPath location = Path.fromOSString(file.getAbsolutePath());

        IFileStore fileStore = EFS.getLocalFileSystem().getStore(location);
        FileStoreEditorInput fileStoreEditorInput = new FileStoreEditorInput(fileStore);

        String editorId = IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID;
        if (preferIdeEditor) {
            IEditorDescriptor editorDescriptor = workBench.getEditorRegistry().getDefaultEditor(file.getName());
            if (editorDescriptor != null) {
                editorId = editorDescriptor.getId();
            }
        }

        return page.openEditor(fileStoreEditorInput, editorId);
    }
 
开发者ID:baloise,项目名称:eZooKeeper,代码行数:24,代码来源:FileEditor.java

示例4: openFileInEditor

import org.eclipse.ui.IEditorDescriptor; //导入依赖的package包/类
protected void openFileInEditor(IFile file, IWorkbenchWindow workbenchWindow, IWorkbenchPage page) throws PartInitException{
		IEditorRegistry editorRegistry = workbench.getEditorRegistry();
		FileEditorInput fileEditorInput = new FileEditorInput(file);
		
		IPath filePath = file.getFullPath();
		String filePathString = filePath.toString();
		
		IEditorDescriptor defaultEditor = editorRegistry.getDefaultEditor(filePathString);
		String defaultEditorId = defaultEditor.getId();
		
		page.openEditor(fileEditorInput, defaultEditorId);					 	 

//		Shell shell = workbenchWindow.getShell();
//		String title = "Error";
//		String message = exception.getMessage();
//		MessageDialog.openError(shell, title, message);
	}
 
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:18,代码来源:DwFeatureModelWizard.java

示例5: getEditorId

import org.eclipse.ui.IEditorDescriptor; //导入依赖的package包/类
private String getEditorId(IFileStore file) {
//		IWorkbench workbench= fWindow.getWorkbench();
		IWorkbench workbench = PlatformUI.getWorkbench();
		IEditorRegistry editorRegistry= workbench.getEditorRegistry();
		IEditorDescriptor descriptor= editorRegistry.getDefaultEditor(file.getName(), getContentType(file));

		// check the OS for in-place editor (OLE on Win32)
		if (descriptor == null && editorRegistry.isSystemInPlaceEditorAvailable(file.getName()))
			descriptor= editorRegistry.findEditor(IEditorRegistry.SYSTEM_INPLACE_EDITOR_ID);
		
		// check the OS for external editor
		if (descriptor == null && editorRegistry.isSystemExternalEditorAvailable(file.getName()))
			descriptor= editorRegistry.findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);
		
		if (descriptor != null)
			return descriptor.getId();
		
		return EditorsUI.DEFAULT_TEXT_EDITOR_ID;
	}
 
开发者ID:subclipse,项目名称:subclipse,代码行数:20,代码来源:SVNConflictResolver.java

示例6: getEditorId

import org.eclipse.ui.IEditorDescriptor; //导入依赖的package包/类
private String getEditorId(IFileStore file) {
	IWorkbench workbench = PlatformUI.getWorkbench();
	IEditorRegistry editorRegistry= workbench.getEditorRegistry();
	IEditorDescriptor descriptor= editorRegistry.getDefaultEditor(file.getName(), getContentType(file));

	// check the OS for in-place editor (OLE on Win32)
	if (descriptor == null && editorRegistry.isSystemInPlaceEditorAvailable(file.getName()))
		descriptor= editorRegistry.findEditor(IEditorRegistry.SYSTEM_INPLACE_EDITOR_ID);
	
	// check the OS for external editor
	if (descriptor == null && editorRegistry.isSystemExternalEditorAvailable(file.getName()))
		descriptor= editorRegistry.findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);
	
	if (descriptor != null)
		return descriptor.getId();
	
	return EditorsUI.DEFAULT_TEXT_EDITOR_ID;
}
 
开发者ID:subclipse,项目名称:subclipse,代码行数:19,代码来源:SVNConflictResolver.java

示例7: initializeTitle

import org.eclipse.ui.IEditorDescriptor; //导入依赖的package包/类
private void initializeTitle(final IEditorInput input) {

        final Image oldImage = fTitleImage;
        fTitleImage = null;
        String title = ""; //$NON-NLS-1$

        if (input != null) {
            final IEditorRegistry editorRegistry = PlatformUI.getWorkbench().getEditorRegistry();
            final IEditorDescriptor editorDesc = editorRegistry.findEditor(getSite().getId());
            final ImageDescriptor imageDesc = editorDesc != null ? editorDesc.getImageDescriptor() : null;

            fTitleImage = imageDesc != null ? imageDesc.createImage() : null;
            title = input.getName();
        }

        setTitleImage(fTitleImage);
        setPartName(title);

        firePropertyChange(PROP_DIRTY);

        if (oldImage != null && !oldImage.isDisposed())
            oldImage.dispose();
    }
 
开发者ID:roundrop,项目名称:ermasterr,代码行数:24,代码来源:TestEditor.java

示例8: initializeTitle

import org.eclipse.ui.IEditorDescriptor; //导入依赖的package包/类
private void initializeTitle(IEditorInput input) {

		Image oldImage = fTitleImage;
		fTitleImage = null;
		String title = ""; //$NON-NLS-1$

		if (input != null) {
			IEditorRegistry editorRegistry = PlatformUI.getWorkbench()
					.getEditorRegistry();
			IEditorDescriptor editorDesc = editorRegistry.findEditor(getSite()
					.getId());
			ImageDescriptor imageDesc = editorDesc != null ? editorDesc
					.getImageDescriptor() : null;

			fTitleImage = imageDesc != null ? imageDesc.createImage() : null;
			title = input.getName();
		}

		setTitleImage(fTitleImage);
		setPartName(title);

		firePropertyChange(PROP_DIRTY);

		if (oldImage != null && !oldImage.isDisposed())
			oldImage.dispose();
	}
 
开发者ID:kozake,项目名称:ermaster-k,代码行数:27,代码来源:TestEditor.java

示例9: openAndSelect

import org.eclipse.ui.IEditorDescriptor; //导入依赖的package包/类
public IEditorPart openAndSelect(IWorkbenchPage wbPage, IFile file, int offset, int length, boolean activate) throws PartInitException {
	String editorId= null;
	IEditorDescriptor desc= IDE.getEditorDescriptor(file);
	if (desc == null || !desc.isInternal()) {
		editorId= "org.eclipse.ui.DefaultTextEditor"; //$NON-NLS-1$
	} else {
		editorId= desc.getId();
	}

	IEditorPart editor;
	if (NewSearchUI.reuseEditor()) {
		editor= showWithReuse(file, wbPage, editorId, activate);
	} else {
		editor= showWithoutReuse(file, wbPage, editorId, activate);
	}

	if (editor instanceof ITextEditor) {
		ITextEditor textEditor= (ITextEditor) editor;
		textEditor.selectAndReveal(offset, length);
	} else if (editor != null) {
		showWithMarker(editor, file, offset, length);
	}
	return editor;
}
 
开发者ID:angelozerr,项目名称:typescript.java,代码行数:25,代码来源:EditorOpener.java

示例10: getImageDescriptor

import org.eclipse.ui.IEditorDescriptor; //导入依赖的package包/类
/**
 * Returns the image descriptor for the given editor descriptor, or
 * <code>null</code> if it has no image.
 */
private ImageDescriptor getImageDescriptor(IEditorDescriptor editorDesc) {
	ImageDescriptor imageDesc = null;
	if (editorDesc == null) {
		imageDesc = fRegistry.getImageDescriptor(fNode.getBuildFile()
				.getBuildFileResource().getName());
	} else {
		imageDesc = editorDesc.getImageDescriptor();
	}
	if (imageDesc == null && editorDesc != null) {
		if (editorDesc.getId().equals(SYSTEM_EDITOR_ID)) {
			imageDesc = getSystemEditorImageDescriptor(fNode.getBuildFile()
					.getBuildFileResource().getFileExtension());
		}
	}
	return imageDesc;
}
 
开发者ID:angelozerr,项目名称:jsbuild-eclipse,代码行数:21,代码来源:BuildFileOpenWithMenu.java

示例11: openInEditor

import org.eclipse.ui.IEditorDescriptor; //导入依赖的package包/类
public static void openInEditor(IWorkbenchPage page,
		IEditorDescriptor editorDescriptor, IJSBuildFileNode node) {
	IEditorPart editorPart = null;
	IFile fileResource = node.getBuildFile().getBuildFileResource();
	try {
		if (editorDescriptor == null) {
			editorPart = page.openEditor(new FileEditorInput(fileResource),
					IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);
		} else {
			editorPart = page.openEditor(new FileEditorInput(fileResource),
					editorDescriptor.getId());
		}
	} catch (PartInitException e) {
		Logger.logException(MessageFormat.format(
				JSBuildFileUIMessages.JSBuildFileUtil_0,
				new Object[] { fileResource.getLocation().toOSString() }),
				e);
	}
	revealInEditor(editorPart, node, page);
}
 
开发者ID:angelozerr,项目名称:jsbuild-eclipse,代码行数:21,代码来源:EditorUtility.java

示例12: openEditor

import org.eclipse.ui.IEditorDescriptor; //导入依赖的package包/类
/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * 
 * @generated
 */
public static boolean openEditor(IWorkbench workbench, URI uri) {
  IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
  IWorkbenchPage page = workbenchWindow.getActivePage();

  IEditorDescriptor editorDescriptor = EditUIUtil.getDefaultEditor(uri, null);
  if (editorDescriptor == null) {
    MessageDialog.openError(workbenchWindow.getShell(), getString("_UI_Error_title"), getString("_WARN_No_Editor", uri.lastSegment()));
    return false;
  } else {
    try {
      page.openEditor(new URIEditorInput(uri), editorDescriptor.getId());
    } catch (PartInitException exception) {
      MessageDialog.openError(workbenchWindow.getShell(), getString("_UI_OpenEditorError_label"), exception.getMessage());
      return false;
    }
  }
  return true;
}
 
开发者ID:eclipse,项目名称:triquetrum,代码行数:24,代码来源:TriquetrumEditorAdvisor.java

示例13: openEditor

import org.eclipse.ui.IEditorDescriptor; //导入依赖的package包/类
/**
 * Opens a subdiagram for a given {@link Diagram}
 */
public static IEditorPart openEditor(Diagram diagramToOpen) {
	IFile file = WorkspaceSynchronizer.getFile(diagramToOpen.eResource());
	try {
		IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getName());
		final IWorkbenchPage wbPage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
		if (diagramToOpen.getElement() instanceof Statechart) {
			return wbPage.openEditor(new FileEditorInput(file), desc.getId());
		} else if (diagramToOpen.getElement() instanceof State) {
			return wbPage.openEditor(new DiagramEditorInput(diagramToOpen), desc.getId());
		}
	} catch (PartInitException e) {
		e.printStackTrace();
	}
	return null;
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:19,代码来源:DiagramPartitioningUtil.java

示例14: openConceptDefinition

import org.eclipse.ui.IEditorDescriptor; //导入依赖的package包/类
private boolean openConceptDefinition(EObject eobj, String stepText) {
	GaugeWorkspace gaugeWorkspace = GaugePlugin.getDefault()
			.getGaugeWorkspace();
	IProject project = getProjectFor(eobj);
	ConceptData concept = gaugeWorkspace.searchConcept(project, stepText);
	if (concept != null) {
		IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench()
				.getActiveWorkbenchWindow();
		IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
		File file = new File(concept.getFilePath());
		try {
			IEditorDescriptor desc = PlatformUI.getWorkbench()
					.getEditorRegistry().getDefaultEditor(file.getName());
			IEditorPart editor = IDE.openEditor(activePage, file.toURI(), desc.getId(), true);
			goToLineNumber(editor, concept.getLineNumber());
		} catch (PartInitException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return true;
	}
	return false;
}
 
开发者ID:getgauge-contrib,项目名称:Gauge-Eclipse,代码行数:24,代码来源:SpecHyperlinkHelper.java

示例15: resetDefaultEditor

import org.eclipse.ui.IEditorDescriptor; //导入依赖的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


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