Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to get a window to front in SWT?
How to get a window to front in SWT? [message #449204] Wed, 19 January 2005 12:46 Go to next message
Eclipse UserFriend
Originally posted by: jb2.403.jb2works.com

Hi,

does anybody know how to get a window in SWT to Front ?
The equivalent AWT command is 'window.toFront()'.

Currently in front is a foreign application window.
I want Eclipse to open a requested source
code and to get the Workbench with the editor to front
on top of the foreign application window.
The behaviour is like to reach a breakpoint.

Source code looks like here yet
...
final IType type = (IType) match.getElement();
final Display display = Display.getDefault();
display.syncExec(new Runnable() {
public void run() {
try {
IEditorPart part= EditorUtility.openInEditor(type, true);
EditorUtility.revealInEditor(part, type);
display.getActiveShell().setActive(); // !!! ...
// ... here i need a toFront() instead but how to do that?
} catch (Exception e){
e.printStackTrace();
};
}
});
...

Thanks in advance,
Regards,
Joerg
Re: How to get a window to front in SWT? [message #449215 is a reply to message #449204] Wed, 19 January 2005 16:10 Go to previous messageGo to next message
Stefan Pietsch is currently offline Stefan PietschFriend
Messages: 68
Registered: July 2009
Member
Hi Joerg,

I think you have to call Shell.setActive()

Bye Stefan

"Joerg Baumgaertel" <jb2.403@jb2works.com> schrieb im Newsbeitrag
news:cslkru$jk0$1@www.eclipse.org...
> Hi,
>
> does anybody know how to get a window in SWT to Front ?
> The equivalent AWT command is 'window.toFront()'.
>
> Currently in front is a foreign application window.
> I want Eclipse to open a requested source
> code and to get the Workbench with the editor to front
> on top of the foreign application window.
> The behaviour is like to reach a breakpoint.
>
> Source code looks like here yet
> ..
> final IType type = (IType) match.getElement();
> final Display display = Display.getDefault();
> display.syncExec(new Runnable() {
> public void run() {
> try {
> IEditorPart part= EditorUtility.openInEditor(type, true);
> EditorUtility.revealInEditor(part, type);
> display.getActiveShell().setActive(); // !!! ...
> // ... here i need a toFront() instead but how to do that?
> } catch (Exception e){
> e.printStackTrace();
> };
> }
> });
> ..
>
> Thanks in advance,
> Regards,
> Joerg
>
>
Re: How to get a window to front in SWT? [message #449216 is a reply to message #449215] Wed, 19 January 2005 16:16 Go to previous messageGo to next message
Stefan Pietsch is currently offline Stefan PietschFriend
Messages: 68
Registered: July 2009
Member
Sorry! I meant Shell.forceActive()

"Stefan Pietsch" <pietsch@multichart.de> schrieb im Newsbeitrag
news:csm0qh$9le$1@www.eclipse.org...
> Hi Joerg,
>
> I think you have to call Shell.setActive()
>
> Bye Stefan
>
> "Joerg Baumgaertel" <jb2.403@jb2works.com> schrieb im Newsbeitrag
> news:cslkru$jk0$1@www.eclipse.org...
> > Hi,
> >
> > does anybody know how to get a window in SWT to Front ?
> > The equivalent AWT command is 'window.toFront()'.
> >
> > Currently in front is a foreign application window.
> > I want Eclipse to open a requested source
> > code and to get the Workbench with the editor to front
> > on top of the foreign application window.
> > The behaviour is like to reach a breakpoint.
> >
> > Source code looks like here yet
> > ..
> > final IType type = (IType) match.getElement();
> > final Display display = Display.getDefault();
> > display.syncExec(new Runnable() {
> > public void run() {
> > try {
> > IEditorPart part= EditorUtility.openInEditor(type, true);
> > EditorUtility.revealInEditor(part, type);
> > display.getActiveShell().setActive(); // !!! ...
> > // ... here i need a toFront() instead but how to do that?
> > } catch (Exception e){
> > e.printStackTrace();
> > };
> > }
> > });
> > ..
> >
> > Thanks in advance,
> > Regards,
> > Joerg
> >
> >
>
>
Re: How to get a window to front in SWT? [message #449220 is a reply to message #449216] Wed, 19 January 2005 17:50 Go to previous message
Eclipse UserFriend
Originally posted by: jb2.403.jb2works.com

Yes, works,

My problem was that
display.getActiveShell() did not work, means returns null
because it did not have the focus at this moment.

So

final Shell[] shells = display.getShells();
shells[shells.length-1].forceActive();

sets the latest shell active and to front - this seems to be
what I need.

Thank you,
Joerg



Stefan Pietsch wrote:

> Sorry! I meant Shell.forceActive()

> "Stefan Pietsch" <pietsch@multichart.de> schrieb im Newsbeitrag
> news:csm0qh$9le$1@www.eclipse.org...
>> Hi Joerg,
>>
>> I think you have to call Shell.setActive()
>>
>> Bye Stefan
>>
>> "Joerg Baumgaertel" <jb2.403@jb2works.com> schrieb im Newsbeitrag
>> news:cslkru$jk0$1@www.eclipse.org...
>> > Hi,
>> >
>> > does anybody know how to get a window in SWT to Front ?
>> > The equivalent AWT command is 'window.toFront()'.
>> >
>> > Currently in front is a foreign application window.
>> > I want Eclipse to open a requested source
>> > code and to get the Workbench with the editor to front
>> > on top of the foreign application window.
>> > The behaviour is like to reach a breakpoint.
>> >
>> > Source code looks like here yet
>> > ..
>> > final IType type = (IType) match.getElement();
>> > final Display display = Display.getDefault();
>> > display.syncExec(new Runnable() {
>> > public void run() {
>> > try {
>> > IEditorPart part= EditorUtility.openInEditor(type, true);
>> > EditorUtility.revealInEditor(part, type);
>> > display.getActiveShell().setActive(); // !!! ...
>> > // ... here i need a toFront() instead but how to do that?
>> > } catch (Exception e){
>> > e.printStackTrace();
>> > };
>> > }
>> > });
>> > ..
>> >
>> > Thanks in advance,
>> > Regards,
>> > Joerg
>> >
>> >
>>
>>
Previous Topic:How do you use FormLayout on a Composite with a Vertical Scrollbar?
Next Topic:Hide columns in table
Goto Forum:
  


Current Time: Fri Nov 22 07:34:48 GMT 2019

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

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

Back to the top