@Override
  protected void performDefaults() {

    outputFolderCombo.select(dao.getDefaultOutputFolder());

    SpreadsheetPreference sheetEntity = dao.getDefaultSpreadsheetCell();
    setText(sheetEntity);

    CustomCodePreference customEntity = dao.getDefaultCustomCode();
    setText(customEntity);

    packageCellColumnComp.setEnabled(true);
    packageCellRowComp.setEnabled(true);
  }
 private SpreadsheetPreference createSpreadsheetCellPreference() {
   SpreadsheetPreference entity = new SpreadsheetPreference();
   entity.setClassCommentCell(classCommentComp.getText());
   entity.setClassNameCell(classNameComp.getText());
   entity.setEnumCommentCell(enumCommentComp.getText());
   entity.setEnumNameCell(enumNameComp.getText());
   entity.setEnumValueCell(enumValueComp.getText());
   entity.setPackageUseSheet(packageUseSheetCheck.getSelection());
   entity.setBasePackage(basePackageNameComp.getText());
   entity.setPackageColumnCell(packageCellColumnComp.getText());
   entity.setPackageRowCell(packageCellRowComp.getText());
   String startRow = startRepeatRowComp.getText();
   if (!Strings.isNullOrEmpty(startRow)) {
     entity.setStartRepeatRow(Integer.valueOf(startRow));
   }
   return entity;
 }
 private void setEnabledToUseSheet(boolean selection) {
   packageCellColumnComp.setEnabled(!selection);
   packageCellRowComp.setEnabled(!selection);
 }
  private void setText(SpreadsheetPreference entity) {
    packageCellColumnComp.dispose();
    packageCellRowComp.dispose();
    classCommentComp.dispose();
    classNameComp.dispose();
    enumCommentComp.dispose();
    enumNameComp.dispose();
    enumValueComp.dispose();
    startRepeatRowComp.dispose();

    packageUseSheetCheck.setSelection(entity.isPackageUseSheet());
    basePackageNameComp.setText(entity.getBasePackage());
    packageCellColumnComp.setText(entity.getPackageColumnCell());
    packageCellRowComp.setText(entity.getPackageRowCell());
    classCommentComp.setText(entity.getClassCommentCell());
    classNameComp.setText(entity.getClassNameCell());
    enumCommentComp.setText(entity.getEnumCommentCell());
    enumNameComp.setText(entity.getEnumNameCell());
    enumValueComp.setText(entity.getEnumValueCell());
    Integer startRow = entity.getStartRepeatRow();
    if (startRow != null) {
      startRepeatRowComp.setText(String.valueOf(startRow));
    }

    packageCellColumnComp.verify();
    packageCellRowComp.verify();
    classCommentComp.verify();
    classNameComp.verify();
    enumCommentComp.verify();
    enumNameComp.verify();
    enumValueComp.verify();
    startRepeatRowComp.verify();
  }
  @Override
  protected Control createContents(Composite parent) {

    CustomCodePreference customEntity = dao.findCustomCodePreference();

    GridLayout layout3 = new GridLayout(3, false);

    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    composite.setLayout(layout3);

    Label outputFolderLabel = new Label(composite, SWT.NONE);
    outputFolderLabel.setText("Output Folder:");
    GridData colspan2 = new GridData(GridData.VERTICAL_ALIGN_END);
    colspan2.horizontalSpan = 2;
    colspan2.horizontalAlignment = GridData.FILL;
    outputFolderCombo = new OutputFolderCombo(composite, SWT.READ_ONLY);
    outputFolderCombo.setLayoutData(colspan2);
    outputFolderCombo.select(dao.findOutputFolder());

    templatePathComp = new JavaFilePathComponent(composite, "Template File Path:");
    templatePathComp.setText(customEntity.getTemplateFilePath());

    Group customGroup = new Group(parent, SWT.NONE);
    customGroup.setText("Custom implements");
    customGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    customGroup.setLayout(layout3);

    codeSeedComp = new JavaClassPathComponent(customGroup, "CodeSeed:");
    codeSeedComp.setText(customEntity.getCodeSeedImplements());
    packageHasErrors.add(codeSeedComp);

    rootTagComp = new JavaClassPathComponent(customGroup, "RootTag:");
    rootTagComp.setText(customEntity.getRootTagImplements());
    packageHasErrors.add(rootTagComp);

    itemsTagComp = new JavaClassPathComponent(customGroup, "ItemsTag:");
    itemsTagComp.setText(customEntity.getItemsTagImplements());
    packageHasErrors.add(itemsTagComp);

    tagHandlerComp = new JavaClassPathComponent(customGroup, "TagHandler:");
    tagHandlerComp.setText(customEntity.getTagHandlerImplements());
    packageHasErrors.add(tagHandlerComp);

    SpreadsheetPreference spreadEntity = dao.findSpreadsheetPreference();

    GridLayout layout6 = new GridLayout(6, false);

    Group packageGroup = new Group(parent, SWT.NONE);
    packageGroup.setText("Package Name");
    GridData colspan6 = new GridData(GridData.FILL_HORIZONTAL);
    colspan6.horizontalSpan = 6;
    packageGroup.setLayoutData(colspan6);
    packageGroup.setLayout(layout6);

    packageUseSheetCheck = new Button(packageGroup, SWT.CHECK);
    packageUseSheetCheck.setText("use sheet name.");
    packageUseSheetCheck.setSelection(spreadEntity.isPackageUseSheet());
    packageUseSheetCheck.addSelectionListener(
        new SelectionListener() {
          @Override
          public void widgetDefaultSelected(SelectionEvent e) {}

          @Override
          public void widgetSelected(SelectionEvent e) {
            Button button = (Button) e.widget;
            setEnabledToUseSheet(button.getSelection());
          }
        });

    packageCellColumnComp = new SpreadSheetColumnCellComponent(packageGroup, "Column:");
    packageCellColumnComp.setText(spreadEntity.getPackageColumnCell());
    packageCellColumnComp.verify();
    packageCellRowComp = new SpreadSheetRowCellComponent(packageGroup, "Row:");
    packageCellRowComp.setText(spreadEntity.getPackageRowCell());
    packageCellRowComp.verify();
    new Label(packageGroup, SWT.NONE);

    basePackageNameComp = new JavaClassPathComponent(packageGroup, "Package Name Base:", false);
    basePackageNameComp.setLayoutData(colspan6);
    basePackageNameComp.setText(spreadEntity.getBasePackage());
    packageHasErrors.add(basePackageNameComp);

    Group spreadGroup = new Group(parent, SWT.NONE);
    spreadGroup.setText("Default SpreadSheet Cell. (It's a enum generator) ");
    spreadGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    spreadGroup.setLayout(layout6);

    classCommentComp = new SpreadSheetColumnCellComponent(spreadGroup, "Class Comment:");
    classCommentComp.setText(spreadEntity.getClassCommentCell());
    classCommentComp.verify();

    classNameComp = new SpreadSheetColumnCellComponent(spreadGroup, "Class Name:");
    classNameComp.setText(spreadEntity.getClassNameCell());
    classNameComp.verify();

    new Label(spreadGroup, SWT.NONE);
    new Label(spreadGroup, SWT.NONE);

    enumCommentComp = new SpreadSheetColumnCellComponent(spreadGroup, "Enum Type Comment:");
    enumCommentComp.setText(spreadEntity.getEnumCommentCell());
    enumCommentComp.verify();

    enumNameComp = new SpreadSheetColumnCellComponent(spreadGroup, "Enum Type Value:");
    enumNameComp.setText(spreadEntity.getEnumNameCell());
    enumNameComp.verify();

    enumValueComp = new SpreadSheetColumnCellComponent(spreadGroup, "Enum Code Value:");
    enumValueComp.setText(spreadEntity.getEnumValueCell());
    enumValueComp.verify();

    startRepeatRowComp =
        new SpreadSheetRowCellComponent(spreadGroup, "A row to start repeat (except empty) :");
    startRepeatRowComp.setText(String.valueOf(spreadEntity.getStartRepeatRow()));
    startRepeatRowComp.verify();

    setEnabledToUseSheet(spreadEntity.isPackageUseSheet());

    return parent;
  }