类org.eclipse.jface.text.IInputChangedListener源码实例Demo

下面列出了怎么用org.eclipse.jface.text.IInputChangedListener的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: APICloud-Studio   文件: JSTextHover.java
@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);
}
 
/**
 * @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);
}
 
源代码3 项目: xtext-eclipse   文件: XbaseHoverProvider.java
@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);
}
 
@Override
public void addInputChangeListener(IInputChangedListener inputChangeListener) {
	control.addInputChangeListener(inputChangeListener);
}
 
源代码5 项目: xtext-eclipse   文件: XbaseInformationControl.java
/**
 * 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);
	
}
 
源代码6 项目: xtext-eclipse   文件: XbaseInformationControl.java
@Override
public void setDelayedInputChangeListener(IInputChangedListener inputChangeListener) {
	fDelayedInputChangeListener = inputChangeListener;
}
 
/**
 * {@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);
}
 
public void setDelayedInputChangeListener(IInputChangedListener inputChangeListener)
{
	fDelayedInputChangeListener = inputChangeListener;
}
 
@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);
	}
}
 
源代码10 项目: xtext-eclipse   文件: XbaseInformationControl.java
/**
 * 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);
}
 
源代码11 项目: xtext-eclipse   文件: XbaseInformationControl.java
/**
 * 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);
}
 
/**
 * 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);
}
 
/**
 * 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);
}
 
public void addInputChangeListener(IInputChangedListener inputChangeListener); 
 类所在包
 同包方法