/**
  * 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;
 }
 /**
  * Returns the qualified name.
  *
  * <p>This includes the contact name and party name, if a contact name is specified. If not, it
  * just returns the party name.
  *
  * @param contact the email contact
  * @return the qualified name. May be {@code null}
  */
 @Override
 public String getQualifiedName(Contact contact) {
   String name = contact.getName();
   String partyName = getPartyName(contact);
   if (StringUtils.isEmpty(name) || StringUtils.equals(defaultValue, name)) {
     name = partyName;
   } else {
     name = (partyName != null) ? Messages.format("mail.qualifiedname", name, partyName) : name;
   }
   return name;
 }
 /** Lays out the component. */
 @Override
 protected Component doLayout() {
   String name = getProperty().getDisplayName();
   String label = Messages.format("relationship.hide.inactive", name);
   hideInactive = CheckBoxFactory.create(null, true);
   hideInactive.setText(label);
   hideInactive.addActionListener(
       new ActionListener() {
         public void onAction(ActionEvent event) {
           onHideInactiveChanged();
         }
       });
   Component component = super.doLayout();
   component.add(hideInactive, 0);
   return component;
 }
  /**
   * 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);
  }
示例#6
0
 /**
  * Validates the object.
  *
  * @param validator the validator
  * @return {@code true} if the object and its descendants are valid otherwise {@code false}
  */
 protected boolean doValidation(Validator validator) {
   List<ValidatorError> errors = null;
   if (validationErrors == null) {
     PropertyTransformer transformer = getTransformer();
     try {
       transformer.apply(getValue());
     } catch (OpenVPMSException exception) {
       invalidate(exception);
     }
   }
   if (validationErrors != null) {
     errors = validationErrors;
   } else if (isRequired() && getValue() == null) {
     validationErrors = new ArrayList<ValidatorError>();
     validationErrors.add(
         new ValidatorError(this, Messages.format("property.error.required", getDisplayName())));
     errors = validationErrors;
   }
   if (errors != null) {
     validator.add(this, errors);
   }
   return (errors == null);
 }
示例#7
0
 /**
  * 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);
 }