org.eclipse.jface.text.IInputChangedListener Java Examples

The following examples show how to use org.eclipse.jface.text.IInputChangedListener. 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
@Override
public void populateToolbarActions(ToolBarManager tbm, CustomBrowserInformationControl iControl)
{
	final OpenDeclarationAction openDeclarationAction = new OpenDeclarationAction(iControl);
	final OpenHelpAction openHelpAction = new OpenHelpAction(iControl);
	tbm.add(openDeclarationAction);
	tbm.add(openHelpAction);
	IInputChangedListener inputChangeListener = new IInputChangedListener()
	{
		public void inputChanged(Object newInput)
		{
			if (newInput instanceof BrowserInformationControlInput)
			{
				openDeclarationAction.update();
				openHelpAction.update();
			}
		}
	};
	iControl.addInputChangeListener(inputChangeListener);
}
 
Example #2
Source File: DefaultEObjectHoverProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @since 2.3
 */
protected void configureControl(final IXtextBrowserInformationControl control, ToolBarManager tbm, String font){
		final BackAction backAction = new BackAction(control);
		backAction.setEnabled(false);
		tbm.add(backAction);
		final ForwardAction forwardAction = new ForwardAction(control);
		tbm.add(forwardAction);
		forwardAction.setEnabled(false);

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

		//				final SimpleSelectionProvider selectionProvider= new SimpleSelectionProvider();

		IInputChangedListener inputChangeListener = new IInputChangedListener() {
			@Override
			public void inputChanged(Object newInput) {
				backAction.update();
				forwardAction.update();
		
				if (newInput == null) {
					//							selectionProvider.setSelection(new StructuredSelection());
				} else if (newInput instanceof XtextBrowserInformationControlInput) {
					//							XtextBrowserInformationControlInput input= (XtextBrowserInformationControlInput) newInput;
					//							Object inputElement = input.getInputElement();
					//							selectionProvider.setSelection(new StructuredSelection(inputElement));
					//							boolean isJavaElementInput= inputElement instanceof IJavaElement;
					//							showInJavadocViewAction.setEnabled(isJavaElementInput);
					openDeclarationAction.setEnabled(true);
				}
			}
		};
		control.addInputChangeListener(inputChangeListener);
		tbm.update(true);
		addLinkListener(control);
}
 
Example #3
Source File: XbaseHoverProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void configureControl(final IXtextBrowserInformationControl control, ToolBarManager tbm, String font) {
	final BackAction backAction = new BackAction(control);
	backAction.setEnabled(false);
	tbm.add(backAction);
	final ForwardAction forwardAction = new ForwardAction(control);
	tbm.add(forwardAction);
	forwardAction.setEnabled(false);
	final ShowInJavadocViewAction showInJavadocViewAction = new ShowInJavadocViewAction(control);
	tbm.add(showInJavadocViewAction);
	showInJavadocViewAction.setEnabled(false);
	final OpenDeclarationAction openDeclarationAction = new OpenDeclarationAction(control);
	tbm.add(openDeclarationAction);
	IInputChangedListener inputChangeListener = new IInputChangedListener() {
		@Override
		public void inputChanged(Object newInput) {
			backAction.update();
			forwardAction.update();
			if (newInput != null && newInput instanceof XbaseInformationControlInput) {
				openDeclarationAction.setEnabled(true);
				if (((XtextBrowserInformationControlInput) newInput).getInputElement() != null) {
					showInJavadocViewAction.setEnabled(true);
				}
			}
		}
	};
	control.addInputChangeListener(inputChangeListener);
	tbm.update(true);
	addLinkListener(control);
}
 
Example #4
Source File: XtextBrowserInformationControlAdapter.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void addInputChangeListener(IInputChangedListener inputChangeListener) {
	control.addInputChangeListener(inputChangeListener);
}
 
Example #5
Source File: XbaseInformationControl.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Xbase - modification added detailPane
 */
@Override
public void setInput(Object input) {
	Assert.isLegal(input == null || input instanceof String || input instanceof XtextBrowserInformationControlInput, String.valueOf(input));

	if (input instanceof String) {
		setInformation((String) input);
		return;
	}
	if (input instanceof XtextBrowserInformationControlInput)
		fInput = (XtextBrowserInformationControlInput) input;

	String content = null;
	if (fInput != null)
		content = fInput.getHtml();

	fBrowserHasContent = content != null && content.length() > 0;

	if (!fBrowserHasContent)
		content = "<html><body ></html>"; //$NON-NLS-1$

	boolean RTL = (getShell().getStyle() & SWT.RIGHT_TO_LEFT) != 0;
	boolean resizable = isResizable();

	// The default "overflow:auto" would not result in a predictable width for the client area
	// and the re-wrapping would cause visual noise
	String[] styles = null;
	if (RTL && resizable)
		styles = new String[] { "direction:rtl;", "overflow:scroll;", "word-wrap:break-word;" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
	else if (RTL && !resizable)
		styles = new String[] { "direction:rtl;", "overflow:hidden;", "word-wrap:break-word;" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
	else if (!resizable)
		//XXX: In IE, "word-wrap: break-word;" causes bogus wrapping even in non-broken words :-(see e.g. Javadoc of String).
		// Re-check whether we really still need this now that the Javadoc Hover header already sets this style.
		styles = new String[] { "overflow:hidden;"/*, "word-wrap: break-word;"*/}; //$NON-NLS-1$
	else
		styles = new String[] { "overflow:scroll;" }; //$NON-NLS-1$

	StringBuffer buffer = new StringBuffer(content);
	HTMLPrinter.insertStyles(buffer, styles);
	content = buffer.toString();

	/*
	 * XXX: Should add some JavaScript here that shows something like
	 * "(continued...)" or "..." at the end of the visible area when the page overflowed
	 * with "overflow:hidden;".
	 */

	fCompleted = false;
	fBrowser.setText(content);
	String unsugaredExpression = "";
	if (fInput != null && fInput instanceof XbaseInformationControlInput) {
		XbaseInformationControlInput castedInput = (XbaseInformationControlInput) fInput;
		unsugaredExpression = castedInput.getUnsugaredExpression();
		if(unsugaredExpression != null && unsugaredExpression.length() > 0){
			EObject element = fInput.getElement();
			if(element != null && element.eResource() != null && element.eResource().getResourceSet() != null){
				// FIXME: No arguments need when https://bugs.eclipse.org/bugs/show_bug.cgi?id=368827 is solved
				// THEN move to createContent as it was before
				if(embeddedEditorAccess == null)
					embeddedEditorAccess = embeddedEditor.createPartialEditor("", "INITIAL CONTENT", "", false);
				resourceProvider.setContext(((XtextResourceSet) element.eResource().getResourceSet()).getClasspathURIContext());
			} else
				return;
			embeddedEditorAccess.updateModel(castedInput.getPrefix() , unsugaredExpression ,castedInput.getSuffix());
		}
	}

	if (unsugaredExpression != null && unsugaredExpression.length() > 0)
		fSashForm.setWeights(new int[] { 7, 3 });
	else
		fSashForm.setWeights(new int[] { 10, 0 });
	Object[] listeners = fInputChangeListeners.getListeners();
	for (int i = 0; i < listeners.length; i++)
		((IInputChangedListener) listeners[i]).inputChanged(fInput);
	
}
 
Example #6
Source File: XbaseInformationControl.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void setDelayedInputChangeListener(IInputChangedListener inputChangeListener) {
	fDelayedInputChangeListener = inputChangeListener;
}
 
Example #7
Source File: CustomBrowserInformationControl.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * {@inheritDoc} This control can handle {@link String} and {@link BrowserInformationControlInput}.
 */
public void setInput(Object input)
{
	Assert.isLegal(input == null || input instanceof String || input instanceof BrowserInformationControlInput);

	if (input instanceof String)
	{
		setInformation((String) input);
		return;
	}

	fInput = (BrowserInformationControlInput) input;

	String content = null;
	if (fInput != null)
		content = fInput.getHtml();

	fBrowserHasContent = content != null && content.length() > 0;

	if (!fBrowserHasContent)
		content = "<html><body ></html>"; //$NON-NLS-1$

	boolean RTL = (getShell().getStyle() & SWT.RIGHT_TO_LEFT) != 0;
	boolean resizable = isResizable();

	// The default "overflow:auto" would not result in a predictable width for the client area
	// and the re-wrapping would cause visual noise
	String[] styles = null;
	if (RTL && resizable)
		styles = new String[] { "direction:rtl;", "overflow:scroll;", "word-wrap:break-word;" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
	else if (RTL && !resizable)
		styles = new String[] { "direction:rtl;", "overflow:hidden;", "word-wrap:break-word;" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
	else if (!resizable)
		// XXX: In IE, "word-wrap: break-word;" causes bogus wrapping even in non-broken words :-(see e.g. Javadoc
		// of String).
		// Re-check whether we really still need this now that the Javadoc Hover header already sets this style.
		styles = new String[] { "overflow:hidden;"/* , "word-wrap: break-word;" */}; //$NON-NLS-1$
	else
		styles = new String[] { "overflow:scroll;" }; //$NON-NLS-1$

	StringBuffer buffer = new StringBuffer(content);
	HTMLPrinter.insertStyles(buffer, styles);
	content = buffer.toString();

	/*
	 * XXX: Should add some JavaScript here that shows something like "(continued...)" or "..." at the end of the
	 * visible area when the page overflowed with "overflow:hidden;".
	 */

	fCompleted = false;
	fBrowser.setText(content);

	Object[] listeners = fInputChangeListeners.getListeners();
	for (int i = 0; i < listeners.length; i++)
		((IInputChangedListener) listeners[i]).inputChanged(fInput);
}
 
Example #8
Source File: CustomBrowserInformationControl.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public void setDelayedInputChangeListener(IInputChangedListener inputChangeListener)
{
	fDelayedInputChangeListener = inputChangeListener;
}
 
Example #9
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);
	}
}
 
Example #10
Source File: XbaseInformationControl.java    From xtext-eclipse with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Adds a listener for input changes to this input change provider. Has no effect if an identical listener is
 * already registered.
 * 
 * @param inputChangeListener
 *            the listener to add
 * @since 3.4
 */
@Override
public void addInputChangeListener(IInputChangedListener inputChangeListener) {
	Assert.isNotNull(inputChangeListener);
	fInputChangeListeners.add(inputChangeListener);
}
 
Example #11
Source File: XbaseInformationControl.java    From xtext-eclipse with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Removes the given input change listener from this input change provider. Has no effect if an identical listener
 * is not registered.
 * 
 * @param inputChangeListener
 *            the listener to remove
 * @since 3.4
 */
public void removeInputChangeListener(IInputChangedListener inputChangeListener) {
	fInputChangeListeners.remove(inputChangeListener);
}
 
Example #12
Source File: CustomBrowserInformationControl.java    From APICloud-Studio with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Adds a listener for input changes to this input change provider. Has no effect if an identical listener is
 * already registered.
 * 
 * @param inputChangeListener
 *            the listener to add
 * @since 3.4
 */
public void addInputChangeListener(IInputChangedListener inputChangeListener)
{
	Assert.isNotNull(inputChangeListener);
	fInputChangeListeners.add(inputChangeListener);
}
 
Example #13
Source File: CustomBrowserInformationControl.java    From APICloud-Studio with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Removes the given input change listener from this input change provider. Has no effect if an identical listener
 * is not registered.
 * 
 * @param inputChangeListener
 *            the listener to remove
 * @since 3.4
 */
public void removeInputChangeListener(IInputChangedListener inputChangeListener)
{
	fInputChangeListeners.remove(inputChangeListener);
}
 
Example #14
Source File: IXtextBrowserInformationControl.java    From xtext-eclipse with Eclipse Public License 2.0 votes vote down vote up
public void addInputChangeListener(IInputChangedListener inputChangeListener);