source: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/swt/InsertAssertionDialog.java @ 404

Last change on this file since 404 was 230, checked in by sherbold, 13 years ago
  • extended SWT-GUI with dialogs for editing sequences and adding of assertions

Comment for Revision 229 (comment missing due to Subversive bug):

  • changed de.ugoe.cs.eventbench.assertions.FileEqualsReplay? and de.ugoe.cs.eventbench.assertions.TextEqualsReplay? such that the actual and expected values are now defined via the constructor
  • changed storage method for targets that are found during the parsing of MFC usage log files. If the sequences are stored in the variable "seqsName" the targets are stored in the variable "seqsName_targets"
  • adapted classes in de.ugoe.cs.eventbench.swing to the changes above
  • marked the classes in de.ugoe.cs.eventbench.swing as deprecated as the Swing GUI will not be part of further maintenance. Use the SWT GUI instead.
  • Property svn:mime-type set to text/plain
File size: 3.1 KB
Line 
1package de.ugoe.cs.eventbench.swt;
2
3import java.util.ArrayList;
4import java.util.List;
5import java.util.SortedSet;
6
7import org.eclipse.swt.widgets.Dialog;
8import org.eclipse.swt.widgets.Display;
9import org.eclipse.swt.widgets.Shell;
10import org.eclipse.swt.events.SelectionAdapter;
11import org.eclipse.swt.events.SelectionEvent;
12import org.eclipse.swt.layout.GridLayout;
13import org.eclipse.swt.widgets.TabFolder;
14import org.eclipse.swt.SWT;
15import org.eclipse.swt.widgets.TabItem;
16import org.eclipse.swt.layout.GridData;
17import org.eclipse.swt.widgets.Button;
18
19import de.ugoe.cs.eventbench.data.Event;
20
21public class InsertAssertionDialog extends Dialog {
22
23        protected Event<?> result;
24        protected Shell shell;
25       
26        private TabFolder tabFolder;
27       
28        List<AbstractInsertEventComposite> insertEventComposites;
29        SortedSet<String> targets;
30
31        /**
32         * Create the dialog.
33         * @param parent
34         * @param style
35         */
36        public InsertAssertionDialog(Shell parent, int style, SortedSet<String> targets) {
37                super(parent, style);
38                setText("SWT Dialog");
39                this.targets = targets;
40        }
41
42        /**
43         * Open the dialog.
44         * @return the result
45         */
46        public Event<?> open() {
47                result = null;
48                insertEventComposites = new ArrayList<AbstractInsertEventComposite>();
49                createContents();
50                shell.open();
51                shell.layout();
52                Display display = getParent().getDisplay();
53                while (!shell.isDisposed()) {
54                        if (!display.readAndDispatch()) {
55                                display.sleep();
56                        }
57                }
58                return result;
59        }
60
61        /**
62         * Create contents of the dialog.
63         */
64        private void createContents() {
65                shell = new Shell(getParent(), SWT.SHELL_TRIM | SWT.BORDER | SWT.APPLICATION_MODAL);
66                shell.setSize(450, 300);
67                shell.setText(getText());
68                shell.setLayout(new GridLayout(2, false));
69               
70                tabFolder = new TabFolder(shell, SWT.NONE);
71                tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
72               
73               
74                TabItem tbtmTextEquals = new TabItem(tabFolder, SWT.NONE);
75                tbtmTextEquals.setText("TextEquals");
76                AbstractInsertEventComposite compTextEquals = new InsertTextEquals(tabFolder, SWT.NO_BACKGROUND, targets);
77                tbtmTextEquals.setControl(compTextEquals);
78                insertEventComposites.add(compTextEquals);
79               
80                TabItem tbtmFileEquals = new TabItem(tabFolder, SWT.NONE);
81                tbtmFileEquals.setText("FileEquals");
82                AbstractInsertEventComposite compFileEquals = new InsertFileEquals(tabFolder, SWT.NO_BACKGROUND, targets);
83                tbtmFileEquals.setControl(compFileEquals);
84                insertEventComposites.add(compFileEquals);
85               
86                Button btnInsert = new Button(shell, SWT.NONE);
87                btnInsert.setText("Insert");
88                btnInsert.addSelectionListener(new SelectionAdapter() {
89                        @Override
90                        public void widgetSelected(SelectionEvent e) {
91                                int index = tabFolder.getSelectionIndex();
92                                result = insertEventComposites.get(index).getEvent();
93                                shell.dispose();
94                        }
95                });
96               
97                Button btnAbort = new Button(shell, SWT.NONE);
98                btnAbort.setText("Abort");
99                btnAbort.addSelectionListener(new SelectionAdapter() {
100                        @Override
101                        public void widgetSelected(SelectionEvent e) {
102                                shell.dispose();
103                        }
104                });
105        }
106}
Note: See TracBrowser for help on using the repository browser.