00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 package com.realtime.crossfire.jxclient.gui.commands;
00022
00023 import com.realtime.crossfire.jxclient.gui.commandlist.GUICommand;
00024 import com.realtime.crossfire.jxclient.gui.gui.Gui;
00025 import com.realtime.crossfire.jxclient.gui.gui.GuiUtils;
00026 import com.realtime.crossfire.jxclient.gui.textinput.CommandCallback;
00027 import com.realtime.crossfire.jxclient.gui.textinput.GUIText;
00028 import java.awt.Component;
00029 import org.jetbrains.annotations.NotNull;
00030
00035 public class AccountCreateCharacterCommand implements GUICommand {
00036
00040 @NotNull
00041 private final CommandCallback commandCallback;
00042
00046 @NotNull
00047 private final Component element;
00048
00055 public AccountCreateCharacterCommand(@NotNull final CommandCallback commandCallback, @NotNull final Component button) {
00056 this.commandCallback = commandCallback;
00057 element = button;
00058 }
00059
00063 @Override
00064 public boolean canExecute() {
00065 return true;
00066 }
00067
00071 @Override
00072 public void execute() {
00073 final Gui gui = GuiUtils.getGui(element);
00074 if (gui == null) {
00075 return;
00076 }
00077
00078 final GUIText loginField = gui.getFirstElement(GUIText.class, "character_login");
00079
00080 if (loginField == null) {
00081 return;
00082 }
00083
00084 final String login = loginField.getText();
00085
00086 commandCallback.accountCreateCharacter(login);
00087 }
00088
00089 }