1 11 package org.eclipse.jface.window; 12 13 import java.util.ArrayList ; 14 import java.util.Iterator ; 15 import java.util.List ; 16 17 import org.eclipse.core.runtime.Assert; 18 19 36 public class WindowManager { 37 38 42 private ArrayList windows = new ArrayList (); 43 44 48 private List subManagers; 49 50 54 public WindowManager() { 55 } 56 57 63 public WindowManager(WindowManager parent) { 64 Assert.isNotNull(parent); 65 parent.addWindowManager(this); 66 } 67 68 75 public void add(Window window) { 76 if (!windows.contains(window)) { 77 windows.add(window); 78 window.setWindowManager(this); 79 } 80 } 81 82 88 private void addWindowManager(WindowManager wm) { 89 if (subManagers == null) { 90 subManagers = new ArrayList (); 91 } 92 if (!subManagers.contains(wm)) { 93 subManagers.add(wm); 94 } 95 } 96 97 104 public boolean close() { 105 List t = (List ) windows.clone(); Iterator e = t.iterator(); 107 while (e.hasNext()) { 108 Window window = (Window) e.next(); 109 boolean closed = window.close(); 110 if (!closed) { 111 return false; 112 } 113 } 114 if (subManagers != null) { 115 e = subManagers.iterator(); 116 while (e.hasNext()) { 117 WindowManager wm = (WindowManager) e.next(); 118 boolean closed = wm.close(); 119 if (!closed) { 120 return false; 121 } 122 } 123 } 124 return true; 125 } 126 127 133 public int getWindowCount() { 134 return windows.size(); 135 } 136 137 142 public Window[] getWindows() { 143 Window bs[] = new Window[windows.size()]; 144 windows.toArray(bs); 145 return bs; 146 } 147 148 155 public final void remove(Window window) { 156 if (windows.contains(window)) { 157 windows.remove(window); 158 window.setWindowManager(null); 159 } 160 } 161 } 162 | Popular Tags |