|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | 3 | from concurrent.futures import CancelledError, Future |
| 4 | +from crystal.browser.entitytree_info import ( |
| 5 | + _GroupedNodeInfo, |
| 6 | + ResourceGroupNodeInfo, |
| 7 | + RootResourceNodeInfo, |
| 8 | +) |
4 | 9 | from crystal.browser.icons import ( |
5 | 10 | BADGED_ART_PROVIDER_TREE_NODE_ICON, BADGED_TREE_NODE_ICON, TREE_NODE_ICONS, |
6 | 11 | ) |
@@ -1203,18 +1208,7 @@ def calculate_title(self) -> str: |
1203 | 1208 |
|
1204 | 1209 | @staticmethod |
1205 | 1210 | def calculate_title_of(root_resource: RootResource) -> str: |
1206 | | - project = root_resource.project |
1207 | | - display_url = project.get_display_url(root_resource.url) |
1208 | | - if root_resource.name != '': |
1209 | | - entity_title_format = project.entity_title_format # cache |
1210 | | - if entity_title_format == 'name_url': |
1211 | | - return f'{root_resource.name} - {display_url}' |
1212 | | - elif entity_title_format == 'url_name': |
1213 | | - return f'{display_url} - {root_resource.name}' |
1214 | | - else: |
1215 | | - assert_never(entity_title_format) |
1216 | | - else: |
1217 | | - return f'{display_url}' |
| 1211 | + return RootResourceNodeInfo.calculate_title_of(root_resource) |
1218 | 1212 |
|
1219 | 1213 | @override |
1220 | 1214 | @property |
@@ -1376,8 +1370,8 @@ def __hash__(self): |
1376 | 1370 | class _GroupedNode(Node): # abstract |
1377 | 1371 | entity_tooltip: str # abstract |
1378 | 1372 |
|
1379 | | - ICON = '📁' |
1380 | | - ICON_TRUNCATION_FIX = ' ' |
| 1373 | + ICON = _GroupedNodeInfo.ICON |
| 1374 | + ICON_TRUNCATION_FIX = _GroupedNodeInfo.ICON_TRUNCATION_FIX |
1381 | 1375 |
|
1382 | 1376 | def __init__(self, |
1383 | 1377 | resource_group: ResourceGroup, |
@@ -1460,18 +1454,7 @@ def calculate_title(self) -> str: |
1460 | 1454 |
|
1461 | 1455 | @staticmethod |
1462 | 1456 | def calculate_title_of(resource_group: ResourceGroup) -> str: |
1463 | | - project = resource_group.project |
1464 | | - display_url = project.get_display_url(resource_group.url_pattern) |
1465 | | - if resource_group.name != '': |
1466 | | - entity_title_format = project.entity_title_format # cache |
1467 | | - if entity_title_format == 'name_url': |
1468 | | - return f'{resource_group.name} - {display_url}' |
1469 | | - elif entity_title_format == 'url_name': |
1470 | | - return f'{display_url} - {resource_group.name}' |
1471 | | - else: |
1472 | | - assert_never(entity_title_format) |
1473 | | - else: |
1474 | | - return f'{display_url}' |
| 1457 | + return ResourceGroupNodeInfo.calculate_title_of(resource_group) |
1475 | 1458 |
|
1476 | 1459 | @override |
1477 | 1460 | @property |
|
0 commit comments