Java Code Examples for org.eclipse.ui.IEditorDescriptor#getImageDescriptor()

The following examples show how to use org.eclipse.ui.IEditorDescriptor#getImageDescriptor() . 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: 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 3
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 4
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 5
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 6
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 7
Source File: DefaultEditorImageUtil.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public ImageDescriptor getDefaultEditorImageDescriptor(String fileName) {
	if (fileName != null && workbench != null) {
		IEditorDescriptor defaultEditor = workbench.getEditorRegistry().getDefaultEditor(fileName);
		if (defaultEditor != null) {
			return defaultEditor.getImageDescriptor();
		} else {
			return workbench.getEditorRegistry().getSystemExternalEditorImageDescriptor(fileName);
		}
	}
	return null;
}
 
Example 8
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 9
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 10
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();
}
 
Example 11
Source File: GoNavigatorLabelProvider.java    From goclipse with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected DefaultGetImageSwitcher getBaseImage_switcher() {
	return new DefaultGetImageSwitcher() {
		
		@Override
		public ImageDescriptor visitResource(IResource resource) {
			return getResourceImageDescriptor(resource);
		}
		
		@Override
		public ImageDescriptor visitGoPathElement(GoPathElement goPathElement) {
			if(goPathElement instanceof GoRootElement) {
				return GoPluginImages.NAV_LibraryNative;
			}
			if(goPathElement instanceof GoPathEntryElement) {
				return GoPluginImages.NAVIGATOR_GOPATH_ENTRY.getDescriptor();
			}
			throw assertFail();
		}

		@Override
		public ImageDescriptor visitFileStoreElement(IFileStore fileStore) {
			try {
				if (fileStore.fetchInfo().isDirectory()) {
					return GoPluginImages.NAV_SourceFolder;
				}
				
				// TODO: should cleanup/review this.
				
				IEditorDescriptor descriptor = IDE.getEditorDescriptor(fileStore.getName(), true, false);
				if (descriptor != null) {
					return descriptor.getImageDescriptor();
				} else {
					IWorkbench workbench = PlatformUI.getWorkbench();
					return workbench.getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FILE);
				}
			} catch (PartInitException e) {
			}
			return null;
		}
		
		@Override
		public ImageDescriptor visitBundleElement(IBundleModelElement bundleElement) {
			return new BundleModelGetImageSwitcher() {
				
			}.switchBundleElement(bundleElement);
		}
		
	};
}