<commit_before>package archimulator.view.page;

import archimulator.model.experiment.profile.ExperimentProfile;
import archimulator.model.experiment.profile.ProcessorProfile;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Button;
import org.zkoss.zul.Window;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

public class ExperimentProfilesPage extends GenericForwardComposer<Window> {
    private Button buttonAddExperimentProfile;

    public void onClick$buttonAddExperimentProfile(Event event) throws SQLException {
        Map<String, Object> arg = new HashMap<String, Object>();

        arg.put("create", true);
        ExperimentProfile experimentProfile = new ExperimentProfile(new ProcessorProfile(2, 2, 1024 * 1024 * 4, 8));
        arg.put("experimentProfile", experimentProfile); //TODO: should set null or load from db

        Window win = (Window) Executions.createComponents("/edit/editExperimentProfile.zul", null, arg);
        win.doModal();
    }
}<commit_msg>Warn user if no processor profiles when adding an experiment profile.<commit_after>package archimulator.view.page;

import archimulator.model.experiment.profile.ExperimentProfile;
import archimulator.model.experiment.profile.ProcessorProfile;
import archimulator.service.ArchimulatorService;
import archimulator.service.ArchimulatorServletContextListener;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Button;
import org.zkoss.zul.Messagebox;
import org.zkoss.zul.Window;

import javax.servlet.http.HttpSession;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

public class ExperimentProfilesPage extends GenericForwardComposer<Window> {
    private Button buttonAddExperimentProfile;

    public void onClick$buttonAddExperimentProfile(Event event) throws SQLException {
        HttpSession httpSession = (HttpSession) session.getNativeSession();
        ArchimulatorService archimulatorService = ArchimulatorServletContextListener.getArchimulatorService(httpSession.getServletContext());

        if(archimulatorService.getProcessorProfilesAsList().isEmpty()) {
            Messagebox.show("目标体系结构列表为空，请添加目标体系结构后重试！", "添加实验", Messagebox.OK, Messagebox.EXCLAMATION, new EventListener<Event>() {
                @Override
                public void onEvent(Event event) throws Exception {
                    switch ((Integer) event.getData()) {
                        case Messagebox.OK:
                            Executions.sendRedirect(null);
                            break;
                    }
                }
            });
        }
        else {
            ProcessorProfile processorProfile = archimulatorService.getProcessorProfilesAsList().get(0);

            Map<String, Object> arg = new HashMap<String, Object>();

            arg.put("create", true);
            ExperimentProfile experimentProfile = new ExperimentProfile(processorProfile);
            arg.put("experimentProfile", experimentProfile);

            Window win = (Window) Executions.createComponents("/edit/editExperimentProfile.zul", null, arg);
            win.doModal();
        }
    }
}
{'fraction_non_alphanumeric': 0.09539375928677563, 'fraction_numerical': 0.003863298662704309, 'mean_word_length': 3.5795918367346937, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3750155', 'n_tokens_mistral': 930, 'n_tokens_neox': 908, 'n_words': 180}