You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
991 B
38 lines
991 B
package com.jotuntech.sketcher.server.command;
|
|
|
|
import java.nio.ByteBuffer;
|
|
import java.util.Deque;
|
|
|
|
import com.jotuntech.sketcher.common.UndoEntry;
|
|
import com.jotuntech.sketcher.common.User;
|
|
import com.jotuntech.sketcher.server.Command;
|
|
import com.jotuntech.sketcher.server.Connection;
|
|
import com.jotuntech.sketcher.server.Server;
|
|
|
|
public class UndoCommand implements Command {
|
|
|
|
public int perform(Server server, Connection connection) {
|
|
User user = connection.getUser();
|
|
if(user == null) {
|
|
return Connection.SEND_NONE;
|
|
}
|
|
if(user.isViewer()) {
|
|
return Connection.SEND_NONE;
|
|
}
|
|
Deque<UndoEntry> undoDeque = connection.getUser().getUndoDeque();
|
|
if(undoDeque.size() == 0) {
|
|
return Connection.SEND_NONE;
|
|
}
|
|
UndoEntry undoEntry = undoDeque.removeFirst();
|
|
undoEntry.getLayer().undo(undoEntry.getUndoData());
|
|
return Connection.SEND_OTHERS;
|
|
}
|
|
|
|
public void decode(ByteBuffer in) {
|
|
|
|
}
|
|
|
|
public void encode(ByteBuffer out) {
|
|
|
|
}
|
|
}
|
|
|