Eclipse 4 RCPアプリケーションがあります。パラメータ "-clearPersistedState"は、後で起動するときにウィンドウのサイズと位置が復元されるように明示的には使用されません。 問題は、 ".metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi"に永続化されたモデルは、アプリケーション状態全体を含んでいることです。アプリケーションのモデルを後のバージョンで、例えば、新しいメニュー項目とそれに関連するコマンドを追加すると、これらの追加は永続が見つかると無視されます。 "-deltaRestore"を使用しても動作しません。workbench.xmiの読み込み時にEclipse 4 RCPアプリケーションモデルの新しいメニュー項目が表示されない
"workbench.xmi"から状態を復元するのではなく、アプリケーションの特定の部分をアプリケーションモデルでどのように定義するかをどうすればよいでしょうか? 代わりに、ウィンドウのサイズと位置を永続化/復元することはできますか?
初期モデル:
<?xml version="1.0" encoding="ASCII"?>
<application:Application xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:advanced="http://www.eclipse.org/ui/2010/UIModel/application/ui/advanced" xmlns:application="http://www.eclipse.org/ui/2010/UIModel/application" xmlns:basic="http://www.eclipse.org/ui/2010/UIModel/application/ui/basic" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmi:id="_KdFcsQlbEee-eMrs46logg" elementId="RCPTest.application" contributorURI="platform:/plugin/RCPTest" selectedElement="_KdFcsglbEee-eMrs46logg" bindingContexts="_KdFcvwlbEee-eMrs46logg">
<children xsi:type="basic:TrimmedWindow" xmi:id="_KdFcsglbEee-eMrs46logg" elementId="RCPTest.window.main" contributorURI="platform:/plugin/RCPTest" selectedElement="_KdFcswlbEee-eMrs46logg" label="Eclipse 4 RCP Application" x="223" y="217" width="1318" height="610">
<tags>topLevel</tags>
<children xsi:type="advanced:PerspectiveStack" xmi:id="_KdFcswlbEee-eMrs46logg" elementId="org.eclipse.ui.ide.perspectivestack" contributorURI="platform:/plugin/RCPTest" selectedElement="_KdFctAlbEee-eMrs46logg">
<children xsi:type="advanced:Perspective" xmi:id="_KdFctAlbEee-eMrs46logg" elementId="RCPTest.perspective.sample" contributorURI="platform:/plugin/RCPTest" selectedElement="_KdFctQlbEee-eMrs46logg">
<children xsi:type="basic:PartSashContainer" xmi:id="_KdFctQlbEee-eMrs46logg" elementId="RCPTest.partsashcontainer.sample" contributorURI="platform:/plugin/RCPTest" selectedElement="_KdFctglbEee-eMrs46logg">
<children xsi:type="basic:PartStack" xmi:id="_KdFctglbEee-eMrs46logg" elementId="RCPTest.partstack.sample" contributorURI="platform:/plugin/RCPTest" containerData="5000" selectedElement="_KdFctwlbEee-eMrs46logg">
<tags>active</tags>
<children xsi:type="basic:Part" xmi:id="_KdFctwlbEee-eMrs46logg" elementId="RCPTest.part.sample" contributorURI="platform:/plugin/RCPTest" contributionURI="bundleclass://RCPTest/rcptest.parts.SamplePart" label="Sample Part">
<tags>active</tags>
</children>
</children>
</children>
</children>
</children>
<mainMenu xmi:id="_KdFcuAlbEee-eMrs46logg" elementId="org.eclipse.ui.main.menu" contributorURI="platform:/plugin/RCPTest">
<children xsi:type="menu:Menu" xmi:id="_KdFcuQlbEee-eMrs46logg" elementId="file" contributorURI="platform:/plugin/RCPTest" label="File">
<children xsi:type="menu:HandledMenuItem" xmi:id="_KdFcuglbEee-eMrs46logg" elementId="RCPTest.handleditem.quit" contributorURI="platform:/plugin/RCPTest" label="Quit" command="_KdFcwglbEee-eMrs46logg"/>
</children>
<children xsi:type="menu:Menu" xmi:id="_KdFcuwlbEee-eMrs46logg" elementId="help" contributorURI="platform:/plugin/RCPTest" label="Help"/>
</mainMenu>
</children>
<handlers xmi:id="_KdFcvAlbEee-eMrs46logg" elementId="rcptest.handler.quitCommand" contributorURI="platform:/plugin/RCPTest" contributionURI="bundleclass://RCPTest/rcptest.handlers.QuitHandler" command="_KdFcwglbEee-eMrs46logg"/>
<bindingTables xmi:id="_KdFcvQlbEee-eMrs46logg" elementId="RCPTest.bindingtable" contributorURI="platform:/plugin/RCPTest" bindingContext="_KdFcvwlbEee-eMrs46logg">
<bindings xmi:id="_KdFcvglbEee-eMrs46logg" elementId="RCPTest.keybinding.m1q" contributorURI="platform:/plugin/RCPTest" keySequence="M1+Q" command="_KdFcwglbEee-eMrs46logg"/>
</bindingTables>
<rootContext xmi:id="_KdFcvwlbEee-eMrs46logg" elementId="org.eclipse.ui.contexts.dialogAndWindow" contributorURI="platform:/plugin/RCPTest" name="In Dialog and Windows">
<children xmi:id="_KdFcwAlbEee-eMrs46logg" elementId="org.eclipse.ui.contexts.window" contributorURI="platform:/plugin/RCPTest" name="In Windows"/>
<children xmi:id="_KdFcwQlbEee-eMrs46logg" elementId="org.eclipse.ui.contexts.dialog" contributorURI="platform:/plugin/RCPTest" name="In Dialogs"/>
</rootContext>
<commands xmi:id="_KdFcwglbEee-eMrs46logg" elementId="org.eclipse.ui.file.exit" contributorURI="platform:/plugin/RCPTest" commandName="quitCommand"/>
<addons xmi:id="_KdFcwwlbEee-eMrs46logg" elementId="org.eclipse.e4.core.commands.service" contributorURI="platform:/plugin/RCPTest" contributionURI="bundleclass://org.eclipse.e4.core.commands/org.eclipse.e4.core.commands.CommandServiceAddon"/>
<addons xmi:id="_KdFcxAlbEee-eMrs46logg" elementId="org.eclipse.e4.ui.contexts.service" contributorURI="platform:/plugin/RCPTest" contributionURI="bundleclass://org.eclipse.e4.ui.services/org.eclipse.e4.ui.services.ContextServiceAddon"/>
<addons xmi:id="_KdFcxQlbEee-eMrs46logg" elementId="org.eclipse.e4.ui.bindings.service" contributorURI="platform:/plugin/RCPTest" contributionURI="bundleclass://org.eclipse.e4.ui.bindings/org.eclipse.e4.ui.bindings.BindingServiceAddon"/>
<addons xmi:id="_KdFcxglbEee-eMrs46logg" elementId="org.eclipse.e4.ui.workbench.commands.model" contributorURI="platform:/plugin/RCPTest" contributionURI="bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.CommandProcessingAddon"/>
<addons xmi:id="_KdFcxwlbEee-eMrs46logg" elementId="org.eclipse.e4.ui.workbench.handler.model" contributorURI="platform:/plugin/RCPTest" contributionURI="bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.HandlerProcessingAddon"/>
<addons xmi:id="_KdFcyAlbEee-eMrs46logg" elementId="org.eclipse.e4.ui.workbench.contexts.model" contributorURI="platform:/plugin/RCPTest" contributionURI="bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.ContextProcessingAddon"/>
<addons xmi:id="_KdFcyQlbEee-eMrs46logg" elementId="org.eclipse.e4.ui.workbench.bindings.model" contributorURI="platform:/plugin/RCPTest" contributionURI="bundleclass://org.eclipse.e4.ui.workbench.swt/org.eclipse.e4.ui.workbench.swt.util.BindingProcessingAddon"/>
</application:Application>
新しいメニュー項目を追加することによって拡張アプリケーションモデル::
<?xml version="1.0" encoding="UTF-8"?>
<application:Application xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:advanced="http://www.eclipse.org/ui/2010/UIModel/application/ui/advanced" xmlns:application="http://www.eclipse.org/ui/2010/UIModel/application" xmlns:basic="http://www.eclipse.org/ui/2010/UIModel/application/ui/basic" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmi:id="_6wlLcMgZEeSyMNYR5xypkQ" elementId="RCPTest.application" bindingContexts="_6wlLecgZEeSyMNYR5xypkQ">
<children xsi:type="basic:TrimmedWindow" xmi:id="_6wlLccgZEeSyMNYR5xypkQ" elementId="RCPTest.window.main" label="Eclipse 4 RCP Application" width="500" height="400">
<children xsi:type="advanced:PerspectiveStack" xmi:id="_6wlLkMgZEeSyMNYR5xypkQ" elementId="org.eclipse.ui.ide.perspectivestack">
<children xsi:type="advanced:Perspective" xmi:id="_6wlLkcgZEeSyMNYR5xypkQ" elementId="RCPTest.perspective.sample">
<children xsi:type="basic:PartSashContainer" xmi:id="_6wlLksgZEeSyMNYR5xypkQ" elementId="RCPTest.partsashcontainer.sample">
<children xsi:type="basic:PartStack" xmi:id="_6wlLk8gZEeSyMNYR5xypkQ" elementId="RCPTest.partstack.sample">
<children xsi:type="basic:Part" xmi:id="_6wlLlMgZEeSyMNYR5xypkQ" elementId="RCPTest.part.sample" contributionURI="bundleclass://RCPTest/rcptest.parts.SamplePart" label="Sample Part"/>
</children>
</children>
</children>
</children>
<mainMenu xmi:id="_6wlLicgZEeSyMNYR5xypkQ" elementId="org.eclipse.ui.main.menu">
<children xsi:type="menu:Menu" xmi:id="_6wlLisgZEeSyMNYR5xypkQ" elementId="file" label="File">
<children xsi:type="menu:HandledMenuItem" xmi:id="_rocOUAlbEeeFFeCZvXOsLw" elementId="rcptest.handledmenuitem.test" label="Test" command="_oTNX4AlbEeeFFeCZvXOsLw"/>
<children xsi:type="menu:HandledMenuItem" xmi:id="_6wlLjcgZEeSyMNYR5xypkQ" elementId="RCPTest.handleditem.quit" label="Quit" command="_6wlLfMgZEeSyMNYR5xypkQ"/>
</children>
<children xsi:type="menu:Menu" xmi:id="_6wlLjsgZEeSyMNYR5xypkQ" elementId="help" label="Help"/>
</mainMenu>
</children>
<handlers xmi:id="_6wlLfcgZEeSyMNYR5xypkQ" elementId="rcptest.handler.quitCommand" contributionURI="bundleclass://RCPTest/rcptest.handlers.QuitHandler" command="_6wlLfMgZEeSyMNYR5xypkQ"/>
<handlers xmi:id="_pjrhQAlbEeeFFeCZvXOsLw" elementId="rcptest.handler.test" contributionURI="bundleclass://RCPTest/rcptest.handlers.TestHandler" command="_oTNX4AlbEeeFFeCZvXOsLw"/>
<bindingTables xmi:id="_6wlLfsgZEeSyMNYR5xypkQ" elementId="RCPTest.bindingtable" bindingContext="_6wlLecgZEeSyMNYR5xypkQ">
<bindings xmi:id="_6wlLf8gZEeSyMNYR5xypkQ" elementId="RCPTest.keybinding.m1q" keySequence="M1+Q" command="_6wlLfMgZEeSyMNYR5xypkQ"/>
</bindingTables>
<rootContext xmi:id="_6wlLecgZEeSyMNYR5xypkQ" elementId="org.eclipse.ui.contexts.dialogAndWindow" name="In Dialog and Windows">
<children xmi:id="_6wlLesgZEeSyMNYR5xypkQ" elementId="org.eclipse.ui.contexts.window" name="In Windows"/>
<children xmi:id="_6wlLe8gZEeSyMNYR5xypkQ" elementId="org.eclipse.ui.contexts.dialog" name="In Dialogs"/>
</rootContext>
<commands xmi:id="_6wlLfMgZEeSyMNYR5xypkQ" elementId="org.eclipse.ui.file.exit" commandName="quitCommand"/>
<commands xmi:id="_oTNX4AlbEeeFFeCZvXOsLw" elementId="rcptest.command.test" commandName="test"/>
<addons xmi:id="_6wlLcsgZEeSyMNYR5xypkQ" elementId="org.eclipse.e4.core.commands.service" contributionURI="bundleclass://org.eclipse.e4.core.commands/org.eclipse.e4.core.commands.CommandServiceAddon"/>
<addons xmi:id="_6wlLc8gZEeSyMNYR5xypkQ" elementId="org.eclipse.e4.ui.contexts.service" contributionURI="bundleclass://org.eclipse.e4.ui.services/org.eclipse.e4.ui.services.ContextServiceAddon"/>
<addons xmi:id="_6wlLdMgZEeSyMNYR5xypkQ" elementId="org.eclipse.e4.ui.bindings.service" contributionURI="bundleclass://org.eclipse.e4.ui.bindings/org.eclipse.e4.ui.bindings.BindingServiceAddon"/>
<addons xmi:id="_6wlLdcgZEeSyMNYR5xypkQ" elementId="org.eclipse.e4.ui.workbench.commands.model" contributionURI="bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.CommandProcessingAddon"/>
<addons xmi:id="_6wlLdsgZEeSyMNYR5xypkQ" elementId="org.eclipse.e4.ui.workbench.handler.model" contributionURI="bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.HandlerProcessingAddon"/>
<addons xmi:id="_6wlLd8gZEeSyMNYR5xypkQ" elementId="org.eclipse.e4.ui.workbench.contexts.model" contributionURI="bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.ContextProcessingAddon"/>
<addons xmi:id="_6wlLeMgZEeSyMNYR5xypkQ" elementId="org.eclipse.e4.ui.workbench.bindings.model" contributionURI="bundleclass://org.eclipse.e4.ui.workbench.swt/org.eclipse.e4.ui.workbench.swt.util.BindingProcessingAddon"/>
</application:Application>
を
<?xml version="1.0" encoding="UTF-8"?>
<application:Application xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:advanced="http://www.eclipse.org/ui/2010/UIModel/application/ui/advanced" xmlns:application="http://www.eclipse.org/ui/2010/UIModel/application" xmlns:basic="http://www.eclipse.org/ui/2010/UIModel/application/ui/basic" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmi:id="_6wlLcMgZEeSyMNYR5xypkQ" elementId="RCPTest.application" bindingContexts="_6wlLecgZEeSyMNYR5xypkQ">
<children xsi:type="basic:TrimmedWindow" xmi:id="_6wlLccgZEeSyMNYR5xypkQ" elementId="RCPTest.window.main" label="Eclipse 4 RCP Application" width="500" height="400">
<children xsi:type="advanced:PerspectiveStack" xmi:id="_6wlLkMgZEeSyMNYR5xypkQ" elementId="org.eclipse.ui.ide.perspectivestack">
<children xsi:type="advanced:Perspective" xmi:id="_6wlLkcgZEeSyMNYR5xypkQ" elementId="RCPTest.perspective.sample">
<children xsi:type="basic:PartSashContainer" xmi:id="_6wlLksgZEeSyMNYR5xypkQ" elementId="RCPTest.partsashcontainer.sample">
<children xsi:type="basic:PartStack" xmi:id="_6wlLk8gZEeSyMNYR5xypkQ" elementId="RCPTest.partstack.sample">
<children xsi:type="basic:Part" xmi:id="_6wlLlMgZEeSyMNYR5xypkQ" elementId="RCPTest.part.sample" contributionURI="bundleclass://RCPTest/rcptest.parts.SamplePart" label="Sample Part"/>
</children>
</children>
</children>
</children>
<mainMenu xmi:id="_6wlLicgZEeSyMNYR5xypkQ" elementId="org.eclipse.ui.main.menu">
<children xsi:type="menu:Menu" xmi:id="_6wlLisgZEeSyMNYR5xypkQ" elementId="file" label="File">
<children xsi:type="menu:HandledMenuItem" xmi:id="_6wlLjcgZEeSyMNYR5xypkQ" elementId="RCPTest.handleditem.quit" label="Quit" command="_6wlLfMgZEeSyMNYR5xypkQ"/>
</children>
<children xsi:type="menu:Menu" xmi:id="_6wlLjsgZEeSyMNYR5xypkQ" elementId="help" label="Help"/>
</mainMenu>
</children>
<handlers xmi:id="_6wlLfcgZEeSyMNYR5xypkQ" elementId="rcptest.handler.quitCommand" contributionURI="bundleclass://RCPTest/rcptest.handlers.QuitHandler" command="_6wlLfMgZEeSyMNYR5xypkQ"/>
<bindingTables xmi:id="_6wlLfsgZEeSyMNYR5xypkQ" elementId="RCPTest.bindingtable" bindingContext="_6wlLecgZEeSyMNYR5xypkQ">
<bindings xmi:id="_6wlLf8gZEeSyMNYR5xypkQ" elementId="RCPTest.keybinding.m1q" keySequence="M1+Q" command="_6wlLfMgZEeSyMNYR5xypkQ"/>
</bindingTables>
<rootContext xmi:id="_6wlLecgZEeSyMNYR5xypkQ" elementId="org.eclipse.ui.contexts.dialogAndWindow" name="In Dialog and Windows">
<children xmi:id="_6wlLesgZEeSyMNYR5xypkQ" elementId="org.eclipse.ui.contexts.window" name="In Windows"/>
<children xmi:id="_6wlLe8gZEeSyMNYR5xypkQ" elementId="org.eclipse.ui.contexts.dialog" name="In Dialogs"/>
</rootContext>
<commands xmi:id="_6wlLfMgZEeSyMNYR5xypkQ" elementId="org.eclipse.ui.file.exit" commandName="quitCommand"/>
<addons xmi:id="_6wlLcsgZEeSyMNYR5xypkQ" elementId="org.eclipse.e4.core.commands.service" contributionURI="bundleclass://org.eclipse.e4.core.commands/org.eclipse.e4.core.commands.CommandServiceAddon"/>
<addons xmi:id="_6wlLc8gZEeSyMNYR5xypkQ" elementId="org.eclipse.e4.ui.contexts.service" contributionURI="bundleclass://org.eclipse.e4.ui.services/org.eclipse.e4.ui.services.ContextServiceAddon"/>
<addons xmi:id="_6wlLdMgZEeSyMNYR5xypkQ" elementId="org.eclipse.e4.ui.bindings.service" contributionURI="bundleclass://org.eclipse.e4.ui.bindings/org.eclipse.e4.ui.bindings.BindingServiceAddon"/>
<addons xmi:id="_6wlLdcgZEeSyMNYR5xypkQ" elementId="org.eclipse.e4.ui.workbench.commands.model" contributionURI="bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.CommandProcessingAddon"/>
<addons xmi:id="_6wlLdsgZEeSyMNYR5xypkQ" elementId="org.eclipse.e4.ui.workbench.handler.model" contributionURI="bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.HandlerProcessingAddon"/>
<addons xmi:id="_6wlLd8gZEeSyMNYR5xypkQ" elementId="org.eclipse.e4.ui.workbench.contexts.model" contributionURI="bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.ContextProcessingAddon"/>
<addons xmi:id="_6wlLeMgZEeSyMNYR5xypkQ" elementId="org.eclipse.e4.ui.workbench.bindings.model" contributionURI="bundleclass://org.eclipse.e4.ui.workbench.swt/org.eclipse.e4.ui.workbench.swt.util.BindingProcessingAddon"/>
</application:Application>
"workbench.xmi" は、このバージョンで持続
保存された「workbench.xmi」がロードされたときのメニューの表示方法:
そして、これは私が最初に「workbench.xmi」を削除するか、メニューであることの後に任意のスタートアップ:
解決策は私の現在のユースケースで十分です。アプリケーションモデルの保存/読み込みをカスタマイズする別のソリューションがあるようです:http://www.vogella.com/tutorials/Eclipse4ModelPersistence/article.html#store-certain-model-elements –