diff options
12 files changed, 159 insertions, 87 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/ContainerResolver.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/ContainerResolver.java index fa14d10f3..b01601c03 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/ContainerResolver.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/ContainerResolver.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. + * Copyright (c) 2000, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,15 +8,17 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.debug.internal.ui.stringsubstitution; +package org.eclipse.debug.internal.core.variables; import org.eclipse.core.resources.IResource; /** * Resolver for the <code>${container_*}</code> variables. Accepts an optional * argument that is interpretted as a full path to a container in the workspace. - * - * @since 3.0 + * <p> + * Moved to debug core in 3.5, existed in debug.iu since 3.0. + * </p> + * @since 3.5 */ public class ContainerResolver extends ResourceResolver { diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/Messages.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/Messages.java index 45ac19264..739cdb48c 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/Messages.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/Messages.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 IBM Corporation and others. + * Copyright (c) 2008, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,6 +14,9 @@ import org.eclipse.osgi.util.NLS; public class Messages extends NLS { private static final String BUNDLE_NAME = "org.eclipse.debug.internal.core.variables.Messages"; //$NON-NLS-1$ + public static String ResourceResolver_0; + public static String ResourceResolver_1; + public static String ResourceResolver_2; public static String WorkspaceResolver_0; static { // initialize resource bundle diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/Messages.properties b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/Messages.properties index 7d94b7d73..9029703b6 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/Messages.properties +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/Messages.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2008 IBM Corporation and others. +# Copyright (c) 2008, 2009 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at @@ -8,4 +8,7 @@ # Contributors: # IBM Corporation - initial API and implementation ############################################################################### +ResourceResolver_0=Variable references non-existent resource : {0} +ResourceResolver_1=Variable references empty selection: {0} +ResourceResolver_2=Variable not recognized: {0} WorkspaceResolver_0=Variable references non-existent resource : {0} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/ProjectResolver.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/ProjectResolver.java index 72916619b..ad7b0a8a0 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/ProjectResolver.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/ProjectResolver.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. + * Copyright (c) 2000, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,15 +8,17 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.debug.internal.ui.stringsubstitution; +package org.eclipse.debug.internal.core.variables; import org.eclipse.core.resources.IResource; /** * Resolver for the <code>${project_*}</code> variables. Accepts an optional argument * that is interpretted as the name of a project. - * - * @since 3.0 + * <p> + * Moved to debug core in 3.5, existed in debug.iu since 3.0. + * </p> + * @since 3.5 */ public class ProjectResolver extends ResourceResolver { /* (non-Javadoc) diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/ResourceResolver.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/ResourceResolver.java index 9ebf0cb54..91c9bc45b 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/ResourceResolver.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/ResourceResolver.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.debug.internal.ui.stringsubstitution; +package org.eclipse.debug.internal.core.variables; import java.io.File; import java.net.URI; @@ -24,15 +24,17 @@ import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Status; import org.eclipse.core.variables.IDynamicVariable; import org.eclipse.core.variables.IDynamicVariableResolver; -import org.eclipse.debug.internal.ui.DebugUIPlugin; -import org.eclipse.debug.ui.IDebugUIConstants; +import org.eclipse.core.variables.IStringVariableManager; +import org.eclipse.core.variables.VariablesPlugin; +import org.eclipse.debug.core.DebugPlugin; import com.ibm.icu.text.MessageFormat; /** * Common function of variable resolvers. + * Moved to debug core in 3.5, existed in debug.iu since 3.0. * - * @since 3.0 + * @since 3.5 */ public class ResourceResolver implements IDynamicVariableResolver { @@ -52,7 +54,7 @@ public class ResourceResolver implements IDynamicVariableResolver { return translateToValue(resource, variable); } } - abort(MessageFormat.format(StringSubstitutionMessages.ResourceResolver_6, new String[]{getReferenceExpression(variable, argument)}), null); + abort(MessageFormat.format(Messages.ResourceResolver_0, new String[]{getReferenceExpression(variable, argument)}), null); return null; } @@ -106,22 +108,29 @@ public class ResourceResolver implements IDynamicVariableResolver { * @throws CoreException */ protected void abort(String message, Throwable exception) throws CoreException { - throw new CoreException(new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), IDebugUIConstants.INTERNAL_ERROR, message, exception)); + throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, message, exception)); } /** - * Returns the selected resource. + * Returns the selected resource. Uses the ${selected_resource_path} variable + * to determine the selected resource. This variable is provided by the debug.ui + * plug-in. Selected resource resolution is only available when the debug.ui + * plug-in is present. * * @param variable variable referencing a resource * @return selected resource * @throws CoreException if there is no selection */ protected IResource getSelectedResource(IDynamicVariable variable) throws CoreException { - IResource resource = SelectedResourceManager.getDefault().getSelectedResource(); - if (resource == null) { - abort(MessageFormat.format(StringSubstitutionMessages.ResourceResolver_7, new String[]{getReferenceExpression(variable, null)}), null); + IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); + try { + String pathString = manager.performStringSubstitution("${selected_resource_path}"); //$NON-NLS-1$ + return ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(pathString)); + } catch (CoreException e) { + // unable to resolve a selection } - return resource; + abort(MessageFormat.format(Messages.ResourceResolver_1, new String[]{getReferenceExpression(variable, null)}), null); + return null; } /** @@ -152,7 +161,7 @@ public class ResourceResolver implements IDynamicVariableResolver { } else if (name.endsWith("_name")) { //$NON-NLS-1$ return resource.getName(); } - abort(MessageFormat.format(StringSubstitutionMessages.ResourceResolver_8, new String[]{getReferenceExpression(variable, null)}), null); + abort(MessageFormat.format(Messages.ResourceResolver_2, new String[]{getReferenceExpression(variable, null)}), null); return null; } diff --git a/org.eclipse.debug.core/plugin.properties b/org.eclipse.debug.core/plugin.properties index 278a42667..d2ed1e140 100644 --- a/org.eclipse.debug.core/plugin.properties +++ b/org.eclipse.debug.core/plugin.properties @@ -54,6 +54,15 @@ containerName.default = Default containerDescription.default = Default source lookup path workspace_loc.description=Returns the absolute file system path of the workspace root. When an argument is specified, the absolute file system path of the resource identified by a workspace relative path is returned. +container_loc.description=Returns the absolute file system path of a resource's container. The target resource is the selected resource when no argument is specified, or the resource identified by a workspace relative path. +container_path.description=Returns the workspace relative path of a resource's container. The target resource is the selected resource when no argument is specified, or the resource identified by a workspace relative path. +container_name.description=Returns the name of a resource's container. The target resource is the selected resource when no argument is specified, or the resource identified by a workspace relative path. +project_loc.description=Returns the absolute file system path of a resource's project. The target resource is the selected resource when no argument is specified, or the resource identified by a workspace relative path. +project_path.description=Returns the workspace relative path of a resource's project. The target resource is the selected resource when no argument is specified, or the resource identified by a workspace relative path. +project_name.description=Returns the name of a resource's project. The target resource is the selected resource when no argument is specified, or the resource identified by a workspace relative path. +resource_loc.description=Returns the absolute file system path of a resource. The target resource is the selected resource when no argument is specified, or the resource identified by a workspace relative path. +resource_path.description=Returns the workspace relative path of a resource. The target resource is the selected resource when no argument is specified, or the resource identified by a workspace relative path. +resource_name.description=Returns the name of a resource. The target resource is the selected resource when no argument is specified, or the resource identified by a workspace relative path. LineBreakpoint.name = Line Breakpoint Breakpoint.name = Breakpoint diff --git a/org.eclipse.debug.core/plugin.xml b/org.eclipse.debug.core/plugin.xml index e74efb312..61e3d02b5 100644 --- a/org.eclipse.debug.core/plugin.xml +++ b/org.eclipse.debug.core/plugin.xml @@ -106,6 +106,51 @@ name="workspace_loc" resolver="org.eclipse.debug.internal.core.variables.WorkspaceResolver"> </variable> + <variable + name="project_loc" + description="%project_loc.description" + resolver="org.eclipse.debug.internal.core.variables.ProjectResolver"> + </variable> + <variable + name="project_path" + description="%project_path.description" + resolver="org.eclipse.debug.internal.core.variables.ProjectResolver"> + </variable> + <variable + name="project_name" + description="%project_name.description" + resolver="org.eclipse.debug.internal.core.variables.ProjectResolver"> + </variable> + <variable + name="resource_loc" + description="%resource_loc.description" + resolver="org.eclipse.debug.internal.core.variables.ResourceResolver"> + </variable> + <variable + name="resource_path" + description="%resource_path.description" + resolver="org.eclipse.debug.internal.core.variables.ResourceResolver"> + </variable> + <variable + name="resource_name" + description="%resource_name.description" + resolver="org.eclipse.debug.internal.core.variables.ResourceResolver"> + </variable> + <variable + name="container_loc" + description="%container_loc.description" + resolver="org.eclipse.debug.internal.core.variables.ContainerResolver"> + </variable> + <variable + name="container_path" + description="%container_path.description" + resolver="org.eclipse.debug.internal.core.variables.ContainerResolver"> + </variable> + <variable + name="container_name" + description="%container_name.description" + resolver="org.eclipse.debug.internal.core.variables.ContainerResolver"> + </variable> </extension> <!-- ====================== --> diff --git a/org.eclipse.debug.ui/plugin.properties b/org.eclipse.debug.ui/plugin.properties index 774d1cc19..2b8407ec2 100644 --- a/org.eclipse.debug.ui/plugin.properties +++ b/org.eclipse.debug.ui/plugin.properties @@ -155,16 +155,10 @@ string_prompt.description=Returns the text value entered into a prompt dialog. W password_prompt.description=Returns the text value entered into a password prompt dialog. When one argument is provided, it is used as a prompt hint on the input dialog. When a second argument is provided, it is used as an initial value in the input dialog. The first and second arguments must be separated with a ':'. file_prompt.description=Returns the absolute file system path of a file chosen in a file selection dialog. When one argument is provided, it is used a prompt hint on the dialog title. When a second argument is provided, it is used as an initial value for the file selection dialog. The first and second arguments must be separated with a ':'. folder_prompt.description=Returns the absolute file system path of a directory chosen in a directory selection dialog. When one argument is provided, it is used a prompt hint on the dialog title. When a second argument is provided, it is used as an initial value for the directory selection dialog. The first and second arguments must be separated with a ':'. -container_loc.description=Returns the absolute file system path of a resource's container. The target resource is the selected resource when no argument is specified, or the resource identified by a workspace relative path. -container_path.description=Returns the workspace relative path of a resource's container. The target resource is the selected resource when no argument is specified, or the resource identified by a workspace relative path. -container_name.description=Returns the name of a resource's container. The target resource is the selected resource when no argument is specified, or the resource identified by a workspace relative path. -project_loc.description=Returns the absolute file system path of a resource's project. The target resource is the selected resource when no argument is specified, or the resource identified by a workspace relative path. -project_path.description=Returns the workspace relative path of a resource's project. The target resource is the selected resource when no argument is specified, or the resource identified by a workspace relative path. -project_name.description=Returns the name of a resource's project. The target resource is the selected resource when no argument is specified, or the resource identified by a workspace relative path. -resource_loc.description=Returns the absolute file system path of a resource. The target resource is the selected resource when no argument is specified, or the resource identified by a workspace relative path. -resource_path.description=Returns the workspace relative path of a resource. The target resource is the selected resource when no argument is specified, or the resource identified by a workspace relative path. -resource_name.description=Returns the name of a resource. The target resource is the selected resource when no argument is specified, or the resource identified by a workspace relative path. selected_text.description=Returns the text currently selected in the active editor. +selected_resource_loc.description=Returns the absolute file system path of the selected resource. +selected_resource_path.description=Returns the workspace relative path of the selected resource. +selected_resource_name.description=Returns the name of the selected resource. providerName=Eclipse.org diff --git a/org.eclipse.debug.ui/plugin.xml b/org.eclipse.debug.ui/plugin.xml index 37425b58b..58d8ddb35 100644 --- a/org.eclipse.debug.ui/plugin.xml +++ b/org.eclipse.debug.ui/plugin.xml @@ -2023,51 +2023,6 @@ M4 = Platform-specific fourth key <extension point="org.eclipse.core.variables.dynamicVariables"> <variable - name="project_loc" - description="%project_loc.description" - resolver="org.eclipse.debug.internal.ui.stringsubstitution.ProjectResolver"> - </variable> - <variable - name="project_path" - description="%project_path.description" - resolver="org.eclipse.debug.internal.ui.stringsubstitution.ProjectResolver"> - </variable> - <variable - name="project_name" - description="%project_name.description" - resolver="org.eclipse.debug.internal.ui.stringsubstitution.ProjectResolver"> - </variable> - <variable - name="resource_loc" - description="%resource_loc.description" - resolver="org.eclipse.debug.internal.ui.stringsubstitution.ResourceResolver"> - </variable> - <variable - name="resource_path" - description="%resource_path.description" - resolver="org.eclipse.debug.internal.ui.stringsubstitution.ResourceResolver"> - </variable> - <variable - name="resource_name" - description="%resource_name.description" - resolver="org.eclipse.debug.internal.ui.stringsubstitution.ResourceResolver"> - </variable> - <variable - name="container_loc" - description="%container_loc.description" - resolver="org.eclipse.debug.internal.ui.stringsubstitution.ContainerResolver"> - </variable> - <variable - name="container_path" - description="%container_path.description" - resolver="org.eclipse.debug.internal.ui.stringsubstitution.ContainerResolver"> - </variable> - <variable - name="container_name" - description="%container_name.description" - resolver="org.eclipse.debug.internal.ui.stringsubstitution.ContainerResolver"> - </variable> - <variable name="string_prompt" description="%string_prompt.description" resolver="org.eclipse.debug.internal.ui.stringsubstitution.StringPrompt"> @@ -2092,6 +2047,21 @@ M4 = Platform-specific fourth key description="%selected_text.description" resolver="org.eclipse.debug.internal.ui.stringsubstitution.SelectedTextResolver"> </variable> + <variable + name="selected_resource_loc" + description="%selected_resource_loc.description" + resolver="org.eclipse.debug.internal.ui.stringsubstitution.SelectedResourceResolver"> + </variable> + <variable + name="selected_resource_path" + description="%selected_resource_path.description" + resolver="org.eclipse.debug.internal.ui.stringsubstitution.SelectedResourceResolver"> + </variable> + <variable + name="selected_resource_name" + description="%selected_resource_name.description" + resolver="org.eclipse.debug.internal.ui.stringsubstitution.SelectedResourceResolver"> + </variable> </extension> <!-- String Variable Presentations --> <extension diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/SelectedResourceResolver.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/SelectedResourceResolver.java new file mode 100644 index 000000000..0fcedc27a --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/SelectedResourceResolver.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.debug.internal.ui.stringsubstitution; + +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.variables.IDynamicVariable; +import org.eclipse.core.variables.IDynamicVariableResolver; +import org.eclipse.debug.internal.core.variables.ResourceResolver; + +import com.ibm.icu.text.MessageFormat; + +/** + * Resolves the currently selected resource. + * + * @since 3.5 + */ +public class SelectedResourceResolver extends ResourceResolver implements IDynamicVariableResolver { + + /* (non-Javadoc) + * @see org.eclipse.core.variables.IDynamicVariableResolver#resolveValue(org.eclipse.core.variables.IDynamicVariable, java.lang.String) + */ + public String resolveValue(IDynamicVariable variable, String argument) throws CoreException { + IResource resource = SelectedResourceManager.getDefault().getSelectedResource(); + if (resource != null) { + return translateToValue(resource, variable); + } + abort(MessageFormat.format(StringSubstitutionMessages.SelectedResourceResolver_0, new String[]{getReferenceExpression(variable, argument)}), null); + return null; + } + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/StringSubstitutionMessages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/StringSubstitutionMessages.java index 9a42a9129..4db9fa473 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/StringSubstitutionMessages.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/StringSubstitutionMessages.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved. This + * Copyright (c) 2000, 2009 IBM Corporation and others. All rights reserved. This * program and the accompanying materials are made available under the terms of * the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -36,12 +36,10 @@ public class StringSubstitutionMessages extends NLS { public static String RefreshTab_40; public static String RefreshTab_42; - public static String ResourceResolver_6; - public static String ResourceResolver_7; - public static String ResourceResolver_8; - public static String ResourceSelector_0; + public static String SelectedResourceResolver_0; + public static String StringPromptExpander_0; public static String StringVariableSelectionDialog_2; diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/StringSubstitutionMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/StringSubstitutionMessages.properties index b0e3b8bec..8ecd00da2 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/StringSubstitutionMessages.properties +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/StringSubstitutionMessages.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2000, 2007 IBM Corporation and others. +# Copyright (c) 2000, 2009 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at @@ -29,12 +29,9 @@ RefreshTab_42=Must select resources to refresh. RefreshTab_43=Refresh scope refers to non-existent resource {0} RefreshTab_44=Refresh scope invalid -ResourceResolver_6=Variable references non-existent resource : {0} -ResourceResolver_7=Variable references empty selection: {0} -ResourceResolver_8=Variable not recognized: {0} - ResourceSelector_0=Select Resource +SelectedResourceResolver_0=Unable to resource a selected resource: {0} StringPromptExpander_0=Variable input StringVariableSelectionDialog_2=Select Variable |