[閒聊] How to store state for Eclipse plug-in
Reference link
http://wiki.eclipse.org/FAQ_Where_do_plug-ins_store_their_state%3F
for each workspace
1.install directory (read-only) (<Eclise_home>/plugins)
2.getStateLocation (workspace/.metadata/)
3.preference (@see Plugin.getPreferenceStore())
for serval workspace
1.configuration location (<Eclise_home>/configuration)
2.user location
------------------------------
More details
http://goo.gl/WOQVM
Javadoc Platform#getConfigurationLocation
http://goo.gl/zV3aw
Activator or Plug-in Class
http://www.informit.com/articles/article.aspx?p=1271257&seqNum=4
Plug-in preferences
Plug-in configuration files
Real sample for getConfigurationLocation
http://goo.gl/cT6tQ
--
public static final String ID = "com.qualityeclipse.favorites";
public File getConfigDir() {
Location location =
Platform.getConfigurationLocation();
if (location != null) {
URL configURL = location.getURL();
if (configURL != null
&& configURL.getProtocol().startsWith("file")) {
return new File(configURL.getFile(), ID);
}
}
// If the configuration directory is read-only,
// then return an alternate location
// rather than null or throwing an Exception.
return getStateLocation().toFile();
}
--
--
I am a person, and I am always thinking .
Thinking in love , Thinking in life ,
Thinking in why , Thinking in worth.
I can't believe any of what ,
I am just thinking then thinking ,
but worst of all , most of mine is thinking not actioning...
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 198.203.175.175
Eclipse 近期熱門文章
PTT數位生活區 即時熱門文章