/** * Fill bindings. * * @param parent the parent * @param xrd the xrd * @param bindings the bindings */ private void fillBindings(TreeItem parent, ExternalResourceDescription xrd, ExternalResourceBinding[] bindings) { if (null != bindings) { for (int i = 0; i < bindings.length; i++) { if (bindings[i].getResourceName().equals(xrd.getName())) { addBindingToGUI(parent, bindings[i].getKey(), bindings[i]); } } } }
/** * Propagate key change. * * @param newKey the new key * @param oldKey the old key */ private void propagateKeyChange(String newKey, String oldKey) { ExternalResourceBinding[] xrb = getExternalResourceBindings(); if (null != xrb) for (int i = 0; i < xrb.length; i++) { if (oldKey.equals(xrb[i].getKey())) { xrb[i].setKey(newKey); editor.getResourcesPage().getResourceBindingsSection().markStale(); return; // only 1 binding at most } } }
/** * Create an external resource binding. * * @param aKey * the key to bind to. * @param aResourceKey * the resource key to bind. * @return the description. */ public static ExternalResourceBinding createExternalResourceBinding(final String aKey, final String aResourceKey) { ExternalResourceBinding extResBind = new ExternalResourceBinding_impl(); extResBind.setResourceName(aResourceKey); extResBind.setKey(aKey); return extResBind; }
String key = b.getKey(); if (!key.startsWith(aRes.getName() + PREFIX_SEPARATOR)) { key = aRes.getName() + PREFIX_SEPARATOR + b.getKey(); ExternalResourceDescription nestedRes = res.get(b.getResourceName()); aResources.put(nestedRes.getName(), nestedRes); bindNestedResources(nestedRes, aBindings, aResources); b.setKey(key);
for (int i = 0; i < bindings.length; i++) { ResourceRegistration registration = mInternalResourceRegistrationMap .get(bindings[i].getResourceName()); if (registration == null) { throw new ResourceInitializationException( ResourceInitializationException.UNKNOWN_RESOURCE_NAME, new Object[] { bindings[i].getResourceName(), bindings[i].getSourceUrlString() }); mResourceMap.put(aQualifiedContextName + bindings[i].getKey(), registration.resource); Class<?> impl = mInternalParameterizedResourceImplClassMap.get(bindings[i].getResourceName()); mParameterizedResourceImplClassMap.put(aQualifiedContextName + bindings[i].getKey(), (impl == null) ? EMPTY_RESOURCE_CLASS : impl);
/** * Checks if is bound. * * @param key the key * @return true, if is bound */ private boolean isBound(String key) { ResourceManagerConfiguration rmc = editor.getResolvedExternalResourcesAndBindings(); if (null == rmc) { // happens if there is no such xml element in the descriptor return false; } ExternalResourceBinding[] xrb = rmc.getExternalResourceBindings(); if (null != xrb) for (int i = 0; i < xrb.length; i++) { if (key.equals(xrb[i].getKey())) return true; } return false; }
String key = b.getKey(); if (!key.startsWith(aRes.getName() + PREFIX_SEPARATOR)) { key = aRes.getName() + PREFIX_SEPARATOR + b.getKey(); ExternalResourceDescription nestedRes = res.get(b.getResourceName()); aResources.put(nestedRes.getName(), nestedRes); bindNestedResources(nestedRes, aBindings, aResources); b.setKey(key);
/** * Bind button - enabled only when one dependency is selected, and one External Resource, not * already bound to this key, is selected. */ private void handleBind() { TreeItem xrItem = tree.getSelection()[0]; if (null != xrItem.getParentItem()) xrItem = xrItem.getParentItem(); ExternalResourceDescription xrd = getXRDescriptionFromTreeItem(xrItem); TableItem keyItem = resourceDependencySection.getTable().getSelection()[0]; ExternalResourceBinding xrb = new ExternalResourceBinding_impl(); String key = keyItem.getText(ResourceDependencySection.KEY_COL); xrb.setKey(key); xrb.setResourceName(xrd.getName()); getResourceManagerConfiguration().addExternalResourceBinding(xrb); addBindingToGUI(xrItem, key, xrb); xrItem.setExpanded(true); keyItem.setText(0, "Bound"); keyItem.getParent().getColumn(0).pack(); setFileDirty(); }
/** * Removes the bound flag in dependency section. * * @param xrb the xrb */ private void removeBoundFlagInDependencySection(ExternalResourceBinding xrb) { String key = xrb.getKey(); TableItem[] items = resourceDependencySection.getTable().getItems(); for (int i = 0; i < items.length; i++) { if (key.equals(items[i].getText(ResourceDependencySection.KEY_COL))) items[i].setText(0, ""); // reset bound } }