| 1 | package de.ugoe.cs.eventbench.swt;
|
|---|
| 2 |
|
|---|
| 3 | import org.eclipse.swt.widgets.Composite;
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 | import org.eclipse.swt.SWT;
|
|---|
| 7 | import org.eclipse.swt.widgets.Button;
|
|---|
| 8 | import org.eclipse.swt.widgets.FileDialog;
|
|---|
| 9 | import org.eclipse.swt.widgets.List;
|
|---|
| 10 | import org.eclipse.swt.widgets.MessageBox;
|
|---|
| 11 | import org.eclipse.swt.layout.GridLayout;
|
|---|
| 12 | import org.eclipse.swt.layout.GridData;
|
|---|
| 13 | import org.eclipse.swt.events.SelectionAdapter;
|
|---|
| 14 | import org.eclipse.swt.events.SelectionEvent;
|
|---|
| 15 |
|
|---|
| 16 | import de.ugoe.cs.eventbench.data.GlobalDataContainer;
|
|---|
| 17 | import de.ugoe.cs.util.console.CommandExecuter;
|
|---|
| 18 |
|
|---|
| 19 | public class SequencesTabComposite extends Composite {
|
|---|
| 20 |
|
|---|
| 21 | protected List sequenceList;
|
|---|
| 22 |
|
|---|
| 23 | /**
|
|---|
| 24 | * Create the composite.
|
|---|
| 25 | * @param parent
|
|---|
| 26 | * @param style
|
|---|
| 27 | */
|
|---|
| 28 | public SequencesTabComposite(Composite parent, int style) {
|
|---|
| 29 | super(parent, style);
|
|---|
| 30 | createContents();
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | private void createContents() {
|
|---|
| 34 | setLayout(new GridLayout(5, false));
|
|---|
| 35 |
|
|---|
| 36 | sequenceList = new List(this, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI);
|
|---|
| 37 | sequenceList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 5, 1));
|
|---|
| 38 | sequenceList.setItems(new String[] {});
|
|---|
| 39 |
|
|---|
| 40 | Button btnEdit = new Button(this, SWT.NONE);
|
|---|
| 41 | btnEdit.addSelectionListener(new SelectionAdapter() {
|
|---|
| 42 | @Override
|
|---|
| 43 | public void widgetSelected(SelectionEvent e) {
|
|---|
| 44 | // TODO implement edit sequences.
|
|---|
| 45 | MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_INFORMATION);
|
|---|
| 46 | messageBox.setText("Not implemented!");
|
|---|
| 47 | messageBox.setMessage("Sorry! This functionality has not been implemented yet!");
|
|---|
| 48 | messageBox.open();
|
|---|
| 49 | }
|
|---|
| 50 | });
|
|---|
| 51 | btnEdit.setText("Edit");
|
|---|
| 52 |
|
|---|
| 53 | Button btnDelete = new Button(this, SWT.NONE);
|
|---|
| 54 | btnDelete.addSelectionListener(new SelectionAdapter() {
|
|---|
| 55 | @Override
|
|---|
| 56 | public void widgetSelected(SelectionEvent e) {
|
|---|
| 57 | if( SWTHelpers.deleteSelectedFromStorage(sequenceList)) {
|
|---|
| 58 | updateSequenceList();
|
|---|
| 59 | } else {
|
|---|
| 60 | SWTHelpers.noSelectionError(getShell());
|
|---|
| 61 | }
|
|---|
| 62 | }
|
|---|
| 63 | });
|
|---|
| 64 | btnDelete.setText("Delete");
|
|---|
| 65 |
|
|---|
| 66 | Button btnReplay = new Button(this, SWT.NONE);
|
|---|
| 67 | btnReplay.addSelectionListener(new SelectionAdapter() {
|
|---|
| 68 | @Override
|
|---|
| 69 | public void widgetSelected(SelectionEvent e) {
|
|---|
| 70 | String[] selectedSequences = sequenceList.getSelection();
|
|---|
| 71 | if( selectedSequences.length==0 ) {
|
|---|
| 72 | SWTHelpers.noSelectionError(getShell());
|
|---|
| 73 | } else {
|
|---|
| 74 | StringBuilder commandString = new StringBuilder("generateReplayfile ");
|
|---|
| 75 | FileDialog fileDialog = new FileDialog(getShell());
|
|---|
| 76 | String filename = fileDialog.open();
|
|---|
| 77 | commandString.append(filename + " ");
|
|---|
| 78 | for( String selected : selectedSequences ) {
|
|---|
| 79 | commandString.append(selected + " ");
|
|---|
| 80 | }
|
|---|
| 81 | CommandExecuter.getInstance().exec(commandString.toString().trim());
|
|---|
| 82 | }
|
|---|
| 83 | }
|
|---|
| 84 | });
|
|---|
| 85 | btnReplay.setText("Replay");
|
|---|
| 86 |
|
|---|
| 87 | Button btnTrainModel = new Button(this, SWT.NONE);
|
|---|
| 88 | btnTrainModel.addSelectionListener(new SelectionAdapter() {
|
|---|
| 89 | @Override
|
|---|
| 90 | public void widgetSelected(SelectionEvent e) {
|
|---|
| 91 | String[] selectedSequences = sequenceList.getSelection();
|
|---|
| 92 | if( selectedSequences.length==0 ) {
|
|---|
| 93 | SWTHelpers.noSelectionError(getShell());
|
|---|
| 94 | } else {
|
|---|
| 95 | TrainModelDialog trainDialog = new TrainModelDialog(getShell(), SWT.NONE);
|
|---|
| 96 | trainDialog.setSequenceNames(selectedSequences);
|
|---|
| 97 | trainDialog.open();
|
|---|
| 98 | }
|
|---|
| 99 | }
|
|---|
| 100 | });
|
|---|
| 101 | btnTrainModel.setText("Train Model");
|
|---|
| 102 |
|
|---|
| 103 | Button btnParse = new Button(this, SWT.NONE);
|
|---|
| 104 | btnParse.addSelectionListener(new SelectionAdapter() {
|
|---|
| 105 | @Override
|
|---|
| 106 | public void widgetSelected(SelectionEvent e) {
|
|---|
| 107 | // TODO implement parsing of sequences
|
|---|
| 108 | MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_INFORMATION);
|
|---|
| 109 | messageBox.setText("Not implemented!");
|
|---|
| 110 | messageBox.setMessage("Sorry! This functionality has not been implemented yet!");
|
|---|
| 111 | messageBox.open();
|
|---|
| 112 | }
|
|---|
| 113 | });
|
|---|
| 114 | btnParse.setText("Parse");
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | public void updateSequenceList() {
|
|---|
| 118 | sequenceList.removeAll();
|
|---|
| 119 | for( String sequencesName : GlobalDataContainer.getInstance().getAllSequencesNames() ) {
|
|---|
| 120 | sequenceList.add(sequencesName);
|
|---|
| 121 | }
|
|---|
| 122 | }
|
|---|
| 123 |
|
|---|
| 124 | @Override
|
|---|
| 125 | protected void checkSubclass() {
|
|---|
| 126 | // Disable the check that prevents subclassing of SWT components
|
|---|
| 127 | }
|
|---|
| 128 |
|
|---|
| 129 | }
|
|---|