package _VisualDVM.Visual.Windows;
import Common.Visual.TextField.StyledTextField;
import _VisualDVM.Global;
import _VisualDVM.ProjectData.SapforData.Arrays.UI.ProjectArraysForm;
import _VisualDVM.Visual.Interface.ArraysWindow;

import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
public class ArraysForm implements ArraysWindow {
    public JSplitPane SC8;
    private JPanel content;
    private JPanel arraysPanel;
    private JPanel savedArraysPanel;
    private JTextField filterName;
    private JLabel arraysMatchesLabel;
    private JTextField filterLocationName;
    private JTextField filterLocation;
    private JTextField filterFile;
    private JTextField filterRegion;
    private JPanel savedArraysBackground;
    public ArraysForm() {
        LoadSplitters();
        Global.mainModule.getProject().declaratedArrays.mountUI(arraysPanel);
        Global.mainModule.getProject().db.savedArrays.mountUI(savedArraysPanel);
        //--
        filterName.setText(ProjectArraysForm.filterName);
        filterName.getDocument().addDocumentListener(new DocumentListener() {
            @Override
            public void insertUpdate(DocumentEvent e) {
                ProjectArraysForm.filterName = filterName.getText();
                ShowArrays();
            }
            @Override
            public void removeUpdate(DocumentEvent e) {
                ProjectArraysForm.filterName = filterName.getText();
                ShowArrays();
            }
            @Override
            public void changedUpdate(DocumentEvent e) {
            }
        });
        //-
        filterLocation.setText(ProjectArraysForm.filterLocation);
        filterLocation.getDocument().addDocumentListener(new DocumentListener() {
            @Override
            public void insertUpdate(DocumentEvent e) {
                ProjectArraysForm.filterLocation = filterLocation.getText();
                ShowArrays();
            }
            @Override
            public void removeUpdate(DocumentEvent e) {
                ProjectArraysForm.filterLocation = filterLocation.getText();
                ShowArrays();
            }
            @Override
            public void changedUpdate(DocumentEvent e) {
            }
        });
        //-
        filterLocationName.setText(ProjectArraysForm.filterLocationName);
        filterLocationName.getDocument().addDocumentListener(new DocumentListener() {
            @Override
            public void insertUpdate(DocumentEvent e) {
                ProjectArraysForm.filterLocationName = filterLocationName.getText();
                ShowArrays();
            }
            @Override
            public void removeUpdate(DocumentEvent e) {
                ProjectArraysForm.filterLocationName = filterLocationName.getText();
                ShowArrays();
            }
            @Override
            public void changedUpdate(DocumentEvent e) {
            }
        });
        //-
        filterFile.setText(ProjectArraysForm.filterFile);
        filterFile.getDocument().addDocumentListener(new DocumentListener() {
            @Override
            public void insertUpdate(DocumentEvent e) {
                ProjectArraysForm.filterFile = filterFile.getText();
                ShowArrays();
            }
            @Override
            public void removeUpdate(DocumentEvent e) {
                ProjectArraysForm.filterFile = filterFile.getText();
                ShowArrays();
            }
            @Override
            public void changedUpdate(DocumentEvent e) {
            }
        });
        //-
        filterRegion.setText(ProjectArraysForm.filterRegion);
        filterRegion.getDocument().addDocumentListener(new DocumentListener() {
            @Override
            public void insertUpdate(DocumentEvent e) {
                ProjectArraysForm.filterRegion = filterRegion.getText();
                ShowArrays();
            }
            @Override
            public void removeUpdate(DocumentEvent e) {
                ProjectArraysForm.filterRegion = filterRegion.getText();
                ShowArrays();
            }
            @Override
            public void changedUpdate(DocumentEvent e) {
            }
        });
    }
    @Override
    public JPanel getContent() {
        return content;
    }
    @Override
    public void ShowArrays() {
        Global.mainModule.getProject().declaratedArrays.ShowUI();
        Global.mainModule.getProject().db.savedArrays.ShowUI();
    }
    @Override
    public void ShowNoArrays() {
        Global.mainModule.getProject().declaratedArrays.ClearUI();
        Global.mainModule.getProject().db.savedArrays.ClearUI();
    }
    private void createUIComponents() {
        // TODO: place custom component creation code here
        filterName = new StyledTextField();
        filterLocationName = new StyledTextField();
        filterLocation = new StyledTextField();
        filterFile = new StyledTextField();
        filterRegion = new StyledTextField();
    }
}
