1 14 package org.wings; 15 16 import org.wings.event.SInternalFrameEvent; 17 import org.wings.event.SInternalFrameListener; 18 import org.wings.plaf.InternalFrameCG; 19 20 24 public class SInternalFrame 25 extends SRootContainer 26 implements LowLevelEventListener { 27 private boolean iconifyable = true; 28 private boolean maximizable = true; 29 private boolean closable = true; 30 31 private boolean iconified = false; 32 private boolean maximized = false; 33 private boolean closed = false; 34 35 protected SIcon icon = null; 36 37 protected String title = null; 38 39 public SInternalFrame() { 40 super(); 41 } 42 43 public void setIconifyable(boolean v) { 44 reloadIfChange(iconifyable, v); 45 } 46 47 public boolean isIconifyable() { return iconifyable; } 48 49 public void setMaximizable(boolean v) { 50 maximizable = v; 51 reloadIfChange(maximizable, v); 52 } 53 54 public boolean isMaximizable() { return maximizable; } 55 56 public void setClosable(boolean v) { 57 closable = v; 58 reloadIfChange(closable, v); 59 } 60 61 public boolean isClosable() { return closable; } 62 63 public void setIconified(boolean v) { 64 v &= isIconifyable(); 65 boolean old = iconified; 66 iconified = v; 67 if (old != iconified) { 68 reload(); 69 if (iconified) 70 setMaximized(false); 71 } 72 } 73 74 public boolean isIconified() { return iconified; } 75 76 public void setMaximized(boolean v) { 77 v &= isMaximizable(); 78 boolean old = maximized; 79 maximized = v; 80 if (old != maximized) { 81 reload(); 82 if (maximized) 83 setIconified(false); 84 } 85 } 86 87 public boolean isMaximized() { return maximized; } 88 89 public void setClosed(boolean v) { 90 v &= isClosable(); 91 boolean old = closed; 92 closed = v; 93 if (old != closed) 94 reload(); 95 } 96 97 public boolean isClosed() { return closed; } 98 99 public void setIcon(SIcon i) { 100 if (i != icon || i != null && !i.equals(icon)) { 101 icon = i; 102 reload(); 103 } 104 } 105 106 public SIcon getIcon() { 107 return icon; 108 } 109 110 public void setTitle(String t) { 111 String oldTitle = title; 112 title = t; 113 if ((title == null && oldTitle != null) || 114 (title != null && !title.equals(oldTitle))) 115 reload(); 116 } 117 118 public String getTitle() { 119 return title; 120 } 121 122 public void dispose() { 123 SDesktopPane desktop = (SDesktopPane) getParent(); 124 desktop.remove(this); 125 } 126 127 public void setVisible(boolean visible) { 128 if (visible) 129 show(); 130 else 131 hide(); 132 } 133 134 public void show() { 135 super.setVisible(true); 136 if (isIconified()) { 137 setIconified(false); 138 } 139 if (isClosed()) { 140 setClosed(false); 141 } 142 } 143 144 public void hide() { 145 super.setVisible(false); 146 } 147 148 public void addInternalFrameListener(SInternalFrameListener listener) { 149 addEventListener(SInternalFrameListener.class, listener); 150 } 151 152 public void removeInternalFrameListener(SInternalFrameListener listener) { 153 removeEventListener(SInternalFrameListener.class, listener); 154 } 155 156 private SInternalFrameEvent event; 157 158 public void processLowLevelEvent(String action, String [] values) { 160 processKeyEvents(values); 161 162 switch (new Integer (values[0]).intValue()) { 163 case SInternalFrameEvent.INTERNAL_FRAME_CLOSED: 164 setClosed(true); 165 break; 166 167 case SInternalFrameEvent.INTERNAL_FRAME_ICONIFIED: 168 setIconified(true); 169 break; 170 171 case SInternalFrameEvent.INTERNAL_FRAME_DEICONIFIED: 172 setIconified(false); 173 break; 174 175 case SInternalFrameEvent.INTERNAL_FRAME_MAXIMIZED: 176 setMaximized(true); 177 break; 178 179 case SInternalFrameEvent.INTERNAL_FRAME_UNMAXIMIZED: 180 setMaximized(false); 181 break; 182 183 default: 184 throw new RuntimeException ("unknown id: " + values[0]); 185 } 186 187 event = new SInternalFrameEvent(this, new Integer (values[0]).intValue()); 188 SForm.addArmedComponent(this); } 190 191 public void fireIntermediateEvents() {} 192 193 public void fireFinalEvents() { 194 super.fireFinalEvents(); 195 Object [] listeners = getListenerList(); 197 for (int i = listeners.length - 2; i >= 0; i -= 2) { 200 if (listeners[i] == SInternalFrameListener.class) { 201 SInternalFrameListener listener; 202 listener = (SInternalFrameListener) listeners[i + 1]; 203 switch (event.getID()) { 204 case SInternalFrameEvent.INTERNAL_FRAME_CLOSED: 205 listener.internalFrameClosed(event); 206 break; 207 208 case SInternalFrameEvent.INTERNAL_FRAME_ICONIFIED: 209 listener.internalFrameIconified(event); 210 break; 211 212 case SInternalFrameEvent.INTERNAL_FRAME_DEICONIFIED: 213 listener.internalFrameDeiconified(event); 214 break; 215 216 case SInternalFrameEvent.INTERNAL_FRAME_MAXIMIZED: 217 listener.internalFrameMaximized(event); 218 break; 219 220 case SInternalFrameEvent.INTERNAL_FRAME_UNMAXIMIZED: 221 listener.internalFrameUnmaximized(event); 222 break; 223 } 224 } 225 } 226 227 event = null; 228 } 229 230 public boolean isEpochCheckEnabled() { 231 return true; 232 } 233 234 public void setCG(InternalFrameCG cg) { 235 super.setCG(cg); 236 } 237 } 238 239 240 | Popular Tags |