Java Code Examples for org.eclipse.ui.IEditorRegistry#findEditor()

The following examples show how to use org.eclipse.ui.IEditorRegistry#findEditor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestEditor.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
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();
    }
 
Example 2
Source File: SVNConflictResolver.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example 3
Source File: HtmlBrowserEditor.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
@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();
}
 
Example 4
Source File: XLIFFEditor.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 启动编辑器。
 * 
 * @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);
}
 
Example 5
Source File: HtmlBrowserEditor.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
@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();
}
 
Example 6
Source File: XLIFFEditor.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 启动编辑器。
 * 
 * @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);
}
 
Example 7
Source File: OpenJavaSourceAction.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
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$
}
 
Example 8
Source File: TestEditor.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
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();
	}
 
Example 9
Source File: OriginalEditorSelector.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected IEditorDescriptor getXtextEditor(URI uri) {
	IResourceServiceProvider serviceProvider = resourceServiceProviderRegistry.getResourceServiceProvider(uri);
	if (serviceProvider != null) {
		XtextEditorInfo editorInfo = serviceProvider.get(XtextEditorInfo.class);
		if (editorInfo != null) {
			IEditorRegistry editorRegistry = workbench.getEditorRegistry();
			IEditorDescriptor result = editorRegistry.findEditor(editorInfo.getEditorId());
			return result; // null is ok
		}
	}
	return null;
}
 
Example 10
Source File: XtextEditor.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Image getDefaultImage() {
	IEditorRegistry editorRegistry = PlatformUI.getWorkbench().getEditorRegistry();
	IEditorDescriptor editorDesc = editorRegistry.findEditor(getSite().getId());
	ImageDescriptor imageDesc = editorDesc != null ? editorDesc.getImageDescriptor() : null;
	return imageDesc != null ? imageHelper.getImage(imageDesc) : super.getDefaultImage();
}
 
Example 11
Source File: EditorInputTransferDragAdapter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void dragStart(DragSourceEvent event) {
	fEditorInputDatas= new ArrayList<EditorInputData>();

	ISelection selection= fProvider.getSelection();
	if (selection instanceof IStructuredSelection) {
		IStructuredSelection structuredSelection= (IStructuredSelection) selection;
		for (Iterator<?> iter= structuredSelection.iterator(); iter.hasNext();) {
			Object element= iter.next();
			IEditorInput editorInput= EditorUtility.getEditorInput(element);
			if (editorInput != null && editorInput.getPersistable() != null) {
				try {
					String editorId= EditorUtility.getEditorID(editorInput);
					// see org.eclipse.ui.internal.ide.EditorAreaDropAdapter.openNonExternalEditor(..):
					IEditorRegistry editorReg= PlatformUI.getWorkbench().getEditorRegistry();
					IEditorDescriptor editorDesc= editorReg.findEditor(editorId);
					if (editorDesc != null && !editorDesc.isOpenExternal()) {
						fEditorInputDatas.add(EditorInputTransfer.createEditorInputData(editorId, editorInput));
					}
				} catch (PartInitException e) {
					JavaPlugin.log(e);
				}
			}
		}
	}

	event.doit= fEditorInputDatas.size() > 0;
}
 
Example 12
Source File: XLFEditor.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
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);

	cursorIbeam = new Cursor(null, SWT.CURSOR_IBEAM);
	cursorArrow = new Cursor(null, SWT.CURSOR_ARROW);

	hookListener();
}
 
Example 13
Source File: XLFEditor.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
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);

	cursorIbeam = new Cursor(null, SWT.CURSOR_IBEAM);
	cursorArrow = new Cursor(null, SWT.CURSOR_ARROW);

	hookListener();
}