Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Display browser component to a new shell
Display browser component to a new shell [message #463488] Tue, 08 November 2005 10:29 Go to next message
Valerio Schiavoni is currently offline Valerio SchiavoniFriend
Messages: 9
Registered: July 2009
Junior Member
Hello, this is my first post.

I have this internal class:
class XPathListener implements SelectionListener {

public void widgetSelected(SelectionEvent arg0) {
this.widgetDefaultSelected(arg0); // forward to default
}

public void widgetDefaultSelected(SelectionEvent arg0) {
xpath = text.getText();

if (!fragmentsBrowserShell.isVisible())
fragmentsBrowserShell.open();
fragmentsBrowser.setText(getDocument().getContent(), xpath);
}

}

This class is used within a subclass of Composite, called
XPathControllerBar,
where i do something like this:
private void initializeFragmentsBrowser() {
fragmentsBrowserShell = new Shell();
fragmentsBrowserShell.setText("XPath Fragments");
fragmentsBrowser = new FragmentsBrowser(fragmentsBrowserShell,
SWT.NONE);
}

where fragmentsBrowser is an istance of this class:


public class FragmentsBrowser extends Composite implements Observer {

private Browser fragmentsBrowser = null;

public FragmentsBrowser(Composite parent, int style) {
super(parent, style);

initialize();

}


private void initialize() {

createBrowser();
initializeLayout();
}


private void initializeLayout() {

FormLayout layout = new FormLayout();
this.setLayout(layout);

FormData browserData = new FormData();
browserData.top = new FormAttachment(0, 25);
browserData.right = new FormAttachment(100, -10);
browserData.bottom = new FormAttachment(100, -10);
browserData.left = new FormAttachment(0, 10);
fragmentsBrowser.setLayoutData(browserData);
}


private void createBrowser() {

fragmentsBrowser = new Browser(this, SWT.NONE);
fragmentsBrowser.setToolTipText("Embedded Mozilla for xpath results");
}

public void setText(String html, String xpath) {

fragmentsBrowser.setText("<html><head><title>test
title</title></head><body>test</body></html>");

}

public void update(Observable o, Object arg) {


}

}



Now, when the event of a click (or enter) is caught by the XPathListener,
a new shell is opened (that is, a new application window, don't sure about
the terminology), but the content of the browser is not rendered.

Any help is very appreciated.

Thanks,
valerio
Re: Display browser component to a new shell [message #463494 is a reply to message #463488] Tue, 08 November 2005 12:07 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
You need to have a layout on the fragmentsBrowserShell. Do you have
something like:

fragmentsBrowserShell.setLayout(new FillLayout());


"Valerio Schiavoni" <valerio.schiavoni@gmail.com> wrote in message
news:243567b8254598a7abd1e727afd29475$1@www.eclipse.org...
> Hello, this is my first post.
>
> I have this internal class:
> class XPathListener implements SelectionListener {
>
> public void widgetSelected(SelectionEvent arg0) {
> this.widgetDefaultSelected(arg0); // forward to default
> }
>
> public void widgetDefaultSelected(SelectionEvent arg0) {
> xpath = text.getText();
> if (!fragmentsBrowserShell.isVisible())
> fragmentsBrowserShell.open();
> fragmentsBrowser.setText(getDocument().getContent(), xpath);
> }
>
> }
>
> This class is used within a subclass of Composite, called
> XPathControllerBar,
> where i do something like this:
> private void initializeFragmentsBrowser() {
> fragmentsBrowserShell = new Shell();
> fragmentsBrowserShell.setText("XPath Fragments");
> fragmentsBrowser = new FragmentsBrowser(fragmentsBrowserShell,
> SWT.NONE);
> }
>
> where fragmentsBrowser is an istance of this class:
>
>
> public class FragmentsBrowser extends Composite implements Observer {
> private Browser fragmentsBrowser = null;
> public FragmentsBrowser(Composite parent, int style) {
> super(parent, style);
> initialize();
> }
>
> private void initialize() {
> createBrowser();
> initializeLayout();
> }
>
>
> private void initializeLayout() {
> FormLayout layout = new FormLayout();
> this.setLayout(layout);
>
> FormData browserData = new FormData();
> browserData.top = new FormAttachment(0, 25);
> browserData.right = new FormAttachment(100, -10);
> browserData.bottom = new FormAttachment(100, -10);
> browserData.left = new FormAttachment(0, 10);
> fragmentsBrowser.setLayoutData(browserData);
> }
>
>
> private void createBrowser() {
> fragmentsBrowser = new Browser(this, SWT.NONE);
> fragmentsBrowser.setToolTipText("Embedded Mozilla for xpath results");
> }
>
> public void setText(String html, String xpath) {
> fragmentsBrowser.setText("<html><head><title>test
> title</title></head><body>test</body></html>");
>
> }
>
> public void update(Observable o, Object arg) {
> }
>
> }
>
>
>
> Now, when the event of a click (or enter) is caught by the XPathListener,
> a new shell is opened (that is, a new application window, don't sure about
> the terminology), but the content of the browser is not rendered.
>
> Any help is very appreciated.
>
> Thanks,
> valerio
>
Re: Display browser component to a new shell [message #463498 is a reply to message #463494] Tue, 08 November 2005 13:39 Go to previous messageGo to next message
Valerio Schiavoni is currently offline Valerio SchiavoniFriend
Messages: 9
Registered: July 2009
Junior Member
Hello,
Veronika Irvine wrote:

> fragmentsBrowserShell.setLayout(new FillLayout());

thanks now the new shell is displayed.
the problem is that if i close it, and i try to perform the same action
(that is, a click on a button, caught by the XPathListener) i got the
exception:

Exception in thread "main" org.eclipse.swt.SWTException: Widget is disposed
at org.eclipse.swt.SWT.error(SWT.java:3251)
at org.eclipse.swt.SWT.error(SWT.java:3174)
at org.eclipse.swt.SWT.error(SWT.java:3145)
at org.eclipse.swt.widgets.Widget.error(Widget.java:419)
at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:357)
at org.eclipse.swt.widgets.Shell.isVisible(Shell.java:599)
at
jfrr.xpathvisualizer.XPathControlBar$XPathListener.widgetDef aultSelected(XPathControlBar.java:38)
at
jfrr.xpathvisualizer.XPathControlBar$XPathListener.widgetSel ected(XPathControlBar.java:32)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:90)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1050)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:2909)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2605)
at jfrr.xpathvisualizer.XPathMain.main(XPathMain.java:61)

The error come from this line:
if (!fragmentsBrowserShell.isVisible())

i suppose i misunderstood the semantic of that method.
What i wanted to obtain was that if a user closes the windows, clicking
on the button should re-open it.

Thanks for any help,
valerio


>
>
> "Valerio Schiavoni" <valerio.schiavoni@gmail.com> wrote in message
> news:243567b8254598a7abd1e727afd29475$1@www.eclipse.org...
>
>>Hello, this is my first post.
>>
>>I have this internal class:
>>class XPathListener implements SelectionListener {
>>
>> public void widgetSelected(SelectionEvent arg0) {
>> this.widgetDefaultSelected(arg0); // forward to default
>> }
>>
>> public void widgetDefaultSelected(SelectionEvent arg0) {
>> xpath = text.getText();
>> if (!fragmentsBrowserShell.isVisible())
>> fragmentsBrowserShell.open();
>> fragmentsBrowser.setText(getDocument().getContent(), xpath);
>> }
>>
>>}
>>
>>This class is used within a subclass of Composite, called
>>XPathControllerBar,
>>where i do something like this:
>>private void initializeFragmentsBrowser() {
>> fragmentsBrowserShell = new Shell();
>> fragmentsBrowserShell.setText("XPath Fragments");
>> fragmentsBrowser = new FragmentsBrowser(fragmentsBrowserShell,
>>SWT.NONE);
>>}
>>
>>where fragmentsBrowser is an istance of this class:
>>
>>
>>public class FragmentsBrowser extends Composite implements Observer {
>> private Browser fragmentsBrowser = null;
>> public FragmentsBrowser(Composite parent, int style) {
>> super(parent, style);
>> initialize();
>> }
>>
>> private void initialize() {
>> createBrowser();
>> initializeLayout();
>> }
>>
>>
>> private void initializeLayout() {
>> FormLayout layout = new FormLayout();
>> this.setLayout(layout);
>>
>> FormData browserData = new FormData();
>> browserData.top = new FormAttachment(0, 25);
>> browserData.right = new FormAttachment(100, -10);
>> browserData.bottom = new FormAttachment(100, -10);
>> browserData.left = new FormAttachment(0, 10);
>> fragmentsBrowser.setLayoutData(browserData);
>> }
>>
>>
>> private void createBrowser() {
>> fragmentsBrowser = new Browser(this, SWT.NONE);
>> fragmentsBrowser.setToolTipText("Embedded Mozilla for xpath results");
>> }
>>
>>public void setText(String html, String xpath) {
>> fragmentsBrowser.setText("<html><head><title>test
>>title</title></head><body>test</body></html>");
>>
>>}
>>
>> public void update(Observable o, Object arg) {
>> }
>>
>>}
>>
>>
>>
>>Now, when the event of a click (or enter) is caught by the XPathListener,
>>a new shell is opened (that is, a new application window, don't sure about
>>the terminology), but the content of the browser is not rendered.
>>
>>Any help is very appreciated.
>>
>>Thanks,
>>valerio
>>
>
>
>
Re: Display browser component to a new shell [message #463508 is a reply to message #463498] Tue, 08 November 2005 14:55 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: friederich.kupzog.de

Maybe using setVisible() instead of open/close helps?
Regards,
Friederich

Valerio Schiavoni wrote:
> Hello,
> Veronika Irvine wrote:
>
>
>>fragmentsBrowserShell.setLayout(new FillLayout());
>
>
> thanks now the new shell is displayed.
> the problem is that if i close it, and i try to perform the same action
> (that is, a click on a button, caught by the XPathListener) i got the
> exception:
>
> Exception in thread "main" org.eclipse.swt.SWTException: Widget is disposed
> at org.eclipse.swt.SWT.error(SWT.java:3251)
> at org.eclipse.swt.SWT.error(SWT.java:3174)
> at org.eclipse.swt.SWT.error(SWT.java:3145)
> at org.eclipse.swt.widgets.Widget.error(Widget.java:419)
> at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:357)
> at org.eclipse.swt.widgets.Shell.isVisible(Shell.java:599)
> at
> jfrr.xpathvisualizer.XPathControlBar$XPathListener.widgetDef aultSelected(XPathControlBar.java:38)
> at
> jfrr.xpathvisualizer.XPathControlBar$XPathListener.widgetSel ected(XPathControlBar.java:32)
> at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:90)
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1050)
> at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:2909)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2605)
> at jfrr.xpathvisualizer.XPathMain.main(XPathMain.java:61)
>
> The error come from this line:
> if (!fragmentsBrowserShell.isVisible())
>
> i suppose i misunderstood the semantic of that method.
> What i wanted to obtain was that if a user closes the windows, clicking
> on the button should re-open it.
>
> Thanks for any help,
> valerio
>
>
>
>>
>>"Valerio Schiavoni" <valerio.schiavoni@gmail.com> wrote in message
>>news:243567b8254598a7abd1e727afd29475$1@www.eclipse.org...
>>
>>
>>>Hello, this is my first post.
>>>
>>>I have this internal class:
>>>class XPathListener implements SelectionListener {
>>>
>>> public void widgetSelected(SelectionEvent arg0) {
>>> this.widgetDefaultSelected(arg0); // forward to default
>>> }
>>>
>>> public void widgetDefaultSelected(SelectionEvent arg0) {
>>> xpath = text.getText();
>>> if (!fragmentsBrowserShell.isVisible())
>>> fragmentsBrowserShell.open();
>>> fragmentsBrowser.setText(getDocument().getContent(), xpath);
>>> }
>>>
>>>}
>>>
>>>This class is used within a subclass of Composite, called
>>>XPathControllerBar,
>>>where i do something like this:
>>>private void initializeFragmentsBrowser() {
>>> fragmentsBrowserShell = new Shell();
>>> fragmentsBrowserShell.setText("XPath Fragments");
>>> fragmentsBrowser = new FragmentsBrowser(fragmentsBrowserShell,
>>>SWT.NONE);
>>>}
>>>
>>>where fragmentsBrowser is an istance of this class:
>>>
>>>
>>>public class FragmentsBrowser extends Composite implements Observer {
>>>private Browser fragmentsBrowser = null;
>>>public FragmentsBrowser(Composite parent, int style) {
>>> super(parent, style);
>>> initialize();
>>> }
>>>
>>>private void initialize() {
>>> createBrowser();
>>> initializeLayout();
>>>}
>>>
>>>
>>>private void initializeLayout() {
>>> FormLayout layout = new FormLayout();
>>> this.setLayout(layout);
>>>
>>> FormData browserData = new FormData();
>>> browserData.top = new FormAttachment(0, 25);
>>> browserData.right = new FormAttachment(100, -10);
>>> browserData.bottom = new FormAttachment(100, -10);
>>> browserData.left = new FormAttachment(0, 10);
>>> fragmentsBrowser.setLayoutData(browserData);
>>>}
>>>
>>>
>>>private void createBrowser() {
>>> fragmentsBrowser = new Browser(this, SWT.NONE);
>>> fragmentsBrowser.setToolTipText("Embedded Mozilla for xpath results");
>>>}
>>>
>>>public void setText(String html, String xpath) {
>>> fragmentsBrowser.setText("<html><head><title>test
>>>title</title></head><body>test</body></html>");
>>>
>>>}
>>>
>>>public void update(Observable o, Object arg) {
>>> }
>>>
>>>}
>>>
>>>
>>>
>>>Now, when the event of a click (or enter) is caught by the XPathListener,
>>>a new shell is opened (that is, a new application window, don't sure about
>>>the terminology), but the content of the browser is not rendered.
>>>
>>>Any help is very appreciated.
>>>
>>>Thanks,
>>>valerio
>>>
>>
>>
>>


--
Friederich Kupzog
Elektronik & Software
Neusser Str. 5-7
50670 Köln
Tel 0241 160696-1
Fax 0221 726670
www.kupzog.de/fkmk
Re: Display browser component to a new shell [message #463511 is a reply to message #463498] Tue, 08 November 2005 15:57 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
When the shell is closed, it is disposed.

If you wish to resuse the shell, you should stop it from disposing on close
e.g.

fragmentsBrowserShell.addListener(SWT.Close, new Listener() {
public void handleEvent(Event e) {
e.doit = false;
fragmentsBrowserShell.setVisible(false);
}
});

"Valerio Schiavoni" <valerio.schiavoni@gmail.com> wrote in message
news:dkq9r9$cp4$1@news.eclipse.org...
> Hello,
> Veronika Irvine wrote:
>
>> fragmentsBrowserShell.setLayout(new FillLayout());
>
> thanks now the new shell is displayed.
> the problem is that if i close it, and i try to perform the same action
> (that is, a click on a button, caught by the XPathListener) i got the
> exception:
>
> Exception in thread "main" org.eclipse.swt.SWTException: Widget is
> disposed
> at org.eclipse.swt.SWT.error(SWT.java:3251)
> at org.eclipse.swt.SWT.error(SWT.java:3174)
> at org.eclipse.swt.SWT.error(SWT.java:3145)
> at org.eclipse.swt.widgets.Widget.error(Widget.java:419)
> at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:357)
> at org.eclipse.swt.widgets.Shell.isVisible(Shell.java:599)
> at
> jfrr.xpathvisualizer.XPathControlBar$XPathListener.widgetDef aultSelected(XPathControlBar.java:38)
> at
> jfrr.xpathvisualizer.XPathControlBar$XPathListener.widgetSel ected(XPathControlBar.java:32)
> at
> org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:90)
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1050)
> at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:2909)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2605)
> at jfrr.xpathvisualizer.XPathMain.main(XPathMain.java:61)
>
> The error come from this line:
> if (!fragmentsBrowserShell.isVisible())
>
> i suppose i misunderstood the semantic of that method.
> What i wanted to obtain was that if a user closes the windows, clicking
> on the button should re-open it.
>
> Thanks for any help,
> valerio
>
>
>>
>>
>> "Valerio Schiavoni" <valerio.schiavoni@gmail.com> wrote in message
>> news:243567b8254598a7abd1e727afd29475$1@www.eclipse.org...
>>
>>>Hello, this is my first post.
>>>
>>>I have this internal class:
>>>class XPathListener implements SelectionListener {
>>>
>>> public void widgetSelected(SelectionEvent arg0) {
>>> this.widgetDefaultSelected(arg0); // forward to default
>>> }
>>>
>>> public void widgetDefaultSelected(SelectionEvent arg0) {
>>> xpath = text.getText();
>>> if (!fragmentsBrowserShell.isVisible())
>>> fragmentsBrowserShell.open();
>>> fragmentsBrowser.setText(getDocument().getContent(), xpath);
>>> }
>>>
>>>}
>>>
>>>This class is used within a subclass of Composite, called
>>>XPathControllerBar,
>>>where i do something like this:
>>>private void initializeFragmentsBrowser() {
>>> fragmentsBrowserShell = new Shell();
>>> fragmentsBrowserShell.setText("XPath Fragments");
>>> fragmentsBrowser = new FragmentsBrowser(fragmentsBrowserShell,
>>>SWT.NONE);
>>>}
>>>
>>>where fragmentsBrowser is an istance of this class:
>>>
>>>
>>>public class FragmentsBrowser extends Composite implements Observer {
>>> private Browser fragmentsBrowser = null;
>>> public FragmentsBrowser(Composite parent, int style) {
>>> super(parent, style);
>>> initialize();
>>> }
>>>
>>> private void initialize() {
>>> createBrowser();
>>> initializeLayout();
>>> }
>>>
>>>
>>> private void initializeLayout() {
>>> FormLayout layout = new FormLayout();
>>> this.setLayout(layout);
>>>
>>> FormData browserData = new FormData();
>>> browserData.top = new FormAttachment(0, 25);
>>> browserData.right = new FormAttachment(100, -10);
>>> browserData.bottom = new FormAttachment(100, -10);
>>> browserData.left = new FormAttachment(0, 10);
>>> fragmentsBrowser.setLayoutData(browserData);
>>> }
>>>
>>>
>>> private void createBrowser() {
>>> fragmentsBrowser = new Browser(this, SWT.NONE);
>>> fragmentsBrowser.setToolTipText("Embedded Mozilla for xpath results");
>>> }
>>>
>>>public void setText(String html, String xpath) {
>>> fragmentsBrowser.setText("<html><head><title>test
>>>title</title></head><body>test</body></html>");
>>>
>>>}
>>>
>>> public void update(Observable o, Object arg) {
>>> }
>>>
>>>}
>>>
>>>
>>>
>>>Now, when the event of a click (or enter) is caught by the XPathListener,
>>>a new shell is opened (that is, a new application window, don't sure
>>>about
>>>the terminology), but the content of the browser is not rendered.
>>>
>>>Any help is very appreciated.
>>>
>>>Thanks,
>>>valerio
>>>
>>
>>
>>
Re: Display browser component to a new shell [message #463592 is a reply to message #463511] Thu, 10 November 2005 13:15 Go to previous message
Valerio Schiavoni is currently offline Valerio SchiavoniFriend
Messages: 9
Registered: July 2009
Junior Member
Hello Veronika,

> fragmentsBrowserShell.addListener(SWT.Close, new Listener() {
> public void handleEvent(Event e) {
> e.doit = false;
> fragmentsBrowserShell.setVisible(false);
> }
> });

thanks a lot, this fixed my problem.

Valerio
Previous Topic:SWT for Nokia's new Linux-devices?
Next Topic:Problem about composite size
Goto Forum:
  


Current Time: Fri Apr 26 17:29:18 GMT 2024

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

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

Back to the top