This section introduces what is and how to handle project prefix.
In BTT tooling, the following resources are supported to be chosen from another project:
At time of generating JSP from XUI, value of a widget attribute need to be generated into runtime value properly. The following mapping rules handle multi-project for widget attributes specially:
When a resource is selected from another project, BTT will add project prefix to the resource reference information. In this case, resource reference information will be in the format of [project prefix]:[resource reference identity]. In order to avoid massive modification when a common or global project is renamed, BTT uses project map key instead of project name as project prefix.
For an extended widget, if its attribute refers resource in another project, the widget implementation needs to handle project prefix to locate the resource. BTT provides two APIs for technical developers to handle project prefix.
The API returns project which resource locates according to resourceID, if resourceID does not contain project prefix, the activeProject will be returned. If the project map key is not defined in BTT configuration file, “IllegalArgumentException” exception will be thrown.
The API returns resource without project prefix.
The following sample code demonstrates how to retrieve icon file from global project.
try{ IProject imageProject = FilePathUtil.getProjecByResourceID(imageLocation,EditorUtils.getActiveProject()) String imageRelativeLocation = FilePathUtil.getValueByResourceID(imageLocation); IFile imageFile = imageProject.getFile(imageRelativeLocation); } catch(IllegalArgumentException ie){ // handle map key is not defined exception }
The following sample code demonstrates how to retrieve NLS definition from global project.
try{ IProject selectedProject = FilePathUtil.getProjecByResourceID(nlsLocation,EditorUtils.getActiveProject()) String nlsTextField = getValueByResourceID(nlsLocation); String nlsValue = NLSUtils.getPropertiesValue(nlsTextField,selectedProject); } catch(IllegalArgumentException ie){ // handle map key is not defined exception }