Clover coverage report - DrJava Test Coverage (drjava-20120304-r5456)
Coverage timestamp: Sun Mar 4 2012 03:13:23 CST
file stats: LOC: 610   Methods: 29
NCLOC: 459   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
NewJavaClassDialog.java 51.6% 24% 34.5% 29.2%
coverage coverage
 1    package edu.rice.cs.drjava.ui;
 2   
 3    /*BEGIN_COPYRIGHT_BLOCK
 4    *
 5    * Copyright (c) 2001-2010, JavaPLT group at Rice University (drjava@rice.edu)
 6    * All rights reserved.
 7    *
 8    * Redistribution and use in source and binary forms, with or without
 9    * modification, are permitted provided that the following conditions are met:
 10    * * Redistributions of source code must retain the above copyright
 11    * notice, this list of conditions and the following disclaimer.
 12    * * Redistributions in binary form must reproduce the above copyright
 13    * notice, this list of conditions and the following disclaimer in the
 14    * documentation and/or other materials provided with the distribution.
 15    * * Neither the names of DrJava, the JavaPLT group, Rice University, nor the
 16    * names of its contributors may be used to endorse or promote products
 17    * derived from this software without specific prior written permission.
 18    *
 19    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 20    * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 21    * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 22    * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 23    * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 24    * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 25    * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 26    * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 27    * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 28    * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 29    * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 30    *
 31    * This software is Open Source Initiative approved Open Source Software.
 32    * Open Source Initative Approved is a trademark of the Open Source Initiative.
 33    *
 34    * This file is part of DrJava. Download the current version of this project
 35    * from http://www.drjava.org/ or http://sourceforge.net/projects/drjava/
 36    *
 37    * END_COPYRIGHT_BLOCK*/
 38   
 39    import java.awt.event.*;
 40    import java.awt.Component;
 41    import java.awt.Container;
 42    import java.awt.GridBagLayout;
 43    import java.awt.GridBagConstraints;
 44    import java.awt.Insets;
 45    import java.awt.Color;
 46    import java.awt.EventQueue;
 47    import java.io.IOException;
 48    import java.io.File;
 49    import java.net.URL;
 50    import java.util.*;
 51    import javax.swing.*;
 52    import javax.swing.event.*;
 53    import javax.swing.border.EmptyBorder;
 54    import java.awt.Dimension;
 55    import javax.swing.text.JTextComponent;
 56    import javax.swing.text.BadLocationException;
 57   
 58    import edu.rice.cs.drjava.DrJava;
 59    import edu.rice.cs.drjava.model.SingleDisplayModel;
 60    import edu.rice.cs.drjava.config.OptionConstants;
 61    import edu.rice.cs.drjava.ui.predictive.PredictiveInputFrame;
 62    import edu.rice.cs.drjava.ui.predictive.PredictiveInputModel;
 63    import edu.rice.cs.drjava.model.DummyOpenDefDoc;
 64    import edu.rice.cs.drjava.platform.PlatformFactory;
 65    import edu.rice.cs.drjava.model.OpenDefinitionsDocument;
 66   
 67    import edu.rice.cs.plt.lambda.Runnable1;
 68    import edu.rice.cs.plt.lambda.Runnable3;
 69    import edu.rice.cs.plt.lambda.LambdaUtil;
 70   
 71    import edu.rice.cs.util.swing.SwingFrame;
 72    import edu.rice.cs.util.swing.Utilities;
 73   
 74    import static edu.rice.cs.drjava.ui.MainFrameStatics.*;
 75    import static edu.rice.cs.drjava.ui.predictive.PredictiveInputModel.*;
 76   
 77    /** Generates Java source from information entered in the "New Class" dialog.
 78    * @version $Id: NewJavaClassDialog.java 5245 2010-05-07 02:59:04Z mgricken $
 79    */
 80    public class NewJavaClassDialog extends SwingFrame {
 81   
 82    // private static final int FRAME_WIDTH = 503;
 83    // private static final int FRAME_HEIGHT = 400;
 84   
 85    private MainFrame _mainFrame;
 86    private SingleDisplayModel _model;
 87   
 88    private final JButton _okButton;
 89    private final JButton _cancelButton;
 90    private JPanel _mainPanel;
 91    private final JTextField _className = new JTextField();
 92    private final JTextField _interfaces = new JTextField();
 93    private final JTextField _superClass = new JTextField();
 94    private final JButton _superClassButton = new JButton(new AbstractAction("...") {
 95  0 public void actionPerformed(ActionEvent e) {
 96  0 _autoComplete(_superClass);
 97    }
 98    });
 99    private final JRadioButton _defaultRadio = new JRadioButton("default", false);
 100    private final JRadioButton _publicRadio = new JRadioButton("public", true);
 101    private final JCheckBox _abstractCheck = new JCheckBox("abstract");
 102    private final JCheckBox _finalCheck = new JCheckBox("final");
 103    private final ButtonGroup _group1 = new ButtonGroup();
 104    private final JCheckBox _mainMethod = new JCheckBox("Include main method");
 105    private final JCheckBox _classConstructor = new JCheckBox("Include class constructor");
 106    private final JLabel _errorMessage = new JLabel("<html> </html>");
 107    private final boolean _isElementaryOrFunctionalJava;
 108   
 109    private final AutoCompletePopup _autoCompletePopup;
 110   
 111    private final AbstractAction _autoCompleteAction = new AbstractAction("Autocomplete") {
 112  0 public void actionPerformed(ActionEvent evt) {
 113  0 _autoComplete((JTextComponent)evt.getSource());
 114    }
 115    };
 116   
 117    /** Constructs New Java Class frame and displays it. */
 118  0 public NewJavaClassDialog(MainFrame mf) {
 119  0 super("New Java Class");
 120   
 121    // Utilities.show("NewJavaClass(" + mf + ")");
 122  0 int currentLL = DrJava.getConfig().getSetting(OptionConstants.LANGUAGE_LEVEL);
 123  0 _isElementaryOrFunctionalJava =
 124    (currentLL == OptionConstants.ELEMENTARY_LEVEL) ||
 125    (currentLL == OptionConstants.FUNCTIONAL_JAVA_LEVEL);
 126   
 127  0 _mainFrame = mf;
 128  0 _model = _mainFrame.getModel();
 129  0 _mainPanel= new JPanel();
 130   
 131  0 Action okAction = new AbstractAction("OK") {
 132  0 public void actionPerformed(ActionEvent e) { ok(); }
 133    };
 134  0 _okButton = new JButton(okAction);
 135   
 136  0 Action cancelAction = new AbstractAction("Cancel") {
 137  0 public void actionPerformed(ActionEvent e) { cancel(); }
 138    };
 139  0 _cancelButton = new JButton(cancelAction);
 140   
 141  0 _autoCompletePopup = new AutoCompletePopup(_mainFrame);
 142   
 143  0 init();
 144  0 initDone(); // call mandated by SwingFrame contract
 145    }
 146   
 147    /** Initializes the components in this frame. */
 148  0 private void init() {
 149  0 _setupPanel(_mainPanel);
 150  0 JScrollPane scrollPane = new JScrollPane(_mainPanel);
 151  0 Container cp = getContentPane();
 152   
 153  0 GridBagLayout cpLayout = new GridBagLayout();
 154  0 GridBagConstraints c = new GridBagConstraints();
 155  0 cp.setLayout(cpLayout);
 156   
 157  0 c.fill = GridBagConstraints.BOTH;
 158  0 c.anchor = GridBagConstraints.NORTH;
 159  0 c.gridwidth = GridBagConstraints.REMAINDER;
 160  0 c.gridheight = GridBagConstraints.RELATIVE;
 161  0 c.weightx = 1.0;
 162  0 c.weighty = 1.0;
 163  0 cpLayout.setConstraints(scrollPane, c);
 164  0 cp.add(scrollPane);
 165   
 166    // Add buttons
 167  0 JPanel bottom = new JPanel();
 168  0 bottom.setBorder(new EmptyBorder(5,5,5,5));
 169  0 bottom.setLayout(new BoxLayout(bottom, BoxLayout.X_AXIS));
 170  0 bottom.add(Box.createHorizontalGlue());
 171  0 bottom.add(_okButton);
 172  0 bottom.add(_cancelButton);
 173  0 bottom.add(Box.createHorizontalGlue());
 174   
 175  0 c.fill = GridBagConstraints.NONE;
 176  0 c.anchor = GridBagConstraints.SOUTH;
 177  0 c.gridheight = GridBagConstraints.REMAINDER;
 178  0 c.weighty = 0.0;
 179  0 cpLayout.setConstraints(bottom, c);
 180  0 cp.add(bottom);
 181   
 182  0 pack();
 183  0 Utilities.setPopupLoc(this, _mainFrame);
 184   
 185  0 reset();
 186    }
 187   
 188    /** Resets the frame and hides it. */
 189  0 public void cancel() {
 190  0 setVisible(false);
 191  0 reset();
 192    }
 193   
 194  0 public void reset() {
 195  0 _className.setText("");
 196  0 _interfaces.setText("");
 197  0 _superClass.setText("");
 198  0 _defaultRadio.setSelected(false);
 199  0 _publicRadio.setSelected(true);
 200  0 _abstractCheck.setSelected(false);
 201  0 _finalCheck.setSelected(false);
 202  0 _mainMethod.setSelected(false);
 203  0 _classConstructor.setSelected(false);
 204    }
 205   
 206    /** Caches the settings in the global model */
 207  0 public void ok() {
 208  0 if (!checkClassName(_className.getText())) {
 209  0 _errorMessage.setForeground(Color.RED);
 210  0 _errorMessage.setText("Enter correct class name. ");
 211  0 invalidate();
 212  0 return;
 213    }
 214   
 215  0 if (_superClass.getText().length() != 0) {
 216  0 if(!checkSuperClassName(_superClass.getText())) {
 217  0 _errorMessage.setForeground(Color.RED);
 218  0 _errorMessage.setText("Enter correct superclass.");
 219  0 invalidate();
 220  0 return;
 221    }
 222    }
 223   
 224  0 if(_interfaces.getText().length() != 0) {
 225  0 if(!checkInterfaceNames(_interfaces.getText())) {
 226  0 _errorMessage.setForeground(Color.RED);
 227  0 _errorMessage.setText("Enter correct interface names.");
 228  0 invalidate();
 229  0 return;
 230    }
 231    }
 232   
 233  0 String classContent = getClassContent(_publicRadio.isSelected()?"public":"",
 234  0 _abstractCheck.isSelected()?"abstract":
 235  0 (_finalCheck.isSelected()?"final":""),
 236    _className.getText(),
 237    _mainMethod.isSelected(),
 238    _classConstructor.isSelected(),
 239    _superClass.getText(), _interfaces.getText(),
 240    _isElementaryOrFunctionalJava);
 241   
 242  0 _model.newFile(classContent);
 243   
 244  0 setVisible(false);
 245  0 reset();
 246    }
 247   
 248  0 private void _addAutoCompleteActions(JTextComponent component) {
 249  0 for(KeyStroke ks: DrJava.getConfig().getSetting(OptionConstants.KEY_COMPLETE_FILE)) {
 250    // If you want to bind a keystroke to shift-space (which generates
 251    // a space character), you need to use a pressed-type keystroke.
 252  0 component.getInputMap(JComponent.WHEN_FOCUSED).
 253    put(ks, _autoCompleteAction.getValue(Action.NAME));
 254    }
 255   
 256  0 component.getActionMap().put(_autoCompleteAction.getValue(Action.NAME), _autoCompleteAction);
 257    }
 258   
 259  0 private void _setupPanel(JPanel panel) {
 260  0 GridBagLayout gridbag = new GridBagLayout();
 261  0 GridBagConstraints c = new GridBagConstraints();
 262  0 panel.setLayout(gridbag);
 263  0 c.fill = GridBagConstraints.HORIZONTAL;
 264  0 Insets labelInsets = new Insets(5, 10, 0, 0);
 265  0 Insets compInsets = new Insets(5, 5, 0, 10);
 266   
 267    // Class Name
 268  0 c.weightx = 0.0;
 269  0 c.gridwidth = 1;
 270  0 c.insets = labelInsets;
 271   
 272  0 JLabel prLabel = new JLabel("Class Name");
 273  0 prLabel.setToolTipText("<html>The name of the class.</html>");
 274  0 gridbag.setConstraints(prLabel, c);
 275  0 panel.add(prLabel);
 276   
 277  0 c.weightx = 1.0;
 278  0 c.gridwidth = GridBagConstraints.REMAINDER;
 279  0 c.insets = compInsets;
 280   
 281  0 _className.setPreferredSize(new Dimension(250, _className.getPreferredSize().height));
 282  0 gridbag.setConstraints(_className, c);
 283  0 panel.add(_className);
 284   
 285    // Superclass
 286  0 c.weightx = 0.0;
 287  0 c.gridwidth = 1;
 288  0 c.insets = labelInsets;
 289   
 290  0 prLabel = new JLabel("Superclass");
 291  0 prLabel.setToolTipText("<html>The name of the superclass, or empty for Object.</html>");
 292  0 gridbag.setConstraints(prLabel, c);
 293   
 294  0 panel.add(prLabel);
 295  0 c.weightx = 1.0;
 296  0 c.gridwidth = 1;
 297  0 c.insets = new Insets(5, 5, 0, 0);
 298   
 299  0 gridbag.setConstraints(_superClass, c);
 300  0 _addAutoCompleteActions(_superClass);
 301  0 panel.add(_superClass);
 302   
 303  0 c.weightx = 0.0;
 304  0 c.gridwidth = GridBagConstraints.REMAINDER;
 305  0 c.insets = new Insets(5, 0, 0, 10);
 306  0 _superClassButton.setToolTipText("<html>Select the superclass.</html>");
 307  0 gridbag.setConstraints(_superClassButton, c);
 308  0 panel.add(_superClassButton);
 309   
 310    // Interfaces
 311  0 c.weightx = 0.0;
 312  0 c.gridwidth = 1;
 313  0 c.insets = labelInsets;
 314   
 315  0 prLabel = new JLabel("Interfaces");
 316  0 prLabel.setToolTipText("<html>The name of the interfaces, separated by commas, or empty for none.</html>");
 317  0 gridbag.setConstraints(prLabel, c);
 318   
 319  0 panel.add(prLabel);
 320  0 c.weightx = 1.0;
 321  0 c.gridwidth = GridBagConstraints.REMAINDER;
 322  0 c.insets = compInsets;
 323   
 324  0 gridbag.setConstraints(_interfaces, c);
 325  0 panel.add(_interfaces);
 326   
 327  0 if (!_isElementaryOrFunctionalJava) {
 328    // Modifiers: public/default
 329  0 c.weightx = 0.0;
 330  0 c.gridwidth = 1;
 331  0 c.insets = labelInsets;
 332   
 333  0 prLabel = new JLabel("Access modifier");
 334  0 prLabel.setToolTipText("<html>Class access modifier.</html>");
 335  0 gridbag.setConstraints(prLabel, c);
 336   
 337  0 panel.add(prLabel);
 338  0 c.weightx = 1.0;
 339  0 c.gridwidth = GridBagConstraints.REMAINDER;
 340  0 c.insets = compInsets;
 341   
 342  0 JPanel accessPanel = new JPanel();
 343  0 accessPanel.setLayout(new BoxLayout(accessPanel, BoxLayout.X_AXIS));
 344  0 accessPanel.add(_publicRadio);
 345  0 accessPanel.add(_defaultRadio);
 346  0 gridbag.setConstraints(accessPanel, c);
 347  0 panel.add(accessPanel);
 348   
 349    // Modifiers: abstract/final
 350  0 c.weightx = 0.0;
 351  0 c.gridwidth = 1;
 352  0 c.insets = labelInsets;
 353   
 354  0 prLabel = new JLabel("Other modifiers");
 355  0 prLabel.setToolTipText("<html>final or abstract class modifiers.</html>");
 356  0 gridbag.setConstraints(prLabel, c);
 357   
 358  0 panel.add(prLabel);
 359  0 c.weightx = 1.0;
 360  0 c.gridwidth = GridBagConstraints.REMAINDER;
 361  0 c.insets = compInsets;
 362   
 363  0 JPanel faPanel = new JPanel();
 364  0 faPanel.setLayout(new BoxLayout(faPanel, BoxLayout.X_AXIS));
 365  0 faPanel.add(_abstractCheck);
 366  0 faPanel.add(_finalCheck);
 367  0 gridbag.setConstraints(faPanel, c);
 368  0 panel.add(faPanel);
 369  0 _finalCheck.addActionListener(new ActionListener() {
 370  0 public void actionPerformed(ActionEvent actionEvent) {
 371  0 if (_finalCheck.isSelected()) _abstractCheck.setSelected(false);
 372    }
 373    });
 374  0 _abstractCheck.addActionListener(new ActionListener() {
 375  0 public void actionPerformed(ActionEvent actionEvent) {
 376  0 if (_abstractCheck.isSelected()) _finalCheck.setSelected(false);
 377    }
 378    });
 379   
 380    // Include ctor
 381  0 c.weightx = 0.0;
 382  0 c.gridwidth = 1;
 383  0 c.insets = labelInsets;
 384   
 385  0 prLabel = new JLabel("");
 386  0 gridbag.setConstraints(prLabel, c);
 387   
 388  0 panel.add(prLabel);
 389  0 c.weightx = 1.0;
 390  0 c.gridwidth = GridBagConstraints.REMAINDER;
 391  0 c.insets = compInsets;
 392   
 393  0 gridbag.setConstraints(_classConstructor, c);
 394  0 panel.add(_classConstructor);
 395   
 396    // Include main method
 397  0 c.weightx = 0.0;
 398  0 c.gridwidth = 1;
 399  0 c.insets = labelInsets;
 400   
 401  0 prLabel = new JLabel("");
 402  0 gridbag.setConstraints(prLabel, c);
 403   
 404  0 panel.add(prLabel);
 405  0 c.weightx = 1.0;
 406  0 c.gridwidth = GridBagConstraints.REMAINDER;
 407  0 c.insets = compInsets;
 408   
 409  0 gridbag.setConstraints(_mainMethod, c);
 410  0 panel.add(_mainMethod);
 411    }
 412   
 413    // Error message
 414  0 c.weightx = 1.0;
 415  0 c.gridwidth = GridBagConstraints.REMAINDER;
 416  0 c.insets = compInsets;
 417   
 418  0 gridbag.setConstraints(_errorMessage, c);
 419  0 panel.add(_errorMessage);
 420   
 421    //grouping the modifiers
 422  0 _group1.add(_publicRadio);
 423  0 _group1.add(_defaultRadio);
 424    }
 425   
 426    /** Runnable that calls _cancel. */
 427    protected final Runnable1<WindowEvent> CANCEL = new Runnable1<WindowEvent>() {
 428  0 public void run(WindowEvent e) { cancel(); }
 429    };
 430   
 431    /** Validates before changing visibility. Only runs in the event thread.
 432    * @param vis true if frame should be shown, false if it should be hidden.
 433    */
 434  0 public void setVisible(boolean vis) {
 435  0 assert EventQueue.isDispatchThread();
 436  0 validate();
 437  0 if (vis) {
 438  0 _mainFrame.hourglassOn();
 439  0 _mainFrame.installModalWindowAdapter(this, LambdaUtil.NO_OP, CANCEL);
 440  0 toFront();
 441    }
 442    else {
 443  0 _mainFrame.removeModalWindowAdapter(this);
 444  0 _mainFrame.hourglassOff();
 445  0 _mainFrame.toFront();
 446    }
 447  0 super.setVisible(vis);
 448    }
 449   
 450  0 public void setEnabled(boolean b) {
 451  0 super.setEnabled(b);
 452  0 for(Component c: getComponents()) c.setEnabled(b);
 453    }
 454   
 455    //newclass addition
 456  38 static String getCapitalizedClassName(String name) {
 457  38 name = name.trim();
 458  0 if (name.length() == 0) return "";
 459  38 return name.substring(0,1).toUpperCase() + name.substring(1);
 460    }
 461   
 462  17 static boolean checkClassName(String name) {
 463  1 if (name == null) return false;
 464  16 name = name.trim();
 465  16 return (name.length() != 0 && name.matches("([A-Za-z_][A-Za-z0-9_]*)"));
 466    }
 467   
 468  16 static String getCapitalizedSuperClassName(String name) {
 469  16 name = name.trim();
 470  0 if (name.length() == 0) return "";
 471  16 int lastDotPos = name.lastIndexOf('.');
 472  12 if (lastDotPos == -1) return getCapitalizedClassName(name);
 473  4 return name.substring(0,lastDotPos+1)
 474    + getCapitalizedClassName(name.substring(lastDotPos+1));
 475    }
 476   
 477  43 static boolean checkSuperClassName(String name) {
 478  1 if (name == null) return false;
 479  42 name = name.trim();
 480  42 return (name.length() != 0 && name.matches("([A-Za-z_][A-Za-z0-9_\\.]*)"));
 481    }
 482   
 483  12 static boolean iterateListOfClassNames(String name) {
 484  12 String[] separatedNames = name.split(",",-1);
 485  12 for(String n: separatedNames) {
 486  2 if (!checkSuperClassName(n.trim())) return false;
 487    }
 488  10 return true;
 489    }
 490   
 491  14 static boolean checkInterfaceNames(String name) {
 492  0 if (name == null) return false;
 493  14 name = name.trim();
 494  14 if(name.length() != 0 && name.matches("([A-Za-z_][A-Za-z0-9_, \\.]*)")) {
 495  12 return iterateListOfClassNames(name);
 496    }
 497  2 else return false;
 498    }
 499   
 500  5 static String getCapitalizedInterfacesNames(String name) {
 501  5 String[] separatedNames = name.split(",",-1);
 502  5 StringBuilder correctNames = new StringBuilder();
 503  5 for(int i = 0; i < separatedNames.length; ++i) {
 504  8 correctNames.append(getCapitalizedSuperClassName(separatedNames[i].trim()));
 505  3 if (i < separatedNames.length-1) correctNames.append(", ");
 506    }
 507  5 return correctNames.toString();
 508    }
 509   
 510  38 static String getModifier(String modifier){
 511  38 if(modifier == null)
 512  1 return ""; //return blank modifier
 513  37 else if(modifier.equals("public") || modifier.equals("final") || modifier.equals("abstract"))
 514  22 return modifier+ " ";
 515    else
 516  15 return ""; //return blank modifier
 517    }
 518   
 519  19 static String getClassDeclaration(String accessMod, String modifier, String name,
 520    String superclass, String interfaces,
 521    boolean elementaryOrFunctionalJava) {
 522  19 StringBuilder sb = new StringBuilder();
 523  19 if (!elementaryOrFunctionalJava) {
 524  19 sb.append(getModifier(accessMod));
 525  19 sb.append(getModifier(modifier));
 526    }
 527  19 sb.append("class");
 528  19 if(name != null) {
 529  18 sb.append(' ');
 530  18 sb.append(getCapitalizedClassName(name));
 531    }
 532  19 if(superclass.length() != 0) {
 533  4 sb.append(" extends ");
 534  4 sb.append(getCapitalizedSuperClassName(superclass));
 535    }
 536  19 if(interfaces.length() != 0) {
 537  5 sb.append(" implements ");
 538  5 sb.append(getCapitalizedInterfacesNames(interfaces));
 539    }
 540  19 return sb.toString();
 541    }
 542   
 543  4 public static String getClassContent(String accessMod, String modifier, String className,
 544    boolean mainMethod, boolean classConstructor, String inheritance,
 545    String interfaces,
 546    boolean elementaryOrFunctionalJava) {
 547  4 StringBuilder sb = new StringBuilder();
 548   
 549  4 sb.append("/**\n");
 550  4 if (elementaryOrFunctionalJava) {
 551  0 sb.append("* Auto Generated Java Language Level Class.\n");
 552    }
 553    else {
 554  4 sb.append("* Auto Generated Java Class.\n");
 555    }
 556  4 sb.append("*/\n");
 557  4 sb.append(getClassDeclaration(accessMod, modifier, className, inheritance, interfaces,
 558    elementaryOrFunctionalJava));
 559  4 sb.append(" {\n");
 560  4 sb.append("\n");
 561   
 562  4 if(classConstructor && !elementaryOrFunctionalJava) {
 563  2 sb.append("public " + getCapitalizedClassName(className) + "() { \n");
 564  2 sb.append("/* YOUR CONSTRUCTOR CODE HERE*/");
 565  2 sb.append("\n}\n");
 566    }
 567   
 568  4 if(mainMethod && !elementaryOrFunctionalJava) {
 569  2 sb.append("\n public static void main(String[] args) { \n\n");
 570  2 sb.append("}\n\n");
 571    }
 572   
 573  4 sb.append("/* ADD YOUR CODE HERE */\n");
 574  4 sb.append("\n");
 575  4 sb.append("}\n");
 576  4 return sb.toString();
 577    }
 578   
 579  0 private void _autoComplete(final JTextComponent component) {
 580  0 _mainFrame.removeModalWindowAdapter(NewJavaClassDialog.this);
 581  0 setEnabled(false);
 582  0 final String initial = component.getText();
 583  0 final int loc = initial.length();
 584  0 _autoCompletePopup.show(this,
 585    "Select Class",
 586    initial,
 587    loc,
 588    new Runnable() {
 589  0 public void run() {
 590    // canceled
 591  0 NewJavaClassDialog.this.setEnabled(true);
 592  0 _mainFrame.installModalWindowAdapter(NewJavaClassDialog.this, LambdaUtil.NO_OP, CANCEL);
 593  0 NewJavaClassDialog.this.toFront();
 594    }
 595    },
 596    new Runnable3<AutoCompletePopupEntry,Integer,Integer>() {
 597  0 public void run(AutoCompletePopupEntry entry,
 598    Integer from,
 599    Integer to) {
 600    // accepted
 601  0 String fullName = entry.getFullPackage()+entry.getClassName();
 602  0 component.setText(fullName);
 603  0 component.setCaretPosition(fullName.length());
 604  0 NewJavaClassDialog.this.setEnabled(true);
 605  0 _mainFrame.installModalWindowAdapter(NewJavaClassDialog.this, LambdaUtil.NO_OP, CANCEL);
 606  0 NewJavaClassDialog.this.toFront();
 607    }
 608    });
 609    }
 610    }