Search in sources :

Example 1 with ParametersModelComparator

use of org.cirdles.squid.parameters.ParametersModelComparator in project Squid by CIRDLES.

the class ParametersManagerGUIController method refMatSaveAndRegisterEdit.

@FXML
private void refMatSaveAndRegisterEdit(ActionEvent event) throws SquidException {
    boolean hasModelWithSameNameAndVersion = false;
    String name = refMatModelName.getText();
    String version = refMatVersion.getText();
    for (int i = 0; i < refMatModels.size() && !hasModelWithSameNameAndVersion; i++) {
        hasModelWithSameNameAndVersion = name.equals(refMatModels.get(i).getModelName()) && version.equals(refMatModels.get(i).getVersion());
    }
    if (!hasModelWithSameNameAndVersion || isEditingCurrRefMat) {
        refMatModel.setIsEditable(true);
        refMatModel.setModelName(refMatModelName.getText());
        refMatModel.setLabName(refMatLabName.getText());
        refMatModel.setVersion(refMatVersion.getText());
        refMatModel.setDateCertified(refMatDateCertified.getText());
        ObservableList<RefMatDataModel> dataModels = refMatDataTable.getItems();
        dataModels.addAll(UUTable.getItems());
        boolean[] isMeasures = new boolean[dataModels.size()];
        for (int i = 0; i < isMeasures.length; i++) {
            RefMatDataModel mod = dataModels.get(i);
            isMeasures[i] = mod.getIsMeasured().isSelected();
        }
        ((ReferenceMaterialModel) refMatModel).setDataMeasured(isMeasures);
        refMatModel.setReferences(refMatReferencesArea.getText());
        refMatModel.setComments(refMatCommentsArea.getText());
        if (!isEditingCurrRefMat) {
            refMatModels.add(refMatModel);
        } else {
            isEditingCurrRefMat = false;
            refMatHolder = null;
        }
        refMatModels.sort(new ParametersModelComparator());
        setUpRefMatCBItems();
        refMatCB.getSelectionModel().select(refMatModels.indexOf(refMatModel));
        refMatEditable(false);
        setUpRefMatMenuItems(false, refMatModel.isEditable());
        isEditingRefMat = false;
        squidLabData.storeState();
    } else {
        SquidMessageDialog.showWarningDialog("A Reference Material with the same name and version exists.\n" + "Please change the name and/or version", squidLabDataWindow);
    }
}
Also used : ReferenceMaterialModel(org.cirdles.squid.parameters.parameterModels.referenceMaterialModels.ReferenceMaterialModel) ParametersModelComparator(org.cirdles.squid.parameters.ParametersModelComparator) FXML(javafx.fxml.FXML)

Example 2 with ParametersModelComparator

use of org.cirdles.squid.parameters.ParametersModelComparator in project Squid by CIRDLES.

the class ParametersManagerGUIController method commonPbSaveAndRegisterEdit.

@FXML
private void commonPbSaveAndRegisterEdit(ActionEvent event) throws SquidException {
    boolean hasModelWithSameNameAndVersion = false;
    String name = commonPbModelName.getText();
    String version = commonPbVersion.getText();
    for (int i = 0; i < commonPbModels.size() && !hasModelWithSameNameAndVersion; i++) {
        hasModelWithSameNameAndVersion = name.equals(commonPbModels.get(i).getModelName()) && version.equals(commonPbModels.get(i).getVersion());
    }
    if (!hasModelWithSameNameAndVersion || isEditingCurrCommonPbModel) {
        commonPbModel.setIsEditable(true);
        commonPbModel.setModelName(commonPbModelName.getText());
        commonPbModel.setLabName(commonPbLabName.getText());
        commonPbModel.setVersion(commonPbVersion.getText());
        commonPbModel.setDateCertified(commonPbDateCertified.getText());
        commonPbModel.setReferences(commonPbReferencesArea.getText());
        commonPbModel.setComments(commonPbCommentsArea.getText());
        if (!isEditingCurrCommonPbModel) {
            commonPbModels.add(commonPbModel);
        } else {
            isEditingCurrCommonPbModel = false;
            commonPbModelHolder = null;
        }
        commonPbModels.sort(new ParametersModelComparator());
        isEditingCommonPb = false;
        setUpCommonPbCBItems();
        commonPbCB.getSelectionModel().select(commonPbModels.indexOf(commonPbModel));
        commonPbModelEditable(false);
        setUpCommonPbMenuItems(false, commonPbModel.isEditable());
        squidLabData.storeState();
    } else {
        SquidMessageDialog.showWarningDialog("A Common Lead Model with the same name and version exists.\n" + "Please change the name and/or version", squidLabDataWindow);
    }
}
Also used : ParametersModelComparator(org.cirdles.squid.parameters.ParametersModelComparator) FXML(javafx.fxml.FXML)

Example 3 with ParametersModelComparator

use of org.cirdles.squid.parameters.ParametersModelComparator in project Squid by CIRDLES.

the class ParametersManagerGUIController method refMatRemoveCurrMod.

@FXML
private void refMatRemoveCurrMod(ActionEvent event) throws SquidException {
    refMatModels.remove(refMatModel);
    refMatModels.sort(new ParametersModelComparator());
    setUpRefMatCBItems();
    refMatCB.getSelectionModel().selectFirst();
    refMatEditable(false);
    setUpRefMatMenuItems(false, refMatModel.isEditable());
    squidLabData.storeState();
}
Also used : ParametersModelComparator(org.cirdles.squid.parameters.ParametersModelComparator) FXML(javafx.fxml.FXML)

Example 4 with ParametersModelComparator

use of org.cirdles.squid.parameters.ParametersModelComparator in project Squid by CIRDLES.

the class SquidLabData method updateSquidLabData.

private void updateSquidLabData() throws SquidException {
    referenceMaterials.removeAll(ReferenceMaterialModel.getDefaultModels());
    referenceMaterials.addAll(ReferenceMaterialModel.getDefaultModels());
    referenceMaterials.sort(new ParametersModelComparator());
    physicalConstantsModels.removeAll(PhysicalConstantsModel.getDefaultModels());
    physicalConstantsModels.addAll(PhysicalConstantsModel.getDefaultModels());
    physicalConstantsModels.sort(new ParametersModelComparator());
    commonPbModels.removeAll(CommonPbModel.getDefaultModels());
    commonPbModels.addAll(CommonPbModel.getDefaultModels());
    commonPbModels.sort(new ParametersModelComparator());
    physConstDefault = PhysicalConstantsModel.getDefaultModel(SQUID2_DEFAULT_PHYSICAL_CONSTANTS_MODEL_V1, "1.0");
    refMatDefault = ReferenceMaterialModel.getDefaultModel("z6266 ID-TIMS (559.0 Ma)", "1.0");
    refMatConcDefault = ReferenceMaterialModel.getDefaultModel("z6266 ID-TIMS (559.0 Ma)", "1.0");
    commonPbDefault = CommonPbModel.getDefaultModel("Stacey-Kramers@559.0Ma (z6266)", "1.0");
    version = CURRENT_VERSION;
    specialWMSortingReportTable = null;
    specialRMWMSortingReportTable = null;
    defaultReportTable = null;
    defaultReportTableRM = null;
    storeState();
}
Also used : ParametersModelComparator(org.cirdles.squid.parameters.ParametersModelComparator)

Example 5 with ParametersModelComparator

use of org.cirdles.squid.parameters.ParametersModelComparator in project Squid by CIRDLES.

the class SquidUIController method synchronizeTaskLabDataAndSquidVersion.

private void synchronizeTaskLabDataAndSquidVersion() throws SquidException {
    if (squidProject != null && squidProject.getTask() != null) {
        TaskInterface task = squidProject.getTask();
        SquidProject.setProjectChanged(((Task) task).synchronizeTaskVersion());
        (((Task) task).verifySquidLabDataParameters()).forEach(model -> {
            if (model instanceof PhysicalConstantsModel) {
                squidLabData.addPhysicalConstantsModel(model);
                squidLabData.getPhysicalConstantsModels().sort(new ParametersModelComparator());
            } else if (model instanceof CommonPbModel) {
                squidLabData.addcommonPbModel(model);
                squidLabData.getCommonPbModels().sort(new ParametersModelComparator());
            } else if (model instanceof ReferenceMaterialModel) {
                squidLabData.addReferenceMaterial(model);
                squidLabData.getReferenceMaterials().sort(new ParametersModelComparator());
            }
        });
        squidProject.setReferenceMaterialModel(task.getReferenceMaterialModel());
        squidProject.setConcentrationReferenceMaterialModel(task.getConcentrationReferenceMaterialModel());
        if (SquidProject.isProjectChanged()) {
            // dec 2021 for issue #674
            task.setExtPErrU(squidProject.getExtPErrU());
            task.setExtPErrTh(squidProject.getExtPErrTh());
            // next two lines make sure 15-digit rounding is used by reprocessing data
            task.setChanged(true);
            task.setupSquidSessionSpecsAndReduceAndReport(true);
            ((Task) task).initTaskDefaultSquidReportTables(true);
            ProjectFileUtilities.serializeSquidProject(squidProject, projectFileName);
            SquidMessageDialog.showInfoDialog("The project file has been updated for this version of Squid3.\n", primaryStageWindow);
        }
    }
}
Also used : ReferenceMaterialModel(org.cirdles.squid.parameters.parameterModels.referenceMaterialModels.ReferenceMaterialModel) Task(org.cirdles.squid.tasks.Task) PhysicalConstantsModel(org.cirdles.squid.parameters.parameterModels.physicalConstantsModels.PhysicalConstantsModel) TaskInterface(org.cirdles.squid.tasks.TaskInterface) ParametersModelComparator(org.cirdles.squid.parameters.ParametersModelComparator) CommonPbModel(org.cirdles.squid.parameters.parameterModels.commonPbModels.CommonPbModel)

Aggregations

ParametersModelComparator (org.cirdles.squid.parameters.ParametersModelComparator)10 FXML (javafx.fxml.FXML)6 ReferenceMaterialModel (org.cirdles.squid.parameters.parameterModels.referenceMaterialModels.ReferenceMaterialModel)4 IOException (java.io.IOException)2 SquidException (org.cirdles.squid.exceptions.SquidException)2 CommonPbModel (org.cirdles.squid.parameters.parameterModels.commonPbModels.CommonPbModel)2 PhysicalConstantsModel (org.cirdles.squid.parameters.parameterModels.physicalConstantsModels.PhysicalConstantsModel)2 Task (org.cirdles.squid.tasks.Task)2 TaskInterface (org.cirdles.squid.tasks.TaskInterface)2 File (java.io.File)1 BigDecimal (java.math.BigDecimal)1 JAXBException (javax.xml.bind.JAXBException)1 ParametersModel (org.cirdles.squid.parameters.parameterModels.ParametersModel)1 PrawnFile (org.cirdles.squid.prawn.PrawnFile)1 Squid3ProjectParametersAPI (org.cirdles.squid.projects.Squid3ProjectParametersAPI)1 ZipUtility.extractZippedFile (org.cirdles.squid.utilities.fileUtilities.ZipUtility.extractZippedFile)1 SAXException (org.xml.sax.SAXException)1