context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), targetComponent);
context.setProperty(PolicyContext.PropertyName.SOURCE_COMPONENTS.getName(), sourceComponents);
context.setProperty(PolicyContext.PropertyName.ACTION.getName(), Character.valueOf('w'));
context.setProperty(PolicyContext.PropertyName.VIEW_MANIFESTATION_PROVIDER.getName(), event.getTargetManifestation());
final ExecutionResult result = PlatformAccess.getPlatform().getPolicyManager().execute(PolicyInfo.CategoryType.COMPOSITION_POLICY_CATEGORY.getKey(), context);
if (result.getStatus()) {
// Persist
PersistenceProvider persistenceProvider = PlatformAccess.getPlatform().getPersistenceProvider();
boolean successfulAction = false;
try {
persistenceProvider.startRelatedOperations();
targetComponent.addDelegateComponents(sourceComponents);
targetComponent.save();
successfulAction = true;
} finally {
persistenceProvider.completeRelatedOperations(successfulAction);
}
if (successfulAction) {
if (event.getTargetManifestation() instanceof DropboxCanvasView) {
StringBuilder sentObjects = new StringBuilder();
for (AbstractComponent sourceComponent : sourceComponents)
sentObjects.append("\"" + sourceComponent.getExtendedDisplayName() + "\" ");
DropboxCanvasView dropboxManifestation = (DropboxCanvasView) event.getTargetManifestation();
dropboxManifestation.statusMessage.setText((sourceComponents.size() == 0) ? "No objects sent." :
"Accepted at " + DateFormat.getInstance().format(new Date()) +": "+ sentObjects.toString());
dropboxManifestation.revalidate();
}
// Pull tarmanifestInfoget housing window to front.
event.getHousingWindow().toFront();
}
} else {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
OptionBox.showMessageDialog(container, result.getMessage(), "Composition Error - ", OptionBox.ERROR_MESSAGE);
}
});
}
}