Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
db479c5c
Commit
db479c5c
authored
4 years ago
by
Loïc Correnson
Browse files
Options
Downloads
Patches
Plain Diff
[dome] table view
parent
ffaa509f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ivette/src/dome/src/renderer/table/views.tsx
+99
-0
99 additions, 0 deletions
ivette/src/dome/src/renderer/table/views.tsx
with
99 additions
and
0 deletions
ivette/src/dome/src/renderer/table/views.tsx
+
99
−
0
View file @
db479c5c
...
@@ -444,3 +444,102 @@ function headerRenderer(props: TableHeaderProps) {
...
@@ -444,3 +444,102 @@ function headerRenderer(props: TableHeaderProps) {
}
}
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
// --- Table Rows
// --------------------------------------------------------------------------
const
rowClassName
=
(
selected
?:
number
)
=>
({
index
}:
{
index
:
number
})
=>
(
selected
===
index
?
'
dome-color-selected
'
:
(
index
&
1
?
'
dome-xTable-even
'
:
'
dome-xTable-odd
'
));
// --------------------------------------------------------------------------
// --- Column Resizer
// --------------------------------------------------------------------------
const
DRAGGING
=
'
dome-xTable-resizer dome-color-dragging
'
;
const
DRAGZONE
=
'
dome-xTable-resizer dome-color-dragzone
'
;
interface
ResizerProps
{
id
:
number
;
dragging
:
undefined
|
number
;
left
:
string
;
// resized column-id on the left
right
:
string
;
// resized column-id on the right
offset
:
number
;
// drag-start offset
onStart
:
DraggableEventHandler
;
onStop
:
DraggableEventHandler
;
onDrag
:
(
left
:
string
,
right
:
string
,
offset
:
number
)
=>
void
;
}
const
Resizer
=
(
props
:
ResizerProps
)
=>
(
<
DraggableCore
onStart
=
{
props
.
onStart
}
onStop
=
{
props
.
onStop
}
onDrag
=
{
(
_elt
,
data
)
=>
props
.
onDrag
(
props
.
left
,
props
.
right
,
data
.
x
-
props
.
offset
)
}
>
<
div
className
=
{
props
.
id
===
props
.
dragging
?
DRAGGING
:
DRAGZONE
}
style
=
{
{
left
:
props
.
offset
-
2
}
}
/>
</
DraggableCore
>
);
const
computeWidth
=
(
elt
:
Element
)
=>
{
const
parent
=
elt
&&
elt
.
parentElement
;
return
parent
&&
parent
.
getBoundingClientRect
().
width
;
};
// --------------------------------------------------------------------------
// --- Virtualized Table View
// --------------------------------------------------------------------------
// Must be kept in sync with table.css
const
CSS_HEADER_HEIGHT
=
22
;
const
CSS_ROW_HEIGHT
=
20
;
function
makeTable
<
Key
,
Row
>
(
size
:
Size
,
props
:
TableProps
<
Key
,
Row
>
,
state
:
TableState
<
Row
>
,
)
{
const
{
width
,
height
}
=
size
;
const
model
=
props
.
model
;
const
itemCount
=
model
.
getRowCount
();
const
tableHeight
=
CSS_HEADER_HEIGHT
+
CSS_ROW_HEIGHT
*
itemCount
;
const
smallHeight
=
itemCount
>
0
&&
tableHeight
<
height
;
const
rowCount
=
(
smallHeight
?
itemCount
+
1
:
itemCount
);
const
selection
=
props
.
selection
;
const
selected
=
selection
&&
model
.
getIndexOf
(
selection
);
const
resizers
=
null
;
// this.computeResizers(columns);
const
columns
=
makeColumns
(
state
);
return
(
<
React
.
Fragment
>
<
VTable
ref
=
{
state
.
tableRef
}
key
=
'table'
displayName
=
'React-Virtualized-Table'
width
=
{
width
}
height
=
{
height
}
rowCount
=
{
rowCount
}
noRowsRenderer
=
{
props
.
renderEmpty
}
rowGetter
=
{
state
.
rowGetter
}
rowClassName
=
{
rowClassName
(
selected
)
}
rowHeight
=
{
CSS_ROW_HEIGHT
}
headerHeight
=
{
CSS_HEADER_HEIGHT
}
headerRowRenderer
=
{
headerRowRenderer
}
onRowsRendered
=
{
state
.
watchRange
}
onRowClick
=
{
onSelection
&&
this
.
selectRow
}
sortBy
=
{
ordering
&&
ordering
.
sortBy
}
sortDirection
=
{
ordering
&&
ordering
.
sortDirection
}
sort
=
{
model
.
setOrdering
.
bind
(
model
)
}
scrollToIndex
=
{
scrollToIndex
}
scrollToAlignment
=
'auto'
>
{
columns
}
</
VTable
>
{
resizers
}
</
React
.
Fragment
>
);
};
// --------------------------------------------------------------------------
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment