I am trying to save the entire state of the workspace with the goal of restoring it at will.
I am able to do so with certain parts currently, but not all.
Following here is working to recreate the editors and splitters, although focus of the editor I’ve had to save away myself and restore manually separately:
public static Element freshWorkspaceElement() {
return new Element("MMM_WORKSPACE_ELEMENT_STATE");
}
public static Element currentWorkspaceAsElement($Project project) {
Element element = freshWorkspaceElement();
WorkingContextManager workingContextManager = WorkingContextManager.getInstance(project.delegate);
workingContextManager.saveContext(element);
return element;
}
public static void recreateWorkspaceByElement($Project project, Element element) {
WorkingContextManager instance = WorkingContextManager.getInstance(project.delegate);
instance.loadContext(element);
}
However, the above when restoring the workspace, the project view navigator is not restored to whatever view was before.
Tried to remember and reset that by code as well, but nothing seems to have happened:
public static Element freshProjectViewElement() {
return new Element("MMM_PROJECTVIEW_ELEMENT_STATE");
}
public static Element currentProjectViewAsElement($Project project) {
ProjectViewImpl projectView = (ProjectViewImpl) ProjectView.getInstance(project.delegate);
Element state = projectView.getState();
return state;
}
public static void recreateProjectViewByElement($Project project, Element element) {
ProjectViewImpl projectView = (ProjectViewImpl) ProjectView.getInstance(project.delegate);
projectView.loadState(element);
}
Of course restoring all these things is kind of difficult and it would be better if there is a call someplace available where all of this and all kinds of states are stored and restorable at will. Using one or a few methods?
If not, how can I store one tool window at a time.
Currently the prio is on the project window.
I’d imagine when one shuts down idea and opens it up again it is able to do a better job then I am currently able to restoring previous state. Also git checkout branch offers restoration.
How can I achieve this goal?
The project view tree is the focus.