diff --git a/org.eclipse.ice.target.kepler/kepler_rcp.target b/org.eclipse.ice.target.kepler/kepler_rcp.target index cf9c1e287..7d10e5688 100644 --- a/org.eclipse.ice.target.kepler/kepler_rcp.target +++ b/org.eclipse.ice.target.kepler/kepler_rcp.target @@ -1,40 +1,9 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -70,8 +39,13 @@ - - + + + + + + + @@ -83,13 +57,43 @@ - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/repository/org.eclipse.ice.repository/ice.macosx_product.launch b/repository/org.eclipse.ice.repository/ice.macosx_product.launch index 16731995d..0808d2ffd 100644 --- a/repository/org.eclipse.ice.repository/ice.macosx_product.launch +++ b/repository/org.eclipse.ice.repository/ice.macosx_product.launch @@ -15,15 +15,15 @@ - + - - + + diff --git a/repository/org.eclipse.ice.repository/ice.product.launch b/repository/org.eclipse.ice.repository/ice.product.launch index 1e1829831..3b8f6adf6 100644 --- a/repository/org.eclipse.ice.repository/ice.product.launch +++ b/repository/org.eclipse.ice.repository/ice.product.launch @@ -22,8 +22,8 @@ - - + + diff --git a/src/org.eclipse.ice.client.widgets.moose/.classpath b/src/org.eclipse.ice.client.widgets.moose/.classpath index ad32c83a7..098194ca4 100644 --- a/src/org.eclipse.ice.client.widgets.moose/.classpath +++ b/src/org.eclipse.ice.client.widgets.moose/.classpath @@ -1,6 +1,6 @@ - + diff --git a/src/org.eclipse.ice.client.widgets.moose/.settings/org.eclipse.jdt.core.prefs b/src/org.eclipse.ice.client.widgets.moose/.settings/org.eclipse.jdt.core.prefs index c537b6306..f42de363a 100644 --- a/src/org.eclipse.ice.client.widgets.moose/.settings/org.eclipse.jdt.core.prefs +++ b/src/org.eclipse.ice.client.widgets.moose/.settings/org.eclipse.jdt.core.prefs @@ -1,7 +1,7 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/src/org.eclipse.ice.client.widgets.moose/META-INF/MANIFEST.MF b/src/org.eclipse.ice.client.widgets.moose/META-INF/MANIFEST.MF index 3eccbe5fe..4a92da3d9 100644 --- a/src/org.eclipse.ice.client.widgets.moose/META-INF/MANIFEST.MF +++ b/src/org.eclipse.ice.client.widgets.moose/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: ICE Moose Widgets Bundle-SymbolicName: org.eclipse.ice.client.widgets.moose;singleton:=true Bundle-Version: 2.0.0 -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Import-Package: com.jme3.math, org.eclipse.core.resources, org.eclipse.core.runtime;version="3.4.0", @@ -25,6 +25,15 @@ Import-Package: com.jme3.math, org.osgi.framework;version="1.7.0" Require-Bundle: org.eclipse.ice.client.compatibility;bundle-version="2.0.0", org.eclipse.ice.datastructures;bundle-version="2.0.0", - org.eclipse.jface + org.eclipse.jface, + org.eclipse.jgit;bundle-version="3.2.0", + org.eclipse.egit;bundle-version="3.2.0", + org.eclipse.egit.core;bundle-version="3.2.0", + org.eclipse.egit.github.core;bundle-version="3.2.0", + org.eclipse.cdt.core;bundle-version="5.6.0", + org.eclipse.core.runtime;bundle-version="3.9.100", + org.eclipse.cdt.make.core;bundle-version="7.3.0", + org.eclipse.cdt.managedbuilder.core;bundle-version="8.3.0", + org.eclipse.cdt.ui;bundle-version="5.7.0" Service-Component: OSGI-INF/MOOSEEditorComponent.xml Export-Package: org.eclipse.ice.client.widgets.moose diff --git a/src/org.eclipse.ice.client.widgets.moose/plugin.xml b/src/org.eclipse.ice.client.widgets.moose/plugin.xml index 795513189..81a3c9d0f 100644 --- a/src/org.eclipse.ice.client.widgets.moose/plugin.xml +++ b/src/org.eclipse.ice.client.widgets.moose/plugin.xml @@ -125,4 +125,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.eclipse.ice.client.widgets.moose/src/org/eclipse/ice/client/widgets/moose/ForkStorkHandler.java b/src/org.eclipse.ice.client.widgets.moose/src/org/eclipse/ice/client/widgets/moose/ForkStorkHandler.java new file mode 100644 index 000000000..8a050de83 --- /dev/null +++ b/src/org.eclipse.ice.client.widgets.moose/src/org/eclipse/ice/client/widgets/moose/ForkStorkHandler.java @@ -0,0 +1,441 @@ +/******************************************************************************* + * Copyright (c) 2013, 2014 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.client.widgets.moose; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +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.dom.IPDOMManager; +import org.eclipse.cdt.core.index.IIndex; +import org.eclipse.cdt.core.index.IIndexManager; +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.model.ICProject; +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.WriteAccessException; +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.make.core.MakeProjectNature; +import org.eclipse.cdt.managedbuilder.core.BuildException; +import org.eclipse.cdt.managedbuilder.core.IConfiguration; +import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; +import org.eclipse.cdt.managedbuilder.core.IManagedProject; +import org.eclipse.cdt.managedbuilder.core.IProjectType; +import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; +import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature; +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.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.IResource; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.IWorkspaceDescription; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.IWorkspaceRunnable; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.egit.github.core.Repository; +import org.eclipse.egit.github.core.RepositoryId; +import org.eclipse.egit.github.core.User; +import org.eclipse.egit.github.core.client.GitHubClient; +import org.eclipse.egit.github.core.service.RepositoryService; +import org.eclipse.ice.client.widgets.EclipseStreamingTextWidget; +import org.eclipse.ice.datastructures.form.AllowedValueType; +import org.eclipse.ice.datastructures.form.BasicEntryContentProvider; +import org.eclipse.ice.datastructures.form.DataComponent; +import org.eclipse.ice.datastructures.form.Entry; +import org.eclipse.ice.datastructures.form.Form; +import org.eclipse.ice.datastructures.form.FormStatus; +import org.eclipse.ice.datastructures.form.IEntryContentProvider; +import org.eclipse.ice.datastructures.form.TableComponent; +import org.eclipse.ice.item.nuclear.MOOSELauncher; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.jgit.api.CloneCommand; +import org.eclipse.jgit.api.Git; +import org.eclipse.jgit.api.errors.GitAPIException; +import org.eclipse.jgit.api.errors.InvalidRemoteException; +import org.eclipse.jgit.api.errors.TransportException; +import org.eclipse.jgit.errors.NoWorkTreeException; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkingSetManager; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.handlers.HandlerUtil; + +/** + * 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. + * + * @author Alex McCaskey + * + */ +public class ForkStorkHandler extends AbstractHandler { + + /** + * (non-Javadoc) + * + * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) + */ + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + + // Local Declarations + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + IWorkspaceRoot root = workspace.getRoot(); + Shell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell(); + String sep = System.getProperty("file.separator"), appName = "", gitHubUser = "", password = "", remoteURI = ""; + ArrayList cmdList = new ArrayList(); + ProcessBuilder jobBuilder = null; + + // Set the pyton command + cmdList.add("/bin/bash"); + cmdList.add("-c"); + cmdList.add("python make_new_application.py"); + + // Create a new ForkStorkWizard and Dialog + ForkStorkWizard wizard = new ForkStorkWizard(); + WizardDialog dialog = new WizardDialog(shell, wizard); + + // Open the dialog + if (dialog.open() != 0) { + return null; + } + + // Get the User Input Data + appName = wizard.getMooseAppName(); + gitHubUser = wizard.getGitUsername(); + password = wizard.getGitPassword(); + + // Construct the Remote URI for the repo + remoteURI = "https://github.com/" + gitHubUser + "/" + appName; + + // Create a File reference to the repo in the Eclipse workspace + File workspaceFile = new File(ResourcesPlugin.getWorkspace().getRoot() + .getLocation().toOSString() + + sep + appName); + + // 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); + + // Fork the Repository!!! + try { + // Fork and get the repo + Repository repo = service.forkRepository(id); + + // Reset the project name to the provided app name + Map fields = new HashMap(); + fields.put("name", appName); + + // Edit the name + service.editRepository(repo, fields); + } catch (IOException e1) { + e1.printStackTrace(); + } + + // 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 (InvalidRemoteException e1) { + e1.printStackTrace(); + } catch (TransportException e1) { + e1.printStackTrace(); + } catch (GitAPIException e1) { + e1.printStackTrace(); + } + + // 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) { + e.printStackTrace(); + } + + // Pull this into the Project Explorer as CDT project! + String projectTypeString = "cdt.managedbuild.target.macosx.so"; + IProject appProject = root.getProject(appName), cProject = null; + IWorkspaceDescription workspaceDesc = workspace.getDescription(); + workspaceDesc.setAutoBuilding(false); + try { + + /* + * + * + * PROJECT TYPE: + * org.eclipse.linuxtools.cdt.autotools.core.projectType PROJECT + * TYPE: cdt.managedbuild.target.gnu.cross.exe PROJECT TYPE: + * cdt.managedbuild.target.gnu.cross.so PROJECT TYPE: + * cdt.managedbuild.target.gnu.cross.lib PROJECT TYPE: + * cdt.managedbuild.target.gnu.exe PROJECT TYPE: + * cdt.managedbuild.target.gnu.so PROJECT TYPE: + * cdt.managedbuild.target.gnu.lib PROJECT TYPE: + * cdt.managedbuild.target.gnu.cygwin.exe PROJECT TYPE: + * cdt.managedbuild.target.gnu.cygwin.so PROJECT TYPE: + * cdt.managedbuild.target.gnu.cygwin.lib PROJECT TYPE: + * cdt.managedbuild.target.gnu.mingw.exe PROJECT TYPE: + * cdt.managedbuild.target.gnu.mingw.so PROJECT TYPE: + * cdt.managedbuild.target.gnu.mingw.lib PROJECT TYPE: + * cdt.managedbuild.target.macosx.exe PROJECT TYPE: + * cdt.managedbuild.target.macosx.so PROJECT TYPE: + * cdt.managedbuild.target.macosx.lib PROJECT TYPE: + * cdt.managedbuild.target.gnu.solaris.exe PROJECT TYPE: + * cdt.managedbuild.target.gnu.solaris.so PROJECT TYPE: + * cdt.managedbuild.target.gnu.solaris.lib + */ + workspace.setDescription(workspaceDesc); + + IProjectDescription description = workspace + .newProjectDescription(appProject.getName()); + + // Create the CDT Project + cProject = CCorePlugin.getDefault().createCDTProject(description, + appProject, null); + + if (!cProject.isOpen()) { + cProject.open(null); + } + cProject.refreshLocal(IResource.DEPTH_INFINITE, null); + + // Set the project type id + String projTypeId = "cdt.managedbuild.target.macosx.exe"; + + // Create the ManagedBuildInfo + IManagedBuildInfo info = ManagedBuildManager + .createBuildInfo(cProject); + + for (IProjectType t : ManagedBuildManager.getDefinedProjectTypes()) { + System.out.println("PROJECT TYPE: " + t.getId()); + } + + IProjectType type = ManagedBuildManager.getProjectType(projTypeId); + IManagedProject mProj = ManagedBuildManager.createManagedProject( + cProject, type); + + IConfiguration cfgs[] = type.getConfigurations(); + IConfiguration config = mProj + .createConfiguration( + cfgs[0], + ManagedBuildManager.calculateChildId( + cfgs[0].getId(), null)); + + ICProjectDescription cDescription = CoreModel.getDefault() + .getProjectDescriptionManager() + .createProjectDescription(cProject, false); + ICConfigurationDescription cConfigDescription = cDescription + .createConfiguration( + ManagedBuildManager.CFG_DATA_PROVIDER_ID, + config.getConfigurationData()); + cDescription.setActiveConfiguration(cConfigDescription); + cConfigDescription.setSourceEntries(null); + IFolder srcFolder = cProject.getFolder("src"); + IFolder includeFolder = cProject.getFolder("include"); + ICSourceEntry srcFolderEntry = new CSourceEntry(srcFolder, null, + ICSettingEntry.RESOLVED); + ICSourceEntry includeFolderEntry = new CSourceEntry(includeFolder, + null, ICSettingEntry.RESOLVED); + + cConfigDescription.setSourceEntries(new ICSourceEntry[] { + srcFolderEntry, includeFolderEntry }); + + info.setManagedProject(mProj); + + cDescription.setCdtProjectCreated(); + + CoreModel.getDefault() + .setProjectDescription(cProject, cDescription); + ManagedBuildManager.setDefaultConfiguration(cProject, config); + ManagedBuildManager.setSelectedConfiguration(cProject, config); + ManagedBuildManager.setNewProjectVersion(cProject); + ManagedBuildManager.saveBuildInfo(cProject, true); + + // Now create a default Make Target for the Moose user to use to + // build the new app + 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(IMakeTarget.BUILD_LOCATION, cProject + .getLocation().toOSString()); + target.setBuildAttribute(IMakeTarget.BUILD_ARGUMENTS, ""); + target.setBuildAttribute(IMakeTarget.BUILD_TARGET, "all"); + manager.addTarget(cProject, target); + + ICProjectDescription projectDescription = CoreModel.getDefault() + .getProjectDescription(cProject, true); + ICConfigurationDescription configDecriptions[] = projectDescription + .getConfigurations(); + for (ICConfigurationDescription configDescription : configDecriptions) { + ICFolderDescription projectRoot = configDescription + .getRootFolderDescription(); + ICLanguageSetting[] settings = projectRoot + .getLanguageSettings(); + for (ICLanguageSetting setting : settings) { + System.out.println("Setting: " + setting.toString()); + List includes = getIncludePaths(); + includes.addAll(setting + .getSettingEntriesList(ICSettingEntry.INCLUDE_PATH)); + setting.setSettingEntries(ICSettingEntry.INCLUDE_PATH, + includes); + } + } + + CoreModel.getDefault().setProjectDescription(cProject, + projectDescription); + + ICProject proj = CoreModel.getDefault().getCModel() + .getCProject(cProject.getName()); + IIndexManager indexManager = CCorePlugin.getIndexManager(); + IIndex index = indexManager.getIndex(proj, + IIndexManager.ADD_DEPENDENCIES); + indexManager.reindex(proj); + } catch (BuildException | CoreException e) { + e.printStackTrace(); + } + return null; + + } + + private List getIncludePaths() { + List includes = new ArrayList(); + + includes.add(new CIncludePathEntry("/moose/framework/include/actions", + ICSettingEntry.VALUE_WORKSPACE_PATH)); + includes.add(new CIncludePathEntry( + "/moose/framework/include/auxkernels", + ICSettingEntry.VALUE_WORKSPACE_PATH)); + includes.add(new CIncludePathEntry("/moose/framework/include/base", + ICSettingEntry.VALUE_WORKSPACE_PATH)); + includes.add(new CIncludePathEntry("/moose/framework/include/bcs", + ICSettingEntry.VALUE_WORKSPACE_PATH)); + includes.add(new CIncludePathEntry( + "/moose/framework/include/constraints", + ICSettingEntry.VALUE_WORKSPACE_PATH)); + includes.add(new CIncludePathEntry("/moose/framework/include/dampers", + ICSettingEntry.VALUE_WORKSPACE_PATH)); + includes.add(new CIncludePathEntry( + "/moose/framework/include/dgkernels", + ICSettingEntry.VALUE_WORKSPACE_PATH)); + includes.add(new CIncludePathEntry( + "/moose/framework/include/dirackernels", + ICSettingEntry.VALUE_WORKSPACE_PATH)); + includes.add(new CIncludePathEntry( + "/moose/framework/include/executioners", + ICSettingEntry.VALUE_WORKSPACE_PATH)); + includes.add(new CIncludePathEntry( + "/moose/framework/include/functions", + ICSettingEntry.VALUE_WORKSPACE_PATH)); + includes.add(new CIncludePathEntry( + "/moose/framework/include/geomsearch", + ICSettingEntry.VALUE_WORKSPACE_PATH)); + includes.add(new CIncludePathEntry("/moose/framework/include/ics", + ICSettingEntry.VALUE_WORKSPACE_PATH)); + includes.add(new CIncludePathEntry( + "/moose/framework/include/indicators", + ICSettingEntry.VALUE_WORKSPACE_PATH)); + includes.add(new CIncludePathEntry("/moose/framework/include/kernels", + ICSettingEntry.VALUE_WORKSPACE_PATH)); + includes.add(new CIncludePathEntry("/moose/framework/include/markers", + ICSettingEntry.VALUE_WORKSPACE_PATH)); + includes.add(new CIncludePathEntry( + "/moose/framework/include/materials", + ICSettingEntry.VALUE_WORKSPACE_PATH)); + includes.add(new CIncludePathEntry("/moose/framework/include/mesh", + ICSettingEntry.VALUE_WORKSPACE_PATH)); + includes.add(new CIncludePathEntry( + "/moose/framework/include/meshmodifiers", + ICSettingEntry.VALUE_WORKSPACE_PATH)); + includes.add(new CIncludePathEntry( + "/moose/framework/include/multiapps", + ICSettingEntry.VALUE_WORKSPACE_PATH)); + includes.add(new CIncludePathEntry("/moose/framework/include/outputs", + ICSettingEntry.VALUE_WORKSPACE_PATH)); + includes.add(new CIncludePathEntry("/moose/framework/include/parser", + ICSettingEntry.VALUE_WORKSPACE_PATH)); + includes.add(new CIncludePathEntry( + "/moose/framework/include/postprocessors", + ICSettingEntry.VALUE_WORKSPACE_PATH)); + includes.add(new CIncludePathEntry( + "/moose/framework/include/preconditioners", + ICSettingEntry.VALUE_WORKSPACE_PATH)); + includes.add(new CIncludePathEntry( + "/moose/framework/include/predictors", + ICSettingEntry.VALUE_WORKSPACE_PATH)); + includes.add(new CIncludePathEntry("/moose/framework/include/restart", + ICSettingEntry.VALUE_WORKSPACE_PATH)); + includes.add(new CIncludePathEntry("/moose/framework/include/splits", + ICSettingEntry.VALUE_WORKSPACE_PATH)); + includes.add(new CIncludePathEntry( + "/moose/framework/include/timeintegrators", + ICSettingEntry.VALUE_WORKSPACE_PATH)); + includes.add(new CIncludePathEntry( + "/moose/framework/include/timesteppers", + ICSettingEntry.VALUE_WORKSPACE_PATH)); + includes.add(new CIncludePathEntry( + "/moose/framework/include/userobject", + ICSettingEntry.VALUE_WORKSPACE_PATH)); + includes.add(new CIncludePathEntry("/moose/framework/include/utils", + ICSettingEntry.VALUE_WORKSPACE_PATH)); + includes.add(new CIncludePathEntry( + "/moose/framework/include/vectorpostprocessors", + ICSettingEntry.VALUE_WORKSPACE_PATH)); + includes.add(new CIncludePathEntry("/moose/libmesh/installed/include", + ICSettingEntry.VALUE_WORKSPACE_PATH)); + + return includes; + } +} \ No newline at end of file diff --git a/src/org.eclipse.ice.client.widgets.moose/src/org/eclipse/ice/client/widgets/moose/ForkStorkWizard.java b/src/org.eclipse.ice.client.widgets.moose/src/org/eclipse/ice/client/widgets/moose/ForkStorkWizard.java new file mode 100644 index 000000000..f97ec485b --- /dev/null +++ b/src/org.eclipse.ice.client.widgets.moose/src/org/eclipse/ice/client/widgets/moose/ForkStorkWizard.java @@ -0,0 +1,120 @@ +/******************************************************************************* + * Copyright (c) 2013, 2014 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.client.widgets.moose; + +import java.util.ArrayList; + +import org.eclipse.core.commands.IHandler; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.ui.IWorkbenchWindow; + +/** + * The ForkStorkWizard is a subclass of Wizard that + * provides a ForkStorkWizardPage to get user input for + * forking the MOOSE Stork. + * + * @author Alex McCaskey + * + */ +public class ForkStorkWizard extends Wizard { + + /** + * Handle to the workbench window. + */ + protected IWorkbenchWindow workbenchWindow; + + /** + * Reference to the ForStorkWizardPage + */ + private ForkStorkWizardPage page; + + /** + * List of retrieved user input data + * from the ForkStorkWizardPage + */ + private ArrayList forkData; + + /** + * A nullary constructor. This is used by the platform. If called from an + * {@link IHandler}, use {@link #NewItemWizard(IWorkbenchWindow)} . + */ + public ForkStorkWizard() { + page = new ForkStorkWizardPage("Fork the Stork!"); + setWindowTitle("MOOSE Fork the Stork"); + this.setForcePreviousAndNextButtons(false); + + } + + /** + * The default constructor. This is not normally called by the platform but + * via handlers. + * + * @param window + * The workbench window. + */ + public ForkStorkWizard(IWorkbenchWindow window) { + // Initialize the default information. + this(); + // Store a reference to the workbench window. + workbenchWindow = window; + page = new ForkStorkWizardPage("Fork the Stork!"); + + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.wizard.Wizard#addPages() + */ + @Override + public void addPages() { + addPage(page); + } + + /** + * + */ + @Override + public boolean performFinish() { + + // Gather up all the data entered by the user + forkData = new ArrayList(); + forkData.add(page.getMooseAppName()); + forkData.add(page.getGitUserName()); + forkData.add(page.getGitPassword()); + + return true; + } + + /** + * Return the input Moose App name. + * + * @return + */ + public String getMooseAppName() { + return forkData.get(0); + } + + /** + * Retrieve the users GitHub username + * @return + */ + public String getGitUsername() { + return forkData.get(1); + } + + // Retrieve the GitHub password + public String getGitPassword() { + return forkData.get(2); + } +} diff --git a/src/org.eclipse.ice.client.widgets.moose/src/org/eclipse/ice/client/widgets/moose/ForkStorkWizardPage.java b/src/org.eclipse.ice.client.widgets.moose/src/org/eclipse/ice/client/widgets/moose/ForkStorkWizardPage.java new file mode 100644 index 000000000..8dc345beb --- /dev/null +++ b/src/org.eclipse.ice.client.widgets.moose/src/org/eclipse/ice/client/widgets/moose/ForkStorkWizardPage.java @@ -0,0 +1,140 @@ +/******************************************************************************* + * Copyright (c) 2013, 2014 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: + * Initial API and implementation and/or initial documentation - Jay Jay Billings, + * Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson, + * Claire Saunders, Matthew Wang, Anna Wojtowicz + *******************************************************************************/ +package org.eclipse.ice.client.widgets.moose; + +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.KeyListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +/** + * The ForkStorkWizardPage is a subclass of WizardPage that + * provides a Composite for the Wizard that takes the user's + * desired MOOSE app name and GitHub credentials for forking the + * MOOSE stork. + * + * @author Alex McCaskey + * + */ +public class ForkStorkWizardPage extends WizardPage { + + /** + * Reference to the Parent Composite. + */ + private Composite container; + + /** + * The text box for the Moose application name. + */ + private Text appName; + + /** + * The text box for the GitHub user name. + */ + private Text uName; + + /** + * The text box for the user's password. + * + */ + private Text password; + + /** + * The constructor + * @param pageName + */ + protected ForkStorkWizardPage(String pageName) { + super(pageName); + setTitle(pageName); + setDescription("Please provide the name of the Moose Application you'd like to create."); + } + + /** + * Create a Composite with fields for the application name + * and GitHub user credentials. + */ + @Override + public void createControl(Composite parent) { + container = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + container.setLayout(layout); + layout.numColumns = 1; + Label label1 = new Label(container, SWT.NONE); + label1.setText("MooseApp Name:"); + + appName = new Text(container, SWT.BORDER | SWT.SINGLE); + appName.setText(""); + appName.addKeyListener(new KeyListener() { + + @Override + public void keyPressed(KeyEvent e) { + } + + @Override + public void keyReleased(KeyEvent e) { + if (!appName.getText().isEmpty()) { + setPageComplete(true); + + } + } + + }); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + appName.setLayoutData(gd); + + new Label(container, SWT.NONE).setText("GitHub Username:"); + uName = new Text(container, SWT.BORDER | SWT.SINGLE); + uName.setText(System.getProperty("user.name")); + uName.setLayoutData(gd); + + new Label(container, SWT.NONE).setText("GitHub Password:"); + password = new Text(container, SWT.BORDER | SWT.SINGLE | SWT.PASSWORD); + password.setText(""); + password.setLayoutData(gd); + + // required to avoid an error in the system + setControl(container); + setPageComplete(true); + + } + + /** + * Return the Moose application name + * @return + */ + public String getMooseAppName() { + return appName.getText(); + } + + /** + * Return the GitHub user name. + * @return + */ + public String getGitUserName() { + return uName.getText(); + } + + /** + * Return the GitHub password. + * @return + */ + public String getGitPassword() { + return password.getText(); + } + +} diff --git a/src/org.eclipse.ice.client.widgets.moose/src/org/eclipse/ice/client/widgets/moose/MoosePreferencePage.java b/src/org.eclipse.ice.client.widgets.moose/src/org/eclipse/ice/client/widgets/moose/MoosePreferencePage.java new file mode 100644 index 000000000..2362580e8 --- /dev/null +++ b/src/org.eclipse.ice.client.widgets.moose/src/org/eclipse/ice/client/widgets/moose/MoosePreferencePage.java @@ -0,0 +1,42 @@ +package org.eclipse.ice.client.widgets.moose; + +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.preferences.InstanceScope; +import org.eclipse.jface.preference.BooleanFieldEditor; +import org.eclipse.jface.preference.DirectoryFieldEditor; +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.jface.preference.RadioGroupFieldEditor; +import org.eclipse.jface.preference.StringFieldEditor; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; + +public class MoosePreferencePage extends FieldEditorPreferencePage implements + IWorkbenchPreferencePage { + + @Override + public void init(IWorkbench workbench) { +// Preferences preferences = InstanceScope.INSTANCE. +// .getNode("com.vogella.eclipse.preferences.test"); + this.setPreferenceStore(null); + setDescription("A demonstration of a preference page implementation"); + } + + @Override + protected void createFieldEditors() { + addField(new DirectoryFieldEditor("PATH", "&Directory preference:", + getFieldEditorParent())); + addField(new BooleanFieldEditor("BOOLEAN_VALUE", + "&An example of a boolean preference", getFieldEditorParent())); + + addField(new RadioGroupFieldEditor("CHOICE", + "An example of a multiple-choice preference", 1, + new String[][] { { "&Choice 1", "choice1" }, + { "C&hoice 2", "choice2" } }, getFieldEditorParent())); + addField(new StringFieldEditor("MySTRING1", "A &text preference:", + getFieldEditorParent())); + addField(new StringFieldEditor("MySTRING2", "A &text preference:", + getFieldEditorParent())); + } + +} diff --git a/src/org.eclipse.ice.client.widgets.moose/src/org/eclipse/ice/client/widgets/moose/NewKernelHandler.java b/src/org.eclipse.ice.client.widgets.moose/src/org/eclipse/ice/client/widgets/moose/NewKernelHandler.java new file mode 100644 index 000000000..aeb936c86 --- /dev/null +++ b/src/org.eclipse.ice.client.widgets.moose/src/org/eclipse/ice/client/widgets/moose/NewKernelHandler.java @@ -0,0 +1,73 @@ +package org.eclipse.ice.client.widgets.moose; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.cdt.core.dom.ast.ASTVisitor; +import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; +import org.eclipse.cdt.core.dom.ast.gnu.c.GCCLanguage; +import org.eclipse.cdt.core.model.ICContainer; +import org.eclipse.cdt.core.parser.DefaultLogService; +import org.eclipse.cdt.core.parser.FileContent; +import org.eclipse.cdt.core.parser.IParserLogService; +import org.eclipse.cdt.core.parser.IScannerInfo; +import org.eclipse.cdt.core.parser.ScannerInfo; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jface.viewers.TreeSelection; +import org.eclipse.ui.handlers.HandlerUtil; + +public class NewKernelHandler extends AbstractHandler { + + /** + * (non-Javadoc) + * + * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) + */ + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + + TreeSelection selection = (TreeSelection) HandlerUtil + .getCurrentSelection(event); + Object segment = selection.getPaths()[0].getLastSegment(); + if (segment instanceof IProject) { + IProject project = (IProject) segment; + } else if (segment instanceof ICContainer) { + ICContainer folder = (ICContainer) segment; + } + IParserLogService log = new DefaultLogService(); + + String code = "class Class { public: int x,y; Class(); ~Class(); private: Class f(); }; int function(double parameter) { return parameter; };"; + FileContent reader = FileContent.create("kernel.hpp",code.toCharArray()); + Map definedSymbols = new HashMap(); + String[] includePaths = new String[0]; + IScannerInfo info = new ScannerInfo(definedSymbols, includePaths); + + IASTTranslationUnit translationUnit = null; + try { + translationUnit = GCCLanguage.getDefault().getASTTranslationUnit(reader, info, null, null, 0, + log); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + ASTVisitor visitor = new ASTVisitor() { + public int visit(IASTName name) { + System.out.println(name.getRawSignature()); + return ASTVisitor.PROCESS_CONTINUE; + } + }; + visitor.shouldVisitNames = true; + translationUnit.accept(visitor); + + System.out.println("HELLO WORLD FROM NEW KERNEL HANDLER " + + selection.toString()); + return null; + } + +} diff --git a/src/org.eclipse.ice.core/src/org/eclipse/ice/core/internal/Core.java b/src/org.eclipse.ice.core/src/org/eclipse/ice/core/internal/Core.java index 2188a005b..e910da588 100644 --- a/src/org.eclipse.ice.core/src/org/eclipse/ice/core/internal/Core.java +++ b/src/org.eclipse.ice.core/src/org/eclipse/ice/core/internal/Core.java @@ -589,11 +589,19 @@ private void startHttpService() { // Register the service try { // Get the bundle - Bundle bundle = componentContext.getBundleContext().getBundle(); + Bundle bundle = null; + if (componentContext != null) { + bundle = componentContext.getBundleContext().getBundle(); + } else { + System.out + .println("ICore Message: ICE Core ComponentContext was null! No web service started."); + return; + } + // Make sure we got a valid bundle if (bundle == null) { System.out - .println("ICore Message: Could not get a valid reference to the Bundle. Start Http Service Failed."); + .println("ICore Message: ICE Core Bundle was null! No web service started."); return; } @@ -823,10 +831,10 @@ public String postUpdateMessage(String message) { String retVal = null; // Print the message if debugging is enabled - if (debuggingEnabled) { - System.out.println("Core Message: " - + "Update received with message: " + message); - } + // if (debuggingEnabled) { + System.out.println("Core Message: " + "Update received with message: " + + message); + // } // Only process the message if it exists and is not empty if (message != null && !message.isEmpty() && message.contains("=")) { @@ -851,4 +859,4 @@ public String postUpdateMessage(String message) { // Unlock the operation and return safely return (updateLock.getAndSet(false)) ? retVal : null; } -} \ No newline at end of file +}