Dialog Wrapper not working

Answered

Hello, 

Im trying to use simple dialog window and following example use of Dialog wrapper class. Dialog is not appearing and code is not moving past Dialog wrapper initialization. Im not getting any error and i tried debugging where is code stopping. Im not sure what could be the cause for this. Thanks for any help. 

Class usage 

Dialog wrapper class code 

package org.intellij.sdk.settings;

import com.intellij.openapi.ui.DialogWrapper;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.Dimension;

public class UpdateConfirmationDialog extends DialogWrapper {

    public UpdateConfirmationDialog() {
        super(true);
        setTitle("Test DialogWrapper");
        init();
    }

    @Nullable
    @Override
    protected JComponent createCenterPanel() {
        JPanel dialogPanel = new JPanel(new BorderLayout());

        JLabel label = new JLabel("Testing");
        label.setPreferredSize(new Dimension(100, 100));
        dialogPanel.add(label, BorderLayout.CENTER);

        return dialogPanel;
    }

    public String getText() {
        return "hello";
    }
}

Ive found out that code does not continue past this function in Dialog wrapper class. 

 

Called from here 

0
4 comments

Please make sure you follow guidelines from https://plugins.jetbrains.com/docs/intellij/threading-model.html#invoking-operations-on-edt-and-modality for invoking showing the dialog. Otherwise, please share the full code of your project.

0

Hello, it seems that the problem is that im using this code inside scheduled code.  When i put it outside the function, it works properly. I need the dialog to show automatically after period of time. This is my code. 

AppExecutorUtil.getAppScheduledExecutorService().scheduleWithFixedDelay(object : Runnable {
            override fun run() {
                val AppSettingsInstance = AppSettings.getInstance();
                val npmPackage: String = AppSettingsInstance.getPackage(); 
                val promise = CompletableFuture<Boolean>()
                Thread {
                    val isNewest = npmPackageVersionCheck(npmPackage) // Long operation, 
                    im trying to make it non blocking with the usage of promises 
                    promise.complete(isNewest);
                }.start()
                promise.thenAccept { result ->
                    updateNpmPackage(npmPackage) // Calling the class extending the dialog wrapper 
                    println("Async operation completed with result: $result")
                }
                println("Waiting for async operation to complete...")
            }
        }, 5, 10000000, TimeUnit.SECONDS)

Could you recommend how to achieve this together with working dialog ? Thanks for any advice or help. 

0

Any UI code invocation must happen on EDT thread.

0

Thank you, that solved the problem. Guidelines you provided were helpful. 

0

Please sign in to leave a comment.