Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » When to save DialogSettings?
When to save DialogSettings? [message #436142] Wed, 12 May 2004 11:06 Go to next message
Ole Laurisch is currently offline Ole LaurischFriend
Messages: 34
Registered: July 2009
Member
Hello NG,

I would like to save some settings of my SWT-Application unsing the class
DialogSettings which implements the general interface IDialogSettings.
Now I am looking for the right moment to save the information. My first
approach was to call my method saveSettings() like this:
Re: When to save DialogSettings? [message #436144 is a reply to message #436142] Wed, 12 May 2004 11:14 Go to previous messageGo to next message
Ole Laurisch is currently offline Ole LaurischFriend
Messages: 34
Registered: July 2009
Member
Sorry, I hit the "Send"-button wrongly. Here is the whole post:

----------------------------------
Hello NG,

I would like to save some settings of my SWT-Application unsing the class
DialogSettings which implements the general interface IDialogSettings.
Now I am looking for the right moment to save the information. My first
approach was to call my method saveSettings() like this:

while (!shell.isDisposed())
{
if (!display.readAndDispatch())
display.sleep();
}
this.saveSettings();
display.dispose();

This will naturally lead to an error, because in the method saveSettings() I
call methods like

settings.put("ColumnWidth0", table.getColumn(0).getWidth());

But the display in already disposed at this moment and so is the table.

Therefor I have to look for another point in time where to save the
settings, but what would be a clever one?
I could call the method saveSettings() everytime I change the size of a
column or change the order of the columns and so on. Then I have to call the
saveSettings()-method at multiple points from nearly every listener. This
seems to be not the best solution for me. What do you think? Any better
idea?


Every idea would be greatly appreciated!

Ole
Re: When to save DialogSettings? [message #436188 is a reply to message #436144] Wed, 12 May 2004 12:49 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Ole,

The shellClosed callback will allow you to do this, like:

shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
// shell about to be disposed, so save settings here
}
});

Grant


"Ole Laurisch" <OIe.Laurisch@NOSPAMt-systems.com> wrote in message
news:c7t0hl$8qh$1@eclipse.org...
> Sorry, I hit the "Send"-button wrongly. Here is the whole post:
>
> ----------------------------------
> Hello NG,
>
> I would like to save some settings of my SWT-Application unsing the class
> DialogSettings which implements the general interface IDialogSettings.
> Now I am looking for the right moment to save the information. My first
> approach was to call my method saveSettings() like this:
>
> while (!shell.isDisposed())
> {
> if (!display.readAndDispatch())
> display.sleep();
> }
> this.saveSettings();
> display.dispose();
>
> This will naturally lead to an error, because in the method saveSettings()
I
> call methods like
>
> settings.put("ColumnWidth0", table.getColumn(0).getWidth());
>
> But the display in already disposed at this moment and so is the table.
>
> Therefor I have to look for another point in time where to save the
> settings, but what would be a clever one?
> I could call the method saveSettings() everytime I change the size of a
> column or change the order of the columns and so on. Then I have to call
the
> saveSettings()-method at multiple points from nearly every listener. This
> seems to be not the best solution for me. What do you think? Any better
> idea?
>
>
> Every idea would be greatly appreciated!
>
> Ole
>
>
Re: When to save DialogSettings? [message #436193 is a reply to message #436188] Wed, 12 May 2004 13:51 Go to previous messageGo to next message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
... or listen for SWT.Dispose on the Display.

"Grant Gayed" <grant_gayed@ca.ibm.com> wrote in message
news:c7t632$g08$1@eclipse.org...
> Ole,
>
> The shellClosed callback will allow you to do this, like:
>
> shell.addShellListener(new ShellAdapter() {
> public void shellClosed(ShellEvent e) {
> // shell about to be disposed, so save settings here
> }
> });
>
> Grant
>
>
> "Ole Laurisch" <OIe.Laurisch@NOSPAMt-systems.com> wrote in message
> news:c7t0hl$8qh$1@eclipse.org...
> > Sorry, I hit the "Send"-button wrongly. Here is the whole post:
> >
> > ----------------------------------
> > Hello NG,
> >
> > I would like to save some settings of my SWT-Application unsing the
class
> > DialogSettings which implements the general interface IDialogSettings.
> > Now I am looking for the right moment to save the information. My first
> > approach was to call my method saveSettings() like this:
> >
> > while (!shell.isDisposed())
> > {
> > if (!display.readAndDispatch())
> > display.sleep();
> > }
> > this.saveSettings();
> > display.dispose();
> >
> > This will naturally lead to an error, because in the method
saveSettings()
> I
> > call methods like
> >
> > settings.put("ColumnWidth0", table.getColumn(0).getWidth());
> >
> > But the display in already disposed at this moment and so is the table.
> >
> > Therefor I have to look for another point in time where to save the
> > settings, but what would be a clever one?
> > I could call the method saveSettings() everytime I change the size of a
> > column or change the order of the columns and so on. Then I have to call
> the
> > saveSettings()-method at multiple points from nearly every listener.
This
> > seems to be not the best solution for me. What do you think? Any better
> > idea?
> >
> >
> > Every idea would be greatly appreciated!
> >
> > Ole
> >
> >
>
>
Re: When to save DialogSettings? [message #436216 is a reply to message #436188] Thu, 13 May 2004 11:41 Go to previous messageGo to next message
Ole Laurisch is currently offline Ole LaurischFriend
Messages: 34
Registered: July 2009
Member
Hello Grant,

"Grant Gayed" <grant_gayed@ca.ibm.com> schrieb:

> The shellClosed callback will allow you to do this, like:
>
> shell.addShellListener(new ShellAdapter() {
> public void shellClosed(ShellEvent e) {
> // shell about to be disposed, so save settings here
> }
> });

Thank you for your quick response! I've tested your code, but then I get
this Exception,
"org.eclipse.swt.SWTException: Widget is disposed"
while I try to read out the settings of a table with this statement:
"table.getColumnCount()".

The table seems to be already disposed. So the shellClosed-Event seems to be
to late.

Is there any summary about the different events and their order in the
runtime of a swt-programm?

Any hint would be appreciated!

Ole
Re: When to save DialogSettings? [message #436218 is a reply to message #436216] Thu, 13 May 2004 13:05 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
This should work for you, the following snippet works for me on win32 and
gtk. If you have a proper case that fails then please log a bug report with
Platform - SWT and include the snippet that shows the failure happening.

public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setBounds(10,10,220,100);
final Table table = new Table(shell, SWT.NONE);
table.setLinesVisible(true);
table.setBounds(10,10,200,50);
new TableColumn(table, SWT.NONE).setWidth(100);
new TableColumn(table, SWT.NONE).setWidth(100);
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
System.out.println("column count: " +
table.getColumnCount());
}
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}

Grant

"Ole Laurisch" <OIe.Laurisch@NOSPAMt-systems.com> wrote in message
news:c7vmfe$e4i$1@eclipse.org...
> Hello Grant,
>
> "Grant Gayed" <grant_gayed@ca.ibm.com> schrieb:
>
> > The shellClosed callback will allow you to do this, like:
> >
> > shell.addShellListener(new ShellAdapter() {
> > public void shellClosed(ShellEvent e) {
> > // shell about to be disposed, so save settings here
> > }
> > });
>
> Thank you for your quick response! I've tested your code, but then I get
> this Exception,
> "org.eclipse.swt.SWTException: Widget is disposed"
> while I try to read out the settings of a table with this statement:
> "table.getColumnCount()".
>
> The table seems to be already disposed. So the shellClosed-Event seems to
be
> to late.
>
> Is there any summary about the different events and their order in the
> runtime of a swt-programm?
>
> Any hint would be appreciated!
>
> Ole
>
>
Previous Topic:about event patch
Next Topic:about swt close
Goto Forum:
  


Current Time: Thu Mar 28 13:15:13 GMT 2024

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

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

Back to the top