Search in sources :

Example 41 with Fragment

use of org.apache.wicket.markup.html.panel.Fragment in project midpoint by Evolveum.

the class PageAssignmentHolderDetails method createTemplatePanel.

private CreateTemplatePanel<AH> createTemplatePanel() {
    return new CreateTemplatePanel<>(ID_TEMPLATE) {

        @Override
        protected Collection<CompiledObjectCollectionView> findAllApplicableArchetypeViews() {
            return PageAssignmentHolderDetails.this.findAllApplicableArchetypeViews();
        }

        @Override
        protected QName getType() {
            return ObjectTypes.getObjectType(PageAssignmentHolderDetails.this.getType()).getTypeQName();
        }

        @Override
        protected void onTemplateChosePerformed(CompiledObjectCollectionView collectionViews, AjaxRequestTarget target) {
            PrismObject<AH> assignmentHolder;
            try {
                assignmentHolder = getPrismContext().createObject(PageAssignmentHolderDetails.this.getType());
            } catch (Throwable e) {
                LOGGER.error("Cannot create prism object for {}. Using object from page model.", PageAssignmentHolderDetails.this.getType());
                assignmentHolder = getObjectDetailsModels().getObjectWrapperModel().getObject().getObjectOld().clone();
            }
            List<ObjectReferenceType> archetypeRef = ObjectCollectionViewUtil.getArchetypeReferencesList(collectionViews);
            if (archetypeRef != null) {
                AssignmentHolderType holder = assignmentHolder.asObjectable();
                archetypeRef.forEach(a -> holder.getAssignment().add(ObjectTypeUtil.createAssignmentTo(a, getPrismContext())));
            }
            reloadObjectDetailsModel(assignmentHolder);
            Fragment fragment = createDetailsFragment();
            fragment.setOutputMarkupId(true);
            PageAssignmentHolderDetails.this.replace(fragment);
            target.add(fragment);
        }
    };
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) CreateTemplatePanel(com.evolveum.midpoint.gui.impl.page.admin.CreateTemplatePanel) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) Fragment(org.apache.wicket.markup.html.panel.Fragment)

Example 42 with Fragment

use of org.apache.wicket.markup.html.panel.Fragment in project midpoint by Evolveum.

the class PageSelfRegistration method submitRegistration.

@Override
protected void submitRegistration(AjaxRequestTarget target) {
    OperationResult result = new OperationResult(OPERATION_SAVE_USER);
    saveUser(result);
    result.computeStatus();
    if (result.getStatus() == OperationResultStatus.SUCCESS) {
        getSession().success(createStringResource("PageSelfRegistration.registration.success").getString());
        String sequenceName = getSelfRegistrationConfiguration().getAdditionalAuthentication();
        if (SecurityUtils.getSequenceByName(sequenceName, getSelfRegistrationConfiguration().getAuthenticationPolicy()) != null) {
            target.add(PageSelfRegistration.this);
        } else {
            switch(getSelfRegistrationConfiguration().getAuthenticationMethod()) {
                case MAIL:
                    target.add(PageSelfRegistration.this);
                    break;
                case SMS:
                    throw new UnsupportedOperationException();
                case NONE:
                    setResponsePage(PageLogin.class);
            }
        }
        LOGGER.trace("Registration for user {} was successfull.", getUserModel().getObject());
    } else {
        String message;
        if (result.getUserFriendlyMessage() != null) {
            message = WebModelServiceUtils.translateMessage(result, this);
        } else {
            message = result.getMessage();
        }
        getSession().error(createStringResource("PageSelfRegistration.registration.error", message).getString());
        // removePassword(target);
        updateCaptcha(target);
        target.add(getFeedbackPanel());
        LOGGER.error("Failed to register user {}. Reason {}", getUserModel().getObject(), result.getMessage());
        return;
    }
    target.add(getFeedbackPanel());
    MultiLineLabel label = new MultiLineLabel(ID_REGISTRATION_SUBMITED, createStringResource("PageSelfRegistration.registration.confirm.message"));
    Fragment messageContent = new Fragment("contentArea", "messageContent", this);
    messageContent.add(label);
    getMainForm().replace(messageContent);
    target.add(this);
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Fragment(org.apache.wicket.markup.html.panel.Fragment) MultiLineLabel(org.apache.wicket.markup.html.basic.MultiLineLabel)

Example 43 with Fragment

use of org.apache.wicket.markup.html.panel.Fragment in project midpoint by Evolveum.

the class PageAbstractFlow method initLayout.

private void initLayout() {
    MidpointForm<?> mainForm = new MidpointForm<>(ID_MAIN_FORM);
    mainForm.setMultiPart(true);
    add(mainForm);
    WebMarkupContainer content;
    Fragment fragment;
    if (!isCustomFormDefined()) {
        fragment = new Fragment(ID_CONTENT_AREA, "staticContent", this);
        content = initStaticLayout();
    } else {
        fragment = new Fragment(ID_CONTENT_AREA, "dynamicContent", this);
        content = initDynamicLayout();
    }
    fragment.setOutputMarkupId(true);
    content.setOutputMarkupId(true);
    initCaptchaAndButtons(fragment);
    fragment.add(content);
    mainForm.add(fragment);
}
Also used : MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) Fragment(org.apache.wicket.markup.html.panel.Fragment) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 44 with Fragment

use of org.apache.wicket.markup.html.panel.Fragment in project midpoint by Evolveum.

the class ActivitiesStatisticsPanel method addActionsExecutedTablePanel.

private void addActionsExecutedTablePanel(String id, String titleId, String modelField) {
    ListDataProvider<ObjectActionsExecutedEntryType> dataProvider = new ListDataProvider<>(this, PropertyModel.of(statisticsModel, modelField));
    BoxedTablePanel<ObjectActionsExecutedEntryType> actionTable = new BoxedTablePanel<>(id, dataProvider, createActionEntryColumns()) {

        @Override
        protected boolean hideFooterIfSinglePage() {
            return true;
        }

        @Override
        protected WebMarkupContainer createHeader(String headerId) {
            return new Fragment(headerId, titleId, ActivitiesStatisticsPanel.this);
        }
    };
    actionTable.setOutputMarkupId(true);
    actionTable.add(new VisibleBehaviour(() -> !dataProvider.getAvailableData().isEmpty() || dataProvider.size() > 0));
    add(actionTable);
}
Also used : ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) Fragment(org.apache.wicket.markup.html.panel.Fragment)

Example 45 with Fragment

use of org.apache.wicket.markup.html.panel.Fragment in project gitblit by gitblit.

the class RepositoryPage method setupPage.

@Override
protected void setupPage(String repositoryName, String pageName) {
    // It may be attempted to be called again if an info or error message is displayed.
    if (get("projectTitle") != null) {
        return;
    }
    String projectName = StringUtils.getFirstPathElement(repositoryName);
    ProjectModel project = app().projects().getProjectModel(projectName);
    if (project.isUserProject()) {
        // user-as-project
        add(new LinkPanel("projectTitle", null, project.getDisplayName(), UserPage.class, WicketUtils.newUsernameParameter(project.name.substring(1))));
    } else {
        // project
        add(new LinkPanel("projectTitle", null, project.name, ProjectPage.class, WicketUtils.newProjectParameter(project.name)));
    }
    String name = StringUtils.stripDotGit(repositoryName);
    if (!StringUtils.isEmpty(projectName) && name.startsWith(projectName)) {
        name = name.substring(projectName.length() + 1);
    }
    add(new LinkPanel("repositoryName", null, name, SummaryPage.class, WicketUtils.newRepositoryParameter(repositoryName)));
    UserModel user = GitBlitWebSession.get().getUser();
    if (user == null) {
        user = UserModel.ANONYMOUS;
    }
    // indicate origin repository
    RepositoryModel model = getRepositoryModel();
    if (StringUtils.isEmpty(model.originRepository)) {
        if (model.isMirror) {
            add(new Fragment("repoIcon", "mirrorIconFragment", this));
            Fragment mirrorFrag = new Fragment("originRepository", "mirrorFragment", this);
            Label lbl = new Label("originRepository", MessageFormat.format(getString("gb.mirrorOf"), "<b>" + model.origin + "</b>"));
            mirrorFrag.add(lbl.setEscapeModelStrings(false));
            add(mirrorFrag);
        } else {
            if (model.isBare) {
                add(new Fragment("repoIcon", "repoIconFragment", this));
            } else {
                add(new Fragment("repoIcon", "cloneIconFragment", this));
            }
            add(new Label("originRepository", Optional.of(model.description).or("")));
        }
    } else {
        RepositoryModel origin = app().repositories().getRepositoryModel(model.originRepository);
        if (origin == null) {
            // no origin repository, show description if available
            if (model.isBare) {
                add(new Fragment("repoIcon", "repoIconFragment", this));
            } else {
                add(new Fragment("repoIcon", "cloneIconFragment", this));
            }
            add(new Label("originRepository", Optional.of(model.description).or("")));
        } else if (!user.canView(origin)) {
            // show origin repository without link
            add(new Fragment("repoIcon", "forkIconFragment", this));
            Fragment forkFrag = new Fragment("originRepository", "originFragment", this);
            forkFrag.add(new Label("originRepository", StringUtils.stripDotGit(model.originRepository)));
            add(forkFrag);
        } else {
            // link to origin repository
            add(new Fragment("repoIcon", "forkIconFragment", this));
            Fragment forkFrag = new Fragment("originRepository", "originFragment", this);
            forkFrag.add(new LinkPanel("originRepository", null, StringUtils.stripDotGit(model.originRepository), SummaryPage.class, WicketUtils.newRepositoryParameter(model.originRepository)));
            add(forkFrag);
        }
    }
    // new ticket button
    if (user.isAuthenticated && app().tickets().isAcceptingNewTickets(getRepositoryModel())) {
        String newTicketUrl = getRequestCycle().urlFor(NewTicketPage.class, WicketUtils.newRepositoryParameter(repositoryName)).toString();
        addToolbarButton("newTicketLink", "fa fa-ticket", getString("gb.new"), newTicketUrl);
    } else {
        add(new Label("newTicketLink").setVisible(false));
    }
    // (un)star link allows a user to star a repository
    if (user.isAuthenticated && model.hasCommits) {
        PageParameters starParams = DeepCopier.copy(getPageParameters());
        starParams.put(PARAM_STAR, !user.getPreferences().isStarredRepository(model.name));
        String toggleStarUrl = getRequestCycle().urlFor(getClass(), starParams).toString();
        if (user.getPreferences().isStarredRepository(model.name)) {
            // show unstar button
            add(new Label("starLink").setVisible(false));
            addToolbarButton("unstarLink", "icon-star-empty", getString("gb.unstar"), toggleStarUrl);
        } else {
            // show star button
            addToolbarButton("starLink", "icon-star", getString("gb.star"), toggleStarUrl);
            add(new Label("unstarLink").setVisible(false));
        }
    } else {
        // anonymous user
        add(new Label("starLink").setVisible(false));
        add(new Label("unstarLink").setVisible(false));
    }
    // fork controls
    if (!allowForkControls() || !user.isAuthenticated) {
        // must be logged-in to fork, hide all fork controls
        add(new ExternalLink("forkLink", "").setVisible(false));
        add(new ExternalLink("myForkLink", "").setVisible(false));
    } else {
        String fork = app().repositories().getFork(user.username, model.name);
        String userRepo = ModelUtils.getPersonalPath(user.username) + "/" + StringUtils.stripDotGit(StringUtils.getLastPathElement(model.name));
        boolean hasUserRepo = app().repositories().hasRepository(userRepo);
        boolean hasFork = fork != null;
        boolean canFork = user.canFork(model) && model.hasCommits && !hasUserRepo;
        if (hasFork || !canFork) {
            // user not allowed to fork or fork already exists or repo forbids forking
            add(new ExternalLink("forkLink", "").setVisible(false));
            if (hasFork && !fork.equals(model.name)) {
                // user has fork, view my fork link
                String url = getRequestCycle().urlFor(SummaryPage.class, WicketUtils.newRepositoryParameter(fork)).toString();
                add(new ExternalLink("myForkLink", url));
            } else {
                // no fork, hide view my fork link
                add(new ExternalLink("myForkLink", "").setVisible(false));
            }
        } else if (canFork) {
            // can fork and we do not have one
            add(new ExternalLink("myForkLink", "").setVisible(false));
            String url = getRequestCycle().urlFor(ForkPage.class, WicketUtils.newRepositoryParameter(model.name)).toString();
            add(new ExternalLink("forkLink", url));
        }
    }
    if (showAdmin || isOwner) {
        String url = getRequestCycle().urlFor(EditRepositoryPage.class, WicketUtils.newRepositoryParameter(model.name)).toString();
        add(new ExternalLink("editLink", url));
    } else {
        add(new Label("editLink").setVisible(false));
    }
    super.setupPage(repositoryName, pageName);
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) RepositoryModel(com.gitblit.models.RepositoryModel) PageParameters(org.apache.wicket.PageParameters) Fragment(org.apache.wicket.markup.html.panel.Fragment) ExternalLink(org.apache.wicket.markup.html.link.ExternalLink) LinkPanel(com.gitblit.wicket.panels.LinkPanel) UserModel(com.gitblit.models.UserModel) ProjectModel(com.gitblit.models.ProjectModel)

Aggregations

Fragment (org.apache.wicket.markup.html.panel.Fragment)51 Label (org.apache.wicket.markup.html.basic.Label)20 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)12 ArrayList (java.util.ArrayList)9 LinkPanel (com.gitblit.wicket.panels.LinkPanel)6 Component (org.apache.wicket.Component)6 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)6 RepositoryModel (com.gitblit.models.RepositoryModel)5 UserModel (com.gitblit.models.UserModel)5 Item (org.apache.wicket.markup.repeater.Item)5 DataView (org.apache.wicket.markup.repeater.data.DataView)5 ListDataProvider (org.apache.wicket.markup.repeater.data.ListDataProvider)5 ResourceModel (org.apache.wicket.model.ResourceModel)4 TicketLabel (com.gitblit.tickets.TicketLabel)3 List (java.util.List)3 ConnInstanceTO (org.apache.syncope.common.lib.to.ConnInstanceTO)3 IndicatingAjaxLink (org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink)3 CompoundPropertyModel (org.apache.wicket.model.CompoundPropertyModel)3 BoxedTablePanel (com.evolveum.midpoint.web.component.data.BoxedTablePanel)2 ListDataProvider (com.evolveum.midpoint.web.component.util.ListDataProvider)2