1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 18:26:01 +02:00

bug 230185 comment #16 patch: add to project a popup menu to clean all / selected configurations

This commit is contained in:
Andrew Gvozdev 2010-04-14 13:30:11 +00:00
parent f20d66d319
commit 1fe815d140
14 changed files with 922 additions and 472 deletions

View file

@ -4586,65 +4586,68 @@ public class ManagedBuildManager extends AbstractCExtension {
return new Configuration[0];
}
/**
* Build the specified build configurations
* @param configs - configurations to build
* @param monitor - progress monitor
* @throws CoreException
*/
public static void buildConfigurations(IConfiguration[] configs, IProgressMonitor monitor) throws CoreException{
buildConfigurations(configs, null, monitor);
}
/**
* Build the specified build configurations
* @param configs - configurations to build
* @param builder - builder to retrieve build arguments
* @param monitor - progress monitor
* @throws CoreException
*/
public static void buildConfigurations(IConfiguration[] configs, IBuilder builder, IProgressMonitor monitor) throws CoreException{
buildConfigurations(configs, builder, monitor, true);
}
/**
* Build the specified build configurations.
*
* @param configs - configurations to build
* @param builder - builder to retrieve build arguments
* @param monitor - progress monitor
* @param allBuilders - {@code true} if all builders need to be building
* or {@code false} to build with {@link CommonBuilder}
*
* @throws CoreException
*/
public static void buildConfigurations(IConfiguration[] configs, IBuilder builder, IProgressMonitor monitor, boolean allBuilders) throws CoreException{
buildOrCleanConfigurations(configs, builder, monitor, allBuilders, IncrementalProjectBuilder.FULL_BUILD);
buildConfigurations(configs, builder, monitor, allBuilders, IncrementalProjectBuilder.FULL_BUILD);
}
/**
* Clean the specified build configurations
* @param configs
* @param monitor
* Build the specified build configurations.
*
* @param configs - configurations to build
* @param builder - builder to retrieve build arguments
* @param monitor - progress monitor
* @param allBuilders - {@code true} if all builders need to be building
* or {@code false} to build with {@link CommonBuilder}
* @param buildKind - one of
* <li>{@link IncrementalProjectBuilder#CLEAN_BUILD}</li>
* <li>{@link IncrementalProjectBuilder#INCREMENTAL_BUILD}</li>
* <li>{@link IncrementalProjectBuilder#FULL_BUILD}</li>
*
* @throws CoreException
*
* @since 7.0
*/
public static void cleanConfigurations(IConfiguration[] configs, IProgressMonitor monitor) throws CoreException{
cleanConfigurations(configs, null, monitor);
}
public static void buildConfigurations(IConfiguration[] configs, IBuilder builder, IProgressMonitor monitor,
boolean allBuilders, int buildKind) throws CoreException{
/**
* Clean the specified build configurations using the given builder
* @param configs
* @param builder
* @param monitor
* @throws CoreException
* @since 7.0
*/
public static void cleanConfigurations(IConfiguration[] configs, IBuilder builder, IProgressMonitor monitor) throws CoreException{
cleanConfigurations(configs, builder, monitor, true);
}
/**
* Clean the specified configurations
* @param configs
* @param builder
* @param monitor
* @param allBuilders
* @throws CoreException
* @since 7.0
*/
public static void cleanConfigurations(IConfiguration[] configs, IBuilder builder, IProgressMonitor monitor, boolean allBuilders) throws CoreException{
buildOrCleanConfigurations(configs, builder, monitor, allBuilders, IncrementalProjectBuilder.CLEAN_BUILD);
}
private static void buildOrCleanConfigurations(IConfiguration[] configs, IBuilder builder, IProgressMonitor monitor, boolean allBuilders, int buildKind) throws CoreException{
Map map = sortConfigs(configs);
for(Iterator iter = map.entrySet().iterator(); iter.hasNext();){
Map.Entry entry = (Map.Entry)iter.next();
IProject proj = (IProject)entry.getKey();
IConfiguration[] cfgs = (IConfiguration[])entry.getValue();
if(buildKind == IncrementalProjectBuilder.CLEAN_BUILD) {
cleanConfigurations(proj, cfgs, builder, monitor, allBuilders);
} else {
buildConfigurations(proj, cfgs, builder, monitor, allBuilders);
}
buildConfigurations(proj, cfgs, builder, monitor, allBuilders, buildKind);
}
}
@ -4673,83 +4676,99 @@ public class ManagedBuildManager extends AbstractCExtension {
return cfgMap;
}
private static void buildConfigurations(final IProject project, IConfiguration[] configs, IBuilder builder, final IProgressMonitor monitor, boolean allBuilders) throws CoreException{
final boolean runAllBuidlers = allBuilders;
final Map map = builder != null ?
BuilderFactory.createBuildArgs(configs, builder)
: BuilderFactory.createBuildArgs(configs);
/**
* Build the specified build configurations for a given project.
*
* @param project - project the configurations belong to
* @param configs - configurations to build
* @param builder - builder to retrieve build arguments
* @param monitor - progress monitor
* @param allBuilders - {@code true} if all builders need to be building
* or {@code false} to build with {@link CommonBuilder}
* @param buildKind - one of
* <li>{@link IncrementalProjectBuilder#CLEAN_BUILD}</li>
* <li>{@link IncrementalProjectBuilder#INCREMENTAL_BUILD}</li>
* <li>{@link IncrementalProjectBuilder#FULL_BUILD}</li>
*
* @throws CoreException
*/
private static void buildConfigurations(final IProject project, final IConfiguration[] configs,
final IBuilder builder, final IProgressMonitor monitor, final boolean allBuilders, final int buildKind) throws CoreException{
IWorkspaceRunnable op = new IWorkspaceRunnable() {
/*
* (non-Javadoc)
*
* @see org.eclipse.core.resources.IWorkspaceRunnable#run(org.eclipse.core.runtime.IProgressMonitor)
*/
public void run(IProgressMonitor monitor) throws CoreException {
if (runAllBuidlers) {
ICommand[] commands = project.getDescription().getBuildSpec();
monitor.beginTask("", commands.length); //$NON-NLS-1$
for (int i = 0; i < commands.length; i++) {
Map newArgs = map;
if (!commands[i].getBuilderName().equals(CommonBuilder.BUILDER_ID)) {
newArgs = new HashMap(map);
newArgs.putAll(commands[i].getArguments());
}
project.build(IncrementalProjectBuilder.FULL_BUILD, commands[i].getBuilderName(), newArgs, new SubProgressMonitor(monitor, 1));
int ticks = 1;
if (buildKind==IncrementalProjectBuilder.CLEAN_BUILD) {
if (allBuilders) {
ICommand[] commands = project.getDescription().getBuildSpec();
ticks = commands.length;
}
ticks = ticks*configs.length;
}
monitor.beginTask(project.getName(), ticks);
if (buildKind==IncrementalProjectBuilder.CLEAN_BUILD) {
// It is not possible to pass arguments to clean() method of a builder
// So we iterate setting active configuration
IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(project);
IConfiguration savedCfg = buildInfo.getDefaultConfiguration();
try {
for (IConfiguration config : configs) {
if (monitor.isCanceled())
break;
buildInfo.setDefaultConfiguration(config);
buildProject(project, null, allBuilders, buildKind, monitor);
}
} finally {
buildInfo.setDefaultConfiguration(savedCfg);
}
monitor.done();
} else {
project.build(IncrementalProjectBuilder.FULL_BUILD, CommonBuilder.BUILDER_ID, map, monitor);
// configuration IDs are passed in args to CDT builder
Map args = builder!=null ? BuilderFactory.createBuildArgs(configs, builder)
: BuilderFactory.createBuildArgs(configs);
buildProject(project, args, allBuilders, buildKind, monitor);
}
monitor.done();
}
private void buildProject(IProject project, Map args, boolean allBuilders, int buildKind, IProgressMonitor monitor)
throws CoreException {
if (allBuilders) {
ICommand[] commands = project.getDescription().getBuildSpec();
for (ICommand command : commands) {
if (monitor.isCanceled())
break;
String builderName = command.getBuilderName();
Map newArgs = null;
if (buildKind!=IncrementalProjectBuilder.CLEAN_BUILD) {
newArgs = new HashMap(args);
if (!builderName.equals(CommonBuilder.BUILDER_ID)) {
newArgs.putAll(command.getArguments());
}
}
project.build(buildKind, builderName, newArgs, new SubProgressMonitor(monitor, 1));
}
} else {
project.build(buildKind, CommonBuilder.BUILDER_ID, args, new SubProgressMonitor(monitor, 1));
}
}
};
try {
ResourcesPlugin.getWorkspace().run(op, monitor);
} finally {
monitor.done();
}
}
private static void cleanConfigurations(final IProject project, final IConfiguration[] configs, IBuilder builder, final IProgressMonitor monitor, boolean allBuilders) throws CoreException{
final boolean runAllBuidlers = allBuilders;
final IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(project);
IConfiguration savedCfg = buildInfo.getDefaultConfiguration();
IWorkspaceRunnable op = new IWorkspaceRunnable() {
/*
* (non-Javadoc)
*
* @see org.eclipse.core.resources.IWorkspaceRunnable#run(org.eclipse.core.runtime.IProgressMonitor)
*/
public void run(IProgressMonitor monitor) throws CoreException {
ICommand[] commands = project.getDescription().getBuildSpec();
int totalWork = (runAllBuidlers) ? commands.length * configs.length : configs.length;
// iterate through all configurations and clean them
monitor.beginTask("", totalWork); //$NON-NLS-1$
for (IConfiguration config : configs) {
buildInfo.setDefaultConfiguration(config);
if (runAllBuidlers) {
for (int i = 0; i < commands.length; i++) {
// currently the platform doesn't accept arguments for a builder to clean a project, thus arguments are null
project.build(IncrementalProjectBuilder.CLEAN_BUILD, commands[i].getBuilderName(), null, new SubProgressMonitor(monitor, 1));
}
} else {
project.build(IncrementalProjectBuilder.CLEAN_BUILD, CommonBuilder.BUILDER_ID, null, new SubProgressMonitor(monitor, 1));
}
}
}
};
try {
ResourcesPlugin.getWorkspace().run(op, monitor);
} finally {
// complete the progress monitor and restore default configuration
monitor.done();
buildInfo.setDefaultConfiguration(savedCfg);
}
}
public static IBuilder getInternalBuilder(){

View file

@ -53,6 +53,9 @@ Discovery.options=Discovery Options
Environment=Environment
BuildCfgMenu.label=Build configurations
BuildAllConfigurationsMenu.label=Build All
CleanAllConfigurationsMenu.label=Clean All
RebuildConfigurationsMenu.label=Build Selected...
BuildMenu.label=Build
CleanMenu.label=Clean

View file

@ -85,7 +85,7 @@
menubarPath="additions"
enablesFor="1"
id="org.eclipse.cdt.managedbuilder.ui.ConvertTargetAction">
</action>
</action>
<filter
name="projectNature"
value="org.eclipse.cdt.managedbuilder.core.managedBuildNature">
@ -96,19 +96,23 @@
adaptable="true"
id="org.eclipse.cdt.managedbuilder.ui.popupMenu.BuildAll">
<action
class="org.eclipse.cdt.managedbuilder.internal.ui.actions.CleanAllAction"
class="org.eclipse.cdt.managedbuilder.ui.actions.CleanAndBuildAction"
enablesFor="+"
id="org.eclipse.cdt.managedbuilder.ui.cleanAllAction"
label="%CleanMenu.label"
menubarPath="org.eclipse.cdt.ui.cfgmenu/gm1"
style="pulldown"/>
id="org.eclipse.cdt.managedbuilder.ui.rebuildConfigurationsAction"
label="%RebuildConfigurationsMenu.label"
menubarPath="org.eclipse.cdt.ui.cfgmenu/gm1"/>
<action
class="org.eclipse.cdt.managedbuilder.ui.actions.BuildAllAction"
class="org.eclipse.cdt.managedbuilder.ui.actions.CleanAllConfigurationsAction"
enablesFor="+"
id="org.eclipse.cdt.managedbuilder.ui.buildAllAction1"
label="%BuildMenu.label"
menubarPath="org.eclipse.cdt.ui.cfgmenu/gm1"
style="pulldown"/>
id="org.eclipse.cdt.managedbuilder.ui.cleanAllConfigurationsAction"
label="%CleanAllConfigurationsMenu.label"
menubarPath="org.eclipse.cdt.ui.cfgmenu/gm1"/>
<action
class="org.eclipse.cdt.managedbuilder.ui.actions.BuildAllConfigurationsAction"
enablesFor="+"
id="org.eclipse.cdt.managedbuilder.ui.buildAllConfigurationsAction"
label="%BuildAllConfigurationsMenu.label"
menubarPath="org.eclipse.cdt.ui.cfgmenu/gm1"/>
<visibility>
<objectState
name="projectNature"

View file

@ -1,50 +0,0 @@
/*******************************************************************************
* Copyright (c) 2007, 2010 Intel Corporation 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:
* Intel Corporation - initial API and implementation
* LSI Corporation - added symmetric project clean action
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.ui.actions;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.ui.properties.Messages;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
/**
* Action which changes active build configuration of the current project to
* the given one.
*
* @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
* @since 7.0
*/
public class CleanAllAction extends CommonBuildCleanAllAction {
@Override
protected String getTIP_ALL() { return Messages.getString("CleanAllAction.0");}//$NON-NLS-1$
@Override
protected String getLBL_ALL() { return Messages.getString("CleanAllAction.1");}//$NON-NLS-1$
@Override
protected String getJOB_MSG() { return Messages.getString("CleanAllAction.2");}//$NON-NLS-1$
@Override
protected String getERR_MSG() { return Messages.getString("CleanAllAction.3");}//$NON-NLS-1$
@Override
protected String getLBL_SEL() { return Messages.getString("CleanAllAction.4");}//$NON-NLS-1$
@Override
protected String getTIP_SEL() { return Messages.getString("CleanAllAction.5");}//$NON-NLS-1$
@Override
protected String getDLG_TEXT(){ return Messages.getString("CleanAllAction.6"); }//$NON-NLS-1$
@Override
protected String getDLG_TITLE(){ return Messages.getString("CleanAllAction.7");}//$NON-NLS-1$
@Override
protected void performAction(IConfiguration[] configs,
IProgressMonitor monitor) throws CoreException {
ManagedBuildManager.cleanConfigurations(configs, monitor);
}
}

View file

@ -1,237 +0,0 @@
/*******************************************************************************
* Copyright (c) 2007, 2010 Intel Corporation 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:
* Intel Corporation - initial API and implementation
* LSI Corporation - added symmetric project clean action
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.ui.actions;
import java.util.ArrayList;
import java.util.Iterator;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.resources.IProject;
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.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuCreator;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2;
import org.eclipse.ui.actions.ActionDelegate;
import org.eclipse.ui.dialogs.ListSelectionDialog;
/**
* Abstract action which builds or cleans the build configurations of the current project.
*
* @noextend This class is not intended to be subclassed by clients.
* @since 7.0
*/
public abstract class CommonBuildCleanAllAction extends ActionDelegate implements
IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate, IMenuCreator {
protected ArrayList<IProject> projects = null;
private ActionContributionItem it_all = null;
private ActionContributionItem it_sel = null;
/*
* Get message strings
*/
protected abstract String getTIP_ALL();
protected abstract String getLBL_ALL();
protected abstract String getJOB_MSG();
protected abstract String getERR_MSG();
protected abstract String getLBL_SEL();
protected abstract String getTIP_SEL();
protected abstract String getDLG_TEXT();
protected abstract String getDLG_TITLE();
/**
* Perform the requested build
* @param configs
* @param monitor
* @throws CoreException
*/
protected abstract void performAction(IConfiguration[] configs, IProgressMonitor monitor) throws CoreException;
@Override
public void selectionChanged(IAction action, ISelection selection) {
projects = null;
if (!selection.isEmpty()) {
// case for context menu
if (selection instanceof IStructuredSelection) {
Object[] obs = ((IStructuredSelection)selection).toArray();
if (obs.length > 0) {
for (int i=0; i<obs.length; i++) {
IProject prj = null;
if (obs[i] instanceof IProject)
prj = (IProject)obs[i];
else if (obs[i] instanceof ICProject)
prj = ((ICProject)obs[i]).getProject();
if (prj != null) {
if (!CoreModel.getDefault().isNewStyleProject(prj)) continue;
ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(prj, false);
if (prjd == null) continue;
ICConfigurationDescription[] cfgds = prjd.getConfigurations();
if (cfgds != null && cfgds.length > 0) {
if (projects == null) projects = new ArrayList<IProject>();
projects.add(prj);
}
}
}
}
}
}
action.setEnabled(projects != null);
if (projects != null && it_sel != null)
it_sel.getAction().setEnabled(projects.size() == 1);
action.setMenuCreator(this);
}
@Override
public void run(IAction action) {} // do nothing - show menus only
public void setActivePart(IAction action, IWorkbenchPart targetPart) {}
// doing nothing
public void init(IWorkbenchWindow window) { }
private final class BuildCleanFilesJob extends Job {
Object[] cfs;
BuildCleanFilesJob(Object[] _cfs) {
super(getJOB_MSG() + ((ICConfigurationDescription)_cfs[0]).getProjectDescription().getName());
cfs = _cfs;
}
/* (non-Javadoc)
* @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
protected IStatus run(IProgressMonitor monitor) {
IConfiguration[] cf = new IConfiguration[cfs.length];
for (int i=0; i<cfs.length; i++)
cf[i] = ManagedBuildManager.getConfigurationForDescription((ICConfigurationDescription)cfs[i]);
try {
performAction(cf, monitor);
} catch (CoreException e) {
return new Status(IStatus.ERROR, getERR_MSG(), e.getLocalizedMessage());
}
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
monitor.done();
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;
}
}
public Menu getMenu(Control parent) {
return fillMenu(new Menu(parent));
}
public Menu getMenu(Menu parent) {
return fillMenu(new Menu(parent));
}
protected Menu fillMenu(Menu menu) {
it_all = new ActionContributionItem(new LocalAction(true));
it_sel = new ActionContributionItem(new LocalAction(false));
if (projects != null)
it_sel.getAction().setEnabled(projects.size() == 1);
it_all.fill(menu, -1);
it_sel.fill(menu, -1);
return menu;
}
private class LocalAction extends Action {
boolean forAll;
LocalAction(boolean mode) {
super();
forAll = mode;
setText(forAll ? getLBL_ALL() : getLBL_SEL());
setToolTipText(forAll ? getTIP_ALL() : getTIP_SEL());
}
@Override
public void run() {
if (projects == null || projects.isEmpty())
return;
Iterator<IProject> it = projects.iterator();
if (forAll) {
while(it.hasNext())
processProject(it.next());
} else {
if (it.hasNext())
processProject(it.next());
}
}
private void processProject(IProject prj) {
ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(prj, false);
if (prjd == null) return;
Object[] cfgds = prjd.getConfigurations();
if (!forAll) cfgds = openDialog(cfgds);
if (cfgds == null || cfgds.length == 0) return;
Job buildCleanFilesJob = new BuildCleanFilesJob(cfgds);
buildCleanFilesJob.schedule();
}
}
private Object[] openDialog(Object[] cfgds) {
if (cfgds == null || cfgds.length == 0) return null;
ListSelectionDialog dialog = new ListSelectionDialog(
CUIPlugin.getActiveWorkbenchShell(),
cfgds,
new IStructuredContentProvider() {
public Object[] getElements(Object inputElement) { return (Object[])inputElement; }
public void dispose() {}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
},
new LabelProvider() {
@Override
public String getText(Object element) {
if (element == null || !(element instanceof ICConfigurationDescription)) return null;
return ((ICConfigurationDescription)element).getName();
}
},
getDLG_TEXT());
dialog.setTitle(getDLG_TITLE());
dialog.setInitialSelections(cfgds);
return (dialog.open() == Window.OK) ? dialog.getResult() : null;
}
}

View file

@ -1,60 +0,0 @@
/*******************************************************************************
* Copyright (c) 2007, 2010 Intel Corporation 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:
* Intel Corporation - initial API and implementation
* LSI Corporation - added symmetric project clean action
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.ui.actions;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.ui.actions.CommonBuildCleanAllAction;
import org.eclipse.cdt.managedbuilder.ui.properties.Messages;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
/**
* Action which changes active build configuration of the current project to
* the given one.
*
* @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
*/
public class BuildAllAction extends CommonBuildCleanAllAction {
/** @since 7.0 */
@Override
protected String getTIP_ALL() { return Messages.getString("BuildAllAction.0");}//$NON-NLS-1$
/** @since 7.0 */
@Override
protected String getLBL_ALL() { return Messages.getString("BuildAllAction.1");}//$NON-NLS-1$
/** @since 7.0 */
@Override
protected String getJOB_MSG() { return Messages.getString("BuildAllAction.2");}//$NON-NLS-1$
/** @since 7.0 */
@Override
protected String getERR_MSG() { return Messages.getString("BuildAllAction.3");}//$NON-NLS-1$
/** @since 7.0 */
@Override
protected String getLBL_SEL() { return Messages.getString("BuildAllAction.4");}//$NON-NLS-1$
/** @since 7.0 */
@Override
protected String getTIP_SEL() { return Messages.getString("BuildAllAction.5");}//$NON-NLS-1$
/** @since 7.0 */
@Override
protected String getDLG_TEXT(){ return Messages.getString("BuildAllAction.6"); }//$NON-NLS-1$
/** @since 7.0 */
@Override
protected String getDLG_TITLE(){ return Messages.getString("BuildAllAction.7");}//$NON-NLS-1$
/** @since 7.0 */
@Override
protected void performAction(IConfiguration[] configs,
IProgressMonitor monitor) throws CoreException {
ManagedBuildManager.buildConfigurations(configs, monitor);
}
}

View file

@ -0,0 +1,62 @@
/*******************************************************************************
* 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.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.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
*
* @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
*
* @since 7.0
*/
public class BuildAllConfigurationsAction implements IObjectActionDelegate {
private ArrayList<IProject> projects = null;
public void selectionChanged(IAction action, ISelection selection) {
projects = CleanAndBuildAction.getSelectedCdtProjects(selection);
action.setEnabled(projects.size() > 0);
}
public void run(IAction action) {
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();
}
}
}
}
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
}
}

View file

@ -0,0 +1,102 @@
/*******************************************************************************
* 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.ui.actions;
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.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 com.ibm.icu.text.MessageFormat;
/**
* A job to build CDT build configurations.
*
* @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
*
* @since 7.0
*/
public class BuildConfigurationsJob extends Job {
private ICConfigurationDescription[] cfgDescriptions;
private int cleanKind;
private int buildKind;
private static String composeJobName(ICConfigurationDescription[] cfgDescriptions, boolean isCleaning) {
String firstProjectName = cfgDescriptions[0].getProjectDescription().getName();
String firstConfigurationName = cfgDescriptions[0].getName();
if (isCleaning) {
return MessageFormat.format(Messages.BuildConfigurationsJob_Cleaning,
new Object[] {""+cfgDescriptions.length, firstProjectName, firstConfigurationName}); //$NON-NLS-1$
} else {
return MessageFormat.format(Messages.BuildConfigurationsJob_Building,
new Object[] {""+cfgDescriptions.length, firstProjectName, firstConfigurationName}); //$NON-NLS-1$
}
}
/**
* Constructor.
*
* @param cfgDescriptions - a list of configurations to build, possibly from different projects
* @param cleanKind - pass {@link IncrementalProjectBuilder#CLEAN_BUILD} to clean before building
* @param buildKind - kind of build. Can be
* {@link IncrementalProjectBuilder#INCREMENTAL_BUILD}
* {@link IncrementalProjectBuilder#FULL_BUILD}
* {@link IncrementalProjectBuilder#AUTO_BUILD}
*/
public BuildConfigurationsJob(ICConfigurationDescription[] cfgDescriptions, int cleanKind, int buildKind) {
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) {
IConfiguration[] cfgs = new IConfiguration[cfgDescriptions.length];
for (int i=0; i<cfgDescriptions.length; i++) {
cfgs[i] = ManagedBuildManager.getConfigurationForDescription(cfgDescriptions[i]);
}
try {
if (cleanKind==IncrementalProjectBuilder.CLEAN_BUILD) {
ManagedBuildManager.buildConfigurations(cfgs, null, monitor, true, cleanKind);
}
if (buildKind!=0) {
ManagedBuildManager.buildConfigurations(cfgs, null, monitor, true, buildKind);
}
} catch (CoreException e) {
return new Status(IStatus.ERROR, org.eclipse.cdt.managedbuilder.ui.actions.Messages.BuildConfigurationsJob_BuildError, e.getLocalizedMessage());
}
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
monitor.done();
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;
}
}

View file

@ -0,0 +1,62 @@
/*******************************************************************************
* 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.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.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
*
* @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
*
* @since 7.0
*/
public class CleanAllConfigurationsAction implements IObjectActionDelegate {
private ArrayList<IProject> projects = null;
public void selectionChanged(IAction action, ISelection selection) {
projects = CleanAndBuildAction.getSelectedCdtProjects(selection);
action.setEnabled(projects.size() > 0);
}
public void run(IAction action) {
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();
}
}
}
}
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
}
}

View file

@ -0,0 +1,80 @@
/*******************************************************************************
* 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.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}.
*
* @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
*
* @since 7.0
*/
public class CleanAndBuildAction implements IObjectActionDelegate {
private ArrayList<IProject> projects = null;
public void run(IAction action) {
if (projects!=null) {
CleanAndBuildDialog dialog = new CleanAndBuildDialog(projects.toArray(new IProject[projects.size()]));
dialog.open();
}
}
public void selectionChanged(IAction action, ISelection selection) {
projects = getSelectedCdtProjects(selection);
action.setEnabled(projects.size() > 0);
}
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;
}
}

View file

@ -0,0 +1,421 @@
/*******************************************************************************
* 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.ui.actions;
import java.util.ArrayList;
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.ui.properties.ManagedBuilderUIImages;
import org.eclipse.cdt.managedbuilder.ui.properties.ManagedBuilderUIPlugin;
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.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.dialogs.ContainerCheckedTreeViewer;
import org.eclipse.ui.internal.ide.actions.BuildUtilities;
import org.eclipse.ui.model.WorkbenchLabelProvider;
/**
* Dialog to let the user to clean and rebuild configurations of the selected projects.
*
* @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
*
* @since 7.0
*/
public class CleanAndBuildDialog 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$
private static final String DIALOG_WIDTH = "DIALOG_WIDTH"; //$NON-NLS-1$
private static final String DIALOG_HEIGHT = "DIALOG_HEIGHT"; //$NON-NLS-1$
private Button cleanCheckbox;
private Button buildCheckbox;
private ContainerCheckedTreeViewer cfgCheckboxViewer;
private IProject[] projects;
private Object[] selected;
private int cleanKind;
private int buildKind;
private class ConfigurationLabelProvider implements ILabelProvider {
WorkbenchLabelProvider workbenchLabelProvider = new WorkbenchLabelProvider();
public void addListener(ILabelProviderListener listener) {
workbenchLabelProvider.addListener(listener);
}
public void dispose() {
workbenchLabelProvider.dispose();
}
public boolean isLabelProperty(Object element, String property) {
return workbenchLabelProvider.isLabelProperty(element, property);
}
public void removeListener(ILabelProviderListener listener) {
workbenchLabelProvider.removeListener(listener);
}
public Image getImage(Object element) {
if (element instanceof ICConfigurationDescription)
return ManagedBuilderUIImages.get(ManagedBuilderUIImages.IMG_BUILD_CONFIG);
return workbenchLabelProvider.getImage(element);
}
public String getText(Object element) {
if (element instanceof ICConfigurationDescription) {
ICConfigurationDescription cfgDescription = (ICConfigurationDescription) element;
String name = cfgDescription.getName();
if (cfgDescription.isActive()) {
return name + ' ' + Messages.CleanAndBuildDialog_Active;
}
return name;
}
return workbenchLabelProvider.getText(element);
}
}
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)
*/
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
*/
public void dispose() {
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
*/
public Object[] getElements(Object inputElement) {
return getChildren(inputElement);
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
*/
public boolean hasChildren(Object element) {
if (element instanceof IProject[])
return ((IProject[]) element).length > 0;
if (element instanceof IProject) {
IProject project = (IProject) element;
ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(project, false);
if (prjd == null)
return false;
ICConfigurationDescription[] cfgDescriptions = prjd.getConfigurations();
return cfgDescriptions != null && cfgDescriptions.length > 0;
}
return false;
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
*/
public Object getParent(Object element) {
if (element instanceof IProject) {
return projects;
}
if (element instanceof ICConfigurationDescription) {
ICConfigurationDescription cfgDescription = (ICConfigurationDescription) element;
return cfgDescription.getProjectDescription().getProject();
}
return null;
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
*/
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof IProject[])
return (IProject[]) parentElement;
if (parentElement instanceof IProject) {
IProject project = (IProject) parentElement;
ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(project, false);
if (prjd != null) {
ICConfigurationDescription[] cfgDescriptions = prjd.getConfigurations();
return cfgDescriptions;
}
}
return new Object[0];
}
}
/**
* Creates a new Clean and Build dialog.
*
* @param projects - the currently selected projects
*/
public CleanAndBuildDialog(IProject[] projects) {
super(CUIPlugin.getActiveWorkbenchShell(), Messages.CleanAndBuildDialog_RebuildConfigurations, null,
Messages.CleanAndBuildDialog_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);
if (buttonId != IDialogConstants.OK_ID) {
return;
}
// save all dirty editors
BuildUtilities.saveEditors(null);
if (selected!=null) {
List<ICConfigurationDescription> cfgDescriptions = new ArrayList<ICConfigurationDescription>();
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()]);
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);
GridLayout layout = new GridLayout();
layout.marginWidth = layout.marginHeight = 0;
layout.numColumns = 2;
layout.makeColumnsEqualWidth = true;
area.setLayout(layout);
area.setLayoutData(new GridData(GridData.FILL_BOTH));
SelectionListener updateEnablement = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateEnablement();
}
};
// second row
createProjectSelectionTable(area);
// third row
cleanCheckbox = new Button(parent, SWT.CHECK);
cleanCheckbox.setText(Messages.CleanAndBuildDialog_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.setSelection(true);
buildCheckbox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
buildCheckbox.addSelectionListener(updateEnablement);
buildKind = buildCheckbox.getSelection() ? IncrementalProjectBuilder.INCREMENTAL_BUILD : 0;
return area;
}
private void createProjectSelectionTable(Composite area) {
cfgCheckboxViewer = new ContainerCheckedTreeViewer(area, SWT.BORDER);
cfgCheckboxViewer.setContentProvider(new ConfigurationContentProvider());
cfgCheckboxViewer.setLabelProvider(new ConfigurationLabelProvider());
cfgCheckboxViewer.setInput(projects);
GridData data = new GridData(GridData.FILL_BOTH);
data.horizontalSpan = 2;
data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
data.heightHint = IDialogConstants.ENTRY_FIELD_WIDTH;
cfgCheckboxViewer.getControl().setLayoutData(data);
ArrayList<ICConfigurationDescription> initialSelection = new ArrayList<ICConfigurationDescription>(projects.length);
for (IProject prj : projects) {
ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(prj, false);
if (prjd == null)
continue;
cfgCheckboxViewer.setChecked(prjd.getActiveConfiguration(), true);
initialSelection.add(prjd.getActiveConfiguration());
}
cfgCheckboxViewer.expandAll();
cfgCheckboxViewer.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
updateEnablement();
selected = cfgCheckboxViewer.getCheckedElements();
}
});
selected = cfgCheckboxViewer.getCheckedElements();
selected = initialSelection.toArray(new ICConfigurationDescription[initialSelection.size()]);
}
/**
* 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);
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();
return getInitialSize(DIALOG_SETTINGS_SECTION, p);
}
/**
* 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}
*/
private Point getInitialLocation(String dialogSettingsSectionName) {
IDialogSettings settings = getDialogSettings(dialogSettingsSectionName);
try {
int x = settings.getInt(DIALOG_ORIGIN_X);
int y = settings.getInt(DIALOG_ORIGIN_Y);
return new Point(x, y);
} catch (NumberFormatException e) {
}
return null;
}
private IDialogSettings getDialogSettings(String dialogSettingsSectionName) {
IDialogSettings settings = ManagedBuilderUIPlugin.getDefault().getDialogSettings();
IDialogSettings section = settings.getSection(dialogSettingsSectionName);
if (section == null) {
section = settings.addNewSection(dialogSettingsSectionName);
}
return section;
}
/**
* 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
*/
private void persistDialogSettings(Shell shell, String dialogSettingsSectionName) {
Point shellLocation = shell.getLocation();
Point shellSize = shell.getSize();
IDialogSettings settings = getDialogSettings(dialogSettingsSectionName);
settings.put(DIALOG_ORIGIN_X, shellLocation.x);
settings.put(DIALOG_ORIGIN_Y, shellLocation.y);
settings.put(DIALOG_WIDTH, shellSize.x);
settings.put(DIALOG_HEIGHT, shellSize.y);
}
/**
* 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.
*
* @param initialSize - The initialSize to compare against
* @param dialogSettingsSectionName - The name of the dialog settings section
* @return the initial size
*/
private Point getInitialSize(String dialogSettingsSectionName, Point initialSize) {
IDialogSettings settings = getDialogSettings(dialogSettingsSectionName);
try {
int x, y;
x = settings.getInt(DIALOG_WIDTH);
y = settings.getInt(DIALOG_HEIGHT);
return new Point(Math.max(x, initialSize.x), Math.max(y, initialSize.y));
} catch (NumberFormatException e) {
}
return initialSize;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.dialogs.Dialog#isResizable()
*/
@Override
protected boolean isResizable() {
return true;
}
}

View file

@ -0,0 +1,40 @@
/*******************************************************************************
* 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.ui.actions;
import org.eclipse.osgi.util.NLS;
/**
* Message bundle class for externalizing messages.
*
* @noextend This interface is not intended to be extended by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
*
* @since 7.0
*/
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.cdt.managedbuilder.ui.actions.messages"; //$NON-NLS-1$
public static String BuildConfigurationsJob_BuildError;
public static String BuildConfigurationsJob_Building;
public static String BuildConfigurationsJob_Cleaning;
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;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}
private Messages() {
}
}

View file

@ -0,0 +1,20 @@
###############################################################################
# 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
###############################################################################
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.

View file

@ -92,22 +92,6 @@ NewCfgDialog.0=Existing configuration
NewCfgDialog.1=Default configuration
NewBuildConfigurationDialog.0=Cannot create config
NewBuildConfigurationDialog.1=>>
BuildAllAction.0=Build all project configurations in parallel
BuildAllAction.1=All
BuildAllAction.2=Building project
BuildAllAction.3=Build error
BuildAllAction.4=Select...
BuildAllAction.5=Build selected configurations in parallel
BuildAllAction.6=Select configurations to build
BuildAllAction.7=Build configurations
CleanAllAction.0=Clean all project configurations in parallel
CleanAllAction.1=All
CleanAllAction.2=Cleaning project
CleanAllAction.3=Clean error
CleanAllAction.4=Select...
CleanAllAction.5=Clean selected configurations in parallel
CleanAllAction.6=Select configurations to clean
CleanAllAction.7=Clean configurations
PrefPage_NewCDTWizard.0=Settings will be applied to CDT new project wizard during project creation process
WizardDefaultsTab.0=Show only supported toolchains, by default
WizardDefaultsTab.1=Group old-style toolchains to <Others> folder