javaeclipsewindowbuilder

Is there any tool or plugin availabe in eclipse to recompile a Java GUI application


I'm working in a GUI Java Application in Eclipse IDE. I'm using Window Builder to speed the UI design. As a part of refactoring, I've changed the sequential and repetitive code to encapsulated versions in other packages, this breaks the "Design" view, but does not affect the application itself. The problem is that any change made to the ui needs to be seen through the compiled app, (after compile and run the app I mean), and I need to manually relaunch app any time I make a change.

So, my question is:

Is there any plugin or tool that detects changes and automatically relaunches the application, as nodemon does in Nodejs applications.

Thanks in advance.


Solution

  • There is no such tool AFAIK. The next thing is to place the program in Debug mode add a refresh button to redraw the widget and hope for the best (the JVM might or might not be able to re-initialize your class).

    Alternatively, you can create a class that monitors the filesystem for recompiles and then restarts your application.

    All bleh...

    The best tip I can give you is to redesign your application in a way that Windowbuilder can understand.

    I assume you have refactored your UI into multiple modular parts. If your UI consists of e.g. a Customer Detail panel and a Customer List panel, you might want to develop each of these separately. This is something WB can handle fine.

    Create your modular UI classes in such a way that WB can understand them by subclassing a Widget (preferably Composite). The class below can be added to the palette of Windowbuilder and dragged into your 'composite' application.

        public class MyCustomerDetail extends Composite {
    
        public MyCustomerDetail(Composite pParent, int pStyle) {
            super(pParent, pStyle);
    
            GridLayout gridLayout = new GridLayout(2, false);
            setLayout(gridLayout);
    
            Label label = new Label(this, SWT.NONE);
            label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
            label.setText("Customer Name");
    
            Text name = new Text(this, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
            name.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
        }
    }
    

    Don't make a POJO class with a GUI method. The following class cannot be handled by WB and is of bad taste altogether.

    public class MyCustomerDetail {
    
        public void createUI(Composite pParent) {
    
            Label label = new Label(pParent, SWT.NONE);
            label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
            label.setText("Customer Name");
    
            Text name = new Text(pParent, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
            name.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
        }
    }