public void createPartControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(2, false));//设置为两格 { Group grpPythonlist = new Group(composite, SWT.NONE); {//水平,竖直填充且抢占 GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); gridData.widthHint = 363; gridData.heightHint = 440; grpPythonlist.setLayoutData(gridData); } grpPythonlist.setText("python List"); grpPythonlist.setLayout(new GridLayout(1,true));//设置1格,否则直接加内容,上不去 makeAction();//初始化各类Action { ToolBar toolBar = new ToolBar(grpPythonlist, SWT.FLAT | SWT.RIGHT); ToolBarManager toolManager = new ToolBarManager(toolBar); toolManager.add(addAction); toolManager.add(clearAction); toolManager.add(deleteAction); toolManager.update(true); } { //CheckboxTableViewer.newCheckList(parent, style) viewer = new CheckboxTreeViewer(grpPythonlist, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); Tree tree = viewer.getTree(); tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); viewer.setContentProvider(new ViewContentProvider()); viewer.setLabelProvider(new ViewLabelProvider()); viewer.setInput(createDummyModel()); viewer.addSelectionChangedListener(new ExecuteTreeSelectionChangeListener()); viewer.expandAll(); } } { Group grpVm = new Group(composite, SWT.NONE); {//同上 GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); gridData.widthHint = 282; grpVm.setLayoutData(gridData); } grpVm.setLayout(new GridLayout(1, true)); grpVm.setText("VM"); { { ToolBar toolBar = new ToolBar(grpVm, SWT.FLAT | SWT.RIGHT); toolBar.setBounds(10, 22, 212, 22); ToolBarManager toolManager = new ToolBarManager(toolBar); toolManager.add(addVmAction); toolManager.add(modifyVmAction); toolManager.add(deleteVmAction); toolManager.update(true); } ipViewer = new CheckboxTreeViewer(grpVm, SWT.BORDER); Tree tree = ipViewer.getTree(); tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); ipViewer.setContentProvider(new ViewContentProvider()); ipViewer.setLabelProvider(new IpViewLabelProvider()); ipViewer.addCheckStateListener(new IPCheckStateListener()); ipViewer.setInput(getIpViewerInputData()); ipViewer.addSelectionChangedListener(new IpViewerSelectionChangeListener()); ipViewer.addDoubleClickListener(new IpViewerDoubleClickListener()); ipViewer.expandAll(); } } }
详细解决方案
viewpart中GridLayout及GridData的运用
热度:108 发布时间:2012-11-10 10:48:50.0
相关解决方案
- swing gridLayout,该怎么处理
- 小应用程序中setLayout(new GridLayout(0,1));是什么意思?解决方法
- 2003转2005的有关问题 <body MS_POSITIONING="GridLayout">
- android的格局-GridLayout(网格布局)
- 请教:java的窗口程序非要用JPanel,GridLayout,JLabel三个吗,能不能用别的呀
- Android基础入门教程——2.2.5 GridLayout(格子布局)
- Android GridLayout 怎么实现空白列
- wince griddata 如何绑定 combobox控件
- GUI 编程【二】 (GridLayout,BorderLayout,将面板作为容器使用)
- 简易计算器布局 BorderLayout JPanel GridLayout 混合
- Android--(9)--详解网格布局(GridLayout)