Clover coverage report - DrJava Test Coverage (drjava-20110828-r5448)
Coverage timestamp: Sun Aug 28 2011 03:13:33 CDT
file stats: LOC: 650   Methods: 34
NCLOC: 542   Classes: 13
 
 Source file Conditionals Statements Methods TOTAL
ConfigOptionListeners.java 4.2% 9.2% 47.1% 10.9%
coverage coverage
 1    /*BEGIN_COPYRIGHT_BLOCK
 2    *
 3    * Copyright (c) 2001-2010, JavaPLT group at Rice University (drjava@rice.edu)
 4    * All rights reserved.
 5    *
 6    * Redistribution and use in source and binary forms, with or without
 7    * modification, are permitted provided that the following conditions are met:
 8    * * Redistributions of source code must retain the above copyright
 9    * notice, this list of conditions and the following disclaimer.
 10    * * Redistributions in binary form must reproduce the above copyright
 11    * notice, this list of conditions and the following disclaimer in the
 12    * documentation and/or other materials provided with the distribution.
 13    * * Neither the names of DrJava, the JavaPLT group, Rice University, nor the
 14    * names of its contributors may be used to endorse or promote products
 15    * derived from this software without specific prior written permission.
 16    *
 17    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 18    * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 19    * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 20    * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 21    * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 22    * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 23    * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 24    * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 25    * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 26    * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 27    * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 28    *
 29    * This software is Open Source Initiative approved Open Source Software.
 30    * Open Source Initative Approved is a trademark of the Open Source Initiative.
 31    *
 32    * This file is part of DrJava. Download the current version of this project
 33    * from http://www.drjava.org/ or http://sourceforge.net/projects/drjava/
 34    *
 35    * END_COPYRIGHT_BLOCK*/
 36   
 37    package edu.rice.cs.drjava.config;
 38   
 39    import edu.rice.cs.drjava.DrJava;
 40    import edu.rice.cs.drjava.config.OptionConstants;
 41    import edu.rice.cs.util.StringOps;
 42    import edu.rice.cs.plt.concurrent.JVMBuilder;
 43    import edu.rice.cs.util.swing.ConfirmCheckBoxDialog;
 44    import java.awt.EventQueue;
 45    import javax.swing.*;
 46   
 47    /** @version $Id: ConfigOptionListeners.java 5439 2011-08-11 17:13:04Z rcartwright $ */
 48    public class ConfigOptionListeners implements OptionConstants {
 49    public static class DisplayAllCompilerVersionsListener implements OptionListener<Boolean>, OptionConstants {
 50    protected JFrame _parent;
 51  38 public DisplayAllCompilerVersionsListener(JFrame parent) { _parent = parent; }
 52  0 public void optionChanged(OptionEvent<Boolean> oe) {
 53  0 JOptionPane.showMessageDialog(_parent, "You will have to restart DrJava before the change takes effect.");
 54    }
 55    }
 56   
 57    public static class SlaveJVMArgsListener implements OptionListener<String>, OptionConstants {
 58    protected JFrame _parent;
 59  38 public SlaveJVMArgsListener(JFrame parent) { _parent = parent; }
 60  0 public void optionChanged(OptionEvent<String> oe) {
 61    // final OptionListener<String> slaveJvmArgsListener = this;
 62  0 DrJava.getConfig().removeOptionListener(SLAVE_JVM_ARGS, this);
 63  0 if (!oe.value.equals("")) {
 64  0 int result = JOptionPane.
 65    showConfirmDialog(_parent,
 66    "Specifying Interations JVM Args is an advanced option. Invalid arguments may cause\n" +
 67    "the Interactions Pane to stop working.\n" + "Are you sure you want to set this option?\n" +
 68    "(You will have to reset the interactions pane before changes take effect.)",
 69    "Confirm Interactions JVM Arguments", JOptionPane.YES_NO_OPTION);
 70  0 if (result!=JOptionPane.YES_OPTION) {
 71  0 DrJava.getConfig().setSetting(oe.option, "");
 72    }
 73    else {
 74  0 sanitizeSlaveJVMArgs(_parent, oe.value, this);
 75    }
 76    }
 77  0 DrJava.getConfig().addOptionListener(SLAVE_JVM_ARGS, this);
 78    }
 79    }
 80   
 81  38 @SuppressWarnings("fallthrough")
 82    public static void sanitizeSlaveJVMArgs(JFrame parent,
 83    String value,
 84    final OptionListener<String> l) {
 85  38 int pos = value.indexOf("-Xmx");
 86  38 if (((pos>1) && (Character.isWhitespace(value.charAt(pos-1)))) ||
 87    (pos == 0)) {
 88  0 int endpos = pos+("-Xmx".length());
 89  0 while(endpos<value.length() && (! Character.isWhitespace(value.charAt(endpos)))) {
 90  0 ++endpos;
 91    }
 92   
 93  0 int startpos = pos+("-Xmx".length());
 94  0 String size = value.substring(startpos,endpos);
 95  0 long factor = 1;
 96  0 long heapSize;
 97  0 switch(size.toLowerCase().charAt(size.length()-1)) {
 98  0 case 'g': {
 99  0 factor *= 1024; // fall-through intended
 100    }
 101  0 case 'm': {
 102  0 factor *= 1024; // fall-through intended
 103    }
 104  0 case 'k': {
 105  0 factor *= 1024; // fall-through intended
 106  0 break;
 107    }
 108  0 default: {
 109  0 if (!Character.isDigit(size.toLowerCase().charAt(size.length()-1))) factor = 0;
 110    }
 111    }
 112  0 try {
 113  0 if (factor == 1) heapSize = new Long(size);
 114  0 else if (factor > 1) heapSize = new Long(size.substring(0,size.length()-1)) * factor;
 115  0 else heapSize = -1;
 116    }
 117  0 catch(NumberFormatException nfe) { heapSize = -1; /* invalid */ }
 118  0 long heapSizeMB = (heapSize / 1024) / 1024;
 119    // find the next bigger of the choices
 120  0 String newSetting = getNextBiggerHeapSize(heapSizeMB);
 121  0 int result;
 122  0 if (heapSize >= 0) {
 123  0 String[] options = new String[] { "Copy to \"Maximum Heap\" Setting", "Clean \"Slave JVM Args\"", "Ignore" };
 124  0 result = JOptionPane.
 125    showOptionDialog(parent,
 126    "You seem to have specified the maximum heap size as part of the\n" +
 127    "\"JVM Args for Interactions JVM\" setting: \"-Xmx" + size + "\"\n" +
 128    "The \"Maximum Heap Memory for Interactions JVM\" setting should be used instead.\n" +
 129    "Would you like to copy the value \"" + newSetting + "\" into the \"Maximum Heap\" setting,\n" +
 130    "just clean up \"JVM Args for Interactions JVM\", or ignore this potential problem?",
 131    "Maximum Heap Size Set in JVM Arguments",
 132    0,
 133    JOptionPane.QUESTION_MESSAGE,
 134    null,
 135    options,
 136    options[0]);
 137    }
 138    else {
 139  0 String[] options = new String[] { "Clean \"Main JVM Args\"",
 140    "Ignore" };
 141  0 result = JOptionPane.
 142    showOptionDialog(parent,
 143    "You seem to have specified the maximum heap size as part of the\n" +
 144    "\"JVM Args for Interactions JVM\" setting: \"-Xmx" + size + "\"\n" +
 145    "The \"Maximum Heap Memory for Interactions JVM\" setting should be used instead.\n" +
 146    "Furthermore, the specified heap size \"" + size + "\" is invalid.\n" +
 147    "Would you like to clean up the \"JVM Args for Interactions JVM\"\n" +
 148    "or ignore this potential problem?",
 149    "Maximum Heap Size Set in JVM Arguments",
 150    0,
 151    JOptionPane.QUESTION_MESSAGE,
 152    null,
 153    options,
 154    options[0]);
 155  0 if (result==1) { result = 2; }
 156    }
 157  0 if (result!=2) {
 158    // clean up
 159  0 while((endpos<value.length()) &&
 160    (Character.isWhitespace(value.charAt(endpos)))) {
 161  0 ++endpos;
 162    }
 163  0 String newValue = value.substring(0,pos) + value.substring(endpos);
 164  0 DrJava.getConfig().removeOptionListener(SLAVE_JVM_ARGS, l);
 165  0 DrJava.getConfig().addOptionListener(SLAVE_JVM_ARGS, new OptionListener<String>() {
 166  0 public void optionChanged(OptionEvent<String> oe) {
 167  0 DrJava.getConfig().removeOptionListener(SLAVE_JVM_ARGS, this);
 168  0 EventQueue.invokeLater(new Runnable() {
 169  0 public void run() { DrJava.getConfig().addOptionListener(SLAVE_JVM_ARGS, l); }
 170    });
 171    }
 172    });
 173  0 DrJava.getConfig().setSetting(SLAVE_JVM_ARGS, newValue);
 174  0 if (result == 0) {
 175    // copy
 176  0 DrJava.getConfig().setSetting(SLAVE_JVM_XMX, newSetting);
 177    }
 178    else {
 179  0 JOptionPane.showMessageDialog(parent,
 180    "You will have to reset the interactions pane before changes take effect.");
 181    }
 182    }
 183    }
 184    }
 185   
 186    public static class SlaveJVMXMXListener implements OptionListener<String>, OptionConstants {
 187    protected JFrame _parent;
 188  38 public SlaveJVMXMXListener(JFrame parent) { _parent = parent; }
 189  0 public void optionChanged(OptionEvent<String> oe) {
 190  0 DrJava.getConfig().removeOptionListener(SLAVE_JVM_XMX, this);
 191  0 sanitizeSlaveJVMXMX(_parent, oe.value);
 192  0 DrJava.getConfig().addOptionListener(SLAVE_JVM_XMX, this);
 193  0 JOptionPane.showMessageDialog(_parent,
 194    "You will have to reset the interactions pane before changes take effect.");
 195    }
 196    }
 197   
 198  38 public static void sanitizeSlaveJVMXMX(JFrame parent, String value) {
 199  38 if ((!value.equals("")) &&
 200    (!value.equals(OptionConstants.heapSizeChoices.get(0)))) {
 201  0 long heapSize;
 202  0 String size = value.trim();
 203  0 try {
 204  0 heapSize = new Long(size);
 205    }
 206    catch(NumberFormatException nfe) {
 207  0 heapSize = -1; // invalid
 208    }
 209  0 if (heapSize < 0) {
 210  0 String[] options = new String[] { "Clean \"Maximum Heap\" Setting",
 211    "Ignore" };
 212  0 int result = JOptionPane.
 213    showOptionDialog(parent,
 214    "The \"Maximum Heap Memory for Interactions JVM\" setting is invalid: \"" + size + "\"\n" +
 215    "Would you like to clean up the \"Maximum Heap\" setting or ignore this potential problem?",
 216    "Invalid Maximum Heap Size",
 217    0,
 218    JOptionPane.QUESTION_MESSAGE,
 219    null,
 220    options,
 221    options[0]);
 222  0 if (result == 0) {
 223    // clean up
 224  0 DrJava.getConfig().setSetting(SLAVE_JVM_XMX, OptionConstants.heapSizeChoices.get(0));
 225    }
 226    }
 227  0 else if (heapSize > 0) {
 228  0 if (!checkHeapSize(heapSize)) {
 229  0 JOptionPane.
 230    showMessageDialog(parent,
 231    "The \"Maximum Heap Memory for Interactions JVM\" setting is too big: \"" + size + "\"\n" +
 232    "DrJava has reset the heap size to the default. You should choose something smaller.",
 233    "Maximum Heap Size Too Big",
 234    JOptionPane.ERROR_MESSAGE);
 235    // clean up
 236  0 DrJava.getConfig().setSetting(SLAVE_JVM_XMX, OptionConstants.heapSizeChoices.get(0));
 237    }
 238    }
 239    }
 240    }
 241   
 242    /** Return the next bigger heap size setting. */
 243  0 static String getNextBiggerHeapSize(long heapSizeMB) {
 244  0 String newSetting = OptionConstants.heapSizeChoices.get(0);
 245  0 for(int i=1; i < OptionConstants.heapSizeChoices.size(); ++i) {
 246  0 try {
 247  0 newSetting = OptionConstants.heapSizeChoices.get(i);
 248  0 float choice = new Float(newSetting);
 249  0 if (choice>=heapSizeMB) {
 250  0 return newSetting;
 251    }
 252    }
 253    catch(NumberFormatException nfe) {
 254  0 return OptionConstants.heapSizeChoices.get(0);
 255    }
 256    }
 257  0 return newSetting;
 258    }
 259   
 260    public static class MasterJVMArgsListener implements OptionListener<String>, OptionConstants {
 261    protected JFrame _parent;
 262  38 public MasterJVMArgsListener(JFrame parent) { _parent = parent; }
 263  0 public void optionChanged(OptionEvent<String> oe) {
 264  0 DrJava.getConfig().removeOptionListener(MASTER_JVM_ARGS, this);
 265    // final OptionListener<String> masterJvmArgsListener = this;
 266  0 if (!oe.value.equals("")) {
 267  0 int result = JOptionPane.
 268    showConfirmDialog(_parent,
 269    "Specifying Main JVM Args is an advanced option. Invalid arguments may cause\n" +
 270    "DrJava to fail on start up. You may need to edit or delete your .drjava preferences file\n" +
 271    "to recover.\n Are you sure you want to set this option?\n" +
 272    "(You will have to restart Drjava before changes take effect.)",
 273    "Confirm Main JVM Arguments", JOptionPane.YES_NO_OPTION);
 274  0 if (result!=JOptionPane.YES_OPTION) {
 275  0 DrJava.getConfig().setSetting(oe.option, "");
 276    }
 277    else {
 278  0 sanitizeMasterJVMArgs(_parent, oe.value, this);
 279    }
 280    }
 281  0 DrJava.getConfig().addOptionListener(MASTER_JVM_ARGS, this);
 282    }
 283    }
 284   
 285  38 @SuppressWarnings("fallthrough")
 286    public static void sanitizeMasterJVMArgs(JFrame parent, String value, final OptionListener<String> l) {
 287  38 int pos = value.indexOf("-Xmx");
 288  38 if ((pos > 1 && Character.isWhitespace(value.charAt(pos-1))) || pos == 0) {
 289  0 int endpos = pos+("-Xmx".length());
 290  0 while((endpos<value.length()) &&
 291    (!Character.isWhitespace(value.charAt(endpos)))) {
 292  0 ++endpos;
 293    }
 294   
 295  0 int startpos = pos+("-Xmx".length());
 296  0 String size = value.substring(startpos,endpos);
 297  0 long factor = 1;
 298  0 long heapSize;
 299  0 switch(size.toLowerCase().charAt(size.length()-1)) {
 300  0 case 'g': { factor *= 1024; /* fall-through intended */ }
 301  0 case 'm': { factor *= 1024; /* fall-through intended */ }
 302  0 case 'k': {
 303  0 factor *= 1024; /* fall-through intended */
 304  0 break;
 305    }
 306  0 default: { if (!Character.isDigit(size.toLowerCase().charAt(size.length()-1))) factor = 0; }
 307    }
 308  0 try {
 309  0 if (factor==1) heapSize = new Long(size);
 310  0 else if (factor>1) heapSize = new Long(size.substring(0,size.length()-1)) * factor;
 311  0 else heapSize = -1;
 312    }
 313  0 catch(NumberFormatException nfe) { heapSize = -1; /* invalid */ }
 314  0 long heapSizeMB = (heapSize / 1024) / 1024;
 315   
 316    // find the next bigger of the choices
 317  0 String newSetting = getNextBiggerHeapSize(heapSizeMB);
 318  0 int result;
 319  0 if (heapSize >= 0) {
 320  0 String[] options = new String[] { "Copy to \"Maximum Heap\" Setting", "Clean \"Master JVM Args\"", "Ignore" };
 321  0 result = JOptionPane.
 322    showOptionDialog(parent,
 323    "You seem to have specified the maximum heap size as part of the\n" +
 324    "\"JVM Args for Main JVM\" setting: \"-Xmx" + size + "\"\n" +
 325    "The \"Maximum Heap Memory for Main JVM\" setting should be used instead.\n" +
 326    "Would you like to copy the value \"" + newSetting + "\" into the \"Maximum Heap\" setting,\n" +
 327    "just clean up \"JVM Args for Main JVM\", or ignore this potential problem?",
 328    "Maximum Heap Size Set in JVM Arguments",
 329    0,
 330    JOptionPane.QUESTION_MESSAGE,
 331    null,
 332    options,
 333    options[0]);
 334    }
 335    else {
 336  0 String[] options = new String[] { "Clean \"Main JVM Args\"", "Ignore" };
 337  0 result = JOptionPane.
 338    showOptionDialog(parent,
 339    "You seem to have specified the maximum heap size as part of the\n" +
 340    "\"JVM Args for Main JVM\" setting: \"-Xmx" + size + "\"\n" +
 341    "The \"Maximum Heap Memory for Main JVM\" setting should be used instead.\n" +
 342    "Furthermore, the specified heap size \"" + size + "\" is invalid.\n" +
 343    "Would you like to clean up the \"JVM Args for Main JVM\"\n" +
 344    "or ignore this potential problem?",
 345    "Maximum Heap Size Set in JVM Arguments",
 346    0,
 347    JOptionPane.QUESTION_MESSAGE,
 348    null,
 349    options,
 350    options[0]);
 351  0 if (result==1) { result = 2; }
 352    }
 353  0 if (result!=2) {
 354    // clean up
 355  0 while(endpos<value.length() && Character.isWhitespace(value.charAt(endpos))) ++endpos;
 356   
 357  0 String newValue = value.substring(0,pos) + value.substring(endpos);
 358  0 DrJava.getConfig().removeOptionListener(MASTER_JVM_ARGS, l);
 359  0 DrJava.getConfig().addOptionListener(MASTER_JVM_ARGS, new OptionListener<String>() {
 360  0 public void optionChanged(OptionEvent<String> oe) {
 361  0 DrJava.getConfig().removeOptionListener(MASTER_JVM_ARGS, this);
 362  0 EventQueue.invokeLater(new Runnable() {
 363  0 public void run() { DrJava.getConfig().addOptionListener(MASTER_JVM_ARGS, l); }
 364    });
 365    }
 366    });
 367  0 DrJava.getConfig().setSetting(MASTER_JVM_ARGS, newValue);
 368  0 if (result == 0) DrJava.getConfig().setSetting(MASTER_JVM_XMX, newSetting); // copy
 369  0 else JOptionPane.showMessageDialog(parent, "You will have to restart DrJava before the change takes effect.");
 370    }
 371    }
 372    }
 373   
 374    public static class MasterJVMXMXListener implements OptionListener<String>, OptionConstants {
 375    protected JFrame _parent;
 376  38 public MasterJVMXMXListener(JFrame parent) { _parent = parent; }
 377  0 public void optionChanged(OptionEvent<String> oe) {
 378  0 DrJava.getConfig().removeOptionListener(MASTER_JVM_XMX, this);
 379  0 sanitizeMasterJVMXMX(_parent, oe.value);
 380  0 JOptionPane.showMessageDialog(_parent, "You will have to restart DrJava before the change takes effect.");
 381  0 DrJava.getConfig().addOptionListener(MASTER_JVM_XMX, this);
 382    }
 383    }
 384   
 385  38 public static void sanitizeMasterJVMXMX(JFrame parent, String value) {
 386  38 if ((!value.equals("")) &&
 387    (!value.equals(OptionConstants.heapSizeChoices.get(0)))) {
 388  0 String size = value.trim();
 389  0 long heapSize;
 390  0 try {
 391  0 heapSize = new Long(size);
 392    }
 393    catch(NumberFormatException nfe) {
 394  0 heapSize = -1; // invalid
 395    }
 396  0 if (heapSize < 0) {
 397  0 String[] options = new String[] { "Clean \"Maximum Heap\" Setting",
 398    "Ignore" };
 399  0 int result = JOptionPane.
 400    showOptionDialog(parent,
 401    "The \"Maximum Heap Memory for Main JVM\" setting is invalid: \"" + size + "\"\n" +
 402    "Would you like to clean up the \"Maximum Heap\" setting or ignore this potential problem?",
 403    "Invalid Maximum Heap Size",
 404    0,
 405    JOptionPane.QUESTION_MESSAGE,
 406    null,
 407    options,
 408    options[0]);
 409  0 if (result == 0) {
 410    // clean up
 411  0 DrJava.getConfig().setSetting(MASTER_JVM_XMX, OptionConstants.heapSizeChoices.get(0));
 412    }
 413    }
 414  0 else if (heapSize > 0) {
 415  0 if (!checkHeapSize(heapSize)) {
 416  0 JOptionPane.
 417    showMessageDialog(parent,
 418    "The \"Maximum Heap Memory for Main JVM\" setting is too big: \"" + size + "\"\n" +
 419    "DrJava has reset the heap size to the default. You should choose something smaller.",
 420    "Maximum Heap Size Too Big",
 421    JOptionPane.ERROR_MESSAGE);
 422    // clean up
 423  0 DrJava.getConfig().setSetting(MASTER_JVM_XMX, OptionConstants.heapSizeChoices.get(0));
 424    }
 425    }
 426    }
 427    }
 428   
 429    /** @return true if a JVM can be created with the specified heap size (in MB) */
 430  0 public static boolean checkHeapSize(long heapSize) {
 431  0 int exitValue = 1;
 432  0 try {
 433  0 JVMBuilder jvmb = JVMBuilder.DEFAULT.jvmArguments("-Xmx"+heapSize+"M");
 434  0 Process p = jvmb.start(MemoryCheckDummy.class.getName());
 435  0 exitValue = p.waitFor();
 436    }
 437  0 catch(java.io.IOException e) { exitValue = 1; }
 438  0 catch(InterruptedException e) { exitValue = 1; }
 439  0 return (exitValue==0);
 440    }
 441   
 442    /** Class that gets executed to check if the selected heap size is possible. */
 443    public static class MemoryCheckDummy {
 444  0 public static void main(String[] args) {
 445  0 final StringBuilder sb = new StringBuilder("DrJava Version : ");
 446  0 sb.append(edu.rice.cs.drjava.Version.getVersionString());
 447  0 sb.append("\nDrJava Build Time: ");
 448  0 sb.append(edu.rice.cs.drjava.Version.getBuildTimeString());
 449  0 sb.append("\n\nUsed memory: about ");
 450  0 sb.append(StringOps.memSizeToString(Runtime.getRuntime().totalMemory()-Runtime.getRuntime().freeMemory()));
 451  0 sb.append("\nFree memory: about ");
 452  0 sb.append(StringOps.memSizeToString(Runtime.getRuntime().freeMemory()));
 453  0 sb.append("\nTotal memory: about ");
 454  0 sb.append(StringOps.memSizeToString(Runtime.getRuntime().totalMemory()));
 455  0 sb.append("\nTotal memory can expand to: about ");
 456  0 sb.append(StringOps.memSizeToString(Runtime.getRuntime().maxMemory()));
 457  0 System.out.println(sb.toString());
 458  0 System.exit(0);
 459    }
 460    }
 461   
 462    public static class JavadocCustomParamsListener implements OptionListener<String>, OptionConstants {
 463    protected JFrame _parent;
 464  38 public JavadocCustomParamsListener(JFrame parent) { _parent = parent; }
 465  0 public void optionChanged(OptionEvent<String> oe) {
 466  0 sanitizeJavadocCustomParams(_parent, oe.value);
 467    }
 468    }
 469   
 470  38 public static void sanitizeJavadocCustomParams(JFrame parent,
 471    String value) {
 472  38 boolean containsPrivate = (value.indexOf("-private") >= 0);
 473  38 boolean containsProtected = (value.indexOf("-protected") >= 0);
 474  38 boolean containsPublic = (value.indexOf("-public") >= 0);
 475  38 boolean containsPackage = (value.indexOf("-package") >= 0);
 476   
 477  38 if (containsPrivate || containsProtected || containsPublic || containsPackage) {
 478  0 StringBuilder sb = new StringBuilder();
 479  0 if (containsPublic) { sb.append("-public "); }
 480  0 if (containsProtected) { sb.append("-protected "); }
 481  0 if (containsPrivate) { sb.append("-private "); }
 482  0 if (containsPackage) { sb.append("-package "); }
 483  0 String[] options = new String[] { "Copy to \"Access Level\" Setting",
 484    "Clean \"Custom Javadoc Parameters\"",
 485    "Ignore" };
 486  0 int result = JOptionPane.
 487    showOptionDialog(parent,
 488    "You seem to have specified " + sb.toString() + "as part of the\n" +
 489    "\"Custom Javadoc Parameters\" setting. The \"Access Level\"\n" +
 490    "setting should be used instead. Would you like to copy the\n" +
 491    "parameter into the \"Access Level\" setting, just clean up\n" +
 492    "\"Custom Javadoc Parameters\", or ignore this potential problem?",
 493    "Access Level Set in Custom Javadoc Parameters",
 494    0,
 495    JOptionPane.QUESTION_MESSAGE,
 496    null,
 497    options,
 498    options[0]);
 499  0 if (result!=2) {
 500  0 if (result == 0) {
 501    // copy
 502  0 if (containsPublic) { DrJava.getConfig().setSetting(JAVADOC_ACCESS_LEVEL, "public"); }
 503  0 else if (containsProtected) { DrJava.getConfig().setSetting(JAVADOC_ACCESS_LEVEL, "protected"); }
 504  0 else if (containsPrivate) { DrJava.getConfig().setSetting(JAVADOC_ACCESS_LEVEL, "private"); }
 505  0 else if (containsPackage) { DrJava.getConfig().setSetting(JAVADOC_ACCESS_LEVEL, "package"); }
 506    }
 507    // clean up
 508  0 String[] params = value.split("(-private|-protected|-package|-public)");
 509  0 sb = new StringBuilder();
 510  0 for(int i = 0; i < params.length; i++) {
 511  0 if(!params[i].trim().equals("")) { sb.append(params[i].trim()); sb.append(' '); }
 512    }
 513  0 DrJava.getConfig().setSetting(JAVADOC_CUSTOM_PARAMS, sb.toString().trim());
 514    }
 515    }
 516    }
 517   
 518    public static class LookAndFeelListener implements OptionListener<String> {
 519    protected JFrame _parent;
 520  38 public LookAndFeelListener(JFrame parent) { _parent = parent; }
 521  0 public void optionChanged(OptionEvent<String> oe) {
 522    // try {
 523    // UIManager.setLookAndFeel(oe.value);
 524    // SwingUtilities.updateComponentTreeUI(MainFrame.this);
 525    // if (_debugPanel != null) {
 526    // SwingUtilities.updateComponentTreeUI(_debugPanel);
 527    // }
 528    // if (_configFrame != null) {
 529    // SwingUtilities.updateComponentTreeUI(_configFrame);
 530    // }
 531    // if (_helpFrame != null) {
 532    // SwingUtilities.updateComponentTreeUI(_helpFrame);
 533    // }
 534    // if (_aboutDialog != null) {
 535    // SwingUtilities.updateComponentTreeUI(_aboutDialog);
 536    // }
 537    // SwingUtilities.updateComponentTreeUI(_navPanePopupMenu);
 538    // SwingUtilities.updateComponentTreeUI(_interactionsPanePopupMenu);
 539    // SwingUtilities.updateComponentTreeUI(_consolePanePopupMenu);
 540    // SwingUtilities.updateComponentTreeUI(_openChooser);
 541    // SwingUtilities.updateComponentTreeUI(_saveChooser);
 542    // Iterator<TabbedPanel> it = _tabs.iterator();
 543    // while (it.hasNext()) {
 544    // SwingUtilities.updateComponentTreeUI(it.next());
 545    // }
 546    // }
 547    // catch (Exception ex) {
 548    // _showError(ex, "Could Not Set Look and Feel",
 549    // "An error occurred while trying to set the look and feel.");
 550    // }
 551   
 552  0 String title = "Apply Look and Feel";
 553  0 String msg = "Look and feel changes will take effect when you restart DrJava.";
 554  0 if (DrJava.getConfig().getSetting(WARN_CHANGE_LAF).booleanValue()) {
 555  0 ConfirmCheckBoxDialog dialog =
 556    new ConfirmCheckBoxDialog(_parent, title, msg,
 557    "Do not show this message again",
 558    JOptionPane.INFORMATION_MESSAGE,
 559    JOptionPane.DEFAULT_OPTION);
 560  0 if (dialog.show() == JOptionPane.OK_OPTION && dialog.getCheckBoxValue()) {
 561  0 DrJava.getConfig().setSetting(WARN_CHANGE_LAF, Boolean.FALSE);
 562    }
 563    }
 564    }
 565    }
 566   
 567    public static class PlasticThemeListener implements OptionListener<String> {
 568    protected JFrame _parent;
 569  38 public PlasticThemeListener(JFrame parent) { _parent = parent; }
 570  0 public void optionChanged(OptionEvent<String> oe) {
 571  0 String title = "Apply Theme";
 572  0 String msg = "Changes to the theme will take effect when you restart DrJava.";
 573  0 if (DrJava.getConfig().getSetting(WARN_CHANGE_THEME).booleanValue()) {
 574  0 ConfirmCheckBoxDialog dialog =
 575    new ConfirmCheckBoxDialog(_parent, title, msg,
 576    "Do not show this message again",
 577    JOptionPane.INFORMATION_MESSAGE,
 578    JOptionPane.DEFAULT_OPTION);
 579  0 if (dialog.show() == JOptionPane.OK_OPTION && dialog.getCheckBoxValue()) {
 580  0 DrJava.getConfig().setSetting(WARN_CHANGE_THEME, Boolean.FALSE);
 581    }
 582    }
 583    }
 584    }
 585   
 586    public static class RequiresDrJavaRestartListener<T> implements OptionListener<T> {
 587    protected JFrame _parent;
 588    protected String _description;
 589  76 public RequiresDrJavaRestartListener(JFrame parent, String description) {
 590  76 _parent = parent;
 591  76 _description = description;
 592    }
 593  0 public void optionChanged(OptionEvent<T> oe) {
 594  0 String title = "Apply Preference Changes";
 595  0 String msg = "Changes to the '"+_description+"' preferences\nwill only take effect when you restart DrJava.";
 596  0 if (DrJava.getConfig().getSetting(WARN_CHANGE_MISC).booleanValue()) {
 597  0 ConfirmCheckBoxDialog dialog =
 598    new ConfirmCheckBoxDialog(_parent, title, msg,
 599    "Do not show this message again",
 600    JOptionPane.INFORMATION_MESSAGE,
 601    JOptionPane.DEFAULT_OPTION);
 602  0 if (dialog.show() == JOptionPane.OK_OPTION && dialog.getCheckBoxValue()) {
 603  0 DrJava.getConfig().setSetting(WARN_CHANGE_MISC, Boolean.FALSE);
 604    }
 605    }
 606    }
 607    }
 608   
 609    public static class RequiresInteractionsRestartListener<T> implements OptionListener<T> {
 610    protected JFrame _parent;
 611    protected String _description;
 612  152 public RequiresInteractionsRestartListener(JFrame parent, String description) {
 613  152 _parent = parent;
 614  152 _description = description;
 615    }
 616  0 public void optionChanged(OptionEvent<T> oe) {
 617  0 String title = "Apply Preference Changes";
 618  0 String msg = "Changes to the '"+_description+"' preferences\nwill only take effect when you reset the Interactions Pane.";
 619  0 if (DrJava.getConfig().getSetting(WARN_CHANGE_INTERACTIONS).booleanValue()) {
 620  0 ConfirmCheckBoxDialog dialog =
 621    new ConfirmCheckBoxDialog(_parent, title, msg,
 622    "Do not show this message again",
 623    JOptionPane.INFORMATION_MESSAGE,
 624    JOptionPane.DEFAULT_OPTION);
 625  0 if (dialog.show() == JOptionPane.OK_OPTION && dialog.getCheckBoxValue()) {
 626  0 DrJava.getConfig().setSetting(WARN_CHANGE_INTERACTIONS, Boolean.FALSE);
 627    }
 628    }
 629    }
 630    }
 631   
 632    public static class DefaultCompilerListener implements OptionListener<String> {
 633    protected JFrame _parent;
 634  38 public DefaultCompilerListener(JFrame parent) { _parent = parent; }
 635  0 public void optionChanged(OptionEvent<String> oe) {
 636  0 String title = "Apply Default Compiler Preference Change";
 637  0 String msg = "Default Compiler Preference will take effect when you restart DrJava.";
 638  0 if (DrJava.getConfig().getSetting(WARN_CHANGE_DCP).booleanValue()) {
 639  0 ConfirmCheckBoxDialog dialog =
 640    new ConfirmCheckBoxDialog(_parent, title, msg,
 641    "Do not show this message again",
 642    JOptionPane.INFORMATION_MESSAGE,
 643    JOptionPane.DEFAULT_OPTION);
 644  0 if (dialog.show() == JOptionPane.OK_OPTION && dialog.getCheckBoxValue()) {
 645  0 DrJava.getConfig().setSetting(WARN_CHANGE_DCP, Boolean.FALSE);
 646    }
 647    }
 648    }
 649    }
 650    }