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.
46 lines
1.1 KiB
46 lines
1.1 KiB
package com.jotuntech.sketcher.client.command;
|
|
|
|
import java.nio.ByteBuffer;
|
|
|
|
import com.jotuntech.sketcher.client.Client;
|
|
import com.jotuntech.sketcher.client.Command;
|
|
import com.jotuntech.sketcher.common.BitmapUndoData;
|
|
import com.jotuntech.sketcher.common.Layer;
|
|
import com.jotuntech.sketcher.common.UndoEntry;
|
|
import com.jotuntech.sketcher.common.User;
|
|
import com.jotuntech.sketcher.server.Connection;
|
|
|
|
public class UndoEntryCommand implements Command {
|
|
Integer layerKey;
|
|
|
|
public int perform(Client client, User user) {
|
|
if(user == null) {
|
|
return Connection.SEND_NONE;
|
|
}
|
|
|
|
if(user.isViewer()) {
|
|
return Connection.SEND_NONE;
|
|
}
|
|
|
|
Layer layer = client.getCanvas().getLayerMap().get(layerKey);
|
|
|
|
if(layer == null) {
|
|
return Connection.SEND_NONE;
|
|
}
|
|
|
|
UndoEntry undoEntry = new UndoEntry();
|
|
undoEntry.setLayer(layer);
|
|
undoEntry.setUndoData(new BitmapUndoData());
|
|
user.getUndoDeque().addLast(undoEntry);
|
|
|
|
return Connection.SEND_NONE;
|
|
}
|
|
|
|
public void decode(ByteBuffer in) {
|
|
layerKey = in.getInt();
|
|
}
|
|
|
|
public void encode(ByteBuffer out) {
|
|
out.putInt(layerKey);
|
|
}
|
|
}
|
|
|