蓝色天空.知识 · 实践 · 创造
我的收藏
在线代码实验室

运行 Eclipse 视图容器重排、边缘停靠几何、Show View 分类过滤与属性联动离线核验

PYTHONWindows x64、CPython 3.12.14、Playwright 与本地浏览器/标准库。explore-explore-views.py
explore-explore-views.py129 行
"""Offline Eclipse Views, View Folder layout & Show View search verifier for Ch06 (explore-views)."""
import json

VERSION = "CPython 3.12.14 offline Eclipse view-folder layout verifier (desktop Eclipse SWT GUI absent)"


def check(name, summary, expected, actual):
    return {
        "name": name,
        "summary": summary,
        "expected": expected,
        "actual": actual,
        "passed": actual == expected,
    }


def dock_region_span(edge):
    if edge == "bottom":
        return {"orientation": "horizontal", "span": "full_window_width"}
    if edge in ("left", "right"):
        return {"orientation": "vertical", "span": "full_window_height"}
    return {"orientation": "embedded", "span": "editor_adjacent"}


def main():
    cases = []

    # Case 1: View folder tab stack organization & moving views between folders
    folders = {
        "folder_1": ["Problems", "Javadoc", "Declaration", "Console"],
        "folder_2": [],
    }
    initial_single_folder_count = len(folders["folder_1"])
    # Move two views from folder_1 into folder_2 (splitting 4 views across 2 folders)
    for view_name in ("Declaration", "Console"):
        folders["folder_1"].remove(view_name)
        folders["folder_2"].append(view_name)
    cases.append(
        check(
            "view_folder_tab_stack_operations",
            "Verify organizing 4 views in 1 view folder and moving view tabs into a second view folder",
            {
                "initial_folder1_count": 4,
                "after_move_folder1": ["Problems", "Javadoc"],
                "after_move_folder2": ["Declaration", "Console"],
            },
            {
                "initial_folder1_count": initial_single_folder_count,
                "after_move_folder1": folders["folder_1"],
                "after_move_folder2": folders["folder_2"],
            },
        )
    )

    # Case 2: Dynamic view folder creation & edge docking spans
    cases.append(
        check(
            "dynamic_view_folder_docking_geometry",
            "Verify dragging a view title to bottom creates full-width folder and left/right creates full-height folder",
            {
                "bottom": {"orientation": "horizontal", "span": "full_window_width"},
                "left": {"orientation": "vertical", "span": "full_window_height"},
                "right": {"orientation": "vertical", "span": "full_window_height"},
            },
            {
                "bottom": dock_region_span("bottom"),
                "left": dock_region_span("left"),
                "right": dock_region_span("right"),
            },
        )
    )

    # Case 3: Window -> Show View -> Other categorized search filter
    view_catalog = [
        ("General", "Navigator"),
        ("General", "Outline"),
        ("General", "Problems"),
        ("General", "Properties"),
        ("General", "Console"),
        ("Java", "Package Explorer"),
        ("Java", "Type Hierarchy"),
        ("Debug", "Breakpoints"),
        ("Debug", "Variables"),
    ]
    query = "pro"
    matches = [name for _, name in view_catalog if query in name.lower()]
    cases.append(
        check(
            "show_view_category_search_filter",
            "Verify Show View -> Other dialog category organization and incremental keyword filtering",
            {"categories": ["Debug", "General", "Java"], "matches_for_pro": ["Problems", "Properties"]},
            {
                "categories": sorted({cat for cat, _ in view_catalog}),
                "matches_for_pro": matches,
            },
        )
    )

    # Case 4: Navigator/Project metadata synchronized to Properties view
    selected_resource = {
        "path": "/demo-app/src/Main.java",
        "type": "File",
        "encoding": "UTF-8",
        "readonly": False,
    }
    properties_panel = {
        "Resource": selected_resource["path"],
        "Type": selected_resource["type"],
        "Text file encoding": selected_resource["encoding"],
    }
    cases.append(
        check(
            "editor_selection_to_properties_sync",
            "Verify selecting a resource in Navigator projects its metadata into the Properties view",
            {
                "Resource": "/demo-app/src/Main.java",
                "Type": "File",
                "Text file encoding": "UTF-8",
            },
            properties_panel,
        )
    )

    print(json.dumps({"version": VERSION, "cases": cases}, ensure_ascii=False, indent=2))


if __name__ == "__main__":
    main()
本例需在 Windows x64、CPython 3.12.14、Playwright 与本地浏览器/标准库。 中运行,请复制源码、保存文件或下载工程包后在本地执行验证。
运行说明与环境独立工程

运行环境:Windows x64、CPython 3.12.14、Playwright 与本地浏览器/标准库。

入口文件:projects/eclipse-explore-views-lab/explore-explore-views.py

本地运行步骤快速上手
  1. 点击上方“保存源码”保存为 explore-explore-views.py,或下载右侧课程工程包。
  2. 确认本地已准备 Windows x64、CPython 3.12.14、Playwright 与本地浏览器/标准库。。
  3. 按对应章节命令执行,结合正文核对实际输出。
附件与关联工程包下载

下载课程关联工程包:Eclipse

课程关联工程包(登记关联35章) · 含当前章节或实例 · mbskycom202612a2259.zip

下载课程关联工程包:Eclipse

课程关联工程包(登记关联1章) · 含当前章节或实例 · mbskycom202612a2274.zip
SITE SEARCH

搜索教程、工具与资讯

热门搜索

JavaScriptJSON格式化正则表达式AI 编程AI 翻译AI导航专题标签
Esc 关闭

欢迎登录蓝色天空网

使用会员账号,继续你的学习