Browse files

stanza for editor in file properties

  • Loading branch information...
1 parent 6585974 commit 94f0422c7abaa8a743f6e9d1de0af84f3e8857fc @JPMoresmau committed Sep 4, 2012
Showing with 1,105 additions and 1,005 deletions.
  1. +1 −1 net.sf.eclipsefp.haskell-feature/feature.xml
  2. +1 −1 net.sf.eclipsefp.haskell.buildwrapper/META-INF/MANIFEST.MF
  3. +17 −0 net.sf.eclipsefp.haskell.buildwrapper/src/net/sf/eclipsefp/haskell/buildwrapper/BWFacade.java
  4. +1 −0 ....eclipsefp.haskell.buildwrapper/src/net/sf/eclipsefp/haskell/buildwrapper/BuildWrapperPlugin.java
  5. +139 −128 net.sf.eclipsefp.haskell.core/src/net/sf/eclipsefp/haskell/core/code/ModuleCreationInfo.java
  6. +1 −0 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/util/UITexts.java
  7. +1 −0 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/util/uitexts.properties
  8. +258 −192 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/properties/ModuleInclusionComposite.java
  9. +69 −70 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/properties/ModuleInclusionPP.java
  10. +145 −137 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/wizards/ModuleCreationOperation.java
  11. +50 −50 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/wizards/ModuleInclusionPage.java
  12. +104 −105 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/wizards/NewAlexWizard.java
  13. +104 −105 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/wizards/NewHappyWizard.java
  14. +103 −104 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/wizards/NewModuleWizard.java
  15. +111 −112 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/wizards/NewUuagcWizard.java
View
2 net.sf.eclipsefp.haskell-feature/feature.xml
@@ -158,7 +158,7 @@ available at http://www.eclipse.org/legal/epl-v10.html.
id="net.sf.eclipsefp.haskell.buildwrapper"
download-size="0"
install-size="0"
- version="2.3.1"
+ version="2.3.2"
unpack="false"/>
<plugin
View
2 net.sf.eclipsefp.haskell.buildwrapper/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %bundleName
Bundle-SymbolicName: net.sf.eclipsefp.haskell.buildwrapper;singleton:=true
-Bundle-Version: 2.3.1
+Bundle-Version: 2.3.2
Bundle-Activator: net.sf.eclipsefp.haskell.buildwrapper.BuildWrapperPlugin
Bundle-Vendor: %bundleVendor
Bundle-Localization: plugin
View
17 ...sf.eclipsefp.haskell.buildwrapper/src/net/sf/eclipsefp/haskell/buildwrapper/BWFacade.java
@@ -220,6 +220,17 @@ public boolean parseBuildResult(JSONArray arr){
// return flag;
// }
+ private void addEditorStanza(IFile file,List<String> command){
+ try {
+ String editor=file.getPersistentProperty(BuildWrapperPlugin.EDITORSTANZA_PROPERTY);
+ if (editor!=null){
+ command.add("--component="+editor);
+ }
+ } catch (CoreException ce){
+ BuildWrapperPlugin.logError(ce.getLocalizedMessage(), ce);
+ }
+ }
+
/**
* build one file
* @param file the file to build the temp contents
@@ -231,6 +242,7 @@ public boolean parseBuildResult(JSONArray arr){
LinkedList<String> command=new LinkedList<String>();
command.add("build1");
command.add("--file="+path);
+ addEditorStanza(file,command);
//long t0=System.currentTimeMillis();
//command.add("--buildflags="+escapeFlags(i.getFlags()));
JSONArray arr=run(command,ARRAY);
@@ -497,6 +509,7 @@ public OutlineResult outline(IFile file){
LinkedList<String> command=new LinkedList<String>();
command.add("outline");
command.add("--file="+path);
+ addEditorStanza(file,command);
//command.add("--buildflags="+escapeFlags(i.getFlags()));
JSONArray arr=run(command,ARRAY);
or=new OutlineResult();
@@ -545,6 +558,7 @@ public void registerOutline(IFile file,OutlineResult or){
LinkedList<String> command=new LinkedList<String>();
command.add("tokentypes");
command.add("--file="+path);
+ addEditorStanza(file,command);
JSONArray arr=run(command,ARRAY);
//long t01=System.currentTimeMillis();
List<TokenDef> cps;
@@ -576,6 +590,7 @@ public BuildFlags getBuildFlags(IFile file){
LinkedList<String> command=new LinkedList<String>();
command.add("getbuildflags");
command.add("--file="+path);
+ addEditorStanza(file,command);
JSONArray arr=run(command,ARRAY);
if (arr!=null){
if (arr.length()>1){
@@ -598,6 +613,7 @@ public BuildFlags getBuildFlags(IFile file){
command.add("occurrences");
command.add("--file="+path);
command.add("--token="+s);
+ addEditorStanza(file,command);
//command.add("--buildflags="+escapeFlags(i.getFlags()));
JSONArray arr=run(command,ARRAY);
List<Occurrence> cps;
@@ -632,6 +648,7 @@ public ThingAtPoint getThingAtPoint(IFile file,Location location){
command.add("--file="+path);
command.add("--line="+location.getStartLine());
command.add("--column="+(location.getStartColumn()+1));
+ addEditorStanza(file,command);
//command.add("--buildflags="+escapeFlags(i.getFlags()));
JSONArray arr=run(command,ARRAY);
ThingAtPoint tap=null;
View
1 ...fp.haskell.buildwrapper/src/net/sf/eclipsefp/haskell/buildwrapper/BuildWrapperPlugin.java
@@ -37,6 +37,7 @@
public static QualifiedName USERFLAGS_PROPERTY=new QualifiedName("EclipseFP", "UserFlags");
public static QualifiedName EXTRAOPTS_PROPERTY=new QualifiedName("EclipseFP", "ExtraOpts");
+ public static QualifiedName EDITORSTANZA_PROPERTY=new QualifiedName("EclipseFP", "EditorStanza");
// The shared instance
private static BuildWrapperPlugin plugin;
View
267 net.sf.eclipsefp.haskell.core/src/net/sf/eclipsefp/haskell/core/code/ModuleCreationInfo.java
@@ -1,129 +1,140 @@
-// Copyright (c) 2003-2005 by Leif Frenzel - see http://leiffrenzel.de
-package net.sf.eclipsefp.haskell.core.code;
-
-import java.util.Set;
-import net.sf.eclipsefp.haskell.core.cabalmodel.PackageDescriptionStanza;
-import net.sf.eclipsefp.haskell.core.util.ResourceUtil;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IPath;
-
-
-/** <p>holds detailed information about the module which is to be created
- * in the 'New Module' wizard.</p>
- *
- * @author Leif Frenzel
- */
-public class ModuleCreationInfo {
-
- private String moduleName = ""; //$NON-NLS-1$
- private IPath folders;
- private IContainer sourceContainer;
- private EHaskellCommentStyle fCommentStyle = EHaskellCommentStyle.USUAL;
-
- private Set<PackageDescriptionStanza> included;
- private Set<PackageDescriptionStanza> exposed;
-
- /**
- * are the source folders used to generate the qualified name
- */
- private boolean foldersQualify=true;
-
-
- // attribute setters and getters
- ////////////////////////////////
-
- public ModuleCreationInfo() {
- super();
- }
-
- public ModuleCreationInfo(final IFile f) {
- super();
- IContainer src=ResourceUtil.getSourceContainer( f );
- setSourceContainer( src );
- if (src!=null){
- IPath p=ResourceUtil.getSourceRelativePath( src, f );
- setFolders(p);
- }
- setModuleName( f.getProjectRelativePath().removeFileExtension().lastSegment() );
-
- }
-
-
- public IPath getFolders() {
- return folders;
- }
-
- public void setFolders( final IPath folders ) {
- this.folders = folders;
- }
-
- public String getModuleName() {
- return this.moduleName;
- }
-
- public String getQualifiedModuleName(){
- StringBuilder sb=new StringBuilder();
- if (foldersQualify && getFolders()!=null && getFolders().segmentCount()>0){
- String ps=getFolders().toPortableString().replace( '/', '.' ) ;
- sb.append(ps);
- if (!ps.endsWith( "." )){ //$NON-NLS-1$
- sb.append("."); //$NON-NLS-1$
- }
- }
- sb.append(getModuleName());
- return sb.toString();
- }
-
- public void setModuleName( final String moduleName ) {
- this.moduleName = moduleName;
- }
-
- public IContainer getSourceContainer() {
- return sourceContainer;
- }
-
- public void setSourceContainer( final IContainer sourceContainer ) {
- this.sourceContainer = sourceContainer;
- }
-
- public EHaskellCommentStyle getCommentStyle() {
- return fCommentStyle;
- }
-
- public void setCommentStyle( final EHaskellCommentStyle style ) {
- fCommentStyle = style;
- }
-
-
- public Set<PackageDescriptionStanza> getIncluded() {
- return included;
- }
-
-
- public void setIncluded( final Set<PackageDescriptionStanza> included ) {
- this.included = included;
- }
-
-
- public Set<PackageDescriptionStanza> getExposed() {
- return exposed;
- }
-
-
- public void setExposed( final Set<PackageDescriptionStanza> exposed ) {
- this.exposed = exposed;
- }
-
-
- public boolean isFoldersQualify() {
- return foldersQualify;
- }
-
-
- public void setFoldersQualify( final boolean foldersQualify ) {
- this.foldersQualify = foldersQualify;
- }
-
-
+// Copyright (c) 2003-2005 by Leif Frenzel - see http://leiffrenzel.de
+package net.sf.eclipsefp.haskell.core.code;
+
+import java.util.Set;
+import net.sf.eclipsefp.haskell.core.cabalmodel.PackageDescriptionStanza;
+import net.sf.eclipsefp.haskell.core.util.ResourceUtil;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
+
+
+/** <p>holds detailed information about the module which is to be created
+ * in the 'New Module' wizard.</p>
+ *
+ * @author Leif Frenzel
+ */
+public class ModuleCreationInfo {
+
+ private String moduleName = ""; //$NON-NLS-1$
+ private IPath folders;
+ private IContainer sourceContainer;
+ private EHaskellCommentStyle fCommentStyle = EHaskellCommentStyle.USUAL;
+
+ private Set<PackageDescriptionStanza> included;
+ private Set<PackageDescriptionStanza> exposed;
+
+ private PackageDescriptionStanza editorStanza;
+ /**
+ * are the source folders used to generate the qualified name
+ */
+ private boolean foldersQualify=true;
+
+
+ // attribute setters and getters
+ ////////////////////////////////
+
+ public ModuleCreationInfo() {
+ super();
+ }
+
+ public ModuleCreationInfo(final IFile f) {
+ super();
+ IContainer src=ResourceUtil.getSourceContainer( f );
+ setSourceContainer( src );
+ if (src!=null){
+ IPath p=ResourceUtil.getSourceRelativePath( src, f );
+ setFolders(p);
+ }
+ setModuleName( f.getProjectRelativePath().removeFileExtension().lastSegment() );
+
+ }
+
+
+ public IPath getFolders() {
+ return folders;
+ }
+
+ public void setFolders( final IPath folders ) {
+ this.folders = folders;
+ }
+
+ public String getModuleName() {
+ return this.moduleName;
+ }
+
+ public String getQualifiedModuleName(){
+ StringBuilder sb=new StringBuilder();
+ if (foldersQualify && getFolders()!=null && getFolders().segmentCount()>0){
+ String ps=getFolders().toPortableString().replace( '/', '.' ) ;
+ sb.append(ps);
+ if (!ps.endsWith( "." )){ //$NON-NLS-1$
+ sb.append("."); //$NON-NLS-1$
+ }
+ }
+ sb.append(getModuleName());
+ return sb.toString();
+ }
+
+ public void setModuleName( final String moduleName ) {
+ this.moduleName = moduleName;
+ }
+
+ public IContainer getSourceContainer() {
+ return sourceContainer;
+ }
+
+ public void setSourceContainer( final IContainer sourceContainer ) {
+ this.sourceContainer = sourceContainer;
+ }
+
+ public EHaskellCommentStyle getCommentStyle() {
+ return fCommentStyle;
+ }
+
+ public void setCommentStyle( final EHaskellCommentStyle style ) {
+ fCommentStyle = style;
+ }
+
+
+ public Set<PackageDescriptionStanza> getIncluded() {
+ return included;
+ }
+
+
+ public void setIncluded( final Set<PackageDescriptionStanza> included ) {
+ this.included = included;
+ }
+
+
+ public Set<PackageDescriptionStanza> getExposed() {
+ return exposed;
+ }
+
+
+ public void setExposed( final Set<PackageDescriptionStanza> exposed ) {
+ this.exposed = exposed;
+ }
+
+
+ public boolean isFoldersQualify() {
+ return foldersQualify;
+ }
+
+
+ public void setFoldersQualify( final boolean foldersQualify ) {
+ this.foldersQualify = foldersQualify;
+ }
+
+
+ public PackageDescriptionStanza getEditorStanza() {
+ return editorStanza;
+ }
+
+
+ public void setEditorStanza( final PackageDescriptionStanza editorStanza ) {
+ this.editorStanza = editorStanza;
+ }
+
+
}
View
1 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/util/UITexts.java
@@ -295,6 +295,7 @@
public static String module_inclusion_field_section;
public static String module_inclusion_field_include;
public static String module_inclusion_field_expose;
+ public static String module_inclusion_field_editor;
public static String module_inclusion_page_title;
public static String module_inclusion_page_description;
public static String module_inclusion_error;
View
1 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/util/uitexts.properties
@@ -300,6 +300,7 @@ module_inclusion_title=Module inclusion
module_inclusion_field_section=Section
module_inclusion_field_include=Include
module_inclusion_field_expose=Expose
+module_inclusion_field_editor=Default Editor Stanza
module_inclusion_page_title=Include Haskell Module
module_inclusion_page_description=Choose whether to include the Haskell module.
module_inclusion_error=Error updating module inclusion
View
450 ...psefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/properties/ModuleInclusionComposite.java
@@ -1,192 +1,258 @@
-package net.sf.eclipsefp.haskell.ui.properties;
-
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import net.sf.eclipsefp.haskell.buildwrapper.BuildWrapperPlugin;
-import net.sf.eclipsefp.haskell.core.cabalmodel.CabalSyntax;
-import net.sf.eclipsefp.haskell.core.cabalmodel.ModuleInclusionType;
-import net.sf.eclipsefp.haskell.core.cabalmodel.PackageDescription;
-import net.sf.eclipsefp.haskell.core.cabalmodel.PackageDescriptionLoader;
-import net.sf.eclipsefp.haskell.core.cabalmodel.PackageDescriptionStanza;
-import net.sf.eclipsefp.haskell.ui.HaskellUIPlugin;
-import net.sf.eclipsefp.haskell.ui.internal.util.UITexts;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-
-/**
- * <p>Give options to expose and include modules in Cabal sections</p>
- *
- * @author JP Moresmau
- */
-public class ModuleInclusionComposite extends Composite {
- private final Set<PackageDescriptionStanza> included=new HashSet<PackageDescriptionStanza>();
- private final Set<PackageDescriptionStanza> exposed=new HashSet<PackageDescriptionStanza>();
-
- /**
- * have we init at all
- */
- private boolean init=false;
-
- public ModuleInclusionComposite( final Composite parent, final int style ) {
- super( parent, style );
- }
-
- public void initNoSourceFolder(){
- GridLayout gl=new GridLayout(1,false);
- setLayout( gl );
- Label w=new Label(this,SWT.NONE);
- w.setText( UITexts.module_inclusion_nosourcefolder );
- layout( true, true );
- }
-
-
- public boolean isInit() {
- return init;
- }
-
- /**
- * init the composite with information from the cabal file, or if it's a new module, default inclusion
- * @param srcPath the path to the source folder
- * @param module the module name
- * @param isNew is the module being created?
- */
- public void init(final IResource srcPath, final String module,final boolean isNew){
- init=true;
- for (Control c:getChildren()){
- c.dispose();
- }
- included.clear();
- exposed.clear();
- try {
- PackageDescription cabal=PackageDescriptionLoader.load( BuildWrapperPlugin.getCabalFile( srcPath.getProject() ));
- String path=srcPath.getProjectRelativePath().toOSString();
- if (path.length()==0){
- path=".";
- }
- List<PackageDescriptionStanza> l=cabal.getStanzasBySourceDir().get( path );
- if (l!=null && l.size()>0){
- GridLayout gl=new GridLayout(3,false);
- setLayout( gl );
-
- GridData gdTitle=new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gdTitle.horizontalSpan=3;
- Label lTitle=new Label( this, SWT.NONE );
- lTitle.setText( UITexts.module_inclusion_title );
- lTitle.setLayoutData( gdTitle );
-
- Label lSection=new Label( this, SWT.NONE );
- lSection.setText( UITexts.module_inclusion_field_section );
-
- Label lInclude=new Label( this, SWT.NONE );
- lInclude.setText( UITexts.module_inclusion_field_include);
-
- Label lExpose=new Label( this, SWT.NONE );
- lExpose.setText( UITexts.module_inclusion_field_expose );
-
-
- Collections.sort( l,new Comparator<PackageDescriptionStanza>() {
- @Override
- public int compare( final PackageDescriptionStanza o1,
- final PackageDescriptionStanza o2 ) {
- return o1.toTypeName().compareToIgnoreCase( o2.toTypeName() );
- }
- });
-
- for (final PackageDescriptionStanza pd:l){
- Label lName=new Label(this,SWT.NONE);
- lName.setText( pd.toTypeName() );
-
- final Button bInclude=new Button(this,SWT.CHECK);
-
- ModuleInclusionType mit=pd.getModuleInclusionType( module );
-
- if ((CabalSyntax.SECTION_EXECUTABLE.equals( pd.getType()) || CabalSyntax.SECTION_TESTSUITE.equals( pd.getType())) && ModuleInclusionType.MAIN.equals( mit )){
- bInclude.setEnabled( false );
- }
-
- final Button bExpose=new Button(this,SWT.CHECK);
- bExpose.setEnabled( CabalSyntax.SECTION_LIBRARY.equals( pd.getType() ) );
-
- if (bInclude.isEnabled()){
- bInclude.addSelectionListener( new SelectionAdapter() {
- @Override
- public void widgetSelected( final SelectionEvent e ) {
- if(bInclude.getSelection()){
- included.add( pd );
- exposed.remove( pd );
- bExpose.setSelection( false );
- } else {
- included.remove( pd );
- }
- // bExpose.setEnabled(CabalSyntax.SECTION_LIBRARY.equals( pd.getType() ) && !bInclude.getSelection() );
- }
-
- });
- if (ModuleInclusionType.INCLUDED.equals( mit ) || isNew){
- bInclude.setSelection( true);
- included.add( pd );
- bExpose.setSelection( false );
- if (isNew){
- bInclude.notifyListeners( SWT.Selection, new Event() );
- }
- }
- }
-
- if (bExpose.isEnabled()){
-
- bExpose.addSelectionListener( new SelectionAdapter() {
- @Override
- public void widgetSelected( final SelectionEvent e ) {
- if(bExpose.getSelection()){
- exposed.add( pd );
- included.remove( pd );
- bInclude.setSelection( false );
- } else {
- exposed.remove( pd );
- }
- // bInclude.setEnabled( !bExpose.getSelection() );
- }
- });
- if (ModuleInclusionType.EXPOSED.equals( mit ) || (isNew && !bInclude.isEnabled())){
- bExpose.setSelection( true);
- exposed.add( pd );
- bInclude.setSelection( false );
- if (isNew){
- bInclude.notifyListeners( SWT.Selection, new Event() );
- }
- }
-
- }
- }
- }
-
- layout( true, true );
- } catch (CoreException ce){
- HaskellUIPlugin.log( ce );
- }
-
- }
-
-
- public Set<PackageDescriptionStanza> getExposed() {
- return exposed;
- }
-
-
- public Set<PackageDescriptionStanza> getIncluded() {
- return included;
- }
-}
+package net.sf.eclipsefp.haskell.ui.properties;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import net.sf.eclipsefp.haskell.buildwrapper.BuildWrapperPlugin;
+import net.sf.eclipsefp.haskell.core.cabalmodel.CabalSyntax;
+import net.sf.eclipsefp.haskell.core.cabalmodel.ModuleInclusionType;
+import net.sf.eclipsefp.haskell.core.cabalmodel.PackageDescription;
+import net.sf.eclipsefp.haskell.core.cabalmodel.PackageDescriptionLoader;
+import net.sf.eclipsefp.haskell.core.cabalmodel.PackageDescriptionStanza;
+import net.sf.eclipsefp.haskell.core.code.ModuleCreationInfo;
+import net.sf.eclipsefp.haskell.ui.HaskellUIPlugin;
+import net.sf.eclipsefp.haskell.ui.internal.util.UITexts;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+
+/**
+ * <p>Give options to expose and include modules in Cabal sections</p>
+ *
+ * @author JP Moresmau
+ */
+public class ModuleInclusionComposite extends Composite {
+ private final Set<PackageDescriptionStanza> included=new HashSet<PackageDescriptionStanza>();
+ private final Set<PackageDescriptionStanza> exposed=new HashSet<PackageDescriptionStanza>();
+ private PackageDescriptionStanza editorStanza=null;
+
+ private final Collection<Button> editorStanzaButtons=new ArrayList<Button>();
+
+ private final SelectionListener editorButtonL=new SelectionAdapter() {
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected( final SelectionEvent e ) {
+ if (((Button)e.widget).getSelection()){
+ for (Button b:editorStanzaButtons){
+ if (b!=e.widget){
+ b.setSelection( false );
+ }
+ }
+ }
+ }
+ };
+
+ /**
+ * have we init at all
+ */
+ private boolean init=false;
+
+ public ModuleInclusionComposite( final Composite parent, final int style ) {
+ super( parent, style );
+ }
+
+ public void initNoSourceFolder(){
+ GridLayout gl=new GridLayout(1,false);
+ setLayout( gl );
+ Label w=new Label(this,SWT.NONE);
+ w.setText( UITexts.module_inclusion_nosourcefolder );
+ layout( true, true );
+ }
+
+
+ public boolean isInit() {
+ return init;
+ }
+
+ /**
+ * init the composite with information from the cabal file, or if it's a new module, default inclusion
+ * @param srcPath the path to the source folder
+ * @param module the module name
+ * @param isNew is the module being created?
+ */
+ public void init(final IFile file,final IResource srcPath, final String module,final boolean isNew){
+ init=true;
+ for (Control c:getChildren()){
+ c.dispose();
+ }
+ included.clear();
+ exposed.clear();
+ editorStanzaButtons.clear();
+ try {
+ String editor=null;
+ if (file!=null){
+ editor=file.getPersistentProperty( BuildWrapperPlugin.EDITORSTANZA_PROPERTY );
+ }
+
+ PackageDescription cabal=PackageDescriptionLoader.load( BuildWrapperPlugin.getCabalFile( srcPath.getProject() ));
+ String path=srcPath.getProjectRelativePath().toOSString();
+ if (path.length()==0){
+ path=".";
+ }
+ List<PackageDescriptionStanza> l=cabal.getStanzasBySourceDir().get( path );
+ if (l!=null && l.size()>0){
+ GridLayout gl=new GridLayout(4,false);
+ setLayout( gl );
+
+ GridData gdTitle=new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gdTitle.horizontalSpan=4;
+ Label lTitle=new Label( this, SWT.NONE );
+ lTitle.setText( UITexts.module_inclusion_title );
+ lTitle.setLayoutData( gdTitle );
+
+ Label lSection=new Label( this, SWT.NONE );
+ lSection.setText( UITexts.module_inclusion_field_section );
+
+ Label lInclude=new Label( this, SWT.NONE );
+ lInclude.setText( UITexts.module_inclusion_field_include);
+
+ Label lExpose=new Label( this, SWT.NONE );
+ lExpose.setText( UITexts.module_inclusion_field_expose );
+
+ Label lEditor=new Label( this, SWT.NONE );
+ lEditor.setText( UITexts.module_inclusion_field_editor);
+
+ Collections.sort( l,new Comparator<PackageDescriptionStanza>() {
+ @Override
+ public int compare( final PackageDescriptionStanza o1,
+ final PackageDescriptionStanza o2 ) {
+ return o1.toTypeName().compareToIgnoreCase( o2.toTypeName() );
+ }
+ });
+
+ for (final PackageDescriptionStanza pd:l){
+ Label lName=new Label(this,SWT.NONE);
+ lName.setText( pd.toTypeName() );
+
+ final Button bInclude=new Button(this,SWT.CHECK);
+
+ ModuleInclusionType mit=pd.getModuleInclusionType( module );
+
+ if ((CabalSyntax.SECTION_EXECUTABLE.equals( pd.getType()) || CabalSyntax.SECTION_TESTSUITE.equals( pd.getType())) && ModuleInclusionType.MAIN.equals( mit )){
+ bInclude.setEnabled( false );
+ }
+
+ final Button bExpose=new Button(this,SWT.CHECK);
+ bExpose.setEnabled( CabalSyntax.SECTION_LIBRARY.equals( pd.getType() ) );
+
+ final Button bEditor=new Button(this,SWT.RADIO);
+ bEditor.setEnabled( true );
+ editorStanzaButtons.add( bEditor );
+ bEditor.addSelectionListener( editorButtonL );
+ bEditor.addSelectionListener( new SelectionAdapter() {
+ @Override
+ public void widgetSelected(final SelectionEvent e) {
+ if (bEditor.getSelection()){
+ editorStanza=pd;
+ } else {
+ editorStanza=null;
+ }
+ }
+ } );
+ if (bInclude.isEnabled()){
+ bInclude.addSelectionListener( new SelectionAdapter() {
+ @Override
+ public void widgetSelected( final SelectionEvent e ) {
+ if(bInclude.getSelection()){
+ included.add( pd );
+ exposed.remove( pd );
+ bExpose.setSelection( false );
+ } else {
+ included.remove( pd );
+ }
+ // bExpose.setEnabled(CabalSyntax.SECTION_LIBRARY.equals( pd.getType() ) && !bInclude.getSelection() );
+ }
+
+ });
+ if (ModuleInclusionType.INCLUDED.equals( mit ) || isNew){
+ bInclude.setSelection( true);
+ included.add( pd );
+ bExpose.setSelection( false );
+ if (isNew){
+ bInclude.notifyListeners( SWT.Selection, new Event() );
+ }
+ }
+ }
+
+ if (bExpose.isEnabled()){
+
+ bExpose.addSelectionListener( new SelectionAdapter() {
+ @Override
+ public void widgetSelected( final SelectionEvent e ) {
+ if(bExpose.getSelection()){
+ exposed.add( pd );
+ included.remove( pd );
+ bInclude.setSelection( false );
+ } else {
+ exposed.remove( pd );
+ }
+ // bInclude.setEnabled( !bExpose.getSelection() );
+ }
+ });
+ if (ModuleInclusionType.EXPOSED.equals( mit ) || (isNew && !bInclude.isEnabled())){
+ bExpose.setSelection( true);
+ exposed.add( pd );
+ bInclude.setSelection( false );
+ if (isNew){
+ bInclude.notifyListeners( SWT.Selection, new Event() );
+ }
+ }
+
+ }
+ if (editor!=null){
+ if (editor.equals( pd.getName() ) || (editor.equals( "" ) && pd.getName()==null)){
+ bEditor.setSelection( true );
+ editorStanza=pd;
+ }
+ }
+ }
+ }
+
+ layout( true, true );
+ } catch (CoreException ce){
+ HaskellUIPlugin.log( ce );
+ }
+
+ }
+
+
+ public Set<PackageDescriptionStanza> getExposed() {
+ return exposed;
+ }
+
+
+ public Set<PackageDescriptionStanza> getIncluded() {
+ return included;
+ }
+
+
+ /**
+ * @return the editorStanza
+ */
+ public PackageDescriptionStanza getEditorStanza() {
+ return editorStanza;
+ }
+
+ public void populateInfo(final ModuleCreationInfo info){
+ info.setExposed( getExposed() );
+ info.setIncluded( getIncluded() );
+ info.setEditorStanza( getEditorStanza() );
+ }
+}
View
139 ...sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/properties/ModuleInclusionPP.java
@@ -1,70 +1,69 @@
-package net.sf.eclipsefp.haskell.ui.properties;
-
-import net.sf.eclipsefp.haskell.core.code.ModuleCreationInfo;
-import net.sf.eclipsefp.haskell.core.util.ResourceUtil;
-import net.sf.eclipsefp.haskell.ui.HaskellUIPlugin;
-import net.sf.eclipsefp.haskell.ui.internal.util.UITexts;
-import net.sf.eclipsefp.haskell.ui.wizards.ModuleCreationOperation;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.dialogs.PropertyPage;
-
-/**
- * <p>Property page for Haskell files: decide to include or expose the module</p>
- *
- * @author JP Moresmau
- */
-public class ModuleInclusionPP extends PropertyPage {
- private ModuleInclusionComposite mic;
- private ModuleCreationInfo info;
- public ModuleInclusionPP() {
- // NOOP
- }
-
- @Override
- protected Control createContents( final Composite parent ) {
- mic=new ModuleInclusionComposite( parent, SWT.NONE );
- IFile f=(IFile)getElement();
-
- IContainer src=ResourceUtil.getSourceContainer( f );
- if (src!=null){
- info=new ModuleCreationInfo();
- info.setSourceContainer( src );
- IPath p=ResourceUtil.getSourceRelativePath( src, f );
- info.setFolders(p);
- info.setModuleName( f.getProjectRelativePath().removeFileExtension().lastSegment() );
- mic.init( src, info.getQualifiedModuleName() ,false);
- } else {
- mic.initNoSourceFolder();
- }
- Dialog.applyDialogFont( parent );
- return mic;
- }
-
- @Override
- public boolean performOk() {
- if (info!=null){
- info.setExposed( mic.getExposed() );
- info.setIncluded( mic.getIncluded() );
- ModuleCreationOperation mco=new ModuleCreationOperation( info );
- mco.setGeneratedFile( (IFile)getElement() );
-
- try {
- mco.run( new NullProgressMonitor() );
- return true;
- } catch( Exception ex ) {
- HaskellUIPlugin.log( UITexts.module_inclusion_error, ex );
- return false;
- }
- }
- return true;
- }
-
-
-}
+package net.sf.eclipsefp.haskell.ui.properties;
+
+import net.sf.eclipsefp.haskell.core.code.ModuleCreationInfo;
+import net.sf.eclipsefp.haskell.core.util.ResourceUtil;
+import net.sf.eclipsefp.haskell.ui.HaskellUIPlugin;
+import net.sf.eclipsefp.haskell.ui.internal.util.UITexts;
+import net.sf.eclipsefp.haskell.ui.wizards.ModuleCreationOperation;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+/**
+ * <p>Property page for Haskell files: decide to include or expose the module</p>
+ *
+ * @author JP Moresmau
+ */
+public class ModuleInclusionPP extends PropertyPage {
+ private ModuleInclusionComposite mic;
+ private ModuleCreationInfo info;
+ public ModuleInclusionPP() {
+ // NOOP
+ }
+
+ @Override
+ protected Control createContents( final Composite parent ) {
+ mic=new ModuleInclusionComposite( parent, SWT.NONE );
+ IFile f=(IFile)getElement();
+
+ IContainer src=ResourceUtil.getSourceContainer( f );
+ if (src!=null){
+ info=new ModuleCreationInfo();
+ info.setSourceContainer( src );
+ IPath p=ResourceUtil.getSourceRelativePath( src, f );
+ info.setFolders(p);
+ info.setModuleName( f.getProjectRelativePath().removeFileExtension().lastSegment() );
+ mic.init(f, src, info.getQualifiedModuleName() ,false);
+ } else {
+ mic.initNoSourceFolder();
+ }
+ Dialog.applyDialogFont( parent );
+ return mic;
+ }
+
+ @Override
+ public boolean performOk() {
+ if (info!=null){
+ mic.populateInfo( info );
+ ModuleCreationOperation mco=new ModuleCreationOperation( info );
+ mco.setGeneratedFile( (IFile)getElement() );
+
+ try {
+ mco.run( new NullProgressMonitor() );
+ return true;
+ } catch( Exception ex ) {
+ HaskellUIPlugin.log( UITexts.module_inclusion_error, ex );
+ return false;
+ }
+ }
+ return true;
+ }
+
+
+}
View
282 ...eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/wizards/ModuleCreationOperation.java
@@ -1,138 +1,146 @@
-// Copyright (c) 2003-2005 by Leif Frenzel - see http://leiffrenzel.de
-package net.sf.eclipsefp.haskell.ui.wizards;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import net.sf.eclipsefp.haskell.buildwrapper.BuildWrapperPlugin;
-import net.sf.eclipsefp.haskell.core.cabalmodel.CabalSyntax;
-import net.sf.eclipsefp.haskell.core.cabalmodel.PackageDescription;
-import net.sf.eclipsefp.haskell.core.cabalmodel.PackageDescriptionLoader;
-import net.sf.eclipsefp.haskell.core.cabalmodel.PackageDescriptionStanza;
-import net.sf.eclipsefp.haskell.core.cabalmodel.RealValuePosition;
-import net.sf.eclipsefp.haskell.core.code.ModuleCreationInfo;
-import net.sf.eclipsefp.haskell.core.code.SourceFileGenerator;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.ui.editors.text.TextFileDocumentProvider;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-
-
-/** <p>the operation that creates a new module in a Haskell project.</p>
- *
- * @author Leif Frenzel
- */
-public class ModuleCreationOperation implements IRunnableWithProgress {
-
- private final ModuleCreationInfo info;
- // the file that is finally generated in this operation
- private IFile generatedFile;
-
- public ModuleCreationOperation( final ModuleCreationInfo info ) {
- this.info = info;
- }
-
- IFile getGeneratedFile() {
- return generatedFile;
- }
-
-
- public void setGeneratedFile( final IFile generatedFile ) {
- this.generatedFile = generatedFile;
- }
-
- public ModuleCreationInfo getInfo() {
- return info;
- }
-
- // interface methods of IRunnableWithProgress
- /////////////////////////////////////////////
-
- @Override
- public void run( final IProgressMonitor monitor ) throws InvocationTargetException {
- Assert.isNotNull( info );
- try {
- boolean onlyAdd=false;
- if (generatedFile==null){
- generatedFile = new SourceFileGenerator().createFile( monitor, info );
- onlyAdd=true;
- }
- IProject p=generatedFile.getProject();
- IFile f=BuildWrapperPlugin.getCabalFile( p );
- IDocumentProvider prov=new TextFileDocumentProvider();
- prov.connect( f );
- try {
- IDocument doc=prov.getDocument( f );
- PackageDescription pd=PackageDescriptionLoader.load( doc.get() );
- String moduleName=info.getQualifiedModuleName();
-
-
- if (onlyAdd){
- for (PackageDescriptionStanza pds:info.getIncluded()){
- RealValuePosition vp=pd.getSameStanza(pds).addToPropertyList( CabalSyntax.FIELD_OTHER_MODULES, moduleName );
- if (vp!=null){
- vp.updateDocument( doc );
- pd=PackageDescriptionLoader.load( doc.get() );
- }
- }
- for (PackageDescriptionStanza pds:info.getExposed()){
- RealValuePosition vp=pd.getSameStanza(pds).addToPropertyList( CabalSyntax.FIELD_EXPOSED_MODULES, moduleName );
- if (vp!=null){
- vp.updateDocument( doc );
- pd=PackageDescriptionLoader.load( doc.get() );
- }
- }
- } else {
- Set<String> sIncluded=new HashSet<String>();
- for (PackageDescriptionStanza pds:info.getIncluded()){
- sIncluded.add( pds.toTypeName() );
- }
- Set<String> sExposed=new HashSet<String>();
- for (PackageDescriptionStanza pds:info.getExposed()){
- sExposed.add( pds.toTypeName() );
- }
- List<PackageDescriptionStanza> pdss=new ArrayList<PackageDescriptionStanza>( pd.getStanzas() );
- for (PackageDescriptionStanza pds:pdss){
- if (pds.getType()!=null && (pds.getType().equals( CabalSyntax.SECTION_LIBRARY ) || pds.getType().equals( CabalSyntax.SECTION_EXECUTABLE ) || pds.getType().equals( CabalSyntax.SECTION_TESTSUITE ))){
- pds=pd.getSameStanza( pds );
- RealValuePosition vp=null;
- if(sIncluded.contains( pds.toTypeName() )){
- vp=pds.addToPropertyList( CabalSyntax.FIELD_OTHER_MODULES, moduleName );
- } else {
- vp=pds.removeFromPropertyList( CabalSyntax.FIELD_OTHER_MODULES, moduleName );
- }
- if (vp!=null){
- vp.updateDocument( doc );
- pd=PackageDescriptionLoader.load( doc.get() );
- pds=pd.getSameStanza( pds );
- }
- if (sExposed.contains( pds.toTypeName() )){
- vp=pds.addToPropertyList( CabalSyntax.FIELD_EXPOSED_MODULES, moduleName );
- } else {
- vp=pds.removeFromPropertyList( CabalSyntax.FIELD_EXPOSED_MODULES, moduleName );
- }
- if (vp!=null){
- vp.updateDocument( doc );
- pd=PackageDescriptionLoader.load( doc.get() );
- }
- }
- }
- }
- prov.saveDocument( monitor, f, doc, true );
- } finally {
- prov.disconnect( f );
- }
- // let the listener do its work
- // ScionPlugin.getScionInstance( generatedFile ).buildProjectForWorkspace( monitor, false , false);
- } catch( CoreException ex ) {
- throw new InvocationTargetException( ex );
- }
- }
+// Copyright (c) 2003-2005 by Leif Frenzel - see http://leiffrenzel.de
+package net.sf.eclipsefp.haskell.ui.wizards;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import net.sf.eclipsefp.haskell.buildwrapper.BuildWrapperPlugin;
+import net.sf.eclipsefp.haskell.core.cabalmodel.CabalSyntax;
+import net.sf.eclipsefp.haskell.core.cabalmodel.PackageDescription;
+import net.sf.eclipsefp.haskell.core.cabalmodel.PackageDescriptionLoader;
+import net.sf.eclipsefp.haskell.core.cabalmodel.PackageDescriptionStanza;
+import net.sf.eclipsefp.haskell.core.cabalmodel.RealValuePosition;
+import net.sf.eclipsefp.haskell.core.code.ModuleCreationInfo;
+import net.sf.eclipsefp.haskell.core.code.SourceFileGenerator;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.ui.editors.text.TextFileDocumentProvider;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+
+
+/** <p>the operation that creates a new module in a Haskell project.</p>
+ *
+ * @author Leif Frenzel
+ */
+public class ModuleCreationOperation implements IRunnableWithProgress {
+
+ private final ModuleCreationInfo info;
+ // the file that is finally generated in this operation
+ private IFile generatedFile;
+
+ public ModuleCreationOperation( final ModuleCreationInfo info ) {
+ this.info = info;
+ }
+
+ IFile getGeneratedFile() {
+ return generatedFile;
+ }
+
+
+ public void setGeneratedFile( final IFile generatedFile ) {
+ this.generatedFile = generatedFile;
+ }
+
+ public ModuleCreationInfo getInfo() {
+ return info;
+ }
+
+ // interface methods of IRunnableWithProgress
+ /////////////////////////////////////////////
+
+ @Override
+ public void run( final IProgressMonitor monitor ) throws InvocationTargetException {
+ Assert.isNotNull( info );
+ try {
+ boolean onlyAdd=false;
+ if (generatedFile==null){
+ generatedFile = new SourceFileGenerator().createFile( monitor, info );
+ onlyAdd=true;
+ }
+ IProject p=generatedFile.getProject();
+ IFile f=BuildWrapperPlugin.getCabalFile( p );
+ IDocumentProvider prov=new TextFileDocumentProvider();
+ prov.connect( f );
+ try {
+ IDocument doc=prov.getDocument( f );
+ PackageDescription pd=PackageDescriptionLoader.load( doc.get() );
+ String moduleName=info.getQualifiedModuleName();
+
+
+ if (onlyAdd){
+ for (PackageDescriptionStanza pds:info.getIncluded()){
+ RealValuePosition vp=pd.getSameStanza(pds).addToPropertyList( CabalSyntax.FIELD_OTHER_MODULES, moduleName );
+ if (vp!=null){
+ vp.updateDocument( doc );
+ pd=PackageDescriptionLoader.load( doc.get() );
+ }
+ }
+ for (PackageDescriptionStanza pds:info.getExposed()){
+ RealValuePosition vp=pd.getSameStanza(pds).addToPropertyList( CabalSyntax.FIELD_EXPOSED_MODULES, moduleName );
+ if (vp!=null){
+ vp.updateDocument( doc );
+ pd=PackageDescriptionLoader.load( doc.get() );
+ }
+ }
+ } else {
+ Set<String> sIncluded=new HashSet<String>();
+ for (PackageDescriptionStanza pds:info.getIncluded()){
+ sIncluded.add( pds.toTypeName() );
+ }
+ Set<String> sExposed=new HashSet<String>();
+ for (PackageDescriptionStanza pds:info.getExposed()){
+ sExposed.add( pds.toTypeName() );
+ }
+ List<PackageDescriptionStanza> pdss=new ArrayList<PackageDescriptionStanza>( pd.getStanzas() );
+ for (PackageDescriptionStanza pds:pdss){
+ if (pds.getType()!=null && (pds.getType().equals( CabalSyntax.SECTION_LIBRARY ) || pds.getType().equals( CabalSyntax.SECTION_EXECUTABLE ) || pds.getType().equals( CabalSyntax.SECTION_TESTSUITE ))){
+ pds=pd.getSameStanza( pds );
+ RealValuePosition vp=null;
+ if(sIncluded.contains( pds.toTypeName() )){
+ vp=pds.addToPropertyList( CabalSyntax.FIELD_OTHER_MODULES, moduleName );
+ } else {
+ vp=pds.removeFromPropertyList( CabalSyntax.FIELD_OTHER_MODULES, moduleName );
+ }
+ if (vp!=null){
+ vp.updateDocument( doc );
+ pd=PackageDescriptionLoader.load( doc.get() );
+ pds=pd.getSameStanza( pds );
+ }
+ if (sExposed.contains( pds.toTypeName() )){
+ vp=pds.addToPropertyList( CabalSyntax.FIELD_EXPOSED_MODULES, moduleName );
+ } else {
+ vp=pds.removeFromPropertyList( CabalSyntax.FIELD_EXPOSED_MODULES, moduleName );
+ }
+ if (vp!=null){
+ vp.updateDocument( doc );
+ pd=PackageDescriptionLoader.load( doc.get() );
+ }
+ }
+ }
+ }
+ prov.saveDocument( monitor, f, doc, true );
+ } finally {
+ prov.disconnect( f );
+ }
+ if (generatedFile!=null){
+ String esz=info.getEditorStanza()!=null?
+ info.getEditorStanza().getName()!=null?
+ info.getEditorStanza().getName()
+ :""
+ :null;
+ generatedFile.setPersistentProperty( BuildWrapperPlugin.EDITORSTANZA_PROPERTY, esz );
+ }
+ // let the listener do its work
+ // ScionPlugin.getScionInstance( generatedFile ).buildProjectForWorkspace( monitor, false , false);
+ } catch( CoreException ex ) {
+ throw new InvocationTargetException( ex );
+ }
+ }
}
View
100 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/wizards/ModuleInclusionPage.java
@@ -1,50 +1,50 @@
-package net.sf.eclipsefp.haskell.ui.wizards;
-
-import net.sf.eclipsefp.haskell.core.code.ModuleCreationInfo;
-import net.sf.eclipsefp.haskell.ui.internal.util.UITexts;
-import net.sf.eclipsefp.haskell.ui.properties.ModuleInclusionComposite;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * <p>Give options to expose and include modules in Cabal sections</p>
- *
- * @author JP Moresmau
- */
-public class ModuleInclusionPage extends StatusWizardPage{
- ModuleInclusionComposite mic;
-
- public ModuleInclusionPage() {
- super( "ModuleInclusionPage" ); //$NON-NLS-1$
- setTitle( UITexts.module_inclusion_page_title );
- setDescription( UITexts.module_inclusion_page_description );
- }
-
- @Override
- public void createControl( final Composite parent ) {
- initializeDialogUnits( parent );
-
- mic=new ModuleInclusionComposite( parent, SWT.NONE );
- setControl( mic );
-
- Dialog.applyDialogFont( mic );
- }
-
-
- public ModuleInclusionComposite getModuleInclusionComposite() {
- return mic;
- }
-
- @Override
- public void setPreviousPage( final IWizardPage page ) {
- super.setPreviousPage( page );
- ModuleCreationInfo mci=((IModuleCreationInfoProvider)page).getInfo();
- IContainer src=mci.getSourceContainer();
- String module=mci.getQualifiedModuleName();
- mic.init( src, module, true );
-
- }
-}
+package net.sf.eclipsefp.haskell.ui.wizards;
+
+import net.sf.eclipsefp.haskell.core.code.ModuleCreationInfo;
+import net.sf.eclipsefp.haskell.ui.internal.util.UITexts;
+import net.sf.eclipsefp.haskell.ui.properties.ModuleInclusionComposite;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * <p>Give options to expose and include modules in Cabal sections</p>
+ *
+ * @author JP Moresmau
+ */
+public class ModuleInclusionPage extends StatusWizardPage{
+ ModuleInclusionComposite mic;
+
+ public ModuleInclusionPage() {
+ super( "ModuleInclusionPage" ); //$NON-NLS-1$
+ setTitle( UITexts.module_inclusion_page_title );
+ setDescription( UITexts.module_inclusion_page_description );
+ }
+
+ @Override
+ public void createControl( final Composite parent ) {
+ initializeDialogUnits( parent );
+
+ mic=new ModuleInclusionComposite( parent, SWT.NONE );
+ setControl( mic );
+
+ Dialog.applyDialogFont( mic );
+ }
+
+
+ public ModuleInclusionComposite getModuleInclusionComposite() {
+ return mic;
+ }
+
+ @Override
+ public void setPreviousPage( final IWizardPage page ) {
+ super.setPreviousPage( page );
+ ModuleCreationInfo mci=((IModuleCreationInfoProvider)page).getInfo();
+ IContainer src=mci.getSourceContainer();
+ String module=mci.getQualifiedModuleName();
+ mic.init(null, src, module, true );
+
+ }
+}
View
209 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/wizards/NewAlexWizard.java
@@ -1,105 +1,104 @@
-/**
- * (c) 2011, Alejandro Serrano
- * Released under the terms of the EPL.
- */
-package net.sf.eclipsefp.haskell.ui.wizards;
-
-import java.io.IOException;
-import java.io.InputStream;
-import net.sf.eclipsefp.haskell.core.code.ModuleCreationInfo;
-import net.sf.eclipsefp.haskell.ui.HaskellUIPlugin;
-import net.sf.eclipsefp.haskell.ui.internal.util.UITexts;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.INewWizard;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
-
-/**
- * Wizard for creating new Alex files.
- * @author Alejandro Serrano
- *
- */
-public class NewAlexWizard extends RevealAtEndWizard implements INewWizard {
-
- public static final String ID = NewAlexWizard.class.getName();
- static final String FILE_NAME = "/newFiles/alex.x";
-
- private IStructuredSelection selection;
- private NewPartitionedWizardPage page0;
- private ModuleInclusionPage page1;
-
- public NewAlexWizard() {
- super();
- setNeedsProgressMonitor( true );
- setWindowTitle( UITexts.new_alex );
- setDialogSettings( HaskellUIPlugin.getDefault().getDialogSettings() );
- }
-
- @Override
- public void init( final IWorkbench workbench, final IStructuredSelection selection ) {
- this.selection = selection;
- }
-
- @Override
- public void addPages() {
- super.addPages();
- page0 = new NewPartitionedWizardPage( "NewAlexPage", UITexts.new_alex, UITexts.alex_newFile );
- addPage( page0 );
- page0.init( selection );
- page1 = new ModuleInclusionPage();
- addPage( page1 );
- }
-
- @Override
- public boolean performFinish() {
- ModuleCreationInfo mci = page0.getInfo();
- // the user hasn't clicked on next
- if( !page1.getModuleInclusionComposite().isInit() ) {
- page1.setPreviousPage( page0 );
- }
- mci.setExposed( page1.getModuleInclusionComposite().getExposed() );
- mci.setIncluded( page1.getModuleInclusionComposite().getIncluded() );
- TemplateFileCreationOperation mco = new TemplateFileCreationOperation( mci, getInitialContents(), "x" );
-
- IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation( mco );
- boolean result = false;
- try {
- getContainer().run( false, true, op );
- result = true;
- finish( mco.getGeneratedFile() );
- } catch( Exception ex ) {
- handleFinishException( ex );
- HaskellUIPlugin.log( "Error creating new module.", ex );
- }
- return result;
- }
-
- // helping methods
- // ////////////////
-
- private void handleFinishException( final Exception ex ) {
- String msg = "The following error occured: " + ex.getLocalizedMessage()
- + "Please see workspace/.metadata/.log for more information.";
- MessageDialog.openError( getShell(), "Problem occured", msg );
- }
-
- private void finish( final IFile createdFile ) {
- if( createdFile != null ) {
- selectAndReveal( createdFile );
- openResource( createdFile );
- }
- }
-
- protected InputStream getInitialContents() {
- try {
- return HaskellUIPlugin.getDefault().getBundle().getEntry(FILE_NAME).openStream();
- } catch( IOException ex ) {
- // This should never happen
- return null;
- }
- }
-
-}
+/**
+ * (c) 2011, Alejandro Serrano
+ * Released under the terms of the EPL.
+ */
+package net.sf.eclipsefp.haskell.ui.wizards;
+
+import java.io.IOException;
+import java.io.InputStream;
+import net.sf.eclipsefp.haskell.core.code.ModuleCreationInfo;
+import net.sf.eclipsefp.haskell.ui.HaskellUIPlugin;
+import net.sf.eclipsefp.haskell.ui.internal.util.UITexts;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
+
+/**
+ * Wizard for creating new Alex files.
+ * @author Alejandro Serrano
+ *
+ */
+public class NewAlexWizard extends RevealAtEndWizard implements INewWizard {
+
+ public static final String ID = NewAlexWizard.class.getName();
+ static final String FILE_NAME = "/newFiles/alex.x";
+
+ private IStructuredSelection selection;
+ private NewPartitionedWizardPage page0;
+ private ModuleInclusionPage page1;
+
+ public NewAlexWizard() {
+ super();
+ setNeedsProgressMonitor( true );
+ setWindowTitle( UITexts.new_alex );
+ setDialogSettings( HaskellUIPlugin.getDefault().getDialogSettings() );
+ }
+
+ @Override
+ public void init( final IWorkbench workbench, final IStructuredSelection selection ) {
+ this.selection = selection;
+ }
+
+ @Override
+ public void addPages() {
+ super.addPages();
+ page0 = new NewPartitionedWizardPage( "NewAlexPage", UITexts.new_alex, UITexts.alex_newFile );
+ addPage( page0 );
+ page0.init( selection );
+ page1 = new ModuleInclusionPage();
+ addPage( page1 );
+ }
+
+ @Override
+ public boolean performFinish() {
+ ModuleCreationInfo mci = page0.getInfo();
+ // the user hasn't clicked on next
+ if( !page1.getModuleInclusionComposite().isInit() ) {
+ page1.setPreviousPage( page0 );
+ }
+ page1.getModuleInclusionComposite().populateInfo( mci );
+ TemplateFileCreationOperation mco = new TemplateFileCreationOperation( mci, getInitialContents(), "x" );
+
+ IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation( mco );
+ boolean result = false;
+ try {
+ getContainer().run( false, true, op );
+ result = true;
+ finish( mco.getGeneratedFile() );
+ } catch( Exception ex ) {
+ handleFinishException( ex );
+ HaskellUIPlugin.log( "Error creating new module.", ex );
+ }
+ return result;
+ }
+
+ // helping methods
+ // ////////////////
+
+ private void handleFinishException( final Exception ex ) {
+ String msg = "The following error occured: " + ex.getLocalizedMessage()
+ + "Please see workspace/.metadata/.log for more information.";
+ MessageDialog.openError( getShell(), "Problem occured", msg );
+ }
+
+ private void finish( final IFile createdFile ) {
+ if( createdFile != null ) {
+ selectAndReveal( createdFile );
+ openResource( createdFile );
+ }
+ }
+
+ protected InputStream getInitialContents() {
+ try {
+ return HaskellUIPlugin.getDefault().getBundle().getEntry(FILE_NAME).openStream();
+ } catch( IOException ex ) {
+ // This should never happen
+ return null;
+ }
+ }
+
+}
View
209 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/wizards/NewHappyWizard.java
@@ -1,105 +1,104 @@
-/**
- * (c) 2011, Alejandro Serrano
- * Released under the terms of the EPL.
- */
-package net.sf.eclipsefp.haskell.ui.wizards;
-
-import java.io.IOException;
-import java.io.InputStream;
-import net.sf.eclipsefp.haskell.core.code.ModuleCreationInfo;
-import net.sf.eclipsefp.haskell.ui.HaskellUIPlugin;
-import net.sf.eclipsefp.haskell.ui.internal.util.UITexts;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.INewWizard;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
-
-/**
- * Wizard for creating new Happy files.
- * @author Alejandro Serrano
- *
- */
-public class NewHappyWizard extends RevealAtEndWizard implements INewWizard {
-
- public static final String ID = NewHappyWizard.class.getName();
- static final String FILE_NAME = "/newFiles/happy.y";
-
- private IStructuredSelection selection;
- private NewPartitionedWizardPage page0;
- private ModuleInclusionPage page1;
-
- public NewHappyWizard() {
- super();
- setNeedsProgressMonitor( true );
- setWindowTitle( UITexts.new_happy );
- setDialogSettings( HaskellUIPlugin.getDefault().getDialogSettings() );
- }
-
- @Override
- public void init( final IWorkbench workbench, final IStructuredSelection selection ) {
- this.selection = selection;
- }
-
- @Override
- public void addPages() {
- super.addPages();
- page0 = new NewPartitionedWizardPage( "NewHappyPage", UITexts.new_happy, UITexts.happy_newFile );
- addPage( page0 );
- page0.init( selection );
- page1 = new ModuleInclusionPage();
- addPage( page1 );
- }
-
- @Override
- public boolean performFinish() {
- ModuleCreationInfo mci = page0.getInfo();
- // the user hasn't clicked on next
- if( !page1.getModuleInclusionComposite().isInit() ) {
- page1.setPreviousPage( page0 );
- }
- mci.setExposed( page1.getModuleInclusionComposite().getExposed() );
- mci.setIncluded( page1.getModuleInclusionComposite().getIncluded() );
- TemplateFileCreationOperation mco = new TemplateFileCreationOperation( mci, getInitialContents(), "y" );
-
- IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation( mco );
- boolean result = false;
- try {
- getContainer().run( false, true, op );
- result = true;
- finish( mco.getGeneratedFile() );
- } catch( Exception ex ) {
- handleFinishException( ex );
- HaskellUIPlugin.log( "Error creating new module.", ex );
- }
- return result;
- }
-
- // helping methods
- // ////////////////
-
- private void handleFinishException( final Exception ex ) {
- String msg = "The following error occured: " + ex.getLocalizedMessage()
- + "Please see workspace/.metadata/.log for more information.";
- MessageDialog.openError( getShell(), "Problem occured", msg );
- }
-
- private void finish( final IFile createdFile ) {
- if( createdFile != null ) {
- selectAndReveal( createdFile );
- openResource( createdFile );
- }
- }
-
- protected InputStream getInitialContents() {
- try {
- return HaskellUIPlugin.getDefault().getBundle().getEntry(FILE_NAME).openStream();
- } catch( IOException ex ) {
- // This should never happen
- return null;
- }
- }
-
-}
+/**
+ * (c) 2011, Alejandro Serrano
+ * Released under the terms of the EPL.
+ */
+package net.sf.eclipsefp.haskell.ui.wizards;
+
+import java.io.IOException;
+import java.io.InputStream;
+import net.sf.eclipsefp.haskell.core.code.ModuleCreationInfo;
+import net.sf.eclipsefp.haskell.ui.HaskellUIPlugin;
+import net.sf.eclipsefp.haskell.ui.internal.util.UITexts;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
+
+/**
+ * Wizard for creating new Happy files.
+ * @author Alejandro Serrano
+ *
+ */
+public class NewHappyWizard extends RevealAtEndWizard implements INewWizard {
+
+ public static final String ID = NewHappyWizard.class.getName();
+ static final String FILE_NAME = "/newFiles/happy.y";
+
+ private IStructuredSelection selection;
+ private NewPartitionedWizardPage page0;
+ private ModuleInclusionPage page1;
+
+ public NewHappyWizard() {
+ super();
+ setNeedsProgressMonitor( true );
+ setWindowTitle( UITexts.new_happy );
+ setDialogSettings( HaskellUIPlugin.getDefault().getDialogSettings() );
+ }
+
+ @Override
+ public void init( final IWorkbench workbench, final IStructuredSelection selection ) {
+ this.selection = selection;
+ }
+
+ @Override
+ public void addPages() {
+ super.addPages();
+ page0 = new NewPartitionedWizardPage( "NewHappyPage", UITexts.new_happy, UITexts.happy_newFile );
+ addPage( page0 );
+ page0.init( selection );
+ page1 = new ModuleInclusionPage();
+ addPage( page1 );
+ }
+
+ @Override
+ public boolean performFinish() {
+ ModuleCreationInfo mci = page0.getInfo();
+ // the user hasn't clicked on next
+ if( !page1.getModuleInclusionComposite().isInit() ) {
+ page1.setPreviousPage( page0 );
+ }
+ page1.getModuleInclusionComposite().populateInfo( mci );
+ TemplateFileCreationOperation mco = new TemplateFileCreationOperation( mci, getInitialContents(), "y" );
+
+ IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation( mco );
+ boolean result = false;
+ try {
+ getContainer().run( false, true, op );
+ result = true;
+ finish( mco.getGeneratedFile() );
+ } catch( Exception ex ) {
+ handleFinishException( ex );
+ HaskellUIPlugin.log( "Error creating new module.", ex );
+ }
+ return result;
+ }
+
+ // helping methods
+ // ////////////////
+
+ private void handleFinishException( final Exception ex ) {
+ String msg = "The following error occured: " + ex.getLocalizedMessage()
+ + "Please see workspace/.metadata/.log for more information.";
+ MessageDialog.openError( getShell(), "Problem occured", msg );
+ }
+
+ private void finish( final IFile createdFile ) {
+ if( createdFile != null ) {
+ selectAndReveal( createdFile );
+ openResource( createdFile );
+ }
+ }
+
+ protected InputStream getInitialContents() {
+ try {
+ return HaskellUIPlugin.getDefault().getBundle().getEntry(FILE_NAME).openStream();
+ } catch( IOException ex ) {
+ // This should never happen
+ return null;
+ }
+ }
+
+}
View
207 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/wizards/NewModuleWizard.java
@@ -1,105 +1,104 @@
-// Copyright (c) 2003-2005 by Leif Frenzel - see http://leiffrenzel.de
-package net.sf.eclipsefp.haskell.ui.wizards;
-
-import net.sf.eclipsefp.haskell.core.code.ModuleCreationInfo;
-import net.sf.eclipsefp.haskell.ui.HaskellUIPlugin;
-import net.sf.eclipsefp.haskell.ui.internal.util.UITexts;
-import net.sf.eclipsefp.haskell.ui.util.HaskellUIImages;
-import net.sf.eclipsefp.haskell.ui.util.IImageNames;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.ui.INewWizard;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
-
-
-/**
- * <p>
- * The wizard for creating a new Haskell module.
- * </p>
- *
- * @author Leif Frenzel
- */
-public class NewModuleWizard extends RevealAtEndWizard implements INewWizard {
-
- public static final String ID = NewModuleWizard.class.getName();
-
- private IStructuredSelection selection;
- private NewModuleWizardPage page0;
- private ModuleInclusionPage page1;
-
- public NewModuleWizard() {
- super();
- setNeedsProgressMonitor( true );
- setWindowTitle( UITexts.NewModuleWizard_0 );
- initBannerImage();
- setDialogSettings( HaskellUIPlugin.getDefault().getDialogSettings() );
- }
-
- @Override
- public void init( final IWorkbench workbench,
- final IStructuredSelection selection ) {
- this.selection = selection;
- }
-
- @Override
- public void addPages() {
- super.addPages();
- page0 = new NewModuleWizardPage();
- addPage( page0 );
- page0.init( selection );
- page1 = new ModuleInclusionPage();
- addPage( page1 );
-
- }
-
- @Override
- public boolean performFinish() {
- ModuleCreationInfo mci = page0.getInfo();
- // the user hasn't clicked on next
- if( !page1.getModuleInclusionComposite().isInit() ) {
- page1.setPreviousPage( page0 );
- }
- mci.setExposed( page1.getModuleInclusionComposite().getExposed() );
- mci.setIncluded( page1.getModuleInclusionComposite().getIncluded() );
- ModuleCreationOperation mco = new ModuleCreationOperation( mci );
-
- IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation( mco );
- boolean result = false;
- try {
- getContainer().run( false, true, op );
- result = true;
- finish( mco.getGeneratedFile() );
- } catch( Exception ex ) {
- handleFinishException( ex );
- HaskellUIPlugin.log( UITexts.NewModuleWizard_1, ex );
- }
- return result;
- }
-
-
- // helping methods
- // ////////////////
-
- private void handleFinishException( final Exception ex ) {
- String msg = NLS.bind( UITexts.NewModuleWizard_2 , ex.getLocalizedMessage());
- MessageDialog.openError( getShell(), UITexts.NewModuleWizard_4, msg );
- }
-
- private void finish( final IFile createdFile ) {
- if( createdFile != null ) {
- selectAndReveal( createdFile );
- openResource( createdFile );
- }
- }
-
- private void initBannerImage() {
- String key = IImageNames.NEW_MODULE;
- ImageDescriptor imageDescriptor = HaskellUIImages.getImageDescriptor( key );
- setDefaultPageImageDescriptor( imageDescriptor );
- }
+// Copyright (c) 2003-2005 by Leif Frenzel - see http://leiffrenzel.de
+package net.sf.eclipsefp.haskell.ui.wizards;
+
+import net.sf.eclipsefp.haskell.core.code.ModuleCreationInfo;
+import net.sf.eclipsefp.haskell.ui.HaskellUIPlugin;
+import net.sf.eclipsefp.haskell.ui.internal.util.UITexts;
+import net.sf.eclipsefp.haskell.ui.util.HaskellUIImages;
+import net.sf.eclipsefp.haskell.ui.util.IImageNames;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
+
+
+/**
+ * <p>
+ * The wizard for creating a new Haskell module.
+ * </p>
+ *
+ * @author Leif Frenzel
+ */
+public class NewModuleWizard extends RevealAtEndWizard implements INewWizard {
+
+ public static final String ID = NewModuleWizard.class.getName();
+
+ private IStructuredSelection selection;
+ private NewModuleWizardPage page0;
+ private ModuleInclusionPage page1;
+
+ public NewModuleWizard() {
+ super();
+ setNeedsProgressMonitor( true );
+ setWindowTitle( UITexts.NewModuleWizard_0 );
+ initBannerImage();
+ setDialogSettings( HaskellUIPlugin.getDefault().getDialogSettings() );
+ }
+
+ @Override
+ public void init( final IWorkbench workbench,
+ final IStructuredSelection selection ) {
+ this.selection = selection;
+ }
+
+ @Override
+ public void addPages() {
+ super.addPages();
+ page0 = new NewModuleWizardPage();
+ addPage( page0 );
+ page0.init( selection );
+ page1 = new ModuleInclusionPage();
+ addPage( page1 );
+
+ }
+
+ @Override
+ public boolean performFinish() {
+ ModuleCreationInfo mci = page0.getInfo();
+ // the user hasn't clicked on next
+ if( !page1.getModuleInclusionComposite().isInit() ) {
+ page1.setPreviousPage( page0 );
+ }
+ page1.getModuleInclusionComposite().populateInfo( mci );
+ ModuleCreationOperation mco = new ModuleCreationOperation( mci );
+
+ IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation( mco );
+ boolean result = false;
+ try {
+ getContainer().run( false, true, op );
+ result = true;
+ finish( mco.getGeneratedFile() );
+ } catch( Exception ex ) {
+ handleFinishException( ex );
+ HaskellUIPlugin.log( UITexts.NewModuleWizard_1, ex );
+ }
+ return result;
+ }
+
+
+ // helping methods
+ // ////////////////
+
+ private void handleFinishException( final Exception ex ) {
+ String msg = NLS.bind( UITexts.NewModuleWizard_2 , ex.getLocalizedMessage());
+ MessageDialog.openError( getShell(), UITexts.NewModuleWizard_4, msg );
+ }
+
+ private void finish( final IFile createdFile ) {
+ if( createdFile != null ) {
+ selectAndReveal( createdFile );
+ openResource( createdFile );
+ }
+ }
+
+ private void initBannerImage() {
+ String key = IImageNames.NEW_MODULE;
+ ImageDescriptor imageDescriptor = HaskellUIImages.getImageDescriptor( key );
+ setDefaultPageImageDescriptor( imageDescriptor );
+ }
}
View
223 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/wizards/NewUuagcWizard.java
@@ -1,112 +1,111 @@
-/**
- * (c) 2011, Alejandro Serrano
- * Released under the terms of the EPL.
- */
-package net.sf.eclipsefp.haskell.ui.wizards;
-
-import java.io.IOException;
-import java.io.InputStream;
-import net.sf.eclipsefp.haskell.core.code.ModuleCreationInfo;
-import net.sf.eclipsefp.haskell.ui.HaskellUIPlugin;
-import net.sf.eclipsefp.haskell.ui.internal.util.UITexts;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.INewWizard;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
-
-/**
- * Wizard for creating a new UUAGC file.
- * @author Alejandro Serrano
- *
- */
-public class NewUuagcWizard extends RevealAtEndWizard implements INewWizard {
-
- public static final String ID = NewUuagcWizard.class.getName();
- static final String FILE_NAME = "/newFiles/uuagc.ag";
- static final String FILE_NAME_HASKELL = "/newFiles/uuagc-haskell.ag";
-
- private IStructuredSelection selection;
- private NewUuagcWizardPage page0;
- private ModuleInclusionPage page1;
-
- public NewUuagcWizard() {
- super();
- setNeedsProgressMonitor( true );
- setWindowTitle( UITexts.new_uuagc );
- setDialogSettings( HaskellUIPlugin.getDefault().getDialogSettings() );
- }
-
- @Override
- public void init( final IWorkbench workbench,
- final IStructuredSelection selection ) {
- this.selection = selection;
- }
-
- @Override
- public void addPages() {
- super.addPages();
- page0 = new NewUuagcWizardPage( "NewUuagcPage", UITexts.new_uuagc,
- UITexts.uuagc_newFile );
- addPage( page0 );
- page0.init( selection );
- page1 = new ModuleInclusionPage();
- addPage( page1 );
- }
-
- @Override
- public boolean performFinish() {
- ModuleCreationInfo mci = page0.getInfo();
- // the user hasn't clicked on next
- if( !page1.getModuleInclusionComposite().isInit() ) {
- page1.setPreviousPage( page0 );
- }
- mci.setExposed( page1.getModuleInclusionComposite().getExposed() );
- mci.setIncluded( page1.getModuleInclusionComposite().getIncluded() );
- UuagcFileCreationOperator mco = new UuagcFileCreationOperator( mci,
- getInitialContents( page0.getUseHaskellSyntax() ), "ag",
- page0.getUseHaskellSyntax() );
-
- IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation( mco );
- boolean result = false;
- try {
- getContainer().run( false, true, op );
- result = true;
- finish( mco.getGeneratedFile() );
- } catch( Exception ex ) {
- handleFinishException( ex );
- HaskellUIPlugin.log( "Error creating new module.", ex );
- }
- return result;
- }
-
- // helping methods
- // ////////////////
-
- private void handleFinishException( final Exception ex ) {
- String msg = "The following error occured: " + ex.getLocalizedMessage()
- + "Please see workspace/.metadata/.log for more information.";
- MessageDialog.openError( getShell(), "Problem occured", msg );
- }
-
- private void finish( final IFile createdFile ) {
- if( createdFile != null ) {
- selectAndReveal( createdFile );
- openResource( createdFile );
- }
- }
-
- protected InputStream getInitialContents( final boolean useHaskellSyntax ) {
- try {
- return HaskellUIPlugin.getDefault().getBundle()
- .getEntry( useHaskellSyntax ? FILE_NAME_HASKELL : FILE_NAME )
- .openStream();
- } catch( IOException ex ) {
- // This should never happen
- return null;
- }
- }
-
-}
+/**
+ * (c) 2011, Alejandro Serrano
+ * Released under the terms of the EPL.
+ */
+package net.sf.eclipsefp.haskell.ui.wizards;
+
+import java.io.IOException;
+import java.io.InputStream;
+import net.sf.eclipsefp.haskell.core.code.ModuleCreationInfo;
+import net.sf.eclipsefp.haskell.ui.HaskellUIPlugin;
+import net.sf.eclipsefp.haskell.ui.internal.util.UITexts;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
+
+/**
+ * Wizard for creating a new UUAGC file.
+ * @author Alejandro Serrano
+ *
+ */
+public class NewUuagcWizard extends RevealAtEndWizard implements INewWizard {
+
+ public static final String ID = NewUuagcWizard.class.getName();
+ static final String FILE_NAME = "/newFiles/uuagc.ag";
+ static final String FILE_NAME_HASKELL = "/newFiles/uuagc-haskell.ag";
+
+ private IStructuredSelection selection;
+ private NewUuagcWizardPage page0;
+ private ModuleInclusionPage page1;
+
+ public NewUuagcWizard() {
+ super();
+ setNeedsProgressMonitor( true );
+ setWindowTitle( UITexts.new_uuagc );
+ setDialogSettings( HaskellUIPlugin.getDefault().getDialogSettings() );
+ }
+
+ @Override
+ public void init( final IWorkbench workbench,
+ final IStructuredSelection selection ) {
+ this.selection = selection;
+ }
+
+ @Override
+ public void addPages() {
+ super.addPages();
+ page0 = new NewUuagcWizardPage( "NewUuagcPage", UITexts.new_uuagc,
+ UITexts.uuagc_newFile );
+ addPage( page0 );
+ page0.init( selection );
+ page1 = new ModuleInclusionPage();
+ addPage( page1 );
+ }
+
+ @Override
+ public boolean performFinish() {
+ ModuleCreationInfo mci = page0.getInfo();
+ // the user hasn't clicked on next
+ if( !page1.getModuleInclusionComposite().isInit() ) {
+ page1.setPreviousPage( page0 );
+ }
+ page1.getModuleInclusionComposite().populateInfo( mci );
+ UuagcFileCreationOperator mco = new UuagcFileCreationOperator( mci,
+ getInitialContents( page0.getUseHaskellSyntax() ), "ag",
+ page0.getUseHaskellSyntax() );
+
+ IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation( mco );
+ boolean result = false;
+ try {
+ getContainer().run( false, true, op );
+ result = true;
+ finish( mco.getGeneratedFile() );
+ } catch( Exception ex ) {
+ handleFinishException( ex );
+ HaskellUIPlugin.log( "Error creating new module.", ex );
+ }
+ return result;
+ }
+
+ // helping methods
+ // ////////////////
+
+ private void handleFinishException( final Exception ex ) {
+ String msg = "The following error occured: " + ex.getLocalizedMessage()
+ + "Please see workspace/.metadata/.log for more information.";
+ MessageDialog.openError( getShell(), "Problem occured", msg );
+ }
+
+ private void finish( final IFile createdFile ) {
+ if( createdFile != null ) {
+ selectAndReveal( createdFile );
+ openResource( createdFile );
+ }
+ }
+
+ protected InputStream getInitialContents( final boolean useHaskellSyntax ) {
+ try {
+ return HaskellUIPlugin.getDefault().getBundle()
+ .getEntry( useHaskellSyntax ? FILE_NAME_HASKELL : FILE_NAME )
+ .openStream();
+ } catch( IOException ex ) {
+ // This should never happen
+ return null;
+ }
+ }
+
+}

0 comments on commit 94f0422

Please sign in to comment.