Java Code Examples for org.eclipse.jface.internal.text.html.BrowserInformationControlInput#getInputElement()

The following examples show how to use org.eclipse.jface.internal.text.html.BrowserInformationControlInput#getInputElement() . 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: JSTextHover.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Update the action
 */
void update()
{
	properties = null;
	BrowserInformationControlInput input = iControl.getInput();
	if (input instanceof DocumentationBrowserInformationControlInput)
	{
		Object inputElement = input.getInputElement();
		if (inputElement instanceof IParseNode)
		{
			properties = JSModelUtil.getProperties((AbstractThemeableEditor) getEditor(),
					(IParseNode) inputElement);
		}
	}
	setEnabled(!CollectionsUtil.isEmpty(properties));
}
 
Example 2
Source File: HTMLTextHover.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Update the action
 */
void update()
{
	node = null;
	BrowserInformationControlInput input = iControl.getInput();
	if (input instanceof DocumentationBrowserInformationControlInput)
	{
		Object inputElement = input.getInputElement();
		if (inputElement instanceof BaseElement)
		{
			node = (BaseElement) inputElement;
		}
	}
	setEnabled(node != null);
}
 
Example 3
Source File: JavadocHover.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public IInformationControl doCreateInformationControl(Shell parent) {
	if (BrowserInformationControl.isAvailable(parent)) {
		ToolBarManager tbm= new ToolBarManager(SWT.FLAT);
		String font= PreferenceConstants.APPEARANCE_JAVADOC_FONT;
		BrowserInformationControl iControl= new BrowserInformationControl(parent, font, tbm);

		final BackAction backAction= new BackAction(iControl);
		backAction.setEnabled(false);
		tbm.add(backAction);
		final ForwardAction forwardAction= new ForwardAction(iControl);
		tbm.add(forwardAction);
		forwardAction.setEnabled(false);

		final ShowInJavadocViewAction showInJavadocViewAction= new ShowInJavadocViewAction(iControl);
		tbm.add(showInJavadocViewAction);
		final OpenDeclarationAction openDeclarationAction= new OpenDeclarationAction(iControl);
		tbm.add(openDeclarationAction);

		final SimpleSelectionProvider selectionProvider= new SimpleSelectionProvider();
		if (fSite != null) {
			OpenAttachedJavadocAction openAttachedJavadocAction= new OpenAttachedJavadocAction(fSite);
			openAttachedJavadocAction.setSpecialSelectionProvider(selectionProvider);
			openAttachedJavadocAction.setImageDescriptor(JavaPluginImages.DESC_ELCL_OPEN_BROWSER);
			openAttachedJavadocAction.setDisabledImageDescriptor(JavaPluginImages.DESC_DLCL_OPEN_BROWSER);
			selectionProvider.addSelectionChangedListener(openAttachedJavadocAction);
			selectionProvider.setSelection(new StructuredSelection());
			tbm.add(openAttachedJavadocAction);
		}

		IInputChangedListener inputChangeListener= new IInputChangedListener() {
			public void inputChanged(Object newInput) {
				backAction.update();
				forwardAction.update();
				if (newInput == null) {
					selectionProvider.setSelection(new StructuredSelection());
				} else if (newInput instanceof BrowserInformationControlInput) {
					BrowserInformationControlInput input= (BrowserInformationControlInput) newInput;
					Object inputElement= input.getInputElement();
					selectionProvider.setSelection(new StructuredSelection(inputElement));
					boolean isJavaElementInput= inputElement instanceof IJavaElement;
					showInJavadocViewAction.setEnabled(isJavaElementInput);
					openDeclarationAction.setEnabled(isJavaElementInput);
				}
			}
		};
		iControl.addInputChangeListener(inputChangeListener);

		tbm.update(true);

		addLinkListener(iControl);
		return iControl;

	} else {
		return new DefaultInformationControl(parent, true);
	}
}