Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 6 commits
  • 16 files changed
  • 0 commit comments
  • 1 contributor
Showing with 558 additions and 378 deletions.
  1. +2 −1  docs/releasenotes/net.sf.eclipsefp.haskell_2.3.2.txt
  2. +2 −1  net.sf.eclipsefp.haskell.buildwrapper/src/net/sf/eclipsefp/haskell/buildwrapper/BuildWrapperPlugin.java
  3. +55 −54 net.sf.eclipsefp.haskell.buildwrapper/src/net/sf/eclipsefp/haskell/buildwrapper/util/BWText.java
  4. +37 −36 net.sf.eclipsefp.haskell.buildwrapper/src/net/sf/eclipsefp/haskell/buildwrapper/util/bwtext.properties
  5. BIN  net.sf.eclipsefp.haskell.ui/icons/eview16/cabal.png
  6. +1 −0  net.sf.eclipsefp.haskell.ui/plugin.properties
  7. +20 −2 net.sf.eclipsefp.haskell.ui/plugin.xml
  8. +107 −43 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/actions/CabalInstallAction.java
  9. +82 −0 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/actions/CabalInstallDependenciesAction.java
  10. +1 −0  ...ipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/preferences/scion/AutodetectExecutableField.java
  11. +7 −7 ...ipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/preferences/scion/ExecutableFileFieldEditor.java
  12. +1 −0  net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/util/UITexts.java
  13. +1 −0  net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/util/uitexts.properties
  14. +213 −211 ...p.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/views/projectexplorer/HaskellResourceExtensionCP.java
  15. +1 −0  net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/sourcegraph/RunActionDelegate.java
  16. +28 −23 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/views/CabalPackagesView.java
3  docs/releasenotes/net.sf.eclipsefp.haskell_2.3.2.txt
View
@@ -20,9 +20,10 @@ Features:
- Specify the cabal stanza you want to use settings from when checking a file in the editor
- In preferences for executables, you can install the executable from Haskage
- Install all helper executables from one dialog
+ - Install all dependencies for one project from right click on project (performs a clean of the project afterwards).
Internal:
-
+ - Hopefully performance of some UI operations has been enhanced and the UI should be more responsive in places
Upgrade notes:
3  net.sf.eclipsefp.haskell.buildwrapper/src/net/sf/eclipsefp/haskell/buildwrapper/BuildWrapperPlugin.java
View
@@ -130,7 +130,8 @@ public static BWFacade createFacade(IProject p,String cabalPath,Writer outStream
f.setProject(p);
f.setOutStream(outStream);
facades.put(p, f);
- new JobFacade(f).synchronize(false);
+ // why? build will do that for us
+ //new JobFacade(f).synchronize(false);
return f;
}
return null;
109 net.sf.eclipsefp.haskell.buildwrapper/src/net/sf/eclipsefp/haskell/buildwrapper/util/BWText.java
View
@@ -1,54 +1,55 @@
-package net.sf.eclipsefp.haskell.buildwrapper.util;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * Provides access to the internationalized UI texts.
- *
- * @author JP Moresmau
- */
-public class BWText extends NLS {
- public static String process_launch_error;
- public static String process_parse_error;
-
- public static String process_parse_note_error;
- public static String process_apply_note_error;
-
- public static String process_parse_component_error;
- public static String process_parse_package_error;
- public static String process_parse_path_error;
- public static String process_parse_outline_error;
- public static String process_parse_thingatpoint_error;
-
- public static String project_members_list_error;
- public static String project_cabal_duplicate;
-
- public static String job_build;
- public static String job_synchronize;
- public static String job_components;
- public static String job_dependencies;
-
- public static String error_deleteMarkers;
- public static String error_gettingFlags;
- public static String error_noexe;
- public static String error_derived;
- public static String error_refreshLocal;
- public static String error_clean;
- public static String error_parsing_usage_path;
- public static String error_parsing_usage_file;
- public static String error_setup_db;
- public static String error_db;
- public static String error_no_db;
-
- public static String outline_job_name;
- public static String editor_job_name;
- public static String occurrences_job_name;
- public static String thingatpoint_job_name;
-
-
- private static final String BUNDLE_NAME = BWText.class.getPackage().getName() + ".bwtext"; //$NON-NLS-1$
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, BWText.class);
- }
-}
+package net.sf.eclipsefp.haskell.buildwrapper.util;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Provides access to the internationalized UI texts.
+ *
+ * @author JP Moresmau
+ */
+public class BWText extends NLS {
+ public static String process_launch_error;
+ public static String process_parse_error;
+
+ public static String process_parse_note_error;
+ public static String process_apply_note_error;
+
+ public static String process_parse_component_error;
+ public static String process_parse_package_error;
+ public static String process_parse_path_error;
+ public static String process_parse_outline_error;
+ public static String process_parse_thingatpoint_error;
+
+ public static String project_members_list_error;
+ public static String project_cabal_duplicate;
+
+ public static String job_build;
+ public static String job_clean;
+ public static String job_synchronize;
+ public static String job_components;
+ public static String job_dependencies;
+
+ public static String error_deleteMarkers;
+ public static String error_gettingFlags;
+ public static String error_noexe;
+ public static String error_derived;
+ public static String error_refreshLocal;
+ public static String error_clean;
+ public static String error_parsing_usage_path;
+ public static String error_parsing_usage_file;
+ public static String error_setup_db;
+ public static String error_db;
+ public static String error_no_db;
+
+ public static String outline_job_name;
+ public static String editor_job_name;
+ public static String occurrences_job_name;
+ public static String thingatpoint_job_name;
+
+
+ private static final String BUNDLE_NAME = BWText.class.getPackage().getName() + ".bwtext"; //$NON-NLS-1$
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, BWText.class);
+ }
+}
73 net.sf.eclipsefp.haskell.buildwrapper/src/net/sf/eclipsefp/haskell/buildwrapper/util/bwtext.properties
View
@@ -1,36 +1,37 @@
-process_launch_error=Error while launching buildwrapper process
-process_parse_error=Cannot parse buildwrapper response as JSON Object
-process_parse_note_error=Cannot parse notes from JSON
-process_apply_note_error=Cannot apply note
-process_parse_component_error=Cannot parse component from JSON
-process_parse_package_error=Cannot parse package from JSON
-process_parse_path_error=Cannot parse path from JSON
-process_parse_outline_error=Cannot parse outline from JSON
-process_parse_thingatpoint_error=Cannot parse thing at point from JSON
-
-project_members_list_error=Error list members of project {0}
-project_cabal_duplicate=More than one cabal file under project {0}
-
-error_deleteMarkers = Error deleting problem markers
-error_gettingFlags = Error getting saved flags from project
-error_noexe = No buildwrapper executable defined
-error_derived = Cannot set derived status on build-wrapper folder
-error_refreshLocal = Error refreshing resource
-error_clean = Error cleaning project
-error_parsing_usage_path = Error parsing usage paths
-error_parsing_usage_file = Error parsing usage file
-
-error_setup_db = Error setting up SQLite DB
-error_db = SQLite DB threw an exception
-error_no_db = SQLite DB not available
-
-job_build=Building project {0}
-job_synchronize=Synchronizing project {0}
-job_components=Retrieving components for project {0}
-job_dependencies=Retrieving dependencies for project {0}
-
-outline_job_name=Generating outline for {0}
-editor_job_name=Synchronizing editor content for {0}
-occurrences_job_name=Getting occurrences in {0}
-thingatpoint_job_name=Finding thing at point in {0}
-
+process_launch_error=Error while launching buildwrapper process
+process_parse_error=Cannot parse buildwrapper response as JSON Object
+process_parse_note_error=Cannot parse notes from JSON
+process_apply_note_error=Cannot apply note
+process_parse_component_error=Cannot parse component from JSON
+process_parse_package_error=Cannot parse package from JSON
+process_parse_path_error=Cannot parse path from JSON
+process_parse_outline_error=Cannot parse outline from JSON
+process_parse_thingatpoint_error=Cannot parse thing at point from JSON
+
+project_members_list_error=Error list members of project {0}
+project_cabal_duplicate=More than one cabal file under project {0}
+
+error_deleteMarkers = Error deleting problem markers
+error_gettingFlags = Error getting saved flags from project
+error_noexe = No buildwrapper executable defined
+error_derived = Cannot set derived status on build-wrapper folder
+error_refreshLocal = Error refreshing resource
+error_clean = Error cleaning project
+error_parsing_usage_path = Error parsing usage paths
+error_parsing_usage_file = Error parsing usage file
+
+error_setup_db = Error setting up SQLite DB
+error_db = SQLite DB threw an exception
+error_no_db = SQLite DB not available
+
+job_build=Building project {0}
+job_clean=Cleaning project {0}
+job_synchronize=Synchronizing project {0}
+job_components=Retrieving components for project {0}
+job_dependencies=Retrieving dependencies for project {0}
+
+outline_job_name=Generating outline for {0}
+editor_job_name=Synchronizing editor content for {0}
+occurrences_job_name=Getting occurrences in {0}
+thingatpoint_job_name=Finding thing at point in {0}
+
BIN  net.sf.eclipsefp.haskell.ui/icons/eview16/cabal.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1  net.sf.eclipsefp.haskell.ui/plugin.properties
View
@@ -169,6 +169,7 @@ hsCodeTemplates.context=Haskell source code template context
cabalSDistWizard.name=Cabal source export
cabalSDistWizard.description=Export source via Cabal sdist
cabalInstallWizard.name=Cabal install
+cabalInstallDependenciesWizard.name=Cabal install dependencies
cabalInstallWizard.description=Install project via Cabal
cabalTestWizard.name=Cabal test
cabalTestWizard.description=Launch Cabal Test Suites
22 net.sf.eclipsefp.haskell.ui/plugin.xml
View
@@ -777,6 +777,7 @@
class="net.sf.eclipsefp.haskell.ui.actions.CabalInstallAction"
enablesFor="1"
id="net.sf.eclipsefp.haskell.ui.cabalInstallAction"
+ icon="icons/eview16/cabal.png"
label="%cabalInstallWizard.name">
</action>
<enablement>
@@ -787,7 +788,24 @@
</enablement>
</objectContribution>
-
+ <objectContribution
+ id="net.sf.eclipsefp.haskell.ui.contribution2"
+ objectClass="org.eclipse.core.resources.IProject">
+ <action
+ class="net.sf.eclipsefp.haskell.ui.actions.CabalInstallDependenciesAction"
+ enablesFor="1"
+ id="net.sf.eclipsefp.haskell.ui.cabalInstallDependenciesAction"
+ icon="icons/eview16/hackage_install.png"
+ label="%cabalInstallDependenciesWizard.name">
+ </action>
+ <enablement>
+ <adapt type="org.eclipse.core.resources.IProject">
+ <test property="org.eclipse.core.resources.projectNature"
+ value="net.sf.eclipsefp.haskell.core.project.HaskellNature"/>
+ </adapt>
+
+ </enablement>
+ </objectContribution>
<!--objectContribution
id="net.sf.eclipsefp.haskell.ui.contribution1"
objectClass="org.eclipse.core.resources.IProject">
@@ -1159,7 +1177,7 @@
<view
category="net.sf.eclipsefp.haskell"
class="net.sf.eclipsefp.haskell.ui.views.CabalPackagesView"
- icon="icons/eview16/cabal.gif"
+ icon="icons/eview16/cabal.png"
id="net.sf.eclipsefp.haskell.ui.views.CabalPackagesView"
name="%haskellBrowser_cabalPackagesView"
restorable="true">
150 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/actions/CabalInstallAction.java
View
@@ -1,43 +1,107 @@
-package net.sf.eclipsefp.haskell.ui.actions;
-
-import java.util.LinkedHashSet;
-import java.util.Set;
-import net.sf.eclipsefp.haskell.core.util.ResourceUtil;
-import net.sf.eclipsefp.haskell.ui.wizards.cabal.CabalInstallWizard;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * <p>Cabal install action, contextual on projects</p>
- *
- * @author JP Moresmau
- */
-public class CabalInstallAction implements IObjectActionDelegate {
- private final Set<IProject> projects=new LinkedHashSet<IProject>();
- private Shell currentShell;
-
- @Override
- public void setActivePart( final IAction arg0, final IWorkbenchPart arg1 ) {
- currentShell=arg1.getSite().getShell();
-
- }
-
- @Override
- public void run( final IAction arg0 ) {
- WizardDialog wd=new WizardDialog( currentShell, new CabalInstallWizard( projects ) );
- wd.open();
-
- }
-
- @Override
- public void selectionChanged( final IAction arg0, final ISelection arg1 ) {
- projects.clear();
- projects.addAll( ResourceUtil.getProjects( arg1 ) );
- }
-
-}
+package net.sf.eclipsefp.haskell.ui.actions;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+import net.sf.eclipsefp.haskell.buildwrapper.BWFacade;
+import net.sf.eclipsefp.haskell.buildwrapper.BuildWrapperPlugin;
+import net.sf.eclipsefp.haskell.core.cabal.CabalImplementationManager;
+import net.sf.eclipsefp.haskell.core.util.ResourceUtil;
+import net.sf.eclipsefp.haskell.debug.core.internal.launch.AbstractHaskellLaunchDelegate;
+import net.sf.eclipsefp.haskell.ui.HaskellUIPlugin;
+import net.sf.eclipsefp.haskell.ui.internal.util.UITexts;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * <p>Cabal install action, contextual on projects</p>
+ *
+ * @author JP Moresmau
+ */
+public class CabalInstallAction implements IObjectActionDelegate {
+ private final Set<IProject> projects=new LinkedHashSet<IProject>();
+ private Shell currentShell;
+
+ @Override
+ public void setActivePart( final IAction arg0, final IWorkbenchPart arg1 ) {
+ currentShell=arg1.getSite().getShell();
+
+ }
+
+ @Override
+ public void run( final IAction arg0 ) {
+ // do not ask for options, use our own dist folder and default cabal options
+ //WizardDialog wd=new WizardDialog( currentShell, new CabalInstallWizard( projects ) );
+ //wd.open();
+ final String cabalExecutable=CabalImplementationManager.getCabalExecutable();
+ if (cabalExecutable!=null){
+ final List<String> commands = new ArrayList<String>();
+ commands.add( cabalExecutable );
+ commands.add("install");
+ // options
+ commands.add("--builddir="+BWFacade.DIST_FOLDER_CABAL);
+ // commands.add( "--user" ); // use cabal default, which is now user
+ addExtraParameters(commands);
+ for (final IProject p:projects){
+ try {
+ List<String> prjCommands = new ArrayList<String>(commands);
+ BWFacade bf=BuildWrapperPlugin.getFacade( p );
+ // need to provide user supplied info
+ if(bf!=null){
+ String f=bf.getFlags();
+ if (f!=null && f.length()>0){
+ prjCommands.add("--flags="+f);
+ }
+ List<String> extraOpts=bf.getExtraOpts();
+ if (extraOpts!=null){
+ for (String eo:extraOpts){
+ prjCommands.add(eo);
+ }
+ }
+ }
+
+
+ AbstractHaskellLaunchDelegate.runInConsole(p, prjCommands, new File(p.getLocation().toOSString()), NLS.bind( getJobName(), p.getName() ),true,getAfter(p) );
+ } catch (Exception ioe){
+ HaskellUIPlugin.log(ioe);
+ final IStatus st=new Status( IStatus.ERROR, HaskellUIPlugin.getPluginId(),ioe.getLocalizedMessage(),ioe);
+ ErrorDialog.openError( currentShell, UITexts.install_error, UITexts.install_error_text, st);
+ }
+
+
+ }
+ }
+
+
+ }
+
+ protected Runnable getAfter(final IProject p){
+ return null;
+ }
+
+ protected String getJobName(){
+ return UITexts.install_job;
+ }
+
+ protected void addExtraParameters(final List<String> commands){
+ // force reinstall since we're probably reinstalling our development version
+ commands.add( "--reinstall" );
+ }
+
+ @Override
+ public void selectionChanged( final IAction arg0, final ISelection arg1 ) {
+ projects.clear();
+ projects.addAll( ResourceUtil.getProjects( arg1 ) );
+ }
+
+}
82 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/actions/CabalInstallDependenciesAction.java
View
@@ -0,0 +1,82 @@
+/**
+ * Copyright (c) 2012 by JP Moresmau
+ * This code is made available under the terms of the Eclipse Public License,
+ * version 1.0 (EPL). See http://www.eclipse.org/legal/epl-v10.html
+ */
+package net.sf.eclipsefp.haskell.ui.actions;
+
+import java.util.List;
+import net.sf.eclipsefp.haskell.buildwrapper.util.BWText;
+import net.sf.eclipsefp.haskell.ui.HaskellUIPlugin;
+import net.sf.eclipsefp.haskell.ui.internal.util.UITexts;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.osgi.util.NLS;
+
+
+/**
+ * Install only the project dependencies
+ * @author JP Moresmau
+ *
+ */
+public class CabalInstallDependenciesAction extends CabalInstallAction {
+
+ /* (non-Javadoc)
+ * @see net.sf.eclipsefp.haskell.ui.actions.CabalInstallAction#getJobName()
+ */
+ @Override
+ protected String getJobName() {
+ return UITexts.install_dependencies_job;
+ }
+
+ /* (non-Javadoc)
+ * @see net.sf.eclipsefp.haskell.ui.actions.CabalInstallAction#addExtraParameters(java.util.List)
+ */
+ @Override
+ protected void addExtraParameters( final List<String> commands ) {
+ commands.add("--only-dependencies");
+ }
+
+ /* (non-Javadoc)
+ * @see net.sf.eclipsefp.haskell.ui.actions.CabalInstallAction#getAfter(org.eclipse.core.resources.IProject)
+ */
+ @Override
+ protected Runnable getAfter(final IProject p ) {
+ // once we've downloaded the dependencies, we clean the project and rebuild if we're in auto build mode
+ Runnable r=new Runnable(){
+ @Override
+ public void run() {
+ final String jobName = NLS.bind(BWText.job_clean, p.getName());
+ Job j=new Job(jobName) {
+
+ @Override
+ protected IStatus run( final IProgressMonitor mon ) {
+ try {
+ p.build( IncrementalProjectBuilder.CLEAN_BUILD , mon );
+ if (ResourcesPlugin.getWorkspace().isAutoBuilding()){
+ if (mon!=null){
+ mon.setTaskName( NLS.bind(BWText.job_build, p.getName()) );
+ }
+ p.build( IncrementalProjectBuilder.FULL_BUILD , mon );
+ }
+ } catch (CoreException ce){
+ return new Status( IStatus.ERROR, HaskellUIPlugin.getPluginId(), ce.getLocalizedMessage(),ce);
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ j.setPriority( Job.BUILD );
+ j.schedule();
+ }
+ };
+ return r;
+
+
+ }
+}
1  ...efp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/preferences/scion/AutodetectExecutableField.java
View
@@ -158,6 +158,7 @@ public void run() {
String newVal=f.getAbsolutePath();
fieldEditor.setStringValue(newVal);
listener.propertyChange( new PropertyChangeEvent( this, "path", oldVal, newVal) ) ;
+ fieldEditor.checkState();
}
}
installButton.setEnabled( true );
14 ...efp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/preferences/scion/ExecutableFileFieldEditor.java
View
@@ -139,20 +139,20 @@ protected String changePressed() {
* and <code>false</code> if invalid
*/
@Override
- protected boolean checkState() {
+ public boolean checkState() {
if (getTextControl() == null) {
- return false;
- }
+ return false;
+ }
String txt = getTextControl().getText();
boolean result = isEmptyStringAllowed() || txt.length() > 0;
result = result && doCheckState();
if (result) {
- clearErrorMessage();
- } else {
- showErrorMessage(getErrorMessage());
- }
+ clearErrorMessage();
+ } else {
+ showErrorMessage(getErrorMessage());
+ }
return result;
}
1  net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/util/UITexts.java
View
@@ -480,6 +480,7 @@
public static String exportSource_overwrite_warning;
public static String install_job;
+ public static String install_dependencies_job;
public static String install_options;
public static String install_options_folder;
public static String install_options_folder_choose;
1  net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/util/uitexts.properties
View
@@ -502,6 +502,7 @@ exportSource_warning_markers=warning: warnings: note: errors:
exportSource_overwrite_warning=File {0} already exists and will be overwritten
install_job=Installing project {0}
+install_dependencies_job=Installing dependencies of project {0}
install_options=Install options
install_options_folder=Install from build folder:
install_options_folder_choose=Choose a build folder
424 ...askell.ui/src/net/sf/eclipsefp/haskell/ui/internal/views/projectexplorer/HaskellResourceExtensionCP.java
View
@@ -1,211 +1,213 @@
-// Copyright (c) 2006-2008 by Leif Frenzel - see http://leiffrenzel.de
-// This code is made available under the terms of the Eclipse Public License,
-// version 1.0 (EPL). See http://www.eclipse.org/legal/epl-v10.html
-package net.sf.eclipsefp.haskell.ui.internal.views.projectexplorer;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import net.sf.eclipsefp.haskell.buildwrapper.BWFacade;
-import net.sf.eclipsefp.haskell.buildwrapper.BuildWrapperPlugin;
-import net.sf.eclipsefp.haskell.buildwrapper.types.OutlineDef;
-import net.sf.eclipsefp.haskell.core.HaskellCorePlugin;
-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.preferences.ICorePreferenceNames;
-import net.sf.eclipsefp.haskell.core.project.HaskellNature;
-import net.sf.eclipsefp.haskell.core.util.ResourceUtil;
-import net.sf.eclipsefp.haskell.ui.HaskellUIPlugin;
-import net.sf.eclipsefp.haskell.ui.internal.views.common.ITreeElement;
-import net.sf.eclipsefp.haskell.ui.internal.views.projectexplorer.model.GHCSystemLibrary;
-import net.sf.eclipsefp.haskell.util.FileUtil;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.navigator.ICommonContentExtensionSite;
-import org.eclipse.ui.navigator.ICommonContentProvider;
-
-/**
- * <p>
- * content provider which is declared in <code>plugin.xml</code> for the project
- * explorer view.
- * </p>
- *
- * @author Leif Frenzel
- */
-public class HaskellResourceExtensionCP implements ICommonContentProvider {
- // interface methods of ITreeContentProvider
- // //////////////////////////////////////////
-
- @Override
- public Object[] getChildren( final Object parentElement ) {
- final List<Object> result = new ArrayList<Object>();
- try {
- if( parentElement instanceof IProject
- && ( ( IProject )parentElement ).isOpen()
- && ( ( IProject )parentElement ).hasNature( HaskellNature.NATURE_ID ) ) {
- IProject p = ( IProject )parentElement;
- result.add( new GHCSystemLibrary( p ));
- IFile f = BuildWrapperPlugin.getCabalFile( p );
- if (f != null && f.exists()) {
- result.add( f );
- }
- Set<IContainer> srcs=new HashSet<IContainer>(ResourceUtil.getSourceFolders( p ));
- srcs.remove( parentElement ); // may happen if . is a source folder
- result.addAll(srcs);
-
- // add all remaining members so that they appear after the haskell content in view
- for (IResource r:p.members()){
- if (!r.equals( f ) && !srcs.contains( r )){
- result.add(r);
- }
- }
- // addProjectExecutable( ( IProject )parentElement, result );
- } else if( parentElement instanceof IFile ) {
- final IFile f = ( IFile )parentElement;
- // if we have a Haskell source file, we show the same content as outline
- // underneath
- if( FileUtil.hasHaskellExtension( f ) && ResourceUtil.isInHaskellProject( f )) {
- BWFacade si = BuildWrapperPlugin.getFacade( f.getProject() );//ScionPlugin.getScionInstance( f );
- if (si != null) {
- List<OutlineDef> outlineDefs = si.outline( f ).getOutlineDefs();
- //OutlineCP cp = new OutlineCP();
- //cp.inputChanged( null, null, outlineDefs );
- for( OutlineDef def : outlineDefs ) {
- //if( def.getParentID() == null ) {
- result.add( new ProjectExplorerOutlineDef( f, def ) );
- //}
- }
- }
- }
- // if we have a Haskell source file, we show the same content as outline
- // underneath
- else if( FileUtil.hasCabalExtension( f ) && ResourceUtil.isInHaskellProject( f )) {
- PackageDescription descr = PackageDescriptionLoader.load( f );
- PackageDescriptionStanza lib = descr.getLibraryStanza();
- if (lib != null) {
- result.add( new ProjectExplorerStanza( f,descr.getLibraryStanza() ));
- }
- if (descr.getExecutableStanzas().size() > 0) {
- result.add( new CabalFolder(f, CabalFolderType.EXECUTABLE ));
- }
- if (descr.getTestSuiteStanzas().size() > 0) {
- result.add( new CabalFolder(f, CabalFolderType.TEST_SUITE ));
- }
- }
- } else if (parentElement instanceof CabalFolder) {
- CabalFolder folder = ( CabalFolder )parentElement;
- result.addAll( folder.getStanzas() );
- }else if( parentElement instanceof ITreeElement ) {
- ITreeElement treeElement = ( ITreeElement )parentElement;
- result.addAll( treeElement.getChildren() );
- // outline results are wrapped in a structure keeping the tree and the file
- } else if( parentElement instanceof ProjectExplorerOutlineDef ) {
- ProjectExplorerOutlineDef outline = ( ProjectExplorerOutlineDef )parentElement;
- result.addAll( outline.getChildren() );
- }
- } catch( final CoreException cex ) {
- HaskellUIPlugin.log( cex );
- }
- return result.toArray();
- }
-
- @Override
- public Object getParent( final Object element ) {
- Object result = null;
- if( element instanceof ITreeElement ) {
- result = ( ( ITreeElement )element ).getParent();
- }
- return result;
- }
-
- @Override
- public boolean hasChildren( final Object element ) {
- if( element instanceof IFile ) {
- IFile f = ( IFile )element;
- if( FileUtil.hasHaskellExtension( f ) || FileUtil.hasCabalExtension( f ) ) {
- return true;
- }
- return false;
- } else if ( element instanceof CabalFolder ) {
- return true;
- }
- Object[] children = getChildren( element );
- return children == null ? false : children.length > 0;
- }
-
- @Override
- public Object[] getElements( final Object inputElement ) {
- return new Object[ 0 ];
- }
-
- @Override
- public void dispose() {
- // unused
- }
-
- @Override
- public void inputChanged( final Viewer viewer, final Object oldInput,
- final Object newInput ) {
- // unused
- }
-
-
- // interface methods of ICommonContentProvider
- // ////////////////////////////////////////////
-
- // TODO lf note to self: config -> navigator service -> can be used to
- // get state information from the View
- @Override
- public void init( final ICommonContentExtensionSite config ) {
- IEclipsePreferences node = InstanceScope.INSTANCE.getNode( HaskellCorePlugin
- .getPluginId() );
- node.addPreferenceChangeListener( new IPreferenceChangeListener() {
-
- @Override
- public void preferenceChange( final PreferenceChangeEvent event ) {
- String prop = event.getKey();
- if( ICorePreferenceNames.HS_IMPLEMENTATIONS.equals( prop )
- || ICorePreferenceNames.SELECTED_HS_IMPLEMENTATION.equals( prop ) ) {
- config.getService().update();
- }
- }
- } );
- }
-
- @Override
- public void restoreState( final IMemento memento ) {
- // unused
- }
-
- @Override
- public void saveState( final IMemento memento ) {
- // unused
- }
-
-
- // helping functions
- // //////////////////
-
- /* private void addProjectExecutable( final IProject project,
- final List<Object> list ) {
- try {
- IFile[] executables = ResourceUtil.getProjectExecutables( project );
- list.addAll( Arrays.asList( executables ) );
- } catch( CoreException ex ) {
- String msg = "Problem determining project executable for "
- + project.getName();
- HaskellUIPlugin.log( msg, ex );
- }
- }*/
-}
+// Copyright (c) 2006-2008 by Leif Frenzel - see http://leiffrenzel.de
+// This code is made available under the terms of the Eclipse Public License,
+// version 1.0 (EPL). See http://www.eclipse.org/legal/epl-v10.html
+package net.sf.eclipsefp.haskell.ui.internal.views.projectexplorer;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import net.sf.eclipsefp.haskell.buildwrapper.BWFacade;
+import net.sf.eclipsefp.haskell.buildwrapper.BuildWrapperPlugin;
+import net.sf.eclipsefp.haskell.buildwrapper.types.OutlineDef;
+import net.sf.eclipsefp.haskell.core.HaskellCorePlugin;
+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.preferences.ICorePreferenceNames;
+import net.sf.eclipsefp.haskell.core.project.HaskellNature;
+import net.sf.eclipsefp.haskell.core.util.ResourceUtil;
+import net.sf.eclipsefp.haskell.ui.HaskellUIPlugin;
+import net.sf.eclipsefp.haskell.ui.internal.views.common.ITreeElement;
+import net.sf.eclipsefp.haskell.ui.internal.views.projectexplorer.model.GHCSystemLibrary;
+import net.sf.eclipsefp.haskell.util.FileUtil;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.navigator.ICommonContentExtensionSite;
+import org.eclipse.ui.navigator.ICommonContentProvider;
+
+/**
+ * <p>
+ * content provider which is declared in <code>plugin.xml</code> for the project
+ * explorer view.
+ * </p>
+ *
+ * @author Leif Frenzel
+ */
+public class HaskellResourceExtensionCP implements ICommonContentProvider {
+ // interface methods of ITreeContentProvider
+ // //////////////////////////////////////////
+
+ @Override
+ public Object[] getChildren( final Object parentElement ) {
+ final List<Object> result = new ArrayList<Object>();
+ try {
+ if( parentElement instanceof IProject
+ && ( ( IProject )parentElement ).isOpen()
+ && ( ( IProject )parentElement ).hasNature( HaskellNature.NATURE_ID ) ) {
+ IProject p = ( IProject )parentElement;
+ result.add( new GHCSystemLibrary( p ));
+ IFile f = BuildWrapperPlugin.getCabalFile( p );
+ if (f != null && f.exists()) {
+ result.add( f );
+ }
+ Set<IContainer> srcs=new HashSet<IContainer>(ResourceUtil.getSourceFolders( p ));
+ srcs.remove( parentElement ); // may happen if . is a source folder
+ result.addAll(srcs);
+
+ // add all remaining members so that they appear after the haskell content in view
+ for (IResource r:p.members()){
+ if (!r.equals( f ) && !srcs.contains( r )){
+ result.add(r);
+ }
+ }
+ // addProjectExecutable( ( IProject )parentElement, result );
+ } else if( parentElement instanceof IFile ) {
+ final IFile f = ( IFile )parentElement;
+ // if we have a Haskell source file, we show the same content as outline
+ // underneath
+ if( FileUtil.hasHaskellExtension( f ) && ResourceUtil.isInHaskellProject( f )) {
+ BWFacade si = BuildWrapperPlugin.getFacade( f.getProject() );//ScionPlugin.getScionInstance( f );
+ if (si != null) {
+ List<OutlineDef> outlineDefs = si.outline( f ).getOutlineDefs();
+ //OutlineCP cp = new OutlineCP();
+ //cp.inputChanged( null, null, outlineDefs );
+ for( OutlineDef def : outlineDefs ) {
+ //if( def.getParentID() == null ) {
+ result.add( new ProjectExplorerOutlineDef( f, def ) );
+ //}
+ }
+ }
+ }
+ // if we have a Haskell source file, we show the same content as outline
+ // underneath
+ else if( FileUtil.hasCabalExtension( f ) && ResourceUtil.isInHaskellProject( f )) {
+ PackageDescription descr = PackageDescriptionLoader.load( f );
+ PackageDescriptionStanza lib = descr.getLibraryStanza();
+ if (lib != null) {
+ result.add( new ProjectExplorerStanza( f,descr.getLibraryStanza() ));
+ }
+ if (descr.getExecutableStanzas().size() > 0) {
+ result.add( new CabalFolder(f, CabalFolderType.EXECUTABLE ));
+ }
+ if (descr.getTestSuiteStanzas().size() > 0) {
+ result.add( new CabalFolder(f, CabalFolderType.TEST_SUITE ));
+ }
+ }
+ } else if (parentElement instanceof CabalFolder) {
+ CabalFolder folder = ( CabalFolder )parentElement;
+ result.addAll( folder.getStanzas() );
+ }else if( parentElement instanceof ITreeElement ) {
+ ITreeElement treeElement = ( ITreeElement )parentElement;
+ result.addAll( treeElement.getChildren() );
+ // outline results are wrapped in a structure keeping the tree and the file
+ } else if( parentElement instanceof ProjectExplorerOutlineDef ) {
+ ProjectExplorerOutlineDef outline = ( ProjectExplorerOutlineDef )parentElement;
+ result.addAll( outline.getChildren() );
+ }
+ } catch( final CoreException cex ) {
+ HaskellUIPlugin.log( cex );
+ }
+ return result.toArray();
+ }
+
+ @Override
+ public Object getParent( final Object element ) {
+ Object result = null;
+ if( element instanceof ITreeElement ) {
+ result = ( ( ITreeElement )element ).getParent();
+ }
+ return result;
+ }
+
+ @Override
+ public boolean hasChildren( final Object element ) {
+ if( element instanceof IFile ) {
+ IFile f = ( IFile )element;
+ if( FileUtil.hasHaskellExtension( f ) || FileUtil.hasCabalExtension( f ) ) {
+ return true;
+ }
+ return false;
+ } else if ( element instanceof CabalFolder ) {
+ return true;
+ } else if (element instanceof GHCSystemLibrary){ // for performance, we know we always have children
+ return true;
+ }
+ Object[] children = getChildren( element );
+ return children == null ? false : children.length > 0;
+ }
+
+ @Override
+ public Object[] getElements( final Object inputElement ) {
+ return new Object[ 0 ];
+ }
+
+ @Override
+ public void dispose() {
+ // unused
+ }
+
+ @Override
+ public void inputChanged( final Viewer viewer, final Object oldInput,
+ final Object newInput ) {
+ // unused
+ }
+
+
+ // interface methods of ICommonContentProvider
+ // ////////////////////////////////////////////
+
+ // TODO lf note to self: config -> navigator service -> can be used to
+ // get state information from the View
+ @Override
+ public void init( final ICommonContentExtensionSite config ) {
+ IEclipsePreferences node = InstanceScope.INSTANCE.getNode( HaskellCorePlugin
+ .getPluginId() );
+ node.addPreferenceChangeListener( new IPreferenceChangeListener() {
+
+ @Override
+ public void preferenceChange( final PreferenceChangeEvent event ) {
+ String prop = event.getKey();
+ if( ICorePreferenceNames.HS_IMPLEMENTATIONS.equals( prop )
+ || ICorePreferenceNames.SELECTED_HS_IMPLEMENTATION.equals( prop ) ) {
+ config.getService().update();
+ }
+ }
+ } );
+ }
+
+ @Override
+ public void restoreState( final IMemento memento ) {
+ // unused
+ }
+
+ @Override
+ public void saveState( final IMemento memento ) {
+ // unused
+ }
+
+
+ // helping functions
+ // //////////////////
+
+ /* private void addProjectExecutable( final IProject project,
+ final List<Object> list ) {
+ try {
+ IFile[] executables = ResourceUtil.getProjectExecutables( project );
+ list.addAll( Arrays.asList( executables ) );
+ } catch( CoreException ex ) {
+ String msg = "Problem determining project executable for "
+ + project.getName();
+ HaskellUIPlugin.log( msg, ex );
+ }
+ }*/
+}
1  net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/sourcegraph/RunActionDelegate.java
View
@@ -107,6 +107,7 @@ public void selectionChanged( final IAction action, final ISelection selection )
if (prjs.size() > 0){
project = prjs.iterator().next();
}
+ action.setEnabled( project!=null );
}
@Override
51 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/views/CabalPackagesView.java
View
@@ -468,32 +468,34 @@ private void install(final boolean global,final String options){
if (options!=null && options.trim().length()>0){
commands.addAll(Arrays.asList(CommandLineUtil.parse( options.trim() )));
}
- try {
- AbstractHaskellLaunchDelegate.runInConsole(null, commands, new File(cabalExecutable).getParentFile(), UITexts.cabalPackagesView_action_install_running,true, new Runnable() {
- @Override
- public void run() {
- lInstall.getDisplay().asyncExec( new Runnable() {
+ try {
+ // this requires to be in the UI thread
+ AbstractHaskellLaunchDelegate.runInConsole(null, commands, new File(cabalExecutable).getParentFile(), UITexts.cabalPackagesView_action_install_running,true, new Runnable() {
- @Override
- public void run() {
- lInstall.setText( UITexts.cabalPackagesView_info_installed );
- helper.setInstalled( null );
- if (!bAll.getSelection()){
- refreshJob.schedule();
+ @Override
+ public void run() {
+ lInstall.getDisplay().asyncExec( new Runnable() {
+
+ @Override
+ public void run() {
+ lInstall.setText( UITexts.cabalPackagesView_info_installed );
+ helper.setInstalled( null );
+ if (!bAll.getSelection()){
+ refreshJob.schedule();
+ }
}
- }
- });
- BrowserPlugin.loadLocalDatabase( true );
- }
- });
- } catch (Exception ioe){
- HaskellUIPlugin.log(ioe);
- final IStatus st=new Status( IStatus.ERROR, HaskellUIPlugin.getPluginId(),ioe.getLocalizedMessage(),ioe);
- ErrorDialog.openError(getSite().getShell(), UITexts.cabalPackagesView_action_install_error, UITexts.cabalPackagesView_action_install_error, st);
- }
- }
+ });
+ BrowserPlugin.loadLocalDatabase( true );
+ }
+ });
+ } catch (Exception ioe){
+ HaskellUIPlugin.log(ioe);
+ final IStatus st=new Status( IStatus.ERROR, HaskellUIPlugin.getPluginId(),ioe.getLocalizedMessage(),ioe);
+ ErrorDialog.openError(getSite().getShell(), UITexts.cabalPackagesView_action_install_error, UITexts.cabalPackagesView_action_install_error, st);
+ }
+ }
}
private void update(){
@@ -618,8 +620,11 @@ public void modifyText( final ModifyEvent arg0 ) {
@Override
protected void okPressed() {
- install(global,options);
+ // install does things in the UI thread, so close the dialog first
super.okPressed();
+
+ install(global,options);
+
}
}
}

No commit comments for this range

Something went wrong with that request. Please try again.