Author: dmaliarevich
Date: 2009-04-24 08:11:05 -0400 (Fri, 24 Apr 2009)
New Revision: 14886
Modified:
trunk/common/plugins/org.jboss.tools.common.resref.core/src/org/jboss/tools/common/resref/core/ResourceReferenceList.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-3211, old preferences that've stored to
IResource.setPersistentProperty() now get loaded on the first tun and can be used.
Modified:
trunk/common/plugins/org.jboss.tools.common.resref.core/src/org/jboss/tools/common/resref/core/ResourceReferenceList.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.resref.core/src/org/jboss/tools/common/resref/core/ResourceReferenceList.java 2009-04-24
11:51:30 UTC (rev 14885)
+++
trunk/common/plugins/org.jboss.tools.common.resref.core/src/org/jboss/tools/common/resref/core/ResourceReferenceList.java 2009-04-24
12:11:05 UTC (rev 14886)
@@ -101,8 +101,22 @@
}
private String[] getDeclaredResources(IResource resource) {
+ /*
+ * Property value
+ */
String s = null;
/*
+ * Old preferences format property value.
+ */
+ String old = null;
+ try {
+ old = resource.getPersistentProperty(getPropertyName());
+ } catch (CoreException e) {
+ /*
+ * Ignore, there is no properties for this resource.
+ */
+ }
+ /*
*
https://jira.jboss.org/jira/browse/JBIDE-3211
* Storing project preferences to project scope in .settings
*/
@@ -117,12 +131,19 @@
String nodeString = path.toString();
Preferences node = root.node(nodeString);
if (null != node) {
- String old = node.get(getPropertyName().getLocalName(), "");
//$NON-NLS-1$
- s = old;
+ s = node.get(getPropertyName().getLocalName(), ""); //$NON-NLS-1$
}
}
if (s == null || s.length() == 0) {
- return new String[0];
+ if (old == null || old.length() == 0) {
+ return new String[0];
+ } else {
+ /*
+ * If there is property stored in the old preferences format
+ * return this value.
+ */
+ return decodeResourceString(old);
+ }
} else {
return decodeResourceString(s);
}
@@ -237,21 +258,39 @@
private TreeMap getAllExternalResources() {
if (allExternalResources == null) {
allExternalResources = new TreeMap();
+ /*
+ * Property value
+ */
String s = null;
/*
+ * Old preferences format property value.
+ */
+ String old = null;
+ try {
+ old = ModelPlugin.getWorkspace().getRoot().getPersistentProperty(getPropertyName());
+ } catch (CoreException e) {
+ /*
+ * Ignore, there is no properties for this resource.
+ */
+ }
+ /*
*
https://jira.jboss.org/jira/browse/JBIDE-3211 Reading project
* Reading global preferences from instance scope.
*/
IScopeContext instanceContext = new InstanceScope();
Preferences root = instanceContext.getNode(ModelPlugin.PLUGIN_ID);
if (null != root) {
- Preferences node = root
- .node(ResourceReferencePlugin.PLUGIN_ID);
+ Preferences node = root.node(ResourceReferencePlugin.PLUGIN_ID);
s = node.get(getPropertyName().getLocalName(), ""); //$NON-NLS-1$
}
-
- if (s != null) {
+ /*
+ * If there is property stored in the old preferences format
+ * and there are no other properties old value will be returned
+ */
+ if (s != null && s.length() > 0) {
parseExternalResources(s);
+ } else if (old != null && old.length() > 0) {
+ parseExternalResources(old);
}
}
return allExternalResources;