Search in sources :

Example 1 with PkgInfo

use of com.tencent.wstt.apt.data.PkgInfo in project GT by Tencent.

the class DevicesView method createSubTitle.

/**
	 * 
	 * @param parent
	 */
private void createSubTitle(Composite parent) {
    FormData pkgNameLabelFromData = new FormData();
    pkgNameLabelFromData.top = new FormAttachment(0, 5);
    pkgNameLabelFromData.left = new FormAttachment(0, 5);
    pkgNameLabelFromData.right = new FormAttachment(100, -50);
    // 绝对位置
    pkgNameLabelFromData.bottom = new FormAttachment(parent, 30);
    pkgNameText = new Text(parent, SWT.BORDER);
    pkgNameText.setToolTipText("在这里可以手动输入要进行测试的进程名");
    pkgNameText.setBackground(new Color(Display.getCurrent(), 192, 192, 192));
    pkgNameText.setLayoutData(pkgNameLabelFromData);
    FormData addBtnFromData = new FormData();
    addBtnFromData.top = new FormAttachment(0, 5);
    addBtnFromData.left = new FormAttachment(pkgNameText, 5);
    addBtnFromData.right = new FormAttachment(100, -5);
    // 绝对位置
    addBtnFromData.bottom = new FormAttachment(parent, 30);
    addBtn = new Button(parent, SWT.NONE);
    addBtn.setText("添加");
    addBtn.setLayoutData(addBtnFromData);
    addBtn.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (isSupportAddOrDeleteOper) {
                APTState.getInstance().DealWithEventBefore(APTEventEnum.CONFIGRURE_OPER);
                String text = pkgNameText.getText().trim();
                if (text.equals("")) {
                    APTConsoleFactory.getInstance().APTPrint("请输入合法的包名");
                    return;
                }
                PkgInfo dataItem = new PkgInfo();
                dataItem.contents[PkgInfo.NAME_INDEX] = text;
                dataItem.contents[PkgInfo.PID_INDEX] = Constant.PID_NOT_EXSIT;
                addDataItem(targetPkgTableViewer, dataItem);
                APTState.getInstance().DealWithEventAfter(APTEventEnum.CONFIGRURE_OPER);
            } else {
                APTConsoleFactory.getInstance().APTPrint("Operation forbid");
            }
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
}
Also used : FormData(org.eclipse.swt.layout.FormData) Button(org.eclipse.swt.widgets.Button) Color(org.eclipse.swt.graphics.Color) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Text(org.eclipse.swt.widgets.Text) PkgInfo(com.tencent.wstt.apt.data.PkgInfo) FormAttachment(org.eclipse.swt.layout.FormAttachment) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 2 with PkgInfo

use of com.tencent.wstt.apt.data.PkgInfo in project GT by Tencent.

the class DevicesView method createTargetPkgTableView.

/**
	 * 创建被测进程列表
	* @Title: createTargetPkgTableView  
	* @Description:   
	* @param parent 
	* void 
	* @throws
	 */
private void createTargetPkgTableView(Composite parent) {
    targetPkgTableViewer = new TableViewer(parent, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK);
    ctv = new CheckboxTableViewer(targetPkgTableViewer.getTable());
    ctv.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            if (isSupportCheckChangePer) {
                GetCurCheckedStateUtil.update();
            } else {
                APTConsoleFactory.getInstance().APTPrint("Operation forbid");
            }
        }
    });
    // 设置表头内容 
    for (int i = 0; i < TARGET_COLUMN_NAME.length; i++) {
        new TableColumn(targetPkgTableViewer.getTable(), SWT.LEFT).setText(TARGET_COLUMN_NAME[i]);
    }
    targetPkgTableViewer.getTable().getColumn(0).setWidth(200);
    targetPkgTableViewer.getTable().getColumn(1).setWidth(50);
    // 设置表头和表格线可见
    targetPkgTableViewer.getTable().setHeaderVisible(true);
    targetPkgTableViewer.getTable().setLinesVisible(true);
    targetPkgTableViewer.setContentProvider(new ViewContentProvider());
    targetPkgTableViewer.setLabelProvider(new ViewLabelProvider());
    targetPkgTableViewer.getTable().addMouseListener(new MouseListener() {

        @Override
        public void mouseUp(MouseEvent e) {
        }

        @Override
        public void mouseDown(MouseEvent e) {
        }

        @Override
        public void mouseDoubleClick(MouseEvent e) {
            if (isSupportAddOrDeleteOper) {
                APTState.getInstance().DealWithEventBefore(APTEventEnum.CONFIGRURE_OPER);
                TableItem[] selectData = targetPkgTableViewer.getTable().getSelection();
                if (selectData == null || selectData.length == 0) {
                    return;
                }
                PkgInfo itemData = (PkgInfo) selectData[0].getData();
                targetPkgTableViewer.remove(itemData);
                APTState.getInstance().DealWithEventAfter(APTEventEnum.CONFIGRURE_OPER);
            } else {
                APTConsoleFactory.getInstance().APTPrint("Operation forbid");
            }
        }
    });
    targetPkgTableViewer.getTable().setToolTipText("双击或者右键菜单可删除被测进程");
    FormData tableViewFormData = new FormData();
    tableViewFormData.left = new FormAttachment(0, 5);
    tableViewFormData.right = new FormAttachment(100, -5);
    tableViewFormData.top = new FormAttachment(pkgNameText, 10);
    tableViewFormData.height = 125;
    Table table = targetPkgTableViewer.getTable();
    table.setLayoutData(tableViewFormData);
}
Also used : FormData(org.eclipse.swt.layout.FormData) MouseEvent(org.eclipse.swt.events.MouseEvent) Table(org.eclipse.swt.widgets.Table) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) TableColumn(org.eclipse.swt.widgets.TableColumn) PkgInfo(com.tencent.wstt.apt.data.PkgInfo) MouseListener(org.eclipse.swt.events.MouseListener) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 3 with PkgInfo

use of com.tencent.wstt.apt.data.PkgInfo in project GT by Tencent.

the class GetPkgInfosByPsUtil method getPkgInfos.

public static List<PkgInfo> getPkgInfos() {
    APTConsoleFactory.getInstance().APTPrint("GetPkgInfosByPsUtil.getPkgInfos start");
    //TODO 性能问题:每次都new一个list对象
    List<PkgInfo> result = new ArrayList<PkgInfo>();
    String cmdOutputStr = CMDExecute.runCMD(PCInfo.adbShell + " " + PS_CMD);
    if (cmdOutputStr == null) {
        APTConsoleFactory.getInstance().APTPrint("GetPkgInfosByPsUtil.getPkgInfos cmdOutputStr == null");
        return null;
    }
    String[] rows = cmdOutputStr.split(Constant.CMD_RESULT_SPLIT);
    if (rows == null) {
        APTConsoleFactory.getInstance().APTPrint("GetPkgInfosByPsUtil.getPkgInfos rows == null");
        return null;
    }
    for (int i = 0; i < rows.length; i++) {
        String[] columns = rows[i].split(Constant.BLANK_SPLIT);
        if (columns != null && columns.length == TARGETLINEITEMNUMBER) {
            for (String filter : FILTERS) {
                if (columns[USER_INDEX].indexOf(filter) != -1) {
                    PkgInfo item = new PkgInfo();
                    item.contents[PkgInfo.NAME_INDEX] = columns[NAME_INDEX];
                    item.contents[PkgInfo.PID_INDEX] = columns[PID_INDEX];
                    result.add(item);
                    break;
                }
            }
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) PkgInfo(com.tencent.wstt.apt.data.PkgInfo)

Example 4 with PkgInfo

use of com.tencent.wstt.apt.data.PkgInfo in project GT by Tencent.

the class DumpHprofAction method run.

@Override
public void run() {
    DevicesView deviceViewPart = (DevicesView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(DevicesView.ID);
    TableItem[] selectData = deviceViewPart.sourcePkgTableViewer.getTable().getSelection();
    if (selectData == null || selectData.length == 0) {
        APTConsoleFactory.getInstance().APTPrint("进程列表为空");
        return;
    }
    PkgInfo itemData = (PkgInfo) selectData[0].getData();
    final String pkgName = itemData.contents[PkgInfo.NAME_INDEX];
    DDMSUtil.dump(pkgName);
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) DevicesView(com.tencent.wstt.apt.ui.views.DevicesView) PkgInfo(com.tencent.wstt.apt.data.PkgInfo)

Example 5 with PkgInfo

use of com.tencent.wstt.apt.data.PkgInfo in project GT by Tencent.

the class GCAction method run.

@Override
public void run() {
    DevicesView deviceViewPart = (DevicesView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(DevicesView.ID);
    TableItem[] selectData = deviceViewPart.sourcePkgTableViewer.getTable().getSelection();
    if (selectData == null || selectData.length == 0) {
        APTConsoleFactory.getInstance().APTPrint("进程列表为空");
        return;
    }
    PkgInfo itemData = (PkgInfo) selectData[0].getData();
    final String pkgName = itemData.contents[PkgInfo.NAME_INDEX];
    DDMSUtil.gc(pkgName);
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) DevicesView(com.tencent.wstt.apt.ui.views.DevicesView) PkgInfo(com.tencent.wstt.apt.data.PkgInfo)

Aggregations

PkgInfo (com.tencent.wstt.apt.data.PkgInfo)11 TableItem (org.eclipse.swt.widgets.TableItem)5 IOException (java.io.IOException)3 FormAttachment (org.eclipse.swt.layout.FormAttachment)3 FormData (org.eclipse.swt.layout.FormData)3 DevicesView (com.tencent.wstt.apt.ui.views.DevicesView)2 File (java.io.File)2 FileWriter (java.io.FileWriter)2 Date (java.util.Date)2 CheckboxTableViewer (org.eclipse.jface.viewers.CheckboxTableViewer)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 TableViewer (org.eclipse.jface.viewers.TableViewer)2 MouseEvent (org.eclipse.swt.events.MouseEvent)2 MouseListener (org.eclipse.swt.events.MouseListener)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 Table (org.eclipse.swt.widgets.Table)2 TableColumn (org.eclipse.swt.widgets.TableColumn)2 DumpHprofAction (com.tencent.wstt.apt.action.DumpHprofAction)1 GCAction (com.tencent.wstt.apt.action.GCAction)1 GetPMAPInfoAction (com.tencent.wstt.apt.action.GetPMAPInfoAction)1