package at.fos.ermodel.gui;

import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.control.RadioButton;

public class A2
        implements EventHandler<ActionEvent> {
    private final B3 view;

    public A2(B3 simpleFrame) {
        this.view = simpleFrame;
    }


    public void handle(ActionEvent arg0) {
        Object source = arg0.getSource();

        if (source instanceof RadioButton && source == this.view.selectModeBTN) {
            this.view.selectModeBTN.setStyle("-fx-text-fill:red");
            this.view.creationModelabel.setStyle("-fx-text-fill:white");
            this.view.menuVisibility.setDisable(false);
        }
        if (source instanceof RadioButton && source != this.view.selectModeBTN) {


            this.view.menuVisibilityAllRMI.setSelected(true);
            this.view.menuVisibilityTEXTRMI.setSelected(true);
            (this.view.getCurrentTab()).canvas.modelVisibility();
            (this.view.getCurrentTab()).canvas.sdfsdfds3465er(true);
            this.view.menuVisibility.setDisable(true);


            this.view.showAttributeCB.setSelected(false);
            this.view.graphicElemLV.getItems().clear();
            this.view.graphicElemLV.getItems().addAll((this.view.getCurrentTab()).canvas.sddsfsfsdf45645645());

            this.view.selectModeBTN.setStyle("-fx-text-fill:white");
            this.view.creationModelabel.setStyle("-fx-text-fill:red");
            this.view.lastCreationSelected = (RadioButton) source;
            if (this.view.getCurrentTab() == null) {
                this.view.selectModeBTN.setSelected(true);


                return;
            }


            if (this.view.generateRelationalModelCB.isSelected()) {
                this.view.selectModeBTN.setStyle("-fx-text-fill:red");
                this.view.creationModelabel.setStyle("-fx-text-fill:white");
                this.view.selectModeBTN.setSelected(true);


                return;
            }
        }


        if (source == this.view.menuExitMI) {
            this.view.close();
        }


        if (source == this.view.menuNewMI) {
            this.view.setCurrentTab(this.view.addNewTab(null));
            (this.view.getCurrentTab()).canvas.requestFocus();
            this.view.tabPane.getSelectionModel().select(this.view.getCurrentTab());
        }


        if (source == this.view.menuRedrawMI) {
            (this.view.getCurrentTab()).canvas.sdfsdfds3465er(true);
        }

        if (source == this.view.menuExportMI) {
            this.view.exportModel();
        }

        if (source == this.view.menuSaveMI) {
            this.view.saveModel();
        }

        if (source == this.view.menuSaveAsMI) {
            this.view.saveModelAs();
        }

        if (source == this.view.menuReadMI) {
            this.view.readModel();
        }


        if (source == this.view.creation_selection_group.getSelectedToggle()) {
            (this.view.getCurrentTab()).canvas.sdfdsfdsdf43543ref();
        }


        if (source == this.view.selectModeBTN) {
            (this.view.getCurrentTab()).canvas.sdfsdfds3465er(true);
            (this.view.getCurrentTab()).canvas.sdfsdfds435634terf();
            this.view.statusInformation.setText("Selection mode: move mouse over element or use mouse to draw a rectangle  - ESC -> deselect - DEL -> delete selected elements - pressed left mouse key -> move selected elements - right mouse over selected element -> open context menu");
        }


        if (source == this.view.textElemBTN) {
            (this.view.getCurrentTab()).canvas.sdfsdfds3465er(true);
            this.view.statusInformation.setText("Creation Mode: text-element-with-border -> press left mouse button on working area -> enter text (ALT-Enter for linefeed) -> press enter key");
        }
        if (source == this.view.textWithoutBorderElemBTN) {
            (this.view.getCurrentTab()).canvas.sdfsdfds3465er(true);
            this.view.statusInformation.setText("Creation Mode: text-element-without-border -> press left mouse button on working area -> enter text (ALT-Enter for linefeed) -> press enter key");
        }

        if (source == this.view.esBTN) {
            (this.view.getCurrentTab()).canvas.sdfsdfds3465er(true);
            this.view.statusInformation.setText("Creation Mode: entity-set -> press left mouse button on working area -> enter name of entity-set -> press enter key");
        }
        if (source == this.view.esWeakBTN) {
            (this.view.getCurrentTab()).canvas.sdfsdfds3465er(true);
            this.view.statusInformation.setText("Creation Mode: weak-entity-set -> press left mouse button on working area -> enter name of weak-entity-set -> press enter key");
        }
        if (source == this.view.esAssociativeBTN) {
            (this.view.getCurrentTab()).canvas.sdfsdfds3465er(true);
            this.view.statusInformation.setText("Creation Mode: associative-entity-set -> press left mouse button on working area -> enter name of assoc.-entity-set -> press enter key");
        }
        if (source == this.view.rsBTN) {
            (this.view.getCurrentTab()).canvas.sdfsdfds3465er(true);
            this.view.statusInformation.setText("Creation Mode: relationship-type -> press left mouse button on working area -> enter name of relationship-type -> press enter key");
        }
        if (source == this.view.rsIDBTN) {
            (this.view.getCurrentTab()).canvas.sdfsdfds3465er(true);
            this.view.statusInformation.setText("Creation Mode: identifying-relationship-type -> press left mouse button on working area -> enter name of entity-set -> press enter key");
        }
        if (source == this.view.rsISABTN) {
            (this.view.getCurrentTab()).canvas.sdfsdfds3465er(true);
            this.view.statusInformation.setText("Creation Mode: isa relationship-type -> press left mouse button on working area -> enter type (p/t/d/nd) -> press enter key");
        }
        if (source == this.view.attrKeyBTN) {
            (this.view.getCurrentTab()).canvas.sdfsdfds3465er(true);
            this.view.statusInformation.setText("Creation Mode: key-attribute");
        }
        if (source == this.view.attrWeakKeyBTN) {
            (this.view.getCurrentTab()).canvas.sdfsdfds3465er(true);
            this.view.statusInformation.setText("Creation Mode: weak-key-attribute");
        }
        if (source == this.view.attrOneBTN) {
            (this.view.getCurrentTab()).canvas.sdfsdfds3465er(true);

            this.view.statusInformation.setText("Creation Mode: one-value-attribute");
        }
        if (source == this.view.attrMultiBTN) {
            (this.view.getCurrentTab()).canvas.sdfsdfds3465er(true);

            this.view.statusInformation.setText("Creation Mode: multi-value-attribute");
        }
        if (source == this.view.attrDerivedOneBTN) {
            (this.view.getCurrentTab()).canvas.sdfsdfds3465er(true);

            this.view.statusInformation.setText("Creation Mode: derived-one-value-attribute");
        }
        if (source == this.view.attrDerivedMultiBTN) {
            (this.view.getCurrentTab()).canvas.sdfsdfds3465er(true);
            this.view.statusInformation.setText("Creation Mode: derived-multi-value-attribute");
        }


        (this.view.getCurrentTab()).canvas.setConnectionModeSet(false);
        if (source == this.view.attrToAttrBTN) {
            (this.view.getCurrentTab()).canvas.setConnectionModeSet(true);
            (this.view.getCurrentTab()).canvas.sdfdsfdsdf34543erretwre();
            this.view.statusInformation.setText("Creation Mode: connect attribute to a composite-attribute -  select element->click left mouse button->move mouse to second element->click left mouse button");
        }

        if (source == this.view.attrToESBTN) {
            (this.view.getCurrentTab()).canvas.setConnectionModeSet(true);
            (this.view.getCurrentTab()).canvas.sdfdsfdsdf34543erretwre();
            this.view.statusInformation.setText("Creation Mode: connect attribute with an entity-set -  select element->click left mouse button->move mouse to second element->click left mouse button");
        }

        if (source == this.view.attrToRSBTN) {
            (this.view.getCurrentTab()).canvas.setConnectionModeSet(true);
            (this.view.getCurrentTab()).canvas.sdfdsfdsdf34543erretwre();
            this.view.statusInformation.setText("Creation Mode: connect attribute with a relationship-type -  select element->click left mouse button->move mouse to second element->click left mouse button");
        }

        if (source == this.view.attrToRSBTN) {
            (this.view.getCurrentTab()).canvas.setConnectionModeSet(true);
            (this.view.getCurrentTab()).canvas.sdfdsfdsdf34543erretwre();
            this.view.statusInformation.setText("Creation Mode: connect attribute with a relationship-type -  select element->click left mouse button->move mouse to second element->click left mouse button");
        }

        if (source == this.view.rsToESBTN) {
            (this.view.getCurrentTab()).canvas.setConnectionModeSet(true);
            (this.view.getCurrentTab()).canvas.sdfdsfdsdf34543erretwre();
            this.view.statusInformation.setText("Creation Mode: connect relationship-type with (associative-)entity-set or entity-set with associative-entity-set -  select element->click left mouse button->move mouse to second element->click left mouse button");
        }

        if (source == this.view.rsidToESBTN) {
            (this.view.getCurrentTab()).canvas.setConnectionModeSet(true);
            (this.view.getCurrentTab()).canvas.sdfdsfdsdf34543erretwre();
            this.view.statusInformation.setText("Creation Mode: connect identifying-relationship-type with entity-set -  select element->click left mouse button->move mouse to second element->click left mouse button");
        }

        if (source == this.view.rsidToESWeakBTN) {
            (this.view.getCurrentTab()).canvas.setConnectionModeSet(true);
            (this.view.getCurrentTab()).canvas.sdfdsfdsdf34543erretwre();
            this.view.statusInformation.setText("Creation Mode: connect identifying-relationship-type with weak-entity-set -  select element->click left mouse button->move mouse to second element->click left mouse button");
        }

        if (source == this.view.rsisaGeToESBTN) {
            (this.view.getCurrentTab()).canvas.setConnectionModeSet(true);
            (this.view.getCurrentTab()).canvas.sdfdsfdsdf34543erretwre();
            this.view.statusInformation.setText("Creation Mode: connect isa-relationship-type with generalized entity-set -  select element->click left mouse button->move mouse to second element->click left mouse button");
        }

        if (source == this.view.rsisaSpToESBTN) {
            (this.view.getCurrentTab()).canvas.setConnectionModeSet(true);
            (this.view.getCurrentTab()).canvas.sdfdsfdsdf34543erretwre();
            this.view.statusInformation.setText("Creation Mode: connect isa-relationship-type with specialized entity-set -  select element->click left mouse button->move mouse to second element->click left mouse button");
        }


        if (this.view.getCurrentTab() != null) {
            (this.view.getCurrentTab()).canvas.dsfdsdfssdf45645re();
        }

        if (source == this.view.menuVisibilityTEXTRMI || source == this.view.menuVisibilityAllRMI || source == this.view.menuVisibilityES_RS_KEYRMI ||
                source == this.view.menuVisibilityES_RSRMI) {
            (this.view.getCurrentTab()).canvas.modelVisibility();
            (this.view.getCurrentTab()).canvas.sdfsdfds3465er(true);
        }
    }
}


