mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Bug #185590
This commit is contained in:
parent
6871fd9ab5
commit
adfede637e
11 changed files with 351 additions and 82 deletions
|
@ -416,3 +416,4 @@ Cproject.desc=Create a new C project
|
|||
|
||||
TemplatePreferencePage.name=Template Default Values
|
||||
Template.Engine.Wizard=template entries contributor
|
||||
ConfigManager=Dialog for Configurations management
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
<extension-point id="ProposalFilter" name="%proposalFilter.name" schema="schema/ProposalFilter.exsd"/>
|
||||
<extension-point id="completionProposalComputer" name="%completionProposalComputer" schema="schema/completionProposalComputer.exsd"/>
|
||||
<extension-point id="newCfgDialog" name="%NewCfgDialog.name" schema="schema/newCfgDialog.exsd"/>
|
||||
<extension-point id="ConfigManager" name="%ConfigManager" schema="schema/ConfigManager.exsd"/>
|
||||
|
||||
<extension
|
||||
point="org.eclipse.core.runtime.adapters">
|
||||
|
|
119
core/org.eclipse.cdt.ui/schema/ConfigManager.exsd
Normal file
119
core/org.eclipse.cdt.ui/schema/ConfigManager.exsd
Normal file
|
@ -0,0 +1,119 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!-- Schema file written by PDE -->
|
||||
<schema targetNamespace="org.eclipse.cdt.ui">
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.schema plugin="org.eclipse.cdt.ui" id="ConfigManager" name="ConfigManager"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
In the new CDT 4.0 project model, you should be able to override the dialog
|
||||
that gets displayed when clicking the manage button on any of the C/C++
|
||||
project property pages,
|
||||
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<element name="extension">
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element ref="manager" minOccurs="1" maxOccurs="unbounded"/>
|
||||
</sequence>
|
||||
<attribute name="point" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="id" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="name" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
<appInfo>
|
||||
<meta.attribute translatable="true"/>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="manager">
|
||||
<complexType>
|
||||
<attribute name="class" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Class which implements IConfigManager interface
|
||||
</documentation>
|
||||
<appInfo>
|
||||
<meta.attribute kind="java" basedOn="org.eclipse.cdt.ui.wizards.IConfigManager"/>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="since"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
CDT 4.0
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="examples"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
[Enter extension point usage example here.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="apiInfo"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
[Enter API information here.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="implementation"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
[Enter information about supplied implementation of this extension point.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="copyright"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
/**********************************************************************
|
||||
* 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
|
||||
**********************************************************************/
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
</schema>
|
|
@ -115,7 +115,7 @@ COutlineInformationControl.viewMenu.move.label=Move outline
|
|||
COutlineInformationControl.viewMenu.sort.label=Sort
|
||||
|
||||
ChangeBuildConfigMenuAction.title=Sorry
|
||||
ChangeBuildConfigMenuAction.text=Only one project should be selected to manage configurations.
|
||||
ChangeBuildConfigMenuAction.text=No way to manage configurations for selected objects.
|
||||
|
||||
DeleteResConfigsAction.0=Select configurations to delete
|
||||
DeleteResConfigsAction.1=Delete resource configurations
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.actions;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
|
@ -22,7 +21,8 @@ import org.eclipse.ui.IWorkbenchWindow;
|
|||
import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2;
|
||||
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.cdt.ui.newui.ManageConfigDialog;
|
||||
import org.eclipse.cdt.ui.newui.IConfigManager;
|
||||
import org.eclipse.cdt.ui.newui.ManageConfigSelector;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.actions.ActionMessages;
|
||||
|
||||
|
@ -68,9 +68,10 @@ public class ChangeBuildConfigMenuAction extends ChangeBuildConfigActionBase imp
|
|||
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
|
||||
*/
|
||||
public void run(IAction action) {
|
||||
if (fProjects.size() == 1) {
|
||||
IProject project = (IProject)fProjects.toArray(new IProject[1])[0];
|
||||
ManageConfigDialog.manage(project, true);
|
||||
Object[] obs = fProjects.toArray();
|
||||
IConfigManager cm = ManageConfigSelector.getManager(obs);
|
||||
if (cm != null) {
|
||||
cm.manage(obs, true);
|
||||
} else {
|
||||
MessageDialog.openInformation(CUIPlugin.getActiveWorkbenchShell(),
|
||||
ActionMessages.getString("ChangeBuildConfigMenuAction.title"), //$NON-NLS-1$
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.actions;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
|
@ -22,11 +20,8 @@ import org.eclipse.ui.IWorkbenchPart;
|
|||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2;
|
||||
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||
import org.eclipse.cdt.ui.newui.ManageConfigDialog;
|
||||
import org.eclipse.cdt.ui.newui.IConfigManager;
|
||||
import org.eclipse.cdt.ui.newui.ManageConfigSelector;
|
||||
|
||||
/**
|
||||
* Action which changes active build configuration of the current project to
|
||||
|
@ -34,66 +29,27 @@ import org.eclipse.cdt.ui.newui.ManageConfigDialog;
|
|||
*/
|
||||
public class ManageConfigsAction
|
||||
implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
|
||||
|
||||
protected IProject project = null;
|
||||
|
||||
Object[] obs = null;
|
||||
|
||||
public void selectionChanged(IAction action, ISelection selection) {
|
||||
project = null;
|
||||
if (!selection.isEmpty()) {
|
||||
// case for context menu
|
||||
if (selection instanceof StructuredSelection) {
|
||||
Object[] obs = ((StructuredSelection)selection).toArray();
|
||||
for (int i=0; i<obs.length; i++) {
|
||||
if (!getProject(obs[i])) break;
|
||||
}
|
||||
obs = ((StructuredSelection)selection).toArray();
|
||||
action.setEnabled(ManageConfigSelector.getManager(obs) != null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
action.setEnabled(project != null);
|
||||
}
|
||||
|
||||
protected boolean getProject(Object ob) {
|
||||
IProject prj = null;
|
||||
|
||||
// Extract project from selection
|
||||
if (ob instanceof ICElement) { // for C/C++ view
|
||||
prj = ((ICElement)ob).getCProject().getProject();
|
||||
} else if (ob instanceof IResource) { // for other views
|
||||
prj = ((IResource)ob).getProject();
|
||||
}
|
||||
|
||||
if (prj != null) {
|
||||
if (!CoreModel.getDefault().isNewStyleProject(prj))
|
||||
return false;
|
||||
|
||||
// 2 or more projects selected - cannot handle
|
||||
if (project != null && project != prj) {
|
||||
project = null;
|
||||
return false;
|
||||
}
|
||||
// only New CDT model projects can be handled
|
||||
if (isManaged(prj)) project = prj;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for project type.
|
||||
private boolean isManaged(IProject p) {
|
||||
if (!p.isOpen()) return false;
|
||||
ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, false);
|
||||
if (prjd != null) {
|
||||
ICConfigurationDescription[] c = prjd.getConfigurations();
|
||||
if (c != null && c.length > 0) return true;
|
||||
}
|
||||
return false;
|
||||
action.setEnabled(false);
|
||||
}
|
||||
|
||||
public void run(IAction action) {
|
||||
if (project != null)
|
||||
ManageConfigDialog.manage(project, true);
|
||||
IConfigManager cm = ManageConfigSelector.getManager(obs);
|
||||
if (cm != null && obs != null)
|
||||
cm.manage(obs, true);
|
||||
}
|
||||
|
||||
public void dispose() { project = null; }
|
||||
public void dispose() { obs = null; }
|
||||
|
||||
// doing nothing
|
||||
public void init(IWorkbenchWindow window) { }
|
||||
|
|
|
@ -256,7 +256,9 @@ implements
|
|||
manageButton.setLayoutData(gd);
|
||||
manageButton.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
if (ManageConfigDialog.manage(getProject(), false)) {
|
||||
Object[] obs = new Object[] { getProject() };
|
||||
IConfigManager cm = ManageConfigSelector.getManager(obs);
|
||||
if (cm != null && cm.manage(obs, false)) {
|
||||
cfgDescs = null;
|
||||
populateConfigurations();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
/*******************************************************************************
|
||||
* 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.newui;
|
||||
|
||||
/*
|
||||
* Implementors are intended to
|
||||
* override "Manage Configurations" dialog
|
||||
*
|
||||
* @see ConfigManager extension point.
|
||||
*/
|
||||
public interface IConfigManager {
|
||||
/**
|
||||
* Checks whether objects are applicable to the manager
|
||||
*
|
||||
* @param obs - selected objects
|
||||
* @return true if Configuration Management
|
||||
* is possible for these objects
|
||||
*/
|
||||
public boolean canManage(Object[] obs);
|
||||
|
||||
/**
|
||||
* Displays "Manage Configurations" dialog
|
||||
*
|
||||
* @param obs - selected objects
|
||||
* @param doOk - whether data saving is required
|
||||
* @return true if user pressed OK in dialog
|
||||
*/
|
||||
public boolean manage(Object[] obs, boolean doOk);
|
||||
}
|
|
@ -38,7 +38,6 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
|||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
|
||||
public class ManageConfigDialog extends Dialog {
|
||||
public static final String MANAGE_TITLE = UIMessages.getString("ManageConfigDialog.0"); //$NON-NLS-1$
|
||||
private static final String EXTENSION_POINT_ID = "org.eclipse.cdt.ui.newCfgDialog"; //$NON-NLS-1$
|
||||
public static final String ELEMENT_NAME = "dialog"; //$NON-NLS-1$
|
||||
public static final String CLASS_NAME = "class"; //$NON-NLS-1$
|
||||
|
@ -68,22 +67,6 @@ public class ManageConfigDialog extends Dialog {
|
|||
protected Button renBtn;
|
||||
protected Button delBtn;
|
||||
|
||||
private static Composite comp;
|
||||
|
||||
public static boolean manage(IProject _prj, boolean doOk) {
|
||||
ManageConfigDialog d = new ManageConfigDialog(CUIPlugin.getActiveWorkbenchShell(),
|
||||
_prj.getName()+ " : " + MANAGE_TITLE, _prj); //$NON-NLS-1$
|
||||
boolean result = false;
|
||||
if (d.open() == OK) {
|
||||
if (doOk) {
|
||||
CDTPropertyManager.performOk(comp);
|
||||
}
|
||||
AbstractPage.updateViews(_prj);
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parentShell
|
||||
*/
|
||||
|
@ -164,7 +147,7 @@ public class ManageConfigDialog extends Dialog {
|
|||
}} );
|
||||
|
||||
des = CDTPropertyManager.getProjectDescription(composite, prj);
|
||||
comp = composite;
|
||||
// comp = composite;
|
||||
|
||||
updateData();
|
||||
return composite;
|
||||
|
@ -289,5 +272,5 @@ public class ManageConfigDialog extends Dialog {
|
|||
if (table.getItemCount() > 0) table.select(0);
|
||||
table.setFocus();
|
||||
updateButtons();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2007 IBM 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:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.newui;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.jface.window.Window;
|
||||
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
|
||||
public class ManageConfigRunner implements IConfigManager {
|
||||
private static final String MANAGE_TITLE = UIMessages.getString("ManageConfigDialog.0"); //$NON-NLS-1$
|
||||
|
||||
protected static ManageConfigRunner instance = null;
|
||||
protected IProject project = null;
|
||||
|
||||
public static ManageConfigRunner getDefault() {
|
||||
if (instance == null)
|
||||
instance = new ManageConfigRunner();
|
||||
return instance;
|
||||
}
|
||||
|
||||
public boolean canManage(Object[] obs) {
|
||||
project = null;
|
||||
for (int i=0; i<obs.length; i++)
|
||||
if (!getProject(obs[i]))
|
||||
break;
|
||||
return project != null;
|
||||
}
|
||||
|
||||
public boolean manage(Object[] obs, boolean doOk) {
|
||||
if (!canManage(obs))
|
||||
return false;
|
||||
|
||||
ManageConfigDialog d = new ManageConfigDialog(CUIPlugin.getActiveWorkbenchShell(),
|
||||
project.getName()+ " : " + MANAGE_TITLE, project); //$NON-NLS-1$
|
||||
boolean result = false;
|
||||
if (d.open() == Window.OK) {
|
||||
if (doOk) {
|
||||
CDTPropertyManager.performOk(d.getShell());
|
||||
}
|
||||
AbstractPage.updateViews(project);
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean getProject(Object ob) {
|
||||
IProject prj = null;
|
||||
|
||||
// Extract project from selection
|
||||
if (ob instanceof ICElement) { // for C/C++ view
|
||||
prj = ((ICElement)ob).getCProject().getProject();
|
||||
} else if (ob instanceof IResource) { // for other views
|
||||
prj = ((IResource)ob).getProject();
|
||||
}
|
||||
|
||||
if (prj != null) {
|
||||
if (!CoreModel.getDefault().isNewStyleProject(prj))
|
||||
return false;
|
||||
|
||||
// 2 or more projects selected - cannot handle
|
||||
if (project != null && project != prj) {
|
||||
project = null;
|
||||
return false;
|
||||
}
|
||||
// only New CDT model projects can be handled
|
||||
if (isManaged(prj)) project = prj;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for project type.
|
||||
private boolean isManaged(IProject p) {
|
||||
if (!p.isOpen()) return false;
|
||||
ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, false);
|
||||
if (prjd != null) {
|
||||
ICConfigurationDescription[] c = prjd.getConfigurations();
|
||||
if (c != null && c.length > 0) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2007 IBM 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:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.newui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IExtension;
|
||||
import org.eclipse.core.runtime.IExtensionPoint;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
/**
|
||||
* This class provides static methods to work with
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ManageConfigSelector {
|
||||
private static final String EXTENSION_POINT_ID = "org.eclipse.cdt.ui.ConfigManager"; //$NON-NLS-1$
|
||||
public static final String ELEMENT_NAME = "manager"; //$NON-NLS-1$
|
||||
public static final String CLASS_NAME = "class"; //$NON-NLS-1$
|
||||
private static IConfigManager[] mgrs = null;
|
||||
|
||||
public static IConfigManager getManager(Object[] obs) {
|
||||
readMgrs();
|
||||
if (mgrs == null)
|
||||
return null;
|
||||
for (int i=0; i<mgrs.length; i++) {
|
||||
if (mgrs[i].canManage(obs))
|
||||
return mgrs[i];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void readMgrs() {
|
||||
if (mgrs != null)
|
||||
return;
|
||||
|
||||
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT_ID);
|
||||
if (extensionPoint == null)
|
||||
return;
|
||||
|
||||
IExtension[] extensions = extensionPoint.getExtensions();
|
||||
if (extensions == null)
|
||||
return;
|
||||
|
||||
ArrayList list = new ArrayList();
|
||||
for (int i = 0; i < extensions.length; ++i) {
|
||||
IConfigurationElement[] elements = extensions[i].getConfigurationElements();
|
||||
for (int k = 0; k < elements.length; k++) {
|
||||
if (elements[k].getName().equals(ELEMENT_NAME)) {
|
||||
IConfigManager cm = null;
|
||||
try {
|
||||
cm = (IConfigManager) elements[k].createExecutableExtension(CLASS_NAME);
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
if (cm != null)
|
||||
list.add(cm);
|
||||
}
|
||||
}
|
||||
}
|
||||
list.add(ManageConfigRunner.getDefault()); // Default manager
|
||||
mgrs = (IConfigManager[]) list.toArray(new IConfigManager[list.size()]);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue