Changeset 238 for trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/swt
- Timestamp:
- 10/05/11 04:32:06 (13 years ago)
- Location:
- trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/swt
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/swt/ConsoleTabComposite.java
r195 r238 8 8 import org.eclipse.swt.layout.GridLayout; 9 9 import org.eclipse.swt.layout.GridData; 10 import org.eclipse.swt.custom.StyledText; 10 11 import org.eclipse.swt.events.SelectionAdapter; 11 12 import org.eclipse.swt.events.SelectionEvent; … … 29 30 protected Text textCommand; 30 31 31 protected Text textConsoleOutput;32 protected StyledText textConsoleOutput; 32 33 33 34 /** … … 69 70 btnEnter.setText("Enter"); 70 71 71 textConsoleOutput = new Text(this, SWT.BORDER | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL);72 textConsoleOutput = new StyledText(this, SWT.BORDER | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL); 72 73 GridData gd_textConsoleOutput = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1); 73 74 gd_textConsoleOutput.heightHint = 102; -
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/swt/MainWindow.java
r195 r238 7 7 import org.eclipse.swt.widgets.FileDialog; 8 8 import org.eclipse.swt.widgets.MenuItem; 9 import org.eclipse.swt.widgets.Text;10 9 import org.eclipse.swt.widgets.TabFolder; 11 10 import org.eclipse.swt.widgets.TabItem; … … 17 16 import de.ugoe.cs.util.console.CommandExecuter; 18 17 18 /** 19 * <p> 20 * Main window of the SWT GUI. 21 * </p> 22 * 23 * @author Steffen Herbold 24 * @version 1.0 25 */ 19 26 public class MainWindow { 20 27 21 protected Shell sh ell;22 28 protected Shell shlEventbenchConsole; 29 23 30 protected TabItem consoleTab; 24 31 protected TabItem sequencesTab; … … 29 36 protected ModelsTabComposite modelsTabComposite; 30 37 protected DataTabComposite dataTabComposite; 31 38 32 39 protected CommandHistoryDialog historyDialog; 33 40 34 35 /**41 /** 42 * <p> 36 43 * Open the window. 44 * </p> 45 * 37 46 * @wbp.parser.entryPoint 38 47 */ … … 40 49 Display display = Display.getDefault(); 41 50 createContents(); 42 new SWTConsole( getTextConsoleOutput());43 historyDialog = new CommandHistoryDialog(sh ell, SWT.NONE);44 sh ell.open();45 sh ell.layout();46 while (!sh ell.isDisposed()) {51 new SWTConsole(consoleTabComposite.textConsoleOutput); 52 historyDialog = new CommandHistoryDialog(shlEventbenchConsole, SWT.NONE); 53 shlEventbenchConsole.open(); 54 shlEventbenchConsole.layout(); 55 while (!shlEventbenchConsole.isDisposed()) { 47 56 if (!display.readAndDispatch()) { 48 57 display.sleep(); … … 52 61 53 62 /** 63 * <p> 54 64 * Create contents of the window. 65 * </p> 55 66 */ 56 67 protected void createContents() { 57 shell = new Shell(); 58 shell.setSize(500, 300); 59 shell.setText("SWT Application"); 60 shell.setLayout(new GridLayout(1, false)); 61 62 Menu menu = new Menu(shell, SWT.BAR); 63 shell.setMenuBar(menu); 64 68 shlEventbenchConsole = new Shell(); 69 shlEventbenchConsole.setSize(500, 300); 70 shlEventbenchConsole.setText("EventBench Console"); 71 shlEventbenchConsole.setLayout(new GridLayout(1, false)); 72 73 createMenu(); 74 createTabs(); 75 } 76 77 /** 78 * </p> Creates the menu of the window. </p> 79 */ 80 private void createMenu() { 81 Menu menu = new Menu(shlEventbenchConsole, SWT.BAR); 82 shlEventbenchConsole.setMenuBar(menu); 83 65 84 MenuItem mntmFile = new MenuItem(menu, SWT.CASCADE); 66 85 mntmFile.setText("File"); 67 86 68 87 Menu menu_1 = new Menu(mntmFile); 69 88 mntmFile.setMenu(menu_1); 70 89 71 90 MenuItem mntmShowHistory = new MenuItem(menu_1, SWT.NONE); 72 91 mntmShowHistory.addSelectionListener(new SelectionAdapter() { 73 92 @Override 74 93 public void widgetSelected(SelectionEvent e) { 75 if (!historyDialog.isOpen()) {94 if (!historyDialog.isOpen()) { 76 95 historyDialog.open(); 77 96 } … … 79 98 }); 80 99 mntmShowHistory.setText("Show History"); 81 100 82 101 MenuItem mntmExecBatchFile = new MenuItem(menu_1, SWT.NONE); 83 102 mntmExecBatchFile.addSelectionListener(new SelectionAdapter() { 84 103 @Override 85 104 public void widgetSelected(SelectionEvent e) { 86 FileDialog fileDialog = new FileDialog(shell, SWT.OPEN); 105 FileDialog fileDialog = new FileDialog(shlEventbenchConsole, 106 SWT.OPEN); 87 107 String filename = fileDialog.open(); 88 if ( filename!=null) {108 if (filename != null) { 89 109 String command = "exec '" + filename + "'"; 90 110 CommandExecuter.getInstance().exec(command); … … 93 113 }); 94 114 mntmExecBatchFile.setText("Exec. Batch File"); 95 115 96 116 new MenuItem(menu_1, SWT.SEPARATOR); 97 117 98 118 MenuItem mntmLoad = new MenuItem(menu_1, SWT.NONE); 99 119 mntmLoad.addSelectionListener(new SelectionAdapter() { 100 120 @Override 101 121 public void widgetSelected(SelectionEvent e) { 102 FileDialog fileDialog = new FileDialog(shell, SWT.OPEN); 122 FileDialog fileDialog = new FileDialog(shlEventbenchConsole, 123 SWT.OPEN); 103 124 String filename = fileDialog.open(); 104 if ( filename!=null) {125 if (filename != null) { 105 126 String command = "load '" + filename + "'"; 106 127 CommandExecuter.getInstance().exec(command); … … 109 130 }); 110 131 mntmLoad.setText("Load..."); 111 132 112 133 MenuItem mntmSave = new MenuItem(menu_1, SWT.NONE); 113 134 mntmSave.addSelectionListener(new SelectionAdapter() { 114 135 @Override 115 136 public void widgetSelected(SelectionEvent e) { 116 FileDialog fileDialog = new FileDialog(shell, SWT.SAVE); 137 FileDialog fileDialog = new FileDialog(shlEventbenchConsole, 138 SWT.SAVE); 117 139 String filename = fileDialog.open(); 118 if ( filename!=null) {140 if (filename != null) { 119 141 String command = "save '" + filename + "'"; 120 142 CommandExecuter.getInstance().exec(command); … … 123 145 }); 124 146 mntmSave.setText("Save..."); 125 147 126 148 new MenuItem(menu_1, SWT.SEPARATOR); 127 149 128 150 MenuItem mntmExit = new MenuItem(menu_1, SWT.NONE); 129 151 mntmExit.addSelectionListener(new SelectionAdapter() { 130 152 @Override 131 153 public void widgetSelected(SelectionEvent e) { 132 sh ell.dispose();154 shlEventbenchConsole.dispose(); 133 155 } 134 156 }); 135 157 mntmExit.setText("Exit"); 136 158 137 159 MenuItem mntmHelp = new MenuItem(menu, SWT.CASCADE); 138 160 mntmHelp.setText("Help"); 139 161 140 162 Menu menu_2 = new Menu(mntmHelp); 141 163 mntmHelp.setMenu(menu_2); 142 164 143 165 MenuItem mntmAbout = new MenuItem(menu_2, SWT.NONE); 144 166 mntmAbout.addSelectionListener(new SelectionAdapter() { 145 167 @Override 146 168 public void widgetSelected(SelectionEvent e) { 147 AboutDialog aboutDialog = new AboutDialog(shell, SWT.NONE); 169 AboutDialog aboutDialog = new AboutDialog(shlEventbenchConsole, 170 SWT.NONE); 148 171 aboutDialog.open(); 149 172 } 150 173 }); 151 174 mntmAbout.setText("About"); 152 153 TabFolder tabFolder = new TabFolder(shell, SWT.NONE); 175 } 176 177 /** 178 * <p> 179 * Creates the central TabFolder of the window. 180 * </p> 181 */ 182 private void createTabs() { 183 TabFolder tabFolder = new TabFolder(shlEventbenchConsole, SWT.NONE); 154 184 tabFolder.addSelectionListener(new SelectionAdapter() { 155 185 @Override 156 186 public void widgetSelected(SelectionEvent e) { 157 if ( e.item == sequencesTab) {187 if (e.item == sequencesTab) { 158 188 sequencesTabComposite.updateSequenceList(); 159 } 160 else if(e.item == modelsTab ) { 189 } else if (e.item == modelsTab) { 161 190 modelsTabComposite.updateModelList(); 162 } 163 else if(e.item == dataTab) { 191 } else if (e.item == dataTab) { 164 192 dataTabComposite.updateDataList(); 165 193 } 166 194 } 167 195 }); 168 tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); 169 196 tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 197 1)); 198 170 199 consoleTab = new TabItem(tabFolder, SWT.NONE); 171 200 consoleTab.setText("Console"); 172 173 consoleTabComposite = new ConsoleTabComposite(tabFolder, SWT.NO_BACKGROUND); 201 202 consoleTabComposite = new ConsoleTabComposite(tabFolder, 203 SWT.NO_BACKGROUND); 174 204 consoleTab.setControl(consoleTabComposite); 175 205 176 206 sequencesTab = new TabItem(tabFolder, SWT.NONE); 177 207 sequencesTab.setText("Sequences"); 178 179 sequencesTabComposite = new SequencesTabComposite(tabFolder, SWT.NO_BACKGROUND); 208 209 sequencesTabComposite = new SequencesTabComposite(tabFolder, 210 SWT.NO_BACKGROUND); 180 211 sequencesTab.setControl(sequencesTabComposite); 181 212 182 213 modelsTab = new TabItem(tabFolder, SWT.NONE); 183 214 modelsTab.setText("Models"); 184 185 modelsTabComposite = new ModelsTabComposite(tabFolder, SWT.NO_BACKGROUND); 215 216 modelsTabComposite = new ModelsTabComposite(tabFolder, 217 SWT.NO_BACKGROUND); 186 218 modelsTab.setControl(modelsTabComposite); 187 219 188 220 dataTab = new TabItem(tabFolder, SWT.NONE); 189 221 dataTab.setText("Data"); 190 222 191 223 dataTabComposite = new DataTabComposite(tabFolder, SWT.NO_BACKGROUND); 192 224 dataTab.setControl(dataTabComposite); 193 194 }195 public Text getTextConsoleOutput() {196 return consoleTabComposite.textConsoleOutput;197 225 } 198 226 } -
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/swt/SWTConsole.java
r202 r238 1 1 package de.ugoe.cs.eventbench.swt; 2 2 3 import org.eclipse.swt.widgets.Text; 3 import org.eclipse.swt.SWT; 4 import org.eclipse.swt.custom.StyleRange; 5 import org.eclipse.swt.custom.StyledText; 4 6 5 7 import de.ugoe.cs.util.StringTools; … … 12 14 public class SWTConsole implements IOutputListener, IErrorListener, ITraceListener, ICommandListener { 13 15 14 Text output;16 StyledText output; 15 17 16 public SWTConsole( Text output) {18 public SWTConsole(StyledText styledText) { 17 19 Console.getInstance().registerOutputListener(this); 18 20 Console.getInstance().registerErrorListener(this); 19 21 Console.getInstance().registerTraceListener(this); 20 22 Console.getInstance().registerCommandListener(this); 21 this.output = output;23 this.output = styledText; 22 24 } 23 25 … … 29 31 @Override 30 32 public void errorMsg(String errMessage) { 31 output.append(errMessage); 32 33 appendColored(errMessage, SWT.COLOR_RED); 33 34 } 34 35 35 36 @Override 36 37 public void traceMsg(String traceMessage) { 37 output.append(traceMessage);38 appendColored(traceMessage, SWT.COLOR_BLUE); 38 39 } 39 40 … … 42 43 output.append("> " + command + StringTools.ENDLINE); 43 44 } 45 46 private void appendColored(String str, int id) { 47 StyleRange styleRange = new StyleRange(); 48 styleRange.start = output.getText().length(); 49 styleRange.length = str.length(); 50 styleRange.foreground = output.getDisplay().getSystemColor(id); 51 output.append(str); 52 output.setStyleRange(styleRange); 53 } 44 54 }
Note: See TracChangeset
for help on using the changeset viewer.