Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2014
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. public class SampleDialog extends TrayDialog {
  2.  
  3. public SampleDialog(final Shell shell) {
  4. super(shell);
  5. this.shell = shell;
  6.  
  7. }
  8.  
  9.  
  10. @Override
  11. public void create() {
  12. super.create();
  13.  
  14. }
  15.  
  16. @Override
  17. protected Control createDialogArea(final Composite parent) {
  18. final GridLayout layout = new GridLayout();
  19. layout.numColumns = 1;
  20. parent.setLayout(layout);
  21.  
  22. final ScrolledComposite sc1 = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.BORDER);
  23. sc1.setExpandHorizontal(true);
  24. sc1.setExpandVertical(true);
  25. //sc1.setMinWidth(0);
  26.  
  27. final Composite composite = new Composite(sc1, SWT.NONE);
  28. final GridLayout gridLayout = new GridLayout();
  29. gridLayout.numColumns = 2;
  30. composite.setLayout(gridLayout);
  31.  
  32. sc1.setContent(composite);
  33.  
  34. //this.sc1.setMinSize(parent.computeSize(SWT.DEFAULT, SWT.DEFAULT));
  35. //this.sc1.setMinHeight(50);
  36. //this.sc1.setAlwaysShowScrollBars(true);
  37.  
  38. sc1.addControlListener(new ControlAdapter() {
  39. @Override
  40. public void controlResized(final ControlEvent e) {
  41. final Rectangle r = sc1.getClientArea();
  42. sc1.setMinSize(parent.computeSize(r.width, SWT.DEFAULT));
  43. }
  44. });
  45. final GridData gridDataLabel = new GridData();
  46. final Label label = new Label(composite, SWT.NONE);
  47. label.setText("Testing");
  48. label.setLayoutData(gridDataLabel);
  49. for (i = 0 ; i <= n ; i++) { // n can be 1 to any number -- decided at run time
  50. createSampleCombo(composite);
  51. }
  52. }
  53.  
  54. public void createSampleCombo(Composite parent) {
  55. final Composite composite = new Composite(parent, SWT.NONE);
  56. final GridLayout layout = new GridLayout();
  57. layout.numColumns = 3;
  58. composite.setLayout(layout);
  59.  
  60. final GridData gridDataCombo = new GridData();
  61. gridDataCombo.horizontalAlignment = GridData.FILL;
  62. gridDataCombo.grabExcessHorizontalSpace = true;
  63.  
  64. final Combo myCombo = new Combo(composite, SWT.NONE);
  65. myCombo.setLayoutData(gridDataCombo);
  66. gridDataCombo.minimumWidth = 500;
  67.  
  68. final GridData gridDataButton = new GridData();
  69. final Button browse = new Button(composite, SWT.PUSH);
  70. browse.setText("Browse");
  71. browse.setLayoutData(gridDataButton);
  72. }
  73. }
  74.  
  75. where:
  76. org.eclipse.jface.dialogs.TrayDialog;
  77. org.eclipse.swt.layout.GridLayout;
  78.  
  79. sc1.setExpandVertical( false );
  80.  
  81. Rectangle clientArea = scrolledComposite.getClientArea();
  82. Point minSize = scrolledComposite.getContent().computeSize( clientArea.width, SWT.DEFAULT );
  83. scrolledComposite.getContent().setSize( minSize );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement