Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Invalid Acces
Invalid Acces [message #530038] Wed, 28 April 2010 09:18 Go to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 100
Registered: March 2010
Senior Member
Hello.

I have
TextViewer textViewer=... of a editorPart (editorJava of workbench)

and I have a handler of scroll of a windows too (handlerW).

and I need make in the handler of scroll (handlerW)

textViewer.getTopIndex(index) 

in an handler, but when I try make it, there are a a lot of exception and errors of Unknow source and SWT.ERROR_THREAD_INVALID_ACCESS

the idea is thah whan I move the scroll of windows the TextViewer up or down too.

What can i make?

Thanks a lot


Jose

Re: Invalid Acces [message #530058 is a reply to message #530038] Wed, 28 April 2010 11:01 Go to previous messageGo to next message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
On 28.04.2010 11:18, Jose wrote:
> I have TextViewer textViewer=... of a editorPart (editorJava of workbench)
> and I have a handler of scroll of a windows too (handlerW).
>
> and I need make in the handler of scroll (handlerW)
>
> textViewer.getTopIndex(index) in an handler, but when I try make it,
> there are a a lot of exception and errors of Unknow source and
> SWT.ERROR_THREAD_INVALID_ACCESS
> the idea is thah whan I move the scroll of windows the TextViewer up or
> down too.
>
> What can i make?

SWT uses a single-UI thread model. So, if you need to update the UI at
some dedicated point in the non-UI-thread you need to do that within
a Runnable invoked by either Display.async (usually recommended) or
Display.sync (only, when necessary, because the danger of a dead-lock
exists).

HTH & Greetings from Bremen,

Daniel Krügler
Re: Invalid Acces [message #530078 is a reply to message #530058] Wed, 28 April 2010 12:09 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 100
Registered: March 2010
Senior Member
I'll try and I tell you

Thanks for you help

Jose
Re: Invalid Acces [message #530303 is a reply to message #530078] Thu, 29 April 2010 09:43 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 100
Registered: March 2010
Senior Member
Hello

The handler for the scroll of my windows is
public class AdjusteScroll implements AdjustmentListener
	{
		
		public void adjustmentValueChanged(AdjustmentEvent event)
		{
			final Object object=event.getSource();
			if((object==scrollPane.getVerticalScrollBar())&&(((JScrollBar)object).isEnabled()))
			{
				
				int index=((JScrollBar)object).getValue();
				System.out.println("Entra en manejador"+index);
		
  					                                                      PlatformUI.getWorkbench().getActiveWorkbenchWindow().g  etShell().getDisplay().asyncExec(new Runnable()
    			        {

							@Override
							public void run() 
							{
								int index=((JScrollBar)object).getValue();
								textViewer.setTopIndex(index);
							}
			         });		
			            	   
			 }
			
		}
		
		}


The textViewer is the TextViewer of the activate editor in the workbench. I get the value of Vertical scroll of my windows and I try set it to textViewer using textViewer.setTopIndex(index).

But there are a lot exception still.

Exception and errors:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at com.proyectoJose.VentanaTr.VentanaTr$AdjusteScroll.adjustmentValueChanged(VentanaTr.java:205)
	at javax.swing.JScrollBar.fireAdjustmentValueChanged(Unknown Source)
	at javax.swing.JScrollBar.access$100(Unknown Source)
	at javax.swing.JScrollBar$ModelListener.stateChanged(Unknown Source)
	at javax.swing.DefaultBoundedRangeModel.fireStateChanged(Unknown Source)
	at javax.swing.DefaultBoundedRangeModel.setRangeProperties(Unknown Source)
	at javax.swing.JScrollBar.setValues(Unknown Source)
	at javax.swing.plaf.basic.BasicScrollPaneUI.syncScrollPaneWithViewport(Unknown Source)
	at javax.swing.plaf.basic.BasicScrollPaneUI$Handler.viewportStateChanged(Unknown Source)
	at javax.swing.plaf.basic.BasicScrollPaneUI$Handler.stateChanged(Unknown Source)
	at javax.swing.JViewport.fireStateChanged(Unknown Source)
	at javax.swing.JViewport.reshape(Unknown Source)
	at java.awt.Component.setBounds(Unknown Source)
	at java.awt.Component.setBounds(Unknown Source)
	at javax.swing.ScrollPaneLayout.layoutContainer(Unknown Source)
	at java.awt.Container.layout(Unknown Source)
	at java.awt.Container.doLayout(Unknown Source)
	at java.awt.Container.validateTree(Unknown Source)
	at java.awt.Container.validateTree(Unknown Source)
	at java.awt.Container.validateTree(Unknown Source)
	at java.awt.Container.validateTree(Unknown Source)
	at java.awt.Container.validate(Unknown Source)
	at javax.swing.plaf.metal.MetalRootPaneUI$MouseInputHandler.mouseDragged(Unknown Source)
	at java.awt.Component.processMouseMotionEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Window.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)



I need help, please

Thanks a lot

Jose


Re: Invalid Acces [message #530474 is a reply to message #530303] Thu, 29 April 2010 17:59 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Jose wrote:
> Hello
>
> The handler for the scroll of my windows is
> public class AdjusteScroll implements AdjustmentListener
> {
>
> public void adjustmentValueChanged(AdjustmentEvent event)
> {
> final Object object=event.getSource();
>
> if((object==scrollPane.getVerticalScrollBar())&&(((J ScrollBar)object).isEnabled()))
>
> {
>
> int index=((JScrollBar)object).getValue();
> System.out.println("Entra en manejador"+index);
>
>
> PlatformUI.getWorkbench().getActiveWorkbenchWindow().g
> etShell().getDisplay().asyncExec(new Runnable()
> {
>
> @Override
> public void run() {
> int index=((JScrollBar)object).getValue();

For one thing, don't ask your Swing/AWT widget for data again in the SWT
UI thread ... You should use "final int
index=((JScrollBar)object).getValue();" and then use the final value in
your Runnable


>
> Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
> at
> com.proyectoJose.VentanaTr.VentanaTr$AdjusteScroll.adjustmen tValueChanged(VentanaTr.java:205)
>
> at javax.swing.JScrollBar.fireAdjustmentValueChanged(Unknown Source)

This is an NPE in your AWT thread. That means one part of your chain:
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShel l().getDisplay()
is returning null ... don't do that.

But you can shorten it with PlatformUI.getWorkbench().getDisplay().

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: Invalid Acces [message #530579 is a reply to message #530474] Fri, 30 April 2010 08:36 Go to previous message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 100
Registered: March 2010
Senior Member
Thanks thanks thanks a lot

I have make it

Jose
Previous Topic:Separator for objectContribution
Next Topic:TreeViewer.collapseAll() is slow on OS X
Goto Forum:
  


Current Time: Sat Dec 20 00:54:25 GMT 2014

Powered by FUDForum. Page generated in 0.02492 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software