1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-08 08:45:44 +02:00

Added build toolbar button discussed in bug 154280.

This commit is contained in:
Ken Ryall 2007-05-07 03:42:24 +00:00
parent e553056f27
commit 39051c4adb
8 changed files with 198 additions and 40 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 870 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View file

@ -157,6 +157,8 @@ BuildConfigMenuAction.label=Set Active
BuildConfigContextAction.label=Set Active
BuildConfigAction.tooltip=Change active build configuration for project(s)
BuildConfigAction.tooltip2=Manage configurations for the current project
BuildActiveConfiguration.label=Build Active Configuration
BuildActiveConfiguration.tooltip=Build the active configurations of selected projects
ManageConfigAction.label=Manage...
DeleteRcConfigAction.label=Delete resource cfgs...
@ -401,7 +403,7 @@ exportWizard.CDTCategory.name = C/C++
page.c.general=C/C++ General
# menu labels
Configurations.menu=Build configurations
Configurations.menu=Build Configurations
Index.menu=Index
CDTWizard=CDT New Project Wizard

View file

@ -1058,8 +1058,17 @@
menubarPath="project/org.eclipse.cdt.ui.prjmenu/gm1"
style="pulldown"
tooltip="%BuildConfigAction.tooltip"/>
<action
<action
class="org.eclipse.cdt.ui.actions.BuildActiveConfigMenuAction"
disabledIcon="icons/dlcl16/build_exec.png"
enablesFor="+"
icon="icons/elcl16/build_exec.png"
id="org.eclipse.cdt.ui.buildActiveConfigToolbarAction"
label="%BuildActiveConfiguration.label"
style="pulldown"
toolbarPath="buildConfig"
tooltip="%BuildActiveConfiguration.tooltip"/>
<action
class="org.eclipse.cdt.ui.actions.ManageConfigsAction"
enablesFor="+"
id="org.eclipse.cdt.ui.manageConfigsAction2"

View file

@ -0,0 +1,99 @@
/*******************************************************************************
* Copyright (c) 2007 Nokia 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:
* Nokia - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.ui.actions;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.events.MenuAdapter;
import org.eclipse.swt.events.MenuEvent;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2;
import org.eclipse.ui.actions.BuildAction;
/**
* Implements a toolbar button that builds the active configuration
* of selected projects. Also includes a menu that builds any of the
* other configurations.
*
*/
public class BuildActiveConfigMenuAction extends ChangeBuildConfigActionBase
implements IWorkbenchWindowPulldownDelegate2 {
private BuildAction buildaction;
/**
* @see org.eclipse.ui.IWorkbenchWindowPulldownDelegate2#getMenu(org.eclipse.swt.widgets.Menu)
*/
public Menu getMenu(Menu parent) {
Menu menu = new Menu(parent);
addMenuListener(menu);
return menu;
}
/**
* @see org.eclipse.ui.IWorkbenchWindowPulldownDelegate#getMenu(org.eclipse.swt.widgets.Control)
*/
public Menu getMenu(Control parent) {
Menu menu = new Menu(parent);
addMenuListener(menu);
return menu;
}
/**
* @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
*/
public void dispose() {
// do nothing
}
/**
* @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
*/
public void init(IWorkbenchWindow window) {
buildaction = new BuildAction(window.getShell(), IncrementalProjectBuilder.INCREMENTAL_BUILD);
}
/**
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
public void run(IAction action) {
buildaction.selectionChanged(new StructuredSelection(fProjects.toArray()));
buildaction.run();
}
/**
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
*/
public void selectionChanged(IAction action, ISelection selection) {
onSelectionChanged(action, selection);
}
/**
* Adds a listener to the given menu to repopulate it each time is is shown
* @param menu The menu to add listener to
*/
private void addMenuListener(Menu menu) {
menu.addMenuListener(new MenuAdapter() {
public void menuShown(MenuEvent e) {
fillMenu((Menu)e.widget);
}
});
}
protected IAction makeAction(String sName, StringBuffer builder, int accel) {
return new BuildConfigAction(fProjects, sName, builder.toString(), accel + 1, buildaction);
}
}

View file

@ -1,66 +1,44 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 Intel Corporation and others.
* Copyright (c) 2007 Nokia 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
* Nokia - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.ui.actions;
import java.util.HashSet;
import java.util.Iterator;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.action.Action;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.ui.newui.AbstractPage;
import org.eclipse.cdt.ui.newui.CDTPropertyManager;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.actions.BuildAction;
/**
* Action which changes active build configuration of the current project to
* the given one.
* Action which builds the active configurations of the selected projects.
*/
public class BuildConfigAction extends Action {
private String fConfigName = null;
private HashSet fProjects = null;
public class BuildConfigAction extends ChangeConfigAction {
private BuildAction buildAction;
/**
* Constructs the action.
* @param projects List of selected managed-built projects
* @param configName Build configuration name
* @param accel Number to be used as accelerator
*/
public BuildConfigAction(HashSet projects, String configName, String displayName, int accel) {
super("&" + accel + " " + displayName); //$NON-NLS-1$ //$NON-NLS-2$
fProjects = projects;
fConfigName = configName;
public BuildConfigAction(HashSet projects, String configName, String displayName, int accel, BuildAction buildAction) {
super(projects, configName, displayName, accel);
this.buildAction = buildAction;
}
/**
* @see org.eclipse.jface.action.IAction#run()
*/
public void run() {
Iterator iter = fProjects.iterator();
while (iter.hasNext()) {
IProject prj = (IProject)iter.next();
ICProjectDescription prjd = CDTPropertyManager.getProjectDescription(prj);
ICConfigurationDescription[] configs = prjd.getConfigurations();
if (configs != null && configs.length > 0) {
for (int i = 0; i < configs.length; i++) {
if (configs[i].getName().equals(fConfigName)) {
configs[i].setActive();
CDTPropertyManager.performOk(null);
AbstractPage.updateViews(prj);
break;
}
}
}
}
super.run();
buildAction.selectionChanged(new StructuredSelection(fProjects.toArray()));
buildAction.run();
}
}

View file

@ -122,7 +122,7 @@ public class ChangeBuildConfigActionBase {
builder.append(" (...)"); //$NON-NLS-1$
}
IAction action = new BuildConfigAction(fProjects, sName, builder.toString(), accel + 1);
IAction action = makeAction(sName ,builder, accel);
if (bCurrentConfig && sCurrentConfig.equals(sName)) {
action.setChecked(true);
}
@ -133,6 +133,10 @@ public class ChangeBuildConfigActionBase {
}
}
protected IAction makeAction(String sName, StringBuffer builder, int accel) {
return new ChangeConfigAction(fProjects, sName, builder.toString(), accel + 1);
}
/**
* selectionChanged() event handler. Fills the list of managed-built projects
* based on the selection. If some non-managed-built projects are selected,

View file

@ -0,0 +1,66 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 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
*******************************************************************************/
package org.eclipse.cdt.ui.actions;
import java.util.HashSet;
import java.util.Iterator;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.action.Action;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.ui.newui.AbstractPage;
import org.eclipse.cdt.ui.newui.CDTPropertyManager;
/**
* Action which changes active build configuration of the current project to
* the given one.
*/
public class ChangeConfigAction extends Action {
private String fConfigName = null;
protected HashSet fProjects = null;
/**
* Constructs the action.
* @param projects List of selected managed-built projects
* @param configName Build configuration name
* @param accel Number to be used as accelerator
*/
public ChangeConfigAction(HashSet projects, String configName, String displayName, int accel) {
super("&" + accel + " " + displayName); //$NON-NLS-1$ //$NON-NLS-2$
fProjects = projects;
fConfigName = configName;
}
/**
* @see org.eclipse.jface.action.IAction#run()
*/
public void run() {
Iterator iter = fProjects.iterator();
while (iter.hasNext()) {
IProject prj = (IProject)iter.next();
ICProjectDescription prjd = CDTPropertyManager.getProjectDescription(prj);
ICConfigurationDescription[] configs = prjd.getConfigurations();
if (configs != null && configs.length > 0) {
for (int i = 0; i < configs.length; i++) {
if (configs[i].getName().equals(fConfigName)) {
configs[i].setActive();
CDTPropertyManager.performOk(null);
AbstractPage.updateViews(prj);
break;
}
}
}
}
}
}