From a28df172a8a1cefb51079ffb98135248cd7b5a0d Mon Sep 17 00:00:00 2001 From: Oleg Krasilnikov Date: Mon, 7 May 2007 12:36:45 +0000 Subject: [PATCH] Bug #185590: input parameter type changed. --- .../actions/ChangeBuildConfigMenuAction.java | 3 +- .../cdt/ui/actions/ManageConfigsAction.java | 5 +- .../eclipse/cdt/ui/newui/AbstractPage.java | 2 +- .../eclipse/cdt/ui/newui/IConfigManager.java | 10 +-- .../cdt/ui/newui/ManageConfigRunner.java | 63 +++--------------- .../cdt/ui/newui/ManageConfigSelector.java | 66 ++++++++++++++++--- 6 files changed, 79 insertions(+), 70 deletions(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigMenuAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigMenuAction.java index 914d11ca720..62f7a54d080 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigMenuAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigMenuAction.java @@ -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); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ManageConfigsAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ManageConfigsAction.java index fbc45c40403..561d24d69b1 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ManageConfigsAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ManageConfigsAction.java @@ -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; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java index 5a1888d9da8..16ff9feca99 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java @@ -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; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IConfigManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IConfigManager.java index cf83e7deb4a..2119ca84083 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IConfigManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IConfigManager.java @@ -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); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigRunner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigRunner.java index 91a35a7d10a..90f8a39e8ac 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigRunner.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigRunner.java @@ -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 0) return true; - } - return false; - } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigSelector.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigSelector.java index b8ae800b52d..5ca0f12aac4 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigSelector.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigSelector.java @@ -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