/** * @since 4.0 */ public Set<String> getCallbackMethods() { Set<String> res = new LinkedHashSet<>(); for (CallbackDescriptor descriptor : getCallbackMap().getCallbacks()) { res.addAll(descriptor.getCallbackMethods()); } return res; }
private void processStartPostRemove(Attributes attributes) { String methodName = attributes.getValue("", "method-name"); if (objEntity != null) { objEntity.getCallbackMap().getPostRemove().addCallbackMethod(methodName); } }
public CallbackMap() { LifecycleEvent[] events = LifecycleEvent.values(); callbacks = new CallbackDescriptor[events.length]; for (int i = 0; i < events.length; i++) { callbacks[i] = new CallbackDescriptor(events[i]); } }
/** * stores edited value * * @param newVal new value * @param row row * @param col column */ public void setValueAt(Object newVal, int row, int col) { String method = (String) newVal; if (method != null) { method = method.trim(); } String prevMethod = getObjectList().get(row); if (method != null && method.length() > 0) { // check that method changed and name is not duplicate if (!method.equals(prevMethod) && !getCallbackDescriptor().getCallbackMethods().contains(method)) { // update model getObjectList().set(row, method); // update entity getCallbackDescriptor().setCallbackMethodAt(row, method); fireTableRowsUpdated(row, row); mediator.fireCallbackMethodEvent(new CallbackMethodEvent( eventSource, prevMethod, method, MapEvent.CHANGE)); } } }
/** * Compiles internal callback registry. */ synchronized void initCallbacks() { if (callbackRegistry == null) { LifecycleCallbackRegistry callbackRegistry = new LifecycleCallbackRegistry(this); // load entity callbacks for (ObjEntity entity : getObjEntities()) { Class<?> entityClass = entity.getJavaClass(); CallbackDescriptor[] callbacks = entity.getCallbackMap().getCallbacks(); for (CallbackDescriptor callback : callbacks) { for (String method : callback.getCallbackMethods()) { callbackRegistry.addCallback(callback.getCallbackType(), entityClass, method); } } } this.callbackRegistry = callbackRegistry; } }
public void removeCallbackMethod(CallbackType callbackType, String method) { ProjectController mediator = getProjectController(); getCallbackMap().getCallbackDescriptor(callbackType.getType()).removeCallbackMethod(method); CallbackMethodEvent e = new CallbackMethodEvent( this, null, method, MapEvent.REMOVE); mediator.fireCallbackMethodEvent(e); }
public CallbackDescriptor(LifecycleEvent callbackType) { setCallbackType(callbackType); this.callbackMethods = new LinkedHashSet<String>(3); }
public boolean importData(JComponent comp, Transferable t) { if (canImport(comp, t.getTransferDataFlavors())) { String callbackMethod; try { callbackMethod = (String) t.getTransferData(DataFlavor.stringFlavor); } catch (Exception e) { logger.warn("Error transferring", e); return false; } int rowIndex = table.getSelectedRow(); CallbackDescriptor callbackDescriptor = ((CallbackDescriptorTableModel)table.getCayenneModel()).getCallbackDescriptor(); mediator.setDirty(callbackDescriptor.moveMethod(callbackMethod, rowIndex)); rebuildTables(); return true; } return false; }
private void removeMethods(ProjectController mediator, ConfirmRemoveDialog dialog, ObjCallbackMethod[] methods) { CallbackMap callbackMap = mediator.getCurrentObjEntity().getCallbackMap(); CallbackType callbackType = mediator.getCurrentCallbackType(); if ((methods.length == 1 && dialog.shouldDelete("callback method", methods[0].getName())) || (methods.length > 1 && dialog.shouldDelete("selected callback methods"))) { for (ObjCallbackMethod callbackMethod : methods) { callbackMap.getCallbackDescriptor(callbackType.getType()).removeCallbackMethod(callbackMethod.getName()); CallbackMethodEvent ce = new CallbackMethodEvent(this, null, callbackMethod.getName(), MapEvent.REMOVE); mediator.fireCallbackMethodEvent(ce); } Application.getInstance().getUndoManager() .addEdit(new RemoveCallbackMethodUndoableEdit(callbackType, methods)); } }
EntityUtils(DataMap dataMap, ObjEntity objEntity, String baseClassName, String basePackageName, String superClassName, String superPackageName, String subClassName, String subPackageName) { this.baseClassName = baseClassName; this.basePackageName = basePackageName; this.superClassName = superClassName; this.superPackageName = superPackageName; this.subClassName = subClassName; this.subPackageName = subPackageName; this.primaryDataMap = dataMap; this.objEntity = objEntity; this.callbackNames = new LinkedHashSet<String>(); for (CallbackDescriptor cb : objEntity.getCallbackMap().getCallbacks()) { callbackNames.addAll(cb.getCallbackMethods()); } }
private void processStartPreUpdate(Attributes attributes) { String methodName = attributes.getValue("", "method-name"); if (objEntity != null) { objEntity.getCallbackMap().getPreUpdate().addCallbackMethod(methodName); } }
methods.addAll(descriptor.getCallbackMethods());
private void processStartPostPersist(Attributes attributes) { String methodName = attributes.getValue("", "method-name"); if (objEntity != null) { objEntity.getCallbackMap().getPostPersist().addCallbackMethod(methodName); } }
private static void printMethods( CallbackDescriptor descriptor, String stringCallbackName, XMLEncoder encoder) { for (String methodName : descriptor.getCallbackMethods()) { encoder.print("<"); encoder.print(stringCallbackName); encoder.print(" method-name=\""); encoder.print(methodName); encoder.println("\"/>"); } } }
private void processStartPostAdd(Attributes attributes) { String methodName = attributes.getValue("", "method-name"); if (objEntity != null) { // new callback tags - children of "obj-entity" objEntity.getCallbackMap().getPostAdd().addCallbackMethod(methodName); } }
public EntityUtils(DataMap dataMap, ObjEntity objEntity, String fqnBaseClass, String fqnSuperClass, String fqnSubClass) { StringUtils stringUtils = StringUtils.getInstance(); this.baseClassName = stringUtils.stripPackageName(fqnBaseClass); this.basePackageName = stringUtils.stripClass(fqnBaseClass); this.superClassName = stringUtils.stripPackageName(fqnSuperClass); this.superPackageName = stringUtils.stripClass(fqnSuperClass); this.subClassName = stringUtils.stripPackageName(fqnSubClass); this.subPackageName = stringUtils.stripClass(fqnSubClass); this.primaryDataMap = dataMap; this.objEntity = objEntity; this.callbackNames = new LinkedHashSet<String>(); for (CallbackDescriptor cb : objEntity.getCallbackMap().getCallbacks()) { callbackNames.addAll(cb.getCallbackMethods()); } }
private void processStartPostUpdate(Attributes attributes) { String methodName = attributes.getValue("", "method-name"); if (objEntity != null) { objEntity.getCallbackMap().getPostUpdate().addCallbackMethod(methodName); } }
private void processStartPreRemove(Attributes attributes) { String methodName = attributes.getValue("", "method-name"); if (objEntity != null) { objEntity.getCallbackMap().getPreRemove().addCallbackMethod(methodName); } }
private void processStartPostLoad(Attributes attributes) { String methodName = attributes.getValue("", "method-name"); if (objEntity != null) { objEntity.getCallbackMap().getPostLoad().addCallbackMethod(methodName); } }
private void processStartPrePersist(Attributes attributes) { // 3.0 -> 3.0.0.1 upgrade hack... treat pre-persist as post-add // only 3.0 used "pre-persist" in a "post-add" sense if ("3.0".equals(mapVersion)) { processStartPostAdd(attributes); } else { String methodName = attributes.getValue("", "method-name"); if (objEntity != null) { // new callback tags - children of "obj-entity" objEntity.getCallbackMap().getPrePersist().addCallbackMethod(methodName); } } }