Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2014-07-30 22:07:38 -0400
committerSergey Prigogin2014-07-30 22:07:38 -0400
commit7880c684eb41f66086987ff1335068b5afef9c82 (patch)
tree26b7f4ce3d643be57b87a519944d0211fc06af09 /build/org.eclipse.cdt.managedbuilder.ui
parent31f37f5b63cc75cbf8d39b14ab05019607c462b6 (diff)
downloadorg.eclipse.cdt-7880c684eb41f66086987ff1335068b5afef9c82.tar.gz
org.eclipse.cdt-7880c684eb41f66086987ff1335068b5afef9c82.tar.xz
org.eclipse.cdt-7880c684eb41f66086987ff1335068b5afef9c82.zip
Slightly reduced clutter in the project's context menu.
Diffstat (limited to 'build/org.eclipse.cdt.managedbuilder.ui')
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/META-INF/MANIFEST.MF3
-rwxr-xr-xbuild/org.eclipse.cdt.managedbuilder.ui/plugin.properties9
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/plugin.xml61
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.java23
-rwxr-xr-xbuild/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.properties7
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/BuildFilesHandler.java3
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/CleanFilesHandler.java3
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/ConvertTargetAction.java144
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/ConvertTargetDialog.java59
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/ConvertTargetHandler.java107
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/Messages.java34
-rwxr-xr-xbuild/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/Messages.properties24
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/ProjectPropertyTester.java28
13 files changed, 281 insertions, 224 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.managedbuilder.ui/META-INF/MANIFEST.MF
index ff182a48d1..9efcfcd54a 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/META-INF/MANIFEST.MF
+++ b/build/org.eclipse.cdt.managedbuilder.ui/META-INF/MANIFEST.MF
@@ -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
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/plugin.properties b/build/org.eclipse.cdt.managedbuilder.ui/plugin.properties
index 6d22cd22fa..93aea465d5 100755
--- a/build/org.eclipse.cdt.managedbuilder.ui/plugin.properties
+++ b/build/org.eclipse.cdt.managedbuilder.ui/plugin.properties
@@ -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
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml b/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml
index 3260626260..357e384856 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml
+++ b/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml
@@ -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,6 +116,42 @@
</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
@@ -116,20 +159,6 @@
<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"
id="org.eclipse.cdt.managedbuilder.ui.popupMenu.BuildAll">
<action
class="org.eclipse.cdt.managedbuilder.internal.ui.actions.CleanAndBuildAction"
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.java
index 18939f441d..393ead7f20 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.java
@@ -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;
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.properties b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.properties
index 3e3cc73ada..8996945a2e 100755
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.properties
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.properties
@@ -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
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/BuildFilesHandler.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/BuildFilesHandler.java
index 7e7b87583e..0d63e5bf3c 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/BuildFilesHandler.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/BuildFilesHandler.java
@@ -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;
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/CleanFilesHandler.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/CleanFilesHandler.java
index 5e12e8bf17..37074ee912 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/CleanFilesHandler.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/CleanFilesHandler.java
@@ -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;
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/ConvertTargetAction.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/ConvertTargetAction.java
deleted file mode 100644
index 89a70eecdf..0000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/ConvertTargetAction.java
+++ /dev/null
@@ -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;
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/ConvertTargetDialog.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/ConvertTargetDialog.java
index e5de8c8b85..812220e1b3 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/ConvertTargetDialog.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/ConvertTargetDialog.java
@@ -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;
}
-
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/ConvertTargetHandler.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/ConvertTargetHandler.java
new file mode 100644
index 0000000000..8c45bef2e1
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/ConvertTargetHandler.java
@@ -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()));
+ }
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/Messages.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/Messages.java
new file mode 100644
index 0000000000..313b1070c6
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/Messages.java
@@ -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() {
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/Messages.properties b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/Messages.properties
new file mode 100755
index 0000000000..5f20f5f669
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/Messages.properties
@@ -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
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/ProjectPropertyTester.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/ProjectPropertyTester.java
new file mode 100644
index 0000000000..5f13d48f9a
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/ProjectPropertyTester.java
@@ -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;
+ }
+}

Back to the top