Author: rob.stryker(a)jboss.com
Date: 2008-07-08 17:56:22 -0400 (Tue, 08 Jul 2008)
New Revision: 9101
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceVFS.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntVariables.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchivesVFS.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IVariableManager.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveNodeImpl.java
Log:
allows fallback to linked resource variables and classpath variables if not found
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceVFS.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceVFS.java 2008-07-08
19:59:08 UTC (rev 9100)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceVFS.java 2008-07-08
21:56:22 UTC (rev 9101)
@@ -6,13 +6,17 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.preferences.DefaultScope;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.jdt.core.JavaCore;
import org.jboss.ide.eclipse.archives.core.ArchivesCorePlugin;
import org.jboss.ide.eclipse.archives.core.model.IArchivesVFS;
import org.jboss.ide.eclipse.archives.core.model.IVariableManager;
import org.jboss.ide.eclipse.archives.core.xpl.StringSubstitutionEngineClone;
+import org.osgi.service.prefs.BackingStoreException;
public class WorkspaceVFS implements IArchivesVFS {
protected WorkspaceVariableManager manager;
@@ -28,17 +32,41 @@
public class WorkspaceVariableManager implements IVariableManager {
private static final String PREFIX =
"org.jboss.ide.eclipse.archives.core.model.other.internal.WorkspaceVariableManager.";
+ private static final int TYPE_NONE = -1;
+ private static final int TYPE_CUSTOM = 0;
+ private static final int TYPE_LINK = 1;
+ private static final int TYPE_CLASSPATH = 2;
+
public boolean containsVariable(String variable) {
- IEclipsePreferences prefs = new DefaultScope().getNode(ArchivesCorePlugin.PLUGIN_ID);
- return prefs.get(PREFIX + variable, null) != null;
+ return getVariableLocation(variable) != -1;
}
public String getVariableValue(String variable) {
+ int type = getVariableLocation(variable);
+ if( type == TYPE_CUSTOM ) {
+ IEclipsePreferences prefs = new
DefaultScope().getNode(ArchivesCorePlugin.PLUGIN_ID);
+ return prefs.get(PREFIX + variable, null);
+ }else if( type == TYPE_LINK ) {
+ return
ResourcesPlugin.getWorkspace().getPathVariableManager().getValue(variable).toString();
+ } else if( type == TYPE_CLASSPATH ) {
+ return JavaCore.getClasspathVariable(variable).toString();
+ }
+ return null;
+ }
+
+ public int getVariableLocation(String variable) {
IEclipsePreferences prefs = new DefaultScope().getNode(ArchivesCorePlugin.PLUGIN_ID);
- return prefs.get(PREFIX + variable, null);
+ if( prefs.get(PREFIX + variable, null) != null )
+ return TYPE_CUSTOM;
+
+ if( ResourcesPlugin.getWorkspace().getPathVariableManager().getValue(variable) != null
)
+ return TYPE_LINK;
+
+ if( JavaCore.getClasspathVariable(variable) != null)
+ return TYPE_CLASSPATH;
+ return TYPE_NONE;
}
-
public void setValue(String name, IPath value) throws CoreException {
try {
IEclipsePreferences prefs = new
DefaultScope().getNode(ArchivesCorePlugin.PLUGIN_ID);
@@ -47,8 +75,9 @@
else
prefs.remove(PREFIX + name);
prefs.flush();
- } catch (org.osgi.service.prefs.BackingStoreException e) {
- e.printStackTrace();
+ } catch (BackingStoreException e) {
+ IStatus status = new Status(IStatus.ERROR, ArchivesCorePlugin.PLUGIN_ID,
e.getMessage(), e);
+ throw new CoreException(status);
}
}
}
@@ -63,13 +92,13 @@
throws CoreException {
// set this project name
if( projectName != null ) {
- manager.setValue("current.project", new Path(projectName));
+ manager.setValue(IVariableManager.CURRENT_PROJECT, new Path(projectName));
}
String ret = engine.performStringSubstitution(expression, reportUndefinedVariables,
manager);
if( projectName != null ) {
- manager.setValue("current.project", null);
+ manager.setValue(IVariableManager.CURRENT_PROJECT, null);
}
return ret;
}
@@ -110,7 +139,7 @@
return results;
}
- public String findProject(IPath absolutePath) {
+ public String getProjectName(IPath absolutePath) {
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
for( int i = 0; i < projects.length; i++ )
if( projects[i].getLocation().equals(absolutePath))
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntVariables.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntVariables.java 2008-07-08
19:59:08 UTC (rev 9100)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntVariables.java 2008-07-08
21:56:22 UTC (rev 9101)
@@ -46,7 +46,7 @@
// TODO Auto-generated method stub
return null;
}
- public String findProject(IPath absolutePath) {
+ public String getProjectName(IPath absolutePath) {
// TODO Auto-generated method stub
return null;
}
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchivesVFS.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchivesVFS.java 2008-07-08
19:59:08 UTC (rev 9100)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchivesVFS.java 2008-07-08
21:56:22 UTC (rev 9101)
@@ -46,7 +46,7 @@
*/
public IPath workspacePathToAbsolutePath(IPath path);
public IPath[] workspacePathToAbsolutePath(IPath[] paths);
- public String findProject(IPath absolutePath);
+ public String getProjectName(IPath absolutePath);
public String performStringSubstitution(String expression, boolean
reportUndefinedVariables) throws CoreException;
public String performStringSubstitution(String expression, String projectName, boolean
reportUndefinedVariables) throws CoreException;
}
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IVariableManager.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IVariableManager.java 2008-07-08
19:59:08 UTC (rev 9100)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IVariableManager.java 2008-07-08
21:56:22 UTC (rev 9101)
@@ -26,6 +26,7 @@
*
*/
public interface IVariableManager {
+ public static final String CURRENT_PROJECT = "current.project";
public boolean containsVariable(String variable);
public String getVariableValue(String variable);
}
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveNodeImpl.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveNodeImpl.java 2008-07-08
19:59:08 UTC (rev 9100)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveNodeImpl.java 2008-07-08
21:56:22 UTC (rev 9101)
@@ -182,7 +182,7 @@
*/
public String getProjectName() {
IPath path = getProjectPath();
- return ArchivesCore.getInstance().getVFS().findProject(path);
+ return ArchivesCore.getInstance().getVFS().getProjectName(path);
}
/*
Show replies by date