source: trunk/autoquest-ui-swt/src/main/java/de/ugoe/cs/autoquest/ui/swt/InsertFileEquals.java @ 927

Last change on this file since 927 was 927, checked in by sherbold, 12 years ago
  • added copyright under the Apache License, Version 2.0
  • Property svn:mime-type set to text/plain
File size: 3.5 KB
Line 
1//   Copyright 2012 Georg-August-Universität Göttingen, Germany
2//
3//   Licensed under the Apache License, Version 2.0 (the "License");
4//   you may not use this file except in compliance with the License.
5//   You may obtain a copy of the License at
6//
7//       http://www.apache.org/licenses/LICENSE-2.0
8//
9//   Unless required by applicable law or agreed to in writing, software
10//   distributed under the License is distributed on an "AS IS" BASIS,
11//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//   See the License for the specific language governing permissions and
13//   limitations under the License.
14
15package de.ugoe.cs.autoquest.ui.swt;
16
17import org.eclipse.swt.widgets.Composite;
18import org.eclipse.swt.widgets.FileDialog;
19import org.eclipse.swt.layout.GridLayout;
20import org.eclipse.swt.widgets.Label;
21import org.eclipse.swt.SWT;
22import org.eclipse.swt.widgets.Text;
23import org.eclipse.swt.layout.GridData;
24import org.eclipse.swt.widgets.Button;
25
26import de.ugoe.cs.autoquest.assertions.FileEqualsAssertEventType;
27import de.ugoe.cs.autoquest.assertions.FileEqualsReplay;
28import de.ugoe.cs.autoquest.eventcore.Event;
29import de.ugoe.cs.autoquest.eventcore.guimodel.GUIModel;
30
31import org.eclipse.swt.events.SelectionAdapter;
32import org.eclipse.swt.events.SelectionEvent;
33
34public class InsertFileEquals extends AbstractInsertEventComposite {
35    private Text actualText;
36    private Text expectedText;
37
38    public InsertFileEquals(Composite parent, int style) {
39        this(parent, style, null);
40    }
41
42    /**
43     * Create the composite.
44     *
45     * @param parent
46     * @param style
47     */
48    public InsertFileEquals(Composite parent, int style, GUIModel guiModel) {
49        super(parent, style, guiModel);
50        setLayout(new GridLayout(3, false));
51
52        Label lblExpectedFile = new Label(this, SWT.NONE);
53        lblExpectedFile.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
54        lblExpectedFile.setText("Expected file:");
55
56        expectedText = new Text(this, SWT.BORDER);
57        expectedText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
58
59        Button btnSearch = new Button(this, SWT.NONE);
60        btnSearch.addSelectionListener(new SelectionAdapter() {
61            @Override
62            public void widgetSelected(SelectionEvent e) {
63                FileDialog fileDialog = new FileDialog(getShell(), SWT.OPEN);
64                String filename = fileDialog.open();
65                if (filename != null) {
66                    expectedText.setText(filename);
67                }
68            }
69        });
70        btnSearch.setText("Search...");
71
72        Label lblActualFile = new Label(this, SWT.NONE);
73
74        lblActualFile.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
75        lblActualFile.setText("Actual file:");
76
77        actualText = new Text(this, SWT.BORDER);
78        actualText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
79        new Label(this, SWT.NONE);
80
81    }
82
83    @Override
84    protected void checkSubclass() {
85        // Disable the check that prevents subclassing of SWT components
86    }
87
88    @Override
89    public Event getEvent() {
90        FileEqualsReplay replay =
91            new FileEqualsReplay(expectedText.getText(), actualText.getText());
92        Event event = new Event(new FileEqualsAssertEventType());
93        event.addReplayable(replay);
94        return event;
95    }
96
97}
Note: See TracBrowser for help on using the repository browser.