mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 17:26: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;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
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)
|
||||
*/
|
||||
public void run(IAction action) {
|
||||
Object[] obs = fProjects.toArray();
|
||||
IProject[] obs = (IProject[])fProjects.toArray(new IProject[fProjects.size()]);
|
||||
IConfigManager cm = ManageConfigSelector.getManager(obs);
|
||||
if (cm != null) {
|
||||
cm.manage(obs, true);
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.actions;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
|
@ -29,13 +30,13 @@ import org.eclipse.cdt.ui.newui.ManageConfigSelector;
|
|||
*/
|
||||
public class ManageConfigsAction
|
||||
implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
|
||||
Object[] obs = null;
|
||||
IProject[] obs = null;
|
||||
|
||||
public void selectionChanged(IAction action, ISelection selection) {
|
||||
if (!selection.isEmpty()) {
|
||||
// case for context menu
|
||||
if (selection instanceof StructuredSelection) {
|
||||
obs = ((StructuredSelection)selection).toArray();
|
||||
obs = ManageConfigSelector.getProjects(((StructuredSelection)selection).toArray());
|
||||
action.setEnabled(ManageConfigSelector.getManager(obs) != null);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -256,7 +256,7 @@ implements
|
|||
manageButton.setLayoutData(gd);
|
||||
manageButton.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
Object[] obs = new Object[] { getProject() };
|
||||
IProject[] obs = new IProject[] { getProject() };
|
||||
IConfigManager cm = ManageConfigSelector.getManager(obs);
|
||||
if (cm != null && cm.manage(obs, false)) {
|
||||
cfgDescs = null;
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.newui;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
||||
/*
|
||||
* Implementors are intended to
|
||||
* override "Manage Configurations" dialog
|
||||
|
@ -20,18 +22,18 @@ public interface IConfigManager {
|
|||
/**
|
||||
* Checks whether objects are applicable to the manager
|
||||
*
|
||||
* @param obs - selected objects
|
||||
* @param obs - selected projects
|
||||
* @return true if Configuration Management
|
||||
* is possible for these objects
|
||||
*/
|
||||
public boolean canManage(Object[] obs);
|
||||
public boolean canManage(IProject[] obs);
|
||||
|
||||
/**
|
||||
* Displays "Manage Configurations" dialog
|
||||
*
|
||||
* @param obs - selected objects
|
||||
* @param obs - selected projects
|
||||
* @param doOk - whether data saving is required
|
||||
* @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
|
||||
* 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
|
||||
* Intel Corporation - 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)
|
||||
|
@ -32,65 +27,25 @@ public class ManageConfigRunner implements IConfigManager {
|
|||
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 canManage(IProject[] obs) {
|
||||
// Only one project can be accepted
|
||||
return (obs != null && obs.length == 1);
|
||||
}
|
||||
|
||||
public boolean manage(Object[] obs, boolean doOk) {
|
||||
public boolean manage(IProject[] obs, boolean doOk) {
|
||||
if (!canManage(obs))
|
||||
return false;
|
||||
|
||||
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;
|
||||
if (d.open() == Window.OK) {
|
||||
if (doOk) {
|
||||
CDTPropertyManager.performOk(d.getShell());
|
||||
}
|
||||
AbstractPage.updateViews(project);
|
||||
AbstractPage.updateViews(obs[0]);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,35 +1,47 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2007 IBM Corporation and others.
|
||||
* 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:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* Intel Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.ui.newui;
|
||||
|
||||
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.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IExtension;
|
||||
import org.eclipse.core.runtime.IExtensionPoint;
|
||||
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 {
|
||||
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) {
|
||||
|
||||
/**
|
||||
* 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();
|
||||
if (mgrs == null)
|
||||
return null;
|
||||
|
@ -39,7 +51,45 @@ public class ManageConfigSelector {
|
|||
}
|
||||
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() {
|
||||
if (mgrs != null)
|
||||
return;
|
||||
|
|
Loading…
Add table
Reference in a new issue