-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Allow LayoutHints to be accessible from Python, TreeTables #5543
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -251,6 +251,66 @@ def with_filters(self, filters: Union[str, Filter, Sequence[str], Sequence[Filte | |||||
except Exception as e: | ||||||
raise DHError(e, "with_filters operation on RollupTable failed.") from e | ||||||
|
||||||
def layout_hints(self, front: Union[str, List[str]] = None, back: Union[str, List[str]] = None, | ||||||
freeze: Union[str, List[str]] = None, hide: Union[str, List[str]] = None, | ||||||
column_groups: List[dict] = None, search_display_mode: SearchDisplayMode = None) -> Table: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||
""" Sets layout hints on the RollupTable | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pydocs do not mention the default behaviors. |
||||||
|
||||||
Args: | ||||||
front (Union[str, List[str]]): the columns to show at the front. | ||||||
back (Union[str, List[str]]): the columns to show at the back. | ||||||
freeze (Union[str, List[str]]): the columns to freeze to the front. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This leaves a lot of questions for me:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just copied these from the existing |
||||||
These will not be affected by horizontal scrolling. | ||||||
hide (Union[str, List[str]]): the columns to hide. | ||||||
column_groups (List[Dict]): A list of dicts specifying which columns should be grouped in the UI. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See typehint comment above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does "grouped in the UI" mean? |
||||||
The dicts can specify the following: | ||||||
|
||||||
* name (str): The group name | ||||||
* children (List[str]): The column names in the group | ||||||
* color (Optional[str]): The hex color string or Deephaven color name | ||||||
Comment on lines
+266
to
+270
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is very unclear. e.g. is |
||||||
search_display_mode (SearchDisplayMode): set the search bar to explicitly be accessible or inaccessible, | ||||||
or use the system default. :attr:`SearchDisplayMode.SHOW` will show the search bar, | ||||||
:attr:`SearchDisplayMode.HIDE` will hide the search bar, and :attr:`SearchDisplayMode.DEFAULT` will | ||||||
use the default value configured by the user and system settings. | ||||||
|
||||||
Returns: | ||||||
a new rollup table with the layout hints set | ||||||
|
||||||
Raises: | ||||||
DHError | ||||||
""" | ||||||
try: | ||||||
_j_layout_hint_builder = _JLayoutHintBuilder.get() | ||||||
|
||||||
if front is not None: | ||||||
_j_layout_hint_builder.atFront(to_sequence(front)) | ||||||
|
||||||
if back is not None: | ||||||
_j_layout_hint_builder.atBack(to_sequence(back)) | ||||||
|
||||||
if freeze is not None: | ||||||
_j_layout_hint_builder.freeze(to_sequence(freeze)) | ||||||
|
||||||
if hide is not None: | ||||||
_j_layout_hint_builder.hide(to_sequence(hide)) | ||||||
|
||||||
if column_groups is not None: | ||||||
for group in column_groups: | ||||||
_j_layout_hint_builder.columnGroup(group.get("name"), j_array_list(group.get("children")), | ||||||
group.get("color", "")) | ||||||
Comment on lines
+299
to
+300
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should probably error if there are other keys in the dict. e.g. a misspelling. |
||||||
|
||||||
if search_display_mode is not None: | ||||||
_j_layout_hint_builder.setSearchBarAccess(search_display_mode.value) | ||||||
|
||||||
except Exception as e: | ||||||
raise DHError(e, "failed to create layout hints") from e | ||||||
|
||||||
try: | ||||||
return RollupTable(j_rollup_table=self.j_rollup_table.setLayoutHints(_j_layout_hint_builder.build()), | ||||||
include_constituents=self.include_constituents, aggs=self.aggs, by=self.by) | ||||||
except Exception as e: | ||||||
raise DHError(e, "failed to set layout hints on rollup table") from e | ||||||
|
||||||
|
||||||
class TreeNodeOperationsRecorder(JObjectWrapper, _FormatOperationsRecorder, | ||||||
_SortOperationsRecorder, _FilterOperationsRecorder): | ||||||
|
@@ -343,6 +403,65 @@ def with_filters(self, filters: Union[str, Filter, Sequence[str], Sequence[Filte | |||||
except Exception as e: | ||||||
raise DHError(e, "with_filters operation on TreeTable failed.") from e | ||||||
|
||||||
def layout_hints(self, front: Union[str, List[str]] = None, back: Union[str, List[str]] = None, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. apply other comments here |
||||||
freeze: Union[str, List[str]] = None, hide: Union[str, List[str]] = None, | ||||||
column_groups: List[dict] = None, search_display_mode: SearchDisplayMode = None) -> Table: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
""" Sets layout hints on the TreeTable | ||||||
|
||||||
Args: | ||||||
front (Union[str, List[str]]): the columns to show at the front. | ||||||
back (Union[str, List[str]]): the columns to show at the back. | ||||||
freeze (Union[str, List[str]]): the columns to freeze to the front. | ||||||
These will not be affected by horizontal scrolling. | ||||||
hide (Union[str, List[str]]): the columns to hide. | ||||||
column_groups (List[Dict]): A list of dicts specifying which columns should be grouped in the UI. | ||||||
The dicts can specify the following: | ||||||
|
||||||
* name (str): The group name | ||||||
* children (List[str]): The column names in the group | ||||||
* color (Optional[str]): The hex color string or Deephaven color name | ||||||
search_display_mode (SearchDisplayMode): set the search bar to explicitly be accessible or inaccessible, | ||||||
or use the system default. :attr:`SearchDisplayMode.SHOW` will show the search bar, | ||||||
:attr:`SearchDisplayMode.HIDE` will hide the search bar, and :attr:`SearchDisplayMode.DEFAULT` will | ||||||
use the default value configured by the user and system settings. | ||||||
|
||||||
Returns: | ||||||
a new tree table with the layout hints set | ||||||
|
||||||
Raises: | ||||||
DHError | ||||||
""" | ||||||
try: | ||||||
_j_layout_hint_builder = _JLayoutHintBuilder.get() | ||||||
|
||||||
if front is not None: | ||||||
_j_layout_hint_builder.atFront(to_sequence(front)) | ||||||
|
||||||
if back is not None: | ||||||
_j_layout_hint_builder.atBack(to_sequence(back)) | ||||||
|
||||||
if freeze is not None: | ||||||
_j_layout_hint_builder.freeze(to_sequence(freeze)) | ||||||
|
||||||
if hide is not None: | ||||||
_j_layout_hint_builder.hide(to_sequence(hide)) | ||||||
|
||||||
if column_groups is not None: | ||||||
for group in column_groups: | ||||||
_j_layout_hint_builder.columnGroup(group.get("name"), j_array_list(group.get("children")), | ||||||
group.get("color", "")) | ||||||
|
||||||
if search_display_mode is not None: | ||||||
_j_layout_hint_builder.setSearchBarAccess(search_display_mode.value) | ||||||
|
||||||
except Exception as e: | ||||||
raise DHError(e, "failed to create layout hints") from e | ||||||
|
||||||
try: | ||||||
return TreeTable(j_tree_table=self.j_tree_table.setLayoutHints(_j_layout_hint_builder.build()), | ||||||
id_col=self.id_col, parent_col=self.parent_col) | ||||||
except Exception as e: | ||||||
raise DHError(e, "failed to set layout hints on tree table") from e | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Those classes don't extend |
||||||
def _j_py_script_session() -> _JPythonScriptSession: | ||||||
j_execution_context = _JExecutionContext.getContext() | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.