1 19 package org.openharmonise.him.serverconfig; 20 21 import java.awt.*; 22 import java.awt.event.*; 23 24 import javax.swing.*; 25 26 import org.openharmonise.vfs.*; 27 import org.openharmonise.vfs.context.*; 28 29 30 36 public class PreviewConfigDialog extends JDialog implements LayoutManager, ActionListener, ContextListener { 37 38 private JButton m_buttonOK = null; 39 private JButton m_buttonCancel = null; 40 private JButton m_buttonApply = null; 41 private AbstractVirtualFileSystem m_vfs = null; 42 private String m_sPath = null; 43 private JTabbedPane m_tabs = null; 44 private PagePreviewConfigOptions m_pageOptions = null; 45 private DocumentPreviewConfigOptions m_docOptions = null; 46 47 52 public PreviewConfigDialog(Frame arg0, String arg1) 53 throws HeadlessException { 54 super(arg0, arg1); 55 setup(); 56 } 57 58 private void setup() { 59 ContextHandler.getInstance().addListener(ContextType.CONTEXT_APP_FOCUS, this); 60 61 this.setResizable(false); 62 63 try { 64 this.getContentPane().setLayout(this); 65 66 this.setSize(485,360); 67 int x = this.getGraphicsConfiguration().getBounds().width/2-this.getSize().width/2; 68 int y = this.getGraphicsConfiguration().getBounds().height/2-this.getSize().height/2; 69 70 this.setLocation(x, y); 71 72 String fontName = "Dialog"; 73 int fontSize = 11; 74 Font font = new Font(fontName, Font.PLAIN, fontSize); 75 this.getContentPane().setBackground(new Color(224,224,224)); 76 77 this.m_buttonOK = new JButton("OK"); 78 this.m_buttonOK.setActionCommand("OK"); 79 this.m_buttonOK.addActionListener(this); 80 this.m_buttonOK.setFont(font); 81 this.getContentPane().add(this.m_buttonOK); 82 83 this.m_buttonCancel = new JButton("Cancel"); 84 this.m_buttonCancel.setActionCommand("CANCEL"); 85 this.m_buttonCancel.addActionListener(this); 86 this.m_buttonCancel.setFont(font); 87 this.getContentPane().add(this.m_buttonCancel); 88 89 this.m_buttonApply = new JButton("Apply"); 90 this.m_buttonApply.setActionCommand("APPLY"); 91 this.m_buttonApply.addActionListener(this); 92 this.m_buttonApply.setFont(font); 93 m_buttonApply.setEnabled(false); 94 this.getContentPane().add(this.m_buttonApply); 95 96 m_tabs = new JTabbedPane(); 97 m_tabs.setFont(font); 98 99 m_pageOptions = new PagePreviewConfigOptions(this); 100 m_tabs.addTab("Pages",m_pageOptions); 101 102 m_docOptions = new DocumentPreviewConfigOptions(this); 103 m_tabs.addTab("Documents",m_docOptions); 104 105 getContentPane().add(this.m_tabs); 106 107 } catch (Exception e) { 108 e.printStackTrace(System.err); 109 } 110 111 } 112 113 116 public void layoutContainer(Container arg0) { 117 int width = getSize().width; 118 int height = getSize().height; 119 120 this.m_tabs.setSize(width-25, height-70); 121 this.m_tabs.setLocation(10, 10); 122 123 int x = 100; 124 125 this.m_buttonOK.setSize(70, 20); 126 this.m_buttonOK.setLocation(x, height-50); 127 128 this.m_buttonCancel.setSize(70, 20); 129 this.m_buttonCancel.setLocation(x+110, height-50); 130 131 this.m_buttonApply.setSize(70,20); 132 this.m_buttonApply.setLocation(x+220, height-50); 133 134 } 135 138 public PreviewConfigDialog() throws HeadlessException { 139 super(); 140 } 141 142 146 public PreviewConfigDialog(Dialog arg0) throws HeadlessException { 147 super(arg0); 148 } 149 150 155 public PreviewConfigDialog(Dialog arg0, boolean arg1) 156 throws HeadlessException { 157 super(arg0, arg1); 158 } 159 160 164 public PreviewConfigDialog(Frame arg0) throws HeadlessException { 165 super(arg0); 166 } 167 172 public PreviewConfigDialog(Dialog arg0, String arg1) 173 throws HeadlessException { 174 super(arg0, arg1); 175 } 176 177 183 public PreviewConfigDialog(Dialog arg0, String arg1, boolean arg2) 184 throws HeadlessException { 185 super(arg0, arg1, arg2); 186 } 187 188 193 public PreviewConfigDialog(Frame arg0, boolean arg1) 194 throws HeadlessException { 195 super(arg0, arg1); 196 } 197 198 204 public PreviewConfigDialog(Frame arg0, String arg1, boolean arg2) 205 throws HeadlessException { 206 super(arg0, arg1, arg2); 207 } 208 209 216 public PreviewConfigDialog(Dialog arg0, String arg1, boolean arg2, 217 GraphicsConfiguration arg3) throws HeadlessException { 218 super(arg0, arg1, arg2, arg3); 219 } 220 221 227 public PreviewConfigDialog(Frame arg0, String arg1, boolean arg2, 228 GraphicsConfiguration arg3) { 229 super(arg0, arg1, arg2, arg3); 230 } 231 232 235 public void addLayoutComponent(String arg0, Component arg1) { 236 } 237 238 241 public Dimension minimumLayoutSize(Container arg0) { 242 return null; 243 } 244 245 248 public Dimension preferredLayoutSize(Container arg0) { 249 return null; 250 } 251 252 255 public void actionPerformed(ActionEvent ae) { 256 if (ae.getActionCommand().equals("OK")) { 257 m_pageOptions.save(); 258 m_docOptions.save(); 259 this.hide(); 260 } if (ae.getActionCommand().equals("APPLY")){ 261 m_pageOptions.save(); 262 m_docOptions.save(); 263 this.m_buttonApply.setEnabled(false); 264 } else if (ae.getActionCommand().equals("CANCEL")) { 265 this.hide(); 266 } 267 268 } 269 270 273 public void contextMessage(ContextEvent ce) { 274 } 275 276 279 public void removeLayoutComponent(Component arg0) { 280 } 281 282 285 public void changesMade() { 286 this.m_buttonApply.setEnabled(true); 287 } 288 } 289 | Popular Tags |