00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 package com.realtime.crossfire.jxclient.commands;
00023
00024 import com.realtime.crossfire.jxclient.gui.label.JXCWindowRenderer;
00025 import com.realtime.crossfire.jxclient.gui.log.Buffer;
00026 import com.realtime.crossfire.jxclient.server.crossfire.CrossfireServerConnection;
00027 import org.jetbrains.annotations.NotNull;
00028
00033 public class ClearCommand extends AbstractCommand {
00034
00038 @NotNull
00039 private final JXCWindowRenderer windowRenderer;
00040
00046 public ClearCommand(@NotNull final JXCWindowRenderer windowRenderer, @NotNull final CrossfireServerConnection crossfireServerConnection) {
00047 super("clear", crossfireServerConnection);
00048 this.windowRenderer = windowRenderer;
00049 }
00050
00054 @Override
00055 public boolean allArguments() {
00056 return false;
00057 }
00058
00062 @Override
00063 public void execute(@NotNull final String args) {
00064 if (args.length() != 0) {
00065 drawInfoError("The clear command does not take arguments.");
00066 return;
00067 }
00068
00069 final Buffer buffer = windowRenderer.getActiveMessageBuffer();
00070 if (buffer == null) {
00071 drawInfoError("No active text window.");
00072 return;
00073 }
00074
00075 buffer.clear();
00076 }
00077
00078 }