Skip to content
Browse files

install dependencies

  • Loading branch information...
1 parent 9a7ead4 commit dc2881a507ae4c4fdbc5630f3c26002325121738 @JPMoresmau committed Oct 19, 2012
View
3 docs/releasenotes/net.sf.eclipsefp.haskell_2.3.2.txt
@@ -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:
View
109 ...eclipsefp.haskell.buildwrapper/src/net/sf/eclipsefp/haskell/buildwrapper/util/BWText.java
@@ -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);
+ }
+}
View
73 ...efp.haskell.buildwrapper/src/net/sf/eclipsefp/haskell/buildwrapper/util/bwtext.properties
@@ -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}
+
View
1 net.sf.eclipsefp.haskell.ui/plugin.properties
@@ -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
View
19 net.sf.eclipsefp.haskell.ui/plugin.xml
@@ -788,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">
View
150 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/actions/CabalInstallAction.java
@@ -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 ) );
+ }
+
+}
View
82 ...fp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/actions/CabalInstallDependenciesAction.java
@@ -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;
+
+
+ }
+}
View
1 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/util/UITexts.java
@@ -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;
View
1 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/util/uitexts.properties
@@ -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

0 comments on commit dc2881a

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