Example usage for org.apache.wicket.markup.html WebMarkupContainer getId

List of usage examples for org.apache.wicket.markup.html WebMarkupContainer getId

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html WebMarkupContainer getId.

Prototype

@Override
public String getId() 

Source Link

Document

Gets the id of this component.

Usage

From source file:com.genericconf.bbbgateway.web.pages.HomePage.java

License:Apache License

public HomePage(final PageParameters parameters) {
    IModel<? extends List<? extends Meeting>> model = new LoadableDetachableModel<List<? extends Meeting>>() {
        private static final long serialVersionUID = 1L;

        @Override/*from ww  w .  jav  a 2 s.com*/
        protected List<? extends Meeting> load() {
            return new ArrayList<Meeting>(meetingService.getMeetings());
        }
    };

    final WebMarkupContainer joinContainer = new WebMarkupContainer("joinContainer");
    joinContainer.setOutputMarkupPlaceholderTag(true).setVisible(false);
    add(joinContainer);

    final WebMarkupContainer placeholder = new WebMarkupContainer("tablePlaceholder");
    placeholder.add(new AbstractAjaxTimerBehavior(
            Duration.seconds(TimerSettings.INSTANCE.getSecondsBetweenHomePagePolls())) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onTimer(AjaxRequestTarget target) {
            target.addComponent(placeholder);
            target.appendJavascript("initializeTableStuff();");
        }

    });
    final PropertyListView<Meeting> meetingList = new PropertyListView<Meeting>("meetings", model) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<Meeting> item) {
            item.add(new Label("name"));
            item.add(new DateTimeLabel("startTime"));
            item.add(new Label("attendeesInMeeting"));
            item.add(new Label("attendeesWaiting"));
            item.add(new AjaxLink<Void>("join") {
                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    JoinMeetingFormPanel panel = new JoinMeetingFormPanel(joinContainer.getId(),
                            item.getModel());
                    joinContainer.replaceWith(panel);
                    target.addComponent(panel);

                    panel.add(new SimpleAttributeModifier("style", "display: none;"));
                    panel.onAjaxRequest(target);

                    StringBuffer js = new StringBuffer().append("$('#").append(panel.getMarkupId())
                            .append("').dialog({ modal: true, title: 'Join Meeting' });");
                    target.appendJavascript(js.toString());
                }
            });
        }

    };
    meetingList.setOutputMarkupId(true);
    add(placeholder.setOutputMarkupId(true));
    placeholder.add(meetingList);
}

From source file:com.genericconf.bbbgateway.web.pages.WaitingRoom.java

License:Apache License

public WaitingRoom(PageParameters params) {
    final String meetingID = params.getString("0");
    final String attName = params.getString("1");
    if (StringUtils.isEmpty(meetingID) || StringUtils.isEmpty(attName)) {
        throw new RestartResponseAtInterceptPageException(getApplication().getHomePage());
    }//w w  w .  ja v a  2 s .c  o  m
    meeting = new LoadableDetachableModel<Meeting>() {
        private static final long serialVersionUID = 1L;

        @Override
        protected Meeting load() {
            return meetingService.findByMeetingID(meetingID);
        }
    };
    attendee = new LoadableDetachableModel<Attendee>() {
        private static final long serialVersionUID = 1L;

        @Override
        protected Attendee load() {
            return meeting.getObject().getAttendeeByName(attName);
        }
    };

    add(new Label("name", new PropertyModel<String>(meeting, "name")));
    add(new Label("meetingID", new PropertyModel<String>(meeting, "meetingID")));

    add(new Label("attName", new PropertyModel<String>(attendee, "name")));
    add(new Label("attRole", new PropertyModel<String>(attendee, "role")));

    final AttendeeAndWaitingListPanel attendeeList = new AttendeeAndWaitingListPanel("attendeeList", meeting);
    add(attendeeList);

    final DateTimeLabel checked = new DateTimeLabel("checkedTime", new AlwaysReturnCurrentDateModel());
    add(checked.setOutputMarkupId(true));

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

    add(new AbstractAjaxTimerBehavior(
            Duration.seconds(TimerSettings.INSTANCE.getSecondsBeforeFirstWaitingRoomPagePoll())) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onTimer(AjaxRequestTarget target) {
            target.addComponent(checked);
            setUpdateInterval(Duration.seconds(TimerSettings.INSTANCE.getSecondsBetweenWaitingRoomPagePolls()));
            attendeeList.onAjaxRequest(target);
            final Attendee att = attendee.getObject();
            att.pinged();
            if (att.isAllowedToJoin()) {
                stop();

                final JoinMeetingLinkPanel panel = new JoinMeetingLinkPanel(joinDialog.getId(), meeting,
                        attendee);
                joinDialog.replaceWith(panel);
                target.addComponent(panel);

                StringBuffer js = new StringBuffer().append("$('#").append(panel.getMarkupId())
                        .append("').dialog({ modal: true, title: 'Join Meeting' });");
                target.appendJavascript(js.toString());
            }
        }
    });
}

From source file:com.kenai.wicketgae.web.page.MainPage.java

License:Apache License

public void updateEditPersonPanel(final WebMarkupContainer newPanel, final AjaxRequestTarget target) {
    Preconditions.checkArgument(EDIT_PANEL_ID.equals(newPanel.getId()),
            "edit panel must have wicket id MainPage.EDIT_PANEL_ID");

    editPersonPanelContainer.addOrReplace(newPanel);
    target.addComponent(editPersonPanelContainer);
}

From source file:com.servoy.j2db.server.headlessclient.MainPage.java

License:Open Source License

public void add(final IComponent c, final String name) {
    // a new main form is added clear everything
    webForms.clear();// ww  w .j a  v a2  s  .co  m
    FormController currentNavigator = navigator;
    WebMarkupContainer container = (WebMarkupContainer) c;
    if (!"webform".equals(container.getId())) //$NON-NLS-1$
    {
        throw new RuntimeException("only webforms with the name webform can be added to this mainpage"); //$NON-NLS-1$
    }

    if (main != null) {
        addStateChange(new Change() {
            private static final long serialVersionUID = 1L;

            final String formName = main.getController().getName();

            @Override
            public void undo() {
                ((FormManager) client.getFormManager()).setCurrentContainer(MainPage.this,
                        MainPage.this.getPageMap().getName());
                ((FormManager) client.getFormManager()).showFormInMainPanel(formName, MainPage.this, null, true,
                        MainPage.this.getPageMap().getName());
            }
        });
        if (main.getMainPage() != this)
            main.setMainPage(null);
    }
    listview.removeAll();

    ((WebForm) container).setMainPage(this);
    main = (WebForm) container;
    webForms.add(main);
    navigator = currentNavigator;
    if (navigator != null) {
        webForms.add(navigator.getFormUI());
    }

    /*
     * if (navigator != null) { calculateFormAndNavigatorSizes(); }
     */
}

From source file:jp.javelindev.wicket.repeat.RepeatingPanel.java

License:Apache License

private void construct() {
    add(new ListView<String>("repeatingList", getModel()) {
        private static final long serialVersionUID = 1L;

        @Override//from  ww w. j a va2s.c  o m
        protected void populateItem(final ListItem<String> item) {
            item.add(new Label("content", item.getModelObject().toString()));
        }
    });

    final WebMarkupContainer next = new WebMarkupContainer("next");
    next.setOutputMarkupId(true);
    next.setOutputMarkupPlaceholderTag(true);
    next.setVisible(false);
    add(next);

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

    AjaxLink<Void> button = new AjaxLink<Void>("repeatingButton") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            LOGGER.info("clicked");
            Panel panel = new RepeatingPanel(next.getId(), Model.ofList(Arrays.asList("1", "2", "3")));
            next.replaceWith(panel);
            container.setVisible(false);
            target.add(container, panel);
        }
    };
    container.add(button);
}

From source file:org.apache.isis.viewer.wicket.ui.components.entity.fieldset.PropertyGroup.java

License:Apache License

private void buildGui() {

    final List<PropertyLayoutData> properties = fieldSet.getProperties();

    // changed to NO_CHECK because more complex BS3 layouts trip concurrency exception (haven't investigated as to why).
    final ObjectAdapter adapter = getModel().load(AdapterManager.ConcurrencyChecking.NO_CHECK);

    final WebMarkupContainer div = new WebMarkupContainer(ID_MEMBER_GROUP);

    String groupName = fieldSet.getName();

    div.add(new Label(ID_MEMBER_GROUP_NAME, groupName));

    final List<LinkAndLabel> memberGroupActions = Lists.newArrayList();

    final RepeatingView propertyRv = new RepeatingView(ID_PROPERTIES);
    div.add(propertyRv);//from  w  ww.j  a  va  2s  .  c o  m

    final ImmutableList<ObjectAssociation> visibleAssociations = FluentIterable.from(properties)
            .filter(new Predicate<PropertyLayoutData>() {
                @Override
                public boolean apply(final PropertyLayoutData propertyLayoutData) {
                    return propertyLayoutData.getMetadataError() == null;
                }
            }).transform(new Function<PropertyLayoutData, ObjectAssociation>() {
                @Override
                public ObjectAssociation apply(final PropertyLayoutData propertyLayoutData) {
                    return adapter.getSpecification().getAssociation(propertyLayoutData.getId());
                }
            }).filter(new Predicate<ObjectAssociation>() {
                @Override
                public boolean apply(@Nullable final ObjectAssociation objectAssociation) {
                    final Consent visibility = objectAssociation.isVisible(adapter, InteractionInitiatedBy.USER,
                            Where.OBJECT_FORMS);
                    return visibility.isAllowed();
                }
            }).toList();

    for (final ObjectAssociation association : visibleAssociations) {
        final WebMarkupContainer propertyRvContainer = new WebMarkupContainer(propertyRv.newChildId());
        propertyRv.add(propertyRvContainer);
        addPropertyToForm(getModel(), (OneToOneAssociation) association, propertyRvContainer,
                memberGroupActions);
        visible = true;
    }

    final List<LinkAndLabel> actionsPanel = LinkAndLabel.positioned(memberGroupActions,
            ActionLayout.Position.PANEL);
    final List<LinkAndLabel> actionsPanelDropDown = LinkAndLabel.positioned(memberGroupActions,
            ActionLayout.Position.PANEL_DROPDOWN);

    AdditionalLinksPanel.addAdditionalLinks(div, ID_ASSOCIATED_ACTION_LINKS_PANEL, actionsPanel,
            AdditionalLinksPanel.Style.INLINE_LIST);
    AdditionalLinksPanel.addAdditionalLinks(div, ID_ASSOCIATED_ACTION_LINKS_PANEL_DROPDOWN,
            actionsPanelDropDown, AdditionalLinksPanel.Style.DROPDOWN);

    // either add the built content, or hide entire
    if (!visible) {
        Components.permanentlyHide(this, div.getId());
    } else {
        this.add(div);
    }
}

From source file:org.apache.isis.viewer.wicket.ui.components.layout.bs3.col.Col.java

License:Apache License

private void buildGui() {

    setRenderBodyOnly(true);//from ww w.j  a  v  a  2  s .c o m

    if (bs3Col.getSpan() == 0) {
        Components.permanentlyHide(this, ID_COL);
        return;
    }

    final WebMarkupContainer div = new WebMarkupContainer(ID_COL);

    CssClassAppender.appendCssClassTo(div, bs3Col.toCssClass());
    Util.appendCssClass(div, bs3Col, ID_COL);

    // icon/title
    final DomainObjectLayoutData domainObject = bs3Col.getDomainObject();

    final WebMarkupContainer actionOwner;
    final String actionIdToUse;
    final String actionIdToHide;
    if (domainObject != null) {
        final WebMarkupContainer entityHeaderPanel = new WebMarkupContainer(ID_ENTITY_HEADER_PANEL);
        div.add(entityHeaderPanel);
        final ComponentFactory componentFactory = getComponentFactoryRegistry()
                .findComponentFactory(ComponentType.ENTITY_ICON_TITLE_AND_COPYLINK, getModel());
        final Component component = componentFactory.createComponent(getModel());
        entityHeaderPanel.addOrReplace(component);

        actionOwner = entityHeaderPanel;
        actionIdToUse = "entityActions";
        actionIdToHide = "actions";

        visible = true;
    } else {
        Components.permanentlyHide(div, ID_ENTITY_HEADER_PANEL);
        actionOwner = div;
        actionIdToUse = "actions";
        actionIdToHide = null;
    }

    // actions
    // (rendering depends on whether also showing the icon/title)
    final List<ActionLayoutData> actionLayoutDatas = bs3Col.getActions();
    final List<ObjectAction> visibleActions = FluentIterable.from(actionLayoutDatas)
            .filter(new Predicate<ActionLayoutData>() {
                @Override
                public boolean apply(final ActionLayoutData actionLayoutData) {
                    return actionLayoutData.getMetadataError() == null;
                }
            }).transform(new Function<ActionLayoutData, ObjectAction>() {
                @Nullable
                @Override
                public ObjectAction apply(@Nullable final ActionLayoutData actionLayoutData) {
                    return getModel().getTypeOfSpecification().getObjectAction(actionLayoutData.getId());
                }
            }).filter(Predicates.<ObjectAction>notNull()).filter(new Predicate<ObjectAction>() {
                @Override
                public boolean apply(@Nullable final ObjectAction objectAction) {
                    final Consent visibility = objectAction.isVisible(getModel().getObject(),
                            InteractionInitiatedBy.USER, Where.OBJECT_FORMS);
                    return visibility.isAllowed();
                }
            }).toList();
    final List<LinkAndLabel> entityActionLinks = EntityActionUtil
            .asLinkAndLabelsForAdditionalLinksPanel(getModel(), visibleActions);

    if (!entityActionLinks.isEmpty()) {
        AdditionalLinksPanel.addAdditionalLinks(actionOwner, actionIdToUse, entityActionLinks,
                AdditionalLinksPanel.Style.INLINE_LIST);
        visible = true;
    } else {
        Components.permanentlyHide(actionOwner, actionIdToUse);
    }
    if (actionIdToHide != null) {
        Components.permanentlyHide(div, actionIdToHide);
    }

    // rows
    final List<BS3Row> rows = Lists.newArrayList(this.bs3Col.getRows());
    if (!rows.isEmpty()) {
        final RepeatingViewWithDynamicallyVisibleContent rowsRv = buildRows(ID_ROWS, rows);
        div.add(rowsRv);
        visible = visible || rowsRv.isVisible();
    } else {
        Components.permanentlyHide(div, ID_ROWS);
    }

    // tab groups
    final List<BS3TabGroup> tabGroupsWithNonEmptyTabs = FluentIterable.from(bs3Col.getTabGroups())
            .filter(new Predicate<BS3TabGroup>() {
                @Override
                public boolean apply(@Nullable final BS3TabGroup bs3TabGroup) {
                    final List<BS3Tab> bs3TabsWithRows = FluentIterable.from(bs3TabGroup.getTabs())
                            .filter(BS3Tab.Predicates.notEmpty()).toList();
                    return !bs3TabsWithRows.isEmpty();
                }
            }).toList();
    if (!tabGroupsWithNonEmptyTabs.isEmpty()) {
        final RepeatingViewWithDynamicallyVisibleContent tabGroupRv = new RepeatingViewWithDynamicallyVisibleContent(
                ID_TAB_GROUPS);

        for (BS3TabGroup bs3TabGroup : tabGroupsWithNonEmptyTabs) {

            final String id = tabGroupRv.newChildId();
            final List<BS3Tab> tabs = FluentIterable.from(bs3TabGroup.getTabs())
                    .filter(BS3Tab.Predicates.notEmpty()).toList();
            switch (tabs.size()) {
            case 0:
                // shouldn't occur; previously have filtered these out
                throw new IllegalStateException("Cannot render tabGroup with no tabs");
            case 1:
                final BS3Tab bs3Tab = tabs.get(0);
                // render the rows of the one-and-only tab of this tab group.
                final List<BS3Row> tabRows = bs3Tab.getRows();
                final RepeatingViewWithDynamicallyVisibleContent rowsRv = buildRows(id, tabRows);
                tabGroupRv.add(rowsRv);
                break;
            default:
                final EntityModel entityModelWithHints = getModel().cloneWithLayoutMetadata(bs3TabGroup);

                final WebMarkupContainer tabGroup = new TabGroupPanel(id, entityModelWithHints);

                tabGroupRv.add(tabGroup);
                break;
            }

        }
        div.add(tabGroupRv);
        visible = visible || tabGroupRv.isVisible();
    } else {
        Components.permanentlyHide(div, ID_TAB_GROUPS);
    }

    // fieldsets
    final List<FieldSet> fieldSetsWithProperties = FluentIterable.from(bs3Col.getFieldSets())
            .filter(new Predicate<FieldSet>() {
                @Override
                public boolean apply(@Nullable final FieldSet fieldSet) {
                    return !fieldSet.getProperties().isEmpty();
                }
            }).toList();
    if (!fieldSetsWithProperties.isEmpty()) {
        final RepeatingViewWithDynamicallyVisibleContent fieldSetRv = new RepeatingViewWithDynamicallyVisibleContent(
                ID_FIELD_SETS);

        for (FieldSet fieldSet : fieldSetsWithProperties) {

            final String id = fieldSetRv.newChildId();
            final EntityModel entityModelWithHints = getModel().cloneWithLayoutMetadata(fieldSet);

            final PropertyGroup propertyGroup = new PropertyGroup(id, entityModelWithHints);
            fieldSetRv.add(propertyGroup);
        }
        div.add(fieldSetRv);
        visible = visible || fieldSetRv.isVisible();
    } else {
        Components.permanentlyHide(div, ID_FIELD_SETS);
    }

    // collections
    final List<CollectionLayoutData> collections = FluentIterable.from(bs3Col.getCollections())
            .filter(new Predicate<CollectionLayoutData>() {
                @Override
                public boolean apply(final CollectionLayoutData collectionLayoutData) {
                    return collectionLayoutData.getMetadataError() == null;
                }
            }).toList();
    if (!collections.isEmpty()) {
        final RepeatingViewWithDynamicallyVisibleContent collectionRv = new RepeatingViewWithDynamicallyVisibleContent(
                ID_COLLECTIONS);

        for (CollectionLayoutData collection : collections) {

            final String id = collectionRv.newChildId();
            final EntityModel entityModelWithHints = getModel().cloneWithLayoutMetadata(collection);

            final EntityCollectionPanel collectionPanel = new EntityCollectionPanel(id, entityModelWithHints);
            collectionRv.add(collectionPanel);
        }
        div.add(collectionRv);
        visible = visible || collectionRv.isVisible();
    } else {
        Components.permanentlyHide(div, ID_COLLECTIONS);
    }

    final WebMarkupContainer panel = this;
    if (visible) {
        panel.add(div);
    } else {
        Components.permanentlyHide(panel, div.getId());
    }

}

From source file:org.apache.isis.viewer.wicket.ui.components.layout.bs3.tabs.TabPanel.java

License:Apache License

protected void buildGui(final EntityModel model, final BS3Tab bs3Tab,
        final RepeatingViewWithDynamicallyVisibleContent rvIfAny) {

    final WebMarkupContainer div = new WebMarkupContainer(ID_TAB_PANEL);

    final RepeatingViewWithDynamicallyVisibleContent rv = rvIfAny != null ? rvIfAny : newRows(model, bs3Tab);
    div.add(rv);// www.  java 2 s.  co m
    visible = visible || rv.isVisible();

    final WebMarkupContainer panel = this;
    if (visible) {
        Util.appendCssClassIfRequired(panel, bs3Tab);
        panel.add(div);
    } else {
        Components.permanentlyHide(panel, div.getId());
    }

}

From source file:org.apache.syncope.client.console.pages.BasePage.java

License:Apache License

public BasePage(final PageParameters parameters) {
    super(parameters);

    // Native WebSocket
    add(new WebSocketBehavior() {

        private static final long serialVersionUID = 3109256773218160485L;

        @Override//w w  w  . j a  v a  2s .c o  m
        protected void onConnect(final ConnectedMessage message) {
            super.onConnect(message);

            SyncopeConsoleSession.get().scheduleAtFixedRate(new ApprovalsWidget.ApprovalInfoUpdater(message), 0,
                    30, TimeUnit.SECONDS);

            if (BasePage.this instanceof Dashboard) {
                SyncopeConsoleSession.get().scheduleAtFixedRate(new JobWidget.JobInfoUpdater(message), 0, 10,
                        TimeUnit.SECONDS);
                SyncopeConsoleSession.get().scheduleAtFixedRate(
                        new ReconciliationWidget.ReconciliationJobInfoUpdater(message), 0, 10,
                        TimeUnit.SECONDS);
            }
        }

    });

    body = new WebMarkupContainer("body");
    Serializable leftMenuCollapse = SyncopeConsoleSession.get()
            .getAttribute(SyncopeConsoleSession.MENU_COLLAPSE);
    if ((leftMenuCollapse instanceof Boolean) && ((Boolean) leftMenuCollapse)) {
        body.add(new AttributeAppender("class", " sidebar-collapse"));
    }
    add(body);

    notificationPanel = new NotificationPanel(Constants.FEEDBACK);
    body.addOrReplace(notificationPanel.setOutputMarkupId(true));

    // header, footer
    body.add(new Label("version", SyncopeConsoleApplication.get().getVersion()));
    body.add(new Label("username", SyncopeConsoleSession.get().getSelfTO().getUsername()));

    body.add(new ApprovalsWidget("approvalsWidget", getPageReference()).setRenderBodyOnly(true));

    // right sidebar
    SystemInfo systemInfo = SyncopeConsoleSession.get().getSystemInfo();
    body.add(new Label("hostname", systemInfo.getHostname()));
    body.add(new Label("processors", systemInfo.getAvailableProcessors()));
    body.add(new Label("os", systemInfo.getOs()));
    body.add(new Label("jvm", systemInfo.getJvm()));

    Link<Void> dbExportLink = new Link<Void>("dbExportLink") {

        private static final long serialVersionUID = -4331619903296515985L;

        @Override
        public void onClick() {
            try {
                HttpResourceStream stream = new HttpResourceStream(new ConfigurationRestClient().dbExport());

                ResourceStreamRequestHandler rsrh = new ResourceStreamRequestHandler(stream);
                rsrh.setFileName(
                        stream.getFilename() == null ? SyncopeConsoleSession.get().getDomain() + "Content.xml"
                                : stream.getFilename());
                rsrh.setContentDisposition(ContentDisposition.ATTACHMENT);

                getRequestCycle().scheduleRequestHandlerAfterCurrent(rsrh);
            } catch (Exception e) {
                SyncopeConsoleSession.get().error(getString(Constants.ERROR) + ": " + e.getMessage());
            }
        }
    };
    MetaDataRoleAuthorizationStrategy.authorize(dbExportLink, WebPage.ENABLE,
            StandardEntitlement.CONFIGURATION_EXPORT);
    body.add(dbExportLink);

    // menu
    WebMarkupContainer liContainer = new WebMarkupContainer(getLIContainerId("dashboard"));
    body.add(liContainer);
    liContainer.add(BookmarkablePageLinkBuilder.build("dashboard", Dashboard.class));

    liContainer = new WebMarkupContainer(getLIContainerId("realms"));
    body.add(liContainer);
    BookmarkablePageLink<? extends BasePage> link = BookmarkablePageLinkBuilder.build("realms", Realms.class);
    MetaDataRoleAuthorizationStrategy.authorize(link, WebPage.ENABLE, StandardEntitlement.REALM_LIST);
    liContainer.add(link);

    liContainer = new WebMarkupContainer(getLIContainerId("topology"));
    body.add(liContainer);
    link = BookmarkablePageLinkBuilder.build("topology", Topology.class);
    StringBuilder bld = new StringBuilder();
    bld.append(StandardEntitlement.CONNECTOR_LIST).append(",").append(StandardEntitlement.RESOURCE_LIST)
            .append(",");
    MetaDataRoleAuthorizationStrategy.authorize(link, WebPage.ENABLE, bld.toString());
    liContainer.add(link);

    liContainer = new WebMarkupContainer(getLIContainerId("reports"));
    body.add(liContainer);
    link = BookmarkablePageLinkBuilder.build("reports", Reports.class);
    MetaDataRoleAuthorizationStrategy.authorize(link, WebPage.ENABLE, StandardEntitlement.REPORT_LIST);
    liContainer.add(link);

    WebMarkupContainer confLIContainer = new WebMarkupContainer(getLIContainerId("configuration"));
    body.add(confLIContainer);
    WebMarkupContainer confULContainer = new WebMarkupContainer(getULContainerId("configuration"));
    confLIContainer.add(confULContainer);

    liContainer = new WebMarkupContainer(getLIContainerId("workflow"));
    confULContainer.add(liContainer);
    link = BookmarkablePageLinkBuilder.build("workflow", Workflow.class);
    MetaDataRoleAuthorizationStrategy.authorize(link, WebPage.ENABLE, StandardEntitlement.WORKFLOW_DEF_READ);
    liContainer.add(link);

    liContainer = new WebMarkupContainer(getLIContainerId("audit"));
    confULContainer.add(liContainer);
    link = BookmarkablePageLinkBuilder.build("audit", Audit.class);
    MetaDataRoleAuthorizationStrategy.authorize(link, WebPage.ENABLE, StandardEntitlement.AUDIT_LIST);
    liContainer.add(link);

    liContainer = new WebMarkupContainer(getLIContainerId("logs"));
    confULContainer.add(liContainer);
    link = BookmarkablePageLinkBuilder.build("logs", Logs.class);
    MetaDataRoleAuthorizationStrategy.authorize(link, WebPage.ENABLE, StandardEntitlement.LOG_LIST);
    liContainer.add(link);

    liContainer = new WebMarkupContainer(getLIContainerId("securityquestions"));
    confULContainer.add(liContainer);
    bld = new StringBuilder();
    bld.append(StandardEntitlement.SECURITY_QUESTION_CREATE).append(",")
            .append(StandardEntitlement.SECURITY_QUESTION_DELETE).append(",")
            .append(StandardEntitlement.SECURITY_QUESTION_UPDATE);
    link = BookmarkablePageLinkBuilder.build("securityquestions", SecurityQuestions.class);
    MetaDataRoleAuthorizationStrategy.authorize(link, WebPage.ENABLE, bld.toString());
    liContainer.add(link);

    liContainer = new WebMarkupContainer(getLIContainerId("types"));
    confULContainer.add(liContainer);
    link = BookmarkablePageLinkBuilder.build("types", Types.class);
    MetaDataRoleAuthorizationStrategy.authorize(link, WebPage.ENABLE, StandardEntitlement.SCHEMA_LIST);
    liContainer.add(link);

    liContainer = new WebMarkupContainer(getLIContainerId("roles"));
    confULContainer.add(liContainer);
    link = BookmarkablePageLinkBuilder.build("roles", Roles.class);
    MetaDataRoleAuthorizationStrategy.authorize(link, WebPage.ENABLE, StandardEntitlement.ROLE_LIST);
    liContainer.add(link);

    liContainer = new WebMarkupContainer(getLIContainerId("policies"));
    confULContainer.add(liContainer);
    link = BookmarkablePageLinkBuilder.build("policies", Policies.class);
    MetaDataRoleAuthorizationStrategy.authorize(link, WebPage.ENABLE, StandardEntitlement.POLICY_LIST);
    liContainer.add(link);

    liContainer = new WebMarkupContainer(getLIContainerId("notifications"));
    confULContainer.add(liContainer);
    link = BookmarkablePageLinkBuilder.build("notifications", Notifications.class);
    MetaDataRoleAuthorizationStrategy.authorize(link, WebPage.ENABLE, StandardEntitlement.NOTIFICATION_LIST);
    liContainer.add(link);

    liContainer = new WebMarkupContainer(getLIContainerId("parameters"));
    confULContainer.add(liContainer);
    link = BookmarkablePageLinkBuilder.build("parameters", Parameters.class);
    MetaDataRoleAuthorizationStrategy.authorize(link, WebPage.ENABLE, StandardEntitlement.CONFIGURATION_LIST);
    liContainer.add(link);

    body.add(new AjaxLink<Void>("collapse") {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            SyncopeConsoleSession.get().setAttribute(SyncopeConsoleSession.MENU_COLLAPSE,
                    SyncopeConsoleSession.get().getAttribute(SyncopeConsoleSession.MENU_COLLAPSE) == null ? true
                            : !(Boolean) SyncopeConsoleSession.get()
                                    .getAttribute(SyncopeConsoleSession.MENU_COLLAPSE));
        }
    });
    body.add(new Label("domain", SyncopeConsoleSession.get().getDomain()));
    body.add(new BookmarkablePageLink<Page>("logout", Logout.class));

    // set 'active' menu item for everything but extensions
    // 1. check if current class is set to top-level menu
    Component containingLI = body.get(getLIContainerId(getClass().getSimpleName().toLowerCase()));
    // 2. if not, check if it is under 'Configuration'
    if (containingLI == null) {
        containingLI = confULContainer.get(getLIContainerId(getClass().getSimpleName().toLowerCase()));
    }
    // 3. when found, set CSS coordinates for menu
    if (containingLI != null) {
        containingLI.add(new Behavior() {

            private static final long serialVersionUID = 1469628524240283489L;

            @Override
            public void onComponentTag(final Component component, final ComponentTag tag) {
                tag.put("class", "active");
            }
        });

        if (confULContainer.getId().equals(containingLI.getParent().getId())) {
            confULContainer.add(new Behavior() {

                private static final long serialVersionUID = 3109256773218160485L;

                @Override
                public void onComponentTag(final Component component, final ComponentTag tag) {
                    tag.put("class", "treeview-menu menu-open");
                    tag.put("style", "display: block;");
                }

            });

            confLIContainer.add(new Behavior() {

                private static final long serialVersionUID = 3109256773218160485L;

                @Override
                public void onComponentTag(final Component component, final ComponentTag tag) {
                    tag.put("class", "treeview active");
                }
            });
        }
    }

    // Extensions
    ClassPathScanImplementationLookup classPathScanImplementationLookup = (ClassPathScanImplementationLookup) SyncopeConsoleApplication
            .get().getServletContext().getAttribute(ConsoleInitializer.CLASSPATH_LOOKUP);
    List<Class<? extends BaseExtPage>> extPageClasses = classPathScanImplementationLookup.getExtPageClasses();

    WebMarkupContainer extensionsLI = new WebMarkupContainer(getLIContainerId("extensions"));
    extensionsLI.setOutputMarkupPlaceholderTag(true);
    extensionsLI.setVisible(!extPageClasses.isEmpty());
    body.add(extensionsLI);

    ListView<Class<? extends BaseExtPage>> extPages = new ListView<Class<? extends BaseExtPage>>("extPages",
            extPageClasses) {

        private static final long serialVersionUID = 4949588177564901031L;

        @Override
        protected void populateItem(final ListItem<Class<? extends BaseExtPage>> item) {
            WebMarkupContainer containingLI = new WebMarkupContainer("extPageLI");
            item.add(containingLI);
            if (item.getModelObject().equals(BasePage.this.getClass())) {
                containingLI.add(new Behavior() {

                    private static final long serialVersionUID = 1469628524240283489L;

                    @Override
                    public void onComponentTag(final Component component, final ComponentTag tag) {
                        tag.put("class", "active");
                    }
                });
            }

            ExtPage ann = item.getModelObject().getAnnotation(ExtPage.class);

            BookmarkablePageLink<Page> link = new BookmarkablePageLink<>("extPage", item.getModelObject());
            link.add(new Label("extPageLabel", ann.label()));
            MetaDataRoleAuthorizationStrategy.authorize(link, WebPage.ENABLE, ann.listEntitlement());
            containingLI.add(link);

            Label extPageIcon = new Label("extPageIcon");
            extPageIcon.add(new AttributeModifier("class", "fa " + ann.icon()));
            link.add(extPageIcon);
        }
    };
    extPages.setOutputMarkupId(true);
    extensionsLI.add(extPages);

    if (getPage() instanceof BaseExtPage) {
        extPages.add(new Behavior() {

            private static final long serialVersionUID = 1469628524240283489L;

            @Override
            public void onComponentTag(final Component component, final ComponentTag tag) {
                tag.put("class", "treeview-menu menu-open");
                tag.put("style", "display: block;");
            }

        });

        extensionsLI.add(new Behavior() {

            private static final long serialVersionUID = 1469628524240283489L;

            @Override
            public void onComponentTag(final Component component, final ComponentTag tag) {
                tag.put("class", "treeview active");
            }
        });
    }
}

From source file:org.artifactory.webapp.wicket.page.browse.treebrowser.tabs.general.GeneralTabPanel.java

License:Open Source License

public GeneralTabPanel(String id, RepoAwareActionableItem repoItem) {
    super(id);/*from  w  ww . j a  v  a2s  .  c o  m*/
    setOutputMarkupId(true);
    this.repoItem = repoItem;

    add(new GeneralInfoPanel("generalInfoPanel").init(repoItem));

    if (shouldDisplayDistributionManagement()) {
        RepeatingView distributionManagement = new RepeatingView("distributionManagement");
        add(distributionManagement);

        //TODO [mamo]: make it generic, let addon contribute ui sections
        AddonsManager addonsManager = ContextHelper.get().beanForType(AddonsManager.class);
        GemsWebAddon gemsWebAddon = addonsManager.addonByType(GemsWebAddon.class);
        if (!gemsWebAddon.isDefault() && repoItem.getRepo().getType().equals(RepoType.Gems)) {
            distributionManagement.add(gemsWebAddon.buildDistributionManagementPanel(
                    distributionManagement.newChildId(), repoItem.getRepoPath()));
        }

        NpmWebAddon npmWebAddon = addonsManager.addonByType(NpmWebAddon.class);
        if (!npmWebAddon.isDefault() && repoItem.getRepo().getType().equals(RepoType.Npm)) {
            distributionManagement.add(npmWebAddon.buildDistributionManagementPanel(
                    distributionManagement.newChildId(), repoItem.getRepoPath()));
        }

        NuGetWebAddon nuGetWebAddon = addonsManager.addonByType(NuGetWebAddon.class);
        if (!nuGetWebAddon.isDefault() && repoItem.getRepo().getType().equals(RepoType.NuGet)) {
            distributionManagement.add(nuGetWebAddon.buildDistributionManagementPanel(
                    distributionManagement.newChildId(), repoItem.getRepoPath()));
        }

        DebianWebAddon debianWebAddon = addonsManager.addonByType(DebianWebAddon.class);
        if (!debianWebAddon.isDefault() && repoItem.getRepo().getType().equals(RepoType.Debian)) {
            distributionManagement.add(debianWebAddon.buildDistributionManagementPanel(
                    distributionManagement.newChildId(), repoItem.getRepoPath()));
        }

        PypiWebAddon pypiWebAddon = addonsManager.addonByType(PypiWebAddon.class);
        if (!pypiWebAddon.isDefault() && repoItem.getRepo().getType().equals(RepoType.Pypi)) {
            distributionManagement.add(pypiWebAddon.buildDistributionManagementPanel(
                    distributionManagement.newChildId(), repoItem.getRepoPath()));
        }

        GitLfsWebAddon lfsWebAddon = addonsManager.addonByType(GitLfsWebAddon.class);
        if (!lfsWebAddon.isDefault() && RepoType.GitLfs.equals(repoItem.getRepo().getType())) {
            distributionManagement.add(lfsWebAddon.buildDistributionManagementPanel(
                    distributionManagement.newChildId(), repoItem.getRepoPath()));
        }

        if (distributionManagement.size() == 0) {
            distributionManagement
                    .add(new DistributionManagementPanel(distributionManagement.newChildId(), repoItem));
        }
    } else {
        add(new WebMarkupContainer("distributionManagement"));
    }

    add(checksumInfo());

    add(new ActionsPanel("actionsPanel", repoItem));

    WebMarkupContainer markupContainer = new WebMarkupContainer("dependencyDeclarationPanel");
    add(markupContainer);

    org.artifactory.fs.ItemInfo itemInfo = repoItem.getItemInfo();
    if (!itemInfo.isFolder()) {
        ModuleInfo moduleInfo = null;
        if (repoItem.getRepo().isMavenRepoLayout()) {
            MavenArtifactInfo mavenArtifactInfo = MavenArtifactInfo.fromRepoPath(itemInfo.getRepoPath());
            if (mavenArtifactInfo.isValid()) {
                moduleInfo = new ModuleInfoBuilder().organization(mavenArtifactInfo.getGroupId())
                        .module(mavenArtifactInfo.getArtifactId()).baseRevision(mavenArtifactInfo.getVersion())
                        .classifier(mavenArtifactInfo.getClassifier()).ext(mavenArtifactInfo.getType()).build();
            }
        }

        if (moduleInfo == null) {
            moduleInfo = repositoryService.getItemModuleInfo(itemInfo.getRepoPath());
        }

        if (moduleInfo.isValid()) {
            this.replace(new DependencyDeclarationPanel(markupContainer.getId(), moduleInfo,
                    repoItem.getRepo().getRepoLayout()));
        }
    }

    add(new VirtualRepoListPanel("virtualRepoList", repoItem));
    addMessage();
}