1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-10 09:45:39 +02:00

Slightly reduced clutter in the project's context menu.

Change-Id: I78b5a8b37ce297a9ceaf8ecf9cb94b8df014e61d
This commit is contained in:
Sergey Prigogin 2014-07-30 19:07:38 -07:00
parent 31f37f5b63
commit 7880c684eb
17 changed files with 324 additions and 250 deletions

View file

@ -4732,7 +4732,6 @@ public class ManagedBuildManager extends AbstractCExtension {
}
}
}
}
/**

View file

@ -1447,7 +1447,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
OutputStream stdout = buildRunnerHelper.getOutputStream();
OutputStream stderr = buildRunnerHelper.getErrorStream();
buildRunnerHelper.greeting(ManagedMakeMessages.getResourceString("BuildFilesHandler.buildingSelectedFiles"), cfgName, toolchainName, isSupported); //$NON-NLS-1$
buildRunnerHelper.greeting(ManagedMakeMessages.getResourceString("GeneratedMakefileBuilder.buildingSelectedFiles"), cfgName, toolchainName, isSupported); //$NON-NLS-1$
buildRunnerHelper.printLine(ManagedMakeMessages.getResourceString("ManagedMakeBuilder.message.internal.builder.header.note")); //$NON-NLS-1$
// Build artifacts for each file in the project
@ -1574,7 +1574,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
ErrorParserManager epm = new ErrorParserManager(project, des.getDefaultBuildDirLocationURI(), this, errorParsers);
buildRunnerHelper.prepareStreams(epm, null , console, new SubProgressMonitor(monitor, TICKS_STREAM_PROGRESS_MONITOR));
buildRunnerHelper.greeting(ManagedMakeMessages.getResourceString("CleanFilesHandler.cleanSelectedFiles"), cfgName, toolchainName, isSupported); //$NON-NLS-1$
buildRunnerHelper.greeting(ManagedMakeMessages.getResourceString("GeneratedMakefileBuilder.cleanSelectedFiles"), cfgName, toolchainName, isSupported); //$NON-NLS-1$
buildRunnerHelper.printLine(ManagedMakeMessages.getResourceString("ManagedMakeBuilder.message.internal.builder.header.note")); //$NON-NLS-1$
for (IFile file : files) {

View file

@ -115,7 +115,7 @@ UserDefinedMacroSupplier.storeOutputStream.wrong.arguments=Failed to persist mac
# BuildMacroStatus messages
BuildMacroStatus.status.macro.undefined=Macro {0} is undefined
BuildFilesHandler.buildingSelectedFiles=Building Selected Files
GeneratedMakefileBuilder.buildingSelectedFiles=Building Selected Files
BuildDescriptionGnuMakefileGenerator.0=IO exception occurred:
BuildDescriptionGnuMakefileGenerator.1=IO exception occurred:
BuildMacroStatus.status.reference.eachother=Macros {0} and {1} reference each other
@ -144,8 +144,7 @@ ManagedBuilderCorePlugin.resourceChangeHandlingInitializationJob=Initializing Re
InternalBuilder.msg.header=Internal Builder: {0}
InternalBuilder.nothing.todo=Nothing to be done for project {0}
CfgScannerConfigUtil_ErrorNotSupported=Only type {0} is supported in this method.
CleanFilesHandler.cleanSelectedFiles=Cleaning Selected Files
CleanFilesHandler.cleaningFiles=Cleaning files
GeneratedMakefileBuilder.cleanSelectedFiles=Cleaning Selected Files
BuilderFactory.1=can not find builder with the specified id
FolderInfo.4=converter invocation failed
MbsMacroSupplier.1=tool parent must be one of configuration, toolchain, or resource configuration

View file

@ -22,7 +22,8 @@ Require-Bundle: org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
org.eclipse.ui.console;bundle-version="[3.5.100,4.0.0)",
org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)",
org.eclipse.ui.navigator;bundle-version="[3.2.0,4.0.0)";resolution:=optional
org.eclipse.ui.navigator;bundle-version="[3.2.0,4.0.0)";resolution:=optional,
org.eclipse.core.expressions
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Import-Package: com.ibm.icu.text

View file

@ -37,13 +37,14 @@ propSettingsPrefName=Property Pages Settings
MngResourceProp.name=C/C++ Build
# The Project Converter page
ConvertTargetAction.label=Convert To...
command.convertTarget.label=Convert To...
command.convertTarget.name=Convert To
# Build/clean selected files actions
BuildSelectedFiles.label=Build Selected &File(s)
command.buildFiles.label=Build Selected &File(s)
command.buildFiles.name=Build Selected File(s)
command.buildFiles.description=Rebuilds the selected source files
CleanSelectedFiles.label=C&lean Selected File(s)
command.cleanFiles.label=C&lean Selected File(s)
command.cleanFiles.name=Clean Selected File(s)
command.cleanFiles.description=Deletes build output files for the selected source files
@ -83,7 +84,7 @@ Tool.settings=Tool Settings
Build.steps=Build Steps
Build.artifact=Build Artifact
Builder.settings=Builder Settings
WBB.settings=Behaviour
WBB.settings=Behavior
Refresh.policy=Refresh Policy
Includes=Includes
Includes.tooltip=Includes list

View file

@ -50,6 +50,10 @@
description="%command.buildFiles.description"
categoryId="org.eclipse.cdt.managedbuilder.ui.category.build"
id="org.eclipse.cdt.managedbuilder.ui.buildFiles"/>
<command
name="%command.convertTarget.name"
categoryId="org.eclipse.ui.category.project"
id="org.eclipse.cdt.managedbuilder.ui.convertTarget"/>
</extension>
<extension
@ -60,6 +64,9 @@
<handler
class="org.eclipse.cdt.managedbuilder.internal.ui.actions.BuildFilesHandler"
commandId="org.eclipse.cdt.managedbuilder.ui.buildFiles"/>
<handler
class="org.eclipse.cdt.managedbuilder.internal.ui.actions.ConvertTargetHandler"
commandId="org.eclipse.cdt.managedbuilder.ui.convertTarget"/>
</extension>
<extension
@ -68,7 +75,7 @@
locationURI="popup:org.eclipse.ui.popup.any?before=additions">
<command
commandId="org.eclipse.cdt.managedbuilder.ui.cleanFiles"
label="%CleanSelectedFiles.label"
label="%command.cleanFiles.label"
style="push">
<visibleWhen checkEnabled="false">
<and>
@ -89,7 +96,7 @@
</command>
<command
commandId="org.eclipse.cdt.managedbuilder.ui.buildFiles"
label="%BuildSelectedFiles.label"
label="%command.buildFiles.label"
style="push">
<visibleWhen checkEnabled="false">
<and>
@ -109,24 +116,46 @@
</visibleWhen>
</command>
</menuContribution>
<!-- This menu command doesn't belong here. It should be contributed
by the plug-ins that contribute target converters. -->
<menuContribution
locationURI="popup:org.eclipse.ui.popup.any?after=additions">
<command
commandId="org.eclipse.cdt.managedbuilder.ui.convertTarget"
label="%command.convertTarget.label"
style="push">
<visibleWhen checkEnabled="false">
<with variable="selection" >
<count value="1"/>
<iterate ifEmpty="false">
<adapt type="org.eclipse.core.resources.IProject">
<and>
<test property="org.eclipse.core.resources.projectNature"
value="org.eclipse.cdt.managedbuilder.core.managedBuildNature"/>
<test property="org.eclipse.cdt.ui.projectBuilder"
value="org.eclipse.cdt.managedbuilder.core.genmakebuilder"/>
<test property="org.eclipse.cdt.managedbuilder.ui.hasTargetConverters"/>
</and>
</adapt>
</iterate>
</with>
</visibleWhen>
</command>
</menuContribution>
</extension>
<extension
point="org.eclipse.core.expressions.propertyTesters">
<propertyTester
class="org.eclipse.cdt.managedbuilder.internal.ui.actions.ProjectPropertyTester"
id="org.eclipse.cdt.managedbuilder.ui.projectPropertyTester"
namespace="org.eclipse.cdt.managedbuilder.ui"
properties="hasTargetConverters"
type="org.eclipse.core.resources.IProject"/>
</extension>
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
objectClass="org.eclipse.core.resources.IProject"
adaptable="true"
id="org.eclipse.cdt.managedbuilder.ui.popupMenu.ConvertTargetContribution">
<action
label="%ConvertTargetAction.label"
class="org.eclipse.cdt.managedbuilder.internal.ui.actions.ConvertTargetAction"
menubarPath="additions"
enablesFor="1"
id="org.eclipse.cdt.managedbuilder.ui.ConvertTargetAction"/>
<filter
name="projectNature"
value="org.eclipse.cdt.managedbuilder.core.managedBuildNature"/>
</objectContribution>
<objectContribution
objectClass="org.eclipse.core.resources.IProject"
adaptable="true"

View file

@ -1,20 +1,19 @@
/*******************************************************************************
* Copyright (c) 2010, 2011 Andrew Gvozdev 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
* Copyright (c) 2010, 2011 Andrew Gvozdev 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:
* Andrew Gvozdev - Initial API and implementation
* IBM Corporation
* Contributors:
* Andrew Gvozdev - Initial API and implementation
* IBM Corporation
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.ui;
import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
public static String AbstractCWizard_0;
public static String AbstractPrefPage_0;
public static String ArtifactTab_0;
@ -85,7 +84,6 @@ public class Messages extends NLS {
public static String CMainWizardPage_0;
public static String CMainWizardPage_1;
public static String CNewWizard_0;
public static String ConvertTargetAction_No_Converter;
public static String CPropertyVarsTab_0;
public static String CWizardHandler_0;
public static String CWizardHandler_1;
@ -195,11 +193,6 @@ public class Messages extends NLS {
public static String PreferredToolchainsTab_3;
public static String PrefPage_NewCDTWizard_0;
public static String PrefPage_PropertyPage_0;
public static String ProjectConvert_conversionErrordialog_message;
public static String ProjectConvert_conversionErrordialog_title;
public static String ProjectConvert_convertersList;
public static String ProjectConvert_noConverterErrordialog_message;
public static String ProjectConvert_title;
public static String PropertyMultiCfgTab_10;
public static String PropertyMultiCfgTab_11;
public static String PropertyMultiCfgTab_3;

View file

@ -247,12 +247,6 @@ BuildToolSettingsPage_tool_command=Command:
BuildToolSettingsPage_tool_commandLinePattern=Command\nline pattern:
BuildToolSettingsPage_tool_advancedSettings=Expert settings:
# Project Conversion Dialog messages
ProjectConvert_conversionErrordialog_title=Project Conversion Error
ProjectConvert_conversionErrordialog_message=Error has occurred during the conversion of the project {0} .
ProjectConvert_noConverterErrordialog_message=There are no converters available to convert the project {0} .
ProjectConvert_title=Project Converters for {0}
PropertyMultiCfgTab_10=Add/remove/change affected elements, do not touch others
PropertyMultiCfgTab_11=Replace existing string lists with string list shown to user
PropertyMultiCfgTab_3=String List Display Mode
@ -278,7 +272,6 @@ PropertyPageDefsTab_9=Always show profile IDs only
PropertyPageDefsTab_showIncludeFileTab=Display "Include Files" tab on Paths and Symbols page
PropertyPageDefsTab_showProvidersTab=Display "Preprocessor Include Paths" page
PropertyPageDefsTab_showScannerDiscoveryTab=Display "Discovery Options" page
ProjectConvert_convertersList=Converters List
AbstractPrefPage_0=\ Preference settings will be applied to new projects \n only when there were no toolchains selected.
EnvironmentTab_15=Current String List DISPLAY mode. Double-click to change

View file

@ -23,7 +23,6 @@ import org.eclipse.cdt.internal.ui.util.AbstractResourceActionHandler;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.core.GeneratedMakefileBuilder;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
@ -168,7 +167,7 @@ public class BuildFilesHandler extends AbstractResourceActionHandler {
private final List<IFile> files;
BuildFilesJob(List<IFile> filesToBuild) {
super(ManagedMakeMessages.getResourceString("BuildFilesHandler.buildingSelectedFiles")); //$NON-NLS-1$
super(Messages.BuildFilesHandler_buildingSelectedFiles);
files = filesToBuild;
}

View file

@ -21,7 +21,6 @@ import org.eclipse.cdt.internal.ui.util.AbstractResourceActionHandler;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.core.GeneratedMakefileBuilder;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IFile;
@ -115,7 +114,7 @@ public class CleanFilesHandler extends AbstractResourceActionHandler {
private final List<IFile> files;
private CleanFilesJob(List<IFile> filesToBuild) {
super(ManagedMakeMessages.getResourceString("CleanFilesHandler.cleaningFiles")); //$NON-NLS-1$
super(Messages.CleanFilesHandler_cleaningFiles);
files = filesToBuild;
}

View file

@ -1,144 +0,0 @@
/*******************************************************************************
* Copyright (c) 2005, 2012 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
* Anna Dushistova (MontaVista) - [366771]Converter fails to convert a CDT makefile project
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.ui.actions;
import java.util.Vector;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.ui.Messages;
import org.eclipse.cdt.managedbuilder.ui.properties.ManagedBuilderUIPlugin;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.actions.ActionDelegate;
public class ConvertTargetAction
extends ActionDelegate
implements IObjectActionDelegate {
private IProject selectedProject = null;
public static final String PREFIX = "ProjectConvert"; //$NON-NLS-1$
public static final String PROJECT_CONVERTER_DIALOG = PREFIX + ".title"; //$NON-NLS-1$
public static void initStartup() {
return;
}
@Override
public void selectionChanged(IAction action, ISelection selection) {
if (selection instanceof IStructuredSelection) {
IStructuredSelection sel = (IStructuredSelection) selection;
Object obj = sel.getFirstElement();
if (obj instanceof IProject) {
IProject project = (IProject)obj;
// Save the selected project.
setSelectedProject(project);
return;
}
}
setSelectedProject(null);
}
private IProjectType getProjectType(IProject project) {
IProjectType projectType = null;
// Get the projectType from project.
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
if (info != null) {
IManagedProject managedProject = info.getManagedProject();
if ( managedProject != null )
projectType = managedProject.getProjectType();
}
return projectType;
}
private Vector<IBuildObject> getProjectToolchains(IProject project) {
Vector<IBuildObject> projectToolchains = new Vector<IBuildObject>();
// Get the projectType from project.
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
if (info != null) {
IConfiguration[] configs = info.getManagedProject().getConfigurations();
for (IConfiguration config : configs) {
IToolChain tc = config.getToolChain();
if (tc != null) {
projectToolchains.add(tc);
}
}
}
return projectToolchains;
}
@Override
public void run(IAction action) {
Shell shell = CUIPlugin.getActiveWorkbenchShell();
// Check whether the converters available for the selected project
// If there are no converters display error dialog otherwise display converters list
if( ManagedBuildManager.hasTargetConversionElements(getProjectType(getSelectedProject())) == true ||
ManagedBuildManager.hasAnyTargetConversionElements(getProjectToolchains(getSelectedProject()))) {
handleConvertTargetAction();
} else {
MessageDialog.openError(shell,Messages.ConvertTargetAction_No_Converter,
NLS.bind(Messages.ProjectConvert_noConverterErrordialog_message, new String[] {getSelectedProject().getName()}) );
}
}
private void handleConvertTargetAction() {
Shell shell = ManagedBuilderUIPlugin.getDefault().getShell();
String projectName = getSelectedProject().getName();
String title = NLS.bind(Messages.ProjectConvert_title, new String(projectName));
ConvertTargetDialog dialog = new ConvertTargetDialog(shell, getSelectedProject(), title);
if ( dialog.open() == ConvertTargetDialog.OK ) {
if ( ConvertTargetDialog.isConversionSuccessful() == false) {
MessageDialog.openError(shell, Messages.ProjectConvert_conversionErrordialog_title,
NLS.bind(Messages.ProjectConvert_conversionErrordialog_message, projectName));
}
}
return;
}
@Override
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
// TODO Auto-generated method stub
}
/**
* @return Returns the selectedProject.
*/
private IProject getSelectedProject() {
return selectedProject;
}
/**
* @param selectedProject The selectedProject to set.
*/
private void setSelectedProject(IProject selectedProject) {
this.selectedProject = selectedProject;
}
}

View file

@ -7,13 +7,15 @@
*
* Contributors:
* Intel Corporation - initial API and implementation
* Anna Dushistova (MontaVista) - [366771]Converter fails to convert a CDT makefile project
* Anna Dushistova (MontaVista) - [366771] Converter fails to convert a CDT makefile project
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.ui.actions;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
@ -23,7 +25,7 @@ import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.ui.Messages;
import org.eclipse.cdt.managedbuilder.ui.properties.ManagedBuilderUIPlugin;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
@ -39,35 +41,33 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
public class ConvertTargetDialog extends Dialog {
final private String title;
protected List convertersList;
protected org.eclipse.swt.widgets.List convertersList;
private IProject project;
private Map<String, IConfigurationElement> conversionElements;
private IConfigurationElement selectedConversionElement;
private static boolean isConversionSuccessful = false;
public static final String PREFIX = "ProjectConvert"; //$NON-NLS-1$
public static final String CONVERTERS_LIST = PREFIX +".convertersList"; //$NON-NLS-1$
public static final String CONVERTERS_LIST = PREFIX + ".convertersList"; //$NON-NLS-1$
/**
* @param parentShell
* @param project
* @param title The title of the dialog
* @param parentShell the parent shell
* @param project the project to convert
* @param title the title of the dialog
*/
protected ConvertTargetDialog(Shell parentShell, IProject project, String title) {
super(parentShell);
this.title = title;
setProject(project);
if (getProjectType() != null) {
conversionElements = ManagedBuildManager.getConversionElements(getProjectType());
IProjectType projectType = getProjectType();
if (projectType != null) {
conversionElements = ManagedBuildManager.getConversionElements(projectType);
}
for (IBuildObject tc : getProjectToolchains()) {
Map<String, IConfigurationElement> converters = ManagedBuildManager.getConversionElements(tc);
@ -80,34 +80,29 @@ public class ConvertTargetDialog extends Dialog {
}
}
setShellStyle(getShellStyle()|SWT.RESIZE);
setShellStyle(getShellStyle() | SWT.RESIZE);
}
@Override
protected void buttonPressed(int buttonId) {
if (buttonId == IDialogConstants.OK_ID) {
handleConverterSelection();
IConvertManagedBuildObject convertBuildObject = null;
try {
convertBuildObject = (IConvertManagedBuildObject) getSelectedConversionElement()
.createExecutableExtension("class"); //$NON-NLS-1$
convertBuildObject =
(IConvertManagedBuildObject) getSelectedConversionElement().createExecutableExtension("class"); //$NON-NLS-1$
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
ManagedBuilderUIPlugin.log(e);
}
if (convertBuildObject != null) {
String fromId = getSelectedConversionElement().getAttribute(
"fromId"); //$NON-NLS-1$
String toId = getSelectedConversionElement().getAttribute(
"toId"); //$NON-NLS-1$
String fromId = getSelectedConversionElement().getAttribute("fromId"); //$NON-NLS-1$
String toId = getSelectedConversionElement().getAttribute("toId"); //$NON-NLS-1$
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
if (info != null) {
IManagedProject managedProject = info.getManagedProject();
if (managedProject != null) {
if (convertBuildObject.convert(managedProject, fromId,
toId, true) == null) {
if (convertBuildObject.convert(managedProject, fromId, toId, true) == null) {
setConversionSuccessful(false);
} else {
setConversionSuccessful(true);
@ -135,7 +130,6 @@ public class ConvertTargetDialog extends Dialog {
@Override
protected Control createDialogArea(Composite parent) {
Composite comp = new Composite(parent, SWT.NULL);
comp.setFont(parent.getFont());
comp.setLayout(new GridLayout(1, true));
@ -149,7 +143,7 @@ public class ConvertTargetDialog extends Dialog {
convertersListGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
// Create the current config List
convertersList = new List(convertersListGroup, SWT.SINGLE|SWT.V_SCROLL|SWT.H_SCROLL|SWT.BORDER);
convertersList = new org.eclipse.swt.widgets.List(convertersListGroup, SWT.SINGLE|SWT.V_SCROLL|SWT.H_SCROLL|SWT.BORDER);
convertersList.setFont(convertersListGroup.getFont());
GridData data = new GridData(GridData.FILL_BOTH);
convertersList.setLayoutData(data);
@ -240,22 +234,21 @@ public class ConvertTargetDialog extends Dialog {
ConvertTargetDialog.isConversionSuccessful = isConversionSuccessful;
}
private Vector<IBuildObject> getProjectToolchains() {
Vector<IBuildObject> projectToolchains = new Vector<IBuildObject>();
private List<IBuildObject> getProjectToolchains() {
List<IBuildObject> projectToolchains = new ArrayList<>();
// Get the projectType from project.
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
if (info != null) {
IConfiguration[] configs = info.getManagedProject().getConfigurations();
for (IConfiguration config : configs) {
IToolChain tc = config.getToolChain();
if (tc != null) {
projectToolchains.add(tc);
IToolChain toolchain = config.getToolChain();
if (toolchain != null) {
projectToolchains.add(toolchain);
}
}
}
return projectToolchains;
}
}

View file

@ -0,0 +1,107 @@
/*******************************************************************************
* Copyright (c) 2005, 2014 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
* Anna Dushistova (MontaVista) - [366771] Converter fails to convert a CDT makefile project
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.ui.actions;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.internal.ui.util.AbstractResourceActionHandler;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.handlers.HandlerUtil;
public class ConvertTargetHandler extends AbstractResourceActionHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Shell shell = HandlerUtil.getActiveShellChecked(event);
IProject project;
IStructuredSelection selection = getSelection(event);
if (selection.size() != 1)
return null;
Object obj = selection.getFirstElement();
if (!(obj instanceof IProject))
return null;
project = (IProject) obj;
// Check whether the converters available for the selected project.
// If there are no converters display error dialog otherwise display converters list.
if (hasTargetConverters(project)) {
handleConvertTargetAction(project, shell);
} else {
MessageDialog.openError(shell, Messages.ConvertTargetHandler_No_Converter,
NLS.bind(Messages.ProjectConvert_noConverterErrorDialog_message, new String[] {project.getName()}) );
}
return null;
}
public static boolean hasTargetConverters(IProject project) {
return ManagedBuildManager.hasTargetConversionElements(getProjectType(project)) ||
ManagedBuildManager.hasAnyTargetConversionElements(getProjectToolchains(project));
}
private static IProjectType getProjectType(IProject project) {
IProjectType projectType = null;
// Get the projectType from project.
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
if (info != null) {
IManagedProject managedProject = info.getManagedProject();
if (managedProject != null)
projectType = managedProject.getProjectType();
}
return projectType;
}
private static List<IBuildObject> getProjectToolchains(IProject project) {
List<IBuildObject> projectToolchains = new ArrayList<>();
// Get the projectType from project.
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
if (info != null) {
IConfiguration[] configs = info.getManagedProject().getConfigurations();
for (IConfiguration config : configs) {
IToolChain toolchain = config.getToolChain();
if (toolchain != null) {
projectToolchains.add(toolchain);
}
}
}
return projectToolchains;
}
private static void handleConvertTargetAction(IProject project, Shell shell) {
String title = NLS.bind(Messages.ProjectConvert_title, project.getName());
ConvertTargetDialog dialog = new ConvertTargetDialog(shell, project, title);
if (dialog.open() != ConvertTargetDialog.OK)
return;
if (!ConvertTargetDialog.isConversionSuccessful()) {
MessageDialog.openError(shell, Messages.ProjectConvert_conversionErrordialog_title,
NLS.bind(Messages.ProjectConvert_conversionErrordialog_message, project.getName()));
}
}
}

View file

@ -0,0 +1,34 @@
/*******************************************************************************
* Copyright (c) 2010, 2011 Andrew Gvozdev 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:
* Andrew Gvozdev - Initial API and implementation
* IBM Corporation
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.ui.actions;
import org.eclipse.osgi.util.NLS;
class Messages extends NLS {
public static String BuildFilesHandler_buildingSelectedFiles;
public static String CleanFilesHandler_cleaningFiles;
public static String ConvertTargetHandler_No_Converter;
public static String ProjectConvert_noConverterErrorDialog_message;
public static String ProjectConvert_title;
public static String ProjectConvert_conversionErrordialog_message;
public static String ProjectConvert_conversionErrordialog_title;
public static String ProjectConvert_convertersList;
static {
// Initialize resource bundle.
NLS.initializeMessages(Messages.class.getName(), Messages.class);
}
private Messages() {
}
}

View file

@ -0,0 +1,24 @@
###############################################################################
# Copyright (c) 2000, 2011 IBM Corporation, QNX Software Systems, 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 - Initial API and implementation
# Andrew Gvozdev (Quoin Inc.) - Combined managedbuilder.ui bundles to NLS message format, bug 318812
# Sergey Prigogin (Google)
###############################################################################
BuildFilesHandler_buildingSelectedFiles=Building Selected Files
CleanFilesHandler_cleanSelectedFiles=Cleaning Selected Files
CleanFilesHandler_cleaningFiles=Cleaning files
# Project Conversion Dialog messages
ProjectConvert_conversionErrordialog_title=Project Conversion Error
ProjectConvert_conversionErrordialog_message=Error has occurred during the conversion of the project {0} .
ProjectConvert_noConverterErrorDialog_message=There are no converters available to convert the project {0} .
ProjectConvert_title=Project Converters for {0}
ProjectConvert_convertersList=Converters List
ConvertTargetHandler_No_Converter=No converter

View file

@ -0,0 +1,28 @@
/*******************************************************************************
* Copyright (c) 2014 Google, Inc 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:
* Sergey Prigogin (Google) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.ui.actions;
import org.eclipse.core.expressions.PropertyTester;
import org.eclipse.core.resources.IProject;
public class ProjectPropertyTester extends PropertyTester {
private static final String PROP_HAS_TARGET_CONVERTERS = "hasTargetConverters"; //$NON-NLS-1$
@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
if (!(receiver instanceof IProject) || args.length != 0)
return false;
if (property.equals(PROP_HAS_TARGET_CONVERTERS)) {
return ConvertTargetHandler.hasTargetConverters((IProject) receiver);
}
return false;
}
}

View file

@ -3406,7 +3406,8 @@
id="org.eclipse.cdt.ui.indexer">
<enabledWhen>
<adapt type="org.eclipse.core.resources.IProject">
<test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
<test property="org.eclipse.core.resources.projectNature"
value="org.eclipse.cdt.core.cnature"/>
</adapt>
</enabledWhen>
</page>
@ -3417,7 +3418,8 @@
id="org.eclipse.cdt.ui.fileTypes">
<enabledWhen>
<adapt type="org.eclipse.core.resources.IProject">
<test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
<test property="org.eclipse.core.resources.projectNature"
value="org.eclipse.cdt.core.cnature"/>
</adapt>
</enabledWhen>
</page>
@ -3428,7 +3430,8 @@
id="org.eclipse.cdt.ui.cHelp">
<enabledWhen>
<adapt type="org.eclipse.core.resources.IProject">
<test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
<test property="org.eclipse.core.resources.projectNature"
value="org.eclipse.cdt.core.cnature"/>
</adapt>
</enabledWhen>
</page>
@ -3439,7 +3442,8 @@
name="%CDTLanguagesProperty.name">
<enabledWhen>
<adapt type="org.eclipse.core.resources.IProject">
<test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
<test property="org.eclipse.core.resources.projectNature"
value="org.eclipse.cdt.core.cnature"/>
</adapt>
</enabledWhen>
</page>
@ -3463,7 +3467,8 @@
id="org.eclipse.cdt.ui.propertyPages.CodeFormatterPreferencePage">
<enabledWhen>
<adapt type="org.eclipse.core.resources.IProject">
<test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
<test property="org.eclipse.core.resources.projectNature"
value="org.eclipse.cdt.core.cnature"/>
</adapt>
</enabledWhen>
</page>
@ -3475,7 +3480,8 @@
<keywordReference id="org.eclipse.cdt.ui.common"/>
<enabledWhen>
<adapt type="org.eclipse.core.resources.IProject">
<test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
<test property="org.eclipse.core.resources.projectNature"
value="org.eclipse.cdt.core.cnature"/>
</adapt>
</enabledWhen>
</page>
@ -3487,9 +3493,10 @@
<enabledWhen>
<adapt type="org.eclipse.core.resources.IResource">
<and>
<test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
<test property="org.eclipse.core.resources.projectNature"
value="org.eclipse.cdt.core.cnature"/>
<test property="org.eclipse.cdt.ui.checkPreference"
value="org.eclipse.cdt.core/language.settings.providers.disabled=false"/>
value="org.eclipse.cdt.core/language.settings.providers.disabled=false"/>
</and>
</adapt>
</enabledWhen>
@ -3769,7 +3776,8 @@
<instanceof value="org.eclipse.cdt.ui.CElementGrouping"/>
<and>
<instanceof value="org.eclipse.core.resources.IResource"/>
<test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
<test property="org.eclipse.core.resources.projectNature"
value="org.eclipse.cdt.core.cnature"/>
</and>
<instanceof value="org.eclipse.core.resources.IWorkspaceRoot"/>
</or>
@ -3797,7 +3805,8 @@
<instanceof value="org.eclipse.cdt.core.model.ICElement" />
<and>
<instanceof value="org.eclipse.core.resources.IProject"/>
<test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
<test property="org.eclipse.core.resources.projectNature"
value="org.eclipse.cdt.core.cnature"/>
</and>
</or>
</enablement>
@ -3811,7 +3820,8 @@
<instanceof value="org.eclipse.cdt.core.model.ICElement" />
<and>
<instanceof value="org.eclipse.core.resources.IProject"/>
<test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
<test property="org.eclipse.core.resources.projectNature"
value="org.eclipse.cdt.core.cnature"/>
</and>
</or>
</enablement>
@ -3844,7 +3854,8 @@
<instanceof value="org.eclipse.cdt.core.model.ICElement" />
<and>
<instanceof value="org.eclipse.core.resources.IResource" />
<test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
<test property="org.eclipse.core.resources.projectNature"
value="org.eclipse.cdt.core.cnature"/>
</and>
</or>
</enablement>
@ -3858,7 +3869,8 @@
<instanceof value="org.eclipse.cdt.core.model.ICElement" />
<and>
<instanceof value="org.eclipse.core.resources.IResource" />
<test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
<test property="org.eclipse.core.resources.projectNature"
value="org.eclipse.cdt.core.cnature"/>
</and>
</or>
</enablement>
@ -3878,7 +3890,8 @@
<instanceof value="org.eclipse.cdt.core.model.ICElement" />
<and>
<instanceof value="org.eclipse.core.resources.IProject"/>
<test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
<test property="org.eclipse.core.resources.projectNature"
value="org.eclipse.cdt.core.cnature"/>
</and>
</or>
</enablement>
@ -3898,7 +3911,8 @@
<instanceof value="org.eclipse.cdt.core.model.ICElement" />
<and>
<instanceof value="org.eclipse.core.resources.IProject"/>
<test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
<test property="org.eclipse.core.resources.projectNature"
value="org.eclipse.cdt.core.cnature"/>
</and>
</or>
</enablement>
@ -3913,7 +3927,8 @@
<instanceof value="org.eclipse.cdt.core.model.ICElement" />
<and>
<instanceof value="org.eclipse.core.resources.IProject"/>
<test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
<test property="org.eclipse.core.resources.projectNature"
value="org.eclipse.cdt.core.cnature"/>
</and>
</or>
</enablement>
@ -3928,7 +3943,8 @@
<instanceof value="org.eclipse.cdt.core.model.ICElement" />
<and>
<instanceof value="org.eclipse.core.resources.IProject"/>
<test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
<test property="org.eclipse.core.resources.projectNature"
value="org.eclipse.cdt.core.cnature"/>
</and>
</or>
</enablement>
@ -3943,7 +3959,8 @@
<instanceof value="org.eclipse.cdt.core.model.ICElement" />
<and>
<instanceof value="org.eclipse.core.resources.IContainer"/>
<test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
<test property="org.eclipse.core.resources.projectNature"
value="org.eclipse.cdt.core.cnature"/>
</and>
</or>
</enablement>
@ -3958,7 +3975,8 @@
<instanceof value="org.eclipse.cdt.core.model.ICElement" />
<and>
<instanceof value="org.eclipse.core.resources.IProject"/>
<test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
<test property="org.eclipse.core.resources.projectNature"
value="org.eclipse.cdt.core.cnature"/>
</and>
</or>
</enablement>
@ -3972,7 +3990,8 @@
<instanceof value="org.eclipse.cdt.core.model.ICElement" />
<and>
<instanceof value="org.eclipse.core.resources.IContainer"/>
<test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
<test property="org.eclipse.core.resources.projectNature"
value="org.eclipse.cdt.core.cnature"/>
</and>
</or>
</enablement>