Ignore:
Timestamp:
08/17/12 11:38:43 (12 years ago)
Author:
sherbold
Message:
  • adapted to quest coding style
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/quest-ui-swt/src/main/java/de/ugoe/cs/quest/ui/swt/InsertAssertionDialog.java

    r548 r570  
     1 
    12package de.ugoe.cs.quest.ui.swt; 
    23 
     
    2122public class InsertAssertionDialog extends Dialog { 
    2223 
    23         protected Event result; 
    24         protected Shell shell; 
    25          
    26         private TabFolder tabFolder; 
    27          
    28         List<AbstractInsertEventComposite> insertEventComposites; 
    29         SortedSet<String> targets; 
     24    protected Event result; 
     25    protected Shell shell; 
    3026 
    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         } 
     27    private TabFolder tabFolder; 
    4128 
    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         } 
     29    List<AbstractInsertEventComposite> insertEventComposites; 
     30    SortedSet<String> targets; 
    6031 
    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         } 
     32    /** 
     33     * Create the dialog. 
     34     *  
     35     * @param parent 
     36     * @param style 
     37     */ 
     38    public InsertAssertionDialog(Shell parent, int style, SortedSet<String> targets) { 
     39        super(parent, style); 
     40        setText("SWT Dialog"); 
     41        this.targets = targets; 
     42    } 
     43 
     44    /** 
     45     * Open the dialog. 
     46     *  
     47     * @return the result 
     48     */ 
     49    public Event open() { 
     50        result = null; 
     51        insertEventComposites = new ArrayList<AbstractInsertEventComposite>(); 
     52        createContents(); 
     53        shell.open(); 
     54        shell.layout(); 
     55        Display display = getParent().getDisplay(); 
     56        while (!shell.isDisposed()) { 
     57            if (!display.readAndDispatch()) { 
     58                display.sleep(); 
     59            } 
     60        } 
     61        return result; 
     62    } 
     63 
     64    /** 
     65     * Create contents of the dialog. 
     66     */ 
     67    private void createContents() { 
     68        shell = new Shell(getParent(), SWT.SHELL_TRIM | SWT.BORDER | SWT.APPLICATION_MODAL); 
     69        shell.setSize(450, 300); 
     70        shell.setText(getText()); 
     71        shell.setLayout(new GridLayout(2, false)); 
     72 
     73        tabFolder = new TabFolder(shell, SWT.NONE); 
     74        tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); 
     75 
     76        TabItem tbtmTextEquals = new TabItem(tabFolder, SWT.NONE); 
     77        tbtmTextEquals.setText("TextEquals"); 
     78        AbstractInsertEventComposite compTextEquals = 
     79            new InsertTextEquals(tabFolder, SWT.NO_BACKGROUND, targets); 
     80        tbtmTextEquals.setControl(compTextEquals); 
     81        insertEventComposites.add(compTextEquals); 
     82 
     83        TabItem tbtmFileEquals = new TabItem(tabFolder, SWT.NONE); 
     84        tbtmFileEquals.setText("FileEquals"); 
     85        AbstractInsertEventComposite compFileEquals = 
     86            new InsertFileEquals(tabFolder, SWT.NO_BACKGROUND, targets); 
     87        tbtmFileEquals.setControl(compFileEquals); 
     88        insertEventComposites.add(compFileEquals); 
     89 
     90        Button btnInsert = new Button(shell, SWT.NONE); 
     91        btnInsert.setText("Insert"); 
     92        btnInsert.addSelectionListener(new SelectionAdapter() { 
     93            @Override 
     94            public void widgetSelected(SelectionEvent e) { 
     95                int index = tabFolder.getSelectionIndex(); 
     96                result = insertEventComposites.get(index).getEvent(); 
     97                shell.dispose(); 
     98            } 
     99        }); 
     100 
     101        Button btnAbort = new Button(shell, SWT.NONE); 
     102        btnAbort.setText("Abort"); 
     103        btnAbort.addSelectionListener(new SelectionAdapter() { 
     104            @Override 
     105            public void widgetSelected(SelectionEvent e) { 
     106                shell.dispose(); 
     107            } 
     108        }); 
     109    } 
    106110} 
Note: See TracChangeset for help on using the changeset viewer.