Package org.dmrad.view

Examples of org.dmrad.view.App


   */
  public EntityDisplayPage(final ModelContext modelContext,
      final ViewContext viewContext) {
    super(modelContext, viewContext);
    try {
      App app = viewContext.getApp();

      ModelContext entityDisplayPanelModelContext = new ModelContext(
          modelContext);

      ViewContext entityDisplayPanelViewContext = new ViewContext(
          viewContext);
      entityDisplayPanelViewContext.setWicketId("entityDisplayPanel");
      entityDisplayPanelViewContext.setPage(this);
      entityDisplayPanelViewContext.setUpdate(false);

      add(app.getViewMeta().getPanel("EntityDisplayPanel",
          entityDisplayPanelModelContext,
          entityDisplayPanelViewContext));
    } catch (Exception e) {
      log.error("Error in EntityDisplayPage: "
          + modelContext.getEntityCode() + " - " + e.getMessage());
View Full Code Here


        String action = baseModelContext.getAction();

        if (baseEntityPropertyConfig.isReference()) {
          String neighborCode = baseEntityPropertyConfig
              .getReferenceNeighbor();
          App app = baseViewContext.getApp();
          if (action.equals("add")) {
            IEntity entity = baseModelContext.getEntity();
            entity.setNeighborEntity(neighborCode, lookupEntity);
            ModelContext entityAddFormPageModelContext = new ModelContext(
                baseModelContext);
            entityAddFormPageModelContext
                .setEntities(baseModelContext
                    .getContextEntities());
            entityAddFormPageModelContext.setLookupEntities(null);
            ViewContext entityAddFormPageViewContext = new ViewContext(
                baseViewContext);
            entityAddFormPageViewContext.setUpdate(true);
            setResponsePage(app.getViewMeta().getPage(
                "EntityAddFormPage",
                entityAddFormPageModelContext,
                entityAddFormPageViewContext));
          } else {
            IEntity entity = baseModelContext.getUpdateEntity();
            entity.setNeighborEntity(neighborCode, lookupEntity);
            ModelContext entityEditFormPageModelContext = new ModelContext(
                baseModelContext);
            entityEditFormPageModelContext
                .setEntities(baseModelContext
                    .getContextEntities());
            entityEditFormPageModelContext.setLookupEntities(null);
            ViewContext entityEditFormPageViewContext = new ViewContext(
                baseViewContext);
            entityEditFormPageViewContext.setUpdate(true);
            setResponsePage(app.getViewMeta().getPage(
                "EntityEditFormPage",
                entityEditFormPageModelContext,
                entityEditFormPageViewContext));
          }
        } else {
View Full Code Here

   */
  public EntityAddFormPanel(final ModelContext modelContext,
      final ViewContext viewContext) {
    super(modelContext, viewContext);
    try {
      App app = viewContext.getApp();
     
      IEntities entities = modelContext.getEntities();

      ModelContext entityAddFormModelContext = new ModelContext(
          modelContext);
      entityAddFormModelContext.setAction("add");
      IEntity newEntity = modelContext.getEntity();
      if (newEntity == null) {
        newEntity = app.getModelMeta().createEntity(entities);
        entityAddFormModelContext.setEntity(newEntity);
      }

      ViewContext entityAddFormViewContext = new ViewContext(viewContext);
      entityAddFormViewContext.setWicketId("entityUpdateForm");

      add(app.getViewMeta().getForm("EntityAddForm",
          entityAddFormModelContext, entityAddFormViewContext));
    } catch (Exception e) {
      log.error("Error in EntityAddFormPanel: "
          + modelContext.getEntitiesCode() + " - " + e.getMessage());
    }
View Full Code Here

   */
  public EntityConfirmRemovePage(final ModelContext modelContext,
      final ViewContext viewContext) {
    super(modelContext, viewContext);
    try {
      App app = viewContext.getApp();

      add(new FeedbackPanel("feedbackPanel"));

      ModelContext entityDisplayPanelModelContext = new ModelContext(
          modelContext);

      ViewContext entityDisplayPanelViewContext = new ViewContext(
          viewContext);
      entityDisplayPanelViewContext.setPage(this);
      entityDisplayPanelViewContext.setWicketId("entityDisplayPanel");
      entityDisplayPanelViewContext.setUpdate(false);

      add(app.getViewMeta().getPanel("EntityDisplayPanel",
          entityDisplayPanelModelContext,
          entityDisplayPanelViewContext));

      ViewContext entityConfirmRemovePanelContext = new ViewContext(
          viewContext);
      entityConfirmRemovePanelContext.setPage(this);
      entityConfirmRemovePanelContext
          .setWicketId("entityConfirmRemovePanel");
      add(app.getViewMeta().getPanel("EntityConfirmRemovePanel",
          entityDisplayPanelModelContext,
          entityConfirmRemovePanelContext));
    } catch (Exception e) {
      log.error("Error in EntityConfirmRemovePage: "
          + modelContext.getEntitiesCode() + " - " + e.getMessage());
View Full Code Here

   */
  protected void populateItem(ListItem item) {
    try {
      IEntity entity = (IEntity) item.getModelObject();
     
      App app = viewContext.getApp();

      ConceptConfig conceptConfig = entity.getConceptConfig();
      String conceptCode = conceptConfig.getCode();

      ModelContext entityModelContext = new ModelContext(modelContext);
      entityModelContext.setEntity(entity);

      List<PropertyNameLabelValuePanelPair> propertyNameLabelValuePanelPairs = new ArrayList<PropertyNameLabelValuePanelPair>();

      // Properties absorbed from parents.
      NeighborsConfig neighborsConfig = conceptConfig
          .getNeighborsConfig();
      for (IEntity neighborConfigEntity : neighborsConfig) {
        NeighborConfig neighborConfig = (NeighborConfig) neighborConfigEntity;
        if (neighborConfig.getType().equals("parent")
            && neighborConfig.getMax().equals("1")
            && neighborConfig.isAbsorb()) {
          ConceptConfig parentConceptConfig = neighborConfig
              .getNeighborDestinationConceptConfig();
          if (parentConceptConfig != null) {
            if (conceptCode.equals(neighborConfig
                .getContextConceptConfig().getCode())
                && parentConceptConfig.getDisplayType().equals(
                    "slide")) {
              // Do not absorb the context parent properties when
              // the parent is displayed as a slide.
              continue;
            }
            PropertiesConfig parentConceptPropertiesConfig = parentConceptConfig
                .getPropertiesConfig();
            for (IEntity parentPropertyConfigEntity : parentConceptPropertiesConfig) {
              PropertyConfig parentConceptPropertyConfig = (PropertyConfig) parentPropertyConfigEntity;
              if (parentConceptPropertyConfig.isEssential()) {
                IEntity parentEntity = entity
                    .getNeighborEntity(neighborConfig
                        .getCode());
                if (parentEntity != null) {
                  String parentCode = parentEntity
                      .getConceptConfig().getCode();
                  String parentPropertyKey = parentCode
                      + "."
                      + parentConceptPropertyConfig
                          .getCode();
                  String parentPropertyName = getLocalizer()
                      .getString(parentPropertyKey, this);
                  Label parentPropertyNameLabel = new Label(
                      "propertyName", parentPropertyName);
                  PropertyNameLabelValuePanelPair propertyNameLabelValuePanelPair = new PropertyNameLabelValuePanelPair();
                  propertyNameLabelValuePanelPair
                      .setPropertyNameLabel(parentPropertyNameLabel);

                  ModelContext parentModelContext = new ModelContext(
                      modelContext);
                  parentModelContext.setEntity(parentEntity);
                  parentModelContext
                      .setPropertyConfig(parentConceptPropertyConfig);

                  ViewContext parentViewContext = new ViewContext(
                      viewContext);
                  parentViewContext.setWicketId("valuePanel");
                  Panel parentPropertyPanel;
                  if (parentConceptPropertyConfig
                      .getPropertyClass().equals(
                          "java.net.URL")
                      || parentConceptPropertyConfig
                          .getPropertyClass()
                          .equals(
                              "org.dmlite.type.email.Email")) {
                    parentPropertyPanel = new ExternalLinkPanel(
                        parentModelContext,
                        parentViewContext);
                  } else {
                    parentPropertyPanel = new LabelPanel(
                        parentModelContext,
                        parentViewContext);
                  } // if
                  if (!app.isNeighborDisplayAllowed(
                      getAppSession(), neighborConfig)) {
                    parentPropertyPanel.setVisible(false);
                  } else if (!app.isPropertyDisplayAllowed(
                      getAppSession(),
                      parentConceptPropertyConfig)) {
                    parentPropertyPanel.setVisible(false);
                  }

                  propertyNameLabelValuePanelPair
                      .setPropertyValuePanel(parentPropertyPanel);
                  propertyNameLabelValuePanelPairs
                      .add(propertyNameLabelValuePanelPair);
                } // if
              } // if
            } // for
          } // if
        } // if
      } // for

      PropertiesConfig propertiesConfig = conceptConfig
          .getPropertiesConfig();
      for (IEntity propertyConfigEntity : propertiesConfig) {
        PropertyConfig propertyConfig = (PropertyConfig) propertyConfigEntity;
        if (!propertyConfig.isReference()) {
          String propertyKey = conceptCode + "."
              + propertyConfig.getCode();
          String propertyName = getLocalizer().getString(propertyKey,
              this);
          Label propertyNameLabel = new Label("propertyName",
              propertyName);
          PropertyNameLabelValuePanelPair propertyNameLabelValuePanelPair = new PropertyNameLabelValuePanelPair();
          propertyNameLabelValuePanelPair
              .setPropertyNameLabel(propertyNameLabel);

          entityModelContext.setPropertyConfig(propertyConfig);
          ViewContext propertiesViewContext = new ViewContext(
              viewContext);
          propertiesViewContext.setWicketId("valuePanel");
          Panel propertyValuePanel;
          if (propertyConfig.getPropertyClass()
              .equals("java.net.URL")
              || propertyConfig.getPropertyClass().equals(
                  "org.dmlite.type.email.Email")) {
            propertyValuePanel = new ExternalLinkPanel(
                entityModelContext, propertiesViewContext);
          } else if (propertyConfig.getPropertyClass().equals(
              "java.lang.String")
              && propertyConfig.isValidateType()
              && (propertyConfig.getValidationType().equals(
                  "java.net.URL") || propertyConfig
                  .getValidationType().equals(
                      "org.dmlite.type.email.Email"))) {
            propertyValuePanel = new ExternalLinkPanel(
                entityModelContext, propertiesViewContext);
          } else {
            propertyValuePanel = new LabelPanel(entityModelContext,
                propertiesViewContext);
          }
          if (!app.isPropertyDisplayAllowed(getAppSession(),
              propertyConfig)) {
            propertyNameLabel.setVisible(false);
            propertyValuePanel.setVisible(false);
          }

          propertyNameLabelValuePanelPair
              .setPropertyValuePanel(propertyValuePanel);
          propertyNameLabelValuePanelPairs
              .add(propertyNameLabelValuePanelPair);
        }
      }

      ListView propertyNameLabelValuePanelListView = new PropertyNameLabelValuePanelListView(
          "propertyNameLabelValuePanelListView",
          propertyNameLabelValuePanelPairs);
      item.add(propertyNameLabelValuePanelListView);
      if (!app.isConceptDisplayAllowed(getAppSession(), conceptConfig)) {
        propertyNameLabelValuePanelListView.setVisible(false);
      }

      List<Panel> childList = new ArrayList<Panel>();
      for (IEntity neighborConfigEntity : neighborsConfig) {
        NeighborConfig neighborConfig = (NeighborConfig) neighborConfigEntity;
        if (neighborConfig.getType().equals("child")) {
          String childCode = neighborConfig.getCode();
          IDomainModel domainModel = app.getDomainModel();
          IOrderedEntities childEntities = (IOrderedEntities) domainModel
              .getModelMeta().getNeighborEntities(entity,
                  childCode);
          ModelContext childEntitiesContext = new ModelContext(
              modelContext);
          childEntitiesContext.setEntities(childEntities);
          ViewContext entityDisplayListPanelContext = new ViewContext(
              viewContext);
          entityDisplayListPanelContext
              .setWicketId("entityDisplayListPanel");
          Panel entityDisplayListPanel = app.getViewMeta().getPanel(
              "EntityDisplayListPanel", childEntitiesContext,
              entityDisplayListPanelContext);
          childList.add(entityDisplayListPanel);
          if (!app.isNeighborDisplayAllowed(getAppSession(),
              neighborConfig)) {
            entityDisplayListPanel.setVisible(false);
          }
        } // if (neighborConfig.getType().equals("child")) {
      } // for
View Full Code Here

      try {
        add(new Button("no") {
          static final long serialVersionUID = 200682L;

          protected void onSubmit() {
            App app = viewContext.getApp();
            ViewContext entityUpdateTablePageContext = new ViewContext(
                viewContext);
            setResponsePage(app.getViewMeta().getPage(
                "EntityUpdateTablePage", modelContext,
                entityUpdateTablePageContext));
          }
        }.setDefaultFormProcessing(false));
      } catch (Exception e) {
View Full Code Here

     */
    protected void onSubmit() {
      IEntities entities = modelContext.getEntities();
      IEntity entity = modelContext.getEntity();
      ConceptConfig conceptConfig = entities.getConceptConfig();
      App app = viewContext.getApp();

      try {
        if (app.isConceptUpdateAllowed(getAppSession(),
            conceptConfig, entity, "remove")) {
          if (entities.remove(entity)) {
            ViewContext entityUpdateTablePageContext = new ViewContext(
                viewContext);
            setResponsePage(app.getViewMeta().getPage(
                "EntityUpdateTablePage", modelContext,
                entityUpdateTablePageContext));
          } else {
            addDmLiteErrorKeys(entities);
          }
View Full Code Here

  public EntityPropertyDisplayListPanel(final ModelContext modelContext,
      final ViewContext viewContext) {
    super(modelContext, viewContext);
    try {
      App app = viewContext.getApp();
     
      ConceptConfig conceptConfig = modelContext.getEntities()
          .getConceptConfig();
      String entityCode = conceptConfig.getCode();
      String propertyCode = modelContext.getPropertyConfig().getCode();
      String entityPropertyKey = entityCode + "." + propertyCode;
      String entityPropertyTitle = getLocalizer().getString(
          entityPropertyKey, this);
      Label entityPropertyTitleLabel = new Label("entityPropertyTitle",
          entityPropertyTitle);
      add(entityPropertyTitleLabel);

      ModelContext entityPropertyListModelContext = new ModelContext(
          modelContext);
      ViewContext entityPropertyListViewContext = new ViewContext(
          viewContext);
      entityPropertyListViewContext.setWicketId("entityPropertyList");

      ListView entityPropertyDisplayListListView = app.getViewMeta()
          .getListView("EntityPropertyDisplayListListView",
              entityPropertyListModelContext,
              entityPropertyListViewContext);
      add(entityPropertyDisplayListListView);
      if (!app.isConceptDisplayAllowed(getAppSession(), conceptConfig)) {
        entityPropertyDisplayListListView.setVisible(false);
      }
    } catch (Exception e) {
      log.error("Error in EntityPropertyDisplayListPanel: "
          + e.getMessage());
View Full Code Here

  protected void populateItem(ListItem item) {
    super.populateItem(item);
    try {
      IEntity entity = (IEntity) item.getModelObject();
     
      final App app = viewContext.getApp();
     
      IEntities entities = modelContext.getEntities();

      ConceptConfig conceptConfig = entity.getConceptConfig();
      String conceptCode = conceptConfig.getCode();

      // Neighbor display links
      List<NeighborNameLabelLinkPair> neighborNameLabelLinkPairs = new ArrayList<NeighborNameLabelLinkPair>();
      NeighborsConfig neighborsConfig = conceptConfig
          .getNeighborsConfig();
      for (IEntity neighborConfigEntity : neighborsConfig) {
        NeighborConfig neighborConfig = (NeighborConfig) neighborConfigEntity;
        if (neighborConfig.getType().equals("child")) {
          String neighborConcept = neighborConfig.getDestination();
          ConceptConfig neighborConceptConfig = neighborConfig
              .getContextConceptConfig().getContextModelConfig()
              .getConceptConfig(neighborConcept);

          final String neighborDisplayType = neighborConceptConfig
              .getDisplayType();
          NeighborNameLabelLinkPair neighborNameLabelLinkPair = new NeighborNameLabelLinkPair();
          String neighborKey = conceptCode + "."
              + neighborConfig.getCode();
          String neighborName = getLocalizer().getString(neighborKey,
              this);
          Label neighborNameLabel = new Label("neighborName",
              neighborName);
          neighborNameLabelLinkPair
              .setNeighborNameLabel(neighborNameLabel);
          Link neighborLink;
          IDomainModel domainModel = app.getDomainModel();
          IOrderedEntities neighborEntities = (IOrderedEntities) domainModel
              .getModelMeta().getNeighborEntities(entity,
                  neighborConfig.getCode());

          final ModelContext neighborModelContext = new ModelContext(
              modelContext);
          neighborModelContext.setContextEntities(entities);
          neighborModelContext.setContextEntity(entity);
          neighborModelContext.setEntities(neighborEntities);

          final ViewContext neighborViewContext = new ViewContext(
              viewContext);

          neighborLink = new PageLink("neighbor", new IPageLink() {
            static final long serialVersionUID = 200471L;

            WebPage neighborPage;

            public Page getPage() {
              if (neighborDisplayType.equals("table")) {
                neighborPage = app.getViewMeta().getPage(
                    "EntityDisplayTablePage",
                    neighborModelContext,
                    neighborViewContext);
              } else if (neighborDisplayType.equals("list")) {
                neighborPage = app.getViewMeta().getPage(
                    "EntityDisplayListPage",
                    neighborModelContext,
                    neighborViewContext);
              } else if (neighborDisplayType.equals("slide")) {
                neighborPage = app.getViewMeta().getPage(
                    "EntityDisplaySlidePage",
                    neighborModelContext,
                    neighborViewContext);
              }
              return neighborPage;
            }

            Class neighborPageClass;

            public Class getPageIdentity() {
              if (neighborDisplayType.equals("table")) {
                neighborPageClass = app.getViewMeta()
                    .getPageClass("EntityDisplayTablePage",
                        neighborModelContext,
                        neighborViewContext);
              } else if (neighborDisplayType.equals("list")) {
                neighborPageClass = app.getViewMeta()
                    .getPageClass("EntityDisplayListPage",
                        neighborModelContext,
                        neighborViewContext);
              } else if (neighborDisplayType.equals("slide")) {
                neighborPageClass = app.getViewMeta()
                    .getPageClass("EntityDisplaySlidePage",
                        neighborModelContext,
                        neighborViewContext);
              }
              return neighborPageClass;
            }
          });
          if (!app.isNeighborDisplayAllowed(getAppSession(),
              neighborConfig)) {
            neighborLink.setVisible(false);
          }

          neighborNameLabelLinkPair.setNeighborLink(neighborLink);
View Full Code Here

  public EntitySlideNavigatePanel(final ModelContext modelContext,
      final ViewContext viewContext) {
    super(viewContext.getWicketId());
    try {
      final App app = viewContext.getApp();
     
      final IOrderedEntities entities = modelContext.getOrderedEntities();
      final IEntity entity = modelContext.getEntity();   
      ConceptConfig conceptConfig = entity.getConceptConfig();

      Link firstLink = new Link("first") {
        static final long serialVersionUID = 200581L;

        public void onClick() {
          IEntity firstEntity = (IEntity) entities.first();
          ModelContext firstEntityModelContext = new ModelContext(
              modelContext);
          firstEntityModelContext.setEntity(firstEntity);

          ViewContext firstEntityViewContext = new ViewContext(
              viewContext);

          WebPage firstWebPage = app.getViewMeta().getPage(
              "EntityDisplaySlidePage", firstEntityModelContext,
              firstEntityViewContext);
          setResponsePage(firstWebPage);
        }
      };
      add(firstLink);

      Link nextLink = new Link("next") {
        static final long serialVersionUID = 200582L;

        public void onClick() {
          IEntity nextEntity = findNextEntity(entities, entity);

          ModelContext nextEntityModelContext = new ModelContext(
              modelContext);
          nextEntityModelContext.setEntity(nextEntity);

          ViewContext nextEntityViewContext = new ViewContext(
              viewContext);

          WebPage nextWebPage = app.getViewMeta().getPage(
              "EntityDisplaySlidePage", nextEntityModelContext,
              nextEntityViewContext);
          setResponsePage(nextWebPage);
        }
      };
      add(nextLink);

      Link priorLink = new Link("prior") {
        static final long serialVersionUID = 200583L;

        public void onClick() {
          IEntity priorEntity = findPriorEntity(entities, entity);

          ModelContext priorEntityModelContext = new ModelContext(
              modelContext);
          priorEntityModelContext.setEntity(priorEntity);

          ViewContext priorEntityViewContext = new ViewContext(
              viewContext);

          WebPage priorWebPage = app.getViewMeta().getPage(
              "EntityDisplaySlidePage", priorEntityModelContext,
              priorEntityViewContext);
          setResponsePage(priorWebPage);
        }
      };
      add(priorLink);

      Link lastLink = new Link("last") {
        static final long serialVersionUID = 200584L;

        public void onClick() {
          IEntity lastEntity = (IEntity) entities.last();

          ModelContext lastEntityModelContext = new ModelContext(
              modelContext);
          lastEntityModelContext.setEntity(lastEntity);

          ViewContext lastEntityViewContext = new ViewContext(
              viewContext);

          WebPage lastWebPage = app.getViewMeta().getPage(
              "EntityDisplaySlidePage", lastEntityModelContext,
              lastEntityViewContext);
          setResponsePage(lastWebPage);
        }
      };
      add(lastLink);

      if (!app.isConceptDisplayAllowed(getAppSession(), conceptConfig)) {
        firstLink.setVisible(false);
        nextLink.setVisible(false);
        priorLink.setVisible(false);
        lastLink.setVisible(false);
      }
View Full Code Here

TOP

Related Classes of org.dmrad.view.App

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.