001/* 002 * JGrapes Event Driven Framework 003 * Copyright (C) 2017-2018 Michael N. Lipp 004 * 005 * This program is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU Affero General Public License as published by 007 * the Free Software Foundation; either version 3 of the License, or 008 * (at your option) any later version. 009 * 010 * This program is distributed in the hope that it will be useful, but 011 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 012 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License 013 * for more details. 014 * 015 * You should have received a copy of the GNU Affero General Public License along 016 * with this program; if not, see <http://www.gnu.org/licenses/>. 017 */ 018 019package org.jgrapes.webconsole.base.events; 020 021import java.io.IOException; 022import java.io.Writer; 023 024/** 025 * Removes a web console component type from the console page. 026 * 027 * Implementations of the front-end are not expected to remove 028 * resources from the page that were added by {@link AddConletType} 029 * because this is hardly possible to implement. 030 * 031 * The only expected action of the front-end is to prevent further 032 * usage of the conlet, typically by removing the conlet type from 033 * e.g. a menu that allows adding conlets. The front-end is also 034 * not expected to remove existing instances of the conlet. If 035 * such a behavior is desired, the required {@link DeleteConlet} 036 * events must be generated on the server side. 037 */ 038public class RemoveConletType extends ConsoleCommand { 039 040 private final String conletType; 041 042 /** 043 * Create a new event for the given web console component type. 044 * 045 * @param conletType a unique id for the web console component type 046 * (usually the class name) 047 */ 048 public RemoveConletType(String conletType) { 049 this.conletType = conletType; 050 } 051 052 /** 053 * Return the web console component type. 054 * 055 * @return the web console component type 056 */ 057 public String conletType() { 058 return conletType; 059 } 060 061 @Override 062 public void toJson(Writer writer) throws IOException { 063 toJson(writer, "removeConletType", conletType()); 064 } 065}