Example usage for org.apache.wicket.markup.html.list ListView setVisible

List of usage examples for org.apache.wicket.markup.html.list ListView setVisible

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.list ListView setVisible.

Prototype

public final Component setVisible(final boolean visible) 

Source Link

Document

Sets whether this component and any children are visible.

Usage

From source file:org.hippoecm.frontend.editor.workflow.dialog.DocumentMetadataDialog.java

License:Apache License

public DocumentMetadataDialog(WorkflowDescriptorModel model) {
    super(model);

    setTitleKey("document-info");
    setSize(DialogConstants.MEDIUM_AUTO);

    setOkVisible(false);/*from   w ww .  java 2 s. c  om*/
    setCancelLabel(new StringResourceModel("close", this, null));
    setFocusOnCancel();

    ListView metaDataListView = getMetaDataListView();
    add(metaDataListView);

    // Show info of live variant if one found with hippostd:state = published and hippostd:stateSummary = live || changed
    List<DocumentMetadataEntry> publicationMetadata = getPublicationMetaData();
    ListView publicationDataList = new ListView<DocumentMetadataEntry>("publicationmetadatalist",
            publicationMetadata) {
        protected void populateItem(ListItem item) {
            final DocumentMetadataEntry entry = (DocumentMetadataEntry) item.getModelObject();
            item.add(new Label("key", entry.getKey()));
            item.add(new Label("value", entry.getValue()));
        }
    };
    final Label publicationheader = new Label("publicationheader", getString("publication-header"));
    add(publicationheader);
    add(publicationDataList);

    if (publicationMetadata.size() == 0) {
        publicationDataList.setVisible(false);
        publicationheader.setVisible(false);
    }
}

From source file:org.hippoecm.frontend.plugins.cms.admin.users.SetMembershipsPanel.java

License:Apache License

public SetMembershipsPanel(final String id, final IPluginContext context,
        final IBreadCrumbModel breadCrumbModel, final IModel<User> userModel) {
    super(id);/*from w w  w. j a  v  a 2  s .c om*/

    setOutputMarkupId(true);

    selectedGroup = null;
    this.userModel = userModel;
    this.context = context;
    final User user = userModel.getObject();

    // All local groups
    hippoForm = new HippoForm("form");

    final WebMarkupContainer localMembershipContainer = new WebMarkupContainer("localMembershipsContainer");
    localMembershipContainer.setOutputMarkupId(true);
    hippoForm.add(localMembershipContainer);

    final WebMarkupContainer externalMembershipsContainer = new WebMarkupContainer(
            "externalMembershipsContainer");
    externalMembershipsContainer.setOutputMarkupId(true);
    hippoForm.add(externalMembershipsContainer);

    final AjaxButton submit = new AjaxButton("submit", hippoForm) {
        @Override
        protected void onSubmit(final AjaxRequestTarget target, final Form form) {
            hippoForm.clearFeedbackMessages();
            try {
                if (selectedGroup.getMembers().contains(user.getUsername())) {
                    showInfo(getString("user-membership-already-member", new DetachableGroup(selectedGroup)),
                            target);
                } else {
                    selectedGroup.addMembership(user.getUsername());

                    final String msg = String.format("added user %s to group %s", user.getUsername(),
                            selectedGroup.getGroupname());
                    EventBusUtils.post("add-user-to-group", HippoEventConstants.CATEGORY_GROUP_MANAGEMENT, msg);
                    showInfo(getString("user-membership-added", new DetachableGroup(selectedGroup)), target);
                }
            } catch (RepositoryException e) {
                showError(getString("user-membership-add-failed", new DetachableGroup(selectedGroup)), target);
                log.error("Failed to add memberships", e);
            }
            target.add(localMembershipContainer);
        }
    };
    hippoForm.add(submit);

    final List<Group> localGroups = Group.getLocalGroups();
    final DropDownChoice<Group> ddc = new DropDownChoice<>("local-groups",
            PropertyModel.of(this, "selectedGroup"), localGroups, new ChoiceRenderer<>("groupname"));
    ddc.setNullValid(false);
    ddc.setRequired(true);

    hippoForm.add(ddc);
    add(hippoForm);

    // local memberships
    final Label localLabel = new Label("local-memberships-label", new ResourceModel("user-local-memberships"));
    final MembershipsListEditView localList = new MembershipsListEditView("local-memberships", user,
            localMembershipContainer);
    hippoForm.add(localLabel);
    localMembershipContainer.add(localList);

    // external memberships
    final Label externalLabel = new Label("external-memberships-label",
            new ResourceModel("user-external-memberships"));
    final ListView externalList = new MembershipsListView("external-memberships", "label", user);
    externalLabel.setVisible(!user.getExternalMemberships().isEmpty());
    externalList.setVisible(!user.getExternalMemberships().isEmpty());
    hippoForm.add(externalLabel);
    externalMembershipsContainer.add(externalList);

    // add a cancel/back button
    hippoForm.add(new AjaxButton("back-button") {
        @Override
        protected void onSubmit(final AjaxRequestTarget target, final Form form) {
            // one up
            final List<IBreadCrumbParticipant> all = breadCrumbModel.allBreadCrumbParticipants();
            breadCrumbModel.setActive(all.get(all.size() - 2));
        }
    }.setDefaultFormProcessing(false));
}

From source file:org.jaulp.wicket.dialogs.examples.HomePage.java

License:Apache License

/**
 * Constructor that is invoked when page is invoked without a session.
 *
 * @param parameters/* w w  w.  j  a  va 2 s .  com*/
 *            Page parameters
 */
public HomePage(final PageParameters parameters) {

    final WebMarkupContainer wmc = new WebMarkupContainer("comments");
    wmc.setOutputMarkupId(true);

    final List<MessageBean> noteList = new ArrayList<MessageBean>();
    final MessageBean messageBean = new MessageBean();
    messageBean.setMessageContent("hello");
    final ModalWindow modalWindow = new BaseModalWindow<MessageBean>("baseModalWindow", "Title", 350, 160,
            new CompoundPropertyModel<MessageBean>(messageBean)) {
        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void onCancel(final AjaxRequestTarget target) {
            target.add(wmc);
            close(target);
        }

        @Override
        public void onSelect(final AjaxRequestTarget target, final MessageBean object) {
            MessageBean clone = (MessageBean) WicketObjects.cloneObject(object);
            noteList.add(clone);
            // Clear the content from textarea in the dialog.
            object.setMessageContent("");
            target.add(wmc);
            close(target);
        }

    };
    modalWindow.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    modalWindow.setResizable(false);
    add(modalWindow);

    final AjaxLink<String> linkToModalWindow = new AjaxLink<String>("linkToModalWindow") {
        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            modalWindow.show(target);
        }
    };
    // Add the WebMarkupContainer...
    add(wmc);

    final Label linkToModalWindowLabel = new Label("linkToModalWindowLabel", "show modal dialog");
    linkToModalWindow.add(linkToModalWindowLabel);
    // The AjaxLink to open the modal window
    add(linkToModalWindow);
    // here we must set the message content from the bean in a repeater...
    final ListView<MessageBean> repliesAndNotesListView = new ListView<MessageBean>("repliesAndNotesListView",
            noteList) {
        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<MessageBean> item) {
            final MessageBean repliesandnotes = item.getModelObject();
            item.add(new RepliesandnotesPanel("repliesandnotesPanel", repliesandnotes));

        }
    };
    repliesAndNotesListView.setVisible(true);
    wmc.add(repliesAndNotesListView);

    @SuppressWarnings("rawtypes")
    Link showUploadPage = new Link("showUploadPage") {

        /**
         *
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            setResponsePage(new UploadPage(getPageParameters()));
        }

    };
    add(showUploadPage);

    add(new ModalDialogWithStylePanel("modalDialogWithStylePanel"));

}

From source file:org.modelibra.wicket.concept.EntityDisplayListListView.java

License:Apache License

/**
 * Populates a list view line./*  w w w.  j  a  v a2  s  .c o  m*/
 * 
 * @param item
 *            list item (line)
 */
protected void populateItem(ListItem item) {
    IEntity<?> entity = (IEntity<?>) item.getModelObject();

    DomainApp app = (DomainApp) getApplication();

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

    ViewModel entityModel = new ViewModel();
    entityModel.copyPropertiesFrom(viewModel);
    entityModel.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.getDestinationConceptConfig();
            if (parentConceptConfig != null) {
                if (conceptCode.equals(neighborConfig.getConceptConfig().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.getParentNeighbor(neighborConfig.getCode());
                        if (parentEntity != null) {
                            String parentPropertyName = LocalizedText.getPropertyName(this, parentEntity,
                                    parentConceptPropertyConfig);
                            Label parentPropertyNameLabel = new Label("propertyName", parentPropertyName);
                            PropertyNameLabelValuePanelPair propertyNameLabelValuePanelPair = new PropertyNameLabelValuePanelPair();
                            propertyNameLabelValuePanelPair.setPropertyNameLabel(parentPropertyNameLabel);

                            ViewModel parentModel = new ViewModel();
                            parentModel.copyPropertiesFrom(viewModel);
                            parentModel.setEntity(parentEntity);
                            parentModel.setPropertyConfig(parentConceptPropertyConfig);

                            View parentView = new View();
                            parentView.copyPropertiesFrom(view);
                            parentView.setWicketId("valuePanel");
                            Panel parentPropertyPanel;
                            if (parentConceptPropertyConfig.getPropertyClass().equals(PropertyClass.getUrl())
                                    || parentConceptPropertyConfig.getPropertyClass()
                                            .equals(PropertyClass.getEmail())) {
                                parentPropertyPanel = new ExternalLinkPanel(parentModel, parentView);
                            } else if (parentConceptPropertyConfig.getPropertyClass()
                                    .equals(PropertyClass.getString())
                                    && parentConceptPropertyConfig.isValidateType()
                                    && (parentConceptPropertyConfig.getValidationType()
                                            .equals(ValidationType.getUrl())
                                            || parentConceptPropertyConfig.getValidationType()
                                                    .equals(ValidationType.getEmail()))) {
                                parentPropertyPanel = new ExternalLinkPanel(parentModel, parentView);
                            } else if (parentConceptPropertyConfig.getPropertyClass()
                                    .equals(PropertyClass.getBoolean())) {
                                parentPropertyPanel = new CheckBoxPanel(parentModel, parentView);

                            } else {
                                parentPropertyPanel = new LabelPanel(parentModel, parentView);
                            } // if
                            if (!app.getAccessPoint().isNeighborDisplayAllowed(getAppSession(),
                                    neighborConfig)) {
                                parentPropertyPanel.setVisible(false);
                            } else if (!app.getAccessPoint().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()) {
        if (propertyConfig.isEssential()) {
            String propertyName = LocalizedText.getPropertyName(this, entity, propertyConfig);
            Label propertyNameLabel = new Label("propertyName", propertyName);
            PropertyNameLabelValuePanelPair propertyNameLabelValuePanelPair = new PropertyNameLabelValuePanelPair();
            propertyNameLabelValuePanelPair.setPropertyNameLabel(propertyNameLabel);

            entityModel.setPropertyConfig(propertyConfig);
            View propertiesView = new View();
            propertiesView.copyPropertiesFrom(view);
            propertiesView.setWicketId("valuePanel");
            Panel propertyValuePanel;
            if (propertyConfig.getPropertyClass().equals(PropertyClass.getUrl())
                    || propertyConfig.getPropertyClass().equals(PropertyClass.getEmail())) {
                propertyValuePanel = new ExternalLinkPanel(entityModel, propertiesView);
            } else if (propertyConfig.getPropertyClass().equals(PropertyClass.getString())
                    && propertyConfig.isValidateType()
                    && (propertyConfig.getValidationType().equals(ValidationType.getUrl())
                            || propertyConfig.getValidationType().equals(ValidationType.getEmail()))) {
                propertyValuePanel = new ExternalLinkPanel(entityModel, propertiesView);
            } else if (propertyConfig.getPropertyClass().equals(PropertyClass.getBoolean())) {
                propertyValuePanel = new CheckBoxPanel(entityModel, propertiesView);

            } else {
                propertyValuePanel = new LabelPanel(entityModel, propertiesView);
            }
            if (!app.getAccessPoint().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.getAccessPoint().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();
            DomainModel model = (DomainModel) viewModel.getModel();
            IEntities<?> childEntities = model.getModelMeta().getChildNeighbor(entity, childCode);
            ViewModel childEntitiesModel = new ViewModel();
            childEntitiesModel.copyPropertiesFrom(viewModel);
            childEntitiesModel.setEntities(childEntities);
            View entityDisplayListPanelView = new View();
            entityDisplayListPanelView.copyPropertiesFrom(view);
            entityDisplayListPanelView.setWicketId("entityDisplayListPanel");
            Panel entityDisplayListPanel = app.getViewMeta(modelCode).getPanel("EntityDisplayListPanel",
                    childEntitiesModel, entityDisplayListPanelView);
            childList.add(entityDisplayListPanel);
            if (!app.getAccessPoint().isNeighborDisplayAllowed(getAppSession(), neighborConfig)) {
                entityDisplayListPanel.setVisible(false);
            }
        } // if (neighborConfig.getType().equals("child")) {
    } // for

    item.add(new PanelListView("childEntityListPanelListView", childList));
}

From source file:org.modelibra.wicket.concept.EntityDisplayListPanel.java

License:Apache License

/**
 * Constructs an entity display list panel.
 * //ww  w  .  java  2s. co m
 * @param viewModel
 *            view model
 * @param view
 *            view
 */
public EntityDisplayListPanel(final ViewModel viewModel, final View view) {
    super(view.getWicketId());
    DomainApp app = (DomainApp) getApplication();
    String modelCode = viewModel.getModel().getModelConfig().getCode();

    IEntities entities = viewModel.getEntities();

    ConceptConfig conceptConfig = entities.getConceptConfig();
    String conceptsName = LocalizedText.getConceptsName(this, entities);
    add(new Label("conceptsName", conceptsName));

    ViewModel entityDisplayListModel = new ViewModel();
    entityDisplayListModel.copyPropertiesFrom(viewModel);

    View entityDisplayListView = new View();
    entityDisplayListView.copyPropertiesFrom(view);
    entityDisplayListView.setWicketId("entityDisplayListListView");

    ListView entityDisplayListListView = app.getViewMeta(modelCode).getListView("EntityDisplayListListView",
            entityDisplayListModel, entityDisplayListView);
    add(entityDisplayListListView);
    if (!app.getAccessPoint().isConceptDisplayAllowed(getAppSession(), conceptConfig)) {
        entityDisplayListListView.setVisible(false);
    }
}

From source file:org.modelibra.wicket.concept.EntityDisplayMinPanel.java

License:Apache License

/**
 * Constructs an entity display min panel.
 * /*ww  w  .  j av a  2 s . c  om*/
 * @param viewModel
 *            view model
 * @param view
 *            view
 */
public EntityDisplayMinPanel(final ViewModel viewModel, final View view) {
    super(view.getWicketId());
    DomainApp app = (DomainApp) getApplication();
    IEntity<?> entity = viewModel.getEntity();
    ConceptConfig conceptConfig = entity.getConceptConfig();

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

    ViewModel propertyModel = new ViewModel();
    propertyModel.copyPropertiesFrom(viewModel);
    propertyModel.setEntity(entity);

    PropertiesConfig propertiesConfig = conceptConfig.getPropertiesConfig();
    for (PropertyConfig propertyConfig : propertiesConfig) {
        if (propertyConfig.isEssential()) {
            String propertyName = LocalizedText.getPropertyName(this, entity, propertyConfig);
            PropertyNameLabelValuePanelPair propertyNameLabelValuePanelPair = new PropertyNameLabelValuePanelPair();
            Label propertyNameLabel = new Label("propertyName", propertyName);
            propertyNameLabelValuePanelPair.setPropertyNameLabel(propertyNameLabel);

            propertyModel.setPropertyConfig(propertyConfig);
            View propertyValueView = new View();
            propertyValueView.copyPropertiesFrom(view);
            propertyValueView.setWicketId("valuePanel");
            Panel essentialPropertyPanel;
            if (propertyConfig.getPropertyClass().equals(PropertyClass.getUrl())
                    || propertyConfig.getPropertyClass().equals(PropertyClass.getEmail())) {
                essentialPropertyPanel = new ExternalLinkPanel(propertyModel, propertyValueView);
            } else if (propertyConfig.getPropertyClass().equals(PropertyClass.getString())
                    && propertyConfig.isValidateType()
                    && (propertyConfig.getValidationType().equals(ValidationType.getUrl())
                            || propertyConfig.getValidationType().equals(ValidationType.getEmail()))) {
                essentialPropertyPanel = new ExternalLinkPanel(propertyModel, propertyValueView);
            } else if (propertyConfig.getPropertyClass().equals(PropertyClass.getBoolean())) {
                essentialPropertyPanel = new CheckBoxPanel(propertyModel, propertyValueView);
            } else if (propertyConfig.getPropertyClass().equals(PropertyClass.getString())
                    && propertyConfig.getDisplayLengthInt() > DomainApp.MIN_LONG_TEXT_LENGTH) {
                essentialPropertyPanel = new MultiLineLabelPanel(propertyModel, propertyValueView);
            } else {
                essentialPropertyPanel = new LabelPanel(propertyModel, propertyValueView);
            }
            if (!app.getAccessPoint().isPropertyDisplayAllowed(getAppSession(), propertyConfig)) {
                essentialPropertyPanel.setVisible(false);
            }

            propertyNameLabelValuePanelPair.setPropertyValuePanel(essentialPropertyPanel);
            propertyNameLabelValuePanelPairs.add(propertyNameLabelValuePanelPair);
        } // if (propertyConfig.isEssential()) {
    } // end for

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

From source file:org.modelibra.wicket.concept.EntityDisplayPanel.java

License:Apache License

/**
 * Constructs an entity display panel.//from w  w  w .  j av a2s  .com
 * 
 * @param viewModel
 *            view model
 * @param view
 *            view
 */
public EntityDisplayPanel(final ViewModel viewModel, final View view) {
    super(view.getWicketId());
    DomainApp app = (DomainApp) getApplication();

    IEntity<?> entity = viewModel.getEntity();

    ConceptConfig conceptConfig = entity.getConceptConfig();
    String conceptName = LocalizedText.getConceptName(this, entity);
    add(new Label("conceptName", conceptName));

    ViewModel entityModel = new ViewModel();
    entityModel.copyPropertiesFrom(viewModel);

    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.getDestinationConceptConfig();
            if (parentConceptConfig != null) {
                PropertiesConfig parentConceptPropertiesConfig = parentConceptConfig.getPropertiesConfig();
                for (IEntity<?> parentPropertyConfigEntity : parentConceptPropertiesConfig) {
                    PropertyConfig parentConceptPropertyConfig = (PropertyConfig) parentPropertyConfigEntity;
                    if (parentConceptPropertyConfig.isEssential()) {
                        IEntity<?> parentEntity = entity.getParentNeighbor(neighborConfig.getCode());
                        if (parentEntity != null) {
                            String parentPropertyName = LocalizedText.getPropertyName(this, parentEntity,
                                    parentConceptPropertyConfig);
                            Label parentPropertyNameLabel = new Label("propertyName", parentPropertyName);
                            PropertyNameLabelValuePanelPair propertyNameLabelValuePanelPair = new PropertyNameLabelValuePanelPair();
                            propertyNameLabelValuePanelPair.setPropertyNameLabel(parentPropertyNameLabel);

                            ViewModel parentViewModel = new ViewModel();
                            parentViewModel.copyPropertiesFrom(viewModel);
                            parentViewModel.setEntity(parentEntity);
                            parentViewModel.setPropertyConfig(parentConceptPropertyConfig);

                            View parentView = new View();
                            parentView.copyPropertiesFrom(view);
                            parentView.setWicketId("valuePanel");

                            Panel parentPropertyPanel;
                            if (parentConceptPropertyConfig.getPropertyClass().equals(PropertyClass.getUrl())
                                    || parentConceptPropertyConfig.getPropertyClass()
                                            .equals(PropertyClass.getEmail())) {
                                parentPropertyPanel = new ExternalLinkPanel(parentViewModel, parentView);
                            } else if (parentConceptPropertyConfig.getPropertyClass()
                                    .equals(PropertyClass.getString())
                                    && parentConceptPropertyConfig.isValidateType()
                                    && (parentConceptPropertyConfig.getValidationType()
                                            .equals(ValidationType.getUrl())
                                            || parentConceptPropertyConfig.getValidationType()
                                                    .equals(ValidationType.getEmail()))) {
                                parentPropertyPanel = new ExternalLinkPanel(parentViewModel, parentView);
                            } else if (parentConceptPropertyConfig.getPropertyClass()
                                    .equals(PropertyClass.getBoolean())) {
                                parentPropertyPanel = new CheckBoxPanel(parentViewModel, parentView);
                            } else {
                                parentPropertyPanel = new LabelPanel(parentViewModel, parentView);
                            }
                            if (!app.getAccessPoint().isNeighborDisplayAllowed(getAppSession(),
                                    neighborConfig)) {
                                parentPropertyNameLabel.setVisible(false);
                                parentPropertyPanel.setVisible(false);
                            } else if (!app.getAccessPoint().isPropertyDisplayAllowed(getAppSession(),
                                    parentConceptPropertyConfig)) {
                                parentPropertyNameLabel.setVisible(false);
                                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 propertyName = LocalizedText.getPropertyName(this, entity, propertyConfig);
            Label propertyNameLabel = new Label("propertyName", propertyName);
            PropertyNameLabelValuePanelPair propertyNameLabelValuePanelPair = new PropertyNameLabelValuePanelPair();
            propertyNameLabelValuePanelPair.setPropertyNameLabel(propertyNameLabel);
            entityModel.setPropertyConfig(propertyConfig);
            View propertiesView = new View();
            propertiesView.copyPropertiesFrom(view);
            propertiesView.setWicketId("valuePanel");
            Panel propertyValuePanel;
            if (propertyConfig.getPropertyClass().equals(PropertyClass.getUrl())
                    || propertyConfig.getPropertyClass().equals(PropertyClass.getEmail())) {
                propertyValuePanel = new ExternalLinkPanel(entityModel, propertiesView);
            } else if (propertyConfig.getPropertyClass().equals(PropertyClass.getString())
                    && propertyConfig.isValidateType()
                    && (propertyConfig.getValidationType().equals(ValidationType.getUrl())
                            || propertyConfig.getValidationType().equals(ValidationType.getEmail()))) {

                propertyValuePanel = new ExternalLinkPanel(entityModel, propertiesView);

            } else if (propertyConfig.getPropertyClass().equals(PropertyClass.getBoolean())) {
                propertyValuePanel = new CheckBoxPanel(entityModel, propertiesView);

            } else if (propertyConfig.getPropertyClass().equals(PropertyClass.getString())
                    && propertyConfig.getDisplayLengthInt() > DomainApp.MIN_LONG_TEXT_LENGTH) {
                propertyValuePanel = new MultiLineLabelPanel(entityModel, propertiesView);

            } else {
                propertyValuePanel = new LabelPanel(entityModel, propertiesView);
            } // end if
            if (!app.getAccessPoint().isPropertyDisplayAllowed(getAppSession(), propertyConfig)) {
                propertyNameLabel.setVisible(false);
                propertyValuePanel.setVisible(false);
            }

            propertyNameLabelValuePanelPair.setPropertyValuePanel(propertyValuePanel);
            propertyNameLabelValuePanelPairs.add(propertyNameLabelValuePanelPair);
        } // end if (!propertyConfig.isReference()) {
    } // end for

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

From source file:org.modelibra.wicket.concept.EntityPropertiesDisplayTableListView.java

License:Apache License

/**
 * Populates a list view line./* w ww  .java 2s  .com*/
 * 
 * @param item
 *            list item (line)
 */
protected void populateItem(ListItem item) {
    IEntity entity = (IEntity) item.getModelObject();

    final DomainApp app = (DomainApp) getApplication();

    ConceptConfig conceptConfig = entity.getConceptConfig();

    final ViewModel entityModel = new ViewModel();
    entityModel.copyPropertiesFrom(viewModel);
    entityModel.setEntity(entity);

    ViewModel parentViewModel = new ViewModel();
    parentViewModel.copyPropertiesFrom(viewModel);
    View parentView = new View();
    parentView.copyPropertiesFrom(viewContext);

    List<Panel> propertyValuePanels = new ArrayList<Panel>();

    // 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.getDestinationConceptConfig();
            if (parentConceptConfig != null) {
                PropertiesConfig parentConceptPropertiesConfig = parentConceptConfig.getPropertiesConfig();
                for (IEntity parentPropertyConfigEntity : parentConceptPropertiesConfig) {
                    PropertyConfig parentConceptPropertyConfig = (PropertyConfig) parentPropertyConfigEntity;
                    if (parentConceptPropertyConfig.isEssential()) {
                        IEntity parentEntity = entity.getParentNeighbor(neighborConfig.getCode());
                        Panel parentPropertyPanel;
                        if (parentEntity != null) {
                            parentViewModel.setEntity(parentEntity);
                            parentViewModel.setPropertyConfig(parentConceptPropertyConfig);
                            parentView.setWicketId("valuePanel");
                            parentView.getUserProperties().addUserProperty("shortText", Boolean.TRUE);
                            if (parentConceptPropertyConfig.getPropertyClass().equals(PropertyClass.getUrl())
                                    || parentConceptPropertyConfig.getPropertyClass()
                                            .equals(PropertyClass.getEmail())) {
                                parentPropertyPanel = new ExternalLinkPanel(parentViewModel, parentView);
                            } else if (parentConceptPropertyConfig.getPropertyClass()
                                    .equals(PropertyClass.getString())
                                    && parentConceptPropertyConfig.isValidateType()
                                    && (parentConceptPropertyConfig.getValidationType()
                                            .equals(ValidationType.getUrl())
                                            || parentConceptPropertyConfig.getValidationType()
                                                    .equals(ValidationType.getEmail()))) {
                                parentPropertyPanel = new ExternalLinkPanel(parentViewModel, parentView);
                            } else if (parentConceptPropertyConfig.getPropertyClass()
                                    .equals(PropertyClass.getBoolean())) {
                                parentPropertyPanel = new CheckBoxPanel(parentViewModel, parentView);

                            } else {
                                parentPropertyPanel = new LabelPanel(parentViewModel, parentView);
                            } // if
                            if (!app.getAccessPoint().isNeighborDisplayAllowed(getAppSession(),
                                    neighborConfig)) {
                                parentPropertyPanel.setVisible(false);
                            } else if (!app.getAccessPoint().isPropertyDisplayAllowed(getAppSession(),
                                    parentConceptPropertyConfig)) {
                                parentPropertyPanel.setVisible(false);
                            }
                        } else {
                            parentPropertyPanel = new Panel("valuePanel");
                            parentPropertyPanel.setVisible(false);
                        }
                        propertyValuePanels.add(parentPropertyPanel);
                    } // if
                } // for
            } // if
        } // if
    } // for

    PropertiesConfig propertiesConfig = conceptConfig.getPropertiesConfig();
    for (IEntity propertyConfigEntity : propertiesConfig) {
        PropertyConfig propertyConfig = (PropertyConfig) propertyConfigEntity;
        if (propertyConfig.isEssential()) {
            entityModel.setPropertyConfig(propertyConfig);
            View propertiesView = new View();
            propertiesView.copyPropertiesFrom(viewContext);
            propertiesView.setWicketId("valuePanel");
            propertiesView.getUserProperties().addUserProperty("shortText", Boolean.TRUE);
            Panel essentialPropertyPanel;
            if (propertyConfig.getPropertyClass().equals(PropertyClass.getUrl())
                    || propertyConfig.getPropertyClass().equals(PropertyClass.getEmail())) {
                essentialPropertyPanel = new ExternalLinkPanel(entityModel, propertiesView);
            } else if (propertyConfig.getPropertyClass().equals(PropertyClass.getString())
                    && propertyConfig.isValidateType()
                    && (propertyConfig.getValidationType().equals(ValidationType.getUrl())
                            || propertyConfig.getValidationType().equals(ValidationType.getEmail()))) {
                essentialPropertyPanel = new ExternalLinkPanel(entityModel, propertiesView);
            } else if (propertyConfig.getPropertyClass().equals(PropertyClass.getBoolean())) {
                essentialPropertyPanel = new CheckBoxPanel(entityModel, propertiesView);

            } else {
                essentialPropertyPanel = new LabelPanel(entityModel, propertiesView);
            } // end if
            if (!app.getAccessPoint().isPropertyDisplayAllowed(getAppSession(), propertyConfig)) {
                essentialPropertyPanel.setVisible(false);
            }

            propertyValuePanels.add(essentialPropertyPanel);
        } // end if (propertyConfig.isEssential()) {
    } // for

    ListView propertyValuePanelListView = new PropertyValuePanelListView("propertyValuePanelListView",
            propertyValuePanels);
    item.add(propertyValuePanelListView);
    if (!app.getAccessPoint().isConceptDisplayAllowed(getAppSession(), conceptConfig)) {
        propertyValuePanelListView.setVisible(false);
    }

    final View entityDisplayPageView = new View();
    entityDisplayPageView.copyPropertiesFrom(viewContext);
    entityDisplayPageView.setUpdate(false);
    Link displayLink = new PageLink("display", new IPageLink() {
        static final long serialVersionUID = 200531L;

        public Page getPage() {
            return app.getViewMeta(modelCode).getPage("EntityDisplayPage", entityModel, entityDisplayPageView);
        }

        public Class getPageIdentity() {
            return app.getViewMeta(modelCode).getPageClass("EntityDisplayPage", entityModel,
                    entityDisplayPageView);
        }
    });
    item.add(displayLink);
}

From source file:org.modelibra.wicket.concept.EntityPropertyDisplayListPanel.java

License:Apache License

public EntityPropertyDisplayListPanel(final ViewModel viewModel, final View view) {
    super(viewModel, view);
    DomainApp app = (DomainApp) getApplication();
    String modelCode = viewModel.getModel().getModelConfig().getCode();

    ConceptConfig conceptConfig = viewModel.getEntities().getConceptConfig();

    String sectionTitle = LocalizedText.getApplicationPropertiesText(this, view.getTitle());
    Label sectionTitleLabel = new Label("sectionTitle", sectionTitle);
    add(sectionTitleLabel);//from w w w .  jav  a 2s  .  c  o m

    String entityPropertyTitle = LocalizedText.getPropertyName(this, viewModel.getEntities(),
            viewModel.getPropertyConfig());
    Label entityPropertyTitleLabel = new Label("entityPropertyTitle", entityPropertyTitle);
    add(entityPropertyTitleLabel);

    ViewModel entityPropertyModel = new ViewModel();
    entityPropertyModel.copyPropertiesFrom(viewModel);
    View entityPropertyView = new View();
    entityPropertyView.copyPropertiesFrom(view);
    entityPropertyView.setWicketId("entityPropertyList");

    ListView entityPropertyDisplayListView = app.getViewMeta(modelCode)
            .getListView("EntityPropertyDisplayListListView", entityPropertyModel, entityPropertyView);
    add(entityPropertyDisplayListView);
    if (!app.getAccessPoint().isConceptDisplayAllowed(getAppSession(), conceptConfig)) {
        entityPropertyDisplayListView.setVisible(false);
    }
}

From source file:org.modelibra.wicket.concept.EntityUpdateForm.java

License:Apache License

/**
 * Constructs an entity update form.//w  w w .j a  va  2 s.co  m
 * 
 * @param viewModel
 *            view model
 * @param view
 *            view
 */
public EntityUpdateForm(final ViewModel viewModel, final View view) {
    super(viewModel, view);
    DomainApp app = (DomainApp) getApplication();
    final String modelCode = viewModel.getModel().getModelConfig().getCode();

    final IEntity entity = viewModel.getEntity();
    ConceptConfig conceptConfig = entity.getConceptConfig();
    String conceptCode = conceptConfig.getCode();

    Label titleLabel;
    String titleKey = view.getTitle();
    if (titleKey != null) {
        String title = LocalizedText.getApplicationPropertiesText(this, titleKey);
        titleLabel = new Label("formTitle", title);
    } else {
        String conceptName = LocalizedText.getConceptName(this, entity);
        titleLabel = new Label("formTitle", conceptName);
    }
    add(titleLabel);

    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.getDestinationConceptConfig();
            if (parentConceptConfig != null) {
                PropertiesConfig parentConceptPropertiesConfig = parentConceptConfig.getPropertiesConfig();
                for (IEntity propertyConfigEntity : parentConceptPropertiesConfig) {
                    PropertyConfig parentConceptPropertyConfig = (PropertyConfig) propertyConfigEntity;
                    if (parentConceptPropertyConfig.isEssential()) {
                        IEntity parentEntity = entity.getParentNeighbor(neighborConfig.getCode());
                        if (parentEntity != null) {
                            String parentPropertyName = LocalizedText.getPropertyName(this, parentEntity,
                                    parentConceptPropertyConfig);
                            Label parentPropertyNameLabel = new Label("propertyName", parentPropertyName);
                            PropertyNameLabelValuePanelPair propertyNameLabelValuePanelPair = new PropertyNameLabelValuePanelPair();
                            propertyNameLabelValuePanelPair.setPropertyNameLabel(parentPropertyNameLabel);

                            ViewModel parentModel = new ViewModel();
                            parentModel.copyPropertiesFrom(viewModel);
                            parentModel.setEntity(parentEntity);
                            parentModel.setUpdateEntity(parentEntity);
                            parentModel.setPropertyConfig(parentConceptPropertyConfig);

                            View parentView = new View();
                            parentView.copyPropertiesFrom(view);
                            parentView.setWicketId("valuePanel");

                            Panel parentPropertyPanel;
                            if (parentConceptPropertyConfig.getPropertyClass().equals(PropertyClass.getUrl())
                                    || parentConceptPropertyConfig.getPropertyClass()
                                            .equals(PropertyClass.getEmail())) {
                                parentPropertyPanel = new ExternalLinkPanel(parentModel, parentView);
                            } else if (parentConceptPropertyConfig.getPropertyClass()
                                    .equals(PropertyClass.getString())
                                    && parentConceptPropertyConfig.isValidateType()
                                    && (parentConceptPropertyConfig.getValidationType()
                                            .equals(ValidationType.getUrl())
                                            || parentConceptPropertyConfig.getValidationType()
                                                    .equals(ValidationType.getEmail()))) {
                                parentPropertyPanel = new ExternalLinkPanel(parentModel, parentView);
                            } else if (parentConceptPropertyConfig.getPropertyClass()
                                    .equals(PropertyClass.getBoolean())) {
                                parentPropertyPanel = new CheckBoxPanel(parentModel, parentView);
                                // disable check box in CheckBoxPanel to
                                // prevent editing parent entity
                                ((CheckBoxPanel) parentPropertyPanel).getCheckBox().setEnabled(false);
                            } else {
                                parentPropertyPanel = new LabelPanel(parentModel, parentView);
                            }
                            if (!app.getAccessPoint().isNeighborDisplayAllowed(getAppSession(),
                                    neighborConfig)) {
                                parentPropertyNameLabel.setVisible(false);
                                parentPropertyPanel.setVisible(false);
                            } else if (!app.getAccessPoint().isPropertyDisplayAllowed(getAppSession(),
                                    parentConceptPropertyConfig)) {
                                parentPropertyNameLabel.setVisible(false);
                                parentPropertyPanel.setVisible(false);
                            }

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

    PropertiesConfig propertiesConfig = conceptConfig.getPropertiesConfig();
    for (PropertyConfig config : propertiesConfig) {
        PropertyConfig propertyConfig = (PropertyConfig) config;
        String propertyCode = propertyConfig.getCode();
        String propertyName = LocalizedText.getPropertyName(this, conceptConfig, propertyConfig);
        PropertyNameLabelValuePanelPair propertyNameLabelValuePanelPair = new PropertyNameLabelValuePanelPair();
        Label propertyNameLabel = new Label("propertyName", propertyName);
        propertyNameLabelValuePanelPair.setPropertyNameLabel(propertyNameLabel);
        ViewModel entityModel = new ViewModel();
        entityModel.copyPropertiesFrom(viewModel);
        entityModel.setPropertyConfig(propertyConfig);
        Panel propertyValuePanel;
        if (propertyConfig.isDerived()) {
            View derivedPanelView = new View();
            derivedPanelView.copyPropertiesFrom(view);
            derivedPanelView.setWicketId("valuePanel");
            propertyValuePanel = new LabelPanel(entityModel, derivedPanelView);
        } else if (propertyConfig.getPropertyClass().equals(PropertyClass.getBoolean())) {
            View checkBoxPanelView = new View();
            checkBoxPanelView.copyPropertiesFrom(view);
            checkBoxPanelView.setWicketId("valuePanel");
            propertyValuePanel = new CheckBoxPanel(entityModel, checkBoxPanelView);
        } else if (propertyConfig.getPropertyClass().equals(PropertyClass.getString())
                && propertyConfig.getDisplayLengthInt() > DomainApp.MIN_LONG_TEXT_LENGTH) {
            View textAreaPanelView = new View();
            textAreaPanelView.copyPropertiesFrom(view);
            textAreaPanelView.setWicketId("valuePanel");
            propertyValuePanel = new TextAreaPanel(entityModel, textAreaPanelView);
        } else if (propertyConfig.isReference()) {
            String neighborCode = propertyConfig.getReferenceNeighbor();
            NeighborConfig neighborConfig = conceptConfig.getNeighborsConfig().getNeighborConfig(neighborCode);
            String neighborConceptCode = neighborConfig.getDestinationConcept();
            IDomainModel model = viewModel.getModel();
            IEntities<?> lookupEntities = model.getEntry(neighborConceptCode);
            if (lookupEntities == null) {
                ConceptConfig neighborConceptConfig = model.getModelConfig()
                        .getConceptConfig(neighborConceptCode);
                String lookupEntitiesCode = neighborConceptConfig.getEntitiesCode();
                String getLookupEntitiesMethod = "get" + lookupEntitiesCode;
                lookupEntities = (IEntities<?>) Reflector.executeMethod(model, getLookupEntitiesMethod);
            }
            if (lookupEntities != null) {
                ViewModel neighborModel = new ViewModel();
                neighborModel.copyPropertiesFrom(viewModel);
                neighborModel.setPropertyConfig(propertyConfig);
                neighborModel.setLookupEntities(lookupEntities);
                View lookupView = new View();
                lookupView.copyPropertiesFrom(view);
                lookupView.setWicketId("valuePanel");
                if (propertyConfig.isReferenceDropDownLookup()) {
                    propertyValuePanel = new LookupDropDownChoicePanel(neighborModel, lookupView);
                } else {
                    if (neighborConfig.getMinInt() == 0) {
                        propertyValuePanel = new LookupEmptyPanel(neighborModel, lookupView);

                    } else {
                        propertyValuePanel = new LookupPanel(neighborModel, lookupView);
                    }
                }
            } else {
                log.info(modelCode + "." + conceptCode + "." + propertyCode
                        + " reference property does not have the lookup entities.");
                View textFieldPanelView = new View();
                textFieldPanelView.copyPropertiesFrom(view);
                textFieldPanelView.setWicketId("valuePanel");
                propertyValuePanel = new TextFieldPanel(entityModel, textFieldPanelView);
            }
        } else if (propertyConfig.isValidateType()) {
            if (propertyConfig.isValidateClassType()) {
                View textFieldPanelView = new View();
                textFieldPanelView.copyPropertiesFrom(view);
                textFieldPanelView.setWicketId("valuePanel");
                propertyValuePanel = new TextFieldPanel(entityModel, textFieldPanelView);
            } else {
                View dropDownChoicePanelView = new View();
                dropDownChoicePanelView.copyPropertiesFrom(view);
                dropDownChoicePanelView.setWicketId("valuePanel");
                propertyValuePanel = new TypeValueDropDownChoicePanel(entityModel, dropDownChoicePanelView);
            }
        } else {
            View textFieldPanelView = new View();
            textFieldPanelView.copyPropertiesFrom(view);
            textFieldPanelView.setWicketId("valuePanel");
            propertyValuePanel = new TextFieldPanel(entityModel, textFieldPanelView);
        } // end if
        if (!app.getAccessPoint().isPropertyDisplayAllowed(getAppSession(), propertyConfig)) {
            propertyNameLabel.setVisible(false);
            propertyValuePanel.setVisible(false);
        } else if (!app.getAccessPoint().isPropertyUpdateAllowed(getAppSession(), propertyConfig)) {
            View labelPanelView = new View();
            labelPanelView.copyPropertiesFrom(view);
            labelPanelView.setWicketId("valuePanel");
            propertyValuePanel = new LabelPanel(entityModel, labelPanelView);
        }

        propertyNameLabelValuePanelPair.setPropertyValuePanel(propertyValuePanel);
        propertyNameLabelValuePanelPairs.add(propertyNameLabelValuePanelPair);
    } // end for

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

    add(new Button("cancel") {
        static final long serialVersionUID = 200721L;

        public void onSubmit() {
            onCancel(viewModel, view);
        }
    }.setDefaultFormProcessing(false));
}