001/*
002    Licensed to the Apache Software Foundation (ASF) under one
003    or more contributor license agreements.  See the NOTICE file
004    distributed with this work for additional information
005    regarding copyright ownership.  The ASF licenses this file
006    to you under the Apache License, Version 2.0 (the
007    "License"); you may not use this file except in compliance
008    with the License.  You may obtain a copy of the License at
009
010       http://www.apache.org/licenses/LICENSE-2.0
011
012    Unless required by applicable law or agreed to in writing,
013    software distributed under the License is distributed on an
014    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015    KIND, either express or implied.  See the License for the
016    specific language governing permissions and limitations
017    under the License.
018*/
019package org.apache.wiki.ui.admin.beans;
020
021import java.util.Collection;
022
023import javax.management.NotCompliantMBeanException;
024
025import org.apache.wiki.WikiEngine;
026import org.apache.wiki.modules.WikiModuleInfo;
027import org.apache.wiki.util.XHTML;
028import org.apache.wiki.util.XhtmlUtil;
029import org.jdom2.Element;
030
031
032public class FilterBean extends ModuleBean {
033
034    public FilterBean( WikiEngine engine ) throws NotCompliantMBeanException {
035        super( engine );
036    }
037
038    /**
039     * {@inheritDoc}
040     */
041    public String getTitle() {
042        return "Filters";
043    }
044
045    /**
046     * {@inheritDoc}
047     */
048    public int getType() {
049        return CORE;
050    }
051
052    /**
053     * {@inheritDoc}
054     */
055    @Override
056    protected Collection< WikiModuleInfo > modules() {
057        return m_engine.getFilterManager().modules();
058    }
059
060    /**
061     * {@inheritDoc}
062     */
063    @Override
064    protected Element heading() {
065        Element trHead = XhtmlUtil.element( XHTML.tr );
066        trHead.addContent( XhtmlUtil.element( XHTML.th ).addContent( "Name" ) )
067              .addContent( XhtmlUtil.element( XHTML.th ).addContent( "Author" ) )
068              .addContent( XhtmlUtil.element( XHTML.th ).addContent( "Notes" ) );
069        return trHead;
070    }
071
072    /**
073     * {@inheritDoc}
074     */
075    @Override
076    protected Element rowBody( WikiModuleInfo info ) {
077        Element tr = XhtmlUtil.element( XHTML.tr );
078        tr.addContent( XhtmlUtil.element( XHTML.td ).addContent( info.getName() ) )
079          .addContent( XhtmlUtil.element( XHTML.td ).addContent( info.getAuthor() ) )
080          .addContent( XhtmlUtil.element( XHTML.td ).addContent( validModuleVersion( info ) ) );
081        return tr;
082    }
083
084}