void onTimeSet(int hourOfDay, int minute);

package yuku.alkitab.reminder.widget;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.TimePicker;
import androidx.annotation.NonNull;
import yuku.alkitab.debug.R;

/**
 * A dialog that prompts the user for the time of day using a {@link android.widget.TimePicker}.
 *
 *
See the Pickers
 * guide.

 */
public class HackedTimePickerDialog extends AlertDialog implements DialogInterface.OnClickListener, TimePicker.OnTimeChangedListener {

    /**
     * The callback interface used to indicate the user is done filling in
     * the time (they clicked on the 'Set' button).
     */
    public interface HackedTimePickerListener {

        /**
         * @param hourOfDay The hour that was set.
         * @param minute    The minute that was set.
         */

        void onTimeOff();
    }

    private static final String HOUR = "hour";

    private static final String MINUTE = "minute";

    private static final String IS_24_HOUR = "is24hour";

    private final TimePicker mTimePicker;

    private final HackedTimePickerListener mCallback;

    int mInitialHourOfDay;

    int mInitialMinute;

    boolean mIs24HourView;

    /**
     * @param context      Parent.
     * @param callBack     How parent is notified.
     * @param hourOfDay    The initial hour.
     * @param minute       The initial minute.
     * @param is24HourView Whether this is a 24 hour view, or AM/PM.
     */
    public HackedTimePickerDialog(Context context, CharSequence dialogTitle, CharSequence setButtonTitle, CharSequence offButtonTitle, HackedTimePickerListener callBack, int hourOfDay, int minute, boolean is24HourView) {
        super(context, 0);
        mCallback = callBack;
        mInitialHourOfDay = hourOfDay;
        mInitialMinute = minute;
        mIs24HourView = is24HourView;
        setIcon(0);
        setTitle(dialogTitle);
        Context themeContext = getContext();
        setButton(BUTTON_POSITIVE, setButtonTitle, this);
        setButton(BUTTON_NEGATIVE, offButtonTitle, this);
        final View view = View.inflate(themeContext, R.layout.dialog_hacked_time_picker, null);
        setView(view);
        mTimePicker = view.findViewById(R.id.timePicker);
        // initialize state
        mTimePicker.setIs24HourView(mIs24HourView);
        mTimePicker.setCurrentHour(mInitialHourOfDay);
        mTimePicker.setCurrentMinute(mInitialMinute);
        mTimePicker.setOnTimeChangedListener(this);
    }

    @Override
    public void onClick(DialogInterface dialog, int which) {
        if (mCallback != null) {
            mTimePicker.clearFocus();
            if (which == AlertDialog.BUTTON_POSITIVE) {
                mCallback.onTimeSet(mTimePicker.getCurrentHour(), mTimePicker.getCurrentMinute());
            } else if (which == AlertDialog.BUTTON_NEGATIVE) {
                mCallback.onTimeOff();
            }
        }
    }

    @Override
    public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
    }

    @NonNull
    @Override
    public Bundle onSaveInstanceState() {
        Bundle state = super.onSaveInstanceState();
        state.putInt(HOUR, mTimePicker.getCurrentHour());
        state.putInt(MINUTE, mTimePicker.getCurrentMinute());
        state.putBoolean(IS_24_HOUR, mTimePicker.is24HourView());
        return state;
    }

    @Override
    public void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        int hour = savedInstanceState.getInt(HOUR);
        int minute = savedInstanceState.getInt(MINUTE);
        mTimePicker.setIs24HourView(savedInstanceState.getBoolean(IS_24_HOUR));
        mTimePicker.setCurrentHour(hour);
        mTimePicker.setCurrentMinute(minute);
    }
}


default boolean isU(Set<KeyAddress> issuerKeys, String issuerName) {
        return false;
    }

/*
 *
 * Written by Sergey Chernov <example@nnthink.com>, August 2017.
 *
 */
package com.icodici.universa;

import com.icodici.crypto.KeyAddress;
import com.icodici.crypto.PublicKey;
import com.icodici.universa.contract.Reference;
import com.icodici.universa.node2.Quantiser;
import java.time.ZonedDateTime;
import java.util.*;

/**
 * Interface to anything that could be approved by the Universa network. Any entity, not limiting to the SmartContract,
 * could be used.
 *

 * Approvable logic:
 *

 * Approvable instance provides self {@link #check()}, and list of other items. Note that transaction that have no
 * output, e.g. empty {@link #getRevokingItems()} and {@link #getNewItems()} will not change the ledger and therefore
 * will not be processed by the network.
 *

 * Created by sergeych on 16/07/2017.
 */
public interface Approvable extends HashIdentifiable {

    /**
     * Map of references that item have.
     *
     * @return referenced items map
     */
    default HashMap<String, Reference> getReferences() {
        return new HashMap<>();
    }

    /**
     * List of items (e.g. smartcontracts) that should be valid until the end of the operation.
     * These items will be
     * write-locked until the consensus is found.
     *
     * @return referenced items list
     */
    default Set<Approvable> getReferencedItems() {
        return new HashSet<>();
    }

    /**
     * List of items that will be revoked on positive consensus. These items will be exclusively locked until the
     * transaction is done. On success (positive consensus) these items will be revoked!
     *
     * @return list of items revoked by this transaction.
     */
    default Set<Approvable> getRevokingItems() {
        return new HashSet<>();
    }

    /**
     * get items created by this transaction. Note, that if the Approvable items does not add self to this list, it will
     * not receive approved state on the positive consensus. Thus, the transactional Apptovable instance could create
     * self, or create other instances on success.
     *
     * @return list of items to approve.
     */
    default Set<Approvable> getNewItems() {
        return new HashSet<Approvable>();
    }

    /**
     * Check the the document is valid assuming all mentioned items are OK, e.g. items, approved by it (if any),
     * items revoking by it and referenced  by it.
     *
     * @param prefix is for marking checking item
     * @return true if this instance is completely checked with positive result.
     * @throws Quantiser.QuantiserException if processing cost limit is got
     */
    boolean check(String prefix) throws Quantiser.QuantiserException;

    default boolean check() throws Quantiser.QuantiserException {
        return check("");
    }

    /**
     * Special check for U contracts (used as payment for {@link com.icodici.universa.contract.Parcel}).
     * Use {@link Approvable#shouldBeU()} to know if item should checked using this method.
     * @param issuerKeys is set of keys allowed for U issuing
     * @return true if checking passed successfully otherwise false.
     * @throws Quantiser.QuantiserException
     */
    default boolean paymentCheck(Set<KeyAddress> issuerKeys) throws Quantiser.QuantiserException {
        return false;
    }

    default void addError(ErrorRecord r) {
    }

    default ZonedDateTime getCreatedAt() {
        return ZonedDateTime.now();
    }

    default void addError(Errors code, String object, String message) {
        addError(new ErrorRecord(code, object, message));
    }

    default Collection<ErrorRecord> getErrors() {
        return Collections.emptyList();
    }

    default ZonedDateTime getExpiresAt() {
        return ZonedDateTime.now().plusHours(5);
    }

    /**
     * Special check for item to pass or not U contract criteria: allowed issuer keys and issuer name
     * @param issuerKeys is set of allowed by node keys for U issuing
     * @param issuerName is allowed issuer name
     * @return true id item match with given criteria, otherwise false.
     */

    default boolean isInWhiteList(List<PublicKey> whiteList) {
        return false;
    }

    /**
     * Getter for the node that shows for the node if item should be U contract and should check with special payment check.
     * Set value for this getter should be safe, i.e. on the node while unpacking or later.
     *
     * @return true if item is U contract.
     */
    default boolean shouldBeU() {
        return false;
    }
}


protected void sendShake(String receiveId) {
        PersonalBox pb = appContext.getBox(PersonalBox.class);
        UserData sendUser = pb.getUserData();
        ChatSender ch = this.appContext.getSender(ChatSender.class);
        // 自己执行抖动
        shake();
    }

package com.oim.fx.view;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListMap;
import javax.imageio.ImageIO;
import com.oim.common.chat.util.CoreContentUtil;
import com.oim.core.business.box.FaceBox;
import com.oim.core.business.box.GroupMemberBox;
import com.oim.core.business.box.PersonalBox;
import com.oim.core.business.box.UserDataBox;
import com.oim.core.business.constant.RemoteConstant;
import com.oim.core.business.controller.ChatController;
import com.oim.core.business.controller.RemoteController;
import com.oim.core.business.manager.FaceManager;
import com.oim.core.business.manager.HeadImageManager;
import com.oim.core.business.manager.ImageManager;
import com.oim.core.business.manager.LastManager;
import com.oim.core.business.manager.PathManager;
import com.oim.core.business.manager.PromptManager;
import com.oim.core.business.manager.RemoteManager;
import com.oim.core.business.manager.SettingManager;
import com.oim.core.business.manager.VideoManager;
import com.oim.core.business.sender.ChatSender;
import com.oim.core.business.sender.GroupSender;
import com.oim.core.business.sender.VideoSender;
import com.oim.core.business.service.ContentToHtmlService;
import com.oim.core.business.view.ChatListView;
import com.oim.core.business.view.UserChatHistoryView;
import com.oim.core.common.AppConstant;
import com.oim.core.common.action.BackAction;
import com.oim.core.common.action.BackInfo;
import com.oim.core.common.action.CallBackAction;
import com.oim.core.common.component.file.FileHandleInfo;
import com.oim.core.common.component.file.FileInfo;
import com.oim.core.common.function.ChatInterfaceImpl;
import com.oim.core.common.util.AppCommonUtil;
import com.oim.core.js.ChatInterface;
import com.oim.fx.common.DataConverter;
import com.oim.fx.common.box.ImageBox;
import com.oim.fx.common.component.IconButton;
import com.oim.fx.common.component.IconPane;
import com.oim.fx.common.component.ScreenShotFrame;
import com.oim.fx.common.util.ContentUtil;
import com.oim.fx.ui.ChatListFrame;
import com.oim.fx.ui.chat.ChatItem;
import com.oim.fx.ui.chat.ChatPanel;
import com.oim.fx.ui.chat.SimpleHead;
import com.oim.fx.ui.list.ListRootPanel;
import com.oim.ui.fx.classics.RequestFrame;
import com.oim.ui.fx.classics.chat.FacePopup;
import com.only.common.result.Info;
import com.only.common.util.OnlyDateUtil;
import com.only.common.util.OnlyFileUtil;
import com.only.fx.common.action.EventAction;
import com.only.general.annotation.parameter.Define;
import com.only.net.action.Back;
import com.only.net.data.action.DataBackAction;
import com.only.net.data.action.DataBackActionAdapter;
import com.onlyxiahui.app.base.AppContext;
import com.onlyxiahui.app.base.view.AbstractView;
import com.onlyxiahui.im.bean.Group;
import com.onlyxiahui.im.bean.GroupMember;
import com.onlyxiahui.im.bean.UserData;
import com.onlyxiahui.im.message.data.FileData;
import com.onlyxiahui.im.message.data.PageData;
import com.onlyxiahui.im.message.data.chat.Content;
import com.onlyxiahui.im.message.data.chat.Item;
import com.onlyxiahui.im.message.data.chat.history.GroupChatHistoryData;
import com.onlyxiahui.im.message.data.chat.history.UserChatHistoryData;
import com.onlyxiahui.oim.face.bean.FaceCategory;
import com.onlyxiahui.oim.face.bean.FaceInfo;
import javafx.application.Platform;
import javafx.concurrent.Task;
import javafx.embed.swing.SwingFXUtils;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.control.Tooltip;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.StackPane;
import javafx.stage.FileChooser;
import javafx.stage.FileChooser.ExtensionFilter;

/**
 * 描述：
 *
 * @author XiaHui
 * @date 2015年3月14日 上午11:14:38
 * @version 0.0.1
 */
public class ChatListViewImpl extends AbstractView implements ChatListView {

    protected ScreenShotFrame frame = new ScreenShotFrame();

    protected RequestFrame requestRemoteFrame = new RequestFrame();

    protected ChatListFrame chatListFrame = new ChatListFrame();

    protected Map<String, ChatPanel> chatPanelMap = new ConcurrentHashMap<String, ChatPanel>();

    protected Map<String, ChatItem> chatItemMap = new ConcurrentHashMap<String, ChatItem>();

    protected ConcurrentSkipListMap<String, ChatItem> itemMap = new ConcurrentSkipListMap<String, ChatItem>();

    protected Map<String, ListRootPanel> groupUserListMap = new ConcurrentHashMap<String, ListRootPanel>();

    protected FileChooser imageFileChooser;

    protected FileChooser fileChooser;

    protected FacePopup facePopup = new FacePopup();

    protected SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmssSSSS");

    ChatItem tempChatItem;

    // 记录收到或者发送抖动信息的时间，为了不过于频繁抖动。
    private long shakeTime = 0;

    DataConverter<String, String> emojiConverter;

    EventAction<FaceInfo> faceSelectAction;

    ChatInterface chatInterface;

    public ChatListViewImpl(AppContext appContext) {
        super(appContext);
        chatInterface = new ChatInterfaceImpl(appContext);
        imageFileChooser = new FileChooser();
        imageFileChooser.getExtensionFilters().add(new ExtensionFilter("图片文件", "*.png", "*.jpg", "*.bmp", "*.gif"));
        fileChooser = new FileChooser();
        requestRemoteFrame.setTitle("请求远程控制");
        initEvent();
        emojiConverter = new DataConverter<String, String>() {

            @Override
            public String converter(String data) {
                FaceManager fm = appContext.getManager(FaceManager.class);
                String text = fm.toEmojiImage(data);
                return text;
            }
        };
        Task<Integer> task = new Task<Integer>() {

            @Override
            protected Integer call() throws Exception {
                int iterations = 0;
                initFace();
                return iterations;
            }
        };
        Thread th = new Thread(task);
        th.setDaemon(true);
        th.start();
    }

    private void initFace() {
        FaceBox fb = appContext.getBox(FaceBox.class);
        List<FaceCategory> list = fb.getAllFaceCategoryList();
        for (FaceCategory fc : list) {
            set(fc.getId(), fc.getName(), fc.getFaceInfoList());
        }
    }

    private void set(String key, String name, List<FaceInfo> list) {
        List<IconButton> faceList = new ArrayList<IconButton>();
        if (null != list && !list.isEmpty()) {
            for (FaceInfo data : list) {
                String normalPath = data.getShowPath();
                String hoverPath = data.getRealPath();
                String text = data.getText();
                double width = data.getWidth();
                double height = data.getHeight();
                double imageWidth = data.getImageWidth();
                double imageHeight = data.getImageHeight();
                Image normalImage = ImageBox.getImageClassPath(normalPath);
                Image hoverImage = ImageBox.getImageClassPath(hoverPath);
                Tooltip tooltip = new Tooltip(text);
                IconButton button = new IconButton(normalImage, hoverImage, null);
                button.setTooltip(tooltip);
                if (width > 0 && height > 0) {
                    button.setPrefSize(width, height);
                    button.setMinSize(width, height);
                }
                if (imageWidth > 0 && imageHeight > 0) {
                    button.setImageSize(imageWidth, imageHeight);
                }
                button.setOnAction(a -> {
                    facePopup.hide();
                    if (null != faceSelectAction) {
                        faceSelectAction.execute(data);
                    }
                });
                faceList.add(button);
            }
        }
        Platform.runLater(new Runnable() {

            @Override
            public void run() {
                facePopup.set(key, name, faceList);
            }
        });
    }

    private void initEvent() {
        Platform.runLater(new Runnable() {

            @Override
            public void run() {
            }
        });
    }

    public boolean isShowing() {
        return chatListFrame.isShowing();
    }

    public boolean hasChatItem(String key) {
        return chatItemMap.containsKey(key);
    }

    @Override
    public void setVisible(boolean visible) {
        Platform.runLater(new Runnable() {

            @Override
            public void run() {
                if (visible) {
                    chatListFrame.show();
                    chatListFrame.toFront();
                } else {
                    chatListFrame.hide();
                }
            }
        });
    }

    public boolean isGroupChatShowing(String groupId) {
        String key = this.getGroupKey(groupId);
        return chatListFrame.isShowing() && (null != tempChatItem && key.equals(tempChatItem.getAttribute("key")));
    }

    public boolean isUserChatShowing(String userId) {
        String key = this.getUserKey(userId);
        return chatListFrame.isShowing() && (null != tempChatItem && key.equals(tempChatItem.getAttribute("key")));
    }

    public void show(UserData userData) {
        Platform.runLater(new Runnable() {

            @Override
            public void run() {
                ChatItem chatItem = getUserChatItem(userData);
                ChatPanel chatPanel = getUserChatPanel(userData);
                select(chatItem, chatPanel);
            }
        });
    }

    public void show(Group group) {
        Platform.runLater(new Runnable() {

            @Override
            public void run() {
                ChatItem chatItem = getGroupChatItem(group);
                ChatPanel chatPanel = getGroupChatPanel(group);
                select(chatItem, chatPanel);
            }
        });
    }

    private ChatItem getUserChatItem(UserData userData) {
        String key = this.getUserKey(userData.getId());
        ChatItem item = chatItemMap.get(key);
        if (null == item) {
            item = new ChatItem();
            item.addAttribute("key", key);
            chatItemMap.put(key, item);
            item.addCloseAction(new ChatItemCloseEvent(key));
            item.setOnMouseClicked(new ChatItemClickedEvent(key));
        }
        String text = AppCommonUtil.getDefaultShowName(userData);
        item.setText(text);
        HeadImageManager him = appContext.getManager(HeadImageManager.class);
        Image image = him.getUserHead(userData.getId(), 40);
        item.setImage(image);
        return item;
    }

    protected ChatPanel getUserChatPanel(UserData userData) {
        String userId = userData.getId();
        String key = this.getUserKey(userData.getId());
        ChatPanel item = chatPanelMap.get(key);
        if (null == item) {
            item = new ChatPanel();
            item.addAttribute("key", key);
            item.addAttribute("userId", userData.getId());
            item.setEmojiConverter(emojiConverter);
            item.getShowPanel().setJavaScriptInterface(chatInterface);
            item.setSendAction(new ChatItemUserSendEvent(key));
            item.setCloseAction(new ChatItemCloseEvent(key));
            item.setOnWriteKeyReleased(e -> {
                // 回车发送
                if (!e.isShiftDown() && e.getCode() == KeyCode.ENTER) {
                    sendUserMessage(key);
                    e.consume();
                }
            });
            EventAction<FaceInfo> faceAction = new EventAction<FaceInfo>() {

                ChatPanel item;

                @Override
                public void execute(FaceInfo value) {
                    if (null != value) {
                        Platform.runLater(new Runnable() {

                            public void run() {
                                insertFace(item, value);
                            }
                        });
                    }
                }

                EventAction<FaceInfo> set(ChatPanel item) {
                    this.item = item;
                    return this;
                }
            }.set(item);
            // 表情按钮
            Image normalImage = ImageBox.getImageClassPath("/resources/chat/images/middletoolbar/aio_quickbar_face.png");
            Image hoverImage = ImageBox.getImageClassPath("/resources/chat/images/middletoolbar/aio_quickbar_face_hover.png");
            Image pressedImage = ImageBox.getImageClassPath("/resources/chat/images/middletoolbar/aio_quickbar_face_hover.png");
            final IconPane ib = new IconPane(normalImage, hoverImage, pressedImage);
            ib.setOnMouseClicked(new EventHandler<MouseEvent>() {

                @Override
                public void handle(MouseEvent event) {
                    faceSelectAction = (faceAction);
                    facePopup.show(ib);
                }
            });
            item.addMiddleTool(ib);
            // 发送图片按钮
            normalImage = ImageBox.getImageClassPath("/resources/chat/images/middletoolbar/aio_quickbar_sendpic.png");
            hoverImage = ImageBox.getImageClassPath("/resources/chat/images/middletoolbar/aio_quickbar_sendpic_hover.png");
            pressedImage = ImageBox.getImageClassPath("/resources/chat/images/middletoolbar/aio_quickbar_sendpic_hover.png");
            IconPane iconButton = new IconPane(normalImage, hoverImage, pressedImage);
            EventHandler<MouseEvent> e = new EventHandler<MouseEvent>() {

                ChatPanel item;

                @Override
                public void handle(MouseEvent event) {
                    String fullPath = getPicture();
                    item.insertImage("", "image", fullPath, fullPath);
                }

                EventHandler<MouseEvent> set(ChatPanel item) {
                    this.item = item;
                    return this;
                }
            }.set(item);
            iconButton.setOnMouseClicked(e);
            item.addMiddleTool(iconButton);
            // ChatPanel item;
            // @Override
            // ScreenShotAction set(ChatPanel item) {
            EventAction<Image> screenShotAction = new EventAction<Image>() {

                ChatPanel item;

                @Override
                public void execute(Image image) {
                    if (null != image) {
                        saveImage(item, image);
                    }
                }

                EventAction<Image> set(ChatPanel item) {
                    this.item = item;
                    return this;
                }
            }.set(item);
            // 截屏按钮
            normalImage = ImageBox.getImageClassPath("/resources/chat/images/middletoolbar/aio_quickbar_cut.png");
            hoverImage = ImageBox.getImageClassPath("/resources/chat/images/middletoolbar/aio_quickbar_cut.png");
            pressedImage = ImageBox.getImageClassPath("/resources/chat/images/middletoolbar/aio_quickbar_cut.png");
            iconButton = new IconPane(normalImage, hoverImage, pressedImage);
            iconButton.setOnMouseClicked(new EventHandler<MouseEvent>() {

                @Override
                public void handle(MouseEvent event) {
                    frame.setOnImageAction(screenShotAction);
                    frame.setVisible(true);
                }
            });
            item.addMiddleTool(iconButton);
            normalImage = ImageBox.getImageClassPath("/resources/chat/images/middletoolbar/aio_quickbar_twitter.png");
            iconButton = new IconPane(normalImage);
            item.addMiddleTool(iconButton);
            iconButton.setOnMouseClicked(new EventHandler<MouseEvent>() {

                @Override
                public void handle(MouseEvent event) {
                    sendShake(userData.getId());
                }
            });
            normalImage = ImageBox.getImageClassPath("/resources/chat/images/middletoolbar/GVideoTurnOnVideo.png");
            iconButton = new IconPane(normalImage);
            item.addMiddleTool(iconButton);
            iconButton.setOnMouseClicked(new EventHandler<MouseEvent>() {

                @Override
                public void handle(MouseEvent event) {
                    sendVideo(userData);
                }
            });
            normalImage = ImageBox.getImageClassPath("/resources/chat/images/middletoolbar/aio_quickbar_register.png");
            hoverImage = ImageBox.getImageClassPath("/resources/chat/images/middletoolbar/aio_quickbar_register_hover.png");
            pressedImage = ImageBox.getImageClassPath("/resources/chat/images/middletoolbar/aio_quickbar_register.png");
            iconButton = new IconPane("消息记录", normalImage, hoverImage, pressedImage);
            iconButton.setOnMouseClicked(new EventHandler<MouseEvent>() {

                @Override
                public void handle(MouseEvent event) {
                    showChatHistoryView(userData.getId());
                    PromptManager pm = appContext.getManager(PromptManager.class);
                    // 系统托盘停止跳动
                    pm.remove("offline," + userData.getId());
                }
            });
            item.addMiddleRightTool(iconButton);
            chatPanelMap.put(key, item);
            StackPane rightPane = new StackPane();
            ImageView imageView = new ImageView();
            rightPane.getChildren().add(imageView);
            if (!"2".equals(userData.getGender())) {
                Image image = ImageBox.getImagePath("Resources/Images/Default/Show/default_av_girl_v3.png", 140, 380);
                imageView.setImage(image);
            } else {
                Image image = ImageBox.getImagePath("Resources/Images/Default/Show/default_av_boy_v3.png", 140, 380);
                imageView.setImage(image);
            }
            Image i = ImageBox.getImageClassPath("/resources/chat/images/user/file/aio_toobar_send_hover.png");
            IconButton isb = new IconButton();
            isb.setNormalImage(i);
            item.addTopTool(isb);
            isb.setOnAction(a -> {
                UserDataBox ub = appContext.getBox(UserDataBox.class);
                boolean online = ub.isOnline(userId);
                if (online) {
                    File file = fileChooser.showOpenDialog(chatListFrame);
                    if (null != file) {
                        SettingManager sm = appContext.getManager(SettingManager.class);
                        if (file.length() > sm.getChatSetting().getFileLimitSize()) {
                            chatListFrame.showPrompt(sm.getChatSetting().getFileLimitInfo());
                            return;
                        }
                        ChatController cc = appContext.getController(ChatController.class);
                        cc.sendFile(userData.getId(), file);
                    }
                } else {
                    chatListFrame.showPrompt("对方不在线！");
                }
            });
            item.setFileEventAction(file -> {
                if (null != file) {
                    UserDataBox ub = appContext.getBox(UserDataBox.class);
                    boolean online = ub.isOnline(userId);
                    if (online) {
                        SettingManager sm = appContext.getManager(SettingManager.class);
                        if (file.length() > sm.getChatSetting().getFileLimitSize()) {
                            chatListFrame.showPrompt(sm.getChatSetting().getFileLimitInfo());
                            return;
                        }
                        ChatController cc = appContext.getController(ChatController.class);
                        cc.sendFile(userData.getId(), file);
                    } else {
                        chatListFrame.showPrompt("对方不在线！");
                    }
                }
            });
            i = ImageBox.getImageClassPath("/resources/chat/images/user/top/Remote_MenuTextue2.png");
            isb = new IconButton();
            isb.setNormalImage(i);
            item.addTopTool(isb);
            isb.setOnAction(a -> {
                UserDataBox ub = appContext.getBox(UserDataBox.class);
                boolean online = ub.isOnline(userId);
                if (online) {
                    RemoteController rc = appContext.getController(RemoteController.class);
                    rc.requestRemoteControl(userId);
                } else {
                    chatListFrame.showPrompt("对方不在线！");
                }
            });
        }
        if (null != userData.getRemarkName() && !"".equals(userData.getRemarkName())) {
            item.setName(userData.getRemarkName());
        } else {
            item.setName(userData.getNickname());
        }
        item.setText(userData.getSignature());
        return item;
    }

    private ChatItem getGroupChatItem(Group group) {
        String key = this.getGroupKey(group.getId());
        ChatItem item = chatItemMap.get(key);
        if (null == item) {
            item = new ChatItem();
            item.addAttribute("key", key);
            chatItemMap.put(key, item);
            item.addCloseAction(new ChatItemCloseEvent(key));
            item.setOnMouseClicked(new ChatItemClickedEvent(key));
        }
        item.setText(group.getName());
        HeadImageManager him = appContext.getManager(HeadImageManager.class);
        Image image = him.getGroupHead(group.getId());
        item.setImage(image);
        return item;
    }

    protected ChatPanel getGroupChatPanel(Group group) {
        String key = this.getGroupKey(group.getId());
        ChatPanel item = chatPanelMap.get(key);
        if (null == item) {
            item = new ChatPanel();
            item.addAttribute("key", key);
            item.addAttribute("groupId", group.getId());
            item.setEmojiConverter(emojiConverter);
            item.getShowPanel().setJavaScriptInterface(chatInterface);
            item.setSendAction(new ChatItemGroupSendEvent(key));
            item.setCloseAction(new ChatItemCloseEvent(key));
            item.setOnWriteKeyReleased(e -> {
                // 回车发送
                if (!e.isShiftDown() && e.getCode() == KeyCode.ENTER) {
                    sendGroupMessage(key);
                    e.consume();
                }
            });
            chatPanelMap.put(key, item);
            setGroupUserListPane(item, group.getId());
            EventAction<FaceInfo> faceAction = new EventAction<FaceInfo>() {

                ChatPanel item;

                @Override
                public void execute(FaceInfo value) {
                    if (null != value) {
                        Platform.runLater(new Runnable() {

                            public void run() {
                                insertFace(item, value);
                            }
                        });
                    }
                }

                EventAction<FaceInfo> set(ChatPanel item) {
                    this.item = item;
                    return this;
                }
            }.set(item);
            // 表情按钮
            Image normalImage = ImageBox.getImageClassPath("/resources/chat/images/middletoolbar/aio_quickbar_face.png");
            Image hoverImage = ImageBox.getImageClassPath("/resources/chat/images/middletoolbar/aio_quickbar_face_hover.png");
            Image pressedImage = ImageBox.getImageClassPath("/resources/chat/images/middletoolbar/aio_quickbar_face_hover.png");
            IconPane ib = new IconPane(normalImage, hoverImage, pressedImage);
            ib.setOnMouseClicked(new EventHandler<MouseEvent>() {

                @Override
                public void handle(MouseEvent event) {
                    faceSelectAction = (faceAction);
                    facePopup.show(ib);
                }
            });
            item.addMiddleTool(ib);
            // 发送图片按钮
            normalImage = ImageBox.getImageClassPath("/resources/chat/images/middletoolbar/aio_quickbar_sendpic.png");
            hoverImage = ImageBox.getImageClassPath("/resources/chat/images/middletoolbar/aio_quickbar_sendpic_hover.png");
            pressedImage = ImageBox.getImageClassPath("/resources/chat/images/middletoolbar/aio_quickbar_sendpic_hover.png");
            IconPane iconButton = new IconPane(normalImage, hoverImage, pressedImage);
            EventHandler<MouseEvent> e = new EventHandler<MouseEvent>() {

                ChatPanel item;

                @Override
                public void handle(MouseEvent event) {
                    String fullPath = getPicture();
                    item.insertImage("", "image", fullPath, fullPath);
                }

                EventHandler<MouseEvent> set(ChatPanel item) {
                    this.item = item;
                    return this;
                }
            }.set(item);
            iconButton.setOnMouseClicked(e);
            item.addMiddleTool(iconButton);
            // ChatPanel item;
            // @Override
            // ScreenShotAction set(ChatPanel item) {
            EventAction<Image> screenShotAction = new EventAction<Image>() {

                ChatPanel item;

                @Override
                public void execute(Image image) {
                    if (null != image) {
                        saveImage(item, image);
                    }
                }

                EventAction<Image> set(ChatPanel item) {
                    this.item = item;
                    return this;
                }
            }.set(item);
            // 截屏按钮
            normalImage = ImageBox.getImageClassPath("/resources/chat/images/middletoolbar/aio_quickbar_cut.png");
            hoverImage = ImageBox.getImageClassPath("/resources/chat/images/middletoolbar/aio_quickbar_cut.png");
            pressedImage = ImageBox.getImageClassPath("/resources/chat/images/middletoolbar/aio_quickbar_cut.png");
            iconButton = new IconPane(normalImage, hoverImage, pressedImage);
            iconButton.setOnMouseClicked(new EventHandler<MouseEvent>() {

                @Override
                public void handle(MouseEvent event) {
                    frame.setOnImageAction(screenShotAction);
                    frame.setVisible(true);
                }
            });
            item.addMiddleTool(iconButton);
        }
        item.setName(group.getName());
        item.setText(group.getPublicNotice());
        return item;
    }

    protected void select(ChatItem item, ChatPanel chatPanel) {
        if (item != this.tempChatItem) {
            if (null != this.tempChatItem) {
                this.tempChatItem.setSelected(false);
            }
            item.setSelected(true);
        }
        this.tempChatItem = item;
        chatListFrame.addItem(item);
        chatListFrame.setChatPanel(chatPanel);
        if (!itemMap.containsValue(item)) {
            String key = item.getAttribute("key");
            itemMap.put(key, item);
        }
    }

    @Override
    public boolean hasGroupChat(String groupId) {
        String key = getGroupKey(groupId);
        return chatItemMap.containsKey(key);
    }

    @Override
    public boolean hasUserChat(String userId) {
        String key = getUserKey(userId);
        return chatItemMap.containsKey(key);
    }

    protected void sendVideo(UserData userData) {
        PersonalBox pb = appContext.getBox(PersonalBox.class);
        UserData sendUser = pb.getUserData();
        VideoManager vm = this.appContext.getManager(VideoManager.class);
        vm.showSendVideoFrame(userData);
        VideoSender vh = this.appContext.getSender(VideoSender.class);
        vh.requestVideo(sendUser.getId(), userData.getId());
    }

    public void userChat(boolean isOwn, UserData userData, Content content) {
        if (null != userData) {
            String name = AppCommonUtil.getDefaultShowName(userData);
            String time = OnlyDateUtil.dateToString(new Date(content.getTimestamp()), "yyyy-MM-dd HH:mm:ss");
            // String color =
            Platform.runLater(new Runnable() {

                @Override
                public void run() {
                    ChatPanel chatPanel = getUserChatPanel(userData);
                    HeadImageManager him = appContext.getManager(HeadImageManager.class);
                    String headPath = him.getUserHeadPath(userData.getId());
                    String orientation = isOwn ? "right" : "left";
                    insertShow(chatPanel, name, headPath, time, orientation, content);
                }
            });
        }
    }

    public void groupChat(Group group, UserData userData, Content content) {
        if (null != userData) {
            PersonalBox pb = appContext.getBox(PersonalBox.class);
            UserData user = pb.getUserData();
            boolean isOwn = user.getId().equals(userData.getId());
            String name = AppCommonUtil.getDefaultShowName(userData);
            String time = OnlyDateUtil.getCurrentDateTime();
            Platform.runLater(new Runnable() {

                @Override
                public void run() {
                    ChatPanel chatPanel = getGroupChatPanel(group);
                    HeadImageManager him = appContext.getManager(HeadImageManager.class);
                    String headPath = him.getUserHeadPath(userData.getId());
                    String orientation = isOwn ? "right" : "left";
                    insertShow(chatPanel, name, headPath, time, orientation, content);
                }
            });
        }
    }

    protected void insertShow(ChatPanel cp, String name, String head, String time, String orientation, Content content) {
        if (null != cp) {
            ContentToHtmlService cths = appContext.getService(ContentToHtmlService.class);
            String contentTag = cths.getBubbleInsertContentTag(content);
            Platform.runLater(new Runnable() {

                @Override
                public void run() {
                    String headPath = "";
                    if (null != head && head.startsWith("/")) {
                        headPath = "file:" + head;
                    } else {
                        headPath = "file:/" + head;
                    }
                    cp.insertShowLastHtml(name, headPath, time, orientation, contentTag);
                }
            });
            List<Item> items = CoreContentUtil.getImageItemList(content);
            if (!items.isEmpty()) {
                PersonalBox pb = appContext.getBox(PersonalBox.class);
                UserData sendUser = pb.getUserData();
                BackAction<List<FileHandleInfo>> backAction = new BackAction<List<FileHandleInfo>>() {

                    @Override
                    public void back(BackInfo backInfo, List<FileHandleInfo> list) {
                        for (FileHandleInfo info : list) {
                            FileInfo fi = info.getFileInfo();
                            if (info.isSuccess()) {
                                File file = (null != fi) ? fi.getFile() : null;
                                String name = (null != file) ? file.getName() : "";
                                String id = (null != fi) ? fi.getId() : "";
                                String appPath = AppConstant.userHome + "/" + AppConstant.app_home_path + "/" + sendUser.getNumber() + "/image/" + name;
                                Platform.runLater(new Runnable() {

                                    @Override
                                    public void run() {
                                        String path = "";
                                        if (appPath.startsWith("/")) {
                                            path = "file:" + appPath;
                                        } else {
                                            path = "file:/" + appPath;
                                        }
                                        cp.replaceImage(id, path);
                                    }
                                });
                            } else {
                                String id = (null != fi) ? fi.getId() : "";
                                Platform.runLater(new Runnable() {

                                    @Override
                                    public void run() {
                                        String tempImage = "Resources/Images/Default/ChatFrame/ImageLoading/image_download_fail.png";
                                        File file = new File(tempImage);
                                        if (file.exists()) {
                                            tempImage = file.getAbsolutePath();
                                        }
                                        cp.replaceImage(id, tempImage);
                                    }
                                });
                            }
                        }
                    }
                };
                ImageManager im = this.appContext.getManager(ImageManager.class);
                im.downloadImage(items, backAction);
            }
        }
    }

    protected void insertShowChat(ChatPanel cp, String name, String color, String time, Content content) {
        if (null != cp) {
            ContentToHtmlService cths = appContext.getService(ContentToHtmlService.class);
            String contentTag = cths.getInsertContentTag(content);
            Platform.runLater(new Runnable() {

                @Override
                public void run() {
                    cp.insertShowLastHtml(contentTag);
                }
            });
            List<Item> items = CoreContentUtil.getImageItemList(content);
            if (!items.isEmpty()) {
                PersonalBox pb = appContext.getBox(PersonalBox.class);
                UserData sendUser = pb.getUserData();
                BackAction<List<FileHandleInfo>> backAction = new BackAction<List<FileHandleInfo>>() {

                    @Override
                    public void back(BackInfo backInfo, List<FileHandleInfo> list) {
                        for (FileHandleInfo info : list) {
                            FileInfo fi = info.getFileInfo();
                            if (info.isSuccess()) {
                                File file = (null != fi) ? fi.getFile() : null;
                                String name = (null != file) ? file.getName() : "";
                                String id = (null != fi) ? fi.getId() : "";
                                String appPath = AppConstant.userHome + "/" + AppConstant.app_home_path + "/" + sendUser.getNumber() + "/image/" + name;
                                Platform.runLater(new Runnable() {

                                    @Override
                                    public void run() {
                                        String path = "";
                                        if (appPath.startsWith("/")) {
                                            path = "file:" + appPath;
                                        } else {
                                            path = "file:/" + appPath;
                                        }
                                        cp.replaceImage(id, path);
                                    }
                                });
                            } else {
                                String id = (null != fi) ? fi.getId() : "";
                                Platform.runLater(new Runnable() {

                                    @Override
                                    public void run() {
                                        String tempImage = "Resources/Images/Default/ChatFrame/ImageLoading/image_download_fail.png";
                                        File file = new File(tempImage);
                                        if (file.exists()) {
                                            tempImage = file.getAbsolutePath();
                                        }
                                        cp.replaceImage(id, tempImage);
                                    }
                                });
                            }
                        }
                    }
                };
                ImageManager im = this.appContext.getManager(ImageManager.class);
                im.downloadImage(items, backAction);
            }
        }
    }

    protected void sendUserMessage(String key) {
        PersonalBox pb = appContext.getBox(PersonalBox.class);
        UserData sendUser = pb.getUserData();
        ChatPanel chatPanel = chatPanelMap.get(key);
        if (null != chatPanel) {
            String html = chatPanel.getHtml();
            boolean underline = chatPanel.isUnderline();
            boolean bold = chatPanel.isBold();
            String color = chatPanel.getWebColor();
            boolean italic = chatPanel.isItalic();
            String fontName = chatPanel.getFontName();
            int fontSize = chatPanel.getFontSize();
            Content content = ContentUtil.getContent(html, fontName, fontSize, color, underline, bold, italic);
            String receiveUserId = chatPanel.getAttribute("userId");
            if (null != content) {
                chatPanel.initializeWriteHtml();
                String name = AppCommonUtil.getDefaultPersonalShowName(sendUser);
                String time = OnlyDateUtil.getCurrentDateTime();
                DataBackActionAdapter action = new DataBackActionAdapter() {

                    @Back
                    public void back(Info info, @Define("userData") UserData user) {
                        if (info.isSuccess()) {
                            UserDataBox ub = appContext.getBox(UserDataBox.class);
                            UserData userData = ub.getUserData(receiveUserId);
                            if (null != userData) {
                                LastManager lastManage = appContext.getManager(LastManager.class);
                                String text = CoreContentUtil.getText(content);
                            }
                        }
                    }
                };
                List<Item> items = CoreContentUtil.getImageItemList(content);
                if (!items.isEmpty()) {
                    CallBackAction<List<FileData>> fileBackAction = new CallBackAction<List<FileData>>() {

                        @Override
                        public void execute(List<FileData> list) {
                            for (FileData fd : list) {
                                String name = fd.getName();
                                String appPath = AppConstant.userHome + "/" + AppConstant.app_home_path + "/" + sendUser.getNumber() + "/image/" + name;
                                Platform.runLater(new Runnable() {

                                    @Override
                                    public void run() {
                                        String path = "";
                                        if (appPath.startsWith("/")) {
                                            path = "file:" + appPath;
                                        } else {
                                            path = "file:/" + appPath;
                                        }
                                        chatPanel.replaceImage(fd.getId(), path);
                                    }
                                });
                            }
                        }
                    };
                    ImageManager im = this.appContext.getManager(ImageManager.class);
                    BackAction<List<FileHandleInfo>> backAction = new BackAction<List<FileHandleInfo>>() {

                        @Override
                        public void back(BackInfo backInfo, List<FileHandleInfo> t) {
                            ChatSender ch = appContext.getSender(ChatSender.class);
                            Platform.runLater(new Runnable() {

                                @Override
                                public void run() {
                                    HeadImageManager him = appContext.getManager(HeadImageManager.class);
                                    String headPath = him.getUserHeadPath(sendUser.getId());
                                    String orientation = "right";
                                    insertShow(chatPanel, name, headPath, time, orientation, content);
                                }
                            });
                            im.handleLocalImage(items, fileBackAction);
                        }
                    };
                    im.uploadImage(items, backAction);
                } else {
                    ChatSender ch = appContext.getSender(ChatSender.class);
                    Platform.runLater(new Runnable() {

                        @Override
                        public void run() {
                            HeadImageManager him = appContext.getManager(HeadImageManager.class);
                            String headPath = him.getUserHeadPath(sendUser.getId());
                            String orientation = "right";
                            insertShow(chatPanel, name, headPath, time, orientation, content);
                        }
                    });
                }
            }
        }
    }

    private void sendGroupMessage(String key) {
        PersonalBox pb = appContext.getBox(PersonalBox.class);
        UserData user = pb.getUserData();
        ChatPanel chatPanel = chatPanelMap.get(key);
        if (null != chatPanel) {
            String html = chatPanel.getHtml();
            boolean underline = chatPanel.isUnderline();
            boolean bold = chatPanel.isBold();
            String color = chatPanel.getWebColor();
            boolean italic = chatPanel.isItalic();
            String fontName = chatPanel.getFontName();
            int fontSize = chatPanel.getFontSize();
            Content content = ContentUtil.getContent(html, fontName, fontSize, color, underline, bold, italic);
            String groupId = chatPanel.getAttribute("groupId");
            if (null != content) {
                chatPanel.initializeWriteHtml();
                List<Item> items = CoreContentUtil.getImageItemList(content);
                if (!items.isEmpty()) {
                    // 判断信息中是否有图片，没有图片直接发送，节省响应事件
                    ImageManager im = this.appContext.getManager(ImageManager.class);
                    BackAction<List<FileHandleInfo>> backAction = new BackAction<List<FileHandleInfo>>() {

                        @Override
                        public void back(BackInfo backInfo, List<FileHandleInfo> t) {
                            ChatSender ch = appContext.getSender(ChatSender.class);
                        }
                    };
                    im.uploadImage(items, backAction);
                } else {
                    ChatSender ch = appContext.getSender(ChatSender.class);
                }
            }
        }
    }

    private void selectChatItem(String key) {
        ChatItem ci = chatItemMap.get(key);
        ChatPanel cp = chatPanelMap.get(key);
        if (null != ci && null != cp) {
            select(ci, cp);
        }
    }

    private void removeChatItem(String key) {
        ChatItem item = chatItemMap.get(key);
        if (null != item) {
            chatListFrame.removeItem(item);
            itemMap.remove(key);
            if (itemMap.isEmpty()) {
                setVisible(false);
            } else {
                if (item.isSelected()) {
                    Iterator<String> iterator = itemMap.keySet().iterator();
                    if (iterator.hasNext()) {
                        String nextKey = iterator.next();
                        selectChatItem(nextKey);
                    }
                }
            }
        }
    }

    protected String getUserKey(String userId) {
        StringBuilder sb = new StringBuilder();
        sb.append("user_");
        sb.append(userId);
        return sb.toString();
    }

    protected String getGroupKey(String groupId) {
        StringBuilder sb = new StringBuilder();
        sb.append("group_");
        sb.append(groupId);
        return sb.toString();
    }

    protected void setGroupUserListPane(ChatPanel item, String groupId) {
        ListRootPanel groupUserList = groupUserListMap.get(groupId);
        if (null == groupUserList) {
            updateGroupUserList(groupId);
        } else {
            if (null != item) {
                groupUserList.setPrefWidth(140);
                item.setRightPane(groupUserList);
            }
        }
    }

    public void setGroupUserList(final String groupId) {
        GroupMemberBox gmb = appContext.getBox(GroupMemberBox.class);
        List<GroupMember> gml = gmb.getGroupMemberList(groupId);
        if (null == gml) {
            DataBackAction dataBackAction = new DataBackActionAdapter() {

                @Back
                public void back(@Define("userDataList") List<UserData> userDataList, @Define("groupMemberList") List<GroupMember> groupMemberList) {
                    setGroupUserList(groupId, userDataList, groupMemberList);
                }
            };
            GroupSender gh = this.appContext.getSender(GroupSender.class);
            gh.getGroupMemberListWithUserDataList(groupId, dataBackAction);
        }
    }

    public void updateGroupUserList(final String groupId) {
        DataBackAction dataBackAction = new DataBackActionAdapter() {

            @Back
            public void back(@Define("userDataList") List<UserData> userDataList, @Define("groupMemberList") List<GroupMember> groupMemberList) {
                setGroupUserList(groupId, userDataList, groupMemberList);
            }
        };
        GroupSender gh = this.appContext.getSender(GroupSender.class);
        gh.getGroupMemberListWithUserDataList(groupId, dataBackAction);
    }

    private void setGroupUserList(String groupId, List<UserData> userDataList, List<GroupMember> groupMemberList) {
        Platform.runLater(new Runnable() {

            @Override
            public void run() {
                GroupMemberBox gmb = appContext.getBox(GroupMemberBox.class);
                gmb.putGroupMemberList(groupId, groupMemberList);
                ListRootPanel groupUserList = groupUserListMap.get(groupId);
                if (groupUserList == null) {
                    groupUserList = new ListRootPanel();
                }
                groupUserList.clearNode();
                for (UserData userData : userDataList) {
                    SimpleHead item = new SimpleHead();
                    item.setOnMouseClicked((MouseEvent me) -> {
                        if (me.getClickCount() == 2) {
                        }
                        me.consume();
                    });
                    item.setText(userData.getNickname());
                    HeadImageManager him = appContext.getManager(HeadImageManager.class);
                    Image image = him.getUserHead(userData.getId(), 40);
                    // Image image =
                    item.setHeadSize(20);
                    item.setHeadRadius(20);
                    item.setImage(image);
                    item.addAttribute(UserData.class, userData);
                    groupUserList.addNode(item);
                }
                String key = getGroupKey(groupId);
                ChatPanel chatPanel = chatPanelMap.get(key);
                if (null != chatPanel) {
                    groupUserList.setPrefWidth(140);
                    chatPanel.setRightPane(groupUserList);
                }
            }
        });
    }

    protected class ChatItemGroupSendEvent implements EventHandler<ActionEvent> {

        String key;

        public ChatItemGroupSendEvent(String key) {
            this.key = key;
        }

        @Override
        public void handle(ActionEvent event) {
            sendGroupMessage(key);
        }
    }

    protected class ChatItemUserSendEvent implements EventHandler<ActionEvent> {

        String key;

        public ChatItemUserSendEvent(String key) {
            this.key = key;
        }

        @Override
        public void handle(ActionEvent event) {
            sendUserMessage(key);
        }
    }

    protected class ChatItemCloseEvent implements EventHandler<ActionEvent> {

        String key;

        public ChatItemCloseEvent(String key) {
            this.key = key;
        }

        @Override
        public void handle(ActionEvent event) {
            removeChatItem(key);
        }
    }

    protected class ChatItemClickedEvent implements EventHandler<MouseEvent> {

        String key;

        public ChatItemClickedEvent(String key) {
            this.key = key;
        }

        @Override
        public void handle(MouseEvent event) {
            selectChatItem(key);
        }
    }

    /**
     * 发送抖动操作
     *
     * @Author: XiaHui
     * @Date: 2016年2月16日
     * @ModifyUser: XiaHui
     * @ModifyDate: 2016年2月16日
     * @param receiveId
     */

    @Override
    public void doShake(UserData userData) {
        Platform.runLater(new Runnable() {

            @Override
            public void run() {
                ChatItem chatItem = getUserChatItem(userData);
                ChatPanel chatPanel = getUserChatPanel(userData);
                select(chatItem, chatPanel);
                shake();
            }
        });
    }

    private void shake() {
        if (System.currentTimeMillis() - shakeTime < 3000) {
            return;
        }
        Platform.runLater(new Runnable() {

            @Override
            public void run() {
                Task<Integer> task = new Task<Integer>() {

                    @Override
                    protected Integer call() throws Exception {
                        int iterations = 0;
                        for (int i = 0; i < 3; i++) {
                            chatListFrame.setX(chatListFrame.getX() + 4);
                            chatListFrame.setY(chatListFrame.getY() - 4);
                            try {
                                Thread.sleep(40);
                                chatListFrame.setX(chatListFrame.getX() - 8);
                                chatListFrame.setY(chatListFrame.getY());
                                Thread.sleep(40);
                                chatListFrame.setX(chatListFrame.getX());
                                chatListFrame.setY(chatListFrame.getY() + 4);
                                Thread.sleep(40);
                                chatListFrame.setX(chatListFrame.getX() + 4);
                                chatListFrame.setY(chatListFrame.getY());
                                Thread.sleep(40);
                            } catch (InterruptedException ex) {
                                ex.printStackTrace();
                            }
                        }
                        return iterations;
                    }
                };
                Thread th = new Thread(task);
                th.setDaemon(true);
                th.start();
            }
        });
        shakeTime = System.currentTimeMillis();
    }

    public void saveImage(ChatPanel cp, Image image) {
        String fileName = dateFormat.format(new Date()).toString() + ".png";
        PathManager pm = appContext.getManager(PathManager.class);
        String savePath = pm.getScreenshotSavePath();
        String path = savePath + fileName;
        try {
            OnlyFileUtil.checkOrCreateFolder(path);
            File file = new File(path);
            ImageIO.write(SwingFXUtils.fromFXImage(image, null), "png", file);
            cp.insertImage("", "image", path, path);
        } catch (IOException ex) {
        }
    }

    public void saveBufferedImage(ChatPanel cp, BufferedImage image) {
        String fileName = dateFormat.format(new Date()).toString() + ".jpg";
        PathManager pm = appContext.getManager(PathManager.class);
        String savePath = pm.getScreenshotSavePath();
        String path = savePath + fileName;
        try {
            OnlyFileUtil.checkOrCreateFolder(path);
            ImageIO.write(image, "jpg", new File(path));
            cp.insertImage("", "image", path, path);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    public String getPicture() {
        String fullPath = null;
        File file = imageFileChooser.showOpenDialog(chatListFrame);
        if (file != null) {
            if (file.exists()) {
                SettingManager sm = appContext.getManager(SettingManager.class);
                if (file.length() > sm.getChatSetting().getImageLimitSize()) {
                    chatListFrame.showPrompt(sm.getChatSetting().getImageLimitInfo());
                    return null;
                }
                fullPath = file.getAbsolutePath();
            }
        }
        return fullPath;
    }

    public void insertFace(ChatPanel cp, FaceInfo fi) {
        FaceManager fm = appContext.getManager(FaceManager.class);
        String tag = fm.getFaceImageTag(fi);
        if (null != tag) {
            cp.insertWriteSelectionHtml(tag);
        }
    }

    private Map<String, UserChatHistoryView> chvMap = new ConcurrentHashMap<String, UserChatHistoryView>();

    /**
     * 显示历史记录
     *
     * @param userId
     */
    public void showChatHistoryView(String userId) {
        Platform.runLater(new Runnable() {

            @Override
            public void run() {
                UserChatHistoryView chf = getChatHistoryView(userId);
                chf.setVisible(true);
            }
        });
    }

    public UserChatHistoryView getChatHistoryView(String userId) {
        UserChatHistoryView chv = chvMap.get(userId);
        if (null == chv) {
            chv = appContext.getObject(UserChatHistoryView.class, true);
            chv.setUserId(userId);
            chvMap.put(userId, chv);
        }
        return chv;
    }

    public void userChatHistory(UserData userData, List<UserChatHistoryData> contents) {
        if (null != contents) {
            for (UserChatHistoryData chd : contents) {
                UserData sendUserData = chd.getSendUserData();
                Content content = chd.getContent();
                String name = sendUserData.getNickname();
                String time = OnlyDateUtil.dateToDateTime(new Date(content.getTimestamp()));
                // String blueColor =
                PersonalBox pb = appContext.getBox(PersonalBox.class);
                UserData user = pb.getUserData();
                boolean isOwn = user.getId().equals(sendUserData.getId());
                // String nameTag = ContentUtil.getInsertNameTag(name, isOwn ?
                Platform.runLater(new Runnable() {

                    @Override
                    public void run() {
                        HeadImageManager him = appContext.getManager(HeadImageManager.class);
                        String head = him.getUserHeadPath(sendUserData.getId());
                        String headPath = "";
                        if (null != head && head.startsWith("/")) {
                            headPath = "file:" + head;
                        } else {
                            headPath = "file:/" + head;
                        }
                        String orientation = isOwn ? "right" : "left";
                        ChatPanel chatPanel = getUserChatPanel(userData);
                    }
                });
            }
        }
        // @Override
        PersonalBox pb = appContext.getBox(PersonalBox.class);
        UserData user = pb.getUserData();
        BackAction<List<FileHandleInfo>> backAction = new BackAction<List<FileHandleInfo>>() {

            @Override
            public void back(BackInfo backInfo, List<FileHandleInfo> list) {
                for (FileHandleInfo info : list) {
                    FileInfo fi = info.getFileInfo();
                    if (info.isSuccess()) {
                        File file = (null != fi) ? fi.getFile() : null;
                        String name = (null != file) ? file.getName() : "";
                        String id = (null != fi) ? fi.getId() : "";
                        String appPath = AppConstant.userHome + "/" + AppConstant.app_home_path + "/" + user.getNumber() + "/image/" + name;
                        Platform.runLater(new Runnable() {

                            @Override
                            public void run() {
                                String path = "";
                                if (appPath.startsWith("/")) {
                                    path = "file:" + appPath;
                                } else {
                                    path = "file:/" + appPath;
                                }
                                ChatPanel chatPanel = getUserChatPanel(userData);
                                chatPanel.replaceImage(id, path);
                            }
                        });
                    } else {
                        String id = (null != fi) ? fi.getId() : "";
                        Platform.runLater(new Runnable() {

                            @Override
                            public void run() {
                                String tempImage = "Resources/Images/Default/ChatFrame/ImageLoading/image_download_fail.png";
                                File file = new File(tempImage);
                                if (file.exists()) {
                                    tempImage = file.getAbsolutePath();
                                }
                                ChatPanel chatPanel = getUserChatPanel(userData);
                                chatPanel.replaceImage(id, tempImage);
                            }
                        });
                    }
                }
            }
        };
        if (null != contents) {
            for (UserChatHistoryData chd : contents) {
                Content content = chd.getContent();
                ImageManager im = this.appContext.getManager(ImageManager.class);
                List<Item> items = CoreContentUtil.getImageItemList(content);
                im.downloadImage(items, backAction);
            }
        }
    }

    @Override
    public boolean hasRequestRemoteControl(String userId) {
        return requestRemoteFrame.isShowing();
    }

    public void showRequestRemoteControl(UserData userData) {
        String userId = userData.getId();
        String name = AppCommonUtil.getDefaultShowName(userData);
        StringBuilder content = new StringBuilder();
        content.append(name);
        content.append(" 请求远程控制你的电脑，接受还是拒绝？");
        requestRemoteFrame.setContent(content.toString());
        RemoteManager rm = appContext.getManager(RemoteManager.class);
        requestRemoteFrame.setOnAcceptAction(a -> {
            requestRemoteFrame.hide();
            rm.responseRemoteControl(userId, RemoteConstant.action_type_agree);
        });
        requestRemoteFrame.setOnRefuseAction(a -> {
            requestRemoteFrame.hide();
            rm.responseRemoteControl(userId, RemoteConstant.action_type_shut);
        });
        Platform.runLater(new Runnable() {

            @Override
            public void run() {
                requestRemoteFrame.show();
            }
        });
    }

    @Override
    public void updateUserChatInfo(String userId, String text, String time) {
        // TODO 自动生成的方法存根
    }

    @Override
    public void setChatUserItemRed(String userId, boolean red, int count) {
        // TODO 自动生成的方法存根
    }

    @Override
    public void userChat(boolean isOwn, UserData showUserData, UserData chatUserData, Content content) {
        // TODO 自动生成的方法存根
    }

    @Override
    public void showUserChatHistory(UserData userId, PageData page, List<UserChatHistoryData> list) {
        // TODO 自动生成的方法存根
    }

    @Override
    public void loadUserChatHistory(UserData userData, PageData page, List<UserChatHistoryData> list) {
        // TODO 自动生成的方法存根
    }

    @Override
    public void updateGroupChatInfo(String groupId, String text, String time) {
        // TODO 自动生成的方法存根
    }

    @Override
    public void setChatGroupItemRed(String groupId, boolean red, int count) {
        // TODO 自动生成的方法存根
    }

    @Override
    public void groupChat(boolean isOwn, Group group, UserData chatUserData, Content content) {
        // TODO 自动生成的方法存根
    }

    @Override
    public void showGroupChatHistory(UserData userId, PageData page, List<UserChatHistoryData> list) {
        // TODO 自动生成的方法存根
    }

    @Override
    public void loadGroupChatHistory(Group group, PageData page, List<GroupChatHistoryData> contents) {
        // TODO 自动生成的方法存根
    }

    @Override
    public void addOrUpdateGroupMember(String groupId, GroupMember groupMember, UserData userData) {
        // TODO 自动生成的方法存根
    }

    @Override
    public void removeGroupMember(String groupId, String userId) {
        // TODO 自动生成的方法存根
    }
}


public boolean isEmpty() {
        return range.isEmpty();
    }

package opendial.datastructs;

import java.util.logging.*;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.OptionalInt;
import java.util.Set;
import java.util.stream.Collectors;
import opendial.bn.values.Value;
import opendial.utils.InferenceUtils;

/**
 * Representation of a range of alternative values for a set of variables.
 *
 * @author Pierre Lison (plison@ifi.uio.no)
 */
public class ValueRange {

    // logger
    final static Logger log = Logger.getLogger("OpenDial");

    Map<String, Set<Value>> range;

    /**
     * Constructs a new, empty range of values.
     */
    public ValueRange() {
        range = new HashMap<String, Set<Value>>();
    }

    /**
     * Creates a value range out of a set of value assignments
     *
     * @param assigns the assignments specifying the possible (variable,value) pairs
     */
    public ValueRange(Set<Assignment> assigns) {
        this();
        for (Assignment a : assigns) {
            addAssign(a);
        }
    }

    /**
     * Constructs a new range that is the union of two existing ranges
     *
     * @param range1 the first range of values
     * @param range2 the second range of values.
     */
    public ValueRange(ValueRange range1, ValueRange range2) {
        this();
        addRange(range1);
        addRange(range2);
    }

    /**
     * Constructs a range of values based on the mapping between variables and sets
     * of values
     *
     * @param range the range (as a map)
     */
    public ValueRange(Map<String, Set<Value>> range) {
        this.range = new HashMap<String, Set<Value>>(range);
    }

    /**
     * Adds a value for the variable in the range.
     *
     * @param variable the variable
     * @param val the value
     */
    public void addValue(String variable, Value val) {
        if (!range.containsKey(variable)) {
            range.put(variable, new HashSet<Value>());
        }
        range.get(variable).add(val);
    }

    /**
     * Adds a set of values for the variable
     *
     * @param variable the variable
     * @param values the values to add
     */
    public void addValues(String variable, Collection<? extends Value> values) {
        for (Value val : values) {
            addValue(variable, val);
        }
    }

    /**
     * Adds the values defined in the assignment to the range
     *
     * @param assignment the value assignments
     */
    public void addAssign(Assignment assignment) {
        for (String var : assignment.getVariables()) {
            addValue(var, assignment.getValue(var));
        }
    }

    /**
     * Adds the range of values to the existing one.
     *
     * @param newRange the new range
     */
    public void addRange(ValueRange newRange) {
        for (String var : newRange.getVariables()) {
            addValues(var, newRange.getValues(var));
        }
    }

    /**
     * Extracts all alternative assignments of values for the variables in the range.
     * This operation can be computational expensive, use with caution.
     *
     * @return the set of alternative assignments
     */
    public Set<Assignment> linearise() {
        if (range.size() == 1) {
            String var = range.keySet().iterator().next();
            return range.get(var).stream().map(v -> new Assignment(var, v)).collect(Collectors.toSet());
        }
        return InferenceUtils.getAllCombinations(range);
    }

    /**
     * Returns the estimated number (higher bound) of combinations for the value
     * range.
     *
     * @return the higher bound on the number of possible combinations
     */
    public int getNbCombinations() {
        OptionalInt estimation = range.values().stream().mapToInt(set -> set.size()).reduce((a, b) -> a * b);
        return (estimation.isPresent()) ? estimation.getAsInt() : 1;
    }

    /**
     * Returns the set of variables with a non-empty range of values
     *
     * @return the set of variables
     */
    public Set<String> getVariables() {
        return range.keySet();
    }

    /**
     * Returns the set of values for the variable in the range (if defined). If the
     * variable is not defined in the range, returns null
     *
     * @param variable the variable
     * @return its set of alternative values
     */
    public Set<Value> getValues(String variable) {
        return range.get(variable);
    }

    /**
     * Returns a string representation for the range
     */
    @Override
    public String toString() {
        return range.toString();
    }

    /**
     * Returns the hashcode for the range of values
     */
    @Override
    public int hashCode() {
        return range.hashCode() - 1;
    }

    /**
     * Returns true if the range is empty (contains no variables).
     *
     * @return true if empty, else false.
     */

    /**
     * Intersects the range with the existing one (only retains the values defined in
     * both ranges).
     *
     * @param otherRange the range to intersect with the existing one
     */
    public void intersectRange(ValueRange otherRange) {
        for (String id : otherRange.getVariables()) {
            if (range.containsKey(id)) {
                range.get(id).retainAll(otherRange.getValues(id));
            } else {
                addValues(id, otherRange.getValues(id));
            }
        }
    }

    /**
     * Remove the variables from the value range
     *
     * @param variables the variables to remove
     */
    public void removeVariables(Set<String> variables) {
        for (String var : variables) {
            range.remove(var);
        }
    }

    public ValueRange getSubRange(Set<String> slots) {
        ValueRange copy = new ValueRange(range);
        for (String id : range.keySet()) {
            if (!slots.contains(id)) {
                copy.range.remove(id);
            }
        }
        return copy;
    }
}


public SteamID getChatterID() {
        return chatterID;
    }

package in.dragonbra.javasteam.steam.handlers.steamfriends.callback;

import in.dragonbra.javasteam.enums.EChatAction;
import in.dragonbra.javasteam.enums.EChatActionResult;
import in.dragonbra.javasteam.generated.MsgClientChatActionResult;
import in.dragonbra.javasteam.steam.steamclient.callbackmgr.CallbackMsg;
import in.dragonbra.javasteam.types.SteamID;

/**
 * This callback is fired when a chat action has completed.
 */
public class ChatActionResultCallback extends CallbackMsg {

    private SteamID chatRoomID;

    private SteamID chatterID;

    private EChatAction action;

    private EChatActionResult result;

    public ChatActionResultCallback(MsgClientChatActionResult result) {
        chatRoomID = result.getSteamIdChat();
        chatterID = result.getSteamIdUserActedOn();
        action = result.getChatAction();
        this.result = result.getActionResult();
    }

    public ChatActionResultCallback(SteamID chatRoomID, SteamID chatterID, EChatAction action, EChatActionResult result) {
        this.chatRoomID = chatRoomID;
        this.chatterID = chatterID;
        this.action = action;
        this.result = result;
    }

    /**
     * @return the SteamID of the chat room the action was performed in.
     */
    public SteamID getChatRoomID() {
        return chatRoomID;
    }

    /**
     * @return the SteamID of the chat member the action was performed on.
     */

    /**
     * @return the chat action that was performed.
     */
    public EChatAction getAction() {
        return action;
    }

    /**
     * @return the result of the chat action.
     */
    public EChatActionResult getResult() {
        return result;
    }
}


public Image getColumnImage(String tableName, String columnName);

package com.hangum.tadpole.rdb.erd.core.extensionpoint.definition;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.swt.graphics.Image;
import com.hangum.tadpole.engine.query.dao.system.UserDBDAO;

/**
 * @author hangum
 */
public interface ITableDecorationExtension {

    /**
     * table Column list
     */
    Map<String, List<String>> mapColumnDescList = new HashMap<>();

    public boolean initExtension(UserDBDAO userDB);

    /**
     * @param tableName
     */
    public Image getTableImage(String tableName);

    /**
     * @param tableName
     * @param columnName
     */


switch(isUnboxing ? postConversionType(currentScope).id : codegenBinding.returnType.id) {
                case T_long:
                case T_double:
                    codeStream.pop2();
                    break;
                case T_void:
                    break;
                default:
                    codeStream.pop();
            }

/**
 * ****************************************************************************
 *
 *  Contributors:
 *      IBM Corporation - initial API and implementation
 *         Andy Clement (GoPivotal, Inc) example@nnthink.com - Contributions for
 *                           Bug 409245 - [1.8][compiler] Type annotations dropped when call is routed through a synthetic bridge method
 *                           Bug 409250 - [1.8][compiler] Various loose ends in 308 code generation
 *         Stephan Herrmann - Contribution for
 * 							Bug 400874 - [1.8][compiler] Inference infrastructure should evolve to meet JLS8 18.x (Part G of JSR335 spec)
 * 							Bug 424415 - [1.8][compiler] Eventual resolution of ReferenceExpression is not seen to be happening.
 * 							Bug 427438 - [1.8][compiler] NPE at org.eclipse.jdt.internal.compiler.ast.ConditionalExpression.generateCode(ConditionalExpression.java:280)
 * *****************************************************************************
 */
package org.eclipse.jdt.internal.eval;

import static org.eclipse.jdt.internal.compiler.ast.ExpressionContext.INVOCATION_CONTEXT;
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.CastExpression;
import org.eclipse.jdt.internal.compiler.ast.Expression;
import org.eclipse.jdt.internal.compiler.ast.MessageSend;
import org.eclipse.jdt.internal.compiler.ast.NameReference;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
import org.eclipse.jdt.internal.compiler.codegen.Opcodes;
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.impl.Constant;
import org.eclipse.jdt.internal.compiler.lookup.Binding;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding;
import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;

public class CodeSnippetMessageSend extends MessageSend {

    EvaluationContext evaluationContext;

    FieldBinding delegateThis;

    public CodeSnippetMessageSend(EvaluationContext evaluationContext) {
        this.evaluationContext = evaluationContext;
    }

    /**
     * MessageSend code generation
     *
     * @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope
     * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
     * @param valueRequired boolean
     */
    @Override
    public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
        int pc = codeStream.position;
        MethodBinding codegenBinding = this.binding.original();
        if (codegenBinding.canBeSeenBy(this.actualReceiverType.original(), this, currentScope)) {
            // generate receiver/enclosing instance access
            boolean isStatic = codegenBinding.isStatic();
            // outer access ?
            if (!isStatic && ((this.bits & DepthMASK) != 0)) {
                // outer method can be reached through emulation
                ReferenceBinding targetType = currentScope.enclosingSourceType().enclosingTypeAt((this.bits & DepthMASK) >> DepthSHIFT);
                Object[] path = currentScope.getEmulationPath(targetType, true, /*only exact match*/
                false);
                if (path == null) {
                    // emulation was not possible (should not happen per construction)
                    currentScope.problemReporter().needImplementation(this);
                } else {
                    codeStream.generateOuterAccess(path, this, targetType, currentScope);
                }
            } else {
                this.receiver.generateCode(currentScope, codeStream, !isStatic);
                if ((this.bits & NeedReceiverGenericCast) != 0) {
                    codeStream.checkcast(this.actualReceiverType);
                }
                codeStream.recordPositionsFrom(pc, this.sourceStart);
            }
            // generate arguments
            generateArguments(this.binding, this.arguments, currentScope, codeStream);
            // actual message invocation
            TypeBinding constantPoolDeclaringClass = CodeStream.getConstantPoolDeclaringClass(currentScope, codegenBinding, this.actualReceiverType, this.receiver.isImplicitThis());
            if (isStatic) {
                codeStream.invoke(Opcodes.OPC_invokestatic, codegenBinding, constantPoolDeclaringClass, this.typeArguments);
            } else if ((this.receiver.isSuper()) || codegenBinding.isPrivate()) {
                codeStream.invoke(Opcodes.OPC_invokespecial, codegenBinding, constantPoolDeclaringClass, this.typeArguments);
            } else {
                if (constantPoolDeclaringClass.isInterface()) {
                    // interface or annotation type
                    codeStream.invoke(Opcodes.OPC_invokeinterface, codegenBinding, constantPoolDeclaringClass, this.typeArguments);
                } else {
                    codeStream.invoke(Opcodes.OPC_invokevirtual, codegenBinding, constantPoolDeclaringClass, this.typeArguments);
                }
            }
        } else {
            codeStream.generateEmulationForMethod(currentScope, codegenBinding);
            // generate receiver/enclosing instance access
            boolean isStatic = codegenBinding.isStatic();
            // outer access ?
            if (!isStatic && ((this.bits & DepthMASK) != 0)) {
                // not supported yet
                currentScope.problemReporter().needImplementation(this);
            } else {
                this.receiver.generateCode(currentScope, codeStream, !isStatic);
                if ((this.bits & NeedReceiverGenericCast) != 0) {
                    codeStream.checkcast(this.actualReceiverType);
                }
                codeStream.recordPositionsFrom(pc, this.sourceStart);
            }
            if (isStatic) {
                // we need an object on the stack which is ignored for the method invocation
                codeStream.aconst_null();
            }
            // generate arguments
            if (this.arguments != null) {
                int argsLength = this.arguments.length;
                codeStream.generateInlinedValue(argsLength);
                codeStream.newArray(currentScope.createArrayType(currentScope.getType(TypeConstants.JAVA_LANG_OBJECT, 3), 1));
                codeStream.dup();
                for (int i = 0; i < argsLength; i++) {
                    codeStream.generateInlinedValue(i);
                    this.arguments[i].generateCode(currentScope, codeStream, true);
                    TypeBinding parameterBinding = codegenBinding.parameters[i];
                    if (parameterBinding.isBaseType() && parameterBinding != TypeBinding.NULL) {
                        codeStream.generateBoxingConversion(codegenBinding.parameters[i].id);
                    }
                    codeStream.aastore();
                    if (i < argsLength - 1) {
                        codeStream.dup();
                    }
                }
            } else {
                codeStream.generateInlinedValue(0);
                codeStream.newArray(currentScope.createArrayType(currentScope.getType(TypeConstants.JAVA_LANG_OBJECT, 3), 1));
            }
            codeStream.invokeJavaLangReflectMethodInvoke();
            // convert the return value to the appropriate type for primitive types
            if (codegenBinding.returnType.isBaseType()) {
                int typeID = codegenBinding.returnType.id;
                if (typeID == T_void) {
                    // remove the null from the stack
                    codeStream.pop();
                }
                codeStream.checkcast(typeID);
                codeStream.getBaseTypeValue(typeID);
            } else {
                codeStream.checkcast(codegenBinding.returnType);
            }
        }
        // required cast must occur even if no value is required
        if (this.valueCast != null)
            codeStream.checkcast(this.valueCast);
        if (valueRequired) {
            // implicit conversion if necessary
            codeStream.generateImplicitConversion(this.implicitConversion);
        } else {
            boolean isUnboxing = (this.implicitConversion & TypeIds.UNBOXING) != 0;
            // conversion only generated if unboxing
            if (isUnboxing)
                codeStream.generateImplicitConversion(this.implicitConversion);

        }
        // highlight selector
        codeStream.recordPositionsFrom(pc, (int) (this.nameSourcePosition >>> 32));
    }

    @Override
    public void manageSyntheticAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo) {
        if ((flowInfo.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) == 0) {
            // if method from parameterized type got found, use the original method at codegen time
            MethodBinding codegenBinding = this.binding.original();
            if (codegenBinding != this.binding) {
                // extra cast needed if method return type was type variable
                if (codegenBinding.returnType.isTypeVariable()) {
                    TypeVariableBinding variableReturnType = (TypeVariableBinding) codegenBinding.returnType;
                    if (TypeBinding.notEquals(variableReturnType.firstBound, this.binding.returnType)) {
                        // no need for extra cast if same as first bound anyway
                        this.valueCast = this.binding.returnType;
                    }
                }
            }
        }
    }

    @Override
    public TypeBinding resolveType(BlockScope scope) {
        // Answer the signature return type
        // Base type promotion
        if (this.constant != Constant.NotAConstant) {
            this.constant = Constant.NotAConstant;
            boolean receiverCast = false;
            if (this.receiver instanceof CastExpression) {
                // will check later on
                this.receiver.bits |= DisableUnnecessaryCastCheck;
                receiverCast = true;
            }
            this.actualReceiverType = this.receiver.resolveType(scope);
            if (receiverCast && this.actualReceiverType != null) {
                // due to change of declaring class with receiver type, only identity cast should be notified
                if (TypeBinding.equalsEquals(((CastExpression) this.receiver).expression.resolvedType, this.actualReceiverType)) {
                    scope.problemReporter().unnecessaryCast((CastExpression) this.receiver);
                }
            }
            // resolve type arguments (for generic constructor call)
            if (this.typeArguments != null) {
                int length = this.typeArguments.length;
                // typeChecks all arguments
                this.argumentsHaveErrors = false;
                this.genericTypeArguments = new TypeBinding[length];
                for (int i = 0; i < length; i++) {
                    if ((this.genericTypeArguments[i] = this.typeArguments[i].resolveType(scope, true)) == null) {
                        this.argumentsHaveErrors = true;
                    }
                }
                if (this.argumentsHaveErrors) {
                    return null;
                }
            }
            // will check for null after args are resolved
            if (this.arguments != null) {
                // typeChecks all arguments
                this.argumentsHaveErrors = false;
                int length = this.arguments.length;
                this.argumentTypes = new TypeBinding[length];
                for (int i = 0; i < length; i++) {
                    Expression argument = this.arguments[i];
                    if (argument instanceof CastExpression) {
                        // will check later on
                        argument.bits |= DisableUnnecessaryCastCheck;
                        this.argsContainCast = true;
                    }
                    argument.setExpressionContext(INVOCATION_CONTEXT);
                    if ((this.argumentTypes[i] = this.arguments[i].resolveType(scope)) == null)
                        this.argumentsHaveErrors = true;
                }
                if (this.argumentsHaveErrors) {
                    if (this.actualReceiverType instanceof ReferenceBinding) {
                        // record any selector match, for clients who may still need hint about possible method match
                        this.binding = scope.findMethod((ReferenceBinding) this.actualReceiverType, this.selector, new TypeBinding[] {}, this, false);
                    }
                    return null;
                }
            }
            if (this.actualReceiverType == null) {
                return null;
            }
            // base type cannot receive any message
            if (this.actualReceiverType.isBaseType()) {
                scope.problemReporter().errorNoMethodFor(this, this.actualReceiverType, this.argumentTypes);
                return null;
            }
        }
        findMethodBinding(scope);
        if (!this.binding.isValidBinding()) {
            if (this.binding instanceof ProblemMethodBinding && ((ProblemMethodBinding) this.binding).problemId() == ProblemReasons.NotVisible) {
                if (this.evaluationContext.declaringTypeName != null) {
                    this.delegateThis = scope.getField(scope.enclosingSourceType(), EvaluationConstants.DELEGATE_THIS, this);
                    if (this.delegateThis == null) {
                        // if not found then internal error, field should have been found
                        this.constant = Constant.NotAConstant;
                        scope.problemReporter().invalidMethod(this, this.binding, scope);
                        return null;
                    }
                } else {
                    this.constant = Constant.NotAConstant;
                    scope.problemReporter().invalidMethod(this, this.binding, scope);
                    return null;
                }
                CodeSnippetScope localScope = new CodeSnippetScope(scope);
                MethodBinding privateBinding = this.receiver instanceof CodeSnippetThisReference && ((CodeSnippetThisReference) this.receiver).isImplicit ? localScope.getImplicitMethod((ReferenceBinding) this.delegateThis.type, this.selector, this.argumentTypes, this) : localScope.getMethod(this.delegateThis.type, this.selector, this.argumentTypes, this);
                if (!privateBinding.isValidBinding()) {
                    if (this.binding.declaringClass == null) {
                        if (this.actualReceiverType instanceof ReferenceBinding) {
                            this.binding.declaringClass = (ReferenceBinding) this.actualReceiverType;
                        } else {
                            // really bad error ....
                            scope.problemReporter().errorNoMethodFor(this, this.actualReceiverType, this.argumentTypes);
                            return null;
                        }
                    }
                    scope.problemReporter().invalidMethod(this, this.binding, scope);
                    return null;
                } else {
                    this.binding = privateBinding;
                }
            } else {
                if (this.binding.declaringClass == null) {
                    if (this.actualReceiverType instanceof ReferenceBinding) {
                        this.binding.declaringClass = (ReferenceBinding) this.actualReceiverType;
                    } else {
                        // really bad error ....
                        scope.problemReporter().errorNoMethodFor(this, this.actualReceiverType, this.argumentTypes);
                        return null;
                    }
                }
                scope.problemReporter().invalidMethod(this, this.binding, scope);
                return null;
            }
        }
        if (!this.binding.isStatic()) {
            // the "receiver" must not be a type, in other words, a NameReference that the TC has bound to a Type
            if (this.receiver instanceof NameReference && (((NameReference) this.receiver).bits & Binding.TYPE) != 0) {
                scope.problemReporter().mustUseAStaticMethod(this, this.binding);
            } else {
                // handle indirect inheritance thru variable secondary bound
                // receiver may receive generic cast, as part of implicit conversion
                TypeBinding oldReceiverType = this.actualReceiverType;
                this.actualReceiverType = this.actualReceiverType.getErasureCompatibleType(this.binding.declaringClass);
                this.receiver.computeConversion(scope, this.actualReceiverType, this.actualReceiverType);
                if (TypeBinding.notEquals(this.actualReceiverType, oldReceiverType) && TypeBinding.notEquals(this.receiver.postConversionType(scope), this.actualReceiverType)) {
                    // record need for explicit cast at codegen since receiver could not handle it
                    this.bits |= NeedReceiverGenericCast;
                }
            }
        }
        if (checkInvocationArguments(scope, this.receiver, this.actualReceiverType, this.binding, this.arguments, this.argumentTypes, this.argsContainCast, this)) {
            this.bits |= ASTNode.Unchecked;
        }
        // -------message send that are known to fail at compile time-----------
        if (this.binding.isAbstract()) {
            if (this.receiver.isSuper()) {
                scope.problemReporter().cannotDireclyInvokeAbstractMethod(this, this.binding);
            }
            // abstract private methods cannot occur nor abstract static............
        }
        if (isMethodUseDeprecated(this.binding, scope, true))
            scope.problemReporter().deprecatedMethod(this.binding, this);
        // from 1.5 compliance on, array#clone() returns the array type (but binding still shows Object)
        if (this.actualReceiverType.isArrayType() && this.binding.parameters == Binding.NO_PARAMETERS && scope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_5 && CharOperation.equals(this.binding.selector, CLONE)) {
            this.resolvedType = this.actualReceiverType;
        } else {
            TypeBinding returnType = this.binding.returnType;
            if (returnType != null) {
                if ((this.bits & ASTNode.Unchecked) != 0 && this.genericTypeArguments == null) {
                    returnType = scope.environment().convertToRawType(returnType.erasure(), true);
                }
                returnType = returnType.capture(scope, this.sourceStart, this.sourceEnd);
            }
            this.resolvedType = returnType;
        }
        return this.resolvedType;
    }
}


/*
 * Created on Apr 18, 2008
 * Created by Paul Gardner
 *
 *
 */
package com.biglybt.core.crypto;

public interface ClientCryptoListener {

    public char[] getSessionPassword(String reason) throws ClientCryptoException;

    public void sessionPasswordCorrect();

    /**
     * Indicates that the session password returned is incorrect. This is a bad state of
     * affairs and the (probable) only solution is to generate a new public/private key
     * pair
     */