Skip to content
This repository
Browse code

src folder

  • Loading branch information...
commit 7d0aa52138203dd1bda230093ee65ab435fd75f3 1 parent 3efb908
JP Moresmau authored
232 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/wizards/NewGtkProjectWizard.java
... ... @@ -1,116 +1,116 @@
1   -/**
2   - * Copyright (c) 2012 by JP Moresmau
3   - * This code is made available under the terms of the Eclipse Public License,
4   - * version 1.0 (EPL). See http://www.eclipse.org/legal/epl-v10.html
5   - */
6   -package net.sf.eclipsefp.haskell.ui.wizards;
7   -
8   -import net.sf.eclipsefp.haskell.core.cabalmodel.CabalSyntax;
9   -import net.sf.eclipsefp.haskell.core.cabalmodel.PackageDescription;
10   -import net.sf.eclipsefp.haskell.core.cabalmodel.PackageDescriptionStanza;
11   -import net.sf.eclipsefp.haskell.core.internal.project.ProjectModelFilesOp;
12   -import net.sf.eclipsefp.haskell.ui.internal.util.UITexts;
13   -import net.sf.eclipsefp.haskell.ui.internal.wizards.NewProjectWizardPage;
14   -import net.sf.eclipsefp.haskell.util.PlatformUtil;
15   -import org.eclipse.swt.widgets.Composite;
16   -import org.eclipse.ui.INewWizard;
17   -
18   -
19   -/**
20   - * GTK project wizard: executable referencing gtk, Main.hs have default hello world
21   - * @author JP Moresmau
22   - *
23   - */
24   -public class NewGtkProjectWizard extends NewHaskellProjectWizard implements INewWizard {
25   -
26   - /**
27   - *
28   - */
29   - public NewGtkProjectWizard() {
30   - super();
31   - op=new GktProjectModelFilesOp();
32   - getOperation().setExtraOperation( op );
33   - }
34   -
35   - /* (non-Javadoc)
36   - * @see net.sf.eclipsefp.haskell.ui.internal.wizards.ProjectCreationWizard#addPages()
37   - */
38   - @Override
39   - public void addPages() {
40   - page = new NewProjectWizardPage(){
41   - /* (non-Javadoc)
42   - * @see net.sf.eclipsefp.haskell.ui.internal.wizards.NewProjectWizardPage#createControls(org.eclipse.swt.widgets.Composite)
43   - */
44   - @Override
45   - protected void createControls( final Composite composite ) {
46   - createNameControl(composite);
47   - createLocationControl(composite);
48   - }
49   - };
50   - page.setTitle( getPageTitle() );
51   - page.setDescription( getPageDescription() );
52   - addPage( page );
53   - }
54   -
55   - @Override
56   - public boolean performFinish() {
57   - op.setExecutable( true);
58   - op.setLibrary( false );
59   - return super.performFinish();
60   - }
61   -
62   - @Override
63   - protected String getPageDescription() {
64   - return UITexts.newGtkProjectWizard_pageDesc;
65   - }
66   -
67   - @Override
68   - protected String getPageTitle() {
69   - return UITexts.newGtkProjectWizard_pageTitle;
70   - }
71   -
72   - @Override
73   - protected String getTheWindowTitle() {
74   - return UITexts.newGtkProjectWizard_windowTitle;
75   - }
76   -
77   - /**
78   - * override main.hs and cabal file with gtk specifics
79   - * @author JP Moresmau
80   - *
81   - */
82   - private static class GktProjectModelFilesOp extends ProjectModelFilesOp{
83   - /* (non-Javadoc)
84   - * @see net.sf.eclipsefp.haskell.core.internal.project.ProjectModelFilesOp#getCabalFile(java.lang.String)
85   - */
86   - @Override
87   - protected PackageDescription getCabalFile( final String name ) {
88   - PackageDescription pd=super.getCabalFile( name );
89   - PackageDescriptionStanza pds=pd.getStanzas().get( 1 );
90   - pds.addToPropertyList( CabalSyntax.FIELD_BUILD_DEPENDS, "gtk" ); //$NON-NLS-1$
91   -
92   - return pd;
93   - }
94   -
95   - /* (non-Javadoc)
96   - * @see net.sf.eclipsefp.haskell.core.internal.project.ProjectModelFilesOp#getMainFileContent()
97   - */
98   - @Override
99   - protected String getMainFileContent() {
100   - return "module Main where"+PlatformUtil.NL+PlatformUtil.NL+
101   - "import Graphics.UI.Gtk"+PlatformUtil.NL+PlatformUtil.NL+
102   - "main :: IO ()"+PlatformUtil.NL+
103   - "main = do"+PlatformUtil.NL+
104   - " initGUI"+PlatformUtil.NL+
105   - " window <- windowNew"+PlatformUtil.NL+
106   - " button <- buttonNew"+PlatformUtil.NL+
107   - " set window [ containerBorderWidth := 10,"+PlatformUtil.NL+
108   - " containerChild := button ]"+PlatformUtil.NL+
109   - " set button [ buttonLabel := \"Hello World\" ]"+PlatformUtil.NL+
110   - " onClicked button (putStrLn \"Hello World\")"+PlatformUtil.NL+
111   - " onDestroy window mainQuit"+PlatformUtil.NL+
112   - " widgetShowAll window"+PlatformUtil.NL+
113   - " mainGUI"+PlatformUtil.NL;
114   - }
115   - }
116   -}
  1 +/**
  2 + * Copyright (c) 2012 by JP Moresmau
  3 + * This code is made available under the terms of the Eclipse Public License,
  4 + * version 1.0 (EPL). See http://www.eclipse.org/legal/epl-v10.html
  5 + */
  6 +package net.sf.eclipsefp.haskell.ui.wizards;
  7 +
  8 +import net.sf.eclipsefp.haskell.core.cabalmodel.CabalSyntax;
  9 +import net.sf.eclipsefp.haskell.core.cabalmodel.PackageDescription;
  10 +import net.sf.eclipsefp.haskell.core.cabalmodel.PackageDescriptionStanza;
  11 +import net.sf.eclipsefp.haskell.core.internal.project.ProjectModelFilesOp;
  12 +import net.sf.eclipsefp.haskell.ui.internal.util.UITexts;
  13 +import net.sf.eclipsefp.haskell.ui.internal.wizards.NewProjectWizardPage;
  14 +import net.sf.eclipsefp.haskell.util.PlatformUtil;
  15 +import org.eclipse.swt.widgets.Composite;
  16 +import org.eclipse.ui.INewWizard;
  17 +
  18 +
  19 +/**
  20 + * GTK project wizard: executable referencing gtk, Main.hs have default hello world
  21 + * @author JP Moresmau
  22 + *
  23 + */
  24 +public class NewGtkProjectWizard extends NewHaskellProjectWizard implements INewWizard {
  25 +
  26 + /**
  27 + *
  28 + */
  29 + public NewGtkProjectWizard() {
  30 + super();
  31 + op=new GktProjectModelFilesOp();
  32 + getOperation().setExtraOperation( op );
  33 + }
  34 +
  35 + /* (non-Javadoc)
  36 + * @see net.sf.eclipsefp.haskell.ui.internal.wizards.ProjectCreationWizard#addPages()
  37 + */
  38 + @Override
  39 + public void addPages() {
  40 + page = new NewProjectWizardPage(){
  41 + /* (non-Javadoc)
  42 + * @see net.sf.eclipsefp.haskell.ui.internal.wizards.NewProjectWizardPage#createControls(org.eclipse.swt.widgets.Composite)
  43 + */
  44 + @Override
  45 + protected void createControls( final Composite composite ) {
  46 + createNameControl(composite);
  47 + createLocationControl(composite);
  48 + }
  49 + };
  50 + page.setTitle( getPageTitle() );
  51 + page.setDescription( getPageDescription() );
  52 + addPage( page );
  53 + }
  54 +
  55 + @Override
  56 + public boolean performFinish() {
  57 + op.setExecutable( true);
  58 + op.setLibrary( false );
  59 + return super.performFinish();
  60 + }
  61 +
  62 + @Override
  63 + protected String getPageDescription() {
  64 + return UITexts.newGtkProjectWizard_pageDesc;
  65 + }
  66 +
  67 + @Override
  68 + protected String getPageTitle() {
  69 + return UITexts.newGtkProjectWizard_pageTitle;
  70 + }
  71 +
  72 + @Override
  73 + protected String getTheWindowTitle() {
  74 + return UITexts.newGtkProjectWizard_windowTitle;
  75 + }
  76 +
  77 + /**
  78 + * override main.hs and cabal file with gtk specifics
  79 + * @author JP Moresmau
  80 + *
  81 + */
  82 + private static class GktProjectModelFilesOp extends ProjectModelFilesOp{
  83 + /* (non-Javadoc)
  84 + * @see net.sf.eclipsefp.haskell.core.internal.project.ProjectModelFilesOp#getCabalFile(java.lang.String)
  85 + */
  86 + @Override
  87 + protected PackageDescription getCabalFile( final String name , final String src) {
  88 + PackageDescription pd=super.getCabalFile( name, src );
  89 + PackageDescriptionStanza pds=pd.getStanzas().get( 1 );
  90 + pds.addToPropertyList( CabalSyntax.FIELD_BUILD_DEPENDS, "gtk" ); //$NON-NLS-1$
  91 +
  92 + return pd;
  93 + }
  94 +
  95 + /* (non-Javadoc)
  96 + * @see net.sf.eclipsefp.haskell.core.internal.project.ProjectModelFilesOp#getMainFileContent()
  97 + */
  98 + @Override
  99 + protected String getMainFileContent() {
  100 + return "module Main where"+PlatformUtil.NL+PlatformUtil.NL+
  101 + "import Graphics.UI.Gtk"+PlatformUtil.NL+PlatformUtil.NL+
  102 + "main :: IO ()"+PlatformUtil.NL+
  103 + "main = do"+PlatformUtil.NL+
  104 + " initGUI"+PlatformUtil.NL+
  105 + " window <- windowNew"+PlatformUtil.NL+
  106 + " button <- buttonNew"+PlatformUtil.NL+
  107 + " set window [ containerBorderWidth := 10,"+PlatformUtil.NL+
  108 + " containerChild := button ]"+PlatformUtil.NL+
  109 + " set button [ buttonLabel := \"Hello World\" ]"+PlatformUtil.NL+
  110 + " onClicked button (putStrLn \"Hello World\")"+PlatformUtil.NL+
  111 + " onDestroy window mainQuit"+PlatformUtil.NL+
  112 + " widgetShowAll window"+PlatformUtil.NL+
  113 + " mainGUI"+PlatformUtil.NL;
  114 + }
  115 + }
  116 +}

0 comments on commit 7d0aa52

Please sign in to comment.
Something went wrong with that request. Please try again.