From 91a194dc3383771685a6465f42fec8ce3e988e4e Mon Sep 17 00:00:00 2001 From: Oleg Krasilnikov Date: Wed, 28 Feb 2007 17:38:06 +0000 Subject: [PATCH] Bug # 161547 --- core/org.eclipse.cdt.ui/plugin.properties | 3 +- core/org.eclipse.cdt.ui/plugin.xml | 14 ++ .../ui/actions/ActionMessages.properties | 8 +- .../ui/actions/DeleteResConfigsAction.java | 6 +- .../ui/actions/ExcludeFromBuildAction.java | 210 ++++++++++++++++++ 5 files changed, 237 insertions(+), 4 deletions(-) create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ExcludeFromBuildAction.java diff --git a/core/org.eclipse.cdt.ui/plugin.properties b/core/org.eclipse.cdt.ui/plugin.properties index 70269ae4c6c..0cc6cf79365 100644 --- a/core/org.eclipse.cdt.ui/plugin.properties +++ b/core/org.eclipse.cdt.ui/plugin.properties @@ -162,8 +162,9 @@ BuildConfigContextAction.label=Active Bui&ld Configuration BuildConfigAction.tooltip=Change active build configuration for project(s) BuildConfigAction.tooltip2=Manage configurations for the current project -ManageConfigAction.label=Manage configurations +ManageConfigAction.label=Manage configurations... DeleteRcConfigAction.label=Delete resource configs... +ExcludeAction.label=Exclude from build... BuildConfigurationActionSet.descr=Build configuration for the current project # Common Editor ruler actions diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml index 3ed26cfeb54..164d4e1fd62 100644 --- a/core/org.eclipse.cdt.ui/plugin.xml +++ b/core/org.eclipse.cdt.ui/plugin.xml @@ -837,6 +837,13 @@ label="%DeleteRcConfigAction.label" menubarPath="buildGroup" /> + @@ -979,6 +986,13 @@ label="%DeleteRcConfigAction.label" menubarPath="project/build" /> + 0) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ExcludeFromBuildAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ExcludeFromBuildAction.java new file mode 100644 index 00000000000..56b716bb17c --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ExcludeFromBuildAction.java @@ -0,0 +1,210 @@ +/******************************************************************************* + * Copyright (c) 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.ArrayList; +import java.util.Iterator; + +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.jface.action.IAction; +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.dialogs.ListSelectionDialog; + +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.model.ICContainer; +import org.eclipse.cdt.core.model.ICElement; +import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.core.model.ITranslationUnit; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.cdt.core.settings.model.ICFolderDescription; +import org.eclipse.cdt.core.settings.model.ICProjectDescription; +import org.eclipse.cdt.core.settings.model.ICResourceDescription; +import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.ui.newui.AbstractPage; + +import org.eclipse.cdt.internal.ui.actions.ActionMessages; + +/** + * Action which changes active build configuration of the current project to + * the given one. + */ +public class ExcludeFromBuildAction +implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate { + + protected ArrayList objects = null; + protected ArrayList cfgNames = null; + + public void selectionChanged(IAction action, ISelection selection) { + objects = null; + boolean cfgsOK = true; + + 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 0) + dialog.setInitialElementSelections(lst); + + if (dialog.open() == Window.OK) { + Object[] selected = dialog.getResult(); + if (selected != null && selected.length > 0) { + Iterator it2 = objects.iterator(); +outer: + while(it2.hasNext()) { + IResource res = (IResource)it2.next(); + IProject p = res.getProject(); + if (!p.isOpen()) continue; + // get writable description + ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, true); + if (prjd == null) continue; + ICConfigurationDescription[] cfgds = prjd.getConfigurations(); + IPath p2 = res.getProjectRelativePath(); + for (int i=0; i