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


Java IEditorRegistry类代码示例

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


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

示例1: editFile

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

示例2: openFileInEditor

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

示例3: getEditorId

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

示例4: getEditorId

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

示例5: initializeTitle

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

示例6: initializeTitle

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

示例7: openInEditor

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

示例8: openInEditor

import org.eclipse.ui.IEditorRegistry; //导入依赖的package包/类
/**
 * Open a file in an editor and return the opened editor part.<br>
 * This method will try to open the file in an internal editor, unless there is no editor descriptor assigned to
 * that file type.
 * 
 * @param file
 * @return The {@link IEditorPart} that was created when the file was opened; Return null in case of an error
 */
public static IEditorPart openInEditor(File file)
{
	// NOTE: Moved from PHP's EditorUtils
	if (file == null)
	{
		IdeLog.logError(CommonEditorPlugin.getDefault(),
				"Error open a file in the editor", new IllegalArgumentException("file is null")); //$NON-NLS-1$ //$NON-NLS-2$
		return null;
	}
	try
	{
		URI uri = file.toURI();
		IEditorDescriptor desc = getEditorDescriptor(uri);
		String editorId = (desc == null) ? IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID : desc.getId();
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();

		return IDE.openEditor(page, uri, editorId, true);
	}
	catch (Exception e)
	{
		IdeLog.logError(CommonEditorPlugin.getDefault(), "Error open a file in the editor", e); //$NON-NLS-1$
	}
	return null;
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:33,代码来源:EditorUtil.java

示例9: init

import org.eclipse.ui.IEditorRegistry; //导入依赖的package包/类
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
	setSite(site);
	setInput(input);
	setPartName(input.getName());
	
	Image oldTitleImage = titleImage;
	if (input != null) {
		IEditorRegistry editorRegistry = PlatformUI.getWorkbench().getEditorRegistry();
		IEditorDescriptor editorDesc = editorRegistry.findEditor(getSite().getId());
		ImageDescriptor imageDesc = editorDesc != null ? editorDesc.getImageDescriptor() : null;
		titleImage = imageDesc != null ? imageDesc.createImage() : null;
	}

	setTitleImage(titleImage);
	if (oldTitleImage != null && !oldTitleImage.isDisposed()) {
		oldTitleImage.dispose();
	}

	FileEditorInput fileInput = (FileEditorInput) input;
	htmlUrl = fileInput.getFile().getLocation().toOSString();
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:23,代码来源:HtmlBrowserEditor.java

示例10: init

import org.eclipse.ui.IEditorRegistry; //导入依赖的package包/类
/**
 * 启动编辑器。
 * 
 * @param site
 *            the site
 * @param input
 *            the input
 * @throws PartInitException
 *             the part init exception
 * @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite,
 *      org.eclipse.ui.IEditorInput)
 */
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
	if (LOGGER.isDebugEnabled()) {
		LOGGER.debug("init(IEditorSite site, IEditorInput input)");
	}
	setSite(site);
	setInput(input);
	// 设置Editor标题栏的显示名称,否则名称用plugin.xml中的name属性
	setPartName(input.getName());

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

	setTitleImage(titleImage);
	if (oldTitleImage != null && !oldTitleImage.isDisposed()) {
		oldTitleImage.dispose();
	}

	getSite().setSelectionProvider(this);
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:37,代码来源:XLIFFEditor.java

示例11: getEditorId

import org.eclipse.ui.IEditorRegistry; //导入依赖的package包/类
private String getEditorId( IFileStore file )
{
	IWorkbench workbench = window.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 );
	}

	return ( descriptor == null ) ? "" : descriptor.getId( ); //$NON-NLS-1$
}
 
开发者ID:eclipse,项目名称:birt,代码行数:24,代码来源:OpenJavaSourceAction.java

示例12: openFiles

import org.eclipse.ui.IEditorRegistry; //导入依赖的package包/类
@Override
protected void openFiles(PythonpathZipChildTreeNode[] pythonPathFilesSelected) {
    for (PythonpathZipChildTreeNode n : pythonPathFilesSelected) {
        try {
            if (PythonPathHelper.isValidSourceFile(n.zipPath)) {
                new PyOpenAction().run(new ItemPointer(n.zipStructure.file, new Location(), new Location(), null,
                        n.zipPath));
            } else {
                IEditorRegistry editorReg = PlatformUI.getWorkbench().getEditorRegistry();
                IEditorDescriptor defaultEditor = editorReg.getDefaultEditor(n.zipPath);
                PydevZipFileStorage storage = new PydevZipFileStorage(n.zipStructure.file, n.zipPath);
                PydevZipFileEditorInput input = new PydevZipFileEditorInput(storage);

                if (defaultEditor != null) {
                    IDE.openEditor(page, input, defaultEditor.getId());
                } else {
                    IDE.openEditor(page, input, EditorsUI.DEFAULT_TEXT_EDITOR_ID);
                }
            }
        } catch (PartInitException e) {
            Log.log(e);
        }
    }
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:25,代码来源:PyOpenResourceAction.java

示例13: getEditorId

import org.eclipse.ui.IEditorRegistry; //导入依赖的package包/类
@Override
public String getEditorId(IEditorInput input, Object element) {
    IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
    if (element instanceof IFile) {
        IFile file = (IFile)element;
        return registry.getDefaultEditor(file.getName()).getId();
    } else if (element instanceof ILineBreakpoint) {
        String fileName = ((ILineBreakpoint)element).getMarker().getResource().getName();
        return registry.getDefaultEditor(fileName).getId();
    } else if (element instanceof IStorage) {
        IStorage storage = (IStorage)element;
        return registry.getDefaultEditor(storage.getName()).getId();
    } else if (element instanceof URL) {
        URL url = (URL)element;
        return registry.getDefaultEditor(url.getFile()).getId();
    }
    return null;
}
 
开发者ID:konsoletyper,项目名称:teavm,代码行数:19,代码来源:TeaVMDebugModelPresentation.java

示例14: openEditor

import org.eclipse.ui.IEditorRegistry; //导入依赖的package包/类
protected final IEditorPart openEditor(String filePath) throws PartInitException {

        IPath location = Path.fromOSString(filePath);

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

        String editorId = IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID;
        IEditorDescriptor editorDescriptor = getWorkbench().getEditorRegistry().getDefaultEditor(filePath);
        if (editorDescriptor != null) {
            editorId = editorDescriptor.getId();
        }

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

示例15: getEditorDescriptor

import org.eclipse.ui.IEditorRegistry; //导入依赖的package包/类
/**
 * Returns the {@link IEditorDescriptor} associated with this input's editor id.
 * 
 * @return The {@link IEditorDescriptor} for the editor id.
 */
protected IEditorDescriptor getEditorDescriptor() {
    String editorId = getEditorId();
    if (editorId == null) {
        return null;
    }

    IWorkbench workBench = PlatformUI.getWorkbench();
    IEditorRegistry editorRegistry = workBench.getEditorRegistry();
    IEditorDescriptor editorDescriptor = editorRegistry.findEditor(editorId);
    return editorDescriptor;
}
 
开发者ID:baloise,项目名称:eZooKeeper,代码行数:17,代码来源:BaseEditorInput.java


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