/net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/wizards/web/NewYesodProjectPage.java

https://github.com/JPMoresmau/eclipsefp · Java · 129 lines · 52 code · 8 blank · 69 comment · 0 complexity · 1a3e762742c4325714761cc9be974c10 MD5 · raw file

  1. package net.sf.eclipsefp.haskell.ui.wizards.web;
  2. import java.util.Arrays;
  3. import java.util.HashMap;
  4. import java.util.Map;
  5. import net.sf.eclipsefp.haskell.ui.internal.util.UITexts;
  6. import org.eclipse.swt.SWT;
  7. import org.eclipse.swt.layout.GridData;
  8. import org.eclipse.swt.layout.GridLayout;
  9. import org.eclipse.swt.widgets.Combo;
  10. import org.eclipse.swt.widgets.Composite;
  11. import org.eclipse.swt.widgets.Label;
  12. import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
  13. /**
  14. *
  15. * @author Alejandro Serrano
  16. * @author JP Moresmau
  17. */
  18. public class NewYesodProjectPage extends WizardNewProjectCreationPage {
  19. private static Map<String,String> dbs=new HashMap<>();
  20. static {
  21. dbs.put( UITexts.newYesodProjectWizard_db_sqlite , "s");
  22. dbs.put( UITexts.newYesodProjectWizard_db_postgresql ,"p");
  23. dbs.put( UITexts.newYesodProjectWizard_db_postgresqlfay, "pf");
  24. dbs.put( UITexts.newYesodProjectWizard_db_mysql,"mysql");
  25. dbs.put( UITexts.newYesodProjectWizard_db_mongodb , "mongo");
  26. dbs.put( UITexts.newYesodProjectWizard_db_simple , "simple");
  27. }
  28. //Text authorName;
  29. //Text foundation;
  30. Combo dbType;
  31. public NewYesodProjectPage( final String pageName ) {
  32. super( pageName );
  33. }
  34. @Override
  35. public void createControl( final Composite parent ) {
  36. Composite all = new Composite( parent, SWT.NULL );
  37. GridLayout gl = new GridLayout( 1, false );
  38. all.setLayout( gl );
  39. super.createControl( all );
  40. Composite inner = new Composite( all, SWT.NULL );
  41. GridData innerD = new GridData( GridData.FILL_HORIZONTAL );
  42. innerD.grabExcessVerticalSpace = false;
  43. innerD.verticalAlignment = SWT.BEGINNING;
  44. inner.setLayoutData( innerD );
  45. GridLayout innerGl = new GridLayout( 2, false );
  46. inner.setLayout( innerGl );
  47. // Author name
  48. // Label authorNameL = new Label( inner, SWT.NULL );
  49. // authorNameL.setText( "Author" );
  50. // authorName = new Text( inner, SWT.BORDER );
  51. // authorName.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
  52. // String userName=PlatformUtil.getCurrentUser();
  53. // if (userName==null){
  54. // userName="user";
  55. // }
  56. // authorName.setText( userName );
  57. // authorName.addModifyListener( new ModifyListener() {
  58. //
  59. // @Override
  60. // public void modifyText( final ModifyEvent e ) {
  61. // verify();
  62. // }
  63. // } );
  64. // Foundation datatype
  65. // Label foundationL = new Label( inner, SWT.NULL );
  66. // foundationL.setText( "Foundation datatype" );
  67. // foundation = new Text( inner, SWT.BORDER );
  68. // foundation.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
  69. // foundation.setText( "Foundation" );
  70. // foundation.addModifyListener( new ModifyListener() {
  71. //
  72. // @Override
  73. // public void modifyText( final ModifyEvent e ) {
  74. // verify();
  75. // }
  76. // } );
  77. // Type of database
  78. Label comboL = new Label( inner, SWT.NULL );
  79. comboL.setText( "Database" );
  80. dbType = new Combo( inner, SWT.BORDER | SWT.READ_ONLY );
  81. String[] items=dbs.keySet().toArray( new String[dbs.size()] );
  82. Arrays.sort( items,String.CASE_INSENSITIVE_ORDER );
  83. dbType.setItems(items);
  84. dbType.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
  85. dbType.setText(UITexts.newYesodProjectWizard_db_sqlite);
  86. }
  87. // boolean verify() {
  88. // this.setErrorMessage( null );
  89. // if( authorName.getText().length() == 0 ) {
  90. // this.setErrorMessage( "Author name cannot be empty" );
  91. // return false;
  92. // } else if( foundation.getText().length() == 0 ) {
  93. // this.setErrorMessage( "Foundation datatype cannot be empty" );
  94. // return false;
  95. // } else if( !Character.isUpperCase( foundation.getText().charAt( 0 ) ) ) {
  96. // this.setErrorMessage( "Foundation datatype must start with uppercase letter" );
  97. // return false;
  98. // }
  99. // return true;
  100. // }
  101. //
  102. // @Override
  103. // public boolean isPageComplete() {
  104. // if( !super.isPageComplete() ) {
  105. // return false;
  106. // }
  107. //
  108. // return verify();
  109. // }
  110. //
  111. // public String getAuthor() {
  112. // return authorName.getText();
  113. // }
  114. //
  115. // public String getFoundation() {
  116. // return foundation.getText();
  117. // }
  118. public String getDatabase() {
  119. return dbs.get( dbType.getText());
  120. }
  121. }