1 package net.suberic.pooka.gui; 2 import net.suberic.util.gui.propedit.PropertyEditorFactory; 3 import net.suberic.util.gui.ConfigurableToolbar; 5 import net.suberic.util.gui.IconManager; 6 import net.suberic.util.swing.*; 7 import net.suberic.pooka.*; 8 import net.suberic.pooka.gui.search.*; 9 10 import java.awt.Dimension ; 11 import java.awt.GraphicsConfiguration ; 12 import java.awt.GraphicsEnvironment ; 13 import java.awt.Point ; 14 import java.awt.Rectangle ; 15 import java.awt.Window ; 16 17 import javax.swing.JInternalFrame ; 18 import javax.swing.JDialog ; 19 import javax.swing.JScrollPane ; 20 import javax.swing.JTextArea ; 21 import javax.swing.JLabel ; 22 import javax.swing.JOptionPane ; 23 import javax.swing.SwingUtilities ; 24 import javax.mail.MessagingException ; 25 26 30 public class PookaDesktopPaneUIFactory extends SwingUIFactory { 31 32 MessagePanel messagePanel = null; 33 34 37 public PookaDesktopPaneUIFactory(PookaUIFactory pSource) { 38 if (pSource != null) { 39 editorFactory = new PropertyEditorFactory(Pooka.getResources(), pSource.getIconManager(), Pooka.getPookaManager().getHelpBroker()); 40 pookaThemeManager = pSource.getPookaThemeManager(); 41 mIconManager = pSource.getIconManager(); 42 mMessageNotificationManager = pSource.getMessageNotificationManager(); 43 } else { 44 pookaThemeManager = new ThemeManager("Pooka.theme", Pooka.getResources()); 45 mIconManager = IconManager.getIconManager(Pooka.getResources(), "IconManager._default"); 46 editorFactory = new PropertyEditorFactory(Pooka.getResources(), mIconManager, Pooka.getPookaManager().getHelpBroker()); 47 mMessageNotificationManager = new MessageNotificationManager(); 48 } 49 } 50 51 54 public PookaDesktopPaneUIFactory() { 55 this(null); 56 } 57 58 62 public MessageUI createMessageUI(MessageProxy mp, MessageUI templateMui) throws javax.mail.MessagingException { 63 if (mp.getMessageUI() != null) 65 return mp.getMessageUI(); 66 67 boolean createExternal = (templateMui != null && templateMui instanceof MessageFrame); 68 69 MessageUI mui; 70 if (mp instanceof NewMessageProxy) { 71 if (createExternal) 72 mui = new NewMessageFrame((NewMessageProxy) mp); 73 else 74 mui = new NewMessageInternalFrame(getMessagePanel(), (NewMessageProxy) mp); 75 } else { 76 if (createExternal) { 77 mui = new ReadMessageFrame(mp); 78 } else { 79 mui = new ReadMessageInternalFrame(getMessagePanel(), mp); 80 ((ReadMessageInternalFrame)mui).configureMessageInternalFrame(); 81 } 82 } 83 84 mp.setMessageUI(mui); 85 return mui; 86 } 87 88 96 public void doDefaultOpen(MessageProxy mp) { 97 if (mp != null) 98 mp.openWindow(); 99 } 100 101 105 public FolderDisplayUI createFolderDisplayUI(net.suberic.pooka.FolderInfo fi) { 106 108 if (fi.getFolderDisplayUI() != null) 109 return fi.getFolderDisplayUI(); 110 111 FolderDisplayUI fw = new FolderInternalFrame(fi, getMessagePanel()); 112 return fw; 113 } 114 115 122 public void showEditorWindow(String title, String property, String template) { 123 JDialog jd = (JDialog )getEditorFactory().createEditorWindow(title, property, template); 124 jd.pack(); 125 applyNewWindowLocation(jd); 126 jd.setVisible(true); 127 139 } 140 141 144 public void applyNewWindowLocation(Window f) { 145 try { 146 Point newLocation = getNewWindowLocation(f); 147 f.setLocation(newLocation); 148 } catch (Exception e) { 149 } 150 } 151 152 155 public Point getNewWindowLocation(Window f) throws Exception { 156 Point location = Pooka.getMainPanel().getParentFrame().getLocation(); 157 Dimension mainWindowSize = Pooka.getMainPanel().getParentFrame().getSize(); 158 Dimension windowSize = f.getSize(); 159 int yValue = ((mainWindowSize.height - windowSize.height) / 2) + location.y; 160 int xValue = ((mainWindowSize.width - windowSize.width) / 2) + location.x; 161 return new Point (xValue, yValue); 162 } 163 164 165 170 public ContentPanel createContentPanel() { 171 messagePanel = new MessagePanel(); 172 messagePanel.setSize(1000,1000); 173 JScrollPane messageScrollPane = new JScrollPane (messagePanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 174 messagePanel.setDesktopManager(messagePanel.new ExtendedDesktopManager(messagePanel, messageScrollPane)); 175 messagePanel.setUIComponent(messageScrollPane); 176 177 return messagePanel; 179 } 180 181 186 public ContentPanel createContentPanel(PreviewContentPanel pcp) { 187 messagePanel = new MessagePanel(pcp); 188 messagePanel.setSize(1000,1000); 189 JScrollPane messageScrollPane = new JScrollPane (messagePanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 190 messagePanel.setDesktopManager(messagePanel.new ExtendedDesktopManager(messagePanel, messageScrollPane)); 191 messagePanel.setUIComponent(messageScrollPane); 192 193 return messagePanel; 195 } 196 197 198 202 public ConfigurableToolbar createMainToolbar() { 203 return null; 204 } 205 206 209 public ConfigurableToolbar createFolderPanelToolbar() { 210 return new ConfigurableToolbar("FolderToolbar", Pooka.getResources()); 211 } 212 213 216 public MessagePanel getMessagePanel() { 217 return messagePanel; 218 } 219 220 221 224 public void showError(String errorMessage) { 225 showError(errorMessage, Pooka.getProperty("Error", "Error")); 226 } 227 228 231 public void showError(String errorMessage, Exception e) { 232 showError(errorMessage, Pooka.getProperty("Error", "Error"), e); 233 } 234 235 236 239 public ProgressDialog createProgressDialog(int min, int max, int initialValue, String title, String content) { 240 return new ProgressInternalDialog(min, max, initialValue, title, content, getMessagePanel()); 241 } 242 243 246 public boolean isInMainFrame(java.awt.Component c) { 247 java.awt.Window mainWindow = SwingUtilities.getWindowAncestor(messagePanel); 248 java.awt.Window componentWindow = SwingUtilities.getWindowAncestor(c); 249 return (mainWindow == componentWindow); 250 } 251 252 253 } 254 | Popular Tags |