Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added script support for ExtendedItem #1468

Draft
wants to merge 1 commit into
base: qrcode_feature
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,41 @@ public static void handleOnPrepare(ExtendedItemHandle handle, ExecutionContext c

public static void handleOnCreate(ExtendedItemDesign design, IContent content, ExecutionContext context) {
ExtendedItemHandle handle = (ExtendedItemHandle) design.getHandle();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this item after the next if block. No need to get the handle if it is not used.

IReportEventHandler eventHandler = context.getExtendedItemManager().createEventHandler(handle);
if (eventHandler != null) {
try {
OnCreateEvent event = new OnCreateEvent(new ReportEventContext(context), handle, content);
if (!needOnCreate(design)) {
return;
}

try {
OnCreateEvent event = new OnCreateEvent(new ReportEventContext(context), handle, content);
if (handleScript(event, design.getOnCreate(), context).didRun()) {
return;
}
IReportEventHandler eventHandler = context.getExtendedItemManager().createEventHandler(handle);
if (eventHandler != null) {
eventHandler.handle(event);
} catch (Exception e) {
addException(context, e, handle);
}
} catch (Exception e) {
addException(context, e, handle);
}
}

public static void handleOnRender(ExtendedItemDesign design, IContent content, ExecutionContext context) {
ExtendedItemHandle handle = (ExtendedItemHandle) design.getHandle();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

IReportEventHandler eventHandler = context.getExtendedItemManager().createEventHandler(handle);
if (eventHandler != null) {
try {
OnRenderEvent event = new OnRenderEvent(new ReportEventContext(context), handle, content);
if (!needOnRender(design)) {
return;
}

try {
OnRenderEvent event = new OnRenderEvent(new ReportEventContext(context), handle, content);
if (handleScript(event, design.getOnRender(), context).didRun()) {
return;
}
IReportEventHandler eventHandler = context.getExtendedItemManager().createEventHandler(handle);
if (eventHandler != null) {
eventHandler.handle(event);
} catch (Exception e) {
addException(context, e, handle);
}
} catch (Exception e) {
addException(context, e, handle);
}
}
}