Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.43 KB | None | 0 0
  1.  
  2.  
  3. import org.eclipse.swt.SWT;
  4. import org.eclipse.swt.layout.GridLayout;
  5. import org.eclipse.swt.widgets.Display;
  6. import org.eclipse.swt.widgets.Shell;
  7.  
  8. public class Main {
  9.  
  10. public static void main(String[] args) {
  11. // TODO Auto-generated method stub
  12. Display display=new Display();
  13. Shell shell = new Shell(display);
  14. shell.setLayout(new GridLayout(1,false));
  15. VisualGraphManager vgm = new VisualGraphManager(shell, SWT.NONE);
  16. shell.pack();
  17. shell.open();
  18. while(!shell.isDisposed()) {
  19. if(!display.readAndDispatch()) {
  20. display.sleep();
  21. }
  22. }
  23. vgm.setVisible(true);
  24. }
  25.  
  26. }
  27.  
  28.  
  29. /* ----------------------------------------------------------*/
  30.  
  31. import org.eclipse.swt.widgets.Composite;
  32. import org.eclipse.swt.widgets.Event;
  33.  
  34. import java.util.Vector;
  35.  
  36. import javax.swing.JTable;
  37. import javax.swing.table.DefaultTableModel;
  38.  
  39. import org.eclipse.swt.SWT;
  40. import org.eclipse.swt.widgets.Label;
  41. import org.eclipse.swt.widgets.Listener;
  42. import org.eclipse.swt.widgets.Text;
  43. import org.eclipse.swt.widgets.Combo;
  44. import org.eclipse.swt.widgets.Spinner;
  45. import org.eclipse.swt.widgets.Button;
  46. import org.eclipse.swt.widgets.Table;
  47. import org.eclipse.jface.viewers.TableViewer;
  48. import org.eclipse.ui.forms.widgets.FormToolkit;
  49. import org.eclipse.swt.widgets.Display;
  50. import org.eclipse.swt.widgets.List;
  51.  
  52. public class VisualGraphManager extends Composite {
  53. private Text text;
  54. private Text text_1;
  55. private Text text_2;
  56. private final FormToolkit formToolkit = new FormToolkit(Display.getDefault());
  57. /**
  58. * Create the composite.
  59. * @param parent
  60. * @param style
  61. */
  62. public VisualGraphManager(Composite parent, int style) {
  63. super(parent, style);
  64.  
  65. Composite composite = new Composite(this, SWT.NONE);
  66. composite.setBounds(0, 20, 479, 217);
  67.  
  68. Label lblNameOfThe = new Label(composite, SWT.NONE);
  69. lblNameOfThe.setBounds(10, 10, 110, 15);
  70. lblNameOfThe.setText("Name of the Graph");
  71.  
  72. text = new Text(composite, SWT.BORDER);
  73. text.setBounds(10, 28, 459, 21);
  74.  
  75. Label lblPathOfThe = new Label(composite, SWT.NONE);
  76. lblPathOfThe.setBounds(10, 55, 164, 15);
  77. lblPathOfThe.setText("Path of the destination file");
  78.  
  79. text_1 = new Text(composite, SWT.BORDER);
  80. text_1.setBounds(10, 76, 459, 21);
  81.  
  82. Label lblPathOfThe_1 = new Label(composite, SWT.NONE);
  83. lblPathOfThe_1.setBounds(10, 103, 189, 15);
  84. lblPathOfThe_1.setText("Path of the image file");
  85.  
  86. text_2 = new Text(composite, SWT.BORDER);
  87. text_2.setBounds(10, 124, 459, 21);
  88.  
  89. Label lblGraphType = new Label(composite, SWT.NONE);
  90. lblGraphType.setBounds(10, 154, 68, 15);
  91. lblGraphType.setText("Graph type");
  92.  
  93. Combo combo = new Combo(composite, SWT.NONE);
  94. combo.setItems(new String[] {"simple", "directed"});
  95. combo.setBounds(81, 151, 82, 23);
  96.  
  97. Label lblNumberOfVerties = new Label(composite, SWT.NONE);
  98. lblNumberOfVerties.setBounds(169, 154, 103, 15);
  99. lblNumberOfVerties.setText("Number of verties");
  100.  
  101. Spinner spinner = new Spinner(composite, SWT.BORDER);
  102. spinner.setBounds(280, 151, 47, 22);
  103.  
  104. Label lblNumberOfEdges = new Label(composite, SWT.NONE);
  105. lblNumberOfEdges.setBounds(333, 154, 93, 15);
  106. lblNumberOfEdges.setText("Number of edges");
  107.  
  108. Spinner spinner_1 = new Spinner(composite, SWT.BORDER);
  109. spinner_1.setBounds(432, 151, 47, 22);
  110.  
  111. List list = new List(this, SWT.BORDER);
  112. list.setBounds(10, 243, 462, 217);
  113. formToolkit.adapt(list, true, true);
  114.  
  115. Button btnAddToRepository = new Button(composite, SWT.NONE);
  116. btnAddToRepository.addListener(SWT.Selection, new Listener()
  117. {
  118. @Override
  119. public void handleEvent(Event event)
  120. {
  121. String str =text.getText() +"," + combo.getText()+ ",n=" + spinner.getText() + ",m=" + spinner_1.getText() + " [" + text_1.getText() + "] [" + text_2.getText() +"]";
  122. list.add(str);
  123.  
  124. }
  125. });
  126. btnAddToRepository.setBounds(169, 182, 116, 25);
  127. btnAddToRepository.setText("Add to repository");
  128.  
  129. Button btnSave = new Button(this, SWT.NONE);
  130. btnSave.setBounds(125, 470, 75, 25);
  131. btnSave.setText("Save");
  132.  
  133. Button btnLoad = new Button(this, SWT.NONE);
  134. btnLoad.setBounds(252, 470, 75, 25);
  135. btnLoad.setText("Load");
  136.  
  137. Label lblNewLabel = new Label(this, SWT.NONE);
  138. lblNewLabel.setBounds(10, 0, 55, 15);
  139. lblNewLabel.setText("Add graph");
  140. }
  141.  
  142. @Override
  143. protected void checkSubclass() {
  144. // Disable the check that prevents subclassing of SWT components
  145. }
  146. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement