Clover coverage report - DrJava Test Coverage (drjava-20110828-r5448)
Coverage timestamp: Sun Aug 28 2011 03:13:33 CDT
file stats: LOC: 640   Methods: 30
NCLOC: 540   Classes: 3
 
 Source file Conditionals Statements Methods TOTAL
AboutDialog.java 37.5% 78.3% 53.3% 69.8%
coverage coverage
 1    /*BEGIN_COPYRIGHT_BLOCK
 2    *
 3    * Copyright (c) 2001-2010, JavaPLT group at Rice University (javaplt@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.ui;
 38   
 39    import edu.rice.cs.drjava.platform.PlatformFactory;
 40    import edu.rice.cs.util.swing.*;
 41    import edu.rice.cs.util.UnexpectedException;
 42    import edu.rice.cs.util.StringOps;
 43    import edu.rice.cs.drjava.DrJava;
 44    import edu.rice.cs.drjava.Version;
 45    import edu.rice.cs.drjava.config.OptionConstants;
 46    import edu.rice.cs.drjava.config.FileConfiguration;
 47    import javax.swing.*;
 48    import javax.swing.border.*;
 49    import javax.swing.event.ChangeListener;
 50    import javax.swing.event.ChangeEvent;
 51    import java.awt.datatransfer.Clipboard;
 52    import java.awt.datatransfer.StringSelection;
 53    import java.awt.event.*;
 54    import java.awt.*;
 55   
 56    import java.io.*;
 57    import java.net.URL;
 58    import java.util.Map;
 59    import java.util.Properties;
 60   
 61    /** About dialog.
 62    * @version $Id: AboutDialog.java 5232 2010-04-24 00:14:05Z mgricken $
 63    */
 64    public class AboutDialog extends JDialog implements ActionListener {
 65   
 66    private static ImageInfo CSLOGO = new ImageInfo("RiceCS.gif",new Color(0x423585)),
 67    SF = new ImageInfo("SourceForge.gif",Color.black),
 68    DRJAVA = new ImageInfo("DrJava.png",new Color(0xCCCCFF));
 69   
 70    private final JButton _okButton = new JButton("OK");
 71   
 72    /** the button that copies the system properties to the clipboard */
 73    private JButton _copyButton;
 74   
 75    /** the table with the System Properties information */
 76    private JTable _propertiesTable;
 77   
 78    /** index the System Properties tab, one of the tabs in _tabs */
 79    private int _propertiesTabIndex;
 80   
 81    /** the pane with tabs to select */
 82    private final JTabbedPane _tabs = new JTabbedPane();
 83   
 84  38 public AboutDialog(JFrame owner) {
 85  38 super(owner, "About DrJava", true); // (changed to non-modal for now)
 86   
 87  38 buildGUI(getContentPane());
 88  38 getRootPane().setDefaultButton(_okButton);
 89    // pack();
 90    // setSize((int) (.8f*owner.getWidth()),(int) (.8f*owner.getHeight()));
 91  38 setSize(550, 400);
 92    // suggested from zaq@nosi.com, to keep the frame on the screen!
 93    //System.out.println("Dialog created...");
 94    }
 95   
 96  0 public void setVisible(boolean vis) {
 97  0 _tabs.remove(0);
 98  0 addTab(_tabs,"About",createCopyrightTab(), 0);
 99  0 _tabs.setSelectedIndex(0);
 100   
 101  0 if (vis) {
 102    // suggested from zaq@nosi.com, to keep the frame on the screen!
 103    //Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
 104    //Dimension frameSize = this.getSize();
 105  0 Utilities.setPopupLoc(this, getOwner());
 106    }
 107  0 super.setVisible(vis);
 108    }
 109   
 110  38 public void buildGUI(Container cp) {
 111  38 cp.setLayout(new BorderLayout());
 112  38 JLabel drjava = createImageLabel(DRJAVA,JLabel.LEFT);
 113  38 if (drjava != null) {
 114  38 drjava.setBorder(new CompoundBorder(new EmptyBorder(5,5,5,5), drjava.getBorder()));
 115  38 drjava.setCursor(new Cursor(Cursor.HAND_CURSOR));
 116  38 final String url = "http://drjava.org/";
 117  38 drjava.setToolTipText(url);
 118  38 drjava.addMouseListener(new MouseListener() {
 119  0 public void mousePressed(MouseEvent e) { }
 120  0 public void mouseReleased(MouseEvent e) { }
 121  0 public void mouseEntered(MouseEvent e) { }
 122  0 public void mouseExited(MouseEvent e) { }
 123  0 public void mouseClicked(MouseEvent e) {
 124  0 try {
 125  0 PlatformFactory.ONLY.openURL(new URL(url));
 126    } catch(Exception ex) { /* ignore, just not open web page */ }
 127    }
 128    });
 129   
 130  38 JPanel djPanel = new JPanel(new GridLayout(1,1));
 131  38 djPanel.add(drjava);
 132  38 djPanel.setBorder(new CompoundBorder(new EmptyBorder(5,5,5,5), new EtchedBorder()));
 133  38 cp.add(djPanel,BorderLayout.NORTH);
 134    }
 135  38 addTab(_tabs,"About",createCopyrightTab());
 136  38 LICENSE = getLicense();
 137  0 if (LICENSE != null) addTab(_tabs,"DrJava License",createTextScroller(LICENSE));
 138   
 139  38 addTab(_tabs,"DynamicJava License",createTextScroller(DYADE_LICENSE));
 140  38 addTab(_tabs,"Eclipse License",createTextScroller(ECLIPSE_LICENSE));
 141  38 addTab(_tabs,"System Properties",createSysPropTab());
 142  38 _propertiesTabIndex = _tabs.getTabCount()-1;
 143  38 cp.add(createBottomBar(),BorderLayout.SOUTH);
 144  38 cp.add(_tabs,BorderLayout.CENTER);
 145    }
 146   
 147  38 private JComponent createSysPropTab() {
 148  38 Properties props = System.getProperties();
 149  38 int size = props.size();
 150  38 String[][] rowData = new String[size][2];
 151  38 int rowNum = 0;
 152  38 for (Map.Entry<Object, Object> entry : props.entrySet()) {
 153  2090 rowData[rowNum][0] = (String) entry.getKey();
 154  2090 rowData[rowNum][1] = (String) entry.getValue();
 155  2090 rowNum++;
 156    }
 157  38 java.util.Arrays.sort(rowData,new java.util.Comparator<String[]>() {
 158  10070 public int compare(String[] o1, String[] o2) {
 159  10070 return o1[0].compareTo(o2[0]);
 160    }
 161    });
 162  38 String[] nvStrings = new String[]{"Name","Value"};
 163  38 UneditableTableModel model = new UneditableTableModel(rowData, nvStrings);
 164  38 _propertiesTable = new JTable(model);
 165  38 JScrollPane scroller = new BorderlessScrollPane(_propertiesTable);
 166  38 wrapBorder(scroller,new EmptyBorder(5,0,0,0));
 167  38 JPanel propTab = new JPanel(new BorderLayout());
 168  38 propTab.add(new JLabel("Current system properties:"),BorderLayout.NORTH);
 169  38 propTab.add(scroller,BorderLayout.CENTER);
 170  38 return propTab;
 171    }
 172   
 173  152 private static void addTab(JTabbedPane tabs, String title, JComponent tab) {
 174  152 wrapBorder(tab,new EmptyBorder(5,6,6,5));
 175  152 tabs.addTab(title,tab);
 176    }
 177   
 178  0 private static void addTab(JTabbedPane tabs, String title, JComponent tab, int i) {
 179  0 wrapBorder(tab,new EmptyBorder(5,6,6,5));
 180  0 tabs.insertTab(title, null, tab, "", i);
 181    }
 182   
 183  38 public static JComponent createCopyrightTab() {
 184  38 final JPanel panel = new JPanel(new BorderLayout());
 185   
 186  38 final StringBuilder sb = new StringBuilder("DrJava Version : ");
 187  38 sb.append(Version.getVersionString());
 188  38 FileConfiguration config = DrJava.getConfig();
 189  38 if (config!=null) {
 190  38 String customDrJavaJarVersionSuffix = config.getSetting(OptionConstants.CUSTOM_DRJAVA_JAR_VERSION_SUFFIX);
 191  38 if (customDrJavaJarVersionSuffix.length()>0) {
 192  0 sb.append(" with ");
 193  0 sb.append(customDrJavaJarVersionSuffix);
 194    }
 195    }
 196  38 sb.append("\nDrJava Build Time: ");
 197  38 sb.append(Version.getBuildTimeString());
 198  38 sb.append("\n\nDrJava Configuration File: ");
 199  38 sb.append(DrJava.getPropertiesFile().getAbsolutePath());
 200  38 sb.append("\n\nUsed memory: about ");
 201  38 sb.append(StringOps.memSizeToString(Runtime.getRuntime().totalMemory()-Runtime.getRuntime().freeMemory()));
 202  38 sb.append("\nFree memory: about ");
 203  38 sb.append(StringOps.memSizeToString(Runtime.getRuntime().freeMemory()));
 204  38 sb.append("\nTotal memory: about ");
 205  38 sb.append(StringOps.memSizeToString(Runtime.getRuntime().totalMemory()));
 206  38 sb.append("\nTotal memory can expand to: about ");
 207  38 sb.append(StringOps.memSizeToString(Runtime.getRuntime().maxMemory()));
 208  38 sb.append("\n\n");
 209  38 sb.append(COPYRIGHT);
 210  38 final JComponent copy = createTextScroller(sb.toString());
 211  38 wrapBorder(copy,new EmptyBorder(0,0,5,0));
 212   
 213    // deal with logos now (calibrate size)
 214  38 final LogoList logos = new LogoList();
 215  38 logos.addLogo(createBorderedLabel(CSLOGO,new EmptyBorder(5,5,5,5)), "http://compsci.rice.edu/");
 216  38 logos.addLogo(createBorderedLabel(SF,null), "http://sourceforge.net/projects/drjava/");
 217  38 logos.resizeLogos();
 218   
 219    // add to panel
 220  38 final JPanel logoPanel = new JPanel();
 221  38 logoPanel.setLayout(new BoxLayout(logoPanel,BoxLayout.X_AXIS));
 222  38 logoPanel.add(Box.createHorizontalGlue());
 223  38 for (JComponent l : logos) {
 224  76 logoPanel.add(l);
 225  76 l.setCursor(new Cursor(Cursor.HAND_CURSOR));
 226  76 final String url = (String)l.getClientProperty("url");
 227  76 if (url != null) {
 228  76 l.setToolTipText(url);
 229  76 l.addMouseListener(new MouseListener() {
 230  0 public void mousePressed(MouseEvent e) { }
 231  0 public void mouseReleased(MouseEvent e) { }
 232  0 public void mouseEntered(MouseEvent e) { }
 233  0 public void mouseExited(MouseEvent e) { }
 234  0 public void mouseClicked(MouseEvent e) {
 235  0 try { PlatformFactory.ONLY.openURL(new URL(url)); }
 236    catch(Exception ex) { /* ignore, just not open web page */ }
 237    }
 238    });
 239    }
 240  76 logoPanel.add(Box.createHorizontalGlue());
 241    }
 242  38 panel.add(logoPanel,BorderLayout.SOUTH);
 243  38 panel.add(copy,BorderLayout.CENTER);
 244  38 return panel;
 245    }
 246   
 247    private static class LogoList extends java.util.LinkedList<JPanel> implements Serializable {
 248    private int width = Integer.MIN_VALUE;
 249    private int height = Integer.MIN_VALUE;
 250  76 private void addLogo(JPanel logo, String url) {
 251  76 if (logo != null) {
 252  76 Dimension d = logo.getMinimumSize();
 253  76 width = Math.max(width,d.width);
 254  76 height = Math.max(height,d.height);
 255  76 add(logo);
 256  76 if (url != null) logo.putClientProperty("url", url);
 257    }
 258    }
 259   
 260  38 private void resizeLogos() {
 261  38 Dimension d = new Dimension(width,height);
 262  38 for (JComponent i : this) {
 263  76 i.setMinimumSize(d);
 264  76 i.setMaximumSize(d);
 265  76 i.setPreferredSize(d);
 266    }
 267    }
 268    }
 269   
 270  76 public static JPanel createBorderedLabel(ImageInfo info, EmptyBorder pad) {
 271  76 JLabel label = createImageLabel(info,JLabel.CENTER);
 272  0 if (label == null) return null;
 273  76 JPanel panel = new JPanel(new GridLayout(1,1));
 274  76 panel.setOpaque(true);
 275  76 panel.setBackground(info.color);
 276  76 panel.setBorder(pad);
 277  76 wrapBorder(panel,new EtchedBorder());
 278  76 panel.add(label);
 279  76 return panel;
 280    }
 281   
 282  114 public static JLabel createImageLabel(ImageInfo info, int align) {
 283  114 ImageIcon icon = MainFrame.getIcon(info.name);
 284  0 if (icon == null) return null;
 285  114 JLabel label = new JLabel(icon,align);
 286  114 label.setOpaque(true);
 287  114 label.setBackground(info.color);
 288  114 return label;
 289    }
 290   
 291  114 public static JTextArea createTextArea(String text) {
 292  114 JTextArea textArea = new JTextArea(text);
 293  114 textArea.setEditable(false);
 294  114 textArea.setLineWrap(true);
 295  114 textArea.setWrapStyleWord(true);
 296  114 textArea.setCaretPosition(0);
 297  114 return textArea;
 298    }
 299   
 300  114 public static JScrollPane createTextScroller(String text) {
 301  114 return new BorderlessScrollPane(createTextArea(text));
 302    }
 303   
 304  38 private JPanel createBottomBar() {
 305  38 JPanel panel = new JPanel(new BorderLayout());
 306  38 JPanel buttonPanel = new JPanel();
 307  38 _copyButton = new JButton(new AbstractAction("Copy System Properties") {
 308  0 public void actionPerformed(ActionEvent e) {
 309  0 Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();
 310  0 StringSelection contents = new StringSelection(DrJavaErrorWindow.getSystemAndDrJavaInfo());
 311  0 cb.setContents(contents, null);
 312    }
 313    });
 314  38 _copyButton.setToolTipText("Copy information about your computer into the clipboard so it can be pasted.");
 315    // button always visible
 316    // _tabs.addChangeListener(new ChangeListener() {
 317    // // This method is called whenever the selected tab changes
 318    // public void stateChanged(ChangeEvent evt) {
 319    // _copyButton.setVisible(_tabs.getSelectedIndex() == _propertiesTabIndex);
 320    // }
 321    // });
 322    // _copyButton.setVisible(_tabs.getSelectedIndex() == _propertiesTabIndex);
 323  38 _okButton.addActionListener(this);
 324  38 buttonPanel.add(_copyButton);
 325  38 buttonPanel.add(_okButton);
 326  38 panel.add(buttonPanel,BorderLayout.EAST);
 327  38 wrapBorder(panel,new EmptyBorder(5,5,5,5));
 328  38 return panel;
 329    }
 330   
 331  0 public void actionPerformed(ActionEvent e) {
 332  0 setVisible(false);
 333    }
 334   
 335    public static final String COPYRIGHT =
 336    "Copyright (c) 2001-2010, JavaPLT group at Rice University (javaplt@rice.edu)\n" +
 337    "All rights reserved.\n\n" +
 338    "Redistribution and use in source and binary forms, with or without " +
 339    "modification, are permitted provided that the following conditions are met:\n" +
 340    "* Redistributions of source code must retain the above copyright " +
 341    "notice, this list of conditions and the following disclaimer.\n" +
 342    "* Redistributions in binary form must reproduce the above copyright " +
 343    "notice, this list of conditions and the following disclaimer in the " +
 344    "documentation and/or other materials provided with the distribution.\n" +
 345    "* Neither the names of DrJava, the JavaPLT group, Rice University, nor the " +
 346    "names of its contributors may be used to endorse or promote products " +
 347    "derived from this software without specific prior written permission.\n\n" +
 348    "THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS " +
 349    "\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT " +
 350    "LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR " +
 351    "A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR " +
 352    "CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, " +
 353    "EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, " +
 354    "PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR " +
 355    "PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF " +
 356    "LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING " +
 357    "NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS " +
 358    "SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n" +
 359    "This software is Open Source Initiative approved Open Source Software.\n" +
 360    "Open Source Initative Approved is a trademark of the Open Source Initiative.\n";
 361    private static String LICENSE;
 362    private static boolean initLicense = false;
 363    public static final String DYADE_LICENSE =
 364    "DynamicJava - Copyright \u00a9 1999 Dyade\n\nPermission is hereby granted," +
 365    " free of charge, to any person obtaining a copy of this software and associated" +
 366    " documentation files (the \"Software\"), to deal in the Software without restriction," +
 367    " including without limitation the rights to use, copy, modify, merge, publish, distribute," +
 368    " sublicense, and/or sell copies of the Software, and to permit persons to whom the Software" +
 369    " is furnished to do so, subject to the following conditions:\n\n" +
 370    "The above copyright notice and this permission notice shall be included in all copies or" +
 371    " substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY" +
 372    " OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY," +
 373    " FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL DYADE BE LIABLE FOR ANY CLAIM," +
 374    " DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT" +
 375    " OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n" +
 376    "Except as contained in this notice, the name of Dyade shall not be used in advertising or otherwise" +
 377    " to promote the sale, use or other dealings in this Software without prior written authorization from Dyade.";
 378    public static final String ECLIPSE_LICENSE =
 379    "Eclipse Public License - v 1.0\n"+
 380    "\n" +
 381    "THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE " +
 382    "PUBLIC LICENSE (\"AGREEMENT\"). ANY USE, REPRODUCTION OR DISTRIBUTION " +
 383    "OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.\n" +
 384    "\n" +
 385    "1. DEFINITIONS\n" +
 386    "\n" +
 387    "\"Contribution\" means:\n" +
 388    "\n" +
 389    "a) in the case of the initial Contributor, the initial code and documentation distributed " +
 390    "under this Agreement, and\n" +
 391    "\n" +
 392    "b) in the case of each subsequent Contributor:\n" +
 393    "\n" +
 394    "i) changes to the Program, and\n" +
 395    "\n" +
 396    "ii) additions to the Program;\n" +
 397    "\n" +
 398    "where such changes and/or additions to the Program originate from and are distributed by " +
 399    "that particular Contributor. A Contribution 'originates' from a Contributor if it was added " +
 400    "to the Program by such Contributor itself or anyone acting on such Contributor's behalf. " +
 401    "Contributions do not include additions to the Program which: (i) are separate modules of " +
 402    "software distributed in conjunction with the Program under their own license agreement, " +
 403    "and (ii) are not derivative works of the Program.\n" +
 404    "\n" +
 405    "\"Contributor\" means any person or entity that distributes the Program.\n" +
 406    "\n" +
 407    "\"Licensed Patents\" mean patent claims licensable by a Contributor which are necessarily " +
 408    "infringed by the use or sale of its Contribution alone or when combined with the Program.\n" +
 409    "\n" +
 410    "\"Program\" means the Contributions distributed in accordance with this Agreement.\n" +
 411    "\n" +
 412    "\"Recipient\" means anyone who receives the Program under this Agreement, including all " +
 413    "Contributors.\n" +
 414    "\n" +
 415    "2. GRANT OF RIGHTS\n" +
 416    "\n" +
 417    "a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a " +
 418    "non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare " +
 419    "derivative works of, publicly display, publicly perform, distribute and sublicense " +
 420    "the Contribution of such Contributor, if any, and such derivative works, in source " +
 421    "code and object code form.\n" +
 422    "\n" +
 423    "b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a " +
 424    "non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, " +
 425    "use, sell, offer to sell, import and otherwise transfer the Contribution of such " +
 426    "Contributor, if any, in source code and object code form. This patent license shall " +
 427    "apply to the combination of the Contribution and the Program if, at the time the " +
 428    "Contribution is added by the Contributor, such addition of the Contribution causes " +
 429    "such combination to be covered by the Licensed Patents. The patent license shall not " +
 430    "apply to any other combinations which include the Contribution. No hardware per se " +
 431    "is licensed hereunder.\n" +
 432    "\n" +
 433    "c) Recipient understands that although each Contributor grants the licenses to its " +
 434    "Contributions set forth herein, no assurances are provided by any Contributor that " +
 435    "the Program does not infringe the patent or other intellectual property rights of " +
 436    "any other entity. Each Contributor disclaims any liability to Recipient for claims " +
 437    "brought by any other entity based on infringement of intellectual property rights " +
 438    "or otherwise. As a condition to exercising the rights and licenses granted hereunder, " +
 439    "each Recipient hereby assumes sole responsibility to secure any other intellectual " +
 440    "property rights needed, if any. For example, if a third party patent license is " +
 441    "required to allow Recipient to distribute the Program, it is Recipient's responsibility " +
 442    "to acquire that license before distributing the Program.\n" +
 443    "\n" +
 444    "d) Each Contributor represents that to its knowledge it has sufficient copyright " +
 445    "rights in its Contribution, if any, to grant the copyright license set forth in " +
 446    "this Agreement.\n" +
 447    "\n" +
 448    "3. REQUIREMENTS\n" +
 449    "\n" +
 450    "A Contributor may choose to distribute the Program in object code form under its " +
 451    "own license agreement, provided that:\n" +
 452    "\n" +
 453    "a) it complies with the terms and conditions of this Agreement; and\n" +
 454    "\n" +
 455    "b) its license agreement:\n" +
 456    "\n" +
 457    "i) effectively disclaims on behalf of all Contributors all warranties and conditions, " +
 458    "express and implied, including warranties or conditions of title and non-infringement, " +
 459    "and implied warranties or conditions of merchantability and fitness for a particular " +
 460    "purpose;\n" +
 461    "\n" +
 462    "ii) effectively excludes on behalf of all Contributors all liability for damages, " +
 463    "including direct, indirect, special, incidental and consequential damages, such as " +
 464    "lost profits;\n" +
 465    "\n" +
 466    "iii) states that any provisions which differ from this Agreement are offered by " +
 467    "that Contributor alone and not by any other party; and\n" +
 468    "\n" +
 469    "iv) states that source code for the Program is available from such Contributor, and " +
 470    "informs licensees how to obtain it in a reasonable manner on or through a medium " +
 471    "customarily used for software exchange.\n" +
 472    "\n" +
 473    "When the Program is made available in source code form:\n" +
 474    "\n" +
 475    "a) it must be made available under this Agreement; and\n" +
 476    "\n" +
 477    "b) a copy of this Agreement must be included with each copy of the Program.\n" +
 478    "\n" +
 479    "Contributors may not remove or alter any copyright notices contained within the " +
 480    "Program.\n" +
 481    "\n" +
 482    "Each Contributor must identify itself as the originator of its Contribution, if " +
 483    "any, in a manner that reasonably allows subsequent Recipients to identify the " +
 484    "originator of the Contribution.\n" +
 485    "\n" +
 486    "4. COMMERCIAL DISTRIBUTION\n" +
 487    "\n" +
 488    "Commercial distributors of software may accept certain responsibilities with " +
 489    "respect to end users, business partners and the like. While this license is intended " +
 490    "to facilitate the commercial use of the Program, the Contributor who includes the " +
 491    "Program in a commercial product offering should do so in a manner which does not " +
 492    "create potential liability for other Contributors. Therefore, if a Contributor " +
 493    "includes the Program in a commercial product offering, such Contributor " +
 494    "(\"Commercial Contributor\") hereby agrees to defend and indemnify every other " +
 495    "Contributor (\"Indemnified Contributor\") against any losses, damages and costs " +
 496    "(collectively \"Losses\") arising from claims, lawsuits and other legal actions " +
 497    "brought by a third party against the Indemnified Contributor to the extent caused " +
 498    "by the acts or omissions of such Commercial Contributor in connection with its " +
 499    "distribution of the Program in a commercial product offering. The obligations in " +
 500    "this section do not apply to any claims or Losses relating to any actual or " +
 501    "alleged intellectual property infringement. In order to qualify, an Indemnified " +
 502    "Contributor must: a) promptly notify the Commercial Contributor in writing of " +
 503    "such claim, and b) allow the Commercial Contributor to control, and cooperate with " +
 504    "the Commercial Contributor in, the defense and any related settlement negotiations. " +
 505    "The Indemnified Contributor may participate in any such claim at its own expense.\n" +
 506    "\n" +
 507    "For example, a Contributor might include the Program in a commercial product " +
 508    "offering, Product X. That Contributor is then a Commercial Contributor. If that " +
 509    "Commercial Contributor then makes performance claims, or offers warranties related " +
 510    "to Product X, those performance claims and warranties are such Commercial " +
 511    "Contributor's responsibility alone. Under this section, the Commercial Contributor " +
 512    "would have to defend claims against the other Contributors related to those " +
 513    "performance claims and warranties, and if a court requires any other Contributor " +
 514    "to pay any damages as a result, the Commercial Contributor must pay those damages.\n" +
 515    "\n" +
 516    "5. NO WARRANTY\n" +
 517    "\n" +
 518    "EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN " +
 519    "\"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR " +
 520    "IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, " +
 521    "NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each " +
 522    "Recipient is solely responsible for determining the appropriateness of using and " +
 523    "distributing the Program and assumes all risks associated with its exercise of " +
 524    "rights under this Agreement , including but not limited to the risks and costs of " +
 525    "program errors, compliance with applicable laws, damage to or loss of data, " +
 526    "programs or equipment, and unavailability or interruption of operations.\n" +
 527    "\n" +
 528    "6. DISCLAIMER OF LIABILITY\n" +
 529    "\n" +
 530    "EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY " +
 531    "CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, " +
 532    "SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST " +
 533    "PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, " +
 534    "STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY " +
 535    "OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS " +
 536    "GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\n" +
 537    "\n" +
 538    "7. GENERAL\n" +
 539    "\n" +
 540    "If any provision of this Agreement is invalid or unenforceable under applicable " +
 541    "law, it shall not affect the validity or enforceability of the remainder of the " +
 542    "terms of this Agreement, and without further action by the parties hereto, such " +
 543    "provision shall be reformed to the minimum extent necessary to make such " +
 544    "provision valid and enforceable.\n" +
 545    "\n" +
 546    "If Recipient institutes patent litigation against any entity (including a " +
 547    "cross-claim or counterclaim in a lawsuit) alleging that the Program itself " +
 548    "(excluding combinations of the Program with other software or hardware) " +
 549    "infringes such Recipient's patent(s), then such Recipient's rights granted " +
 550    "under Section 2(b) shall terminate as of the date such litigation is filed.\n" +
 551    "\n" +
 552    "All Recipient's rights under this Agreement shall terminate if it fails to " +
 553    "comply with any of the material terms or conditions of this Agreement and does " +
 554    "not cure such failure in a reasonable period of time after becoming aware of " +
 555    "such noncompliance. If all Recipient's rights under this Agreement terminate, " +
 556    "Recipient agrees to cease use and distribution of the Program as soon as " +
 557    "reasonably practicable. However, Recipient's obligations under this Agreement " +
 558    "and any licenses granted by Recipient relating to the Program shall continue " +
 559    "and survive.\n" +
 560    "\n" +
 561    "Everyone is permitted to copy and distribute copies of this Agreement, but " +
 562    "in order to avoid inconsistency the Agreement is copyrighted and may only be " +
 563    "modified in the following manner. The Agreement Steward reserves the right to " +
 564    "publish new versions (including revisions) of this Agreement from time to " +
 565    "time. No one other than the Agreement Steward has the right to modify this " +
 566    "Agreement. The Eclipse Foundation is the initial Agreement Steward. The " +
 567    "Eclipse Foundation may assign the responsibility to serve as the Agreement " +
 568    "Steward to a suitable separate entity. Each new version of the Agreement " +
 569    "will be given a distinguishing version number. The Program (including " +
 570    "Contributions) may always be distributed subject to the version of the " +
 571    "Agreement under which it was received. In addition, after a new version of " +
 572    "the Agreement is published, Contributor may elect to distribute the Program " +
 573    "(including its Contributions) under the new version. Except as expressly " +
 574    "stated in Sections 2(a) and 2(b) above, Recipient receives no rights or " +
 575    "licenses to the intellectual property of any Contributor under this Agreement, " +
 576    "whether expressly, by implication, estoppel or otherwise. All rights in the " +
 577    "Program not expressly granted under this Agreement are reserved.\n" +
 578    "\n" +
 579    "This Agreement is governed by the laws of the State of New York and the " +
 580    "intellectual property laws of the United States of America. No party to this " +
 581    "Agreement will bring a legal action under this Agreement more than one year " +
 582    "after the cause of action arose. Each party waives its rights to a jury trial " +
 583    "in any resulting litigation.";
 584   
 585    public static final String INTRODUCTION =
 586    "DrJava is a pedagogic programming environment for Java, intended to help students focus more on program" +
 587    " design than on the features of a complicated development environment. It provides an Interactions" +
 588    " window based on a \"read-eval-print loop\", which allows programmers to develop, test, and debug" +
 589    " Java programs in an interactive, incremental fashion.\n\n" +
 590    "Home Page: http://www.drjava.org\nPaper: http://drjava.sf.net/papers/drjava-paper.shtml";
 591   
 592    public static class ImageInfo {
 593    private final String name;
 594    private final Color color;
 595  18 public ImageInfo(String name, Color color) {
 596  18 this.name = name;
 597  18 this.color = color;
 598    }
 599    }
 600   
 601  38 public static String getLicense() {
 602  32 if (initLicense) return LICENSE;
 603   
 604  6 try {
 605  6 InputStream is = AboutDialog.class.getResourceAsStream("/edu/rice/cs/LICENSE");
 606  6 if (is != null) {
 607  0 BufferedReader r = new BufferedReader(new InputStreamReader(is));
 608  0 try {
 609   
 610  0 final StringBuilder sb = new StringBuilder();
 611  0 for (String s = r.readLine(); s != null; s = r.readLine()) {
 612  0 int lastSig = s.length()-1; // the last char index
 613   
 614  0 while (lastSig >= 0 && Character.isWhitespace(s.charAt(lastSig))) lastSig--;
 615  0 if (lastSig < 0) sb.append("\n"); // empty line, so insert two newlines.
 616    else {
 617  0 sb.append(s.substring(0,lastSig+1));
 618  0 sb.append('\n');
 619    }
 620    }
 621  0 LICENSE = sb.toString();
 622  0 LICENSE = LICENSE.trim();
 623  0 if (LICENSE.length() == 0) LICENSE = null;
 624    }
 625    finally {
 626  0 is.close();
 627  0 r.close();
 628    }
 629    }
 630    }
 631  0 catch(Exception e) { throw new UnexpectedException(e, StringOps.getStackTrace(e)); }
 632   
 633  6 initLicense = true;
 634  6 return LICENSE;
 635    }
 636   
 637  342 private static void wrapBorder(JComponent c, Border b) {
 638  342 c.setBorder(new CompoundBorder(b,c.getBorder()));
 639    }
 640    }