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.gui.commands;
00023
00024 import com.realtime.crossfire.jxclient.gui.button.AbstractButton;
00025 import com.realtime.crossfire.jxclient.gui.commandlist.GUICommand;
00026 import com.realtime.crossfire.jxclient.gui.gui.ActivatableGUIElement;
00027 import org.jetbrains.annotations.NotNull;
00028
00033 public class ScrollNextCommand implements GUICommand {
00034
00038 @NotNull
00039 private final ActivatableGUIElement nextElement;
00040
00044 @NotNull
00045 private final ActivatableGUIElement prevElement;
00046
00050 private final boolean apply;
00051
00058 public ScrollNextCommand(@NotNull final ActivatableGUIElement nextElement, @NotNull final ActivatableGUIElement prevElement, final boolean apply) {
00059 this.nextElement = nextElement;
00060 this.prevElement = prevElement;
00061 this.apply = apply;
00062 }
00063
00067 @Override
00068 public boolean canExecute() {
00069 return true;
00070 }
00071
00075 @Override
00076 public void execute() {
00077 if (prevElement.isActive()) {
00078 if (apply && nextElement instanceof AbstractButton) {
00079 final AbstractButton abstractButton = (AbstractButton)nextElement;
00080 abstractButton.execute();
00081 } else {
00082 nextElement.setActive(true);
00083 }
00084 }
00085 }
00086
00087 }