Esempio n. 1
0
  private void displayWizardStep(
      IWizardStepDescriptor wizardStep,
      IValueConnector modelConnector,
      IActionHandler actionHandler,
      Map<String, Object> context,
      boolean reuseCurrent) {

    ITranslationProvider translationProvider = getTranslationProvider(context);
    Locale locale = getLocale(context);
    IView<E> view =
        getViewFactory(context)
            .createView(wizardStep.getViewDescriptor(), actionHandler, getLocale(context));
    IModelDescriptor modelDescriptor = wizardStep.getViewDescriptor().getModelDescriptor();
    if (modelDescriptor instanceof IComponentDescriptor<?>) {
      for (IPropertyDescriptor propertyDescriptor :
          ((IComponentDescriptor<?>) modelDescriptor).getPropertyDescriptors()) {
        if (propertyDescriptor instanceof IScalarPropertyDescriptor
            && ((IScalarPropertyDescriptor) propertyDescriptor).getDefaultValue() != null) {
          Map<String, Object> wizardModel = modelConnector.getConnectorValue();
          if (!wizardModel.containsKey(propertyDescriptor.getName())) {
            wizardModel.put(
                propertyDescriptor.getName(),
                ((IScalarPropertyDescriptor) propertyDescriptor).getDefaultValue());
          }
        }
      }
    }
    getMvcBinder(context).bind(view.getConnector(), modelConnector);

    String title =
        getI18nName(translationProvider, locale)
            + " - "
            + wizardStep.getI18nName(translationProvider, locale);
    Dimension dialogSize = getDialogSize(context);
    getController(context)
        .displayModalDialog(
            view.getPeer(),
            createWizardStepActions(
                wizardStep,
                view,
                actionHandler,
                translationProvider,
                locale,
                modelConnector,
                context),
            title,
            getSourceComponent(context),
            context,
            dialogSize,
            reuseCurrent);
    // We must update the context
    context.putAll(
        getActionFactory(context)
            .createActionContext(
                actionHandler,
                view,
                view.getConnector(),
                getActionCommand(context),
                getActionWidget(context)));
  }
Esempio n. 2
0
 /**
  * Retrieves the query component out of the context.
  *
  * @param context the action context.
  * @return the query component.
  */
 @Override
 protected IQueryComponent getQueryComponent(Map<String, Object> context) {
   IValueConnector queryEntityConnector =
       (IValueConnector) context.get(CreateQueryComponentAction.QUERY_MODEL_CONNECTOR);
   if (queryEntityConnector == null) {
     queryEntityConnector = getModelConnector(context);
     while (queryEntityConnector != null
         && !(queryEntityConnector.getConnectorValue() instanceof IQueryComponent)) {
       // climb the connector hierarchy to retrieve the IQueryComponent
       // connector.
       queryEntityConnector = queryEntityConnector.getParentConnector();
     }
   }
   IQueryComponent queryComponent = null;
   if (queryEntityConnector != null && queryEntityConnector.getConnectorValue() != null) {
     queryComponent = queryEntityConnector.getConnectorValue();
   }
   return queryComponent;
 }