mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Bug #185590: input parameter type changed.
This commit is contained in:
parent
1ddccb2b11
commit
a28df172a8
6 changed files with 79 additions and 70 deletions
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.ui.actions;
|
package org.eclipse.cdt.ui.actions;
|
||||||
|
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.jface.action.IAction;
|
import org.eclipse.jface.action.IAction;
|
||||||
import org.eclipse.jface.dialogs.MessageDialog;
|
import org.eclipse.jface.dialogs.MessageDialog;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
|
@ -68,7 +69,7 @@ public class ChangeBuildConfigMenuAction extends ChangeBuildConfigActionBase imp
|
||||||
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
|
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
|
||||||
*/
|
*/
|
||||||
public void run(IAction action) {
|
public void run(IAction action) {
|
||||||
Object[] obs = fProjects.toArray();
|
IProject[] obs = (IProject[])fProjects.toArray(new IProject[fProjects.size()]);
|
||||||
IConfigManager cm = ManageConfigSelector.getManager(obs);
|
IConfigManager cm = ManageConfigSelector.getManager(obs);
|
||||||
if (cm != null) {
|
if (cm != null) {
|
||||||
cm.manage(obs, true);
|
cm.manage(obs, true);
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.ui.actions;
|
package org.eclipse.cdt.ui.actions;
|
||||||
|
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.jface.action.IAction;
|
import org.eclipse.jface.action.IAction;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
import org.eclipse.jface.viewers.StructuredSelection;
|
import org.eclipse.jface.viewers.StructuredSelection;
|
||||||
|
@ -29,13 +30,13 @@ import org.eclipse.cdt.ui.newui.ManageConfigSelector;
|
||||||
*/
|
*/
|
||||||
public class ManageConfigsAction
|
public class ManageConfigsAction
|
||||||
implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
|
implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
|
||||||
Object[] obs = null;
|
IProject[] obs = null;
|
||||||
|
|
||||||
public void selectionChanged(IAction action, ISelection selection) {
|
public void selectionChanged(IAction action, ISelection selection) {
|
||||||
if (!selection.isEmpty()) {
|
if (!selection.isEmpty()) {
|
||||||
// case for context menu
|
// case for context menu
|
||||||
if (selection instanceof StructuredSelection) {
|
if (selection instanceof StructuredSelection) {
|
||||||
obs = ((StructuredSelection)selection).toArray();
|
obs = ManageConfigSelector.getProjects(((StructuredSelection)selection).toArray());
|
||||||
action.setEnabled(ManageConfigSelector.getManager(obs) != null);
|
action.setEnabled(ManageConfigSelector.getManager(obs) != null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -256,7 +256,7 @@ implements
|
||||||
manageButton.setLayoutData(gd);
|
manageButton.setLayoutData(gd);
|
||||||
manageButton.addSelectionListener(new SelectionAdapter() {
|
manageButton.addSelectionListener(new SelectionAdapter() {
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
Object[] obs = new Object[] { getProject() };
|
IProject[] obs = new IProject[] { getProject() };
|
||||||
IConfigManager cm = ManageConfigSelector.getManager(obs);
|
IConfigManager cm = ManageConfigSelector.getManager(obs);
|
||||||
if (cm != null && cm.manage(obs, false)) {
|
if (cm != null && cm.manage(obs, false)) {
|
||||||
cfgDescs = null;
|
cfgDescs = null;
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.ui.newui;
|
package org.eclipse.cdt.ui.newui;
|
||||||
|
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Implementors are intended to
|
* Implementors are intended to
|
||||||
* override "Manage Configurations" dialog
|
* override "Manage Configurations" dialog
|
||||||
|
@ -20,18 +22,18 @@ public interface IConfigManager {
|
||||||
/**
|
/**
|
||||||
* Checks whether objects are applicable to the manager
|
* Checks whether objects are applicable to the manager
|
||||||
*
|
*
|
||||||
* @param obs - selected objects
|
* @param obs - selected projects
|
||||||
* @return true if Configuration Management
|
* @return true if Configuration Management
|
||||||
* is possible for these objects
|
* is possible for these objects
|
||||||
*/
|
*/
|
||||||
public boolean canManage(Object[] obs);
|
public boolean canManage(IProject[] obs);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays "Manage Configurations" dialog
|
* Displays "Manage Configurations" dialog
|
||||||
*
|
*
|
||||||
* @param obs - selected objects
|
* @param obs - selected projects
|
||||||
* @param doOk - whether data saving is required
|
* @param doOk - whether data saving is required
|
||||||
* @return true if user pressed OK in dialog
|
* @return true if user pressed OK in dialog
|
||||||
*/
|
*/
|
||||||
public boolean manage(Object[] obs, boolean doOk);
|
public boolean manage(IProject[] obs, boolean doOk);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +1,25 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2002, 2007 IBM Corporation and others.
|
* Copyright (c) 2007 Intel Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* Intel Corporation - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.ui.newui;
|
package org.eclipse.cdt.ui.newui;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
|
||||||
import org.eclipse.jface.window.Window;
|
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;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
public class ManageConfigRunner implements IConfigManager {
|
public class ManageConfigRunner implements IConfigManager {
|
||||||
private static final String MANAGE_TITLE = UIMessages.getString("ManageConfigDialog.0"); //$NON-NLS-1$
|
private static final String MANAGE_TITLE = UIMessages.getString("ManageConfigDialog.0"); //$NON-NLS-1$
|
||||||
|
|
||||||
protected static ManageConfigRunner instance = null;
|
protected static ManageConfigRunner instance = null;
|
||||||
protected IProject project = null;
|
|
||||||
|
|
||||||
public static ManageConfigRunner getDefault() {
|
public static ManageConfigRunner getDefault() {
|
||||||
if (instance == null)
|
if (instance == null)
|
||||||
|
@ -32,65 +27,25 @@ public class ManageConfigRunner implements IConfigManager {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canManage(Object[] obs) {
|
public boolean canManage(IProject[] obs) {
|
||||||
project = null;
|
// Only one project can be accepted
|
||||||
for (int i=0; i<obs.length; i++)
|
return (obs != null && obs.length == 1);
|
||||||
if (!getProject(obs[i]))
|
|
||||||
break;
|
|
||||||
return project != null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean manage(Object[] obs, boolean doOk) {
|
public boolean manage(IProject[] obs, boolean doOk) {
|
||||||
if (!canManage(obs))
|
if (!canManage(obs))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ManageConfigDialog d = new ManageConfigDialog(CUIPlugin.getActiveWorkbenchShell(),
|
ManageConfigDialog d = new ManageConfigDialog(CUIPlugin.getActiveWorkbenchShell(),
|
||||||
project.getName()+ " : " + MANAGE_TITLE, project); //$NON-NLS-1$
|
obs[0].getName()+ " : " + MANAGE_TITLE, obs[0]); //$NON-NLS-1$
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
if (d.open() == Window.OK) {
|
if (d.open() == Window.OK) {
|
||||||
if (doOk) {
|
if (doOk) {
|
||||||
CDTPropertyManager.performOk(d.getShell());
|
CDTPropertyManager.performOk(d.getShell());
|
||||||
}
|
}
|
||||||
AbstractPage.updateViews(project);
|
AbstractPage.updateViews(obs[0]);
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
return result;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +1,32 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2002, 2007 IBM Corporation and others.
|
* Copyright (c) 2007 Intel Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* Intel Corporation - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.ui.newui;
|
package org.eclipse.cdt.ui.newui;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IConfigurationElement;
|
import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
import org.eclipse.core.runtime.IExtension;
|
import org.eclipse.core.runtime.IExtension;
|
||||||
import org.eclipse.core.runtime.IExtensionPoint;
|
import org.eclipse.core.runtime.IExtensionPoint;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides static methods to work with
|
* This class provides static methods to work with multiple
|
||||||
*
|
* implementors of "ConfigManager" extension point.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class ManageConfigSelector {
|
public class ManageConfigSelector {
|
||||||
private static final String EXTENSION_POINT_ID = "org.eclipse.cdt.ui.ConfigManager"; //$NON-NLS-1$
|
private static final String EXTENSION_POINT_ID = "org.eclipse.cdt.ui.ConfigManager"; //$NON-NLS-1$
|
||||||
|
@ -29,7 +34,14 @@ public class ManageConfigSelector {
|
||||||
public static final String CLASS_NAME = "class"; //$NON-NLS-1$
|
public static final String CLASS_NAME = "class"; //$NON-NLS-1$
|
||||||
private static IConfigManager[] mgrs = null;
|
private static IConfigManager[] mgrs = null;
|
||||||
|
|
||||||
public static IConfigManager getManager(Object[] obs) {
|
/**
|
||||||
|
* Searches for IConfigManager which
|
||||||
|
* can process given projects.
|
||||||
|
*
|
||||||
|
* @param obs - list of projects to handle
|
||||||
|
* @return first matching ConfigManager
|
||||||
|
*/
|
||||||
|
public static IConfigManager getManager(IProject[] obs) {
|
||||||
readMgrs();
|
readMgrs();
|
||||||
if (mgrs == null)
|
if (mgrs == null)
|
||||||
return null;
|
return null;
|
||||||
|
@ -40,6 +52,44 @@ public class ManageConfigSelector {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Searches for IConfigManager which
|
||||||
|
* can process given objects.
|
||||||
|
*
|
||||||
|
* @param obs - "raw" array of objects
|
||||||
|
* @return first matching ConfigManager
|
||||||
|
*/
|
||||||
|
public static IConfigManager getManagerFor(Object[] obs) {
|
||||||
|
return getManager(getProjects(obs));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filters "raw" objects array
|
||||||
|
*
|
||||||
|
* @param obs - objects to filter
|
||||||
|
* @return array with only new-style projects included
|
||||||
|
*/
|
||||||
|
public static IProject[] getProjects(Object[] obs) {
|
||||||
|
ArrayList lst = new ArrayList();
|
||||||
|
if (obs != null) {
|
||||||
|
for (int i=0; i<obs.length; i++) {
|
||||||
|
IProject prj = null;
|
||||||
|
// Extract project from selection
|
||||||
|
if (obs[i] instanceof ICElement) { // for C/C++ view
|
||||||
|
prj = ((ICElement)obs[i]).getCProject().getProject();
|
||||||
|
} else if (obs[i] instanceof IResource) { // for other views
|
||||||
|
prj = ((IResource)obs[i]).getProject();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prj == null || lst.contains(prj) ||
|
||||||
|
!CoreModel.getDefault().isNewStyleProject(prj))
|
||||||
|
continue;
|
||||||
|
lst.add(prj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (IProject[])lst.toArray(new IProject[lst.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
private static void readMgrs() {
|
private static void readMgrs() {
|
||||||
if (mgrs != null)
|
if (mgrs != null)
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Reference in a new issue