| 1 18 package org.apache.batik.apps.svgbrowser; 19 20 import java.awt.BorderLayout ; 21 import java.awt.CardLayout ; 22 import java.awt.Component ; 23 import java.awt.Container ; 24 import java.awt.FlowLayout ; 25 import java.awt.Frame ; 26 import java.awt.Rectangle ; 27 import java.awt.event.ActionEvent ; 28 import java.awt.event.ActionListener ; 29 import java.awt.event.KeyAdapter ; 30 import java.awt.event.KeyEvent ; 31 import java.util.Enumeration ; 32 import java.util.Hashtable ; 33 import java.util.Map ; 34 35 import javax.swing.AbstractButton ; 36 import javax.swing.BorderFactory ; 37 import javax.swing.ButtonGroup ; 38 import javax.swing.ImageIcon ; 39 import javax.swing.JButton ; 40 import javax.swing.JCheckBox ; 41 import javax.swing.JDialog ; 42 import javax.swing.JLabel ; 43 import javax.swing.JList ; 44 import javax.swing.JPanel ; 45 import javax.swing.JRadioButton ; 46 import javax.swing.JScrollPane ; 47 import javax.swing.JTabbedPane ; 48 import javax.swing.JTextField ; 49 import javax.swing.ListCellRenderer ; 50 import javax.swing.UIManager ; 51 import javax.swing.border.Border ; 52 import javax.swing.event.ListSelectionEvent ; 53 import javax.swing.event.ListSelectionListener ; 54 55 import org.apache.batik.ext.swing.GridBagConstants; 56 import org.apache.batik.ext.swing.JGridBagPanel; 57 import org.apache.batik.util.PreferenceManager; 58 import org.apache.batik.util.gui.CSSMediaPanel; 59 import org.apache.batik.util.gui.LanguageDialog; 60 import org.apache.batik.util.gui.UserStyleDialog; 61 62 68 public class PreferenceDialog extends JDialog  69 implements GridBagConstants { 70 71 74 public final static int OK_OPTION = 0; 75 76 79 public final static int CANCEL_OPTION = 1; 80 81 85 public static final String ICON_USER_LANGUAGE 86 = "PreferenceDialog.icon.userLanguagePref"; 87 88 public static final String ICON_USER_STYLESHEET 89 = "PreferenceDialog.icon.userStylesheetPref"; 90 91 public static final String ICON_BEHAVIOR 92 = "PreferenceDialog.icon.behaviorsPref"; 93 94 public static final String ICON_NETWORK 95 = "PreferenceDialog.icon.networkPref"; 96 97 public static final String LABEL_USER_OPTIONS 98 = "PreferenceDialog.label.user.options"; 99 100 public static final String LABEL_BEHAVIOR 101 = "PreferenceDialog.label.behavior"; 102 103 public static final String LABEL_NETWORK 104 = "PreferenceDialog.label.network"; 105 106 public static final String LABEL_USER_LANGUAGE 107 = "PreferenceDialog.label.user.language"; 108 109 public static final String LABEL_USER_STYLESHEET 110 = "PreferenceDialog.label.user.stylesheet"; 111 112 public static final String LABEL_USER_FONT 113 = "PreferenceDialog.label.user.font"; 114 115 public static final String LABEL_APPLICATIONS 116 = "PreferenceDialog.label.applications"; 117 118 public static final String LABEL_SHOW_RENDERING 119 = "PreferenceDialog.label.show.rendering"; 120 121 public static final String LABEL_AUTO_ADJUST_WINDOW 122 = "PreferenceDialog.label.auto.adjust.window"; 123 124 public static final String LABEL_ENABLE_DOUBLE_BUFFERING 125 = "PreferenceDialog.label.enable.double.buffering"; 126 127 public static final String LABEL_SHOW_DEBUG_TRACE 128 = "PreferenceDialog.label.show.debug.trace"; 129 130 public static final String LABEL_SELECTION_XOR_MODE 131 = "PreferenceDialog.label.selection.xor.mode"; 132 133 public static final String LABEL_IS_XML_PARSER_VALIDATING 134 = "PreferenceDialog.label.is.xml.parser.validating"; 135 136 public static final String LABEL_ENFORCE_SECURE_SCRIPTING 137 = "PreferenceDialog.label.enforce.secure.scripting"; 138 139 public static final String LABEL_SECURE_SCRIPTING_TOGGLE 140 = "PreferenceDialog.label.secure.scripting.toggle"; 141 142 public static final String LABEL_GRANT_SCRIPT_FILE_ACCESS 143 = "PreferenceDialog.label.grant.script.file.access"; 144 145 public static final String LABEL_GRANT_SCRIPT_NETWORK_ACCESS 146 = "PreferenceDialog.label.grant.script.network.access"; 147 148 public static final String LABEL_LOAD_JAVA 149 = "PreferenceDialog.label.load.java"; 150 151 public static final String LABEL_LOAD_ECMASCRIPT 152 = "PreferenceDialog.label.load.ecmascript"; 153 154 public static final String LABEL_HOST 155 = "PreferenceDialog.label.host"; 156 157 public static final String LABEL_PORT 158 = "PreferenceDialog.label.port"; 159 160 public static final String LABEL_OK 161 = "PreferenceDialog.label.ok"; 162 163 public static final String LABEL_LOAD_SCRIPTS 164 = "PreferenceDialog.label.load.scripts"; 165 166 public static final String LABEL_ORIGIN_ANY 167 = "PreferenceDialog.label.origin.any"; 168 169 public static final String LABEL_ORIGIN_DOCUMENT 170 = "PreferenceDialog.label.origin.document"; 171 172 public static final String LABEL_ORIGIN_EMBED 173 = "PreferenceDialog.label.origin.embed"; 174 175 public static final String LABEL_ORIGIN_NONE 176 = "PreferenceDialog.label.origin.none"; 177 178 public static final String LABEL_SCRIPT_ORIGIN 179 = "PreferenceDialog.label.script.origin"; 180 181 public static final String LABEL_RESOURCE_ORIGIN 182 = "PreferenceDialog.label.resource.origin"; 183 184 public static final String LABEL_CANCEL 185 = "PreferenceDialog.label.cancel"; 186 187 public static final String TITLE_BROWSER_OPTIONS 188 = "PreferenceDialog.title.browser.options"; 189 190 public static final String TITLE_BEHAVIOR 191 = "PreferenceDialog.title.behavior"; 192 193 public static final String TITLE_SECURITY 194 = "PreferenceDialog.title.security"; 195 196 public static final String TITLE_NETWORK 197 = "PreferenceDialog.title.network"; 198 199 public static final String TITLE_DIALOG 200 = "PreferenceDialog.title.dialog"; 201 202 public static final String CONFIG_HOST_TEXT_FIELD_LENGTH 203 = "PreferenceDialog.config.host.text.field.length"; 204 205 public static final String CONFIG_PORT_TEXT_FIELD_LENGTH 206 = "PreferenceDialog.config.port.text.field.length"; 207 208 public static final String CONFIG_OK_MNEMONIC 209 = "PreferenceDialog.config.ok.mnemonic"; 210 211 public static final String CONFIG_CANCEL_MNEMONIC 212 = "PreferenceDialog.config.cancel.mnemonic"; 213 214 219 public static final String PREFERENCE_KEY_LANGUAGES 220 = "preference.key.languages"; 221 222 public static final String PREFERENCE_KEY_IS_XML_PARSER_VALIDATING 223 = "preference.key.is.xml.parser.validating"; 224 225 public static final String PREFERENCE_KEY_USER_STYLESHEET 226 = "preference.key.user.stylesheet"; 227 228 public static final String PREFERENCE_KEY_SHOW_RENDERING 229 = "preference.key.show.rendering"; 230 231 public static final String PREFERENCE_KEY_AUTO_ADJUST_WINDOW 232 = "preference.key.auto.adjust.window"; 233 234 public static final String PREFERENCE_KEY_ENABLE_DOUBLE_BUFFERING 235 = "preference.key.enable.double.buffering"; 236 237 public static final String PREFERENCE_KEY_SHOW_DEBUG_TRACE 238 = "preference.key.show.debug.trace"; 239 240 public static final String PREFERENCE_KEY_SELECTION_XOR_MODE 241 = "preference.key.selection.xor.mode"; 242 243 public static final String PREFERENCE_KEY_PROXY_HOST 244 = "preference.key.proxy.host"; 245 246 public static final String PREFERENCE_KEY_CSS_MEDIA 247 = "preference.key.cssmedia"; 248 249 public static final String PREFERENCE_KEY_DEFAULT_FONT_FAMILY 250 = "preference.key.default.font.family"; 251 252 public static final String PREFERENCE_KEY_PROXY_PORT 253 = "preference.key.proxy.port"; 254 255 public static final String PREFERENCE_KEY_ENFORCE_SECURE_SCRIPTING 256 = "preference.key.enforce.secure.scripting"; 257 258 public static final String PREFERENCE_KEY_GRANT_SCRIPT_FILE_ACCESS 259 = "preference.key.grant.script.file.access"; 260 261 public static final String PREFERENCE_KEY_GRANT_SCRIPT_NETWORK_ACCESS 262 = "preferenced.key.grant.script.network.access"; 263 264 public static final String PREFERENCE_KEY_LOAD_ECMASCRIPT 265 = "preference.key.load.ecmascript"; 266 267 public static final String PREFERENCE_KEY_LOAD_JAVA 268 = "preference.key.load.java.script"; 269 270 public static final String PREFERENCE_KEY_ALLOWED_SCRIPT_ORIGIN 271 = "preference.key.allowed.script.origin"; 272 273 public static final String PREFERENCE_KEY_ALLOWED_EXTERNAL_RESOURCE_ORIGIN 274 = "preference.key.allowed.external.resource.origin"; 275 276 280 protected PreferenceManager model; 281 282 285 protected ConfigurationPanelSelector configPanelSelector; 286 287 290 protected LanguageDialog.Panel languagePanel; 291 292 295 protected UserStyleDialog.Panel userStylesheetPanel; 296 297 protected JCheckBox showRendering; 298 299 protected JCheckBox autoAdjustWindow; 300 301 protected JCheckBox showDebugTrace; 302 303 protected JCheckBox enableDoubleBuffering; 304 305 protected JCheckBox selectionXorMode; 306 307 protected JCheckBox isXMLParserValidating; 308 309 protected JCheckBox enforceSecureScripting; 310 311 protected JCheckBox grantScriptFileAccess; 312 313 protected JCheckBox grantScriptNetworkAccess; 314 315 protected JCheckBox loadJava; 316 317 protected JCheckBox loadEcmascript; 318 319 protected ButtonGroup scriptOriginGroup; 320 321 protected ButtonGroup resourceOriginGroup; 322 323 protected JTextField host, port; 324 325 protected CSSMediaPanel cssMediaPanel; 326 327 331 protected int returnCode; 332 333 336 public PreferenceDialog(PreferenceManager model){ 337 super((Frame )null, true); 338 339 if(model == null){ 340 throw new IllegalArgumentException (); 341 } 342 343 this.model = model; 344 buildGUI(); 345 initializeGUI(); 346 pack(); 347 } 348 349 352 public PreferenceManager getPreferenceManager() { 353 return model; 354 } 355 356 360 protected void initializeGUI(){ 361 String languages = model.getString(PREFERENCE_KEY_LANGUAGES); 366 languagePanel.setLanguages(languages); 367 368 String userStylesheetPath = model.getString(PREFERENCE_KEY_USER_STYLESHEET); 372 userStylesheetPanel.setPath(userStylesheetPath); 373 374 showRendering.setSelected(model.getBoolean(PREFERENCE_KEY_SHOW_RENDERING)); 378 autoAdjustWindow.setSelected(model.getBoolean(PREFERENCE_KEY_AUTO_ADJUST_WINDOW)); 379 enableDoubleBuffering.setSelected(model.getBoolean(PREFERENCE_KEY_ENABLE_DOUBLE_BUFFERING)); 380 showDebugTrace.setSelected(model.getBoolean(PREFERENCE_KEY_SHOW_DEBUG_TRACE)); 381 selectionXorMode.setSelected(model.getBoolean(PREFERENCE_KEY_SELECTION_XOR_MODE)); 382 383 isXMLParserValidating.setSelected(model.getBoolean(PREFERENCE_KEY_IS_XML_PARSER_VALIDATING)); 384 enforceSecureScripting.setSelected(model.getBoolean(PREFERENCE_KEY_ENFORCE_SECURE_SCRIPTING)); 385 grantScriptFileAccess.setSelected(model.getBoolean(PREFERENCE_KEY_GRANT_SCRIPT_FILE_ACCESS)); 386 grantScriptNetworkAccess.setSelected(model.getBoolean(PREFERENCE_KEY_GRANT_SCRIPT_NETWORK_ACCESS)); 387 loadJava.setSelected(model.getBoolean(PREFERENCE_KEY_LOAD_JAVA)); 388 loadEcmascript.setSelected(model.getBoolean(PREFERENCE_KEY_LOAD_ECMASCRIPT)); 389 390 String allowedScriptOrigin = "" + model.getInteger(PREFERENCE_KEY_ALLOWED_SCRIPT_ORIGIN); 391 if (allowedScriptOrigin == null || "".equals(allowedScriptOrigin)) { 392 allowedScriptOrigin = "" + ResourceOrigin.NONE; 393 } 394 395 Enumeration e = scriptOriginGroup.getElements(); 396 while (e.hasMoreElements()) { 397 AbstractButton ab = (AbstractButton )e.nextElement(); 398 String ac = ab.getActionCommand(); 399 if (allowedScriptOrigin.equals(ac)) { 400 ab.setSelected(true); 401 } 402 } 403 404 String allowedResourceOrigin = "" + model.getInteger(PREFERENCE_KEY_ALLOWED_EXTERNAL_RESOURCE_ORIGIN); 405 if (allowedResourceOrigin == null || "".equals(allowedResourceOrigin)) { 406 allowedResourceOrigin = "" + ResourceOrigin.NONE; 407 } 408 409 e = resourceOriginGroup.getElements(); 410 while (e.hasMoreElements()) { 411 AbstractButton ab = (AbstractButton )e.nextElement(); 412 String ac = ab.getActionCommand(); 413 if (allowedResourceOrigin.equals(ac)) { 414 ab.setSelected(true); 415 } 416 } 417 418 showRendering.setEnabled 419 (!model.getBoolean(PREFERENCE_KEY_ENABLE_DOUBLE_BUFFERING)); 420 grantScriptFileAccess.setEnabled 421 (model.getBoolean(PREFERENCE_KEY_ENFORCE_SECURE_SCRIPTING)); 422 grantScriptNetworkAccess.setEnabled 423 (model.getBoolean(PREFERENCE_KEY_ENFORCE_SECURE_SCRIPTING)); 424 425 host.setText(model.getString(PREFERENCE_KEY_PROXY_HOST)); 429 port.setText(model.getString(PREFERENCE_KEY_PROXY_PORT)); 430 431 cssMediaPanel.setMedia(model.getString(PREFERENCE_KEY_CSS_MEDIA)); 435 setTitle(Resources.getString(TITLE_DIALOG)); 439 } 440 441 444 protected void savePreferences(){ 445 model.setString(PREFERENCE_KEY_LANGUAGES, 446 languagePanel.getLanguages()); 447 model.setString(PREFERENCE_KEY_USER_STYLESHEET, 448 userStylesheetPanel.getPath()); 449 model.setBoolean(PREFERENCE_KEY_SHOW_RENDERING, 450 showRendering.isSelected()); 451 model.setBoolean(PREFERENCE_KEY_AUTO_ADJUST_WINDOW, 452 autoAdjustWindow.isSelected()); 453 model.setBoolean(PREFERENCE_KEY_ENABLE_DOUBLE_BUFFERING, 454 enableDoubleBuffering.isSelected()); 455 model.setBoolean(PREFERENCE_KEY_SHOW_DEBUG_TRACE, 456 showDebugTrace.isSelected()); 457 model.setBoolean(PREFERENCE_KEY_SELECTION_XOR_MODE, 458 selectionXorMode.isSelected()); 459 model.setBoolean(PREFERENCE_KEY_IS_XML_PARSER_VALIDATING, 460 isXMLParserValidating.isSelected()); 461 model.setBoolean(PREFERENCE_KEY_ENFORCE_SECURE_SCRIPTING, 462 enforceSecureScripting.isSelected()); 463 model.setBoolean(PREFERENCE_KEY_GRANT_SCRIPT_FILE_ACCESS, 464 grantScriptFileAccess.isSelected()); 465 model.setBoolean(PREFERENCE_KEY_GRANT_SCRIPT_NETWORK_ACCESS, 466 grantScriptNetworkAccess.isSelected()); 467 model.setBoolean(PREFERENCE_KEY_LOAD_JAVA, 468 loadJava.isSelected()); 469 model.setBoolean(PREFERENCE_KEY_LOAD_ECMASCRIPT, 470 loadEcmascript.isSelected()); 471 model.setInteger(PREFERENCE_KEY_ALLOWED_SCRIPT_ORIGIN, 472 (new Integer (scriptOriginGroup.getSelection().getActionCommand())).intValue()); 473 model.setInteger(PREFERENCE_KEY_ALLOWED_EXTERNAL_RESOURCE_ORIGIN, 474 (new Integer (resourceOriginGroup.getSelection().getActionCommand())).intValue()); 475 model.setString(PREFERENCE_KEY_PROXY_HOST, 476 host.getText()); 477 model.setString(PREFERENCE_KEY_PROXY_PORT, 478 port.getText()); 479 model.setString(PREFERENCE_KEY_CSS_MEDIA, 480 cssMediaPanel.getMediaAsString()); 481 } 482 483 486 protected void buildGUI(){ 487 JPanel panel = new JPanel (new BorderLayout ()); 488 489 Component config = buildConfigPanel(); 490 Component list = buildConfigPanelList(); 491 492 panel.add(list, BorderLayout.WEST); 493 panel.add(config, BorderLayout.CENTER); 494 panel.add(buildButtonsPanel(), BorderLayout.SOUTH); 495 panel.setBorder(BorderFactory.createEmptyBorder(2, 2, 0, 0)); 496 497 getContentPane().add(panel); 498 } 499 500 503 protected JPanel buildButtonsPanel() { 504 JPanel p = new JPanel (new FlowLayout (FlowLayout.RIGHT)); 505 JButton okButton = new JButton (Resources.getString(LABEL_OK)); 506 okButton.setMnemonic(Resources.getCharacter(CONFIG_OK_MNEMONIC)); 507 JButton cancelButton = new JButton (Resources.getString(LABEL_CANCEL)); 508 cancelButton.setMnemonic(Resources.getCharacter(CONFIG_CANCEL_MNEMONIC)); 509 p.add(okButton); 510 p.add(cancelButton); 511 512 okButton.addActionListener(new ActionListener (){ 513 public void actionPerformed(ActionEvent e){ 514 setVisible(false); 515 returnCode = OK_OPTION; 516 savePreferences(); 517 dispose(); 518 } 519 }); 520 521 cancelButton.addActionListener(new ActionListener (){ 522 public void actionPerformed(ActionEvent e){ 523 setVisible(false); 524 returnCode = CANCEL_OPTION; 525 dispose(); 526 } 527 }); 528 529 addKeyListener(new KeyAdapter (){ 530 public void keyPressed(KeyEvent e){ 531 if(e.getKeyCode() == KeyEvent.VK_ESCAPE){ 532 setVisible(false); 533 returnCode = CANCEL_OPTION; 534 dispose(); 535 } 536 } 537 }); 538 539 return p; 540 } 541 542 protected Component buildConfigPanelList(){ 543 String [] configList 544 = { Resources.getString(LABEL_NETWORK), 545 Resources.getString(LABEL_USER_LANGUAGE), 546 Resources.getString(LABEL_BEHAVIOR), 547 Resources.getString(LABEL_USER_STYLESHEET), 548 }; 549 550 final JList list = new JList (configList); 551 list.addListSelectionListener(new ListSelectionListener (){ 552 public void valueChanged(ListSelectionEvent evt){ 553 if(!evt.getValueIsAdjusting()){ 554 configPanelSelector.select(list.getSelectedValue().toString()); 555 } 556 } 557 }); 558 list.setVisibleRowCount(4); 559 560 ClassLoader cl = this.getClass().getClassLoader(); 562 Map map= new Hashtable (); 563 map.put(Resources.getString(LABEL_USER_LANGUAGE), new ImageIcon (cl.getResource(Resources.getString(ICON_USER_LANGUAGE)))); 564 map.put(Resources.getString(LABEL_USER_STYLESHEET), new ImageIcon (cl.getResource(Resources.getString(ICON_USER_STYLESHEET)))); 565 map.put(Resources.getString(LABEL_BEHAVIOR), new ImageIcon (cl.getResource(Resources.getString(ICON_BEHAVIOR)))); 566 map.put(Resources.getString(LABEL_NETWORK), new ImageIcon (cl.getResource(Resources.getString(ICON_NETWORK)))); 567 568 list.setCellRenderer(new IconCellRenderer(map)); 569 570 list.setSelectedIndex(0); 571 572 return new JScrollPane (list); 573 } 574 575 protected Component buildConfigPanel(){ 576 JPanel configPanel = new JPanel (); 577 CardLayout cardLayout = new CardLayout (); 578 configPanel.setLayout(cardLayout); 579 configPanel.add(buildUserLanguage(), 580 Resources.getString(LABEL_USER_LANGUAGE)); 581 582 configPanel.add(buildUserStyleSheet(), 583 Resources.getString(LABEL_USER_STYLESHEET)); 584 585 configPanel.add(buildBehavior(), 586 Resources.getString(LABEL_BEHAVIOR)); 587 588 configPanel.add(buildNetwork(), 589 Resources.getString(LABEL_NETWORK)); 590 591 configPanel.add(buildApplications(), 592 Resources.getString(LABEL_APPLICATIONS)); 593 594 configPanelSelector = new ConfigurationPanelSelector(configPanel, 595 cardLayout); 596 597 return configPanel; 598 } 599 600 protected Component buildUserOptions(){ 601 JTabbedPane p = new JTabbedPane (); 602 p.add(buildUserLanguage(), 603 Resources.getString(LABEL_USER_LANGUAGE)); 604 p.add(buildUserStyleSheet(), 605 Resources.getString(LABEL_USER_STYLESHEET)); 606 p.add(buildUserFont(), 607 Resources.getString(LABEL_USER_FONT)); 608 return p; 609 } 610 611 protected Component buildUserLanguage(){ 612 languagePanel = new LanguageDialog.Panel(); 613 return languagePanel; 614 } 615 616 protected Component buildUserStyleSheet(){ 617 JPanel panel = new JPanel (new BorderLayout ()); 618 panel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); 619 620 userStylesheetPanel = new UserStyleDialog.Panel(); 621 panel.add(userStylesheetPanel, BorderLayout.NORTH); 622 623 cssMediaPanel = new CSSMediaPanel(); 624 panel.add(cssMediaPanel, BorderLayout.SOUTH); 625 626 return panel; 627 } 628 629 protected Component buildUserFont(){ 630 return new JButton ("User Font"); 631 } 632 633 protected Component buildBehavior(){ 634 JGridBagPanel p = new JGridBagPanel(); 635 showRendering 636 = new JCheckBox (Resources.getString(LABEL_SHOW_RENDERING)); 637 autoAdjustWindow 638 = new JCheckBox (Resources.getString(LABEL_AUTO_ADJUST_WINDOW)); 639 enableDoubleBuffering 640 = new JCheckBox (Resources.getString(LABEL_ENABLE_DOUBLE_BUFFERING)); 641 enableDoubleBuffering.addActionListener(new ActionListener () { 642 public void actionPerformed(ActionEvent evt) { 643 showRendering.setEnabled(!enableDoubleBuffering.isSelected()); 644 } 645 }); 646 showDebugTrace 647 = new JCheckBox (Resources.getString(LABEL_SHOW_DEBUG_TRACE)); 648 649 selectionXorMode 650 = new JCheckBox (Resources.getString(LABEL_SELECTION_XOR_MODE)); 651 652 isXMLParserValidating 653 = new JCheckBox (Resources.getString(LABEL_IS_XML_PARSER_VALIDATING)); 654 655 enforceSecureScripting 656 = new JCheckBox (Resources.getString(LABEL_SECURE_SCRIPTING_TOGGLE)); 657 658 grantScriptFileAccess 659 = new JCheckBox (Resources.getString(LABEL_GRANT_SCRIPT_FILE_ACCESS)); 660 661 grantScriptNetworkAccess 662 = new JCheckBox (Resources.getString(LABEL_GRANT_SCRIPT_NETWORK_ACCESS)); 663 664 JGridBagPanel scriptSecurityPanel = new JGridBagPanel(); 665 scriptSecurityPanel.add(enforceSecureScripting, 0, 0, 1, 1, WEST, HORIZONTAL, 1, 0); 666 scriptSecurityPanel.add(grantScriptFileAccess, 1, 0, 1, 1, WEST, HORIZONTAL, 1, 0); 667 scriptSecurityPanel.add(grantScriptNetworkAccess, 1, 1, 1, 1, WEST, HORIZONTAL, 1, 0); 668 669 enforceSecureScripting.addActionListener(new ActionListener () { 670 public void actionPerformed(ActionEvent e) { 671 grantScriptFileAccess.setEnabled(enforceSecureScripting.isSelected()); 672 grantScriptNetworkAccess.setEnabled(enforceSecureScripting.isSelected()); 673 } 674 }); 675 676 loadJava 677 = new JCheckBox (Resources.getString(LABEL_LOAD_JAVA)); 678 679 loadEcmascript 680 = new JCheckBox (Resources.getString(LABEL_LOAD_ECMASCRIPT)); 681 682 JGridBagPanel loadScriptPanel = new JGridBagPanel(); 683 loadScriptPanel.add(loadJava, 0, 0, 1, 1, WEST, NONE, 1, 0); 684 loadScriptPanel.add(loadEcmascript, 1, 0, 1, 1, WEST, NONE, 1, 0); 685 686 JPanel scriptOriginPanel = new JPanel (); 687 688 scriptOriginGroup = new ButtonGroup (); 689 JRadioButton rb = null; 690 691 rb = new JRadioButton (Resources.getString(LABEL_ORIGIN_ANY)); 692 rb.setActionCommand("" + ResourceOrigin.ANY); 693 scriptOriginGroup.add(rb); 694 scriptOriginPanel.add(rb); 695 696 rb = new JRadioButton (Resources.getString(LABEL_ORIGIN_DOCUMENT)); 697 rb.setActionCommand("" + ResourceOrigin.DOCUMENT); 698 scriptOriginGroup.add(rb); 699 scriptOriginPanel.add(rb); 700 701 rb = new JRadioButton (Resources.getString(LABEL_ORIGIN_EMBED)); 702 rb.setActionCommand("" + ResourceOrigin.EMBEDED); 703 scriptOriginGroup.add(rb); 704 scriptOriginPanel.add(rb); 705 706 rb = new JRadioButton (Resources.getString(LABEL_ORIGIN_NONE)); 707 rb.setActionCommand("" + ResourceOrigin.NONE); 708 scriptOriginGroup.add(rb); 709 scriptOriginPanel.add(rb); 710 711 JPanel resourceOriginPanel = new JPanel (); 712 resourceOriginGroup = new |