Commit 5ebecd12 authored by arbennett's avatar arbennett
Browse files

Fixing some bugs and improving usability in projectgeneration.


Signed-off-by: default avatararbennett <bennett.andr@gmail.com>
parent 3476f683
......@@ -25,6 +25,8 @@ import org.eclipse.pde.core.plugin.IPluginBase;
import org.eclipse.pde.core.plugin.IPluginElement;
import org.eclipse.pde.core.plugin.IPluginExtension;
import org.eclipse.pde.core.plugin.IPluginModelFactory;
import org.eclipse.pde.ui.IFieldData;
import org.eclipse.pde.ui.IPluginFieldData;
import org.eclipse.pde.ui.templates.OptionTemplateSection;
/**
......@@ -40,7 +42,7 @@ public class ICEItemTemplate extends OptionTemplateSection {
// Strings used for templating
protected static final String EXTENSION_POINT = "org.eclipse.ice.item.itemBuilder";
protected static final String KEY_CLASS_NAME = "className";
protected static final String KEY_EXTENSION_NAME = "extensionName";
protected static final String KEY_EXTENSION_NAME = "packageName";
/**
* Constructor
......@@ -67,7 +69,7 @@ public class ICEItemTemplate extends OptionTemplateSection {
* Define the options, descriptions, default values, and page numbers
*/
protected void setOptions() {
addOption(KEY_CLASS_NAME , "Class Base Name" , "" , 0);
addOption(KEY_CLASS_NAME , "Class Base Name" , "" , 0);
}
@Override
......@@ -84,6 +86,10 @@ public class ICEItemTemplate extends OptionTemplateSection {
@Override public String getSectionId() { return "ICEItem"; }
@Override public String getUsedExtensionPoint() { return EXTENSION_POINT; }
public void setExtensionName(String extName) {
addOption(KEY_EXTENSION_NAME, "Extension Base Name", extName, 0);
}
protected String getFormattedPackageName(String id) {
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < id.length(); i++) {
......
......@@ -24,6 +24,8 @@ import org.eclipse.pde.ui.templates.NewPluginTemplateWizard;
*/
public class ICEItemWizard extends NewPluginTemplateWizard {
ITemplateSection[] templateSections;
public ICEItemWizard() {
super();
}
......@@ -34,7 +36,12 @@ public class ICEItemWizard extends NewPluginTemplateWizard {
@Override
public ITemplateSection[] createTemplateSections() {
return new ITemplateSection[] {new ICEItemTemplate()};
templateSections = new ITemplateSection[] {new ICEItemTemplate()};
return templateSections;
}
public void setTemplateExtension(String extName) {
((ICEItemTemplate) templateSections[0]).setExtensionName(extName);
}
}
......@@ -16,9 +16,11 @@ import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import static java.nio.file.StandardCopyOption.*;
import java.util.Arrays;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
......@@ -33,22 +35,18 @@ import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.pde.internal.core.PDECore;
import org.eclipse.pde.internal.ui.PDEPlugin;
import org.eclipse.pde.internal.ui.wizards.IProjectProvider;
import org.eclipse.pde.internal.ui.wizards.WizardElement;
import org.eclipse.pde.internal.ui.wizards.plugin.AbstractFieldData;
import org.eclipse.pde.internal.ui.wizards.plugin.NewPluginProjectWizard;
import org.eclipse.pde.internal.ui.wizards.plugin.NewProjectCreationFromTemplatePage;
import org.eclipse.pde.internal.ui.wizards.plugin.NewProjectCreationOperation;
import org.eclipse.pde.internal.ui.wizards.plugin.NewProjectCreationPage;
import org.eclipse.pde.internal.ui.wizards.plugin.PluginContentPage;
import org.eclipse.pde.internal.ui.wizards.plugin.PluginFieldData;
import org.eclipse.pde.ui.IPluginContentWizard;
import org.eclipse.pde.ui.templates.NewPluginProjectFromTemplateWizard;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkingSet;
import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
import org.eclipse.ice.projectgeneration.ICEItemNature;
......@@ -65,7 +63,6 @@ import org.eclipse.ice.projectgeneration.templates.ICEItemWizard;
public class NewICEItemProjectWizard extends NewPluginProjectFromTemplateWizard {
private static final String DESCRIPTION = "Create a new ICE item project.";
private static final String WIZARD_NAME = "New ICE Item Project";
private static final String WIZARD_TITLE = "Create a new ICE item project";
private static final String TEMPLATE_ID = "org.eclipse.ice.projectgeneration.pluginContent.ICEItem";
......@@ -76,9 +73,6 @@ public class NewICEItemProjectWizard extends NewPluginProjectFromTemplateWizard
private IProjectProvider fProjectProvider;
private IConfigurationElement fConfig;
private IStructuredSelection selection;
private IWorkbench workbench;
/**
* Constructor
*/
......@@ -130,10 +124,11 @@ public class NewICEItemProjectWizard extends NewPluginProjectFromTemplateWizard
addPage(pages[i]);
}
} catch (CoreException e) {
e.printStackTrace();
System.out.println("adding wizard pages fails!");
}
}
}
/**
* Takes all of the information from the wizard pages and uses it to create
* the plugin and java classes.
......@@ -151,6 +146,7 @@ public class NewICEItemProjectWizard extends NewPluginProjectFromTemplateWizard
fProjectPage.saveSettings(settings);
fContentPage.saveSettings(settings);
}
fTemplateWizard.setTemplateExtension(fProjectPage.getProjectName());
BasicNewProjectResourceWizard.updatePerspective(fConfig);
// If the PDE models are not initialized, initialize with option to
......@@ -179,6 +175,8 @@ public class NewICEItemProjectWizard extends NewPluginProjectFromTemplateWizard
getWorkbench().getWorkingSetManager().addToWorkingSets(fProjectProvider.getProject(), workingSets);
setNature(fProjectProvider.getProject());
setPackageLayout();
addPackageImports();
fProjectProvider.getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
successful = true;
} catch (InvocationTargetException e) {
PDEPlugin.logException(e);
......@@ -252,16 +250,36 @@ public class NewICEItemProjectWizard extends NewPluginProjectFromTemplateWizard
Files.move(f.toPath(), (new File(launcherDir.getAbsolutePath() + sep + f.getName())).toPath(), REPLACE_EXISTING);
} else if (f.getName().endsWith("Model.java") || f.getName().endsWith("ModelBuilder.java")) {
Files.move(f.toPath(), (new File(modelDir.getAbsolutePath() + sep + f.getName())).toPath(), REPLACE_EXISTING);
}
}
}
fProjectProvider.getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
} catch (IOException ioe) {
ioe.printStackTrace();
} catch (CoreException ce) {
ce.printStackTrace();
}
}
/**
* TODO: Description
*/
private void addPackageImports() {
String sep = System.getProperty("file.separator");
String manifestFile = fProjectProvider.getLocationPath().makeAbsolute().toOSString() +sep
+ fProjectProvider.getProjectName() + sep + "META-INF" + sep +"MANIFEST.MF";
StringBuilder importLines = new StringBuilder();
importLines.append("Import-Package: org.eclipse.ice.datastructures.form,\n");
importLines.append(" org.eclipse.ice.io.serializable,\n");
importLines.append(" org.eclipse.ice.item,\n");
importLines.append(" org.eclipse.ice.item.jobLauncher,\n");
importLines.append(" org.eclipse.ice.item.model,\n");
importLines.append(" org.eclipse.ice.datastructures.ICEObject,\n");
importLines.append(" org.eclipse.core.resources\n");
try {
Files.write(Paths.get(manifestFile), importLines.toString().getBytes(), StandardOpenOption.APPEND);
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
protected String getTemplateID() {
return TEMPLATE_ID;
......
package $packageName$.launcher;
import javax.xml.bind.annotation.XmlRootElement;
import org.eclipse.core.resources.IProject;
import org.eclipse.ice.item.jobLauncher.JobLauncher;
import org.eclipse.ice.datastructures.form.FormStatus;
import org.eclipse.ice.io.serializable.IIOService;
@XmlRootElement(name = "$className$Launcher")
......@@ -35,5 +40,6 @@ public class $className$Launcher extends JobLauncher {
@Override
public FormStatus process(String actionName) {
// TODO: Add User Code Here
return null;
}
}
\ No newline at end of file
......@@ -18,7 +18,7 @@ public class $className$LauncherBuilder extends AbstractItemBuilder {
*/
@Override
public Item getInstance(IProject projectSpace) {
Item item = new $className$(projectSpace);
Item item = new $className$Launcher(projectSpace);
item.setItemBuilderName(this.getItemName());
return item;
}
......
......@@ -5,7 +5,6 @@ import javax.xml.bind.annotation.XmlRootElement;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.ice.datastructures.ICEObject.Component;
import org.eclipse.ice.datastructures.form.Form;
import org.eclipse.ice.datastructures.form.FormStatus;
......@@ -41,11 +40,13 @@ public class $className$Model extends Item {
@Override
protected FormStatus reviewEntries(Form preparedForm) {
// TODO: Add User Code Here
return null;
}
@Override
public FormStatus process(String actionName) {
// TODO: Add User Code Here
return null;
}
@Override
......
......@@ -18,7 +18,7 @@ public class $className$ModelBuilder extends AbstractModelBuilder {
*/
@Override
public Item getInstance(IProject projectSpace) {
Item item = new $className$(projectSpace);
Item item = new $className$Model(projectSpace);
item.setItemBuilderName(this.getItemName());
return item;
}
......
......@@ -282,6 +282,7 @@ Java and all Java-based trademarks are trademarks of Oracle Corporation in the U
<plugin id="org.eclipse.ice.materials.ui" autoStart="true" startLevel="0" />
<plugin id="org.eclipse.ice.mesh" autoStart="true" startLevel="0" />
<plugin id="org.eclipse.ice.nek5000" autoStart="true" startLevel="0" />
<plugin id="org.eclipse.ice.projectgeneration" autoStart="false" startLevel="0" />
<plugin id="org.eclipse.ice.proteus" autoStart="true" startLevel="0" />
<plugin id="org.eclipse.ice.reactor.plant" autoStart="true" startLevel="0" />
<plugin id="org.eclipse.ice.reflectivity" autoStart="true" startLevel="0" />
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment