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


Java IEditorDescriptor.getId方法代码示例

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


在下文中一共展示了IEditorDescriptor.getId方法的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: 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

示例8: openInEditor

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

import org.eclipse.ui.IEditorDescriptor; //导入方法依赖的package包/类
/**
 * find a prefer editor from all existing editors according to the
 * fileExtensions
 * 
 * @param fileExtension
 * @return
 */
private String findPreferEditor(RouteResourceInput fileEditorInput) {
	String editorId = RouteResourceEditor.ID;

	Object underlingFile = fileEditorInput.getAdapter(IFile.class);
	if (underlingFile == null) {
		return editorId;
	}

	IEditorDescriptor ed = null;
	try {
		ed = IDE.getEditorDescriptor((IFile) underlingFile, true);
	} catch (PartInitException e) {
		return editorId;
	}
	if (ed == null) {
		return editorId;
	}
	String id = ed.getId();
	if (id == null || id.trim() == null) {
		return editorId;
	}
	return id;
}
 
开发者ID:Talend,项目名称:tesb-studio-se,代码行数:31,代码来源:RouteResourceEditorUtil.java

示例10: getEditorId

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

示例11: 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:fabioz,项目名称:Pydev,代码行数:26,代码来源:EditorOpener.java

示例12: openEditor

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

示例13: getEditorId

import org.eclipse.ui.IEditorDescriptor; //导入方法依赖的package包/类
private String getEditorId(String filePath) {
	IEditorRegistry editorRegistry = PlatformUI.getWorkbench().getEditorRegistry();
	IEditorDescriptor desc = editorRegistry.getDefaultEditor(filePath);
	if (desc == null) {
		desc = editorRegistry.getDefaultEditor(filePath + ".txt");
	}
	return desc.getId();
}
 
开发者ID:eclipse,项目名称:scanning,代码行数:9,代码来源:DefaultScanResultsHandler.java

示例14: getEditorId

import org.eclipse.ui.IEditorDescriptor; //导入方法依赖的package包/类
private String getEditorId(IEditorInput input) {
	try {
		IEditorDescriptor descriptor = IDE.getEditorDescriptor(input.getName(), true, true);
		return descriptor.getId();
	} catch (PartInitException e) {
		return null;
	}
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:9,代码来源:GotoJavaBookmarkMarker.java

示例15: openFile

import org.eclipse.ui.IEditorDescriptor; //导入方法依赖的package包/类
/**
     * Opens an editor on the given file resource.
     *
     * @param file the file resource
     */
    void openFile(IFile file) {
    	IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    	
    	FileEditorInput editorInput = null;
    	
//		IEditorReference[] editors = activePage.getEditorReferences();
//		for (IEditorReference editorReference : editors) {
//			IEditorInput input;
//			try {
//				input = editorReference.getEditorInput();
//			if (input instanceof FileEditorInput) {
//				FileEditorInput fileEditorInput = (FileEditorInput) input;
//				if(fileEditorInput.getStorage().getFullPath().equals(file.getFullPath())) {
//					editorInput = fileEditorInput;
//				}
//			}
//			} catch (PartInitException e) {
//				// TODO Auto-generated catch block
//				e.printStackTrace();
//			} catch (CoreException e) {
//				// TODO Auto-generated catch block
//				e.printStackTrace();
//			}
//		}
		
    	if(editorInput==null) {
    		editorInput = new FileEditorInput(file);
    	}
    	
   	 	IEditorDescriptor editor = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getName());
     	String editorId = editor==null ? "org.eclipse.ui.DefaultTextEditor" : editor.getId();
    	try {
			activePage.openEditor(editorInput, editorId);
		} catch (PartInitException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
    }
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:44,代码来源:OpenFileAction.java


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