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.plugin.DefaultPluginManager.WikiPluginInfo;
028import org.apache.wiki.util.XHTML;
029import org.apache.wiki.util.XhtmlUtil;
030import org.jdom2.Element;
031
032
033public class PluginBean extends ModuleBean {
034
035    public PluginBean( WikiEngine engine ) throws NotCompliantMBeanException {
036        super( engine );
037    }
038
039    /**
040     * {@inheritDoc}
041     */
042    public String getTitle() {
043        return "Plugins";
044    }
045
046    /**
047     * {@inheritDoc}
048     */
049    public int getType() {
050        return CORE;
051    }
052
053    /**
054     * {@inheritDoc}
055     */
056    @Override
057    protected Collection< WikiModuleInfo > modules() {
058        return m_engine.getPluginManager().modules();
059    }
060
061    /**
062     * {@inheritDoc}
063     */
064    @Override
065    protected Element heading() {
066        Element trHead = XhtmlUtil.element( XHTML.tr );
067        trHead.addContent( XhtmlUtil.element( XHTML.th ).addContent( "Name" ) )
068              .addContent( XhtmlUtil.element( XHTML.th ).addContent( "Alias" ) )
069              .addContent( XhtmlUtil.element( XHTML.th ).addContent( "Author" ) )
070              .addContent( XhtmlUtil.element( XHTML.th ).addContent( "Notes" ) );
071        return trHead;
072    }
073
074    /**
075     * {@inheritDoc}
076     */
077    @Override
078    protected Element rowBody( WikiModuleInfo plugin ) {
079        Element tr = XhtmlUtil.element( XHTML.tr );
080        tr.addContent( XhtmlUtil.element( XHTML.td ).addContent( plugin.getName() ) )
081          .addContent( XhtmlUtil.element( XHTML.td ).addContent( ( ( WikiPluginInfo )plugin).getAlias() ) )
082          .addContent( XhtmlUtil.element( XHTML.td ).addContent( plugin.getAuthor() ) )
083          .addContent( XhtmlUtil.element( XHTML.td ).addContent( validModuleVersion( plugin ) ) );
084        return tr;
085    }
086
087}