Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.eclipse.swt.SWT;
- import org.eclipse.swt.layout.GridLayout;
- import org.eclipse.swt.widgets.Display;
- import org.eclipse.swt.widgets.Shell;
- public class Main {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Display display=new Display();
- Shell shell = new Shell(display);
- shell.setLayout(new GridLayout(1,false));
- VisualGraphManager vgm = new VisualGraphManager(shell, SWT.NONE);
- shell.pack();
- shell.open();
- while(!shell.isDisposed()) {
- if(!display.readAndDispatch()) {
- display.sleep();
- }
- }
- vgm.setVisible(true);
- }
- }
- /* ----------------------------------------------------------*/
- import org.eclipse.swt.widgets.Composite;
- import org.eclipse.swt.widgets.Event;
- import java.util.Vector;
- import javax.swing.JTable;
- import javax.swing.table.DefaultTableModel;
- import org.eclipse.swt.SWT;
- import org.eclipse.swt.widgets.Label;
- import org.eclipse.swt.widgets.Listener;
- import org.eclipse.swt.widgets.Text;
- import org.eclipse.swt.widgets.Combo;
- import org.eclipse.swt.widgets.Spinner;
- import org.eclipse.swt.widgets.Button;
- import org.eclipse.swt.widgets.Table;
- import org.eclipse.jface.viewers.TableViewer;
- import org.eclipse.ui.forms.widgets.FormToolkit;
- import org.eclipse.swt.widgets.Display;
- import org.eclipse.swt.widgets.List;
- public class VisualGraphManager extends Composite {
- private Text text;
- private Text text_1;
- private Text text_2;
- private final FormToolkit formToolkit = new FormToolkit(Display.getDefault());
- /**
- * Create the composite.
- * @param parent
- * @param style
- */
- public VisualGraphManager(Composite parent, int style) {
- super(parent, style);
- Composite composite = new Composite(this, SWT.NONE);
- composite.setBounds(0, 20, 479, 217);
- Label lblNameOfThe = new Label(composite, SWT.NONE);
- lblNameOfThe.setBounds(10, 10, 110, 15);
- lblNameOfThe.setText("Name of the Graph");
- text = new Text(composite, SWT.BORDER);
- text.setBounds(10, 28, 459, 21);
- Label lblPathOfThe = new Label(composite, SWT.NONE);
- lblPathOfThe.setBounds(10, 55, 164, 15);
- lblPathOfThe.setText("Path of the destination file");
- text_1 = new Text(composite, SWT.BORDER);
- text_1.setBounds(10, 76, 459, 21);
- Label lblPathOfThe_1 = new Label(composite, SWT.NONE);
- lblPathOfThe_1.setBounds(10, 103, 189, 15);
- lblPathOfThe_1.setText("Path of the image file");
- text_2 = new Text(composite, SWT.BORDER);
- text_2.setBounds(10, 124, 459, 21);
- Label lblGraphType = new Label(composite, SWT.NONE);
- lblGraphType.setBounds(10, 154, 68, 15);
- lblGraphType.setText("Graph type");
- Combo combo = new Combo(composite, SWT.NONE);
- combo.setItems(new String[] {"simple", "directed"});
- combo.setBounds(81, 151, 82, 23);
- Label lblNumberOfVerties = new Label(composite, SWT.NONE);
- lblNumberOfVerties.setBounds(169, 154, 103, 15);
- lblNumberOfVerties.setText("Number of verties");
- Spinner spinner = new Spinner(composite, SWT.BORDER);
- spinner.setBounds(280, 151, 47, 22);
- Label lblNumberOfEdges = new Label(composite, SWT.NONE);
- lblNumberOfEdges.setBounds(333, 154, 93, 15);
- lblNumberOfEdges.setText("Number of edges");
- Spinner spinner_1 = new Spinner(composite, SWT.BORDER);
- spinner_1.setBounds(432, 151, 47, 22);
- List list = new List(this, SWT.BORDER);
- list.setBounds(10, 243, 462, 217);
- formToolkit.adapt(list, true, true);
- Button btnAddToRepository = new Button(composite, SWT.NONE);
- btnAddToRepository.addListener(SWT.Selection, new Listener()
- {
- @Override
- public void handleEvent(Event event)
- {
- String str =text.getText() +"," + combo.getText()+ ",n=" + spinner.getText() + ",m=" + spinner_1.getText() + " [" + text_1.getText() + "] [" + text_2.getText() +"]";
- list.add(str);
- }
- });
- btnAddToRepository.setBounds(169, 182, 116, 25);
- btnAddToRepository.setText("Add to repository");
- Button btnSave = new Button(this, SWT.NONE);
- btnSave.setBounds(125, 470, 75, 25);
- btnSave.setText("Save");
- Button btnLoad = new Button(this, SWT.NONE);
- btnLoad.setBounds(252, 470, 75, 25);
- btnLoad.setText("Load");
- Label lblNewLabel = new Label(this, SWT.NONE);
- lblNewLabel.setBounds(10, 0, 55, 15);
- lblNewLabel.setText("Add graph");
- }
- @Override
- protected void checkSubclass() {
- // Disable the check that prevents subclassing of SWT components
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement