source: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/swt/SequencesTabComposite.java @ 195

Last change on this file since 195 was 195, checked in by sherbold, 13 years ago

Further work on the SWT GUI prototype.
The GUI is still not finished, however, most features are implemented and the GUI can be used. It may cause some problems, and some features are still missing.

  • Property svn:mime-type set to text/plain
File size: 4.1 KB
Line 
1package de.ugoe.cs.eventbench.swt;
2
3import org.eclipse.swt.widgets.Composite;
4
5
6import org.eclipse.swt.SWT;
7import org.eclipse.swt.widgets.Button;
8import org.eclipse.swt.widgets.FileDialog;
9import org.eclipse.swt.widgets.List;
10import org.eclipse.swt.widgets.MessageBox;
11import org.eclipse.swt.layout.GridLayout;
12import org.eclipse.swt.layout.GridData;
13import org.eclipse.swt.events.SelectionAdapter;
14import org.eclipse.swt.events.SelectionEvent;
15
16import de.ugoe.cs.eventbench.data.GlobalDataContainer;
17import de.ugoe.cs.util.console.CommandExecuter;
18
19public 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}
Note: See TracBrowser for help on using the repository browser.