Home >> Forums >> Creating new actions - Broken GUI

Creating new actions - Broken GUI

Hello,

I'm doing some work on Ichthyop internals and I need to add new actions (Vertical Dispersion, Migration...)
What I'm doing is:
- Coding the action, taking another one as template.
- Copying and pasting the file.
- Compiling using JDK1.8
- Edit the .xml configuration file, so my custom action can read parameters from there.
But... this seems to break the GUI! When I click on the JTree (Say Advanced -> Transport -> Advection), the right panel does not update and remains blank.
Hmm... What am I doing wrong? Could someone give me some hints?

Ichthyop version: 
Ichthyop 3.3alpha
Java version: 
Java SE 8
Operating system: 
Ubuntu
Attachments: 

This is interesting... On JConfigurationPanel.java there is:

private class ShowConfigEditorsTask extends Task {
@Override
protected Object doInBackground() {
// Update configuration panel
}

If I add some code for debug info:

@Override
protected void failed(Throwable c) {
    System.out.println("Config panel update failed: " + (c==null ? null : c.getMessage()));
}

I get:

Config panel update failed: Could not initialize class org.previmer.ichthyop.Population

What does Population.java have to do with the User Interface? :/

Oh, I see... I was trying to add a GUI option for enabling and disabling the multithreading, as I intend to run Ichthyop on a supercomputing cluster. In Population.java, the line:

private final boolean MULTITHREAD = Boolean.valueOf(getSimulationManager().getParameterManager().getParameter("app.misc","enable_multithreading"));

was driving Ichthyop a bit crazy.

This is odd indeed that you get a call to Population. But as you mentionned you were doing something that is likely to have upset Jave by calling the getSimulationManager().getParameterManager().getParameter() for initializing the final variable MULTITHREAD.

I reckon you found your workaround already, otherwise I suggest you do :

private boolean MULTITHREAD;

and in setup

@Override
    public void setupPerformed(SetupEvent e) {
        population.clear();
        MULTITHREAD = getSimulationManager().getParameterManager().getParameter("app.misc", "enabled_multithreading");
    }

Philippe

Hi Ignacio,

First of all : Ichthyop GUI is a bit old and buggy and error are poorly handled. So when you get this grey screen when you cick on a node in the JTree it is because something went wrong in JConfigurationPanel::setupBlockPanel() and the error is not catched as it should. From my experience it most likely comes from ParameterTable::setModel() function and more specifically either from ParameterTableModel constructor, in that case it means the something is missing in the XML and Ichthtyop is not programmed to provide default value, or from ParameterTable::setEditor() function that handles the format of the cell editors when you change a value.

One quick way to minimize the odds of getting the grey screen is to disable the custom cell editors, which means that you will edit every parameter as if it were mere text, without any control from Ichtyop. To do so :

    private void setEditors(XBlock block) {

        RowEditorModel editorModel = new RowEditorModel();
        setRowEditorModel(editorModel);

        setDefaultRenderer(Object.class, new ParamTableCellRenderer());

        for (int row = 0; row < model.getRowCount(); row++) {
            editorModel.addEditorForRow(row, new StringCellEditor());
        }
    }

If you still get a grey screen after such changes (do not forget to recompile the code) then the error is more likely to be related to the XML block itself, maybe forbiden characters, missing flag ?

Cheers,

Philippe

 

I found my workaround, indeed. Thank you for your suggestions.

Fiddling with multithreading involves a lot of changes that are not only related to the Population class, so now I moved the multithreading initialisation to the Simulation class, which does not break the GUI.

As you pointed out, the issue was related to both annoynig Java with unexpected changes in Population and a bad formed, legacy XML that was lying around.

Also, I've been doing some work on Ichthyop that might be of interest to you.
Oh, and congratulations on the baby!

Regards,
Ignacio

Thank you so much for the congrats :)

As for the new developments we will be excited to hear abou them ! Feel free to email us (Nicolas Barrier, Christophe Lett and myself) anytime.

Cheers, Philippe