Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [platform-swt-dev] BusyIndicator.showWhile() doesn't show wai t cursor

>Snippet? 

import java.io.File;
import java.io.BufferedReader;
import java.io.FileReader;
import org.eclipse.swt.*;
import org.eclipse.swt.custom.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.events.*;

public class FormatCarveout extends Object
{
    protected Display display;
    protected Shell shell;
    protected Text inputFileName;
    protected Table inputTable;
    protected Table outputTable;
    ...
    
    fileDialogButton.addSelectionListener(new SelectionAdapter()
        {
            public void widgetSelected(SelectionEvent e)
            {
                FileDialog dialog = new FileDialog (shell, SWT.OPEN);
                dialog.setFilterNames (new String [] {"Comma Seperated
Files", "All Files (*.*)"});
                dialog.setFilterExtensions (new String [] {"*.csv", "*.*"});
                dialog.open();
                String fileName = dialog.getFileName();
                String fullFileName = dialog.getFilterPath() +
File.separator + dialog.getFileName();
                
                if (null == fileName || "".equals(fileName))
                {
                    System.out.println("No File selected");
                }
                else
                {
                    inputFileName.setText(fullFileName);
                    loadCarveouts(fullFileName);
                    System.out.println("File selected: " + fullFileName);
                }
            }
        });
    ...
}

    public void loadCarveouts(String fileName)
    {
        try
        {
            BufferedReader inf = new BufferedReader(new
FileReader(fileName));
            inputTable.removeAll();
            LoadCarveout loadCSV = new LoadCarveout(inputTable, inf);
            BusyIndicator.showWhile(null, loadCSV);
        }
        catch (Exception x)
        {
            x.printStackTrace();
        }
    }


import java.io.BufferedReader;
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.graphics.*;

public class LoadCarveout implements Runnable
{
    protected Table table;
    protected BufferedReader input;
    
    public LoadCarveout(Table table, BufferedReader input)
    {
        this.table = table;
        this.input = input;
    }
    
    public void run()
    {
        try
        {
            int lineNumber = 0;
            String buf = null;
            Color whiteSmoke = new Color(Display.getCurrent(), 245, 245,
245);
            
            while ((buf = input.readLine()) != null)
            {
                lineNumber++;
                StrTokenizer st = new StrTokenizer(buf, ",", true);
                String cptCode = nextToken(st, 0);
                String mod = nextToken(st, 1);
                String amount = formatAmount(nextToken(st, 2));
                String sos = nextToken(st, 3);
                TableItem item = new TableItem(table, SWT.NONE);
                item.setText(new String[] { cptCode, mod, amount, sos});
                
                if (1 == (lineNumber % 2))
                {
                    item.setBackground(whiteSmoke);
                }
            }
            
            whiteSmoke.dispose();
        }
        catch (Exception x)
        {
            x.printStackTrace();
        }    
    }
    ...
}

J.R.
-----Original Message-----
From: Steve Northover [mailto:Steve_Northover@xxxxxxxxxx]
Sent: Tuesday, September 09, 2003 4:11 PM
To: platform-swt-dev@xxxxxxxxxxx
Cc: 'platform-swt-dev@xxxxxxxxxxx'; platform-swt-dev-admin@xxxxxxxxxxx
Subject: Re: [platform-swt-dev] BusyIndicator.showWhile() doesn't show wait
cursor



Snippet? 



JR Ruggentaler <jr@xxxxxxx> 
Sent by: platform-swt-dev-admin@xxxxxxxxxxx 
09/09/2003 02:05 PM 
Please respond to platform-swt-dev         
        To:        "'platform-swt-dev@xxxxxxxxxxx'"
<platform-swt-dev@xxxxxxxxxxx> 
        cc:         
        Subject:        [platform-swt-dev] BusyIndicator.showWhile() doesn't
show wait cursor



I tried writing a simple app using SWT. The app has a Text input field with
a Button next to the Text field. Below the input field and button is a
Table. When the user presses the Button a SelectionListener pops up a
FileDialog allowing the user to select an input file. After the user selects
the file the selection listener creates a object that implements Runnable
and calls BusyIndicator.showWhile(null, loadCSV);. The first time the
SelectionListener is messaged the Table grid lines disappear and the cursor
does not change. After the data is loaded into the table the app responds
normally. If I click the Button a second time and select a file the wait
cursor is displayed within my apps' boundaries. Am I missing something or is
this a SWT bug?

I am using SWT swt-win32-2135.dll on Windows 2000.

P.S. Sorry if this is a dup I was not subscribed to the list the first time
I posted.

J.R.
_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-swt-dev


Back to the top