Ignore:
Timestamp:
09/24/11 04:17:48 (13 years ago)
Author:
sherbold
Message:

Work on the SWT GUI prototype. The prototype is still incomplete and should not be used.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/swt/ModelsTabComposite.java

    r192 r194  
    55import org.eclipse.swt.widgets.Button; 
    66import org.eclipse.swt.widgets.List; 
     7import org.eclipse.swt.widgets.MessageBox; 
    78import org.eclipse.swt.layout.GridLayout; 
    89import org.eclipse.swt.layout.GridData; 
    910 
    1011import de.ugoe.cs.eventbench.data.GlobalDataContainer; 
     12import de.ugoe.cs.eventbench.models.FirstOrderMarkovModel; 
     13import de.ugoe.cs.eventbench.models.IDotCompatible; 
     14import de.ugoe.cs.eventbench.models.IStochasticProcess; 
     15import de.ugoe.cs.util.console.CommandExecuter; 
     16 
    1117import org.eclipse.swt.events.SelectionAdapter; 
    1218import org.eclipse.swt.events.SelectionEvent; 
     
    2935                setLayout(new GridLayout(5, false)); 
    3036                 
    31                 modelList = new List(this, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI); 
     37                modelList = new List(this, SWT.BORDER | SWT.V_SCROLL); 
    3238                modelList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 5, 1)); 
    3339                 
    3440                Button btnShow = new Button(this, SWT.NONE); 
     41                btnShow.addSelectionListener(new SelectionAdapter() { 
     42                        @Override 
     43                        public void widgetSelected(SelectionEvent e) { 
     44                                String[] selectedStrings = modelList.getSelection(); 
     45                                if( selectedStrings.length==0 ) { 
     46                                        SWTHelpers.noSelectionError(getShell()); 
     47                                        return; 
     48                                } 
     49                                IStochasticProcess process = (IStochasticProcess) GlobalDataContainer.getInstance().getData(selectedStrings[0]); 
     50                                if( process instanceof FirstOrderMarkovModel ) { 
     51                                        String command = "showMarkovModel " + selectedStrings[0]; 
     52                                        CommandExecuter.getInstance().exec(command); 
     53                                } else { 
     54                                        MessageBox messageBox = new MessageBox(getShell(), SWT.NONE); 
     55                                        messageBox.setText("Feature Not Available"); 
     56                                        messageBox.setMessage("The feature is currently only available for first-order Markov models."); 
     57                                        messageBox.open(); 
     58                                } 
     59                        } 
     60                }); 
    3561                btnShow.setText("Visualize"); 
    3662                 
     
    4975                 
    5076                Button btnGenSequences = new Button(this, SWT.NONE); 
     77                btnGenSequences.addSelectionListener(new SelectionAdapter() { 
     78                        @Override 
     79                        public void widgetSelected(SelectionEvent e) { 
     80                                String[] selectedStrings = modelList.getSelection(); 
     81                                if( selectedStrings.length==0 ) { 
     82                                        SWTHelpers.noSelectionError(getShell()); 
     83                                        return; 
     84                                } 
     85                                GenerateSequencesDialog generateSequencesDialog = new GenerateSequencesDialog(getShell(), SWT.NONE); 
     86                                generateSequencesDialog.setProcessName(selectedStrings[0]); 
     87                                generateSequencesDialog.open(); 
     88                        } 
     89                }); 
    5190                btnGenSequences.setText("Gen. Sequences"); 
    5291                 
    5392                Button btnProperties = new Button(this, SWT.NONE); 
     93                btnProperties.addSelectionListener(new SelectionAdapter() { 
     94                        @Override 
     95                        public void widgetSelected(SelectionEvent e) { 
     96                                String[] selectedStrings = modelList.getSelection(); 
     97                                if( selectedStrings.length==0 ) { 
     98                                        SWTHelpers.noSelectionError(getShell()); 
     99                                        return; 
     100                                } 
     101                                IStochasticProcess process = (IStochasticProcess) GlobalDataContainer.getInstance().getData(selectedStrings[0]); 
     102                                ModelPropertiesDialog modelPropertiesDialog = new ModelPropertiesDialog(getShell(), SWT.NONE); 
     103                                modelPropertiesDialog.setStochasticProcess(process); 
     104                                modelPropertiesDialog.open(); 
     105                        } 
     106                }); 
    54107                btnProperties.setText("Properties"); 
    55108                 
    56109                Button btnCreateDot = new Button(this, SWT.NONE); 
     110                btnCreateDot.addSelectionListener(new SelectionAdapter() { 
     111                        @Override 
     112                        public void widgetSelected(SelectionEvent e) { 
     113                                String[] selectedStrings = modelList.getSelection(); 
     114                                if( selectedStrings.length==0 ) { 
     115                                        SWTHelpers.noSelectionError(getShell()); 
     116                                        return; 
     117                                } 
     118                                IStochasticProcess process = (IStochasticProcess) GlobalDataContainer.getInstance().getData(selectedStrings[0]); 
     119                                String command = ""; 
     120                                if( process instanceof IDotCompatible ) { 
     121                                        command = "printDot "; 
     122                                } else { 
     123                                        command = "printTrieDot "; 
     124                                } 
     125                                command += selectedStrings[0]; 
     126                                CommandExecuter.getInstance().exec(command); 
     127                        } 
     128                }); 
    57129                btnCreateDot.setText("Create DOT"); 
    58130        } 
Note: See TracChangeset for help on using the changeset viewer.