Commit a7e4e503 authored by amccaskey's avatar amccaskey
Browse files

Added new extensible Developer Menu



This commit adds a new extension point that lets users easily add new
developer-related actions to the ICE Developer Menu. 

Added an extension for ICE and MOOSE - with MOOSE providing the existing
developer actions we had before. I've turned off the action buttons that
were in the toolbar for MOOSE previously. 
Signed-off-by: default avataramccaskey <mccaskeyaj@ornl.gov>
parent 3fdfc776
......@@ -186,19 +186,19 @@
</menuContribution>
</extension>
<extension
<!-- <extension
point="org.eclipse.ui.commands">
<command
defaultHandler="org.eclipse.ice.client.widgets.moose.actions.MOOSEActionHandler"
id="org.eclipse.ice.client.widgets.moose.commands.MOOSEAction"
name="Default MOOSE DropDown Action">
</command>
<!-- <command
<command
defaultHandler="org.eclipse.ice.client.widgets.moose.actions.GenerateYAMLHandler"
description="Generates YAML and Action Syntax files"
id="org.eclipse.ice.client.widgets.moose.commands.GenerateYAML"
name="Generate MOOSE YAML and Action Syntax">
</command>-->
</command>
<command
defaultHandler="org.eclipse.ice.client.widgets.moose.actions.ForkStorkHandler"
description="Forks the Stork"
......@@ -248,14 +248,14 @@
<menuContribution
allPopups="false"
locationURI="menu:org.eclipse.ice.client.widgets.moose.commands.MOOSEAction.toolItem">
<!--<command
<command
commandId="org.eclipse.ice.client.widgets.moose.commands.GenerateYAML"
icon="icons/file_obj.gif"
id="org.eclipse.ice.client.widgets.moose.commands.GenerateYAML.menuItem"
label="Generate YAML and Action Syntax"
style="push"
tooltip="Generates MOOSE YAML and Action Syntax files">
</command>-->
</command>
<command
commandId="org.eclipse.ice.client.widgets.moose.commands.ForkStork"
id="org.eclipse.ice.client.widgets.moose.commands.ForkStork.menuItem"
......@@ -282,6 +282,6 @@
visible="false">
</separator>
</menuContribution>
</extension>
</extension>-->
</plugin>
......@@ -285,14 +285,6 @@
tooltip="Delete the Selected Item">
</command>
</menuContribution>
<menuContribution
allPopups="false"
locationURI="menu:org.eclipse.ui.main.menu">
<menu
id="iceDevMenu"
label="Developer">
</menu>
</menuContribution>
</extension>
<!-- Commands -->
<extension
......
<?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>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.ice.developer.moose</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>
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
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: MOOSE Developer
Bundle-SymbolicName: org.eclipse.ice.developer.moose;singleton:=true
Bundle-Version: 2.1.7
Bundle-Vendor: Oak Ridge National Laboratory
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: org.eclipse.cdt.core.settings.model,
org.eclipse.core.commands,
org.eclipse.core.runtime.jobs,
org.eclipse.egit.github.core;version="4.0.0",
org.eclipse.egit.github.core.client;version="4.0.0",
org.eclipse.egit.github.core.service;version="4.0.0",
org.eclipse.jface.dialogs,
org.eclipse.jface.window,
org.eclipse.jface.wizard,
org.eclipse.jgit.api;version="4.0.0",
org.eclipse.jgit.api.errors;version="4.0.0",
org.eclipse.swt,
org.eclipse.swt.events,
org.eclipse.swt.layout,
org.eclipse.swt.widgets,
org.eclipse.ui,
org.eclipse.ui.handlers,
org.slf4j;version="1.7.2"
Require-Bundle: org.eclipse.cdt;bundle-version="8.7.0",
org.eclipse.cdt.core,
org.eclipse.cdt.make.core;bundle-version="7.3.0",
org.eclipse.cdt.managedbuilder.core;bundle-version="8.3.0",
org.eclipse.cdt.managedbuilder.ui;bundle-version="8.2.2",
org.eclipse.core.runtime;bundle-version="3.11.0",
org.eclipse.core.resources;bundle-version="3.10.0",
org.eclipse.egit;bundle-version="4.0.0",
org.eclipse.ice.developer;bundle-version="2.1.7"
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
id="org.eclipse.ice.developer.moose"
name="MOOSE Developer Tooling"
point="org.eclipse.ice.developer.code">
<code
codeCategory="Framework"
codeName="MOOSE"
generateDefaultCommands="false"
repoURL="https://github.com/idaholab/moose"
versionControlType="git">
<command
commandName="Fork the Stork"
implementation="org.eclipse.ice.developer.moose.actions.ForkStorkHandler">
</command>
<command
commandName="Clone MOOSE"
implementation="org.eclipse.ice.developer.moose.actions.CloneMOOSEHandler">
</command>
<command
commandName="Fork MOOSE"
implementation="org.eclipse.ice.developer.moose.actions.ForkMOOSEHandler">
</command>
</code>
</extension>
</plugin>
/*******************************************************************************
* Copyright (c) 2015 UT-Battelle, LLC.
* 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:
* Alex McCaskey - Initial API and implementation and/or initial documentation
*
*******************************************************************************/
package org.eclipse.ice.developer.moose.actions;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.handlers.HandlerUtil;
/**
* This handler triggers the "Clone MOOSE" action.
*
* TODO Update this documentation with more appropriate details.
*
* @author Alex McCaskey
*
*/
public class CloneMOOSEHandler extends AbstractHandler {
/*
* (non-Javadoc)
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
// Get the current shell from the HandlerUtil.
Shell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell();
// TODO Implement. Note: This is using the UI thread.
return null;
}
}
\ No newline at end of file
/*******************************************************************************
* Copyright (c) 2015 UT-Battelle, LLC.
* 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:
* Alex McCaskey - Initial API and implementation and/or initial documentation
*
*******************************************************************************/
package org.eclipse.ice.developer.moose.actions;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.handlers.HandlerUtil;
/**
* This handler triggers the "Fork MOOSE" action.
*
* TODO Update this documentation with more appropriate details.
*
* @author Alex McCaskey
*
*/
public class ForkMOOSEHandler extends AbstractHandler {
/*
* (non-Javadoc)
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
// Get the current shell from the HandlerUtil.
Shell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell();
// TODO Implement. Note: This is using the UI thread.
return null;
}
}
\ No newline at end of file
/*******************************************************************************
* Copyright (c) 2015 UT-Battelle, LLC.
* 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:
* Alex McCaskey - Initial API and implementation and/or initial documentation
*
*******************************************************************************/
package org.eclipse.ice.developer.moose.actions;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
import org.eclipse.cdt.core.settings.model.CSourceEntry;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICFolderDescription;
import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.core.settings.model.ICSourceEntry;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
import org.eclipse.cdt.make.core.IMakeCommonBuildInfo;
import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.cdt.make.core.IMakeTargetManager;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.managedbuilder.core.IBuilder;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject;
import org.eclipse.cdt.managedbuilder.ui.wizards.CfgHolder;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.egit.github.core.Repository;
import org.eclipse.egit.github.core.RepositoryId;
import org.eclipse.egit.github.core.service.RepositoryService;
import org.eclipse.ice.developer.moose.nature.MooseNature;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.handlers.HandlerUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The ForkStorkHandler displays a Wizard to the user to gather a new MOOSE
* application name and the users GitHub credentials, and then forks
* idaholab/stork and renames the repository to the provided application name.
* Additionally, it imports the project as a CDT Makefile project with existing
* code, creates a new Make Target, and adds the appropriate MOOSE include files
* to the Paths and Symbols preference page.
*
* @author Alex McCaskey
*
*/
public class ForkStorkHandler extends AbstractHandler {
/**
* Logger for handling event messages and other information.
*/
private static final Logger logger = LoggerFactory.getLogger(ForkStorkHandler.class);
/**
* (non-Javadoc)
*
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
// Local Declarations
Shell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell();
// Create a new ForkStorkWizard and Dialog
final ForkStorkWizard wizard = new ForkStorkWizard();
WizardDialog dialog = new WizardDialog(shell, wizard);
// Open the dialog
if (dialog.open() != 0) {
return null;
}
// Create a File reference to the repo in the Eclipse workspace
final Job job = new Job("Forking the MOOSE Stork!") {
@Override
protected IStatus run(IProgressMonitor monitor) {
monitor.beginTask(
"Attempting to Fork the Stork with supplied credentials",
100);
// Local Declarations
IWorkspace workspace = ResourcesPlugin.getWorkspace();
ArrayList<String> cmdList = new ArrayList<String>();
ProcessBuilder jobBuilder = null;
String os = System.getProperty("os.name");
String sep = System.getProperty("file.separator");
// Get the user specified data
String appName = wizard.getMooseAppName();
String gitHubUser = wizard.getGitUsername();
String password = wizard.getGitPassword();
// Construct the Remote URI for the repo
String remoteURI = "https://github.com/" + gitHubUser + "/"
+ appName;
// Create the workspace file
File workspaceFile = new File(ResourcesPlugin.getWorkspace()
.getRoot().getLocation().toOSString()
+ sep + appName);
// Set the pyton command
cmdList.add("/bin/bash");
cmdList.add("-c");
cmdList.add("python make_new_application.py");
// Create a EGit-GitHub RepositoryService and Id to
// connect and create our Fork
RepositoryService service = new RepositoryService();
RepositoryId id = new RepositoryId("idaholab", "stork");
// Set the user's GitHub credentials
service.getClient().setCredentials(gitHubUser, password);
monitor.subTask("Connecting to GitHub...");
monitor.worked(20);
// Fork the Repository!!!
try {
// Fork and get the repo
Repository repo = service.forkRepository(id);
// Reset the project name to the provided app name
Map<String, Object> fields = new HashMap<String, Object>();
fields.put("name", appName);
// Edit the name
service.editRepository(repo, fields);
} catch (IOException e) {
logger.error(getClass().getName() + " Exception!",e);
String errorMessage = "ICE failed in forking the new stork.";
return new Status(IStatus.ERROR,
"org.eclipse.ice.client.widgets.moose", 1,
errorMessage, null);
}
monitor.subTask("Stork Forked, cloning to local machine...");
monitor.worked(40);
// Now that it is all set on the GitHub end,
// Let's pull it down into our workspace
try {
Git result = Git.cloneRepository().setURI(remoteURI)
.setDirectory(workspaceFile).call();
} catch (GitAPIException e) {
logger.error(getClass().getName() + " Exception!",e);
String errorMessage = "ICE failed in cloning the new application.";
return new Status(IStatus.ERROR,
"org.eclipse.ice.client.widgets.moose", 1,
errorMessage, null);
}
monitor.subTask("Executing make_new_application.py...");
monitor.worked(60);
// We can only run the python script on Linux or Mac
// And Moose devs only use Linux or Macs to build their apps
if (os.contains("Linux") || os.contains("Mac")) {
// Create the ProcessBuilder and change to the project dir
jobBuilder = new ProcessBuilder(cmdList);
jobBuilder.directory(new File(workspaceFile
.getAbsolutePath()));
// Do not direct the error to stdout. Catch it separately.
jobBuilder.redirectErrorStream(false);
try {
// Execute the python script!
jobBuilder.start();
} catch (IOException e) {
logger.error(getClass().getName() + " Exception!",e);
String errorMessage = "ICE could not execute the make_new_application python script.";
return new Status(IStatus.ERROR,
"org.eclipse.ice.client.widgets.moose", 1,
errorMessage, null);
}
}
/*------------ The rest is about importing the C++ project correctly ---------*/
// Get the project and project description handles
IProject project = workspace.getRoot().getProject(appName);
IProjectDescription description = workspace
.newProjectDescription(appName);
monitor.subTask("Converting application to CDT C++ Project...");
monitor.worked(80);
try {
// Create the CDT Project
CCorePlugin.getDefault().createCDTProject(description,
project, new NullProgressMonitor());
// Add the CPP nature
CCProjectNature.addCCNature(project,
new NullProgressMonitor());
// Set up build information
ICProjectDescriptionManager pdMgr = CoreModel.getDefault()
.getProjectDescriptionManager();
ICProjectDescription projDesc = pdMgr
.createProjectDescription(project, false);
ManagedBuildInfo info = ManagedBuildManager
.createBuildInfo(project);
ManagedProject mProj = new ManagedProject(projDesc);
info.setManagedProject(mProj);
// Grab the correct toolchain
// FIXME this should be better...
IToolChain toolChain = null;
for (IToolChain tool : ManagedBuildManager
.getRealToolChains()) {
if (os.contains("Mac")
&& tool.getName().contains("Mac")
&& tool.getName().contains("GCC")) {
toolChain = tool;
break;
} else if (os.contains("Linux")
&& tool.getName().contains("Linux")
&& tool.getName().contains("GCC")) {
toolChain = tool;
break;
} else if (os.contains("Windows")
&& tool.getName().contains("Cygwin")) {
toolChain = tool;
break;
} else {
toolChain = null;
}
}
// Set up the Build configuratino
CfgHolder cfgHolder = new CfgHolder(toolChain, null);
String s = toolChain == null ? "0" : toolChain.getId(); //$NON-NLS-1$
IConfiguration config = new Configuration(
mProj,
(org.eclipse.cdt.managedbuilder.internal.core.ToolChain) toolChain,
ManagedBuildManager.calculateChildId(s, null),
cfgHolder.getName());
IBuilder builder = config.getEditableBuilder();
builder.setManagedBuildOn(false);
CConfigurationData data = config.getConfigurationData();
projDesc.createConfiguration(
ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
pdMgr.setProjectDescription(project, projDesc);
// Now create a default Make Target for the Moose user to
// use to
// build the new app
IProject cProject = projDesc.getProject();
IMakeTargetManager manager = MakeCorePlugin.getDefault()
.getTargetManager();
String[] ids = manager.getTargetBuilders(cProject);
IMakeTarget target = manager.createTarget(cProject,
"make all", ids[0]);
target.setStopOnError(false);
target.setRunAllBuilders(false);
target.setUseDefaultBuildCmd(false);
target.setBuildAttribute(
IMakeCommonBuildInfo.BUILD_COMMAND, "make");
target.setBuildAttribute(IMakeCommonBuildInfo.BUILD_LOCATION,
cProject.getLocation().toOSString());
target.setBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, "");
target.setBuildAttribute(IMakeTarget.BUILD_TARGET, "all");
manager.addTarget(cProject, target);
// Set the include and src folders as actual CDT source
// folders
ICProjectDescription cDescription = CoreModel.getDefault()
.getProjectDescriptionManager()
.createProjectDescription(cProject,