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 org.apache.wiki.api.core.Engine; 022import org.apache.wiki.filters.FilterManager; 023import org.apache.wiki.modules.WikiModuleInfo; 024import org.apache.wiki.util.XHTML; 025import org.apache.wiki.util.XhtmlUtil; 026import org.jdom2.Element; 027 028import javax.management.NotCompliantMBeanException; 029import java.util.Collection; 030 031 032public class FilterBean extends ModuleBean { 033 034 public FilterBean( final Engine engine ) throws NotCompliantMBeanException { 035 super( engine ); 036 } 037 038 /** 039 * {@inheritDoc} 040 */ 041 @Override 042 public String getTitle() { 043 return "Filters"; 044 } 045 046 /** 047 * {@inheritDoc} 048 */ 049 @Override 050 public int getType() { 051 return CORE; 052 } 053 054 /** 055 * {@inheritDoc} 056 */ 057 @Override 058 protected Collection< WikiModuleInfo > modules() { 059 return m_engine.getManager( FilterManager.class ).modules(); 060 } 061 062 /** 063 * {@inheritDoc} 064 */ 065 @Override 066 protected Element heading() { 067 final Element trHead = XhtmlUtil.element( XHTML.tr ); 068 trHead.addContent( XhtmlUtil.element( XHTML.th ).addContent( "Name" ) ) 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( final WikiModuleInfo info ) { 079 final Element tr = XhtmlUtil.element( XHTML.tr ); 080 tr.addContent( XhtmlUtil.element( XHTML.td ).addContent( info.getName() ) ) 081 .addContent( XhtmlUtil.element( XHTML.td ).addContent( info.getAuthor() ) ) 082 .addContent( XhtmlUtil.element( XHTML.td ).addContent( validModuleVersion( info ) ) ); 083 return tr; 084 } 085 086}