Search in sources :

Example 1 with IDynamicVariable

use of org.eclipse.core.variables.IDynamicVariable in project egit by eclipse.

the class DynamicVariablesTest method assertVariable.

private void assertVariable(String expected, String variableName, String argument) throws CoreException {
    IResource findMember = project.findMember(TEST_FILE);
    SWTBotView explorerView = TestUtil.showExplorerView();
    final ISelectionProvider selectionProvider = explorerView.getViewReference().getView(true).getSite().getSelectionProvider();
    final StructuredSelection structuredSelection = new StructuredSelection(findMember);
    PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {

        @Override
        public void run() {
            selectionProvider.setSelection(structuredSelection);
        }
    });
    IDynamicVariable dynamicVariable = VariablesPlugin.getDefault().getStringVariableManager().getDynamicVariable(variableName);
    String value = dynamicVariable.getValue(argument);
    assertEquals(expected, value);
}
Also used : ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) IDynamicVariable(org.eclipse.core.variables.IDynamicVariable) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IResource(org.eclipse.core.resources.IResource)

Example 2 with IDynamicVariable

use of org.eclipse.core.variables.IDynamicVariable in project webtools.servertools by eclipse.

the class Resolver method resolveProperty.

private String resolveProperty(String proppedString, HashMap cache) {
    StringBuffer str = new StringBuffer(proppedString);
    int start = str.indexOf(PROP_START);
    int end = str.indexOf(PROP_END, start);
    String key = str.substring(start + 2, end);
    String value = (String) cache.get(key);
    if (value == null) {
        // look in eclipse variables
        IDynamicVariable dv = VariablesPlugin.getDefault().getStringVariableManager().getDynamicVariable(key);
        if (dv != null) {
            try {
                value = dv.getValue(null);
            } catch (CoreException e) {
                CorePlugin.getDefault().getLog().log(new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, 1, "Can not resolve eclipse variable", // $NON-NLS-1$
                e));
            }
        }
    }
    if (value == null)
        return str.toString();
    return str.replace(start, end + 1, value).toString();
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IDynamicVariable(org.eclipse.core.variables.IDynamicVariable) CoreException(org.eclipse.core.runtime.CoreException)

Aggregations

IDynamicVariable (org.eclipse.core.variables.IDynamicVariable)2 IResource (org.eclipse.core.resources.IResource)1 CoreException (org.eclipse.core.runtime.CoreException)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)1