コード例 #1
0
ファイル: WizardAction.java プロジェクト: siwiwit/jspresso-ce
  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)));
  }
コード例 #2
0
 /**
  * Attach the necessary listeners to the value connector so that adequate notifications get sent
  * to the remote client side.
  *
  * @param connector the connector to attach listeners to.
  */
 protected void attachListeners(IValueConnector connector) {
   connector.addPropertyChangeListener(IValueConnector.READABLE_PROPERTY, readabilityListener);
   connector.addPropertyChangeListener(IValueConnector.WRITABLE_PROPERTY, writabilityListener);
   if (connector instanceof ICollectionConnector) {
     connector.addValueChangeListener(collectionConnectorValueChangeListener);
     ((ICollectionConnector) connector).addSelectionChangeListener(selectionChangeListener);
   } else if (connector instanceof IRenderableCompositeValueConnector) {
     if (((IRenderableCompositeValueConnector) connector).getRenderingConnector() != null) {
       ((IRenderableCompositeValueConnector) connector)
           .getRenderingConnector()
           .addValueChangeListener(renderingConnectorValueChangeListener);
     }
   } else if (connector instanceof IFormattedValueConnector) {
     connector.addValueChangeListener(formattedConnectorValueChangeListener);
   } else {
     connector.addValueChangeListener(valueChangeListener);
   }
 }
コード例 #3
0
ファイル: WizardAction.java プロジェクト: siwiwit/jspresso-ce
 /** {@inheritDoc} */
 @SuppressWarnings("unchecked")
 @Override
 public boolean execute(IActionHandler actionHandler, Map<String, Object> context) {
   IValueConnector modelConnector =
       getBackendController(context)
           .createModelConnector(
               ACTION_MODEL_NAME, firstWizardStep.getViewDescriptor().getModelDescriptor());
   Map<String, Object> wizardModelInit =
       (Map<String, Object>) context.get(IWizardStepDescriptor.INITIAL_WIZARD_MODEL);
   Map<String, Object> wizardModel = new ObjectEqualityMap<>();
   if (wizardModelInit != null) {
     wizardModel.putAll(wizardModelInit);
   }
   completeInitialWizardModel(wizardModel, context);
   modelConnector.setConnectorValue(wizardModel);
   displayWizardStep(firstWizardStep, modelConnector, actionHandler, context, false);
   return super.execute(actionHandler, context);
 }
コード例 #4
0
ファイル: FindAction.java プロジェクト: siwiwit/jspresso-ce
 /**
  * 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;
 }