Permalink
Browse files

Added possibility to create project from existing source.

Just like in JDT, there's now a field in the New Project wizard where
a directory for the new project can be set. If this directory exists,
its contents are imported into the new project.

In fact, the new project is just created in the specified location
without regard for what's already there. More advanced importing
(e.g. detection of Cabal file, detection of source directories)
remains to be done.

The UI additions required some changes to the creation wizards,
leading to an overhaul of the Cabal import wizard as well.

In particular, there is now a common structure for wizard validators.
This is not as clean as I would like it to be, yet.
  • Loading branch information...
1 parent 10cbf9d commit fd48f56dfb1ea08ac2fe69f73c356e0209f72ad7 @ttencate committed Jul 25, 2009
Showing with 1,490 additions and 353 deletions.
  1. +1 −0 net.sf.eclipsefp.haskell.ui/META-INF/MANIFEST.MF
  2. +93 −0 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/dialog/Validator.java
  3. +48 −0 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/dialog/ValidatorManager.java
  4. +216 −173 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/dialog/dialogfields/DialogField.java
  5. +132 −0 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/dialog/dialogfields/LayoutUtil.java
  6. +214 −0 ...fp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/dialog/dialogfields/SelectionButtonDialogField.java
  7. +21 −0 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/util/UITexts.java
  8. +23 −2 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/util/uitexts.properties
  9. +125 −52 ...f.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/wizards/CabalPackageImportWP.java
  10. +6 −1 ...lipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/wizards/CabalPackageImportWizard.java
  11. +0 −117 ...psefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/wizards/CabalPackageSelectionBlock.java
  12. +598 −0 ...f.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/wizards/NewProjectWizardPage.java
  13. +7 −8 ....eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/wizards/ProjectCreationWizard.java
  14. +6 −0 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/wizards/NewHaskellProjectWizard.java
@@ -48,3 +48,4 @@ Export-Package: net.sf.eclipsefp.common.ui.dialog,
net.sf.eclipsefp.haskell.ui.util.text,
net.sf.eclipsefp.haskell.ui.wizards;x-friends:="net.sf.eclipsefp.haskell.ui.test"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Import-Package: org.eclipse.core.filesystem
@@ -0,0 +1,93 @@
+package net.sf.eclipsefp.haskell.ui.dialog;
+
+import java.util.Observable;
+import java.util.Observer;
+
+public abstract class Validator implements Observer {
+
+ private ValidatorManager fManager;
+
+ private String fMessage;
+ private String fErrorMessage;
+ private boolean fPageComplete;
+
+ public Validator() {
+ fManager = null;
+ }
+
+ public Validator( final ValidatorManager manager ) {
+ setManager( manager );
+ }
+
+ public void setManager( final ValidatorManager manager ) {
+ if( fManager == null ) {
+ fManager = manager;
+ manager.addValidator( this );
+ }
+ }
+
+ public String getMessage() {
+ return fMessage;
+ }
+
+ public void setMessage( final String message ) {
+ fMessage = message;
+ }
+
+ public String getErrorMessage() {
+ return fErrorMessage;
+ }
+
+ public void setErrorMessage( final String errorMessage ) {
+ fErrorMessage = errorMessage;
+ }
+
+ public boolean isPageComplete() {
+ return fPageComplete;
+ }
+
+ public void setPageComplete( final boolean pageComplete ) {
+ fPageComplete = pageComplete;
+ }
+
+ public void setComplete() {
+ setMessage( null );
+ setErrorMessage( null );
+ setPageComplete( true );
+ }
+
+ public void setIncomplete( final String message, final boolean error ) {
+ if( error ) {
+ setMessage( null );
+ setErrorMessage( message );
+ } else {
+ setMessage( message );
+ setErrorMessage( null );
+ }
+ setPageComplete( false );
+ }
+
+ /**
+ * The only method that subclasses are required to implement.
+ * On entry, message and errorMessage are null, and pageComplete is true.
+ * Do validation and set state accordingly.
+ */
+ protected abstract void doUpdate();
+
+ /**
+ * Do not override. Rather, override {@link #doUpdate}.
+ */
+ public void update() {
+ setComplete();
+ doUpdate();
+ fManager.updatePage();
+ }
+
+ // //////////////////////////
+ // methods from Observable
+
+ public void update( final Observable o, final Object arg ) {
+ update();
+ }
+
+}
@@ -0,0 +1,48 @@
+package net.sf.eclipsefp.haskell.ui.dialog;
+
+import java.util.ArrayList;
+import org.eclipse.jface.wizard.WizardPage;
+
+public final class ValidatorManager {
+
+ private final WizardPage fWizardPage;
+
+ private final ArrayList<Validator> validators = new ArrayList<Validator>();
+
+ public ValidatorManager(final WizardPage wizardPage) {
+ fWizardPage = wizardPage;
+ }
+
+ public void addValidator(final Validator validator) {
+ validators.add( validator );
+ }
+
+ public void updatePage() {
+ String message = null;
+ String errorMessage = null;
+ boolean pageComplete = true;
+ for (Validator validator : validators) {
+ if (message == null && validator.getMessage() != null) {
+ message = validator.getMessage();
+ }
+ if (errorMessage == null && validator.getErrorMessage() != null) {
+ errorMessage = validator.getErrorMessage();
+ }
+ if (pageComplete && !validator.isPageComplete()) {
+ pageComplete = false;
+ }
+ }
+ fWizardPage.setMessage( message );
+ fWizardPage.setErrorMessage( errorMessage );
+ fWizardPage.setPageComplete( pageComplete );
+ }
+
+ public void fullUpdate() {
+ for (Validator validator : validators) {
+ validator.update();
+ }
+ updatePage();
+ }
+
+}
+
Oops, something went wrong.

0 comments on commit fd48f56

Please sign in to comment.