package whelk.gui;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class RunOrCreatePanel extends WizardCard implements ActionListener
{
    private JRadioButton rCreate;
    private JRadioButton rRun;

    public RunOrCreatePanel(Wizard wizard)
    {
        super(wizard);

        this.setLayout(new GridBagLayout());

        Box vbox = Box.createVerticalBox();
        rCreate = new JRadioButton("Skapa en körning.");
        rCreate.addActionListener(this);
        rRun = new JRadioButton("Kör en tidigare skapad körning.");
        rRun.addActionListener(this);

        rCreate.setSelected(true);

        ButtonGroup group = new ButtonGroup();
        group.add(rCreate);
        group.add(rRun);

        vbox.add(rCreate);
        vbox.add(rRun);
        this.add(vbox);
    }

    @Override
    void onShow(Object parameterFromPreviousCard)
    {
        chooseNextCard();
    }

    @Override
    public void actionPerformed(ActionEvent actionEvent)
    {
        chooseNextCard();
    }

    private void chooseNextCard()
    {
        if (! rRun.isSelected())
            setNextCard(Wizard.CREATE_WHAT);
        else
            setNextCard(Wizard.SELECT_SCRIPT);
    }
}

@@ -402,141 +402,560 @@
     
-Box vbox = Box.createVerticalBox();%0A        rCreate = new JRadioButton(%22Skapa en k%C3%B6rning.%22);%0A        rCreate.addActionListener(this);
+boolean creationForbidden = System.getProperty(%22creationForbidden%22) != null &&%0A                System.getProperty(%22creationForbidden%22).equals(%22true%22);%0A%0A        Box vbox = Box.createVerticalBox();%0A        if (creationForbidden)%0A        %7B%0A            rCreate = new JRadioButton(%22Skapa en k%C3%B6rning (ej till%C3%A5tet i denna milj%C3%B6).%22);%0A            rCreate.setEnabled(false);%0A        %7D%0A        else%0A        %7B%0A            rCreate = new JRadioButton(%22Skapa en k%C3%B6rning.%22);%0A            rCreate.addActionListener(this);%0A            rCreate.setSelected(true);%0A        %7D
 %0A   
@@ -1062,44 +1062,8 @@
 );%0A%0A
-        rCreate.setSelected(true);%0A%0A
     

Disable the creation of new scripts in certain environments (prod).