@SuppressWarnings({"rawtypes"}) private void postEvent( final ObjectAction owningAction, final ObjectAdapter targetAdapter, final ObjectAdapter[] argumentAdapters) { try { final Class type = eventType; Identifier actionIdentifier = owningAction.getIdentifier(); final Object source = AdapterUtils.unwrap(targetAdapter); final Object[] arguments = AdapterUtils.unwrap(argumentAdapters); @SuppressWarnings("unchecked") final ActionInvokedEvent<?> event = org.apache.isis.core.metamodel.facets.actions.event.PostsActionInvokedEventFacet.Util .newEvent(type, source, actionIdentifier, arguments); getEventBusService().post(event); } catch (Exception e) { throw new FatalException(e); } }
private void updateBuild( final View view, final Axes axes, final ObjectAdapter object, final List<ObjectAssociation> flds) { LOG.debug(" as update build"); /* * 1/ To remove fields: look through views and remove any that don't * exists in visible fields * * 2/ From remaining views, check for changes as already being done, and * replace if needed * * 3/ Finally look through fields to see if there is no existing * subview; and add one */ View[] subviews = view.getSubviews(); // remove views for fields that no longer exist outer: for (int i = 0; i < subviews.length; i++) { final FieldContent fieldContent = ((FieldContent) subviews[i].getContent()); for (int j = 0; j < flds.size(); j++) { final ObjectAssociation field = flds.get(j); if (fieldContent.getField() == field) { continue outer; } } view.removeView(subviews[i]); } // update existing fields if needed subviews = view.getSubviews(); for (int i = 0; i < subviews.length; i++) { final View subview = subviews[i]; final ObjectAssociation field = ((FieldContent) subview.getContent()).getField(); final ObjectAdapter value = field.get(object); if (field.isOneToManyAssociation()) { subview.update(value); } else if (field.isOneToOneAssociation()) { final ObjectAdapter existing = subview.getContent().getAdapter(); // if the field is parseable then it may have been modified; we // need to replace what was // typed in with the actual title. if (!field.getSpecification().isParseable()) { final boolean changedValue = value != existing; final boolean isDestroyed = existing != null && existing.isDestroyed(); if (changedValue || isDestroyed) { View fieldView; fieldView = createFieldView(view, axes, object, i, field); if (fieldView != null) { view.replaceView(subview, decorateSubview(axes, fieldView)); } else { view.addView(new FieldErrorView("No field for " + value)); } } } else { if (AdapterUtils.exists(value) && !AdapterUtils.wrappedEqual(value, existing)) { final View fieldView = createFieldView(view, axes, object, i, field); view.replaceView(subview, decorateSubview(axes, fieldView)); } else { subview.refresh(); } } } else { throw new UnknownTypeException(field.getName()); } } // add new fields outer2: for (int j = 0; j < flds.size(); j++) { final ObjectAssociation field = flds.get(j); for (int i = 0; i < subviews.length; i++) { final FieldContent fieldContent = ((FieldContent) subviews[i].getContent()); if (fieldContent.getField() == field) { continue outer2; } } addField(view, axes, object, field, j); } }