简体   繁体   中英

Save Eclipse Plugin project state and configurations

I have an eclipse plugin project that is basically a GUI to visualize data from external source.

I want to give the user the option to save the current configurations of the plugin project, ie which views are opened, current data being analysed and the values placed as input in the different views (JTextboxes etc.).

Thus the user may load the file to the restart the project from the last configuration.

Does such a save mechanism of the plugin project exist? Specially loading the project with previous views from the load file.

Views implement IPersistable so you can implement the saveState method:

@Override
public void saveState(IMemento memento)
{
  memento.putString("key", "value");

  ....
}

override the ViewPart init method to restore the data saved in the memento:

@Override
public void init(IViewSite site, IMemento memento)
{
  super.init(site, memento);

  String value = memento.getString("key");

  ...
}

I am assuming you are doing a 3.x style RCP (using ViewPart ), for an e4 RCP different code is required.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM