首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> Java 程式設計 >> Java 相關知識

打造專屬品牌的 Eclipse RCP 產品:Production Configuration 完整實戰

     編輯:Java 相關知識

為何需要 Product Configuration?

Eclipse 3.1 引入 Production Configuration 前,RCP 應用打包分發極其繁瑣。該功能讓開發者將應用、依賴外掛、品牌元素一鍵封裝為獨立可執行產品,徹底脫離 Eclipse 平台依賴。

範例應用:Frog Across River 遊戲

  • 基於 Hello RCP 模板建立外掛專案 com.example.zyx
  • 實作 IPlatformRunnable 入口,雙緩衝繪圖遊戲邏輯(GameView)
  • 擴展點 org.eclipse.ui.views 註冊視圖

建立 .product 配置檔

  1. File → New → Product Configuration,父資料夾選專案,檔名 myProduct.product
  2. Overview 分頁:
    • Product Name:%productName(引用 plugin.properties)
    • Product ID:新增 → Defining Plug-in com.example.zyx → Application com.example.zyx.application → ID product
    • 基於:plug-ins

Configuration 分頁:定義執行時組合

  • Add Required Plug-ins 自動解析依賴
  • Config File:config.ini,關鍵屬性:
    osgi.splashPath=platform:/base/plugins/com.example.zyx
    eclipse.product=com.example.zyx.product
    osgi.bundles.defaultStartLevel=4

Launcher 分頁:自訂啟動器

  • Launcher Name:FrogAcrossRiver(產生 .exe/.ini)
  • 圖標:單一 .ico 包含 7 種尺寸/色深(16×16~48×48,4/8/32 位)
  • Program Arguments:-console(啟動時顯示主控台)

Branding 分頁:全方位品牌化

元素配置要點
Splash Screen根目錄 splash.bmp,進度條/訊息偏移座標設定
視窗圖示16×16(標題列/工作列)、32×32(Alt+Tab),GIF 格式
About 對話框圖示 + 文字(引用 plugin.properties 的 %productBlurb)
歡迎頁面擴展 org.eclipse.ui.intro + org.eclipse.ui.intro.config,HTML 內容

關鍵屬性注入 plugin.xml

<property name="preferenceCustomization" value="plugin_customization.ini"/>
<property name="windowImages" value="icons/alt_window_16.gif,icons/alt_window_32.gif"/>

選單動作啟用

// Help → About
aboutAction = ActionFactory.ABOUT.create(window);
helpMenu.add(aboutAction);

// Help → Welcome
introAction = ActionFactory.INTRO.create(window);
helpMenu.add(introAction);

匯出與分發

  1. Overview 分頁 → Launch the product 測試
  2. Eclipse Product export wizard → 目標目錄 C:\export\MyProduct
  3. 驗證 FrogAcrossRiver.exe 圖標、.ini 參數
  4. 無 JRE 環境機器:將 JRE 目錄複製至產品根目錄即可運行

常見問題排查

  • .ico 缺少規定尺寸 → 啟動器品牌化失敗
  • Program Arguments 加 -clean 會隱藏 Splash Screen

圖示說明

RCP 應用類別圖
RCP 遊戲運行截圖
新增 Product Configuration 向導
導入品牌資源
Overview 分頁配置
產品名稱顯示於標題列
Configuration 分頁
Launcher 分頁
匯出後的 exe 與 ini
Splash Screen 配置
啟動時進度條與訊息
視窗圖示配置
Alt+Tab 32x32 圖示
About 對話框配置
About 對話框成品
歡迎頁面配置
歡迎頁面成品
檔案系統中的匯出產品
加入 JRE 目錄

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved