Search in sources :

Example 1 with IEditorRegistry

use of org.eclipse.ui.IEditorRegistry in project translationstudio8 by heartsome.

the class XLIFFEditor method init.

/**
	 * 启动编辑器。
	 * 
	 * @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);
}
Also used : IEditorDescriptor(org.eclipse.ui.IEditorDescriptor) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) Image(org.eclipse.swt.graphics.Image) IEditorRegistry(org.eclipse.ui.IEditorRegistry)

Example 2 with IEditorRegistry

use of org.eclipse.ui.IEditorRegistry in project xtext-eclipse by eclipse.

the class OriginalEditorSelector method getXtextEditor.

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());
            // null is ok
            return result;
        }
    }
    return null;
}
Also used : IResourceServiceProvider(org.eclipse.xtext.resource.IResourceServiceProvider) IEditorDescriptor(org.eclipse.ui.IEditorDescriptor) XtextEditorInfo(org.eclipse.xtext.ui.editor.XtextEditorInfo) IEditorRegistry(org.eclipse.ui.IEditorRegistry)

Example 3 with IEditorRegistry

use of org.eclipse.ui.IEditorRegistry in project xtext-eclipse by eclipse.

the class XtextEditor method getDefaultImage.

@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();
}
Also used : IEditorDescriptor(org.eclipse.ui.IEditorDescriptor) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) IEditorRegistry(org.eclipse.ui.IEditorRegistry)

Example 4 with IEditorRegistry

use of org.eclipse.ui.IEditorRegistry in project eclipse.platform.text by eclipse.

the class UntitledTextFileWizard method getEditorId.

private String getEditorId(IFileStore fileStore) {
    IWorkbench workbench = fWindow.getWorkbench();
    IEditorRegistry editorRegistry = workbench.getEditorRegistry();
    IEditorDescriptor descriptor = editorRegistry.getDefaultEditor(fileStore.getName());
    if (descriptor != null)
        return descriptor.getId();
    return EditorsUI.DEFAULT_TEXT_EDITOR_ID;
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) IEditorDescriptor(org.eclipse.ui.IEditorDescriptor) IEditorRegistry(org.eclipse.ui.IEditorRegistry)

Example 5 with IEditorRegistry

use of org.eclipse.ui.IEditorRegistry in project eclipse.platform.text by eclipse.

the class AbstractTextEditor method initializeTitle.

/**
 * Initializes the editor's title based on the given editor input.
 * <p>
 * <strong>Note:</strong> We use the editor's image instead of the image from the
 * editor input to distinguish situations where the same editor input is
 * opened in different kinds of editors.
 * </p>
 *
 * @param input the editor input to be used
 */
private void initializeTitle(IEditorInput input) {
    Image oldImage = fTitleImage;
    fTitleImage = null;
    // $NON-NLS-1$
    String title = "";
    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();
}
Also used : IEditorDescriptor(org.eclipse.ui.IEditorDescriptor) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) Image(org.eclipse.swt.graphics.Image) IEditorRegistry(org.eclipse.ui.IEditorRegistry)

Aggregations

IEditorRegistry (org.eclipse.ui.IEditorRegistry)19 IEditorDescriptor (org.eclipse.ui.IEditorDescriptor)18 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)7 IWorkbench (org.eclipse.ui.IWorkbench)7 IContentType (org.eclipse.core.runtime.content.IContentType)5 Image (org.eclipse.swt.graphics.Image)5 InputStream (java.io.InputStream)2 Path (org.eclipse.core.runtime.Path)2 Point (org.eclipse.swt.graphics.Point)2 IEditorPart (org.eclipse.ui.IEditorPart)2 IStorageEditorInput (org.eclipse.ui.IStorageEditorInput)2 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)2 FileEditorInput (org.eclipse.ui.part.FileEditorInput)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 URL (java.net.URL)1 IFile (org.eclipse.core.resources.IFile)1 CoreException (org.eclipse.core.runtime.CoreException)1