0

I need your help, In my swt app I need to show a simple message while some jfreechart chart is loading. Simply I put a shell at the beginning of the chart generating method and I close that shell at the end of the method. I know is not the best solution but I need a simply way to do that. The problem is that the shell is modal and it closes some other jobs running before, so I need a NO MODAL pop up. I tried with message box and dialogs but all of them have buttons, I only need a pop up without any buttons, with a only a label and an image. Thanks!

I put the relevant code:

in the generating chart method I call the shell create method:

    Display display = PlatformUI.createDisplay();
    Shell shell = new Shell(display,SWT.BACKGROUND);
    generateMessageDialog(display,shell);

and this is the method to create the shell:

    Monitor primary = display.getPrimaryMonitor ();
    Rectangle bounds = primary.getBounds ();
    shell.setSize(455, 295);
    Rectangle rect = shell.getBounds ();
    int x = bounds.x + (bounds.width - rect.width) / 2;
    int y = bounds.y + (bounds.height - rect.height) / 2;
    shell.setLocation (x, y);
    shell.setLayout(new FormLayout());
    shell.setText("Information");
    Label label = new Label(shell, SWT.NONE);
    ImageDescriptor id =      Activator.getImageDescriptor("icons/loading4_modificado.gif");
    Image image = id.createImage();
    label.setImage(image);

    Label label2=new Label(shell, SWT.NONE);
    label2.setText("Generating chart. Please, wait...");

    FormData label1FD = new FormData();
    label1FD.top = new FormAttachment(0, 120);
    label1FD.left = new FormAttachment(0, 90);
    label.setLayoutData(label1FD);

    FormData label2FD = new FormData();
    label2FD.top = new FormAttachment(0, 130);
    label2FD.left = new FormAttachment(0, 160);
    label2.setLayoutData(label2FD);
    label2.setFont(new org.eclipse.swt.graphics.Font(null,"Arial", Font.PLAIN, 10));

    shell.open();
    shell.layout();
greg-449
  • 109,219
  • 232
  • 102
  • 145
Monik Eliz
  • 107
  • 9
  • I tried that Greg but it´s still not working well...Thanks anyway! – Monik Eliz Nov 18 '15 at 11:42
  • 1
    Note you have `SWT.BACKGROUND` being passed in as the style to the `Shell`. AFAIK Shell does not support that style bit: http://help.eclipse.org/mars/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/widgets/Shell.html – Jonah Graham Nov 18 '15 at 16:13
  • Thanks all! I resolved the problem with a trick with other composite, making it visible or not, instead a pop up message. Thanks again! – Monik Eliz Nov 20 '15 at 09:59

2 Answers2

0

Creating the Shell with a style something like this:

new Shell(parentShell, SWT.ON_TOP | SWT.TOOL | SWT.NO_FOCUS);

gives you a 'tool tip' style shell.

greg-449
  • 109,219
  • 232
  • 102
  • 145
  • If you like to prevent the user from interacting with other parts of the application while this Shell is open you can add the `SWT.APPLICATION_MODAL` style flag. – Rüdiger Herrmann Nov 18 '15 at 10:08
  • What does 'not working' mean? What are you getting and what did you expect? – greg-449 Nov 19 '15 at 08:10
0

This sounds like you are asking for something a little like a splash screen.

The key style you probably want is SWT.ON_TOP which puts the window on top.

There is a full splash screen example as part of SWT Snippets here: Snippet104

Jonah Graham
  • 7,890
  • 23
  • 55