Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesper Eskilson2016-03-09 01:20:09 +0000
committerGerrit Code Review @ Eclipse.org2016-03-14 20:08:35 +0000
commit1d09e0e2af1258795ff05b7b4578d8405e76e462 (patch)
tree19766dc878669201914ee7483ff627d0a1b46b84 /build/org.eclipse.cdt.cmake.ui/src/org/eclipse
parenteac2f92bb4e7879027c7c4018f2b9daee8bfa751 (diff)
downloadorg.eclipse.cdt-1d09e0e2af1258795ff05b7b4578d8405e76e462.tar.gz
org.eclipse.cdt-1d09e0e2af1258795ff05b7b4578d8405e76e462.tar.xz
org.eclipse.cdt-1d09e0e2af1258795ff05b7b4578d8405e76e462.zip
Added property page for CMake projects
Currently only contains a button for launching the CMake GUI (cmake-qt-gui), but we might want to put other things in here as well. Change-Id: Ia89ad409eaad17a170cf1e2f1cd4fb31a7d678e2 Signed-off-by: Jesper Eskilson <jesper.eskilson@iar.com>
Diffstat (limited to 'build/org.eclipse.cdt.cmake.ui/src/org/eclipse')
-rw-r--r--build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/properties/CMakePropertyPage.java67
-rw-r--r--build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/properties/Messages.java18
-rw-r--r--build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/properties/messages.properties3
3 files changed, 88 insertions, 0 deletions
diff --git a/build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/properties/CMakePropertyPage.java b/build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/properties/CMakePropertyPage.java
new file mode 100644
index 00000000000..65052826fcc
--- /dev/null
+++ b/build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/properties/CMakePropertyPage.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2016 IAR Systems AB
+ * 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:
+ * IAR Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.cmake.ui.properties;
+
+import java.io.IOException;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.dialogs.MessageDialog;
+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.ui.dialogs.PropertyPage;
+
+/**
+ * Property page for CMake projects. The only thing we have here at the moment is a button
+ * to launch the CMake GUI configurator (cmake-qt-gui).
+ *
+ * We assume that the build directory is in project/build/configname, which is where
+ * the CMake project wizard puts it. We also assume that "cmake-gui" is in the user's
+ * PATH.
+ */
+public class CMakePropertyPage extends PropertyPage {
+
+ protected Control createContents(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ composite.setLayout(layout);
+ GridData data = new GridData(GridData.FILL);
+ data.grabExcessHorizontalSpace = true;
+ composite.setLayoutData(data);
+
+ Button b = new Button(composite, SWT.NONE);
+ b.setText(Messages.CMakePropertyPage_LaunchCMakeGui);
+ b.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ IProject project = (IProject) getElement();
+ try {
+ String configName = project.getActiveBuildConfig().getName();
+ String sourceDir = project.getLocation().toOSString();
+ String buildDir = project.getLocation().append("build").append(configName).toOSString(); //$NON-NLS-1$
+
+ Runtime.getRuntime().exec(new String[] { "cmake-gui", "-H" + sourceDir, "-B" + buildDir }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ } catch (CoreException | IOException e1) {
+ MessageDialog.openError(parent.getShell(), Messages.CMakePropertyPage_FailedToStartCMakeGui_Title,
+ Messages.CMakePropertyPage_FailedToStartCMakeGui_Body + e1.getMessage());
+ }
+ }
+ });
+
+ return composite;
+ }
+}
diff --git a/build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/properties/Messages.java b/build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/properties/Messages.java
new file mode 100644
index 00000000000..33caa15ce4f
--- /dev/null
+++ b/build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/properties/Messages.java
@@ -0,0 +1,18 @@
+package org.eclipse.cdt.cmake.ui.properties;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.cdt.cmake.ui.properties.messages"; //$NON-NLS-1$
+ public static String CMakePropertyPage_FailedToStartCMakeGui_Body;
+ public static String CMakePropertyPage_FailedToStartCMakeGui_Title;
+ public static String CMakePropertyPage_LaunchCMakeGui;
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/properties/messages.properties b/build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/properties/messages.properties
new file mode 100644
index 00000000000..ebbe62ef2b5
--- /dev/null
+++ b/build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/properties/messages.properties
@@ -0,0 +1,3 @@
+CMakePropertyPage_FailedToStartCMakeGui_Body=Failed to run the CMake GUI:
+CMakePropertyPage_FailedToStartCMakeGui_Title=Failed to run CMake GUI
+CMakePropertyPage_LaunchCMakeGui=Launch CMake GUI...

Back to the top