Search in sources :

Example 1 with PMAPFileParse

use of com.tencent.wstt.apt.util.PMAPFileParse in project GT by Tencent.

the class PMAPView method makeActions.

/**
	 * 初始化Action
	 */
private void makeActions() {
    openLogAction = new Action() {

        public void run() {
            FileDialog dialog = new FileDialog(Display.getDefault().getActiveShell(), SWT.OPEN | SWT.MULTI);
            //设置初始路径
            dialog.setFilterPath(Constant.LOG_FOLDER_ON_PC);
            //返回的全路径(路径+文件名)
            String fileName = dialog.open();
            if (fileName == null) {
                return;
            }
            String path = dialog.getFilterPath();
            String[] fileNames = dialog.getFileNames();
            int fileNum = fileNames.length;
            if (fileNum > 2) {
                MessageDialog.openInformation(Display.getDefault().getActiveShell(), "提示", "不支持同时打开超过2个pmap文件");
                return;
            }
            PMAPFileParse parse = new PMAPFileParse();
            if (fileNum == 1) {
                Map<String, Integer> pmapResult = null;
                if ((pmapResult = parse.parse(fileName)) == null) {
                    return;
                }
                createCTabItem(fileNames[0], pmapResult);
            } else {
                String file1 = path + File.separator + fileNames[0];
                String file2 = path + File.separator + fileNames[1];
                Map<String, Integer> file1Map = parse.parse(file1);
                Map<String, Integer> file2Map = parse.parse(file2);
                if (file1Map == null || file2Map == null) {
                    return;
                }
                Map<String, Integer> pmapResult = MapUtil.sub(file2Map, file1Map);
                createCTabItem(fileNames[0], file1Map);
                createCTabItem(fileNames[1], file2Map);
                createCTabItem(getMergeFileName(fileNames[0], fileNames[1]), pmapResult);
            }
        }
    };
    openLogAction.setText("打开pmap文件");
    openLogAction.setToolTipText("打开pmap文件");
    openLogAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/open_pc.png"));
}
Also used : Action(org.eclipse.jface.action.Action) FileDialog(org.eclipse.swt.widgets.FileDialog) PMAPFileParse(com.tencent.wstt.apt.util.PMAPFileParse) Map(java.util.Map)

Aggregations

PMAPFileParse (com.tencent.wstt.apt.util.PMAPFileParse)1 Map (java.util.Map)1 Action (org.eclipse.jface.action.Action)1 FileDialog (org.eclipse.swt.widgets.FileDialog)1