Some much need love for the eclipse plugins.

Features/bug fixes include:
- Paul's progress bar for the installers
- Fix to prevent repeatede installation
- Right clicking and running Java projects works now
- Better logging to help find issues (Window > Show View > Other > Error Log)

Change-Id: I2cc791a58752cdeffec27f73880e7afcd1e95771
This commit is contained in:
Alex Henning
2014-06-18 13:46:22 -07:00
parent d9c1a4edfd
commit c106939bc2
31 changed files with 341 additions and 254 deletions

View File

@@ -4,6 +4,7 @@ import java.io.File;
import java.util.Properties;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Status;
import org.eclipse.ui.IStartup;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@@ -89,4 +90,12 @@ public class WPILibCPPPlugin extends AbstractUIPlugin implements IStartup {
new CPPInstaller(getCurrentVersion()).installIfNecessary();
}
public static void logInfo(String msg) {
getDefault().getLog().log(new Status(Status.INFO, PLUGIN_ID, Status.OK, msg, null));
}
public static void logError(String msg, Exception e) {
getDefault().getLog().log(new Status(Status.ERROR, PLUGIN_ID, Status.OK, msg, e));
}
}

View File

@@ -31,7 +31,7 @@ public class CPPInstaller extends AbstractInstaller {
protected void updateInstalledVersion(String version) {
IPreferenceStore prefs = WPILibCPPPlugin.getDefault().getPreferenceStore();
if (prefs.getBoolean(PreferenceConstants.UPDATE_LIBRARY_VERSION)) {
System.out.println("Forcing library version to "+version);
WPILibCPPPlugin.logInfo("Forcing library version to "+version);
Properties props = WPILibCore.getDefault().getProjectProperties(null);
props.setProperty("cpp-version", version);
WPILibCore.getDefault().saveGlobalProperties(props);

View File

@@ -1,39 +1,23 @@
package edu.wpi.first.wpilib.plugins.cpp.launching;
import java.io.File;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.executables.Executable;
import org.eclipse.cdt.debug.core.executables.ExecutablesManager;
import org.eclipse.cdt.debug.mi.core.IGDBServerMILaunchConfigurationConstants;
import org.eclipse.cdt.debug.mi.core.IMIConstants;
import org.eclipse.cdt.debug.mi.core.IMILaunchConfigurationConstants;
import org.eclipse.cdt.launch.remote.IRemoteConnectionConfigurationConstants;
import org.eclipse.cdt.launch.remote.IRemoteConnectionHostConstants;
import org.eclipse.cdt.ui.ICDTConstants;
import org.eclipse.core.internal.resources.Resource;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchHistory;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.debug.ui.ILaunchGroup;
import org.eclipse.debug.ui.ILaunchShortcut;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
@@ -43,7 +27,6 @@ import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.PlatformUI;
import edu.wpi.first.wpilib.plugins.core.WPILibCore;
import edu.wpi.first.wpilib.plugins.core.launching.AntLauncher;
import edu.wpi.first.wpilib.plugins.cpp.WPILibCPPPlugin;
/**
@@ -77,11 +60,10 @@ public class DeployLaunchShortcut implements ILaunchShortcut
// Extract resource from selection
StructuredSelection sel = (StructuredSelection) selection;
IProject activeProject = null;
if (sel.getFirstElement() instanceof IProject)
{
if (sel.getFirstElement() instanceof IProject) {
activeProject = (IProject) sel.getFirstElement();
} else
{
} else {
WPILibCPPPlugin.logError("Selection isn't a project: "+sel.toString(), null);
return;
}
@@ -94,8 +76,7 @@ public class DeployLaunchShortcut implements ILaunchShortcut
public void launch(IEditorPart editor, String mode)
{
// Extract resource from editor
if (editor != null)
{
if (editor != null) {
IFileEditorInput input = (IFileEditorInput) editor.getEditorInput();
IFile file = input.getFile();
IProject activeProject = file.getProject();
@@ -103,9 +84,8 @@ public class DeployLaunchShortcut implements ILaunchShortcut
// If editor existed, run config using extracted resource in
// indicated mode
runConfig(activeProject, mode, editor.getSite().getWorkbenchWindow().getShell());
} else
{
System.err.println("editor was null");
} else {
WPILibCPPPlugin.logError("Editor was null.", null);
}
}
@@ -118,11 +98,10 @@ public class DeployLaunchShortcut implements ILaunchShortcut
* The mode it will be run in (ILaunchManager.RUN_MODE or
* ILaunchManager.DEBUG_MODE)
*/
public void runConfig(IProject activeProj, String mode, Shell shell) //TODO: figure out UI issues. tjats why this is undocumented""
{
public void runConfig(IProject activeProj, String mode, Shell shell) {
// TODO: figure out UI issues. that's why this is undocumented
ILaunchConfigurationWorkingCopy config;
try
{
try {
config = getRemoteDebugConfig(activeProj);
//config.doSave(); // NOTE: For debugging
//org.eclipse.debug.core.DebugPlugin.getDefault().getLaunchManager().addLaunch(config.launch(mode, null));
@@ -130,18 +109,13 @@ public class DeployLaunchShortcut implements ILaunchShortcut
//DebugUITools.openLaunchConfigurationPropertiesDialog(shell, config, "org.eclipse.cdt.launch.launchGroup");
//config.launch(mode, new NullProgressMonitor(), false, true);
DebugUITools.launch(config, mode);
} catch (CoreException e)
{
System.err.println("Debug attach failed.");
e.printStackTrace();
} catch (CoreException e) {
WPILibCPPPlugin.logError("Debug attach failed.", e);
}
try
{
try {
activeProj.refreshLocal(Resource.DEPTH_INFINITE, null);
} catch (Exception e)
{
}
} catch (Exception e) {}
}
private ILaunchConfigurationWorkingCopy getRemoteDebugConfig(IProject activeProj) throws CoreException

View File

@@ -2,9 +2,6 @@ package edu.wpi.first.wpilib.plugins.cpp.launching;
import java.util.Arrays;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.rse.core.PasswordPersistenceManager;
import org.eclipse.rse.core.RSECorePlugin;
@@ -13,6 +10,8 @@ import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.model.SystemSignonInformation;
import edu.wpi.first.wpilib.plugins.cpp.WPILibCPPPlugin;
public class RSEUtils {
public static IHost getTarget(int teamNumber) {
@@ -23,14 +22,13 @@ public class RSEUtils {
// get the singleton RSE registry
try {
RSECorePlugin.waitForInitCompletion();
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (InterruptedException e) {
WPILibCPPPlugin.logError("Error initializing RSE", e);
}
ISystemRegistry registry = RSECorePlugin.getDefault().getSystemRegistry();
// get the default profile, used to store connections
System.out.println("Profiles: "+Arrays.toString(registry.getActiveSystemProfiles()));
WPILibCPPPlugin.logInfo("Profiles: "+Arrays.toString(registry.getActiveSystemProfiles()));
ISystemProfile profile = registry.getActiveSystemProfiles()[0];
// see if a host object already exists for "build.eclipse.org"
@@ -48,7 +46,7 @@ public class RSEUtils {
"", systemType);
PasswordPersistenceManager.getInstance().add(info, true, false);
} catch (Exception e) {
e.printStackTrace();
WPILibCPPPlugin.logError("Error connecting to RoboRIO.", e);
}
}
return host;

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.cpp.WPILibCPPPlugin;
/**
* Launch shortcut base functionality, common for deploying to the robot.
@@ -95,8 +96,8 @@ public class SimulateLaunchShortcut implements ILaunchShortcut {
}
if((lastDeploy != null)&&(!lastDeploy.isTerminated())){
System.out.println("Last deploy running");
//Find the server connection thread and kill it
WPILibCPPPlugin.logInfo("Last deploy running");
// Find the server connection thread and kill it
Vector<ThreadGroup> threadGroups = new Vector<ThreadGroup>();
ThreadGroup root = Thread.currentThread().getThreadGroup().getParent();
while (root.getParent() != null) {root = root.getParent();}
@@ -109,24 +110,25 @@ public class SimulateLaunchShortcut implements ILaunchShortcut {
for(Thread current: threads){
if(current != null){
if(current.getName().equals(ANT_SERVER_THREAD_NAME)){
try{
//Manually end thread and then try terminating launch
try {
// Manually end thread and then try terminating launch
Method stopMethod = current.getClass().getMethod("stop");
stopMethod.invoke(current);
lastDeploy.terminate();
break;
}catch(Exception e){e.printStackTrace();}
} catch(Exception e){
WPILibCPPPlugin.logError("Error killing ant thread.", e);
}
}
}
}
System.out.println("Waiting");
WPILibCPPPlugin.logInfo("Waiting");
try{wait(1000);}catch(Exception e){}
}
System.out.println("Running ant file: " + activeProj.getLocation().toOSString() + File.separator + "build.xml");
System.out.println("Targets: " + targets + ", Mode: " + mode);
WPILibCPPPlugin.logInfo("Running ant file: " + activeProj.getLocation().toOSString() + File.separator + "build.xml");
WPILibCPPPlugin.logInfo("Targets: " + targets + ", Mode: " + mode);
lastDeploy = AntLauncher.runAntFile(new File (activeProj.getLocation().toOSString() + File.separator + "build.xml"), targets, null, mode);
try {

View File

@@ -99,7 +99,7 @@ public class CPPPreferencePage
* @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
*/
public void init(IWorkbench workbench) {
System.out.println("Preferences initialized.");
WPILibCPPPlugin.logInfo("Preferences initialized.");
Properties props = WPILibCore.getDefault().getProjectProperties(null);
getPreferenceStore().setValue(PreferenceConstants.LIBRARY_VERSION,
props.getProperty("cpp-version", WPILibCPPPlugin.getDefault().getCurrentVersion()));
@@ -115,4 +115,4 @@ public class CPPPreferencePage
WPILibCore.getDefault().saveGlobalProperties(props);
return super.performOk();
}
}
}

View File

@@ -62,7 +62,7 @@ public class FileTemplateWizard extends Wizard implements INewWizard {
final IProject project = page.getProject();
final String className = page.getClassName();
final String folderName = page.getFolder();
System.out.println("Class: "+className+" Folder: "+folderName);
WPILibCPPPlugin.logInfo("Class: "+className+" Folder: "+folderName);
IRunnableWithProgress op = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
try {
@@ -105,8 +105,7 @@ public class FileTemplateWizard extends Wizard implements INewWizard {
url = new URL(WPILibCPPPlugin.getDefault().getBundle().getEntry("/resources/templates/"), source+".cpp");
ProjectCreationUtils.createTemplateFile(project, filepath+".cpp", url, map);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
WPILibCPPPlugin.logError("Malforemd URL: "+WPILibCPPPlugin.getDefault().getBundle().getEntry("/resources/templates/")+"/"+source+".h", e);
}
}
@@ -117,9 +116,9 @@ public class FileTemplateWizard extends Wizard implements INewWizard {
*/
public void init(IWorkbench workbench, IStructuredSelection selection) {
this.selection = selection;
System.out.println(selection);
WPILibCPPPlugin.logInfo(selection.toString());
Object element = ((StructuredSelection) selection).getFirstElement();
System.out.println(element.getClass());
WPILibCPPPlugin.logInfo(element.getClass().toString());
if (element instanceof IResource) {
project = ((IResource) element).getProject();
} else if (element instanceof ISourceRoot) {
@@ -130,6 +129,6 @@ public class FileTemplateWizard extends Wizard implements INewWizard {
project = ((ISourceRoot) element).getCProject().getProject();
} else if (element instanceof ICContainer) {
project = ((ICContainer) element).getCProject().getProject();
} else System.out.println("Element not instance of IResource: "+element.getClass());
} else WPILibCPPPlugin.logInfo("Element not instance of IResource: "+element.getClass());
}
}

View File

@@ -20,6 +20,7 @@ import org.eclipse.swt.widgets.Text;
import edu.wpi.first.wpilib.plugins.core.nature.FRCProjectNature;
import edu.wpi.first.wpilib.plugins.core.wizards.IProjectFilter;
import edu.wpi.first.wpilib.plugins.core.wizards.ProjectComboField;
import edu.wpi.first.wpilib.plugins.cpp.WPILibCPPPlugin;
/**
* The "New" wizard page allows setting the container for the new file as well
@@ -67,7 +68,7 @@ public class FileTemplateWizardMainPage extends WizardPage {
return project.hasNature(FRCProjectNature.FRC_PROJECT_NATURE)
&& project.hasNature(CCProjectNature.C_NATURE_ID);
} catch (CoreException e) {
e.printStackTrace();
WPILibCPPPlugin.logError("Error checking for FRC C++ project.", e);
return false;
}
}
@@ -173,7 +174,7 @@ public class FileTemplateWizardMainPage extends WizardPage {
}
public String getDefaultFolder() {
System.out.println("Project: "+project);
WPILibCPPPlugin.logInfo("Project: "+project);
return "src"+File.separator+ending;
}
}
}

View File

@@ -19,6 +19,7 @@ import edu.wpi.first.wpilib.plugins.core.wizards.NewProjectMainPage;
import edu.wpi.first.wpilib.plugins.core.wizards.ProjectCreationUtils;
import edu.wpi.first.wpilib.plugins.core.wizards.ProjectType;
import edu.wpi.first.wpilib.plugins.core.wizards.TeamNumberPage;
import edu.wpi.first.wpilib.plugins.cpp.WPILibCPPPlugin;
/**
*
@@ -73,7 +74,7 @@ public class NewCPPWizard extends Wizard implements INewWizard {
final String teamNumber = TeamNumberPage.getTeamNumberFromPage(teamNumberPage);
final ProjectType projectType = page.getProjectType();
final String worldName = page.getWorld();
System.out.println("Project: "+projectName+" Project Type: "+projectType);
WPILibCPPPlugin.logInfo("Project: "+projectName+" Project Type: "+projectType);
IRunnableWithProgress op = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
try {
@@ -118,4 +119,4 @@ public class NewCPPWizard extends Wizard implements INewWizard {
public void init(IWorkbench workbench, IStructuredSelection selection) {
this.selection = selection;
}
}
}

View File

@@ -72,8 +72,7 @@ public class WPIRobotCPPProjectCreator implements IProjectCreator {
CCorePlugin.getDefault().createCDTProject(project.getDescription(), project, null);
project.open(null);
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
WPILibCPPPlugin.logError("Error intializing FRC C++ project.", e);
}
//config.getToolChain().getOptionById("cdt.managedbuild.option.gnu.cross.prefix").setValue(prefix);