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

Updating IO naming to be consistent; added the IO format selector.


Signed-off-by: default avatararbennett <bennett.andr@gmail.com>
parent d5884f6a
......@@ -496,7 +496,7 @@ public class INIReader implements ITemplatedReader {
*/
@Override
public String getReaderType() {
return "INIReader";
return "INI";
}
}
......@@ -183,7 +183,7 @@ public class INIWriter implements IWriter {
*/
@Override
public String getWriterType() {
return "INIWriter";
return "INI";
}
}
......@@ -210,7 +210,7 @@ public class IPSReader implements IReader {
*/
@Override
public String getReaderType() {
return "IPSReader";
return "IPS";
}
/**
......
......@@ -231,7 +231,7 @@ public class IPSWriter implements IWriter {
*/
@Override
public String getWriterType() {
return "IPSWriter";
return "IPS";
}
/**
......
......@@ -15,6 +15,7 @@ package org.eclipse.ice.projectgeneration.templates;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Locale;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
......@@ -105,23 +106,25 @@ public class ICEItemTemplate extends OptionTemplateSection {
ArrayList<String> writerTypes = new ArrayList<String>();
try {
for (IReader reader : IReader.getIReaders()) {
readerTypes.add(reader.getReaderType().replace("Reader", ""));
readerTypes.add(reader.getReaderType());
}
for (IWriter writer : IWriter.getIWriters()) {
writerTypes.add(writer.getWriterType().replace("Writer", ""));
writerTypes.add(writer.getWriterType());
}
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ArrayList<String> ioFormats = new ArrayList<String>();
ArrayList<String[]> ioFormats = new ArrayList<String[]>();
for (String writer : writerTypes) {
if (readerTypes.contains(writer))
ioFormats.add(writer);
ioFormats.add(new String[] {writer, writer});
}
return new String[][] {(String[]) ioFormats.toArray(), (String[]) ioFormats.toArray()};
ioFormats.add(0, new String[] {"", ""});
String[][] options = new String[ioFormats.size()][2];
options = ioFormats.toArray(options);
return options;
}
protected String getFormattedPackageName(String id) {
......
......@@ -23,8 +23,7 @@ public class $className$Model extends Model {
// TODO:
// These need to be filled in before using this item
// They can be set in the setupItemInfo() method
private String writerName;
private String readerName;
private String ioFormat;
private String outputName;
// End required variables
......@@ -57,11 +56,12 @@ public class $className$Model extends Model {
protected void setupItemInfo() {
setName("$className$ Model");
setDescription("Specify information about $className$");
writerName = "$className$DefaultWriterName";
readerName = "$className$DefaultReaderName";
outputName = "$className$DefaultOutputName";
exportString = "Export to $className$ input format";
allowedActions.add(0, exportString);
ioFormat = $ioFormat$;
reader = ioService.getReader(ioFormat);
writer = ioService.getWriter(ioFormat);
}
/**
......@@ -145,9 +145,7 @@ public class $className$Model extends Model {
// setupItemInfo() method defined above.
if (actionName == exportString) {
IFile outputFile = project.getFile(outputName);
writer = ioService.getWriter(writerName);
retStatus = FormStatus.Processing;
writer.write(form, outputFile);
refreshProjectSpace();
retStatus = FormStatus.Processed;
} else {
......@@ -170,7 +168,6 @@ public class $className$Model extends Model {
// Read in the file and set up the form
IFile inputFile = project.getFile(fileName);
reader = ioService.getReader(readerName);
form = reader.read(inputFile);
form.setName(getName());
form.setDescription(getDescription());
......
......@@ -152,10 +152,10 @@ public class PROTEUSModel extends Item {
setIOService(new IOService());
ioService = getIOService();
}
if (ioService.getTemplatedReader("INIReader") == null) {
if (ioService.getTemplatedReader("INI") == null) {
ioService.addTemplatedReader(new INIReader());
}
if (ioService.getWriter("INIWriter") == null) {
if (ioService.getWriter("INI") == null) {
ioService.addWriter(new INIWriter());
}
......
......@@ -163,7 +163,7 @@ public class VibeLauncher extends JobLauncher {
@Override
public FormStatus process(String actionName) {
IReader reader = (IReader) ioService.getReader("IPSReader");
IReader reader = (IReader) ioService.getReader("IPS");
DataComponent fileComponent = (DataComponent) form.getComponent(1);
IEntry inputFileEntry = fileComponent.retrieveEntry("Input File");
IEntry kvPairFileEntry = fileComponent.retrieveEntry("Use custom key-value pair file?");
......
......@@ -177,7 +177,7 @@ public class VibeModel extends Model {
if (components.size() > 3) {
// create a new IPSWriter with the output file
IWriter writer = (IWriter) ioService.getWriter("IPSWriter");
IWriter writer = (IWriter) ioService.getWriter("IPS");
try {
// Write the output file
writer.write(form, outputFile);
......@@ -267,7 +267,7 @@ public class VibeModel extends Model {
// Load the components from the file and setup the form
logger.info("VibeModel Message: Loading " + inputFile.getName());
IReader reader = (IReader) ioService.getReader("IPSReader"); //new IPSReader();
IReader reader = (IReader) ioService.getReader("IPS"); //new IPSReader();
form = reader.read(inputFile);
form.setName(getName());
form.setDescription(getDescription());
......
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