Author: mareshkau
Date: 2008-11-03 08:21:10 -0500 (Mon, 03 Nov 2008)
New Revision: 11487
Added:
trunk/common/plugins/org.jboss.tools.common.resref.core/src/org/jboss/tools/common/resref/core/ResourceReferencePlugin.java
Removed:
trunk/common/plugins/org.jboss.tools.common.resref.core/src/org/jboss/tools/common/resref/core/Activator.java
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/XModelObjectUtil.java
trunk/common/plugins/org.jboss.tools.common.resref.core/.classpath
trunk/common/plugins/org.jboss.tools.common.resref.core/META-INF/MANIFEST.MF
trunk/common/plugins/org.jboss.tools.common.resref.core/src/org/jboss/tools/common/resref/core/ResourceReferenceList.java
Log:
JBIDE-2979
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/XModelObjectUtil.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/XModelObjectUtil.java 2008-11-03
10:33:32 UTC (rev 11486)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/XModelObjectUtil.java 2008-11-03
13:21:10 UTC (rev 11487)
@@ -28,7 +28,7 @@
}
public static String[] asStringArray(String s) {
- return asStringArray(s, ",;");
+ return asStringArray(s, ",;"); //$NON-NLS-1$
}
public static String[] asStringArray(String s, String separator) {
Modified: trunk/common/plugins/org.jboss.tools.common.resref.core/.classpath
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.resref.core/.classpath 2008-11-03 10:33:32
UTC (rev 11486)
+++ trunk/common/plugins/org.jboss.tools.common.resref.core/.classpath 2008-11-03 13:21:10
UTC (rev 11487)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
Modified: trunk/common/plugins/org.jboss.tools.common.resref.core/META-INF/MANIFEST.MF
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.resref.core/META-INF/MANIFEST.MF 2008-11-03
10:33:32 UTC (rev 11486)
+++
trunk/common/plugins/org.jboss.tools.common.resref.core/META-INF/MANIFEST.MF 2008-11-03
13:21:10 UTC (rev 11487)
@@ -3,9 +3,10 @@
Bundle-Name: Core Plug-in
Bundle-SymbolicName: org.jboss.tools.common.resref.core
Bundle-Version: 1.0.0
-Bundle-Activator: org.jboss.tools.common.resref.core.Activator
+Bundle-Activator: org.jboss.tools.common.resref.core.ResourceReferencePlugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.jboss.tools.common.model;bundle-version="2.0.0"
Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.tools.common.resref.core
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
Deleted:
trunk/common/plugins/org.jboss.tools.common.resref.core/src/org/jboss/tools/common/resref/core/Activator.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.resref.core/src/org/jboss/tools/common/resref/core/Activator.java 2008-11-03
10:33:32 UTC (rev 11486)
+++
trunk/common/plugins/org.jboss.tools.common.resref.core/src/org/jboss/tools/common/resref/core/Activator.java 2008-11-03
13:21:10 UTC (rev 11487)
@@ -1,50 +0,0 @@
-package org.jboss.tools.common.resref.core;
-
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class Activator extends AbstractUIPlugin {
-
- // The plug-in ID
- public static final String PLUGIN_ID = "org.jboss.tools.common.resref.core";
-
- // The shared instance
- private static Activator plugin;
-
- /**
- * The constructor
- */
- public Activator() {
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static Activator getDefault() {
- return plugin;
- }
-
-}
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 2008-11-03
10:33:32 UTC (rev 11486)
+++
trunk/common/plugins/org.jboss.tools.common.resref.core/src/org/jboss/tools/common/resref/core/ResourceReferenceList.java 2008-11-03
13:21:10 UTC (rev 11487)
@@ -11,6 +11,9 @@
package org.jboss.tools.common.resref.core;
import java.io.File;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
import java.util.*;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
@@ -18,6 +21,10 @@
import org.jboss.tools.common.model.util.XModelObjectUtil;
public abstract class ResourceReferenceList {
+
+ //Fix for JBIDE-2979
+ private static final String CODING = "UTF-16";//$NON-NLS-1$
+
ResourceReferenceListListener[] listeners = new ResourceReferenceListListener[0];
protected abstract QualifiedName getPropertyName();
@@ -82,17 +89,36 @@
return (ResourceReference[])css.toArray(new ResourceReference[0]);
}
- private String[] getDeclaredResources(IResource resource) {
+ private String[] getDeclaredResources(IResource resource) {
String s = null;
try {
s = resource.getPersistentProperty(getPropertyName());
} catch (CoreException e) {
//ignore
}
- if(s == null || s.length() == 0) return new String[0];
- return XModelObjectUtil.asStringArray(s);
+ if(s == null || s.length() == 0) {
+ return new String[0];
+ } else {
+ return decodeResourceString(s);
+ }
}
+ //Fix for JBIDE-2979
+ private static String[] decodeResourceString(String resource) {
+ String[] results = XModelObjectUtil.asStringArray(resource);
+ String[] returnValues = new String [results.length];
+ try {
+ for (int i=0;i<results.length;i++) {
+ returnValues[i] = URLDecoder.decode(results[i], CODING);
+ }
+ } catch (UnsupportedEncodingException e) {
+ ResourceReferencePlugin.getPluginLog().logError(e);
+ //in case of exception we return undecoded values
+ return results;
+ }
+ return returnValues;
+ }
+
public void setAllResources(IFile file, ResourceReference[] entries) {
IResource changed = null;
boolean b = setDeclaredResources(file, entries, ResourceReference.FILE_SCOPE, 0);
@@ -134,8 +160,14 @@
if(scope < 10 && s != scope) continue;
if(scope == 10 && s == ResourceReference.FILE_SCOPE) continue;
if(scope == ResourceReference.FOLDER_SCOPE && entries[i].getDepth() != depth)
continue;
- if(sb.length() > 0) sb.append(";");
- sb.append(entries[i].getLocationAndProperties());
+ if(sb.length() > 0)
+ sb.append(';');
+ try {
+ sb.append(URLEncoder.encode(entries[i].getLocationAndProperties(),CODING));
+ } catch (UnsupportedEncodingException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
return sb.toString();
}
@@ -169,7 +201,7 @@
return allExternalResources;
}
private void parseExternalResources(String s) {
- StringTokenizer st = new StringTokenizer(s, "#");
+ StringTokenizer st = new StringTokenizer(s, "#"); //$NON-NLS-1$
while(st.hasMoreTokens()) {
String t = st.nextToken();
int e = t.indexOf('=');
@@ -234,7 +266,11 @@
private String[] getDeclaredResources(IPath path) {
String s = (String)getAllExternalResources().get(path.toString());
- return (s == null || s.length() == 0) ? new String[0] :
XModelObjectUtil.asStringArray(s);
+ if(s == null || s.length() == 0) {
+ return new String[0];
+ }else {
+ return decodeResourceString(s);
+ }
}
public void setAllResources(IPath path, ResourceReference[] entries) {
Added:
trunk/common/plugins/org.jboss.tools.common.resref.core/src/org/jboss/tools/common/resref/core/ResourceReferencePlugin.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.resref.core/src/org/jboss/tools/common/resref/core/ResourceReferencePlugin.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.resref.core/src/org/jboss/tools/common/resref/core/ResourceReferencePlugin.java 2008-11-03
13:21:10 UTC (rev 11487)
@@ -0,0 +1,57 @@
+package org.jboss.tools.common.resref.core;
+
+import org.jboss.tools.common.log.BaseUIPlugin;
+import org.jboss.tools.common.log.IPluginLog;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class ResourceReferencePlugin extends BaseUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.common.resref.core";
//$NON-NLS-1$
+
+ // The shared instance
+ private static ResourceReferencePlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public ResourceReferencePlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static ResourceReferencePlugin getDefault() {
+ return plugin;
+ }
+
+ public static IPluginLog getPluginLog() {
+ return plugin;
+ }
+
+}
Show replies by date