Home » Eclipse Projects » Remote Application Platform (RAP) » ActivateEvent verses ShellEvent?
ActivateEvent verses ShellEvent? [message #70865] |
Sun, 20 January 2008 13:37  |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
This is a multi-part message in MIME format.
--------------090102070602080501090807
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Hi,
I made good progress on
https://bugs.eclipse.org/bugs/show_bug.cgi?id=213988 (it's running now,
woo hoo) but I'm having trouble getting activate events when I do the
following for my viewer panes:
control.addListener(SWT.Activate, this);
It seems that when the listener is registered it goes into
public void addListener( final Widget widget,
final int eventType,
final Listener listener )
{
addListener( eventType, listener );
switch( eventType ) {
//...
break;
case SWT.Activate:
case SWT.Deactivate:
case SWT.Close:
*ShellEvent*.addListener( widget, this );
So it treats it as a shell event:
public final class *ShellEvent *extends TypedEvent {
public static final int SHELL_CLOSED = SWT.Close;
public static final int SHELL_ACTIVATED = SWT.Activate;
public static final int SHELL_DEACTIVATED = SWT.Deactivate;
But in Shell.setActiveControl it uses *ActivateEvent *instead:
void setActiveControl( final Control activateControl ) {
Control control = activateControl;
if( control != null && control.isDisposed() ) {
control = null;
}
if( lastActive != null && lastActive.isDisposed() ) {
lastActive = null;
}
if( lastActive != control ) {
// Compute the list of controls to be activated and
deactivated by finding
// the first common parent control.
Control[] activate
= ( control == null ) ? new Control[ 0 ] : control.getPath();
Control[] deactivate
= lastActive == null ? new Control[ 0 ] : lastActive.getPath();
lastActive = control;
int index = 0;
int length = Math.min( activate.length, deactivate.length );
while( index < length && activate[ index ] == deactivate[
index ] ) {
index++;
}
// It is possible (but unlikely), that application code could have
// destroyed some of the widgets. If this happens, keep
processing those
// widgets that are not disposed.
ActivateEvent evt;
for( int i = deactivate.length - 1; i >= index; --i ) {
if( !deactivate[ i ].isDisposed() ) {
evt = new *ActivateEvent*( deactivate[ i ],
ActivateEvent.DEACTIVATED );
evt.processEvent();
}
}
for( int i = activate.length - 1; i >= index; --i ) {
if( !activate[ i ].isDisposed() ) {
evt = new *ActivateEvent*( activate[ i ],
ActivateEvent.ACTIVATED );
evt.processEvent();
}
}
}
}
The activate event applies for the same constants:
public final class ActivateEvent extends TypedEvent {
public static final int ACTIVATED = *SWT.Activate*;
public static final int DEACTIVATED = *SWT.Deactivate*;
I know in a regular workbench I get my activate events from the above
Shell method so I think something is wrong. I tried changing the code
to use ShellEvent and that made my EMF stuff work properly, but it makes
the rest of the workbench misbehave. The following seems to give the
best results for me:
ActivateEvent evt;
* ShellEvent sevt;*
for( int i = deactivate.length - 1; i >= index; --i ) {
if( !deactivate[ i ].isDisposed() ) {
evt = new ActivateEvent( deactivate[ i ],
ActivateEvent.DEACTIVATED );
evt.processEvent();
* sevt = new ShellEvent( deactivate[ i ],
ShellEvent.SHELL_DEACTIVATED );
sevt.processEvent();*
}
}
for( int i = activate.length - 1; i >= index; --i ) {
if( !activate[ i ].isDisposed() ) {
evt = new ActivateEvent( activate[ i ],
ActivateEvent.ACTIVATED );
evt.processEvent();
* sevt = new ShellEvent( activate[ i ],
ShellEvent.SHELL_ACTIVATED );
sevt.processEvent();*
}
}
Is there something wrong or am I doing something wrong? Should I open a
bugzilla?
--------------090102070602080501090807
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi,<br>
<br>
I made good progress on <a
href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=213988">https://bugs.eclipse.org/bugs/show_bug.cgi?id=213988</a>
(it's running now, woo hoo) but I'm having trouble getting activate
events when I do the following for my viewer panes:<br>
<blockquote><small>control.addListener(SWT.Activate, this);</small><br>
</blockquote>
It seems that when the listener is registered it goes into<br>
<blockquote><small> public void addListener( final Widget widget, </small><br>
<small> final int eventType,</small><br>
<small> final Listener listener )</small><br>
<small> {</small><br>
<small> addListener( eventType, listener );</small><br>
<small> switch( eventType ) {</small><br>
<small>//...</small><br>
<small> break;</small><br>
<small> case SWT.Activate:</small><br>
<small> case SWT.Deactivate:</small><br>
<small> case SWT.Close:</small><br>
<small> <b>ShellEvent</b>.addListener( widget, this );</small><br>
</blockquote>
So it treats it as a shell event:<br>
<blockquote>public final class <b>ShellEvent </b>extends TypedEvent {<br>
<br>
public static final int SHELL_CLOSED = SWT.Close;<br>
public static final int SHELL_ACTIVATED = SWT.Activate;<br>
public static final int SHELL_DEACTIVATED = SWT.Deactivate;<br>
</blockquote>
But in Shell.setActiveControl it uses <b>ActivateEvent </b>instead:<br>
<blockquote><small> void setActiveControl( final Control
activateControl ) {</small><br>
<small> Control control = activateControl;</small><br>
<small> if( control != null && control.isDisposed() ) {</small><br>
<small> control = null;</small><br>
<small> }</small><br>
<small> if( lastActive != null && lastActive.isDisposed()
) {</small><br>
<small> lastActive = null;</small><br>
<small> }</small><br>
<small> if( lastActive != control ) {</small><br>
<small> // Compute the list of controls to be activated and
deactivated by finding</small><br>
<small> // the first common parent control.</small><br>
<small> Control[] activate </small><br>
<small> = ( control == null ) ? new Control[ 0 ] :
control.getPath();</small><br>
<small> Control[] deactivate </small><br>
<small> = lastActive == null ? new Control[ 0 ] :
lastActive.getPath();</small><br>
<small> lastActive = control;</small><br>
<small> </small><br>
<small> int index = 0;</small><br>
<small> int length = Math.min( activate.length,
deactivate.length );</small><br>
<small> while( index < length && activate[ index ] ==
deactivate[ index ] ) {</small><br>
<small> index++;</small><br>
<small> }</small><br>
<small> // It is possible (but unlikely), that application code
could have</small><br>
<small> // destroyed some of the widgets. If this happens, keep
processing those</small><br>
<small> // widgets that are not disposed.</small><br>
<small> ActivateEvent evt;</small><br>
<small> for( int i = deactivate.length - 1; i >= index; --i )
{</small><br>
<small> if( !deactivate[ i ].isDisposed() ) {</small><br>
<small> evt = new <b>ActivateEvent</b>( deactivate[ i ],
ActivateEvent.DEACTIVATED );</small><br>
<small> evt.processEvent();</small><br>
<small> }</small><br>
<small> }</small><br>
<small> for( int i = activate.length - 1; i >= index; --i ) {</small><br>
<small> if( !activate[ i ].isDisposed() ) {</small><br>
<small> evt = new <b>ActivateEvent</b>( activate[ i ],
ActivateEvent.ACTIVATED );</small><br>
<small> evt.processEvent();</small><br>
<small> }</small><br>
<small> }</small><br>
<small> }</small><br>
<small> }</small><br>
</blockquote>
The activate event applies for the same constants:<br>
<blockquote><small>public final class ActivateEvent extends TypedEvent {</small><br>
<br>
<small> public static final int ACTIVATED = <b>SWT.Activate</b>;</small><br>
<small> public static final int DEACTIVATED = <b>SWT.Deactivate</b>;</small>
<br>
</blockquote>
I know in a regular workbench I get my activate events from the above
Shell method so I think something is wrong. I tried changing the code
to use ShellEvent and that made my EMF stuff work properly, but it
makes the rest of the workbench misbehave. The following seems to give
the best results for me:<small><br>
</small>
<blockquote><small> ActivateEvent evt;</small><br>
<b><small> ShellEvent sevt;</small></b><br>
<small> for( int i = deactivate.length - 1; i >= index; --i )
{</small><br>
<small> if( !deactivate[ i ].isDisposed() ) {</small><br>
<small> evt = new ActivateEvent( deactivate[ i ],
ActivateEvent.DEACTIVATED );</small><br>
<small> evt.processEvent();</small><br>
<b><small> sevt = new ShellEvent( deactivate[ i ],
ShellEvent.SHELL_DEACTIVATED );</small><br>
<small> sevt.processEvent();</small></b><br>
<small> }</small><br>
<small> }</small><br>
<small> for( int i = activate.length - 1; i >= index; --i ) {</small><br>
<small> if( !activate[ i ].isDisposed() ) {</small><br>
<small> evt = new ActivateEvent( activate[ i ],
ActivateEvent.ACTIVATED );</small><br>
<small> evt.processEvent();</small><br>
<b><small> sevt = new ShellEvent( activate[ i ],
ShellEvent.SHELL_ACTIVATED );</small><br>
<small> sevt.processEvent();</small></b><br>
<small> }</small><br>
<small> }</small><br>
</blockquote>
Is there something wrong or am I doing something wrong? Should I open
a bugzilla?<br>
<br>
</body>
</html>
--------------090102070602080501090807--
|
|
|
Re: ActivateEvent verses ShellEvent? [message #71294 is a reply to message #70865] |
Wed, 23 January 2008 18:50   |
Eclipse User |
|
|
|
Originally posted by: rherrmann.innoopract.com
Ed,
this very much looks like a bug, could you file a bug report as you offered?
In the meantime, to work around this you could add the ActivateListener
like this:
ActivateEvent.addListener( control, this );
Cheers,
Rüdiger
Ed Merks wrote:
> Hi,
>
> I made good progress on
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=213988 (it's running now,
> woo hoo) but I'm having trouble getting activate events when I do the
> following for my viewer panes:
>
> control.addListener(SWT.Activate, this);
>
> It seems that when the listener is registered it goes into
>
> public void addListener( final Widget widget,
> final int eventType,
> final Listener listener )
> {
> addListener( eventType, listener );
> switch( eventType ) {
> //...
> break;
> case SWT.Activate:
> case SWT.Deactivate:
> case SWT.Close:
> *ShellEvent*.addListener( widget, this );
>
> So it treats it as a shell event:
>
> public final class *ShellEvent *extends TypedEvent {
>
> public static final int SHELL_CLOSED = SWT.Close;
> public static final int SHELL_ACTIVATED = SWT.Activate;
> public static final int SHELL_DEACTIVATED = SWT.Deactivate;
>
> But in Shell.setActiveControl it uses *ActivateEvent *instead:
>
> void setActiveControl( final Control activateControl ) {
> Control control = activateControl;
> if( control != null && control.isDisposed() ) {
> control = null;
> }
> if( lastActive != null && lastActive.isDisposed() ) {
> lastActive = null;
> }
> if( lastActive != control ) {
> // Compute the list of controls to be activated and
> deactivated by finding
> // the first common parent control.
> Control[] activate
> = ( control == null ) ? new Control[ 0 ] : control.getPath();
> Control[] deactivate
> = lastActive == null ? new Control[ 0 ] : lastActive.getPath();
> lastActive = control;
>
> int index = 0;
> int length = Math.min( activate.length, deactivate.length );
> while( index < length && activate[ index ] == deactivate[
> index ] ) {
> index++;
> }
> // It is possible (but unlikely), that application code could have
> // destroyed some of the widgets. If this happens, keep
> processing those
> // widgets that are not disposed.
> ActivateEvent evt;
> for( int i = deactivate.length - 1; i >= index; --i ) {
> if( !deactivate[ i ].isDisposed() ) {
> evt = new *ActivateEvent*( deactivate[ i ],
> ActivateEvent.DEACTIVATED );
> evt.processEvent();
> }
> }
> for( int i = activate.length - 1; i >= index; --i ) {
> if( !activate[ i ].isDisposed() ) {
> evt = new *ActivateEvent*( activate[ i ],
> ActivateEvent.ACTIVATED );
> evt.processEvent();
> }
> }
> }
> }
>
> The activate event applies for the same constants:
>
> public final class ActivateEvent extends TypedEvent {
>
> public static final int ACTIVATED = *SWT.Activate*;
> public static final int DEACTIVATED = *SWT.Deactivate*;
>
> I know in a regular workbench I get my activate events from the above
> Shell method so I think something is wrong. I tried changing the code
> to use ShellEvent and that made my EMF stuff work properly, but it makes
> the rest of the workbench misbehave. The following seems to give the
> best results for me:
>
> ActivateEvent evt;
> * ShellEvent sevt;*
> for( int i = deactivate.length - 1; i >= index; --i ) {
> if( !deactivate[ i ].isDisposed() ) {
> evt = new ActivateEvent( deactivate[ i ],
> ActivateEvent.DEACTIVATED );
> evt.processEvent();
> * sevt = new ShellEvent( deactivate[ i ],
> ShellEvent.SHELL_DEACTIVATED );
> sevt.processEvent();*
> }
> }
> for( int i = activate.length - 1; i >= index; --i ) {
> if( !activate[ i ].isDisposed() ) {
> evt = new ActivateEvent( activate[ i ],
> ActivateEvent.ACTIVATED );
> evt.processEvent();
> * sevt = new ShellEvent( activate[ i ],
> ShellEvent.SHELL_ACTIVATED );
> sevt.processEvent();*
> }
> }
>
> Is there something wrong or am I doing something wrong? Should I open a
> bugzilla?
>
|
|
|
Re: ActivateEvent verses ShellEvent? [message #71372 is a reply to message #71294] |
Thu, 24 January 2008 06:57   |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
Rüdiger,
I've filed https://bugs.eclipse.org/bugs/show_bug.cgi?id=216422
The horror. Using an internal class! I feel unclean!! :-P
Rüdiger Herrmann wrote:
> Ed,
>
> this very much looks like a bug, could you file a bug report as you
> offered?
> In the meantime, to work around this you could add the
> ActivateListener like this:
> ActivateEvent.addListener( control, this );
>
> Cheers,
> Rüdiger
>
> Ed Merks wrote:
>> Hi,
>>
>> I made good progress on
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=213988 (it's running
>> now, woo hoo) but I'm having trouble getting activate events when I
>> do the following for my viewer panes:
>>
>> control.addListener(SWT.Activate, this);
>>
>> It seems that when the listener is registered it goes into
>>
>> public void addListener( final Widget widget,
>> final int eventType,
>> final Listener listener )
>> {
>> addListener( eventType, listener );
>> switch( eventType ) {
>> //...
>> break;
>> case SWT.Activate:
>> case SWT.Deactivate:
>> case SWT.Close:
>> *ShellEvent*.addListener( widget, this );
>>
>> So it treats it as a shell event:
>>
>> public final class *ShellEvent *extends TypedEvent {
>>
>> public static final int SHELL_CLOSED = SWT.Close;
>> public static final int SHELL_ACTIVATED = SWT.Activate;
>> public static final int SHELL_DEACTIVATED = SWT.Deactivate;
>>
>> But in Shell.setActiveControl it uses *ActivateEvent *instead:
>>
>> void setActiveControl( final Control activateControl ) {
>> Control control = activateControl;
>> if( control != null && control.isDisposed() ) {
>> control = null;
>> }
>> if( lastActive != null && lastActive.isDisposed() ) {
>> lastActive = null;
>> }
>> if( lastActive != control ) {
>> // Compute the list of controls to be activated and
>> deactivated by finding
>> // the first common parent control.
>> Control[] activate
>> = ( control == null ) ? new Control[ 0 ] :
>> control.getPath();
>> Control[] deactivate
>> = lastActive == null ? new Control[ 0 ] :
>> lastActive.getPath();
>> lastActive = control;
>> int index = 0;
>> int length = Math.min( activate.length, deactivate.length );
>> while( index < length && activate[ index ] == deactivate[
>> index ] ) {
>> index++;
>> }
>> // It is possible (but unlikely), that application code
>> could have
>> // destroyed some of the widgets. If this happens, keep
>> processing those
>> // widgets that are not disposed.
>> ActivateEvent evt;
>> for( int i = deactivate.length - 1; i >= index; --i ) {
>> if( !deactivate[ i ].isDisposed() ) {
>> evt = new *ActivateEvent*( deactivate[ i ],
>> ActivateEvent.DEACTIVATED );
>> evt.processEvent();
>> }
>> }
>> for( int i = activate.length - 1; i >= index; --i ) {
>> if( !activate[ i ].isDisposed() ) {
>> evt = new *ActivateEvent*( activate[ i ],
>> ActivateEvent.ACTIVATED );
>> evt.processEvent();
>> }
>> }
>> }
>> }
>>
>> The activate event applies for the same constants:
>>
>> public final class ActivateEvent extends TypedEvent {
>>
>> public static final int ACTIVATED = *SWT.Activate*;
>> public static final int DEACTIVATED = *SWT.Deactivate*;
>>
>> I know in a regular workbench I get my activate events from the above
>> Shell method so I think something is wrong. I tried changing the
>> code to use ShellEvent and that made my EMF stuff work properly, but
>> it makes the rest of the workbench misbehave. The following seems to
>> give the best results for me:
>>
>> ActivateEvent evt;
>> * ShellEvent sevt;*
>> for( int i = deactivate.length - 1; i >= index; --i ) {
>> if( !deactivate[ i ].isDisposed() ) {
>> evt = new ActivateEvent( deactivate[ i ],
>> ActivateEvent.DEACTIVATED );
>> evt.processEvent();
>> * sevt = new ShellEvent( deactivate[ i ],
>> ShellEvent.SHELL_DEACTIVATED );
>> sevt.processEvent();*
>> }
>> }
>> for( int i = activate.length - 1; i >= index; --i ) {
>> if( !activate[ i ].isDisposed() ) {
>> evt = new ActivateEvent( activate[ i ],
>> ActivateEvent.ACTIVATED );
>> evt.processEvent();
>> * sevt = new ShellEvent( activate[ i ],
>> ShellEvent.SHELL_ACTIVATED );
>> sevt.processEvent();*
>> }
>> }
>>
>> Is there something wrong or am I doing something wrong? Should I
>> open a bugzilla?
>>
|
|
|
Re: ActivateEvent verses ShellEvent? [message #71704 is a reply to message #71372] |
Thu, 24 January 2008 18:54  |
Eclipse User |
|
|
|
Originally posted by: rherrmann.innoopract.com
Ed,
thanks for the bugzilla.
We got plenty of soap here at the office restrooms. And we use it a lot!
It helps to feel quite clean;)
Rüdiger
Ed Merks wrote:
> Rüdiger,
>
> I've filed https://bugs.eclipse.org/bugs/show_bug.cgi?id=216422
>
> The horror. Using an internal class! I feel unclean!! :-P
>
>
> Rüdiger Herrmann wrote:
>> Ed,
>>
>> this very much looks like a bug, could you file a bug report as you
>> offered?
>> In the meantime, to work around this you could add the
>> ActivateListener like this:
>> ActivateEvent.addListener( control, this );
>>
>> Cheers,
>> Rüdiger
>>
>> Ed Merks wrote:
>>> Hi,
>>>
>>> I made good progress on
>>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=213988 (it's running
>>> now, woo hoo) but I'm having trouble getting activate events when I
>>> do the following for my viewer panes:
>>>
>>> control.addListener(SWT.Activate, this);
>>>
>>> It seems that when the listener is registered it goes into
>>>
>>> public void addListener( final Widget widget,
>>> final int eventType,
>>> final Listener listener )
>>> {
>>> addListener( eventType, listener );
>>> switch( eventType ) {
>>> //...
>>> break;
>>> case SWT.Activate:
>>> case SWT.Deactivate:
>>> case SWT.Close:
>>> *ShellEvent*.addListener( widget, this );
>>>
>>> So it treats it as a shell event:
>>>
>>> public final class *ShellEvent *extends TypedEvent {
>>>
>>> public static final int SHELL_CLOSED = SWT.Close;
>>> public static final int SHELL_ACTIVATED = SWT.Activate;
>>> public static final int SHELL_DEACTIVATED = SWT.Deactivate;
>>>
>>> But in Shell.setActiveControl it uses *ActivateEvent *instead:
>>>
>>> void setActiveControl( final Control activateControl ) {
>>> Control control = activateControl;
>>> if( control != null && control.isDisposed() ) {
>>> control = null;
>>> }
>>> if( lastActive != null && lastActive.isDisposed() ) {
>>> lastActive = null;
>>> }
>>> if( lastActive != control ) {
>>> // Compute the list of controls to be activated and
>>> deactivated by finding
>>> // the first common parent control.
>>> Control[] activate
>>> = ( control == null ) ? new Control[ 0 ] :
>>> control.getPath();
>>> Control[] deactivate
>>> = lastActive == null ? new Control[ 0 ] :
>>> lastActive.getPath();
>>> lastActive = control;
>>> int index = 0;
>>> int length = Math.min( activate.length, deactivate.length );
>>> while( index < length && activate[ index ] == deactivate[
>>> index ] ) {
>>> index++;
>>> }
>>> // It is possible (but unlikely), that application code
>>> could have
>>> // destroyed some of the widgets. If this happens, keep
>>> processing those
>>> // widgets that are not disposed.
>>> ActivateEvent evt;
>>> for( int i = deactivate.length - 1; i >= index; --i ) {
>>> if( !deactivate[ i ].isDisposed() ) {
>>> evt = new *ActivateEvent*( deactivate[ i ],
>>> ActivateEvent.DEACTIVATED );
>>> evt.processEvent();
>>> }
>>> }
>>> for( int i = activate.length - 1; i >= index; --i ) {
>>> if( !activate[ i ].isDisposed() ) {
>>> evt = new *ActivateEvent*( activate[ i ],
>>> ActivateEvent.ACTIVATED );
>>> evt.processEvent();
>>> }
>>> }
>>> }
>>> }
>>>
>>> The activate event applies for the same constants:
>>>
>>> public final class ActivateEvent extends TypedEvent {
>>>
>>> public static final int ACTIVATED = *SWT.Activate*;
>>> public static final int DEACTIVATED = *SWT.Deactivate*;
>>>
>>> I know in a regular workbench I get my activate events from the above
>>> Shell method so I think something is wrong. I tried changing the
>>> code to use ShellEvent and that made my EMF stuff work properly, but
>>> it makes the rest of the workbench misbehave. The following seems to
>>> give the best results for me:
>>>
>>> ActivateEvent evt;
>>> * ShellEvent sevt;*
>>> for( int i = deactivate.length - 1; i >= index; --i ) {
>>> if( !deactivate[ i ].isDisposed() ) {
>>> evt = new ActivateEvent( deactivate[ i ],
>>> ActivateEvent.DEACTIVATED );
>>> evt.processEvent();
>>> * sevt = new ShellEvent( deactivate[ i ],
>>> ShellEvent.SHELL_DEACTIVATED );
>>> sevt.processEvent();*
>>> }
>>> }
>>> for( int i = activate.length - 1; i >= index; --i ) {
>>> if( !activate[ i ].isDisposed() ) {
>>> evt = new ActivateEvent( activate[ i ],
>>> ActivateEvent.ACTIVATED );
>>> evt.processEvent();
>>> * sevt = new ShellEvent( activate[ i ],
>>> ShellEvent.SHELL_ACTIVATED );
>>> sevt.processEvent();*
>>> }
>>> }
>>>
>>> Is there something wrong or am I doing something wrong? Should I
>>> open a bugzilla?
>>>
|
|
|
Goto Forum:
Current Time: Sat Aug 30 15:01:38 EDT 2025
Powered by FUDForum. Page generated in 0.03397 seconds
|