/** * Lays out child components in a tab model. * * @param object the parent object * @param properties the properties * @param model the tab model * @param context the layout context * @param shortcuts if <tt>true</tt> include short cuts */ @Override protected void doTabLayout( IMObject object, List<Property> properties, IMObjectTabPaneModel model, LayoutContext context, boolean shortcuts) { super.doTabLayout(object, properties, model, context, shortcuts); Browser<Act> appointments = getAppointments((Party) object, context); Component inset = ColumnFactory.create(Styles.INSET, appointments.getComponent()); String label = Messages.get("customer.info.appointments"); if (shortcuts && model.size() < 10) { label = getShortcut(label, model.size() + 1); } model.addTab(label, inset); }
/** * Invoked when an appointment is selected. * * <p>If the appointment can be viewed at the current practice location, the appointment workspace * will be switched to. * * @param appointment the appointment * @param layoutContext the layout context */ private void onAppointmentSelected(Act appointment, LayoutContext layoutContext) { AppointmentRules rules = ServiceHelper.getBean(AppointmentRules.class); Context context = layoutContext.getContext(); ContextSwitchListener listener = layoutContext.getContextSwitchListener(); ActBean bean = new ActBean(appointment); Entity schedule = bean.getNodeParticipant("schedule"); Party location = context.getLocation(); if (schedule != null && location != null) { Entity view = rules.getScheduleView(location, schedule); if (view != null) { listener.switchTo(appointment); } else { Party newLocation = rules.getLocation(schedule); String name = (newLocation != null) ? newLocation.getName() : Messages.get("imobject.none"); InformationDialog.show(Messages.format("customer.info.appointment.wrongLocation", name)); } } }
/** * Validates the object. * * @param validator the validator * @return {@code true} if the object and its descendants are valid otherwise {@code false} */ @Override protected boolean doValidation(Validator validator) { boolean result = super.doValidation(validator); if (result) { FinancialAct balance = (FinancialAct) getParent(); if (balance != null) { currentBalance = IMObjectHelper.reload(balance); // make sure we have the latest instance if (currentBalance == null) { ErrorDialog.show( Messages.format("imobject.noexist", DescriptorHelper.getDisplayName(balance))); result = false; } else if (TillBalanceStatus.CLEARED.equals(currentBalance.getStatus())) { ErrorDialog.show(Messages.get("till.adjustment.error.clearedBalance")); result = false; } } } return result; }
/** * Constructs an {@code AlertsViewer} to display alerts for multiple alert types. * * @param alerts the alerts * @param context the context * @param help the help context */ public AlertsViewer(List<Alert> alerts, Context context, HelpContext help) { super(Messages.get("alerts.title"), "AlertsViewer", CLOSE, help); this.context = context; this.alerts = alerts; setModal(true); }