1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

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>
This commit is contained in:
Jesper Eskilson 2016-03-08 20:20:09 -05:00 committed by Gerrit Code Review @ Eclipse.org
parent eac2f92bb4
commit 1d09e0e2af
4 changed files with 101 additions and 0 deletions

View file

@ -13,5 +13,18 @@
project="true">
</wizard>
</extension>
<extension
point="org.eclipse.ui.propertyPages">
<page
class="org.eclipse.cdt.cmake.ui.properties.CMakePropertyPage"
id="org.eclipse.cdt.cmake.ui.properties.cmakePropertyPage"
name="CMake">
<enabledWhen>
<instanceof
value="org.eclipse.core.resources.IProject">
</instanceof>
</enabledWhen>
</page>
</extension>
</plugin>

View file

@ -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;
}
}

View file

@ -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() {
}
}

View file

@ -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...