1 7 package org.ejtools.adwt.service; 8 9 import java.awt.BorderLayout ; 10 import java.beans.beancontext.BeanContext ; 11 import java.util.ResourceBundle ; 12 13 import javax.swing.JMenuBar ; 14 import javax.swing.JScrollPane ; 15 import javax.swing.JTextArea ; 16 17 import org.ejtools.adwt.action.Command; 18 import org.ejtools.adwt.action.edit.CopyAction; 19 import org.ejtools.adwt.action.edit.CutAction; 20 import org.ejtools.adwt.action.edit.DeleteAction; 21 22 26 public class ConsoleServiceInternalFrame extends BeanContextInternalFrame implements ConsoleService 27 { 28 29 protected BeanContext context = null; 30 31 protected MenuBarServiceProvider menubarProvider; 32 33 protected JTextArea textarea = null; 34 35 protected ToolBarServiceProvider toolbarProvider; 36 37 private final static ResourceBundle resources = ResourceBundle.getBundle("org.ejtools.adwt.service.ConsoleService"); 38 39 40 45 public ConsoleServiceInternalFrame(BeanContext context) 46 { 47 super(); 48 this.context = context; 49 this.textarea = new JTextArea (); 50 51 this.menubarProvider = new MenuBarServiceProvider(); 52 this.toolbarProvider = new ToolBarServiceProvider(); 53 54 this.add(this.toolbarProvider); 55 this.add(this.menubarProvider); 56 57 this.add(new CutAction( 58 new Command() 59 { 60 61 public void execute() 62 { 63 ConsoleServiceInternalFrame.this.cut(); 64 } 65 })); 66 67 this.add(new CopyAction( 68 new Command() 69 { 70 71 public void execute() 72 { 73 ConsoleServiceInternalFrame.this.copy(); 74 } 75 })); 76 77 this.add(new DeleteAction( 78 new Command() 79 { 80 81 public void execute() 82 { 83 ConsoleServiceInternalFrame.this.delete(); 84 } 85 })); 86 87 this.frame.setJMenuBar((JMenuBar ) this.menubarProvider.getContainer()); 88 this.frame.getContentPane().add(BorderLayout.NORTH, this.toolbarProvider.getContainer()); 89 this.frame.getContentPane().add(BorderLayout.CENTER, new JScrollPane (this.textarea)); 90 91 this.setTitle(resources.getString("frame.title")); 92 } 93 94 95 98 public void append(String message) 99 { 100 this.textarea.append(message); 101 this.textarea.append("\n"); 102 this.show(); 103 } 104 105 106 107 public void copy() 108 { 109 this.textarea.copy(); 110 } 111 112 113 114 public void cut() 115 { 116 this.textarea.cut(); 117 } 118 119 120 121 public void delete() 122 { 123 this.textarea.setText(""); 124 } 125 126 127 128 public void hide() 129 { 130 if (this.context.contains(this)) 131 { 132 this.close(); 133 } 134 } 135 136 137 138 public void show() 139 { 140 if (!this.context.contains(this)) 141 { 142 this.context.add(this); 143 } 144 this.activate(); 145 } 146 } 147 | Popular Tags |