Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Restore a workbenchpage with an external memento.xml without closing eclipse 3.1
Restore a workbenchpage with an external memento.xml without closing eclipse 3.1 [message #443345] Fri, 27 January 2006 12:54 Go to next message
Eclipse UserFriend
Originally posted by: c.kuepferle.tuhh.de

Dear all,

I am having a problem concerning a restore of a workbench page.

Reading the bug track from Bug 85373 - [RCP] Missing save/restore
capabilities of workbench state
https://bugs.eclipse.org/bugs/show_bug.cgi?id=85373

I' ve got some insight concerning the concept of using the restore
mechanism in eclipse 3.1 and the ideas for following releases. I am not
sure if I encountered a bug or if my approach is wrong.

Use Case:
I want to switch Perspectives, during runtime and have the page set
(restored) to a predefined state saved previously in a XMLMemento (same
format as the workbech.xml in
.../.metadata/.plugins/org.eclipse.ui.workbench/ ) coming from somewhere
in my file system. The views and editors are opened correctly according
to the memento, the only problem I have is that every time I call
WorkbenchPage.restoreState( IMemento myCustomMemento), the editor area
is split in half (this is definitely not in the memento), where the one
half is correctly stacked with the right editors, but the other half is
just painted grey. If I randomly move the opened editors around the grey
areas disappears suddenly and the page looks find now. Could this be an
event problem or do I use the frame work in the wrong way.

the following method performs the switch to another perspective and its
populated with a predefined state from the Memento:

public static boolean nextPerspective(String urlWithPageState, String
perspectiveID, IWorkbenchPage activePage)
{

final IWorkbench workbench = PlatformUI.getWorkbench();

final IPerspectiveRegistry registry =
workbench.getPerspectiveRegistry();

try {

XMLMemento memento = XMLMemento.createReadRoot(new
FileReader( urlWithPageState));
IMemento windowMemento =
memento.getChild(IWorkbenchConstants.TAG_WINDOW);
IMemento pageMemento =
windowMemento.getChild(IWorkbenchConstants.TAG_PAGE);

IPerspectiveDescriptor realDesc =
registry.findPerspectiveWithId(perspectiveID);
IPerspectiveDescriptor oldPerspectiveDesc =
activePage.getPerspective();
activePage.closePerspective(oldPerspectiveDesc, true, false);

((WorkbenchPage) activePage).restoreState(pageMemento, null);
activePage.setPerspective(realDesc);
activePage.resetPerspective();

} catch (IOException e) {
e.printStackTrace();
handleException(e, page);
return false;
} catch (WorkbenchException e) {
e.printStackTrace();
handleException(e, page);
return false;
}

return true;
}

XML Memento:

<?xml version="1.0" encoding="UTF-8"?>
<workbench version="2.0" progressCount="13">
<workbenchAdvisor/>
<window maximized="true" x="132" y="132" width="1024" height="768">
<fastViewData fastViewLocation="1024"/>
<perspectiveBar>
<itemSize x="160"/>
</perspectiveBar>
<coolbarLayout locked="0">
<coolItem id="group.file" itemType="typeGroupMarker"/>
<coolItem id="org.eclipse.ui.workbench.file"
itemType="typeToolBarContribution" x="95" y="22"/>
<coolItem id="additions" itemType="typeGroupMarker"/>
<coolItem id="KalypsoDSSPlanerClient.actionSet"
itemType="typeToolBarContribution" x="59" y="22"/>
<coolItem id="org.eclipse.debug.ui.launchActionSet"
itemType="typeToolBarContribution" x="49" y="22"/>
<coolItem id="org.eclipse.search.searchActionSet"
itemType="typeToolBarContribution" x="36" y="22"/>
<coolItem id="group.nav" itemType="typeGroupMarker"/>
<coolItem id="org.eclipse.ui.workbench.navigate"
itemType="typeToolBarContribution" x="108" y="22"/>
<coolItem id="group.editor" itemType="typeGroupMarker"/>
<coolItem id="org.eclipse.ui.DefaultTextEditor"
itemType="typeToolBarContribution" x="-1" y="-1"/>
<coolItem id="group.help" itemType="typeGroupMarker"/>
<coolItem id="org.eclipse.ui.workbench.help"
itemType="typeToolBarContribution" x="-1" y="-1"/>
</coolbarLayout>
<page label="&lt;Unknown Label&gt; - Kalypso Planer-Client Phase 2"
focus="true">
<editors>
<editorArea activeWorkbook="DefaultEditorWorkbook">
<info part="DefaultEditorWorkbook">
<folder expanded="2" appearance="1">
<presentation
id="org.eclipse.ui.presentations.WorkbenchPresentationFactory ">
<part id="0"/>
</presentation>
</folder>
</info>
<info part="org.eclipse.ui.internal.EditorStack@45f4ae"
relative="DefaultEditorWorkbook" relationship="4" ratioLeft="335"
ratioRight="336" ratio="0.49925485">
<folder expanded="2" appearance="1">
<presentation
id="org.eclipse.ui.presentations.WorkbenchPresentationFactory ">
<part id="0"/>
</presentation>
</folder>
</info>
</editorArea>
<editor title="phase2.txt" name="phase2.txt"
id="org.eclipse.ui.DefaultTextEditor" tooltip="MyTestProject/phase2.txt"
partName="phase2.txt" workbook="DefaultEditorWorkbook" activePart="true"
focus="true"
path="D:/eclipse3.1/runtime-workspace/MyTestProject/phase2.txt ">
<input factoryID="org.eclipse.ui.part.FileEditorInputFactory"
path="/MyTestProject/phase2.txt"/>
</editor>
<editor title="filelInFolder2.txt" name="filelInFolder2.txt"
id="org.eclipse.ui.DefaultTextEditor"
tooltip="MyTestProject/Folder2/filelInFolder2.txt"
partName="filelInFolder2.txt"
workbook="org.eclipse.ui.internal.EditorStack@45f4ae" focus="true"
path=" D:/eclipse3.1/runtime-workspace/MyTestProject/Folder2/filelI nFolder2.txt ">
<input factoryID="org.eclipse.ui.part.FileEditorInputFactory"
path="/MyTestProject/Folder2/filelInFolder2.txt"/>
</editor>
</editors>
<views>
<view id="org.kalypso.dss.planerclient.view.browser" partName="Kalypso
Browser">
<viewState url="file:///D:/TEMP/Perspectives/DssPlanerClient.htm">
<scrolbars/>
</viewState>
</view>
<view id="org.eclipse.ui.views.ResourceNavigator" partName="Navigator">
<viewState sorter="1" LINK_NAVIGATOR_TO_EDITOR="1">
<filters>
<filter element="*.class" isEnabled="false"/>
<filter element=".*" isEnabled="true"/>
</filters>
<expanded>
<element path="/MyTestProject"/>
<element path="/MyTestProject/Folder1"/>
<element path="/MyTestProject/Folder2"/>
</expanded>
<selection>
<element path="/MyTestProject/phase2.txt"/>
</selection>
</viewState>
</view>
</views>
<perspectives
activePerspective="org.kalypso.dss.planerclient.perspectiv.phase.two "
activePart="org.eclipse.ui.DefaultTextEditor">
<perspective version="0.016" editorAreaVisible="1" fixed="0">
<descriptor id="org.kalypso.dss.planerclient.perspectiv.phase.two"
label="Kalypso Planer-Client Phase 2"
class=" org.kalypso.dss.planerclient.perspectives.KalypsoDssPlanerPh aseTwoClientPerspectiveFactory "/>
<alwaysOnActionSet id="org.eclipse.ui.cheatsheets.actionSet"/>
<alwaysOnActionSet id="org.eclipse.search.searchActionSet"/>
<alwaysOnActionSet
id="org.eclipse.ui.edit.text.actionSet.openExternalFile"/>
<alwaysOnActionSet id="org.eclipse.ui.edit.text.actionSet.navigation"/>
<alwaysOnActionSet
id="org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo "/>
<alwaysOnActionSet id="org.eclipse.ui.externaltools.ExternalToolsSet"/>
<alwaysOnActionSet id="KalypsoDSSPlanerClient.actionSet"/>
<alwaysOnActionSet id="org.eclipse.ui.actionSet.keyBindings"/>
<alwaysOnActionSet id="org.eclipse.update.ui.softwareUpdates"/>
<new_wizard_action id="org.eclipse.ui.wizards.new.folder"/>
<new_wizard_action id="org.eclipse.ui.wizards.new.file"/>
<view id="org.eclipse.ui.views.ResourceNavigator"/>
<view id="org.kalypso.dss.planerclient.view.browser"/>
<layout>
<mainWindow>
<info part="org.eclipse.ui.editorss"/>
<info part="stickyFolderRight" relative="org.eclipse.ui.editorss"
relationship="2" ratioLeft="754" ratioRight="252" ratio="0.74950296"
folder="true">
<folder expanded="2" appearance="2">
<page label="LabelNotFound" content="org.eclipse.help.ui.HelpView"/>
<page label="LabelNotFound" content="org.eclipse.ui.internal.introview"/>
<page label="LabelNotFound"
content="org.eclipse.ui.cheatsheets.views.CheatSheetView"/ >
</folder>
</info>
<info part="topRight" relative="org.eclipse.ui.editorss"
relationship="2" ratioLeft="653" ratioRight="353" ratio="0.64910537"
folder="true">
<folder activePageID="org.eclipse.ui.views.ResourceNavigator"
expanded="2" appearance="2">
<page label="Navigator" content="org.eclipse.ui.views.ResourceNavigator"/>
<presentation
id="org.eclipse.ui.presentations.WorkbenchPresentationFactory ">
<part id="0"/>
</presentation>
</folder>
</info>
<info part="bottomRight" relative="org.eclipse.ui.editorss"
relationship="4" ratioLeft="440" ratioRight="227" ratio="0.6596702"
folder="true">
<folder activePageID="org.kalypso.dss.planerclient.view.browser"
expanded="2" appearance="2">
<page label="Kalypso Browser"
content="org.kalypso.dss.planerclient.view.browser"/>
<presentation
id="org.eclipse.ui.presentations.WorkbenchPresentationFactory ">
<part id="0"/>
</presentation>
</folder>
</info>
</mainWindow>
</layout>
</perspective>
</perspectives>
<navigationHistory/>
<stickyState/>
</page>
<workbenchWindowAdvisor/>
<actionBarAdvisor/>
</window>
<mruList>
<file factoryID="org.eclipse.ui.part.FileEditorInputFactory"
id="org.eclipse.ui.DefaultTextEditor" name="filelInFolder2.txt"
tooltip="MyTestProject/Folder2/filelInFolder2.txt">
<persistable path="/MyTestProject/Folder2/filelInFolder2.txt"/>
</file>
<file factoryID="org.eclipse.ui.part.FileEditorInputFactory"
id="org.eclipse.ui.DefaultTextEditor" name="phase2.txt"
tooltip="MyTestProject/phase2.txt">
<persistable path="/MyTestProject/phase2.txt"/>
</file>
<file factoryID="org.eclipse.ui.part.FileEditorInputFactory"
id="org.eclipse.ui.DefaultTextEditor" name="fileInFolder1.txt"
tooltip="MyTestProject/Folder1/fileInFolder1.txt">
<persistable path="/MyTestProject/Folder1/fileInFolder1.txt"/>
</file>
<file factoryID="org.eclipse.ui.part.FileEditorInputFactory"
id="org.eclipse.ui.DefaultTextEditor" name="phase1.txt"
tooltip="MyTestProject/phase1.txt">
<persistable path="/MyTestProject/phase1.txt"/>
</file>
</mruList>
</workbench>


This method is called from the LocationListener.changed(LocationEvent
event) of my own BrowserViewer (extends ViewPart and decorates the
eclipse BrowserViewer) which allows me to browse different perspectives
with a custom state.

What do I miss here??? Your help is realy appreciated.

Cheers
Christoph


--
Dipl.-Ing. Christoph Küpferle

Wissenschaftlicher Mitarbeiter - Arbeitsbereich Wasserbau
TECHNISCHE UNIVERSITÄT HAMBURG-HARBURG
D-21073 Hamburg - Denickestr. 22 (Raum 0039)
Tel. Int. +49 / (0)40 / 428 78-3961
Fax Int. +49 / (0)40 / 428 78-2802
Re: Restore a workbenchpage with an external memento.xml without closing eclipse 3.1 [message #1857994 is a reply to message #443345] Thu, 09 March 2023 19:49 Go to previous messageGo to next message
Eric Geordi is currently offline Eric GeordiFriend
Messages: 2
Registered: March 2023
Junior Member
I know it has been a while, but did you ever find a solution for this? I'm attempting to something similar on a Eclipse 3.x based RCP application.

Thanks,
Eric
Re: Restore a workbenchpage with an external memento.xml without closing eclipse 3.1 [message #1858137 is a reply to message #443345] Thu, 16 March 2023 19:06 Go to previous message
Eric Geordi is currently offline Eric GeordiFriend
Messages: 2
Registered: March 2023
Junior Member
did you ever find a solution for this problem? I too am trying to accomplish the same goal and am seeing the same behavior. We are using Eclipse 3.7 RCP which I know is long gone, but nonetheless was wondering if how you got past this issue?

Thanks,
Eric
Previous Topic:Support for Eclipse RCP on MacOS?
Next Topic:Java 11 and javax.annotation
Goto Forum:
  


Current Time: Thu Feb 06 14:09:01 GMT 2025

Powered by FUDForum. Page generated in 0.06077 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top