diff options
author | Sergey Prigogin | 2014-08-01 18:55:31 +0000 |
---|---|---|
committer | Sergey Prigogin | 2014-08-01 18:55:31 +0000 |
commit | 093b2efacf4da0768d396cd610acd609eb09cdf6 (patch) | |
tree | 7a06d9d2af402b020d249cd8d8e9241d43166731 /build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal | |
parent | 0b62fee46ca81d6157cd9b55388f2416b78a39f2 (diff) | |
download | org.eclipse.cdt-093b2efacf4da0768d396cd610acd609eb09cdf6.tar.gz org.eclipse.cdt-093b2efacf4da0768d396cd610acd609eb09cdf6.tar.xz org.eclipse.cdt-093b2efacf4da0768d396cd610acd609eb09cdf6.zip |
Proper enablement of Build Configurations Build/Clean commands.
Change-Id: I7446a357cc2bafdb5015c3a988a1ad0b6f23a8c6
Diffstat (limited to 'build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal')
17 files changed, 258 insertions, 321 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.java index 393ead7f200..90b13c31564 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.java @@ -20,9 +20,6 @@ public class Messages extends NLS { public static String ArtifactTab_1; public static String ArtifactTab_2; public static String ArtifactTab_3; - public static String BuildConfigurationsJob_BuildError; - public static String BuildConfigurationsJob_Building; - public static String BuildConfigurationsJob_Cleaning; public static String BuilderSettingsTab_0; public static String BuilderSettingsTab_1; public static String BuilderSettingsTab_10; @@ -76,11 +73,6 @@ public class Messages extends NLS { public static String CConfigWizardPage_7; public static String CConfigWizardPage_8; public static String CDTConfigWizardPage_0; - public static String CleanAndBuildDialog_Active; - public static String CleanAndBuildDialog_BuildConfigurations; - public static String CleanAndBuildDialog_CleanConfigurations; - public static String CleanAndBuildDialog_RebuildConfigurations; - public static String CleanAndBuildDialog_SelectConfigurations; public static String CMainWizardPage_0; public static String CMainWizardPage_1; public static String CNewWizard_0; diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.properties b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.properties index 8996945a2e1..d3abe56bfc4 100755 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.properties +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.properties @@ -10,16 +10,6 @@ # Andrew Gvozdev (Quoin Inc.) - Combined managedbuilder.ui bundles to NLS message format, bug 318812 ############################################################################### -BuildConfigurationsJob_BuildError=Build error -BuildConfigurationsJob_Building=Building {1}[{2}], ... [{0}] -BuildConfigurationsJob_Cleaning=Cleaning {1}[{2}], ... [{0}] - -CleanAndBuildDialog_Active=[Active] -CleanAndBuildDialog_BuildConfigurations=Build selected configurations -CleanAndBuildDialog_CleanConfigurations=Clean selected configurations -CleanAndBuildDialog_RebuildConfigurations=Clean and Rebuild Configurations -CleanAndBuildDialog_SelectConfigurations=Select configurations to rebuild. - BuilderSettingsTab_0=Builder BuilderSettingsTab_1=Builder &type: BuilderSettingsTab_2=External builder diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/BuildAllConfigurationsAction.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/BuildAllConfigurationsAction.java deleted file mode 100644 index 1ec00968ca0..00000000000 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/BuildAllConfigurationsAction.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2010 Andrew Gvozdev and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Andrew Gvozdev (Quoin Inc.) - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.managedbuilder.internal.ui.actions; - -import java.util.ArrayList; - -import org.eclipse.cdt.core.model.CoreModel; -import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; -import org.eclipse.cdt.core.settings.model.ICProjectDescription; -import org.eclipse.cdt.ui.CUIPlugin; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IncrementalProjectBuilder; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.internal.ide.actions.BuildUtilities; - -/** - * Action which builds all configurations of the selected projects - */ -public class BuildAllConfigurationsAction implements IObjectActionDelegate { - private ArrayList<IProject> projects = null; - - @Override - public void selectionChanged(IAction action, ISelection selection) { - projects = CleanAndBuildAction.getSelectedCdtProjects(selection); - action.setEnabled(projects.size() > 0); - } - - @Override - public void run(IAction action) { - // Setup the global build console - CUIPlugin.getDefault().startGlobalConsole(); - - for (IProject project : projects) { - ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(project, false); - if (prjd != null) { - ICConfigurationDescription[] cfgds = prjd.getConfigurations(); - if (cfgds != null && cfgds.length > 0) { - // save all dirty editors - BuildUtilities.saveEditors(null); - - Job buildFilesJob = new BuildConfigurationsJob(cfgds, 0, IncrementalProjectBuilder.INCREMENTAL_BUILD); - buildFilesJob.schedule(); - } - } - - } - } - - @Override - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - } -} diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/CleanAllConfigurationsAction.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/CleanAllConfigurationsAction.java deleted file mode 100644 index 13b2c60c7f2..00000000000 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/CleanAllConfigurationsAction.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2010 Andrew Gvozdev and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Andrew Gvozdev (Quoin Inc.) - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.managedbuilder.internal.ui.actions; - -import java.util.ArrayList; - -import org.eclipse.cdt.core.model.CoreModel; -import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; -import org.eclipse.cdt.core.settings.model.ICProjectDescription; -import org.eclipse.cdt.ui.CUIPlugin; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IncrementalProjectBuilder; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.internal.ide.actions.BuildUtilities; - -/** - * Action which cleans all configurations of the selected projects - */ -public class CleanAllConfigurationsAction implements IObjectActionDelegate { - private ArrayList<IProject> projects = null; - - @Override - public void selectionChanged(IAction action, ISelection selection) { - projects = CleanAndBuildAction.getSelectedCdtProjects(selection); - action.setEnabled(projects.size() > 0); - } - - @Override - public void run(IAction action) { - // Setup the global build console - CUIPlugin.getDefault().startGlobalConsole(); - - for (IProject project : projects) { - ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(project, false); - if (prjd != null) { - ICConfigurationDescription[] cfgds = prjd.getConfigurations(); - if (cfgds != null && cfgds.length > 0) { - // save all dirty editors - BuildUtilities.saveEditors(null); - - Job buildFilesJob = new BuildConfigurationsJob(cfgds, IncrementalProjectBuilder.CLEAN_BUILD, 0); - buildFilesJob.schedule(); - } - } - - } - } - - @Override - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - } -} diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/CleanAndBuildAction.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/CleanAndBuildAction.java deleted file mode 100644 index d643ed8c47a..00000000000 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/CleanAndBuildAction.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2010 Andrew Gvozdev and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Andrew Gvozdev (Quoin Inc.) - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.managedbuilder.internal.ui.actions; - -import java.util.ArrayList; - -import org.eclipse.cdt.core.model.CoreModel; -import org.eclipse.cdt.core.model.ICProject; -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPart; - -/** - * Action which cleans and rebuilds selected configurations. User selects - * which configurations to rebuild via {@link CleanAndBuildDialog}. - */ -public class CleanAndBuildAction implements IObjectActionDelegate { - private ArrayList<IProject> projects = null; - - @Override - public void run(IAction action) { - if (projects!=null) { - CleanAndBuildDialog dialog = new CleanAndBuildDialog(projects.toArray(new IProject[projects.size()])); - dialog.open(); - } - } - - @Override - public void selectionChanged(IAction action, ISelection selection) { - projects = getSelectedCdtProjects(selection); - action.setEnabled(projects.size() > 0); - } - - - @Override - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - } - - /** - * @return list of CDT projects from the selection. - * - * @param selection - selected items. - */ - public static ArrayList<IProject> getSelectedCdtProjects(ISelection selection) { - ArrayList<IProject> projects = new ArrayList<IProject>(); - - if (!selection.isEmpty() && selection instanceof IStructuredSelection) { - Object[] selected = ((IStructuredSelection)selection).toArray(); - if (selected.length > 0) { - for (Object sel : selected) { - IProject prj = null; - if (sel instanceof IProject) - prj = (IProject)sel; - else if (sel instanceof ICProject) - prj = ((ICProject)sel).getProject(); - - if (prj != null && CoreModel.getDefault().isNewStyleProject(prj)) { - projects.add(prj); - } - } - } - } - return projects; - } - - -} diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/commands/BuildAllConfigurationsHandler.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/commands/BuildAllConfigurationsHandler.java new file mode 100644 index 00000000000..94049acc823 --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/commands/BuildAllConfigurationsHandler.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright (c) 2010, 2010 Andrew Gvozdev and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andrew Gvozdev (Quoin Inc.) - initial API and implementation + * Sergey Prigogin (Google) + *******************************************************************************/ +package org.eclipse.cdt.managedbuilder.internal.ui.commands; + +import java.util.List; + +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.cdt.core.settings.model.ICProjectDescription; +import org.eclipse.cdt.internal.ui.util.AbstractResourceActionHandler; +import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IncrementalProjectBuilder; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.ui.internal.ide.actions.BuildUtilities; + +/** + * Implementation of the command that builds all configurations of the selected projects. + */ +public class BuildAllConfigurationsHandler extends AbstractResourceActionHandler { + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + List<IProject> projects = + RebuildConfigurationsHandler.getSelectedCdtProjects(getSelection(event)); + if (!projects.isEmpty()) { + // Setup the global build console. + CUIPlugin.getDefault().startGlobalConsole(); + + for (IProject project : projects) { + ICProjectDescription projectDescription = + CoreModel.getDefault().getProjectDescription(project, false); + if (projectDescription != null) { + ICConfigurationDescription[] cfgds = projectDescription.getConfigurations(); + if (cfgds != null && cfgds.length > 0) { + // Save all dirty editors. + BuildUtilities.saveEditors(null); + + Job buildJob = + new BuildConfigurationsJob(cfgds, 0, IncrementalProjectBuilder.INCREMENTAL_BUILD); + buildJob.schedule(); + } + } + } + } + return null; + } + + @Override + public void setEnabled(Object evaluationContext) { + super.setEnabled(evaluationContext); + setBaseEnabled(!RebuildConfigurationsHandler.getSelectedCdtProjects(getSelection()).isEmpty()); + } +} diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/BuildConfigurationsJob.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/commands/BuildConfigurationsJob.java index 71e724646f0..414e0136a9b 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/BuildConfigurationsJob.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/commands/BuildConfigurationsJob.java @@ -8,12 +8,11 @@ * Contributors: * Andrew Gvozdev (Quoin Inc) - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.managedbuilder.internal.ui.actions; +package org.eclipse.cdt.managedbuilder.internal.ui.commands; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; -import org.eclipse.cdt.managedbuilder.internal.ui.Messages; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.core.resources.IncrementalProjectBuilder; import org.eclipse.core.resources.ResourcesPlugin; @@ -38,10 +37,10 @@ public class BuildConfigurationsJob extends Job { String firstConfigurationName = cfgDescriptions[0].getName(); if (isCleaning) { return MessageFormat.format(Messages.BuildConfigurationsJob_Cleaning, - new Object[] {""+cfgDescriptions.length, firstProjectName, firstConfigurationName}); //$NON-NLS-1$ + new Object[] { cfgDescriptions.length, firstProjectName, firstConfigurationName }); } else { return MessageFormat.format(Messages.BuildConfigurationsJob_Building, - new Object[] {""+cfgDescriptions.length, firstProjectName, firstConfigurationName}); //$NON-NLS-1$ + new Object[] { cfgDescriptions.length, firstProjectName, firstConfigurationName }); } } @@ -56,30 +55,27 @@ public class BuildConfigurationsJob extends Job { * {@link IncrementalProjectBuilder#AUTO_BUILD} */ public BuildConfigurationsJob(ICConfigurationDescription[] cfgDescriptions, int cleanKind, int buildKind) { - super(composeJobName(cfgDescriptions, buildKind==0)); + super(composeJobName(cfgDescriptions, buildKind == 0)); this.cfgDescriptions = cfgDescriptions; this.cleanKind = cleanKind; this.buildKind = buildKind; } - /* (non-Javadoc) - * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) - */ @Override protected IStatus run(IProgressMonitor monitor) { // Setup the global build console CUIPlugin.getDefault().startGlobalConsole(); IConfiguration[] cfgs = new IConfiguration[cfgDescriptions.length]; - for (int i=0; i<cfgDescriptions.length; i++) { + for (int i= 0; i < cfgDescriptions.length; i++) { cfgs[i] = ManagedBuildManager.getConfigurationForDescription(cfgDescriptions[i]); } try { - if (cleanKind==IncrementalProjectBuilder.CLEAN_BUILD) { + if (cleanKind == IncrementalProjectBuilder.CLEAN_BUILD) { ManagedBuildManager.buildConfigurations(cfgs, null, monitor, true, cleanKind); } - if (buildKind!=0) { + if (buildKind != 0) { ManagedBuildManager.buildConfigurations(cfgs, null, monitor, true, buildKind); } } catch (CoreException e) { @@ -92,9 +88,6 @@ public class BuildConfigurationsJob extends Job { return Status.OK_STATUS; } - /* (non-Javadoc) - * @see org.eclipse.core.runtime.jobs.Job#belongsTo(java.lang.Object) - */ @Override public boolean belongsTo(Object family) { return ResourcesPlugin.FAMILY_MANUAL_BUILD == family; diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/BuildFilesHandler.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/commands/BuildFilesHandler.java index 0d63e5bf3ca..3371e6f5b7a 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/BuildFilesHandler.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/commands/BuildFilesHandler.java @@ -9,7 +9,7 @@ * Texas Instruments - initial API and implementation * Sergey Prigogin (Google) *******************************************************************************/ -package org.eclipse.cdt.managedbuilder.internal.ui.actions; +package org.eclipse.cdt.managedbuilder.internal.ui.commands; import java.util.ArrayList; import java.util.Collection; diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/commands/CleanAllConfigurationsHandler.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/commands/CleanAllConfigurationsHandler.java new file mode 100644 index 00000000000..7ee4d7bf2e6 --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/commands/CleanAllConfigurationsHandler.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright (c) 2010, 2010 Andrew Gvozdev and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andrew Gvozdev (Quoin Inc.) - initial API and implementation + * Sergey Prigogin (Google) + *******************************************************************************/ +package org.eclipse.cdt.managedbuilder.internal.ui.commands; + +import java.util.List; + +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.cdt.core.settings.model.ICProjectDescription; +import org.eclipse.cdt.internal.ui.util.AbstractResourceActionHandler; +import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IncrementalProjectBuilder; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.ui.internal.ide.actions.BuildUtilities; + +/** + * Implementation of the command that cleans all configurations of the selected projects. + */ +public class CleanAllConfigurationsHandler extends AbstractResourceActionHandler { + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + List<IProject> projects = + RebuildConfigurationsHandler.getSelectedCdtProjects(getSelection(event)); + if (!projects.isEmpty()) { + // Setup the global build console. + CUIPlugin.getDefault().startGlobalConsole(); + + for (IProject project : projects) { + ICProjectDescription projectDescription = + CoreModel.getDefault().getProjectDescription(project, false); + if (projectDescription != null) { + ICConfigurationDescription[] cfgds = projectDescription.getConfigurations(); + if (cfgds != null && cfgds.length > 0) { + // Save all dirty editors. + BuildUtilities.saveEditors(null); + + Job buildJob = + new BuildConfigurationsJob(cfgds, IncrementalProjectBuilder.CLEAN_BUILD, 0); + buildJob.schedule(); + } + } + } + } + return null; + } + + @Override + public void setEnabled(Object evaluationContext) { + super.setEnabled(evaluationContext); + setBaseEnabled(!RebuildConfigurationsHandler.getSelectedCdtProjects(getSelection()).isEmpty()); + } +} diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/CleanFilesHandler.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/commands/CleanFilesHandler.java index 37074ee9126..c77ce6141b0 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/CleanFilesHandler.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/commands/CleanFilesHandler.java @@ -9,7 +9,7 @@ * Texas Instruments - initial API and implementation * Sergey Prigogin (Google) *******************************************************************************/ -package org.eclipse.cdt.managedbuilder.internal.ui.actions; +package org.eclipse.cdt.managedbuilder.internal.ui.commands; import java.util.ArrayList; import java.util.Collection; diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/ConvertTargetDialog.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/commands/ConvertTargetDialog.java index 812220e1b3a..350f1f4d0d8 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/ConvertTargetDialog.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/commands/ConvertTargetDialog.java @@ -10,7 +10,7 @@ * Anna Dushistova (MontaVista) - [366771] Converter fails to convert a CDT makefile project * Sergey Prigogin (Google) *******************************************************************************/ -package org.eclipse.cdt.managedbuilder.internal.ui.actions; +package org.eclipse.cdt.managedbuilder.internal.ui.commands; import java.util.ArrayList; import java.util.HashMap; diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/ConvertTargetHandler.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/commands/ConvertTargetHandler.java index 8c45bef2e17..db250011f8c 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/ConvertTargetHandler.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/commands/ConvertTargetHandler.java @@ -10,7 +10,7 @@ * Anna Dushistova (MontaVista) - [366771] Converter fails to convert a CDT makefile project * Sergey Prigogin (Google) *******************************************************************************/ -package org.eclipse.cdt.managedbuilder.internal.ui.actions; +package org.eclipse.cdt.managedbuilder.internal.ui.commands; import java.util.ArrayList; import java.util.List; diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/Messages.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/commands/Messages.java index 313b1070c65..92e74a5d766 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/Messages.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/commands/Messages.java @@ -10,13 +10,21 @@ * IBM Corporation * Sergey Prigogin (Google) *******************************************************************************/ -package org.eclipse.cdt.managedbuilder.internal.ui.actions; +package org.eclipse.cdt.managedbuilder.internal.ui.commands; import org.eclipse.osgi.util.NLS; class Messages extends NLS { + public static String BuildConfigurationsJob_BuildError; + public static String BuildConfigurationsJob_Building; + public static String BuildConfigurationsJob_Cleaning; public static String BuildFilesHandler_buildingSelectedFiles; public static String CleanFilesHandler_cleaningFiles; + public static String RebuildConfigurationsDialog_Active; + public static String RebuildConfigurationsDialog_BuildConfigurations; + public static String RebuildConfigurationsDialog_CleanConfigurations; + public static String RebuildConfigurationsDialog_RebuildConfigurations; + public static String RebuildConfigurationsDialog_SelectConfigurations; public static String ConvertTargetHandler_No_Converter; public static String ProjectConvert_noConverterErrorDialog_message; public static String ProjectConvert_title; diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/Messages.properties b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/commands/Messages.properties index 5f20f5f6693..aa1223fd6e1 100755 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/Messages.properties +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/commands/Messages.properties @@ -11,10 +11,20 @@ # Sergey Prigogin (Google) ############################################################################### +BuildConfigurationsJob_BuildError=Build error +BuildConfigurationsJob_Building=Building {1}[{2}], ... [{0}] +BuildConfigurationsJob_Cleaning=Cleaning {1}[{2}], ... [{0}] + BuildFilesHandler_buildingSelectedFiles=Building Selected Files CleanFilesHandler_cleanSelectedFiles=Cleaning Selected Files CleanFilesHandler_cleaningFiles=Cleaning files +RebuildConfigurationsDialog_Active=[Active] +RebuildConfigurationsDialog_BuildConfigurations=Build selected configurations +RebuildConfigurationsDialog_CleanConfigurations=Clean selected configurations +RebuildConfigurationsDialog_RebuildConfigurations=Clean and Rebuild Configurations +RebuildConfigurationsDialog_SelectConfigurations=Select configurations to rebuild. + # Project Conversion Dialog messages ProjectConvert_conversionErrordialog_title=Project Conversion Error ProjectConvert_conversionErrordialog_message=Error has occurred during the conversion of the project {0} . diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/ProjectPropertyTester.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/commands/ProjectPropertyTester.java index 5f13d48f9a2..4ec9a105137 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/ProjectPropertyTester.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/commands/ProjectPropertyTester.java @@ -8,7 +8,7 @@ * Contributors: * Sergey Prigogin (Google) - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.managedbuilder.internal.ui.actions; +package org.eclipse.cdt.managedbuilder.internal.ui.commands; import org.eclipse.core.expressions.PropertyTester; import org.eclipse.core.resources.IProject; diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/CleanAndBuildDialog.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/commands/RebuildConfigurationsDialog.java index 26d2de9de13..372447b5b7b 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/CleanAndBuildDialog.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/commands/RebuildConfigurationsDialog.java @@ -8,7 +8,7 @@ * Contributors: * Andrew Gvozdev (Quoin Inc.) - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.managedbuilder.internal.ui.actions; +package org.eclipse.cdt.managedbuilder.internal.ui.commands; import java.util.ArrayList; import java.util.List; @@ -16,7 +16,6 @@ import java.util.List; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescription; -import org.eclipse.cdt.managedbuilder.internal.ui.Messages; import org.eclipse.cdt.managedbuilder.ui.properties.ManagedBuilderUIImages; import org.eclipse.cdt.managedbuilder.ui.properties.ManagedBuilderUIPlugin; import org.eclipse.cdt.ui.CUIPlugin; @@ -51,7 +50,7 @@ import org.eclipse.ui.model.WorkbenchLabelProvider; /** * Dialog to let the user to clean and rebuild configurations of the selected projects. */ -public class CleanAndBuildDialog extends MessageDialog { +public class RebuildConfigurationsDialog extends MessageDialog { private static final String DIALOG_SETTINGS_SECTION = "RebuildConfigurationsDialogSettings"; //$NON-NLS-1$ private static final String DIALOG_ORIGIN_X = "DIALOG_X_ORIGIN"; //$NON-NLS-1$ private static final String DIALOG_ORIGIN_Y = "DIALOG_Y_ORIGIN"; //$NON-NLS-1$ @@ -68,8 +67,7 @@ public class CleanAndBuildDialog extends MessageDialog { private int cleanKind; private int buildKind; - - private class ConfigurationLabelProvider implements ILabelProvider { + private static class ConfigurationLabelProvider implements ILabelProvider { WorkbenchLabelProvider workbenchLabelProvider = new WorkbenchLabelProvider(); @Override @@ -105,7 +103,7 @@ public class CleanAndBuildDialog extends MessageDialog { ICConfigurationDescription cfgDescription = (ICConfigurationDescription) element; String name = cfgDescription.getName(); if (cfgDescription.isActive()) { - return name + ' ' + Messages.CleanAndBuildDialog_Active; + return name + ' ' + Messages.RebuildConfigurationsDialog_Active; } return name; } @@ -115,31 +113,19 @@ public class CleanAndBuildDialog extends MessageDialog { } private class ConfigurationContentProvider implements ITreeContentProvider { - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) - */ @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IContentProvider#dispose() - */ @Override public void dispose() { } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) - */ @Override public Object[] getElements(Object inputElement) { return getChildren(inputElement); } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object) - */ @Override public boolean hasChildren(Object element) { if (element instanceof IProject[]) @@ -157,9 +143,6 @@ public class CleanAndBuildDialog extends MessageDialog { return false; } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object) - */ @Override public Object getParent(Object element) { if (element instanceof IProject) { @@ -172,9 +155,6 @@ public class CleanAndBuildDialog extends MessageDialog { return null; } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object) - */ @Override public Object[] getChildren(Object parentElement) { if (parentElement instanceof IProject[]) @@ -197,19 +177,14 @@ public class CleanAndBuildDialog extends MessageDialog { * * @param projects - the currently selected projects */ - public CleanAndBuildDialog(IProject[] projects) { - super(CUIPlugin.getActiveWorkbenchShell(), Messages.CleanAndBuildDialog_RebuildConfigurations, null, - Messages.CleanAndBuildDialog_SelectConfigurations, NONE, + public RebuildConfigurationsDialog(IProject[] projects) { + super(CUIPlugin.getActiveWorkbenchShell(), Messages.RebuildConfigurationsDialog_RebuildConfigurations, null, + Messages.RebuildConfigurationsDialog_SelectConfigurations, NONE, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0); this.projects = projects; } - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int) - */ @Override protected void buttonPressed(int buttonId) { super.buttonPressed(buttonId); @@ -217,30 +192,26 @@ public class CleanAndBuildDialog extends MessageDialog { return; } - // save all dirty editors + // Save all dirty editors. BuildUtilities.saveEditors(null); - if (selected!=null) { - List<ICConfigurationDescription> cfgDescriptions = new ArrayList<ICConfigurationDescription>(); + if (selected != null) { + List<ICConfigurationDescription> cfgDescriptions = new ArrayList<>(); for (Object sel : selected) { if (sel instanceof ICConfigurationDescription) { cfgDescriptions.add((ICConfigurationDescription)sel); } } - if (cleanKind!=0 || buildKind!=0) { - ICConfigurationDescription[] cfgdArray = cfgDescriptions.toArray(new ICConfigurationDescription[cfgDescriptions.size()]); + if (cleanKind != 0 || buildKind != 0) { + ICConfigurationDescription[] cfgdArray = + cfgDescriptions.toArray(new ICConfigurationDescription[cfgDescriptions.size()]); Job buildJob = new BuildConfigurationsJob(cfgdArray, cleanKind, buildKind); buildJob.schedule(); } } } - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.dialogs.MessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite) - */ @Override protected Control createCustomArea(Composite parent) { Composite area = new Composite(parent, SWT.NONE); @@ -257,19 +228,19 @@ public class CleanAndBuildDialog extends MessageDialog { } }; - // second row + // Second row. createProjectSelectionTable(area); - // third row + // Third row. cleanCheckbox = new Button(parent, SWT.CHECK); - cleanCheckbox.setText(Messages.CleanAndBuildDialog_CleanConfigurations); + cleanCheckbox.setText(Messages.RebuildConfigurationsDialog_CleanConfigurations); cleanCheckbox.setSelection(true); cleanCheckbox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); cleanCheckbox.addSelectionListener(updateEnablement); cleanKind = cleanCheckbox.getSelection() ? IncrementalProjectBuilder.CLEAN_BUILD : 0; buildCheckbox = new Button(parent, SWT.CHECK); - buildCheckbox.setText(Messages.CleanAndBuildDialog_BuildConfigurations); + buildCheckbox.setText(Messages.RebuildConfigurationsDialog_BuildConfigurations); buildCheckbox.setSelection(true); buildCheckbox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); buildCheckbox.addSelectionListener(updateEnablement); @@ -289,7 +260,7 @@ public class CleanAndBuildDialog extends MessageDialog { data.heightHint = IDialogConstants.ENTRY_FIELD_WIDTH; cfgCheckboxViewer.getControl().setLayoutData(data); - ArrayList<ICConfigurationDescription> initialSelection = new ArrayList<ICConfigurationDescription>(projects.length); + List<ICConfigurationDescription> initialSelection = new ArrayList<>(projects.length); for (IProject prj : projects) { ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(prj, false); if (prjd == null) @@ -310,42 +281,27 @@ public class CleanAndBuildDialog extends MessageDialog { } /** - * Updates the enablement of the dialog's ok button based on the current choices in the dialog. + * Updates the enablement of the dialog's OK button based on the current choices in the dialog. */ protected void updateEnablement() { cleanKind = cleanCheckbox.getSelection() ? IncrementalProjectBuilder.CLEAN_BUILD : 0; buildKind = buildCheckbox.getSelection() ? IncrementalProjectBuilder.INCREMENTAL_BUILD : 0; - boolean enabled = cfgCheckboxViewer.getCheckedElements().length>0 && (cleanKind!=0 || buildKind!=0); + boolean enabled = cfgCheckboxViewer.getCheckedElements().length > 0 && (cleanKind != 0 || buildKind != 0); getButton(OK).setEnabled(enabled); } - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.window.Window#close() - */ @Override public boolean close() { persistDialogSettings(getShell(), DIALOG_SETTINGS_SECTION); return super.close(); } - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.window.Window#getInitialLocation(org.eclipse.swt.graphics.Point) - */ @Override protected Point getInitialLocation(Point initialSize) { Point p = getInitialLocation(DIALOG_SETTINGS_SECTION); return p != null ? p : super.getInitialLocation(initialSize); } - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.window.Window#getInitialSize() - */ @Override protected Point getInitialSize() { Point p = super.getInitialSize(); @@ -353,9 +309,9 @@ public class CleanAndBuildDialog extends MessageDialog { } /** - * Returns the initial location which is persisted in the IDE Plugin dialog settings under the provided - * dialog settings section name. If location is not persisted in the settings, the {@code null} is - * returned. + * Returns the initial location which is persisted in the IDE Plugin dialog settings under + * the provided dialog settings section name. If location is not persisted in the settings, + * the {@code null} is returned. * * @param dialogSettingsSectionName - The name of the dialog settings section * @return The initial location or {@code null} @@ -381,8 +337,8 @@ public class CleanAndBuildDialog extends MessageDialog { } /** - * Persists the location and dimensions of the shell and other user settings in the plugin's dialog - * settings under the provided dialog settings section name + * Persists the location and dimensions of the shell and other user settings in the plugin's + * dialog settings under the provided dialog settings section name. * * @param shell - The shell whose geometry is to be stored * @param dialogSettingsSectionName - The name of the dialog settings section @@ -398,9 +354,9 @@ public class CleanAndBuildDialog extends MessageDialog { } /** - * Returns the initial size which is the larger of the <code>initialSize</code> or the size persisted in - * the IDE UI Plugin dialog settings under the provided dialog setttings section name. If no size is - * persisted in the settings, the {@code initialSize} is returned. + * Returns the initial size which is the larger of the {@code initialSize} or the size + * persisted in the IDE UI Plugin dialog settings under the provided dialog settings section + * name. If no size is persisted in the settings, the {@code initialSize} is returned. * * @param initialSize - The initialSize to compare against * @param dialogSettingsSectionName - The name of the dialog settings section @@ -418,11 +374,6 @@ public class CleanAndBuildDialog extends MessageDialog { return initialSize; } - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.dialogs.Dialog#isResizable() - */ @Override protected boolean isResizable() { return true; diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/commands/RebuildConfigurationsHandler.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/commands/RebuildConfigurationsHandler.java new file mode 100644 index 00000000000..00ba772f8fb --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/commands/RebuildConfigurationsHandler.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright (c) 2010, 2010 Andrew Gvozdev and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andrew Gvozdev (Quoin Inc.) - initial API and implementation + * Sergey Prigogin (Google) + *******************************************************************************/ +package org.eclipse.cdt.managedbuilder.internal.ui.commands; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.internal.ui.util.AbstractResourceActionHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.resources.IProject; +import org.eclipse.jface.viewers.IStructuredSelection; + +/** + * Implementation of the command that cleans and rebuilds selected configurations. + * User selects which configurations to rebuild via {@link RebuildConfigurationsDialog}. + */ +public class RebuildConfigurationsHandler extends AbstractResourceActionHandler { + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + List<IProject> projects = getSelectedCdtProjects(getSelection(event)); + if (!projects.isEmpty()) { + RebuildConfigurationsDialog dialog = + new RebuildConfigurationsDialog(projects.toArray(new IProject[projects.size()])); + dialog.open(); + } + return null; + } + + @Override + public void setEnabled(Object evaluationContext) { + super.setEnabled(evaluationContext); + setBaseEnabled(!RebuildConfigurationsHandler.getSelectedCdtProjects(getSelection()).isEmpty()); + } + + /** + * Returns a list of CDT projects from the selection. + */ + public static List<IProject> getSelectedCdtProjects(IStructuredSelection selection) { + if (selection.isEmpty()) + return Collections.emptyList(); + + List<IProject> projects = new ArrayList<>(); + + for (Object element : selection.toArray()) { + IProject project = null; + if (element instanceof IProject) { + project = (IProject) element; + } else if (element instanceof ICProject) { + project = ((ICProject) element).getProject(); + } + + if (project != null && CoreModel.getDefault().isNewStyleProject(project)) { + projects.add(project); + } + } + return projects; + } +} |