package _VisualDVM.GlobalData.Machine.UI;
import Common.Visual.UI;
import Common.Visual.Windows.Dialog.DBObjectDialog;
import _VisualDVM.GlobalData.Machine.Machine;
import _VisualDVM.GlobalData.Machine.MachineType;
public class MachineDialog extends DBObjectDialog<Machine, MachineFields> {
    public MachineDialog() {
        super(MachineFields.class);
    }
    @Override
    public int getDefaultWidth() {
        return 600;
    }
    @Override
    public int getDefaultHeight() {
        return 350;
    }
    @Override
    public void validateFields() {
        if (fields.tfAddress.getText().isEmpty())
            Log.Writeln("Адрес машины не может быть пустым");
    }
    @Override
    public void fillFields() {
        fields.tfName.setText(Result.name);
        fields.tfAddress.setText(Result.address);
        fields.sPort.setValue(Result.port);
        UI.TrySelect(fields.cbMachineType, Result.type);
    }
    @Override
    public void ProcessResult() {
        Result.name = fields.tfName.getText();
        Result.address = fields.tfAddress.getText();
        Result.port = (int) fields.sPort.getValue();
        Result.type = (MachineType) fields.cbMachineType.getSelectedItem();
    }
    @Override
    public void SetEditLimits() {
        fields.cbMachineType.setEnabled(false);
    }
}
