Merge "Added message to notify when simulation is unsupported."

This commit is contained in:
Brad Miller (WPI)
2014-10-28 13:48:04 -07:00
committed by Gerrit Code Review
3 changed files with 58 additions and 2 deletions

View File

@@ -0,0 +1,44 @@
package edu.wpi.first.wpilib.plugins.core.launching;
import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import javax.swing.JOptionPane;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugPlugin;
import edu.wpi.first.wpilib.plugins.core.WPILibCore;
public class SimulationNotification {
private static final String URL = "https://wpilib.screenstepslive.com/s/4485/m/23353";
private static final String SIMULATION_UNSUPPORTED_MSG =
"Simulation is unsupported on your current setup.\n" +
"For more information see: " + URL;
public static void showUnsupported() {
String title = "Simulation Unsupported";
String message = SIMULATION_UNSUPPORTED_MSG;
JOptionPane.showMessageDialog(null, message, title, JOptionPane.OK_OPTION);
try {
Desktop.getDesktop().browse(new URI(URL));
} catch (IOException e) {
WPILibCore.logError("Can't open "+URL, e);
} catch (URISyntaxException e) {
WPILibCore.logError("Can't open "+URL, e);
}
}
public static boolean supportsSimulation() {
String[] cmd = {"frcsim", "--version"};
try {
DebugPlugin.exec(cmd, new File(System.getProperty("user.home")));
return true;
} catch (CoreException e) {
return false;
}
}
}

View File

@@ -18,6 +18,7 @@ import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.PlatformUI;
import edu.wpi.first.wpilib.plugins.core.launching.AntLauncher;
import edu.wpi.first.wpilib.plugins.core.launching.SimulationNotification;
import edu.wpi.first.wpilib.plugins.cpp.WPILibCPPPlugin;
/**
@@ -79,7 +80,12 @@ public class SimulateLaunchShortcut implements ILaunchShortcut {
* @param activeProj The project that the script will be run on/from
* @param mode The mode it will be run in (ILaunchManager.RUN_MODE or ILaunchManager.DEBUG_MODE)
*/
public void runConfig(IProject activeProj, String mode){
public void runConfig(IProject activeProj, String mode) {
if (!SimulationNotification.supportsSimulation()) {
SimulationNotification.showUnsupported();
return;
}
String targets = "simulate";
if(mode.equals(ILaunchManager.RUN_MODE)){

View File

@@ -2,6 +2,8 @@ package edu.wpi.first.wpilib.plugins.java.launching;
import org.eclipse.core.resources.IProject;
import edu.wpi.first.wpilib.plugins.core.launching.SimulationNotification;
public class SimulateLaunchShortcut extends JavaLaunchShortcut {
@@ -11,7 +13,11 @@ public class SimulateLaunchShortcut extends JavaLaunchShortcut {
* @param mode The mode it will be run in (ILaunchManager.RUN_MODE or ILaunchManager.DEBUG_MODE)
*/
public void runConfig(IProject activeProj, String mode){
runConfigHelper(activeProj, mode, "simulate", "debug-simulate");
if (SimulationNotification.supportsSimulation()) {
runConfigHelper(activeProj, mode, "simulate", "debug-simulate");
} else {
SimulationNotification.showUnsupported();
}
}
protected String getHostname(IProject proj) {