Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2017-09-28 00:27:40 +0000
committerDoug Schaefer2017-09-28 17:42:58 +0000
commit5228d193004a8001632385127f5b45a3a5243f7e (patch)
tree58b418f969732f94b12054aa58bba475e579bbd2 /build/org.eclipse.cdt.build.gcc.ui
parent80dc8d9c2517e738be2e16a6f98375266259bd0d (diff)
downloadorg.eclipse.cdt-5228d193004a8001632385127f5b45a3a5243f7e.tar.gz
org.eclipse.cdt-5228d193004a8001632385127f5b45a3a5243f7e.tar.xz
org.eclipse.cdt-5228d193004a8001632385127f5b45a3a5243f7e.zip
UI for adding toolchains for Core Build. New Generic Target Wizard.
Provide a way to add new toolchains. Also start of UI to allow for reordering them to help with toolchain selection for targets. New Generic Target Wizard for the new wizard2 extension point for the Launch Bar Target UI. Change-Id: I60635ab27dad5b69df72c339337473183dcf711a
Diffstat (limited to 'build/org.eclipse.cdt.build.gcc.ui')
-rw-r--r--build/org.eclipse.cdt.build.gcc.ui/.classpath7
-rw-r--r--build/org.eclipse.cdt.build.gcc.ui/.project28
-rw-r--r--build/org.eclipse.cdt.build.gcc.ui/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--build/org.eclipse.cdt.build.gcc.ui/META-INF/MANIFEST.MF14
-rw-r--r--build/org.eclipse.cdt.build.gcc.ui/build.properties5
-rw-r--r--build/org.eclipse.cdt.build.gcc.ui/plugin.xml13
-rw-r--r--build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/Activator.java71
-rw-r--r--build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/GCCToolChainSettingsPage.java128
-rw-r--r--build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/Messages.java54
-rw-r--r--build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/NewEnvVarDialog.java212
-rw-r--r--build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/NewGCCToolChainWizard.java74
-rw-r--r--build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/ToolChainEnvironmentPage.java205
-rw-r--r--build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/messages.properties40
13 files changed, 858 insertions, 0 deletions
diff --git a/build/org.eclipse.cdt.build.gcc.ui/.classpath b/build/org.eclipse.cdt.build.gcc.ui/.classpath
new file mode 100644
index 00000000000..eca7bdba8f0
--- /dev/null
+++ b/build/org.eclipse.cdt.build.gcc.ui/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/build/org.eclipse.cdt.build.gcc.ui/.project b/build/org.eclipse.cdt.build.gcc.ui/.project
new file mode 100644
index 00000000000..4142880ab75
--- /dev/null
+++ b/build/org.eclipse.cdt.build.gcc.ui/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.cdt.build.gcc.ui</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/build/org.eclipse.cdt.build.gcc.ui/.settings/org.eclipse.jdt.core.prefs b/build/org.eclipse.cdt.build.gcc.ui/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..0c68a61dca8
--- /dev/null
+++ b/build/org.eclipse.cdt.build.gcc.ui/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/build/org.eclipse.cdt.build.gcc.ui/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.build.gcc.ui/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..9e2e81bf1f1
--- /dev/null
+++ b/build/org.eclipse.cdt.build.gcc.ui/META-INF/MANIFEST.MF
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: GCC ToolChain Support UI
+Bundle-SymbolicName: org.eclipse.cdt.build.gcc.ui;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.cdt.build.gcc.ui.internal.Activator
+Bundle-Vendor: Eclipse CDT
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.cdt.ui;bundle-version="6.3.0",
+ org.eclipse.cdt.build.gcc.core;bundle-version="1.0.0",
+ org.eclipse.cdt.core;bundle-version="6.4.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Bundle-ActivationPolicy: lazy
diff --git a/build/org.eclipse.cdt.build.gcc.ui/build.properties b/build/org.eclipse.cdt.build.gcc.ui/build.properties
new file mode 100644
index 00000000000..e9863e281ea
--- /dev/null
+++ b/build/org.eclipse.cdt.build.gcc.ui/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
diff --git a/build/org.eclipse.cdt.build.gcc.ui/plugin.xml b/build/org.eclipse.cdt.build.gcc.ui/plugin.xml
new file mode 100644
index 00000000000..44d67046d7a
--- /dev/null
+++ b/build/org.eclipse.cdt.build.gcc.ui/plugin.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.cdt.ui.newToolChainWizards">
+ <wizard
+ class="org.eclipse.cdt.build.gcc.ui.internal.NewGCCToolChainWizard"
+ name="GCC or Compatible ToolChain"
+ providerId="org.eclipse.cdt.build.gcc.core.provider.user">
+ </wizard>
+ </extension>
+
+</plugin>
diff --git a/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/Activator.java b/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/Activator.java
new file mode 100644
index 00000000000..30daf1ee42a
--- /dev/null
+++ b/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/Activator.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2017 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
+ *******************************************************************************/
+package org.eclipse.cdt.build.gcc.ui.internal;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.cdt.build.gcc.ui"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ public static void log(IStatus status) {
+ plugin.getLog().log(status);
+ }
+
+ public static <T> T getService(Class<T> service) {
+ BundleContext context = plugin.getBundle().getBundleContext();
+ ServiceReference<T> ref = context.getServiceReference(service);
+ return ref != null ? context.getService(ref) : null;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/GCCToolChainSettingsPage.java b/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/GCCToolChainSettingsPage.java
new file mode 100644
index 00000000000..22af1c0dc81
--- /dev/null
+++ b/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/GCCToolChainSettingsPage.java
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * Copyright (c) 2017 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
+ *******************************************************************************/
+package org.eclipse.cdt.build.gcc.ui.internal;
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import org.eclipse.cdt.build.gcc.core.GCCToolChain;
+import org.eclipse.cdt.core.build.IToolChain;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+public class GCCToolChainSettingsPage extends WizardPage {
+
+ private final GCCToolChain toolChain;
+ private Text compilerText;
+ private Text osText;
+ private Text archText;
+
+ public GCCToolChainSettingsPage(GCCToolChain toolChain) {
+ super(GCCToolChainSettingsPage.class.getName());
+ this.toolChain = toolChain;
+ setTitle(Messages.GCCToolChainSettingsPage_Title);
+ setDescription(Messages.GCCToolChainSettingsPage_Description);
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ Composite comp = new Composite(parent, SWT.NONE);
+ comp.setLayout(new GridLayout(2, false));
+
+ Label label = new Label(comp, SWT.NONE);
+ label.setText(Messages.GCCToolChainSettingsPage_Compiler);
+
+ Composite compilerComp = new Composite(comp, SWT.NONE);
+ compilerComp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginHeight = layout.marginWidth = 0;
+ compilerComp.setLayout(layout);
+
+ compilerText = new Text(compilerComp, SWT.BORDER);
+ compilerText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ compilerText.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ updateComplete();
+ }
+ });
+ compilerText.addModifyListener(e -> updateComplete());
+ if (toolChain != null) {
+ compilerText.setText(toolChain.getPath().toString());
+ }
+
+ Button compilerBrowse = new Button(compilerComp, SWT.PUSH);
+ compilerBrowse.setText(Messages.GCCToolChainSettingsPage_Browse);
+ compilerBrowse.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ FileDialog fileDialog = new FileDialog(getShell());
+ String newText = fileDialog.open();
+ if (newText != null) {
+ compilerText.setText(newText);
+ }
+ }
+ });
+
+ label = new Label(comp, SWT.NONE);
+ label.setText(Messages.GCCToolChainSettingsPage_OS);
+
+ osText = new Text(comp, SWT.BORDER);
+ osText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ if (toolChain != null) {
+ String os = toolChain.getProperty(IToolChain.ATTR_OS);
+ if (os != null) {
+ osText.setText(os);
+ }
+ }
+
+ label = new Label(comp, SWT.NONE);
+ label.setText(Messages.GCCToolChainSettingsPage_Arch);
+
+ archText = new Text(comp, SWT.BORDER);
+ archText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ if (toolChain != null) {
+ String arch = toolChain.getProperty(IToolChain.ATTR_ARCH);
+ if (arch != null) {
+ archText.setText(arch);
+ }
+ }
+
+ updateComplete();
+
+ setControl(comp);
+ }
+
+ private void updateComplete() {
+ setPageComplete(!compilerText.getText().trim().isEmpty());
+ }
+
+ public Path getPath() {
+ return Paths.get(compilerText.getText().trim());
+ }
+
+ public String getOS() {
+ return osText.getText().trim();
+ }
+
+ public String getArch() {
+ return archText.getText().trim();
+ }
+
+}
diff --git a/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/Messages.java b/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/Messages.java
new file mode 100644
index 00000000000..4edba7647a9
--- /dev/null
+++ b/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/Messages.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2017 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
+ *******************************************************************************/
+package org.eclipse.cdt.build.gcc.ui.internal;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.cdt.build.gcc.ui.internal.messages"; //$NON-NLS-1$
+ public static String GCCToolChainSettingsPage_Arch;
+ public static String GCCToolChainSettingsPage_Browse;
+ public static String GCCToolChainSettingsPage_Compiler;
+ public static String GCCToolChainSettingsPage_Description;
+ public static String GCCToolChainSettingsPage_OS;
+ public static String GCCToolChainSettingsPage_Title;
+ public static String NewEnvVarDialog_Append;
+ public static String NewEnvVarDialog_Delimiter;
+ public static String NewEnvVarDialog_Edit;
+ public static String NewEnvVarDialog_Name;
+ public static String NewEnvVarDialog_New;
+ public static String NewEnvVarDialog_Operation;
+ public static String NewEnvVarDialog_Prepend;
+ public static String NewEnvVarDialog_Replace;
+ public static String NewEnvVarDialog_Select;
+ public static String NewEnvVarDialog_Unset;
+ public static String NewEnvVarDialog_Value;
+ public static String NewGCCToolChainWizard_Add;
+ public static String NewGCCToolChainWizard_New;
+ public static String ToolChainEnvironmentPage_Add;
+ public static String ToolChainEnvironmentPage_Append;
+ public static String ToolChainEnvironmentPage_Description;
+ public static String ToolChainEnvironmentPage_Edit;
+ public static String ToolChainEnvironmentPage_Name;
+ public static String ToolChainEnvironmentPage_Operation;
+ public static String ToolChainEnvironmentPage_Prepend;
+ public static String ToolChainEnvironmentPage_Remove;
+ public static String ToolChainEnvironmentPage_RemoveMessage;
+ public static String ToolChainEnvironmentPage_RemoveTitle;
+ public static String ToolChainEnvironmentPage_Replace;
+ public static String ToolChainEnvironmentPage_Title;
+ public static String ToolChainEnvironmentPage_Unset;
+ public static String ToolChainEnvironmentPage_Value;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/NewEnvVarDialog.java b/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/NewEnvVarDialog.java
new file mode 100644
index 00000000000..c1348b1c781
--- /dev/null
+++ b/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/NewEnvVarDialog.java
@@ -0,0 +1,212 @@
+/*******************************************************************************
+ * Copyright (c) 2017 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
+ *******************************************************************************/
+package org.eclipse.cdt.build.gcc.ui.internal;
+
+import org.eclipse.cdt.core.envvar.EnvironmentVariable;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+public class NewEnvVarDialog extends Dialog {
+
+ private Text nameText;
+ private Label valueLabel;
+ private Text valueText;
+ private Label delimiterLabel;
+ private Text delimiterText;
+ private Button replaceButton;
+ private Button prependButton;
+ private Button appendButton;
+ private Button removeButton;
+
+ private IEnvironmentVariable envvar;
+
+ public NewEnvVarDialog(Shell parentShell) {
+ super(parentShell);
+ }
+
+ public NewEnvVarDialog(Shell parentShell, IEnvironmentVariable var) {
+ super(parentShell);
+ this.envvar = var;
+ }
+
+ @Override
+ protected boolean isResizable() {
+ return true;
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ if (envvar == null) {
+ getShell().setText(Messages.NewEnvVarDialog_New);
+ } else {
+ getShell().setText(Messages.NewEnvVarDialog_Edit);
+ }
+
+ Composite comp = new Composite(parent, SWT.NONE);
+ GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
+ layoutData.widthHint = 400;
+ comp.setLayoutData(layoutData);
+ comp.setLayout(new GridLayout(3, false));
+
+ Group opGroup = new Group(comp, SWT.NONE);
+ opGroup.setText(Messages.NewEnvVarDialog_Operation);
+ opGroup.setLayout(new GridLayout(4, false));
+ layoutData = new GridData(SWT.FILL, SWT.FILL, true, false);
+ layoutData.horizontalSpan = 3;
+ opGroup.setLayoutData(layoutData);
+
+ replaceButton = new Button(opGroup, SWT.RADIO);
+ replaceButton.setText(Messages.NewEnvVarDialog_Replace);
+
+ prependButton = new Button(opGroup, SWT.RADIO);
+ prependButton.setText(Messages.NewEnvVarDialog_Prepend);
+ prependButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ updateEnablement();
+ }
+ });
+
+ appendButton = new Button(opGroup, SWT.RADIO);
+ appendButton.setText(Messages.NewEnvVarDialog_Append);
+ appendButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ updateEnablement();
+ }
+ });
+
+ removeButton = new Button(opGroup, SWT.RADIO);
+ removeButton.setText(Messages.NewEnvVarDialog_Unset);
+ removeButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ updateEnablement();
+ }
+ });
+
+ if (envvar == null) {
+ replaceButton.setSelection(true);
+ } else {
+ switch (envvar.getOperation()) {
+ case IEnvironmentVariable.ENVVAR_REPLACE:
+ replaceButton.setSelection(true);
+ break;
+ case IEnvironmentVariable.ENVVAR_PREPEND:
+ prependButton.setSelection(true);
+ break;
+ case IEnvironmentVariable.ENVVAR_APPEND:
+ appendButton.setSelection(true);
+ break;
+ default:
+ removeButton.setSelection(true);
+ }
+ }
+
+ Label label = new Label(comp, SWT.NONE);
+ label.setText(Messages.NewEnvVarDialog_Name);
+
+ nameText = new Text(comp, SWT.BORDER);
+ nameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ if (envvar != null) {
+ nameText.setText(envvar.getName());
+ }
+
+ Button selectButton = new Button(comp, SWT.PUSH);
+ selectButton.setText(Messages.NewEnvVarDialog_Select);
+
+ valueLabel = new Label(comp, SWT.NONE);
+ valueLabel.setText(Messages.NewEnvVarDialog_Value);
+
+ valueText = new Text(comp, SWT.BORDER);
+ layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
+ layoutData.horizontalSpan = 2;
+ valueText.setLayoutData(layoutData);
+ if (envvar != null && envvar.getValue() != null) {
+ valueText.setText(envvar.getValue());
+ }
+
+ delimiterLabel = new Label(comp, SWT.NONE);
+ delimiterLabel.setText(Messages.NewEnvVarDialog_Delimiter);
+
+ delimiterText = new Text(comp, SWT.BORDER);
+ layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
+ layoutData.horizontalSpan = 2;
+ delimiterText.setLayoutData(layoutData);
+ if (envvar != null && envvar.getDelimiter() != null) {
+ delimiterText.setText(envvar.getDelimiter());
+ }
+
+ updateEnablement();
+ return comp;
+ }
+
+ private void updateEnablement() {
+ valueLabel.setEnabled(!removeButton.getSelection());
+ valueText.setEnabled(!removeButton.getSelection());
+
+ delimiterLabel.setEnabled(prependButton.getSelection() || appendButton.getSelection());
+ delimiterText.setEnabled(prependButton.getSelection() || appendButton.getSelection());
+ }
+
+ @Override
+ protected void okPressed() {
+ String name = nameText.getText().trim();
+
+ int operation;
+ if (replaceButton.getSelection()) {
+ operation = IEnvironmentVariable.ENVVAR_REPLACE;
+ } else if (prependButton.getSelection()) {
+ operation = IEnvironmentVariable.ENVVAR_PREPEND;
+ } else if (appendButton.getSelection()) {
+ operation = IEnvironmentVariable.ENVVAR_APPEND;
+ } else {
+ operation = IEnvironmentVariable.ENVVAR_REMOVE;
+ }
+
+ String value;
+ if (valueText.isEnabled()) {
+ value = valueText.getText().trim();
+ if (value.isEmpty()) {
+ value = null;
+ }
+ } else {
+ value = null;
+ }
+
+ String delimiter;
+ if (delimiterText.isEnabled()) {
+ delimiter = delimiterText.getText().trim();
+ if (delimiter.isEmpty()) {
+ delimiter = null;
+ }
+ } else {
+ delimiter = null;
+ }
+
+ envvar = new EnvironmentVariable(name, value, operation, delimiter);
+
+ super.okPressed();
+ }
+
+ public IEnvironmentVariable getEnvVar() {
+ return envvar;
+ }
+}
diff --git a/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/NewGCCToolChainWizard.java b/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/NewGCCToolChainWizard.java
new file mode 100644
index 00000000000..b6fcb97fa04
--- /dev/null
+++ b/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/NewGCCToolChainWizard.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2017 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
+ *******************************************************************************/
+package org.eclipse.cdt.build.gcc.ui.internal;
+
+import java.nio.file.Path;
+
+import org.eclipse.cdt.build.gcc.core.GCCToolChain;
+import org.eclipse.cdt.build.gcc.core.GCCUserToolChainProvider;
+import org.eclipse.cdt.core.build.IToolChain;
+import org.eclipse.cdt.core.build.IToolChainManager;
+import org.eclipse.cdt.core.build.IUserToolChainProvider;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.cdt.ui.build.ToolChainWizard;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+
+public class NewGCCToolChainWizard extends ToolChainWizard {
+
+ private GCCToolChainSettingsPage settingsPage;
+ private ToolChainEnvironmentPage envPage;
+
+ @Override
+ public boolean performFinish() {
+ Path path = settingsPage.getPath();
+ String os = settingsPage.getOS();
+ String arch = settingsPage.getArch();
+ IEnvironmentVariable[] envvars = envPage.getEnvVars();
+
+ new Job(Messages.NewGCCToolChainWizard_Add) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ IToolChainManager manager = Activator.getService(IToolChainManager.class);
+ IUserToolChainProvider provider = (IUserToolChainProvider) manager
+ .getProvider(GCCUserToolChainProvider.PROVIDER_ID);
+
+ if (toolChain != null) {
+ provider.removeToolChain(toolChain);
+ }
+
+ GCCToolChain gcc = new GCCToolChain(provider, path, arch, envvars);
+ gcc.setProperty(IToolChain.ATTR_OS, os);
+ provider.addToolChain(gcc);
+ return Status.OK_STATUS;
+ } catch (CoreException e) {
+ return e.getStatus();
+ }
+ }
+ }.schedule();
+ return true;
+ }
+
+ @Override
+ public void addPages() {
+ super.addPages();
+
+ settingsPage = new GCCToolChainSettingsPage((GCCToolChain) toolChain);
+ addPage(settingsPage);
+
+ envPage = new ToolChainEnvironmentPage(toolChain);
+ addPage(envPage);
+
+ setWindowTitle(Messages.NewGCCToolChainWizard_New);
+ }
+
+}
diff --git a/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/ToolChainEnvironmentPage.java b/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/ToolChainEnvironmentPage.java
new file mode 100644
index 00000000000..cbe4bb8e66a
--- /dev/null
+++ b/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/ToolChainEnvironmentPage.java
@@ -0,0 +1,205 @@
+/*******************************************************************************
+ * Copyright (c) 2017 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
+ *******************************************************************************/
+package org.eclipse.cdt.build.gcc.ui.internal;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.cdt.core.build.IToolChain;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.BaseLabelProvider;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+public class ToolChainEnvironmentPage extends WizardPage {
+
+ private TableViewer tableViewer;
+ private Button editButton;
+ private Button removeButton;
+
+ private List<IEnvironmentVariable> envvars;
+
+ public ToolChainEnvironmentPage(IToolChain toolChain) {
+ super(ToolChainEnvironmentPage.class.getName());
+ setTitle(Messages.ToolChainEnvironmentPage_Title);
+ setDescription(Messages.ToolChainEnvironmentPage_Description);
+
+ if (toolChain != null && toolChain.getVariables() != null) {
+ this.envvars = new LinkedList<>(Arrays.asList(toolChain.getVariables()));
+ } else {
+ this.envvars = new LinkedList<>();
+ }
+ }
+
+ private static abstract class TableLabelProvider extends BaseLabelProvider implements ITableLabelProvider {
+ @Override
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ Composite comp = new Composite(parent, SWT.NONE);
+ comp.setLayout(new GridLayout(2, false));
+
+ Table table = new Table(comp, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.FULL_SELECTION);
+ table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ TableColumn column = new TableColumn(table, SWT.LEFT);
+ column.setText(Messages.ToolChainEnvironmentPage_Name);
+ column.setWidth(150);
+
+ column = new TableColumn(table, SWT.LEFT);
+ column.setText(Messages.ToolChainEnvironmentPage_Value);
+ column.setWidth(150);
+
+ column = new TableColumn(table, SWT.LEFT);
+ column.setText(Messages.ToolChainEnvironmentPage_Operation);
+ column.setWidth(75);
+
+ tableViewer = new TableViewer(table);
+ tableViewer.setContentProvider(new IStructuredContentProvider() {
+ @Override
+ public Object[] getElements(Object inputElement) {
+ return envvars.toArray();
+ }
+ });
+ tableViewer.setLabelProvider(new TableLabelProvider() {
+ @Override
+ public String getColumnText(Object element, int columnIndex) {
+ IEnvironmentVariable var = (IEnvironmentVariable) element;
+ switch (columnIndex) {
+ case 0:
+ return var.getName();
+ case 1:
+ return var.getValue();
+ case 2:
+ switch (var.getOperation()) {
+ case IEnvironmentVariable.ENVVAR_REPLACE:
+ return Messages.ToolChainEnvironmentPage_Replace;
+ case IEnvironmentVariable.ENVVAR_PREPEND:
+ return Messages.ToolChainEnvironmentPage_Prepend;
+ case IEnvironmentVariable.ENVVAR_APPEND:
+ return Messages.ToolChainEnvironmentPage_Append;
+ case IEnvironmentVariable.ENVVAR_REMOVE:
+ return Messages.ToolChainEnvironmentPage_Unset;
+ }
+ }
+ return null;
+ }
+ });
+
+ Composite buttonComp = new Composite(comp, SWT.NONE);
+ buttonComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
+ buttonComp.setLayout(new GridLayout());
+
+ Button addButton = new Button(buttonComp, SWT.PUSH);
+ addButton.setText(Messages.ToolChainEnvironmentPage_Add);
+ addButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+ addButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ NewEnvVarDialog dialog = new NewEnvVarDialog(getShell());
+ if (dialog.open() == Window.OK) {
+ envvars.add(dialog.getEnvVar());
+ tableViewer.refresh();
+ }
+ }
+ });
+
+ editButton = new Button(buttonComp, SWT.PUSH);
+ editButton.setText(Messages.ToolChainEnvironmentPage_Edit);
+ editButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+ editButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ handleEdit();
+ }
+ });
+
+ removeButton = new Button(buttonComp, SWT.PUSH);
+ removeButton.setText(Messages.ToolChainEnvironmentPage_Remove);
+ removeButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+ removeButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (MessageDialog.openConfirm(getShell(), Messages.ToolChainEnvironmentPage_RemoveTitle,
+ Messages.ToolChainEnvironmentPage_RemoveMessage)) {
+ @SuppressWarnings("rawtypes")
+ Iterator i = tableViewer.getStructuredSelection().iterator();
+ while (i.hasNext()) {
+ IEnvironmentVariable var = (IEnvironmentVariable) i.next();
+ envvars.remove(var);
+ }
+ tableViewer.refresh();
+ }
+ }
+ });
+
+ table.addSelectionListener(new SelectionListener() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ updateButtons();
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ updateButtons();
+ if (table.getSelectionCount() == 1) {
+ handleEdit();
+ }
+ }
+ });
+
+ tableViewer.setInput(envvars);
+ setControl(comp);
+ }
+
+ private void updateButtons() {
+ int n = tableViewer.getTable().getSelectionCount();
+ editButton.setEnabled(n == 1);
+ removeButton.setEnabled(n > 0);
+ }
+
+ private void handleEdit() {
+ IEnvironmentVariable var = (IEnvironmentVariable) tableViewer.getStructuredSelection().getFirstElement();
+ NewEnvVarDialog dialog = new NewEnvVarDialog(getShell(), var);
+ if (dialog.open() == Window.OK) {
+ envvars.remove(var);
+ envvars.add(dialog.getEnvVar());
+ tableViewer.refresh();
+ tableViewer.setSelection(new StructuredSelection(dialog.getEnvVar()));
+ }
+ }
+
+ public IEnvironmentVariable[] getEnvVars() {
+ return !envvars.isEmpty() ? envvars.toArray(new IEnvironmentVariable[0]) : null;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/messages.properties b/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/messages.properties
new file mode 100644
index 00000000000..da97717652f
--- /dev/null
+++ b/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/messages.properties
@@ -0,0 +1,40 @@
+################################################################################
+# Copyright (c) 2017 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
+################################################################################
+GCCToolChainSettingsPage_Arch=CPU Architecture:
+GCCToolChainSettingsPage_Browse=Browse...
+GCCToolChainSettingsPage_Compiler=Compiler:
+GCCToolChainSettingsPage_Description=Enter the path to the compiler and properties for the toolchain.
+GCCToolChainSettingsPage_OS=Operating System:
+GCCToolChainSettingsPage_Title=GCC ToolChain Settings
+NewEnvVarDialog_Append=Append
+NewEnvVarDialog_Delimiter=Delimiter:
+NewEnvVarDialog_Edit=Edit Environment Variable
+NewEnvVarDialog_Name=Name:
+NewEnvVarDialog_New=New Environment Variable
+NewEnvVarDialog_Operation=Operation
+NewEnvVarDialog_Prepend=Prepend
+NewEnvVarDialog_Replace=Replace
+NewEnvVarDialog_Select=Select...
+NewEnvVarDialog_Unset=Unset
+NewEnvVarDialog_Value=Value:
+NewGCCToolChainWizard_Add=Add ToolChain
+NewGCCToolChainWizard_New=New GCC ToolChain
+ToolChainEnvironmentPage_Add=Add...
+ToolChainEnvironmentPage_Append=Append
+ToolChainEnvironmentPage_Description=Environment variables to set when using toolchain.
+ToolChainEnvironmentPage_Edit=Edit...
+ToolChainEnvironmentPage_Name=Name
+ToolChainEnvironmentPage_Operation=Operation
+ToolChainEnvironmentPage_Prepend=Prepend
+ToolChainEnvironmentPage_Remove=Remove
+ToolChainEnvironmentPage_RemoveMessage=Are you sure you would like to remove the selected environment variable(s)
+ToolChainEnvironmentPage_RemoveTitle=Remove
+ToolChainEnvironmentPage_Replace=Replace
+ToolChainEnvironmentPage_Title=Environment Variables
+ToolChainEnvironmentPage_Unset=Unset
+ToolChainEnvironmentPage_Value=Value

Back to the top