rcp 自定义工具栏

//自定义控件  
 
      class ComboContribution extends ContributionItem{       
             private ToolItem toolitem;  
             private Combo fFindCombo;  
            private Button upFindbutton;  
             private Button downFindbutton;  
             private Button allFindbutton;               
             private Label label;  
             public ComboContribution() {  
                 super();  
             }                    
             protected Control createControl(Composite parent) { 
            int width = parent.getMonitor().getClientArea().width;
            int height = parent.getMonitor().getClientArea().height;
            int x = parent.getSize().x;
            int y = parent.getSize().y;
            if (x > width) {
            parent.getSize().x = width;
            }
            if (y > height) {
            parent.getSize().y = height;
            }
//             Toolkit kit = Toolkit.getDefaultToolkit();
//             Dimension screeSize = kit.getScreenSize();
//             int width = screeSize.width;
            System.out.println("屏幕宽度 : "+width);
//                 Composite composite = new Composite(parent, SWT.NONE);                  
                 parent.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
                 // 语言切换关闭所有的视图再展示
                 PlatformUtils.closeAllView();
              parent.setLayout(new FormLayout());
              
              Composite composite = new Composite(parent,SWT.SHADOW_OUT);
                 composite.setBackground(SWTResourceManager.getColor(220, 20, 60));
                 composite.setLayoutData(new FormData());
                 FormData fd_grpWaybill = new FormData();
                 fd_grpWaybill.bottom = new FormAttachment(0, 50);
          fd_grpWaybill.right = new FormAttachment(100, 0);
          fd_grpWaybill.top = new FormAttachment(0);
          fd_grpWaybill.left = new FormAttachment(0);
          composite.setLayoutData(fd_grpWaybill);
                 //查询框  
          label = new Label(composite, SWT.NONE);
                 fFindCombo = new Combo(composite,SWT.NONE);  
                 fFindCombo.setLocation(0, 2);  
                 fFindCombo.setSize(130,20);  
                 System.out.println(" fFindCombo == " + fFindCombo.getBounds()); 

                 //向上查  
                 upFindbutton = new Button(composite, SWT.NONE);  
                 upFindbutton.setLocation(135, 2);  
                 upFindbutton.setSize(30,20);  
                 upFindbutton.setText("上查");     
                 upFindbutton.addSelectionListener(new SelectionListener(){  
                     public void widgetDefaultSelected(SelectionEvent e) {  
                         // TODO 自动生成方法存根                      
                     }  

                     public void widgetSelected(SelectionEvent e) {  
                         fFindCombo.add(fFindCombo.getText());                           
                    }            
                 });  
                 System.out.println(" upFindbutton == " + upFindbutton.getBounds());  
                 //向下查  
                 downFindbutton = new Button(composite, SWT.NONE);  
                 downFindbutton.setLocation(170, 2);  
                 downFindbutton.setSize(30,20);  
                 downFindbutton.setText("下查");  
                //全部查询  
                 allFindbutton = new Button(composite, SWT.NONE);  
                 allFindbutton.setLocation(205, 2);  
                 allFindbutton.setSize(30,20);  
                 allFindbutton.setText("全部");   
                 toolitem.setWidth(width);  
                 return composite;  
             }
             public void fill(ToolBar parent, int index) {               
                 toolitem = new ToolItem(parent, SWT.SEPARATOR, index);  
                 Control control = createControl(parent);  
                 toolitem.setControl(control);  
             } 
      }

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值