use crate::element::parser::ElementParser;
use crate::event::Event;
use crate::{
command::WebDynproCommand,
element::{
Element,
complex::{SapTableDef, SapTableLSData, sap_table::SapTableBody},
},
error::WebDynproError,
};
pub struct SapTableVerticalScrollEventCommand {
element_def: SapTableDef,
first_visible_item_index: u32,
cell_id: String,
access_type: String,
selection_follow_focus: bool,
shift: bool,
ctrl: bool,
alt: bool,
}
impl SapTableVerticalScrollEventCommand {
#[allow(clippy::too_many_arguments)]
pub fn new(
element_def: SapTableDef,
first_visible_item_index: u32,
cell_id: &str,
access_type: &str,
selection_follow_focus: bool,
shift: bool,
ctrl: bool,
alt: bool,
) -> Self {
Self {
element_def,
first_visible_item_index,
cell_id: cell_id.to_string(),
access_type: access_type.to_string(),
selection_follow_focus,
shift,
ctrl,
alt,
}
}
}
impl WebDynproCommand for SapTableVerticalScrollEventCommand {
type Result = Event;
fn dispatch(&self, parser: &ElementParser) -> Result<Self::Result, WebDynproError> {
parser.element_from_def(&self.element_def)?.vertical_scroll(
self.first_visible_item_index,
&self.cell_id,
&self.access_type,
self.selection_follow_focus,
self.shift,
self.ctrl,
self.alt,
)
}
}
pub struct SapTableLSDataCommand {
element_def: SapTableDef,
}
impl SapTableLSDataCommand {
pub fn new(element_def: SapTableDef) -> SapTableLSDataCommand {
Self { element_def }
}
}
impl WebDynproCommand for SapTableLSDataCommand {
type Result = SapTableLSData;
fn dispatch(&self, parser: &ElementParser) -> Result<Self::Result, WebDynproError> {
let lsdata = parser.element_from_def(&self.element_def)?.lsdata().clone();
Ok(lsdata)
}
}
pub struct SapTableBodyCommand {
element_def: SapTableDef,
}
impl SapTableBodyCommand {
pub fn new(element_def: SapTableDef) -> SapTableBodyCommand {
Self { element_def }
}
}
impl WebDynproCommand for SapTableBodyCommand {
type Result = SapTableBody;
fn dispatch(&self, parser: &ElementParser) -> Result<Self::Result, WebDynproError> {
let body = parser.element_from_def(&self.element_def)?.table()?.clone();
Ok(body)
}
}