diff --git a/README.md b/README.md
index 44edcfb2c..9942fdb80 100644
--- a/README.md
+++ b/README.md
@@ -4,3 +4,7 @@ The Eclipse Integrated Computational Environment (ICE)
Eclipse ICE Project Main Repository
Build instructions available here: http://wiki.eclipse.org/ICE_Build_Instructions
+
+Contributions follow the standard Eclipse mechanisms. If you are looking at
+this, then you are most likely using Git and can start the process by issuing
+a pull request on our GitHub repo.
diff --git a/org.eclipse.ice.target.kepler/kepler_rcp.target b/org.eclipse.ice.target.kepler/kepler_rcp.target
index 9ced507cf..cf9c1e287 100644
--- a/org.eclipse.ice.target.kepler/kepler_rcp.target
+++ b/org.eclipse.ice.target.kepler/kepler_rcp.target
@@ -1,5 +1,5 @@
-
+
@@ -82,5 +82,14 @@
+
+
+
+
+
+
+
+
+
diff --git a/repository/org.eclipse.ice.repository/ice.product.launch b/repository/org.eclipse.ice.repository/ice.product.launch
index e4bcc03ba..be1de7f8e 100644
--- a/repository/org.eclipse.ice.repository/ice.product.launch
+++ b/repository/org.eclipse.ice.repository/ice.product.launch
@@ -1,33 +1,33 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/ElementSourceDialog.java b/src/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/ElementSourceDialog.java
new file mode 100644
index 000000000..dc66131dd
--- /dev/null
+++ b/src/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/ElementSourceDialog.java
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * Copyright (c) 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
+ *******************************************************************************/
+package org.eclipse.ice.client.widgets;
+
+import org.eclipse.ice.datastructures.ICEObject.IElementSource;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+
+import ca.odell.glazedlists.EventList;
+import ca.odell.glazedlists.swt.DefaultEventTableViewer;
+
+/**
+ * This class is a JFace Dialog for rendering IElementSources that are used by
+ * ListComponents.
+ *
+ * Only single selections are supported.
+ *
+ * @author Jay Jay Billings
+ *
+ */
+public class ElementSourceDialog extends Dialog {
+
+ /**
+ * The source that should be drawn
+ */
+ private IElementSource source;
+
+ /**
+ * The SWT table that shows the list
+ */
+ private Table listTable;
+
+ /**
+ * The selection made by the user or null if the dialog was closed.
+ */
+ private T selection;
+
+ /**
+ * The list of elements rendered in the table
+ */
+ private EventList elements;
+
+ /**
+ * The constructor
+ *
+ * @param parentShell
+ * The shell in which the dialog should be drawn
+ * @param source
+ * The IElementSource that should be drawn
+ */
+ public ElementSourceDialog(Shell parentShell,
+ IElementSource elementSource) {
+ super(parentShell);
+ source = elementSource;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets
+ * .Composite)
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+
+ Composite comp = (Composite) super.createDialogArea(parent);
+
+ // Create the table to hold the ListComponent.
+ listTable = new Table(parent, SWT.FLAT);
+ elements = source.getElements();
+ DefaultEventTableViewer listTableViewer = new DefaultEventTableViewer(
+ elements, listTable, source.getTableFormat());
+ listTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1,
+ 1));
+
+ return comp;
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ @Override
+ protected void okPressed() {
+ // Set the selection if the OK button was pressed
+ int index = listTable.getSelectionIndex();
+ selection = elements.get(index);
+ super.okPressed();
+ }
+
+ /**
+ * This operation returns the selection made in the dialog.
+ *
+ * @return The selection. If multiple items were selected, only the first is
+ * returned.
+ */
+ public T getSelection() {
+ return selection;
+ }
+
+}
diff --git a/src/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/EntryComposite.java b/src/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/EntryComposite.java
index 967d99a41..2e22cd94e 100644
--- a/src/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/EntryComposite.java
+++ b/src/org.eclipse.ice.client.widgets/src/org/eclipse/ice/client/widgets/EntryComposite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2014 UT-Battelle, LLC.
+ * Copyright (c) 2012, 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
@@ -53,7 +53,6 @@
import org.eclipse.ui.forms.IMessageManager;
/**
- *
*
* This is an subclass of SWT's Composite class made specifically to work with
* ICE Entries.
@@ -67,90 +66,43 @@
* The EntryComposite can post messages about its work with an Entry to a
* IMessageManager if it is set by calling setMessageManager().
*
- *
*
* @author gqx
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
public class EntryComposite extends Composite implements IUpdateableListener {
/**
- *
- *
- *
- *
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
protected final List
*
+ * I also had to override the ListEventListener registration operations to make
+ * sure that the source list was registered. The TransformedList by defaults
+ * registers listeners against itself, not the source, but it processes all of
+ * the list additions, etc., through the source.
+ *
* @author Jay Jay Billings
*
*/
@@ -438,6 +443,17 @@ public T setColumnValue(T baseObject, Object editedValue, int column) {
return retValue;
};
+ /**
+ * This operation sets the element source that should be used by the list
+ *
+ * @param source
+ * the element source that provides a list of values that
+ * *should* be used to seed new entries.
+ */
+ public void setElementSource(IElementSource source) {
+ elementSource = source;
+ }
+
/**
* This operation returns the element source which should be used to create
* new elements to add to the list.
@@ -506,4 +522,5 @@ public void removeListEventListener(
// Remove the listener from the TransformedList's source EventList.
super.source.removeListEventListener(listChangeListener);
}
+
}
diff --git a/src/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/form/AdaptiveTreeComposite.java b/src/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/form/AdaptiveTreeComposite.java
index 968641914..f41d39292 100644
--- a/src/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/form/AdaptiveTreeComposite.java
+++ b/src/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/form/AdaptiveTreeComposite.java
@@ -12,14 +12,11 @@
*******************************************************************************/
package org.eclipse.ice.datastructures.form;
-import java.io.IOException;
-import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import javax.xml.bind.JAXBException;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
@@ -27,7 +24,6 @@
import javax.xml.bind.annotation.XmlRootElement;
import org.eclipse.ice.datastructures.ICEObject.Component;
-import org.eclipse.ice.datastructures.ICEObject.ICEJAXBHandler;
import org.eclipse.ice.datastructures.ICEObject.IUpdateableListener;
import org.eclipse.ice.datastructures.componentVisitor.IComponentVisitor;
@@ -214,8 +210,10 @@ public boolean setType(String type) {
// Look for a match in the new parameter HashMap
if (newParamMap.containsKey(currEntry.getName())) {
// Copy the data into the new parameter list
- (newParamMap.get(currEntry.getName()))
- .copy(currEntry);
+ Entry newEntry = newParamMap.get(currEntry.getName());
+ boolean req = currEntry.isRequired();
+ newEntry.copy(currEntry);
+ newEntry.setRequired(req);
}
// If it's not in the list and the previous type of
@@ -244,9 +242,13 @@ else if (oldType == null
copy(typeTree);
}
- // Set the old name, state, children and child exemplars
+ // Set the old name, state, active data node, children and
+ // child exemplars
setName(oldTreeName);
setActive(isActive);
+ if (getDataNodes() != null && !getDataNodes().isEmpty()) {
+ setActiveDataNode(getDataNodes().get(0));
+ }
for (TreeComposite tree : children) {
setNextChild(tree);
}
@@ -274,8 +276,8 @@ else if (oldType == null
* AdaptiveTreeComposite. It is null if no types are available.
*/
public ArrayList getTypes() {
- return (typesMap != null) ? new ArrayList(typesMap.keySet())
- : null;
+ return (typesMap != null) ?
+ new ArrayList(typesMap.keySet()) : null;
}
/**
diff --git a/src/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/form/Material.java b/src/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/form/Material.java
index f91fcd921..4cd7b66ca 100644
--- a/src/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/form/Material.java
+++ b/src/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/form/Material.java
@@ -62,7 +62,7 @@ public class Material implements Cloneable {
/**
* The list of components that comprise this material.
*/
- @XmlElement(name="Material")
+ @XmlElement(name = "Material")
private List components;
/**
@@ -122,10 +122,15 @@ public void setSize(int matSize) {
*
* @param key
* The key/name of the property whose value should be returned
- * @return the value
+ * @return the value or 0.0 if this value is not in the map, but
+ * never null.
*/
public double getProperty(String key) {
- return properties.get(key);
+ double value = 0.0;
+ if (properties.containsKey(key)) {
+ value = properties.get(key);
+ }
+ return value;
}
/**
@@ -222,22 +227,27 @@ public int hashCode() {
}
/**
- * This operation copies the content of the incoming material into this material.
- * @param material the material to copy
+ * This operation copies the content of the incoming material into this
+ * material.
+ *
+ * @param material
+ * the material to copy
*/
public void copy(Material material) {
// Don't copy the input if it is not a Material or if it is null
if (material != null && material != this) {
this.name = material.name;
this.size = material.size;
- this.properties = (HashMap) material.properties.clone();
+ this.properties = (HashMap) material.properties
+ .clone();
this.components = new ArrayList(material.components);
- }
+ }
}
-
+
/**
* This operation clones the material and creates a completely new material
* with the same information.
+ *
* @return The clone
*/
public Object clone() {
diff --git a/src/org.eclipse.ice.io/META-INF/MANIFEST.MF b/src/org.eclipse.ice.io/META-INF/MANIFEST.MF
index ecb335ded..a9515b733 100644
--- a/src/org.eclipse.ice.io/META-INF/MANIFEST.MF
+++ b/src/org.eclipse.ice.io/META-INF/MANIFEST.MF
@@ -12,6 +12,7 @@ Require-Bundle: org.eclipse.ice.datastructures;bundle-version="2.0.0",
Service-Component: OSGI-INF/HdfIORegistry.xml,OSGI-INF/HdfIOFactory.xml,
OSGI-INF/ioservice.xml
Comment: Service-Component: OSGI-INF/ICEDatabaseHarness.xml
-Export-Package: org.eclipse.ice.io.hdf,
+Export-Package: org.eclipse.ice.io.csv,
+ org.eclipse.ice.io.hdf,
org.eclipse.ice.io.ips,
org.eclipse.ice.io.serializable
diff --git a/src/org.eclipse.ice.io/src/org/eclipse/ice/io/csv/CSVReader.java b/src/org.eclipse.ice.io/src/org/eclipse/ice/io/csv/CSVReader.java
new file mode 100644
index 000000000..b2d86ddb3
--- /dev/null
+++ b/src/org.eclipse.ice.io/src/org/eclipse/ice/io/csv/CSVReader.java
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+package org.eclipse.ice.io.csv;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+
+import javax.naming.OperationNotSupportedException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.ice.datastructures.ICEObject.ListComponent;
+import org.eclipse.ice.datastructures.form.Entry;
+import org.eclipse.ice.datastructures.form.Form;
+import org.eclipse.ice.io.serializable.IReader;
+
+/**
+ * This class implements the IReader interface to provide a reader for CSV
+ * files. It can read any well-formed CSV file. It stores its results in a
+ * ListComponent on the Form returned from read(). Each String [] in
+ * the ListComponent is a line of the file, split and trimmed but uncast.
+ * Clients must know the concrete type to which they want to cast.
+ *
+ * Comments are ignored and begin with the "#" character.
+ *
+ * @author Jay Jay Billings
+ *
+ */
+public class CSVReader implements IReader {
+
+ /**
+ * The lines of text read from the last file.
+ */
+ ListComponent lines;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ice.io.serializable.IReader#read(org.eclipse.core.resources
+ * .IFile)
+ */
+ @Override
+ public Form read(IFile file) {
+
+ // Configure the form
+ Form form = new Form();
+ form.setName(file.getName());
+ form.setDescription(file.getName());
+
+ // Configure the list
+ lines = new ListComponent();
+ lines.setName(file.getName());
+ lines.setDescription(file.getName());
+
+ try {
+ // Grab the contents of the file
+ BufferedReader reader = new BufferedReader(new InputStreamReader(
+ file.getContents()));
+ String line = null;
+ while ((line = reader.readLine()) != null) {
+ // Skip lines that pure comments
+ if (!line.startsWith("#")) {
+ // Clip the line if it has a comment symbol in it to be
+ // everything before the symbol
+ if (line.contains("#")) {
+ int index = line.indexOf("#");
+ line = line.substring(0, index);
+ }
+ // Clean up any crap on the line
+ String[] lineArray = line.trim().split(",");
+ // And clean up any crap on each split piece
+ for (String element : lineArray) {
+ element = element.trim();
+ }
+ // Put the lines in the list
+ lines.add(lineArray);
+ }
+ }
+ form.addComponent(lines);
+ } catch (CoreException e) {
+ // Complain
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return form;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ice.io.serializable.IReader#findAll(org.eclipse.core.resources
+ * .IFile, java.lang.String)
+ */
+ @Override
+ public ArrayList findAll(IFile file, String regex) {
+ try {
+ throw new OperationNotSupportedException("CSVReader Error: "
+ + "IReader.findAll() is not supported... yet.");
+ } catch (OperationNotSupportedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ice.io.serializable.IReader#getReaderType()
+ */
+ @Override
+ public String getReaderType() {
+ return "csv";
+ }
+
+}
diff --git a/src/org.eclipse.ice.item/META-INF/MANIFEST.MF b/src/org.eclipse.ice.item/META-INF/MANIFEST.MF
index df562d967..605eb72c9 100644
--- a/src/org.eclipse.ice.item/META-INF/MANIFEST.MF
+++ b/src/org.eclipse.ice.item/META-INF/MANIFEST.MF
@@ -23,6 +23,7 @@ Export-Package: org.eclipse.ice.item,
org.eclipse.ice.item.jobLauncher,
org.eclipse.ice.item.jobprofile,
org.eclipse.ice.item.messaging,
+ org.eclipse.ice.item.model,
org.eclipse.ice.item.nuclear
Require-Bundle: org.eclipse.core.resources;bundle-version="3.7.100",
org.eclipse.core.runtime;bundle-version="3.7.0",
diff --git a/src/org.eclipse.ice.item/src/org/eclipse/ice/item/AbstractItemBuilder.java b/src/org.eclipse.ice.item/src/org/eclipse/ice/item/AbstractItemBuilder.java
index cc37ce51c..151214bc5 100644
--- a/src/org.eclipse.ice.item/src/org/eclipse/ice/item/AbstractItemBuilder.java
+++ b/src/org.eclipse.ice.item/src/org/eclipse/ice/item/AbstractItemBuilder.java
@@ -49,7 +49,7 @@ public class AbstractItemBuilder implements ItemBuilder {
* The IActionFactory that will provide Actions to the Items created by this
* Builder.
*/
- private static IActionFactory actionFactory;
+ private IActionFactory actionFactory;
/*
* (non-Javadoc)
@@ -89,6 +89,10 @@ public Item build(IProject projectSpace) {
// Set the services
setServices(item);
+ // Tell the Item it can configure any data on its Form that requires the
+ // services
+ item.setupFormWithServices();
+
return item;
}
diff --git a/src/org.eclipse.ice.item/src/org/eclipse/ice/item/AbstractModelBuilder.java b/src/org.eclipse.ice.item/src/org/eclipse/ice/item/AbstractModelBuilder.java
deleted file mode 100644
index f014dfe9c..000000000
--- a/src/org.eclipse.ice.item/src/org/eclipse/ice/item/AbstractModelBuilder.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * 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
- *******************************************************************************/
-package org.eclipse.ice.item;
-
-import org.eclipse.ice.materials.IMaterialsDatabase;
-
-/**
- * This is a subclass of AbstractItemBuilder specifically focused on adding
- * services for Models, which are Items that generate input files or data.
- *
- * @author Jay Jay Billings
- *
- */
-public class AbstractModelBuilder extends AbstractItemBuilder {
-
- /**
- * This operation sets the service reference for the IMaterialsDatabase
- * service.
- *
- * @param database the service
- */
- public void setMaterialsDatabase(IMaterialsDatabase database) {
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ice.item.AbstractItemBuilder#setServices(org.eclipse.ice.
- * item.Item)
- */
- @Override
- protected void setServices(Item item) {
-
- }
-
-}
diff --git a/src/org.eclipse.ice.item/src/org/eclipse/ice/item/Item.java b/src/org.eclipse.ice.item/src/org/eclipse/ice/item/Item.java
index 4b1b81e41..07f41c995 100644
--- a/src/org.eclipse.ice.item/src/org/eclipse/ice/item/Item.java
+++ b/src/org.eclipse.ice.item/src/org/eclipse/ice/item/Item.java
@@ -84,8 +84,6 @@
import java.nio.file.StandardCopyOption;
/**
- *
- *
* The Item class is responsible for carrying out activities necessary to
* perform certain tasks with ICE. The operations process(), setupForm(), and
* reviewEntries() should be tailored and called by subclasses as needed. The
@@ -95,8 +93,10 @@
* FormStatus.ReadyToProcess state and all subclasses shall obey the rule that
* Items are initialized with an acceptable set of default parameters such that
* they could be processed immediately.
- *
- *
+ *
+ * Subclasses that require platform services to fully configure their form
+ * should see and override setupFormWithServices() in addition to setupForm().
+ *
* Instances of classes that realize the IUpdateable interface can be registered
* to receive updates from others in the Item with the Registry. Subclasses
* should override registerUpdateables(). This operation performs parent-child
@@ -106,35 +106,29 @@
* re-registered if the Item is copied. IUpdateables should never be registered
* outside of this operation. (We'll cross the bridge of dynamically updated
* dependencies when we get to it...)
- *
- *
+ *
* Items may be loaded from a file. This file is either an XML file of the form
* required by the Item's JAXB annotations or it is in the Painfully Simple Form
* file format. Items may be initialized using either file type, but they will
* only persist to the ICE database or to the XML form of an Item. Items must be
* loaded by calling either loadFromXML() or loadFromPSF() after construction.
* If it can not read properly either a PSF or XML format, it will fail.
- *
- *
+ *
* By default, the reviewEntries() operation on an Item only performs simple
* dependency checks to determine if Entries should or should not be notified
* that their parents have changed or been marked ready. The default
* implementation of setupForm() will add Entries with parents to the Registry
* if the Item is loaded from a file, otherwise it will do nothing.
- *
- *
+ *
* The only Actions available to the Item by default are actions to write the
* Item's Form to an XML file or a "tagged output" where the tags of Entries are
* used as keys associated with the values of the Entry. If the Entries do not
* have tags, then the names of the Entries are used.
- *
- *
+ *
* The Item class realizes the IComponent Visitor interface so that it can map
* the Components in the Form and determine their types.
- *
- *
+ *
* The Item behaves as follows for each state:
- *
*
*
*
@@ -242,19 +236,17 @@
*
*
*
- *
+ *
* Items can be stored to JPA databases. See the *Database() operations for more
* information.
- *
- *
+ *
* Items can be disabled and put in to a "read-only" mode where their forms can
* be read, but the Item will not accept updated Forms or process actions.
* Attempts to process the Item or submit a form will return
* FormStatus.Unacceptable if the Item is disabled. Checking the Item's status
* with getStatus() will also return FormStatus.Unacceptable. Items are enabled
* by default.
- *
- *
+ *
* The Item class also logs output to an output file. This file includes any
* information that the author of the subclass of the Item wants to persist when
* the Item is processed. It may or may not include, at the discretion of the
@@ -268,72 +260,47 @@
* clients should be careful to only read from the file. Unfortunately there is
* no good way to pass a read-only file in Java because that is an OS dependent
* operation.
- *
- *
- * If the project space for the Item has not be set upon construction, the
- * output file will not be configured and getOutputFile() will be null.
- *
- *
+ *
+ * If the project space for the Item is not set upon construction, the output
+ * file will not be configured and getOutputFile() will be null.
+ *
* Items can also be observed by ItemListeners. Subclasses must implement the
* calls to update the listeners on their own, although some protected utility
* operations like notifyListenersOfProjectChange() exist.
- *
- *
+ *
* Every Item has a directory at its disposal for storing preferences or scratch
* data. This directory can be retrieved by subclasses by calling
* getPreferencesDirectory(). This directory should only include preferences,
* configuration information, scratch data or other types of data that are not
* directly consumed by users.
- *
- *
+ *
* Subclasses may override the loadInput() operation to handle input data
* import. This operation is passed an inputstream that should contain data of
* the proper format when a client tries to import data.
- *
- *
+ *
* Items can also receive updates from other ICE subsystems, remote ICE
* subsystems or external third-party processes through via the update()
* operation. In practice, these messages are filtered by classes higher up the
* call stack and acted upon by the Item.
- *
- *
*
* @author Jay Jay Billings, Anna Wojtowicz
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
@XmlRootElement(name = "Item")
public class Item implements IComponentVisitor, Identifiable,
IUpdateableListener {
/**
- *
- *
* The ItemType of the Item.
- *
- *
- *
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
@XmlAttribute()
protected ItemType itemType;
/**
- *
- *
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
+ * The Registry used to manage registration and update events between the
+ * Item and the various data structures.
*/
@XmlTransient()
protected Registry registry;
/**
- *
- *
* The Item's Form.
- *
- *
- *
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
@XmlAnyElement()
@XmlElementRefs(value = {
@@ -342,225 +309,113 @@ public class Item implements IComponentVisitor, Identifiable,
protected Form form;
/**
- *
- *
* The action that is currently being performed by the Item.
- *
* The list of Entries from the Form. This list is maintained to improve the
* speed of reviewEntries() and is created in setupForm() when it is called
* by loadFromXML() or loadFromPSF().
- *
* The string that is used to describe the process by which the Item class
* writes the values of the Entries in the Form to a file using their tags,
* or their names if no tags are available, as keys.
- *
* A map that contains all of the Components of the Form with each Component
* type as a key (data, output or table) and an arraylist of the Components
* as the value.
- *
* The description of the Item. This description should be different than
* the name of the Item and should contain information that would be useful
* to a human user.
- *
* A specifically attribute designed to be utilized by the JPA database.
* This variable should not be accessed normally by ICE, only by JPA. DO NOT
* OVERRIDE THIS VARIABLE!
- *
* The last status of the Item before it was process or modified. This is
* used, for example, when killing processes or disabling the Item so that
* the it can be reverted to the last state.
- *
* The file handle to the output file that stores output generated by this
* Item during processing. The data in this file is information provided by
* the Item and may or may not include, at the discretion of the author of
* the subclass, output collected from externally launched programs.
- *
- *
- *
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
@XmlTransient
protected File outputFile;
@@ -572,14 +427,7 @@ public class Item implements IComponentVisitor, Identifiable,
private static ResourceHandler resourceHandler = new ResourceHandler();
/**
- *
- *
* The constructor. Subclasses of Item should implement their own
* constructor, but creating the Form should be done in the setupForm()
* operation, which is called by this constructor. Creating the Form
@@ -614,19 +460,12 @@ public class Item implements IComponentVisitor, Identifiable,
* project where the Item should store files is passed as an argument. Since
* there is no guarantee that the Item will actually need this argument, it
* may be null.
- *
- *
*
* @param projectSpace
- *
* The Eclipse project where files should be stored for this
* Item.
- *
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
public Item(IProject projectSpace) {
- // begin-user-code
// Determine whether or not ICE is in debug mode
if (System.getProperty("DebugICE") != null) {
@@ -695,29 +534,19 @@ public Item(IProject projectSpace) {
setupOutputFile();
return;
- // end-user-code
}
/**
- *
- *
* A nullary constructor. This constructor should only be used by JAXB or
* JPA for loading the Item from a serialized or transactional form
* respectively. If this constructor is used, setProject() must be called
* immediately after or an Item will not function.
- *
- *
- *
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
public Item() {
- // begin-user-code
// Just call the other constructor with a null argument.
this(null);
- // end-user-code
}
/**
@@ -791,11 +620,8 @@ public void setActionFactory(IActionFactory factory) {
* (non-Javadoc)
*
* @see Identifiable#setId(int id)
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
public void setId(int id) {
- // begin-user-code
if (id >= 0) {
// Set the unique id
@@ -807,94 +633,70 @@ public void setId(int id) {
return;
- // end-user-code
}
/**
* (non-Javadoc)
*
* @see Identifiable#getDescription()
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
@XmlAttribute()
public String getDescription() {
- // begin-user-code
return itemDescription;
- // end-user-code
}
/**
* (non-Javadoc)
*
* @see Identifiable#getId()
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
@XmlAttribute()
public int getId() {
- // begin-user-code
return uniqueId;
- // end-user-code
}
/**
* (non-Javadoc)
*
* @see Identifiable#setName(String name)
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
public void setName(String name) {
- // begin-user-code
if (name != null) {
itemName = name;
}
- // end-user-code
}
/**
* (non-Javadoc)
*
* @see Identifiable#getName()
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
@XmlAttribute
public String getName() {
- // begin-user-code
return itemName;
- // end-user-code
}
/**
* (non-Javadoc)
*
* @see Identifiable#setDescription(String description)
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
public void setDescription(String description) {
- // begin-user-code
if (description != null) {
this.itemDescription = description;
}
- // end-user-code
}
/**
* (non-Javadoc)
*
* @see Identifiable#equals(Object otherObject)
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
public boolean equals(Object otherObject) {
- // begin-user-code
// Local Declarations
boolean retVal = false;
@@ -925,52 +727,31 @@ public boolean equals(Object otherObject) {
return retVal;
- // end-user-code
}
/**
- *
- *
* This operation returns the type of the Item. The type of the Item is
* determined by the Item class or a subclass and can not be set.
- *
- *
*
- * @return
- * The type of the Item.
- *
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
+ * @return The type of the Item.
*/
public ItemType getItemType() {
- // begin-user-code
return this.itemType;
- // end-user-code
}
/**
- *
- *
* This operation returns a Form for the Item.
- *
- *
+ *
* If this operation is called immediately after processItem() with the same
* Item id and the call to processItem() returns FormStatus.NeedsInfo, then
* this operation will return a simple Form composed of a single
* DataComponent with Entries for all of the additional required
* information. The smaller Form is created by the Action that is executed
* during the call to processItem().
- *
- *
*
- * @return
- * The Form that Eclipse User must prepare.
- *
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
+ * @return The Form that Eclipse User must prepare.
*/
public Form getForm() {
- // begin-user-code
// Local Declarations
Form actionForm = null;
@@ -986,37 +767,24 @@ public Form getForm() {
return actionForm;
}
- // end-user-code
}
/**
- *
- *
* This operation submits a Form to the Item for processing.
- *
- *
+ *
* This operation only reviews the contractual obligations of the Form and
* the Item class, such as matching Item and Form.getItemId() values.
* Business concerns are reviewed in Item.reviewEntries, which is called by
* this class. This class also handles overwriting or discarding Forms as
* required.
- *
- *
*
* @param preparedForm
- *
* A Form that has been prepared by the Eclipse User with
* information that is required by the Item.
- *
- * @return
- * The ItemStatus value that specifies whether or not the Form was
+ * @return The ItemStatus value that specifies whether or not the Form was
* accepted by the Item.
- *
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
public FormStatus submitForm(Form preparedForm) {
- // begin-user-code
// Local Declarations
FormStatus retVal = FormStatus.InfoError;
@@ -1090,17 +858,13 @@ public FormStatus submitForm(Form preparedForm) {
status = retVal;
return retVal;
- // end-user-code
}
/**
- *
- *
* The process operation processes the data in the Form to perform a certain
* action. The action name must be one of the set of actions from the Form
* that represents this Item.
- *
- *
+ *
* It is possible that ICE may require information in addition to that which
* was requested in the original Form, such as for a username and password
* for a remote machine. If this is the case, process will return
@@ -1108,8 +872,7 @@ public FormStatus submitForm(Form preparedForm) {
* Item by calling getItem(). Once this new Form is submitted (by calling
* Item.submitForm() with the completed Form), the Item will finish
* processing.
- *
- *
+ *
* This operation must be tailored by subclasses to initiate specific
* Actions. The only Actions available to the Item by default are actions to
* write the Item's Form to an XML file or a "tagged output" where the tags
@@ -1122,25 +885,16 @@ public FormStatus submitForm(Form preparedForm) {
* actions are be "Export to ICE Native Format" and
* "Export to key-value pair output." Subclasses may choose to add
* additional actions or to remove the default actions.
- *
- *
*
* @param actionName
- *
* The name of action that should be performed using the
* processed Form data.
- *
- * @return
- * The status of the Item after processing the Form and executing
+ * @return The status of the Item after processing the Form and executing
* the action. It returns FormStatus.InfoError if it is unable to
* run for any reason, including being asked to run actions that are
* not in the list of available actions.
- *
* This operation cancels all processes with the specified name.
- *
- *
*
* @param actionName
- *
* The name of action that should be canceled.
- *
- * @return
- * The status of the Item after canceling or trying to cancel an
+ * @return The status of the Item after canceling or trying to cancel an
* action.
- *
* This operation cancels the last process request sent to the Item.
- *
- *
*
- * @return
- * The status of the Item after canceling or trying to cancel an
+ * @return The status of the Item after canceling or trying to cancel an
* action.
- *
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
public FormStatus cancelProcess() {
- // begin-user-code
// Only cancel if the Item is actuallly processing
if (action != null && status.equals(FormStatus.Processing)) {
@@ -1266,41 +998,23 @@ public FormStatus cancelProcess() {
}
return status;
- // end-user-code
}
/**
- *
- *
* This operation returns the list of available actions for an Item.
- *
- *
*
- * @return
- * The list of actions available in the Item.
- *
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
+ * @return The list of actions available in the Item.
*/
public ArrayList getAvailableActions() {
- // begin-user-code
return (ArrayList) allowedActions.clone();
- // end-user-code
}
/**
- *
- *
* This operation returns the status of the Item.
- *
- *
*
- * @return
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
+ * @return The current status of the Item.
*/
public FormStatus getStatus() {
- // begin-user-code
// If the Item is disabled, do not do any further checks. Just report
// it.
@@ -1315,88 +1029,87 @@ public FormStatus getStatus() {
}
return status;
- // end-user-code
}
/**
- *
- *
* This protected operation setups the Entries, DataComponents and Form for
- * a subclass of Item. The default implementation of setupForm() will add
- * Entries with parents to the Registry if the Item is loaded from a file,
- * otherwise it will do nothing. Subclasses should tailor this operation as
- * needed. The list of allowed Actions may also be specified here.
- *
- *
+ * a subclass of Item. Subclasses should tailor this operation as needed.
+ * The list of allowed Actions may also be specified here.
*
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
+ * This operation should always be called first in a subclasses
+ * implementation to instantiate the Form.
+ *
+ * Subclasses that need platform services, such as the IOService, should
+ * override setupFormWithServices() in addition to this operation. In that
+ * scenario, setupForm() will contain the code necessary to instantiate and
+ * add empty data structures to the Form and setupFormWithServices() will
+ * fill those structures with data.
*/
protected void setupForm() {
- // begin-user-code
// Initialize the Form it should be a PSF in case the Item is loaded
// from a PSF file.
form = new PainfullySimpleForm();
return;
- // end-user-code
}
/**
- *
- *
* This operation is used to setup the name and description of an Item. This
* information can be provided by the ItemBuilder responsible for this Item
* or any client, but it is convenient to define it on the class. It is also
* convenient to define it separately of the work in setupForm(). The
* default implementation of this operation does nothing and subclasses must
* override it.
- *
+ * This operation directs the Item to setup its Form using the services that
+ * were registered with it after construction. It is separate from
+ * setupForm() because services are not injected upon construction, but it
+ * is still necessary to construct the Form in some rudimentary way.
+ *
+ * Subclasses should override this operation as well as setupForm() whenever
+ * they need to use services, such as the IOService, to completely
+ * initialize their Form.
+ *
+ * This operation should always be called after an Item is constructed and
+ * its services are set.
+ *
+ * It is not necessary to call the base class implementation of this
+ * operation before doing work as is suggested for setupForm().
+ */
+ public void setupFormWithServices() {
+
+ // Do nothing by default
+
+ }
+
+ /**
* The reviewEntries operations reviews and updates Entry values as needed.
* This is an abstract operation that must be implemented by a subclass.
- *
- *
+ *
* This operation is only concerned with the business issues of the Form and
* not the contractual obligations that it must fulfill to satisfy ICE. For
* example, reviewEntries() should make sure that the Form has acceptable
* Entries for the particular business problem instead of worrying about
* unique identifiers. This operation should also return the status of the
* Form as a literal from the FormStatus enumeration.
- *
- *
+ *
* By default, the reviewEntries() operation on an Item only performs simple
* dependency checks to determine if Entries should or should not be
* notified that their parents have changed or been marked ready.
- *
- *
*
* @param preparedForm
- * @return
- * True if the Entries are completely specified and the Item can be
+ * @return True if the Entries are completely specified and the Item can be
* processed, false otherwise.
- *
* This operation performs dependency matching by registering IUpdateable
* objects with the registry based on values and child names. Subclasses
* should always override this operation to register their dependencies
* since dependencies must be re-registered if the Item is copied. This
* operation does a non-trivial task, so subclasses should always call
* super.registerUpdateables() too.
- *
- *
+ *
* The default implementation pulls all Entries from all Data, Table and
* Output components and registers parent-child dependencies for those
* Entries.
- *
* This operation returns the hashcode value of the Item.
- *
- *
*
- * @return
- * The hashcode
- *
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
+ * @return The hashcode
*/
public int hashCode() {
- // begin-user-code
// Local Declaration
int hash = 9;
@@ -1524,26 +1217,16 @@ public int hashCode() {
hash += 31 * this.builderName.hashCode();
return hash;
- // end-user-code
}
/**
- *
- *
* This operation performs a deep copy of the attributes of another Item
* into the current Item.
- *
- *
*
* @param otherItem
- *
* The Item from which information should be copied.
- *
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
public void copy(Item otherItem) {
- // begin-user-code
// Return if otherItem is null
if (otherItem == null) {
@@ -1570,24 +1253,14 @@ public void copy(Item otherItem) {
setupEntryList();
return;
- // end-user-code
}
/**
- *
- *
* This operation provides a deep copy of the Item.
- *
- *
*
- * @return
- * A clone of the Item.
- *
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
+ * @return A clone of the Item.
*/
public Object clone() {
- // begin-user-code
// Create a new instance, copy contents, and return it
// create a new instance of Item and copy contents
@@ -1595,31 +1268,22 @@ public Object clone() {
item.copy(this);
return item;
- // end-user-code
-
}
/**
- *
- *
* This operation loads the SerializedItem from a Painfully Simple Form file
* format. If it is unable to load the InputStream or determines that the
* contents of the stream are not consistent with the PSF format, then it
* will throw an IOException. It delegates the actual work to a
* PainfullySimpleForm.
- *
- *
*
* @param inputStream
- *
* The InputStream that contains a PSF file.
- *
* @throws IOException
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
+ * This exception is thrown if there is a problem with the
+ * Inputstream.
*/
public void loadFromPSF(InputStream inputStream) throws IOException {
- // begin-user-code
// Local Declarations
InputStreamReader inputStreamReader = null;
@@ -1660,54 +1324,34 @@ public void loadFromPSF(InputStream inputStream) throws IOException {
throw new IOException(
"PSF cannot be loaded from a null InputStream!");
}
- // end-user-code
}
/**
- *
- *
* This operation returns true if the Item is already associated with a
* project space that it can use for storing and retrieving files. That is,
* it returns true if the non-nullary constructor was called or setProject()
* has been called.
- *
- *
*
- * @return
- * True if the Item has a project, false otherwise.
- *
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
+ * @return True if the Item has a project, false otherwise.
*/
public boolean hasProject() {
- // begin-user-code
// Return true if the Project is set
return (project != null);
- // end-user-code
}
/**
- *
- *
* This operation sets the project for the Item. It should only be called
* after the Item is constructed with its nullary constructor. Calling it
* after the Item has been running for a time could lead to unintended
* consequences.
- *
- *
*
* @param projectSpace
- *
* The Eclipse Platform IProject that should be referenced for
* project space information by this Item.
- *
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
public void setProject(IProject projectSpace) {
- // begin-user-code
// Set the project so long as it is not null
if (projectSpace != null) {
@@ -1719,24 +1363,15 @@ public void setProject(IProject projectSpace) {
// FIXME - SHOULD THIS ONLY BE ALLOWED TO BE CALLED ONCE??? ~JJB
// 20120502 14:01
- // end-user-code
}
/**
- *
- *
* This operation sets up a master list of Entries that are managed by the
* Item base class to handle dependencies and accelerate dependency
* checking. It is called by the non-nullary constructor and the loadFrom*
* operations. It also add the components to the Item's component map.
- *
* This operation adds a Component to the component map with the specified
* key (data, output or table). It is called by the visit() operations that
* the Item realizes to satisfy the IComponentVisitor interface.
- *
- *
*
* @param component
- *
* The Component to insert into the map of Components.
- *
* @param key
- *
* The key that identifies the type of the Component, equal to
* one of "data," "output" or "table."
- *
* This operation returns a list of files in the current project space with
* the given type or all of the files in the project space if no type is
* selected (type = null) if and only if the project space is available. If
* the project space is not available, it will return null.
- *
- *
*
* @param type
- *
* The file extension or type of the file that should be
* discovered in the project or null if all files should be
* returned by this operation.
- *
- * @return
- * The names of the files in the project space with the given type
+ * @return The names of the files in the project space with the given type
* or names of all of the files in the project space if no type is
* specified.
- *
* This operation directs the Item to reload data that it has read from its
* project. Calling this operation signifies to the Item that new files have
* been added or old files have been updated in the project.
- *
- *
+ *
* Calling this operation does not refresh the IProject.
- *
- *
+ *
* This operation is meant to be overridden by subclasses and customized. It
* does nothing on the base class.
- *
* This operation notifies the listeners of a change in the IProject,
* normally do to a newly created or deleted resource.
- *
- *
- *
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
protected void notifyListenersOfProjectChange() {
- // begin-user-code
// Notify all of the listeners that they should reload their project
// data because the project has been changed somehow.
@@ -1984,27 +1556,17 @@ protected void notifyListenersOfProjectChange() {
}
return;
- // end-user-code
}
/**
- *
- *
* This operation returns the Eclipse IFolder that points to the preferences
* directory for this Item. This operation will try to create the directory
* in the project if the project exists. It will return null if the project
* space doesn't exist or it can't create the directory.
- *
- *
*
- * @return
- * The directory where preferences should be stored.
- *
* This operation loads data into the Item from an input file. This
* operation should be overridden by subclasses and specialized for the
* correct behavior. The implementation on the base class does nothing.
- *
- *
+ *
* Subclasses that override this operation should make sure that a failed
* load does not result in a partially initialized or incorrect Form and an
* erroneous Item state.
- *
- *
+ *
* This operation expects that the file is in the workspace and only needs
* its name to find it.
- *
- *
*
* @param input
- *
* The file containing the input that should be loaded. It should
* be a file in the project space.
- *
* This operation updates the Item to let it know that a particular event
* has occurred in an ICE subsystem, remote ICE subsystem or external
* third-party process.
- *
- *
+ *
* The base class takes care of a small amount of worked related to
* messages, namely writing them to the process log, and subclasses should
* override this operation to specialize the behavior. Subclasses should
* still call the operation on the base class (via super.update(msg)) from
* their overridden operation so that the message can be properly logged.
- *
- *
*
* @param msg
- *
* The incoming Message.
- *
- * @return
- * True if the Item was able to respond to the Message, false
+ * @return True if the Item was able to respond to the Message, false
* otherwise.
- *
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
public boolean update(Message msg) {
- // begin-user-code
// Dump the text to stdout if we are in debugging mode.
if (debuggingEnabled) {
@@ -2431,28 +1968,18 @@ public boolean update(Message msg) {
// Just return true for now until the logging functionality can be moved
// from JobLauncher to Item.
return true;
- // end-user-code
}
/**
- *
- *
* This operation sets the Item's builderName. This operation can only be
* called once. Although this operation is public, it should only be called
* in the respective ItemBuilder class.
- *
- *
*
* @param builderName
- *
* The builderName to be set. Can not be null or the empty
* string.
- *
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
public void setItemBuilderName(String builderName) {
- // begin-user-code
// If the passed parameter is not null, not an empty string, and the
// builder name has not been set.
@@ -2463,76 +1990,43 @@ public void setItemBuilderName(String builderName) {
this.builderName = builderName;
}
- // end-user-code
}
/**
- *
- *
* This operation sets the Item's builderName. This operation can only be
* called once. Although this operation is public, it should only be called
* in the respective ItemBuilder class.
- *
- *
*
- * @return
- * Returns the builder name. This can be null.
- *
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
+ * @return Returns the builder name. This can be null.
*/
public String getItemBuilderName() {
- // begin-user-code
return this.builderName;
- // end-user-code
}
/**
- *
- *
* This operation disables the Item. Disabled Items will not accept changes
* to their Forms and they cannot be processed.
- *
- *
*
* @param state
- *
* True if the Item is disabled, false if not.
- *
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
public void disable(boolean state) {
- // begin-user-code
// Enable is the opposite of disabled.
enabled = !state;
- // end-user-code
}
/**
- *
- *
* True if the Item is enabled, false if it is disabled.
- *
- *
*
- * @return
- * True if the Item is enabled, false if not.
- *
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
+ * @return True if the Item is enabled, false if not.
*/
public boolean isEnabled() {
- // begin-user-code
return enabled;
- // end-user-code
}
/**
- *
- *
* This operation returns a file handle to the output file for the Item. It
* returns a handle to the file whether or not it actually exists and
* clients should check the File.exists() operation before attempting to
@@ -2542,17 +2036,10 @@ public boolean isEnabled() {
* to only read from the file. Nullerizing the file handle will not
* nullerize it in the Item. If the output file for the Item has not been
* configured, this operation will return null.
- *
- *
*
- * @return
- * The output file for this Item, thoroughly documented elsewhere.
- *
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
+ * @return The output file for this Item, thoroughly documented elsewhere.
*/
public File getOutputFile() {
- // begin-user-code
// Local Declarations
File copiedFileHandle = null;
@@ -2562,7 +2049,6 @@ public File getOutputFile() {
copiedFileHandle = new File(outputFile.toURI());
}
return copiedFileHandle;
- // end-user-code
}
/**
@@ -2589,134 +2075,98 @@ protected IActionFactory getActionFactory() {
* (non-Javadoc)
*
* @see IComponentVisitor#visit(DataComponent component)
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
public void visit(DataComponent component) {
- // begin-user-code
// Add the Component to the map of components
addComponentToMap(component, "data");
return;
- // end-user-code
}
/**
* (non-Javadoc)
*
* @see IComponentVisitor#visit(ResourceComponent component)
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
public void visit(ResourceComponent component) {
- // begin-user-code
// TODO Auto-generated method stub
- // end-user-code
}
/**
* (non-Javadoc)
*
* @see IComponentVisitor#visit(TableComponent component)
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
public void visit(TableComponent component) {
- // begin-user-code
// Add the Component to the map of components
addComponentToMap(component, "table");
return;
- // end-user-code
}
/**
* (non-Javadoc)
*
* @see IComponentVisitor#visit(MatrixComponent component)
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
public void visit(MatrixComponent component) {
- // begin-user-code
// TODO Auto-generated method stub
- // end-user-code
}
/**
* (non-Javadoc)
*
* @see IComponentVisitor#visit(IShape component)
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
public void visit(IShape component) {
- // begin-user-code
// TODO Auto-generated method stub
- // end-user-code
}
/**
* (non-Javadoc)
*
* @see IComponentVisitor#visit(GeometryComponent component)
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
public void visit(GeometryComponent component) {
- // begin-user-code
// TODO Auto-generated method stub
- // end-user-code
}
/**
* (non-Javadoc)
*
* @see IComponentVisitor#visit(MasterDetailsComponent component)
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
public void visit(MasterDetailsComponent component) {
- // begin-user-code
// TODO Auto-generated method stub
- // end-user-code
}
/**
* (non-Javadoc)
*
* @see IComponentVisitor#visit(TreeComposite component)
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
public void visit(TreeComposite component) {
- // begin-user-code
// TODO Auto-generated method stub
- // end-user-code
}
/**
* (non-Javadoc)
*
* @see IComponentVisitor#visit(IReactorComponent component)
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
public void visit(IReactorComponent component) {
- // begin-user-code
// TODO Auto-generated method stub
- // end-user-code
}
@Override
@@ -2731,14 +2181,10 @@ public void visit(TimeDataComponent component) {
* (non-Javadoc)
*
* @see IComponentVisitor#visit(MeshComponent component)
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
public void visit(MeshComponent component) {
- // begin-user-code
// TODO Auto-generated method stub
- // end-user-code
}
@Override
diff --git a/src/org.eclipse.ice.item/src/org/eclipse/ice/item/action/JobLaunchAction.java b/src/org.eclipse.ice.item/src/org/eclipse/ice/item/action/JobLaunchAction.java
index d382c38a6..fc7b42993 100644
--- a/src/org.eclipse.ice.item/src/org/eclipse/ice/item/action/JobLaunchAction.java
+++ b/src/org.eclipse.ice.item/src/org/eclipse/ice/item/action/JobLaunchAction.java
@@ -300,11 +300,9 @@
* The JobLaunchAction adds the working directory to the map with the key
* "workingDir".
*
- *
* The Action appends to the end of each output file listed in the map. It never
* overwrites these files.
- *
- *
+ *
* Additional parameters may be specified in the dictionary and the
* JobLaunchAction will replace them in the executable if required. For a key
* "v" in the dictionary, each instance of the search string "${v}" in the
@@ -315,11 +313,9 @@
* properly name files will result in a failure. Capitalization does not matter.
* The stdOutFile and stdErrFile are exceptions that are not transferred to
* remote machines.
- *
- *
+ *
* The cancel() operation attempts to kill the process if it is still running.
- *
- *
+ *
* This class launches the job on a separate thread. An AtomicReference is used
* for managing access to the Form information an the LoginInfoForm is used
* simply as an internal reference to the current Form within an operation. It
@@ -327,17 +323,13 @@
* and that a semicolon at the end of the line is acceptable to denote the end
* of a command. This assumption is valid on Windows, Linux and Unix systems so
* long as the Windows shell is Powershell.
- *
*
- *
- *
* @author Jay Jay Billings, Anna Wojtowicz
*/
public class JobLaunchAction extends Action implements Runnable {
/**
* The username with which to log into the remote system.
- *
*/
private String username;
diff --git a/src/org.eclipse.ice.item/src/org/eclipse/ice/item/model/AbstractModelBuilder.java b/src/org.eclipse.ice.item/src/org/eclipse/ice/item/model/AbstractModelBuilder.java
index d330ec859..469f072e3 100644
--- a/src/org.eclipse.ice.item/src/org/eclipse/ice/item/model/AbstractModelBuilder.java
+++ b/src/org.eclipse.ice.item/src/org/eclipse/ice/item/model/AbstractModelBuilder.java
@@ -20,18 +20,25 @@
* services for Models, which are Items that generate input files or data.
*
* @author Jay Jay Billings
- *
+ *
*/
public class AbstractModelBuilder extends AbstractItemBuilder {
+ /**
+ * The materials database that is available to the Model Item and provided,
+ * usually, by the OSGi Declarative Services Framework.
+ */
+ private IMaterialsDatabase materialsDatabase;
+
/**
* This operation sets the service reference for the IMaterialsDatabase
* service.
*
- * @param database the service
+ * @param database
+ * the service
*/
public void setMaterialsDatabase(IMaterialsDatabase database) {
-
+ materialsDatabase = database;
}
/*
@@ -43,7 +50,11 @@ public void setMaterialsDatabase(IMaterialsDatabase database) {
*/
@Override
protected void setServices(Item item) {
-
+ // Give the Item the IMaterialsDatabase service.
+ ((Model) item).setMaterialsDatabase(materialsDatabase);
+
+ // Let the base class set any other services.
+ super.setServices(item);
}
}
diff --git a/src/org.eclipse.ice.item/src/org/eclipse/ice/item/model/Model.java b/src/org.eclipse.ice.item/src/org/eclipse/ice/item/model/Model.java
index d980ea04e..834fe2574 100644
--- a/src/org.eclipse.ice.item/src/org/eclipse/ice/item/model/Model.java
+++ b/src/org.eclipse.ice.item/src/org/eclipse/ice/item/model/Model.java
@@ -12,48 +12,57 @@
*******************************************************************************/
package org.eclipse.ice.item.model;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-
-import org.eclipse.ice.datastructures.form.Form;
-import org.eclipse.ice.datastructures.form.FormStatus;
import org.eclipse.ice.item.Item;
+import org.eclipse.ice.materials.IMaterialsDatabase;
import org.eclipse.core.resources.IProject;
/**
- *
- *
* A Model in ICE contains all of the information necessary to describe a
* physical system that will be simulated.
- *
- *
*
* @author Jay Jay Billings
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
public class Model extends Item {
+
+ /**
+ * The materials database that is available to the Model Item and provided,
+ * usually, by the OSGi Declarative Services Framework.
+ */
+ private IMaterialsDatabase materialsDatabase;
+
/**
- *
- *
* The constructor.
- *
- *
*
* @param projectSpace
- *
* The Eclipse project where the Item should store files and from
* which they should be retrieved.
- *
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
public Model(IProject projectSpace) {
- // begin-user-code
-
// Call the super class constructor
super(projectSpace);
+ }
+
+ /**
+ * This operations sets the materials database service that should be used
+ * by the Model.
+ *
+ * @param materialDatabase
+ * The database
+ */
+ public void setMaterialsDatabase(IMaterialsDatabase database) {
+ System.out.println("Model Message: IMaterialsDatabase Registered!");
+ materialsDatabase = database;
+ }
- // end-user-code
+ /**
+ * This operation returns the materials database available to the Model
+ * without exposing the handle in a protected or public way that would allow
+ * it to be modified.
+ *
+ * @return the database
+ */
+ protected IMaterialsDatabase getMaterialsDatabase() {
+ return materialsDatabase;
}
+
}
\ No newline at end of file
diff --git a/src/org.eclipse.ice.item/src/org/eclipse/ice/item/nuclear/MOOSEModel.java b/src/org.eclipse.ice.item/src/org/eclipse/ice/item/nuclear/MOOSEModel.java
index 0905a38c9..706dff4be 100644
--- a/src/org.eclipse.ice.item/src/org/eclipse/ice/item/nuclear/MOOSEModel.java
+++ b/src/org.eclipse.ice.item/src/org/eclipse/ice/item/nuclear/MOOSEModel.java
@@ -118,6 +118,8 @@ public class MOOSEModel extends Item {
*/
@XmlTransient
protected String meshFileName;
+
+ private TreeComposite meshBlock;
/**
* An ArrayList of TreeComposites, constructed from the top-level children
@@ -252,6 +254,7 @@ protected void setupForm() {
// Add the default dummy text to the list of available apps
mooseApps = new ArrayList();
+ mooseApps.add("None");
// Get the list of MOOSE configuration files available to ICE, if
// possible, before creating the app Entry.
@@ -284,11 +287,8 @@ protected void setupForm() {
// Only load up the Entry if some MOOSE apps were discovered.
if (!mooseApps.isEmpty()) {
- // Set the default as null, which will default to "MOOSE app..."
- // from the Entry's list of allowed values when Entry.getValue() is
- // called. This is done intentionally to force the user to select an
- // app when importing an Item
- loadedApp = null;
+ // Set the default to "none", forcing the user to make a selection.
+ loadedApp = mooseApps.get(0);
// Create the MOOSE application Entry. Add all of the files if any
// were found.
mooseAppEntry = new Entry() {
@@ -451,6 +451,8 @@ protected FormStatus reviewEntries(Form preparedForm) {
// Get the MOOSE file information, if available
mooseFileComponent = (DataComponent) preparedForm.getComponent(1);
if (mooseFileComponent != null) {
+
+ // Get the entry that stores the currently-selected MOOSE app name
Entry mooseSpecFileEntry = mooseFileComponent
.retrieveEntry("MOOSE-Based Application");
@@ -458,8 +460,11 @@ protected FormStatus reviewEntries(Form preparedForm) {
// currently loaded.
if (mooseSpecFileEntry != null) {
- if (loadedApp == null
- || !loadedApp.equals(mooseSpecFileEntry.getValue())) {
+ // Get the current value of the MOOSE app Entry and determine
+ String mooseSpecValue = mooseSpecFileEntry.getValue();
+ if (loadedApp == null ||
+ (!mooseSpecValue.equalsIgnoreCase("none")
+ && !loadedApp.equals(mooseSpecValue))) {
// Get the app name
loadedApp = mooseSpecFileEntry.getValue();
@@ -1368,14 +1373,16 @@ private ICEResource createMeshResource() throws IOException {
ICEResource mesh = null;
// Try to find the Mesh block on the TreeComposite
- TreeComposite meshTree = findMeshBlock();
+ if (meshBlock == null) {
+ meshBlock = findMeshBlock();
+ }
- if (meshTree != null) {
+ if (meshBlock != null) {
// Try to find the Entry with the mesh filename
- DataComponent meshBlock = (DataComponent) meshTree.getDataNodes()
- .get(0);
- Entry meshEntry = meshBlock.retrieveEntry("file");
+ DataComponent meshDataComp =
+ (DataComponent) meshBlock.getDataNodes().get(0);
+ Entry meshEntry = meshDataComp.retrieveEntry("file");
if (meshEntry != null) {
// Convert the Mesh entry to a File Entry
@@ -1392,8 +1399,8 @@ private ICEResource createMeshResource() throws IOException {
}
/**
- * This method convert the mesh "file" Entry into a File Entry and registers
- * the Form as a listener.
+ * This method convert the mesh "file" Entry into a Entry with
+ * AllowedValueType.File and registers the Form as a listener.
*
* @param meshEntry
* The "file" Entry on the Mesh TreeComposite
@@ -1512,18 +1519,28 @@ private void setAdaptiveType(AdaptiveTreeComposite tree) {
// Try setting the type
if (typeName != null && !typeName.isEmpty() && tree.setType(typeName)) {
- } else if (tree.getName().equals("Mesh") && fileEntry != null
- && fileEntry.getValue() != null && !fileEntry.getValue().isEmpty()) {
+ } else if (tree.getName().equals("Mesh")
+ && fileEntry != null && fileEntry.getValue() != null
+ && !fileEntry.getValue().isEmpty()) {
// Otherwise try setting the Mesh type "FileMesh", if appropriate
tree.setType("FileMesh");
}
+
+ // Lastly, if this is the Mesh block, set a listener on its type
+ if (tree.getName().equals("Mesh")) {
+ tree.register(this);
+ }
return;
}
/**
- * This method is intended primarily to update the ResourceComponet with a
- * new VizResource if the Mesh block's "file" Entry has changed.
+ * This method updates the ResourceComponet with a new VizResource if the
+ * Mesh block's "file" Entry has changed. It is also used to correctly
+ * display the "file" Entry as commented/uncommented depending on the Mesh
+ * block's currently set type. Lastly, it will listen to updates from the
+ * Mesh's active data node in case a new "file" Entry is ever manually
+ * added (in which case it will register the new Entry with the form).
*
* @param component
* The component that triggered an update
@@ -1533,26 +1550,99 @@ public void update(IUpdateable component) {
// If the mesh file name is different, update the ResourceComponent and
// the Mesh block type
- if (component instanceof Entry
- && (meshFileName == null || meshFileName.isEmpty() ||
- !((Entry) component).getValue().equals(meshFileName))) {
- try {
- // Update the mesh resource
- updateMeshResource();
+ if (component instanceof Entry) {
+
+ Entry fileEntry = (Entry) component;
+ if (meshFileName == null || meshFileName.isEmpty()
+ || !fileEntry.getValue().equals(meshFileName)) {
+ try {
+ // Update the mesh resource
+ updateMeshResource();
+
+ // Also change the file type on the Mesh block to "FileEntry"
+ if (meshBlock == null ) {
+ meshBlock = (AdaptiveTreeComposite) findMeshBlock();
+ }
+ DataComponent meshDataComp =
+ (DataComponent) meshBlock.getActiveDataNode();
+ if (meshDataComp != null
+ && meshDataComp.retrieveEntry("file") != null) {
+ String meshFileName =
+ meshDataComp.retrieveEntry("file").getValue();
+ if (!meshFileName.isEmpty()
+ && ((AdaptiveTreeComposite) meshBlock).getType() == null) {
+ ((AdaptiveTreeComposite) meshBlock).setType("FileMesh");
+ }
+ }
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ // If the Mesh type has changed, evaluate if the "file" parameter should
+ // be commented/uncommented
+ } else if (component instanceof AdaptiveTreeComposite
+ && component.getName().equals("Mesh")) {
+
+ AdaptiveTreeComposite meshBlock = (AdaptiveTreeComposite) component;
+ if (meshBlock.getActiveDataNode() != null) {
+
+ // Get the "file" Entry/parameter
+ DataComponent dataComp =
+ (DataComponent) meshBlock.getActiveDataNode();
+ Entry fileParam = dataComp.retrieveEntry("file");
+
+ if (fileParam != null) {
+
+ // Get the type and tag
+ String type = meshBlock.getType();
+ String fileTag = fileParam.getTag();
- // Also change the file type on the Mesh block to "FileEntry"
- TreeComposite meshBlock = findMeshBlock();
- DataComponent meshDataComp = (DataComponent) meshBlock.getActiveDataNode();
- if (meshDataComp != null && meshDataComp.contains("file")) {
- String meshFileName =
- meshDataComp.retrieveEntry("file").getValue();
- if (!meshFileName.isEmpty()) {
- ((AdaptiveTreeComposite) meshBlock).setType("FileMesh");
+ // Set the tag and required flag correctly
+ if (!type.equals("FileMesh")
+ && (fileTag.equalsIgnoreCase("true"))
+ || fileTag.equalsIgnoreCase("new_parameter")) {
+ // Comment out the "file" parameter
+ fileParam.setTag("false");
+ fileParam.setRequired(false);
+ } else if (type.equals("FileMesh")
+ && fileTag.equalsIgnoreCase("false")) {
+ // Enable the "file" parameter
+ fileParam.setTag("true");
+ fileParam.setRequired(true);
+ } else if (!type.equals("FileMesh")) {
+ fileParam.setRequired(false);
+ } else {
+ fileParam.setRequired(true);
}
}
+ }
+
+ // If a "file" Entry is added, make sure everything is hooked up
+ // correctly to the mesh
+ } else if (component instanceof DataComponent) {
+
+ DataComponent dataComp = (DataComponent) component;
+ if (dataComp.retrieveEntry("file") != null) {
- } catch (IOException e) {
- e.printStackTrace();
+ Entry fileEntry = dataComp.retrieveEntry("file");
+ if (!fileEntry.getValue().isEmpty()) {
+
+ // Re-register the fileEntry in case this "file" parameter
+ // parameter was created after the tree was set up
+ fileEntry.unregister(this);
+ fileEntry.register(this);
+
+ // Try updating the Mesh block so the file parameter will
+ // be set correctly depending on the current block type
+ if (meshBlock == null) {
+ meshBlock = findMeshBlock();
+ }
+ if (meshBlock != null) {
+ update(meshBlock);
+ }
+ }
}
}
diff --git a/src/org.eclipse.ice.item/src/org/eclipse/ice/item/utilities/moose/Block.java b/src/org.eclipse.ice.item/src/org/eclipse/ice/item/utilities/moose/Block.java
index e16a8047d..73c1d0881 100644
--- a/src/org.eclipse.ice.item/src/org/eclipse/ice/item/utilities/moose/Block.java
+++ b/src/org.eclipse.ice.item/src/org/eclipse/ice/item/utilities/moose/Block.java
@@ -351,23 +351,28 @@ public void loadFromMap(Map map) {
* commented out.
*
* @param prefix
- *
- * The prefix for the name of the block. This is most commonly
- * null or the actual section prefix (Block.actualSectionPrefix).
- * If the prefix is not equal to Block.actualSectionPrefix, it
- * will be replaced with an empty string.
- *
- *
- * The prefix is used in GetPot to note the relationship of a
- * section with its parent. In MOOSE it is either null or equal
- * to the actual prefix. In the latter case the section is always
- * closed by the parent section prefix
- * (Block.parentSectionPrefix). These are "./" and "../" for
- * MOOSE, respectively and without the quotation marks.
- *
+ *
+ * The prefix for the name of the block. This is most commonly
+ * null or the actual section prefix (Block.actualSectionPrefix).
+ * If the prefix is not equal to Block.actualSectionPrefix, it
+ * will be replaced with an empty string.
+ *
+ *
+ * The prefix is used in GetPot to note the relationship of a
+ * section with its parent. In MOOSE it is either null or equal
+ * to the actual prefix. In the latter case the section is always
+ * closed by the parent section prefix
+ * (Block.parentSectionPrefix). These are "./" and "../" for
+ * MOOSE, respectively and without the quotation marks.
+ *
+ * @param writeInactiveBlocks
+ * This flag determines if inactive blocks should still be
+ * written out to the GetPot string, but commented out (with a
+ * ("#" in front). By default, all subblocks have this behavior
+ * set to true.
* @return The GetPot representation of this Block.
*/
- public String toGetPot(String prefix) {
+ public String toGetPot(String prefix, boolean writeInactiveBlocks) {
// Local Declarations
String realPrefix = (prefix != null) ? prefix : "";
@@ -376,17 +381,19 @@ public String toGetPot(String prefix) {
: name;
String closingSection = (realPrefix.equals(Block.actualSectionPrefix)) ? parentSectionPrefix
: "";
- String potString = "", commentString = "", whiteSpaceString = "", hash = "";
+ String potString = "", commentString = "", whiteSpaceString = "";
boolean hasComment = false;
// Fix the indentation
indent += (realPrefix.equals(actualSectionPrefix)) ? " " : "";
- // Only write the block if it is active!
- if (isActive()) {
+ // Only write the block if it is active! (or the inactive writing flag is true)
+ if (active || writeInactiveBlocks) {
// Open the section
- potString = indent + "[" + openingSection + "]";
+ potString = (!active && writeInactiveBlocks) ?
+ indent.substring(0, indent.length()-2) + "# [" + openingSection + "]" :
+ indent + "[" + openingSection + "]";
// Check if this section block has a comment, if it does, append it
hasComment = !comment.isEmpty();
@@ -417,10 +424,15 @@ public String toGetPot(String prefix) {
replaceAll("[\n\r]", "");
// Append the line
whiteSpaceString = makeWhiteSpaceString(indent + " " + param.toString());
- potString += String.format("%s %s%s# %s\n",
- indent, param.toString(), whiteSpaceString,commentString);
+ potString += (!active && writeInactiveBlocks) ?
+ String.format("%s# %s%s# %s\n",
+ indent, param.toString(), whiteSpaceString,commentString) :
+ String.format("%s %s%s# %s\n",
+ indent, param.toString(), whiteSpaceString,commentString) ;
} else {
- potString += indent + " " + param.toString() + "\n";
+ potString += (!active && writeInactiveBlocks) ?
+ indent + "# " + param.toString() + "\n" :
+ indent + " " + param.toString() + "\n";
}
}
// If the parameter is not explicitly required, check if it
@@ -432,12 +444,18 @@ else if (param.isEnabled()) {
replaceAll("[\n\r]", "");
// Append the line
whiteSpaceString = makeWhiteSpaceString(indent + " " + param.toString());
- potString += String.format("%s %s%s# %s\n",
- indent, param.toString(), whiteSpaceString, commentString);
+ potString += (!active) ?
+ String.format("%s# %s%s# %s\n",
+ indent, param.toString(), whiteSpaceString, commentString) :
+ String.format("%s %s%s# %s\n",
+ indent, param.toString(), whiteSpaceString, commentString);
} else {
- potString += indent + " " + param.toString() + "\n";
+ potString += (!active) ?
+ indent + "# " + param.toString() + "\n" :
+ indent + " " + param.toString() + "\n";
}
}
+ // Otherwise, the parameter will be commented out
else {
if (hasComment) {
// Remove newline characters from comment
@@ -459,12 +477,14 @@ else if (param.isEnabled()) {
for (int i = 0; i < subblocks.size(); i++) {
Block block = subblocks.get(i);
potString += block.toGetPot(Block.actualSectionPrefix,
- indent);
+ indent, true);
}
}
// Close the section
- potString += indent + "[" + closingSection + "]\n";
+ potString += (!active && writeInactiveBlocks) ?
+ indent.substring(0, indent.length()-2) + "# [" + closingSection + "]\n":
+ indent + "[" + closingSection + "]\n";
}
@@ -473,39 +493,29 @@ else if (param.isEnabled()) {
return potString;
}
-
+
/**
- * This is a utility method that will construct and return a String of
- * whitespaces, depending on the length of the current line. This is used
- * by the toGetPot() method when appending comments, to try to make comments
- * align in columns for neatness' sake.
+ * This method is the same as calling {@code toGetPot(prefix, false)}.
*
- * @param getPotLine Current line that the comment will be appended to
- * @return A string of whitespace characters that will separate
- * the current line's text from its comment
+ * @param prefix
+ *
+ * The prefix for the name of the block. This is most commonly
+ * null or the actual section prefix (Block.actualSectionPrefix).
+ * If the prefix is not equal to Block.actualSectionPrefix, it
+ * will be replaced with an empty string.
+ *
+ *
+ * The prefix is used in GetPot to note the relationship of a
+ * section with its parent. In MOOSE it is either null or equal
+ * to the actual prefix. In the latter case the section is always
+ * closed by the parent section prefix
+ * (Block.parentSectionPrefix). These are "./" and "../" for
+ * MOOSE, respectively and without the quotation marks.
+ *
This class is responsible for testing the ItemProcessor class.
- *
+/**
+ * This class is responsible for testing the ItemProcessor class.
+ *
* @author Jay Jay Billings
- * @generated "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
public class ItemProcessorTester {
- /**
- *
- *
The ItemProcessor to test.
- *
- * @generated "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
+ /**
+ * The ItemProcessor to test.
*/
private ItemProcessor itemProcessor;
- /**
- *
- *
This operation checks the accessor operations of the ItemProcessor class.
- *
- * @generated "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
+ /**
+ * This operation checks the accessor operations of the ItemProcessor class.
*/
@Test
public void checkAccessors() {
- // begin-user-code
// Allocate the ItemProcessor
itemProcessor = new ItemProcessor();
@@ -111,14 +102,13 @@ public void checkAccessors() {
assertEquals(100, itemProcessor.getPollTime());
return;
- // end-user-code
}
- /**
- *
- *
This operation checks the ItemProcessor to make sure that it can properly process an Item. It resets the polling time to 50ms and waits for 75ms on the thread to make sure that setting the polling time actually affects the thread.
- *
- * @generated "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
+ /**
+ * This operation checks the ItemProcessor to make sure that it can properly
+ * process an Item. It resets the polling time to 50ms and waits for 75ms on
+ * the thread to make sure that setting the polling time actually affects
+ * the thread.
*/
@Test
public void checkProcessing() {
@@ -136,7 +126,7 @@ public void checkProcessing() {
// Put a dummy form on the widget
formWidget.setForm(new Form());
-
+
// Allocate the ItemProcessor
itemProcessor = new ItemProcessor();
@@ -172,8 +162,8 @@ public void checkProcessing() {
// Check the process status with the core to make sure the event was
// processed.
- assertEquals(FormStatus.Processed, core.getLastProcessStatus());
-
+ assertEquals(FormStatus.Processed, core.getLastProcessStatus());
+
// Reset the FakeCore's Process state
core.reset();
@@ -221,7 +211,8 @@ public void checkProcessing() {
// Make sure the Form was resubmitted to the core
assertTrue(core.itemUpdated());
- // Check that the label was set. It should be set before being displayed.
+ // Check that the label was set. It should be set before being
+ // displayed.
assertTrue(textWidget.labelSet());
// Check that the streaming text widget was displayed
assertTrue(textWidget.widgetDisplayed());
@@ -246,7 +237,7 @@ public void checkProcessing() {
// Check the process status to make sure the client made the call
assertTrue(core.wasCancelled());
-
+
return;
// end-user-code
}
diff --git a/tests/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/ListComponentTester.java b/tests/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/ListComponentTester.java
index 1c0a0e382..1b32b3703 100644
--- a/tests/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/ListComponentTester.java
+++ b/tests/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/ListComponentTester.java
@@ -32,6 +32,8 @@
import org.junit.*;
import ca.odell.glazedlists.EventList;
+import ca.odell.glazedlists.event.ListEvent;
+import ca.odell.glazedlists.event.ListEventListener;
import ca.odell.glazedlists.gui.TableFormat;
import ca.odell.glazedlists.gui.WritableTableFormat;
@@ -47,13 +49,19 @@
* @author Jay Jay Billings
*/
public class ListComponentTester implements IElementSource,
- WritableTableFormat {
+ WritableTableFormat, ListEventListener {
/**
* A flag to mark whether or not visitation worked.
*/
boolean visited = false;
+ /**
+ * True if the test was notified via the GlazedLists ListEventListener
+ * interface instead of the ICE interface.
+ */
+ private volatile boolean notified = false;
+
/**
* This operation checks the ListComponent to insure that the id, name and
* description getters and setters function properly.
@@ -397,8 +405,7 @@ public void checkNotifications() {
component.add("fred");
// Make sure the listener was notified
assertTrue(firstListener.wasNotified());
-
-
+
return;
}
@@ -557,4 +564,11 @@ public Integer setColumnValue(Integer baseObject, Object editedValue,
return 4;
}
+ @Override
+ public void listChanged(ListEvent listChanges) {
+ System.out.println("ListComponentTester Message: "
+ + "ListEventListener callback executed.");
+ notified = true;
+ }
+
}
diff --git a/tests/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/MaterialTester.java b/tests/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/MaterialTester.java
index b51b05f56..2fe78f979 100644
--- a/tests/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/MaterialTester.java
+++ b/tests/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/MaterialTester.java
@@ -67,6 +67,9 @@ public void checkSimpleAttributes() {
assertTrue(properties.containsKey("molar mass (g/mol)"));
assertTrue(properties.containsKey("vapor pressure (MPa)"));
+ // Make sure that requesting a property that isn't in the map returns 0.0.
+ assertEquals(0.0,testMaterial.getProperty("penguin"),1.0e-8);
+
return;
}
diff --git a/tests/org.eclipse.ice.io.test/META-INF/MANIFEST.MF b/tests/org.eclipse.ice.io.test/META-INF/MANIFEST.MF
index 87ba48573..33f602da0 100644
--- a/tests/org.eclipse.ice.io.test/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.ice.io.test/META-INF/MANIFEST.MF
@@ -7,4 +7,5 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Fragment-Host: org.eclipse.ice.io;bundle-version="1.0.0"
Require-Bundle: org.eclipse.ice.reactor;bundle-version="2.0.0",
org.junit;bundle-version="4.8.2"
-Import-Package: org.junit;version="4.11.0"
+Import-Package: org.eclipse.ice.datastructures.form,
+ org.junit;version="4.11.0"
diff --git a/tests/org.eclipse.ice.io.test/src/org/eclipse/ice/io/csv/test/CSVReaderTester.java b/tests/org.eclipse.ice.io.test/src/org/eclipse/ice/io/csv/test/CSVReaderTester.java
new file mode 100644
index 000000000..a146d876e
--- /dev/null
+++ b/tests/org.eclipse.ice.io.test/src/org/eclipse/ice/io/csv/test/CSVReaderTester.java
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+package org.eclipse.ice.io.csv.test;
+
+import static org.junit.Assert.*;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.ice.datastructures.ICEObject.ListComponent;
+import org.eclipse.ice.datastructures.form.Form;
+import org.eclipse.ice.io.csv.CSVReader;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.IOException;
+
+/**
+ * Test class for {@link org.eclipse.ice.io.csv.CSVReader}.
+ *
+ * @author Jay Jay Billings
+ *
+ */
+public class CSVReaderTester {
+
+ /**
+ * The CSV file that will be tested
+ */
+ private static IFile testFile;
+ /**
+ * The reader that will be tested.
+ */
+ private static CSVReader reader;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ // Get the file separator used on this system, which is different across
+ // OSes.
+ String separator = System.getProperty("file.separator");
+ // Create the path for the reflectivity file in the ICE tests directory
+ String userHome = System.getProperty("user.home");
+ IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+ IProject project = null;
+ String projectName = "CSVLoaderTesterWorkspace";
+ String filename = "getSpecRefSqrdMod_q841.csv";
+ IPath projectPath = new Path(userHome + separator + "ICETests"
+ + separator + projectName + separator + ".project");
+
+ // Setup the project
+ try {
+ // Create the project description
+ IProjectDescription desc = ResourcesPlugin.getWorkspace()
+ .loadProjectDescription(projectPath);
+ // Get the project handle and create it
+ project = workspaceRoot.getProject(desc.getName());
+ project.create(desc, new NullProgressMonitor());
+ // Open the project if it is not already open
+ if (project.exists() && !project.isOpen()) {
+ project.open(new NullProgressMonitor());
+ }
+ // Refresh the workspace
+ project.refreshLocal(IResource.DEPTH_INFINITE,
+ new NullProgressMonitor());
+ // Create the IFile handle for the csv file
+ testFile = project.getFile(filename);
+ } catch (CoreException e) {
+ // Catch exception for creating the project
+ e.printStackTrace();
+ fail();
+ }
+
+ // Create the reader
+ reader = new CSVReader();
+
+ return;
+ }
+
+ /**
+ * Test method for
+ * {@link org.eclipse.ice.io.csv.CSVReader#read(org.eclipse.core.resources.IFile)}
+ * .
+ *
+ * @throws CoreException
+ * @throws IOException
+ */
+ @Test
+ public void testRead() throws CoreException, IOException {
+
+ // Load the file
+ Form form = reader.read(testFile);
+
+ // Check the Form
+ assertTrue(form.getComponents().get(0) instanceof ListComponent);
+ ListComponent lines = (ListComponent) form
+ .getComponents().get(0);
+ assertTrue(lines.get(0) instanceof String[]);
+ assertEquals(lines.size(), 175);
+
+ // Check the first element of the list. The first line of the file is a
+ // comment, so it should be skipped and this should be data.
+ String [] line = lines.get(0);
+ assertEquals(3,line.length);
+ assertEquals("0.00740898494001999",line[0]);
+ assertEquals("4.25",line[1]);
+ assertEquals("0.999852520984978",line[2]);
+
+ // Check the last element of the list
+ line = lines.get(lines.size()-1);
+ assertEquals(4,line.length);
+ assertEquals("2.0700000000E-06",line[0]);
+ assertEquals("4.7498147887E-11",line[1]);
+ assertEquals("1.9976998807E-12",line[2]);
+ assertEquals("1.0000000000E+02",line[3]);
+
+ return;
+ }
+
+ /**
+ * Test method for
+ * {@link org.eclipse.ice.io.csv.CSVReader#findAll(org.eclipse.core.resources.IFile, java.lang.String)}
+ * .
+ */
+// @Test
+ public void testFindAll() {
+ fail("Not yet implemented");
+ }
+
+ /**
+ * Test method for {@link org.eclipse.ice.io.csv.CSVReader#getReaderType()}.
+ */
+ @Test
+ public void testGetReaderType() {
+ assertEquals("csv", reader.getReaderType());
+ }
+
+}
diff --git a/tests/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/AbstractItemBuilderTester.java b/tests/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/AbstractItemBuilderTester.java
index 70577d524..5afbc97f2 100644
--- a/tests/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/AbstractItemBuilderTester.java
+++ b/tests/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/AbstractItemBuilderTester.java
@@ -82,6 +82,9 @@ public void testBuild() {
// Check the fake
IActionFactory returnedFactory = ((TestJobLauncher) item).getActionFactoryForTest();
assertNotNull(returnedFactory);
+
+ // Check that setupFormWithServices was called
+ assertTrue(((TestJobLauncher) item).setupFormWithServicesWasCalled());
}
diff --git a/tests/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/AbstractModelBuilderTester.java b/tests/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/AbstractModelBuilderTester.java
new file mode 100644
index 000000000..5272c10d4
--- /dev/null
+++ b/tests/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/AbstractModelBuilderTester.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+package org.eclipse.ice.item.test;
+
+import static org.junit.Assert.*;
+
+import org.eclipse.ice.item.IActionFactory;
+import org.eclipse.ice.item.ItemBuilder;
+import org.eclipse.ice.item.model.AbstractModelBuilder;
+import org.eclipse.ice.materials.IMaterialsDatabase;
+import org.junit.Test;
+
+/**
+ * This class tests the Model class. Its only test is that the
+ * IMaterialsDatabase is set as a service, which it checks using a
+ * FakeModelBuilder that overrides setInstance to create a FakeModel that
+ * returns the database. The IMaterialsDatabase is implemented by a fake as
+ * well.
+ *
+ * This strategy is OK because the only thing that needs to be tested is that
+ * the AbstractModel.setServices() operation is correctly implemented, which is
+ * not affected by overriding AbstractModelBuilder.getInstance().
+ *
+ * @author Jay Jay Billings
+ *
+ */
+public class AbstractModelBuilderTester {
+
+ /**
+ * Test method for
+ * {@link org.eclipse.ice.item.model.AbstractModelBuilder#setMaterialsDatabase(org.eclipse.ice.materials.IMaterialsDatabase)}
+ * .
+ */
+ @Test
+ public void testSetMaterialsDatabase() {
+ // Create a fake database service and a fake action factory
+ IMaterialsDatabase fakeService = new FakeMaterialsDatabase();
+ IActionFactory factory = new FakeActionFactory();
+
+ // Create a fake model and set the service
+ AbstractModelBuilder builder = new FakeModelBuilder();
+ builder.setActionFactory(factory);
+ builder.setMaterialsDatabase(fakeService);
+ FakeModel model = ((FakeModel) builder.build(null));
+
+ // Make sure the database service was set
+ assertNotNull(model.getMaterialsDatabaseForTest());
+ assertNotNull(model.getActionFactoryForTest());
+
+ return;
+ }
+
+}
diff --git a/tests/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/FakeMaterialsDatabase.java b/tests/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/FakeMaterialsDatabase.java
new file mode 100644
index 000000000..2deeb1d6a
--- /dev/null
+++ b/tests/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/FakeMaterialsDatabase.java
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+package org.eclipse.ice.item.test;
+
+import java.util.List;
+
+import org.eclipse.ice.datastructures.form.Material;
+import org.eclipse.ice.materials.IMaterialsDatabase;
+
+import ca.odell.glazedlists.EventList;
+import ca.odell.glazedlists.gui.TableFormat;
+
+/**
+ * A fake implementation of the IMaterialsDatabase used for testing.
+ *
+ * @author Jay Jay Billings
+ *
+ */
+public class FakeMaterialsDatabase implements IMaterialsDatabase {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ice.materials.IMaterialsDatabase#getMaterials()
+ */
+ @Override
+ public List getMaterials() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ice.materials.IMaterialsDatabase#addMaterial(org.eclipse.
+ * ice.datastructures.form.Material)
+ */
+ @Override
+ public void addMaterial(Material material) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ice.materials.IMaterialsDatabase#deleteMaterial(java.lang
+ * .String)
+ */
+ @Override
+ public void deleteMaterial(String name) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ice.materials.IMaterialsDatabase#deleteMaterial(org.eclipse
+ * .ice.datastructures.form.Material)
+ */
+ @Override
+ public void deleteMaterial(Material material) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ice.materials.IMaterialsDatabase#updateMaterial(org.eclipse
+ * .ice.datastructures.form.Material)
+ */
+ @Override
+ public void updateMaterial(Material material) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ice.materials.IMaterialsDatabase#restoreDefaults()
+ */
+ @Override
+ public void restoreDefaults() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public EventList getElements() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public TableFormat getTableFormat() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/tests/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/FakeModel.java b/tests/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/FakeModel.java
new file mode 100644
index 000000000..821128c01
--- /dev/null
+++ b/tests/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/FakeModel.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+package org.eclipse.ice.item.test;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.ice.item.IActionFactory;
+import org.eclipse.ice.item.model.Model;
+import org.eclipse.ice.materials.IMaterialsDatabase;
+
+/**
+ * This is a fake subclass of Model that returns the IMaterialsDatabase so it
+ * can be used to verify that the AbstractModelBuilder set the service
+ * correctly.
+ *
+ * @author Jay Jay Billings
+ *
+ */
+public class FakeModel extends Model {
+
+ /**
+ * The Constructor
+ * @param projectSpace
+ */
+ public FakeModel(IProject projectSpace) {
+ super(projectSpace);
+ }
+
+ /**
+ * This operation returns the materials database
+ * @return the materials database
+ */
+ public IMaterialsDatabase getMaterialsDatabaseForTest() {
+ return getMaterialsDatabase();
+ }
+
+ /**
+ * This operation returns the action factory
+ * @return the action factory
+ */
+ public IActionFactory getActionFactoryForTest() {
+ return getActionFactory();
+ }
+
+}
diff --git a/tests/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/FakeModelBuilder.java b/tests/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/FakeModelBuilder.java
new file mode 100644
index 000000000..c7b6612b6
--- /dev/null
+++ b/tests/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/FakeModelBuilder.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+package org.eclipse.ice.item.test;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.ice.item.Item;
+import org.eclipse.ice.item.ItemType;
+import org.eclipse.ice.item.model.AbstractModelBuilder;
+
+/**
+ * This is a fake model builder that provides a fake model class that will
+ * return the service reference to the materials database and the action factory
+ * to make sure the overridden AbstractModelBuilder.setServices works.
+ *
+ * @author Jay Jay Billings
+ *
+ */
+public class FakeModelBuilder extends AbstractModelBuilder {
+
+ /**
+ * The constructor
+ */
+ public FakeModelBuilder() {
+ setName("Eyes on Fire");
+ setType(ItemType.AnalysisSession);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ice.item.AbstractItemBuilder#getInstance(org.eclipse.core.resources.IProject)
+ */
+ @Override
+ protected Item getInstance(IProject projectSpace) {
+ return new FakeModel(projectSpace);
+ }
+}
diff --git a/tests/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/TestJobLauncher.java b/tests/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/TestJobLauncher.java
index ae181a2cb..955294e56 100644
--- a/tests/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/TestJobLauncher.java
+++ b/tests/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/TestJobLauncher.java
@@ -32,6 +32,11 @@
*/
public class TestJobLauncher extends JobLauncher {
+ /**
+ * True if the setupFormWithServices() operation was called, false otherwise.
+ */
+ boolean setupAfterServices = false;
+
/**
* The Constructor
*
@@ -70,5 +75,25 @@ protected void setupForm() {
public IActionFactory getActionFactoryForTest() {
return getActionFactory();
}
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ice.item.Item#setupFormWithServices()
+ */
+ public void setupFormWithServices() {
+ setupAfterServices = true;
+ }
+ /**
+ * This operation describes whether or not the setupFormWithServices
+ * operation was called after the Item was constructed. It is used by the
+ * tests to make sure that the AbstractItemBuilder builds the Item properly.
+ *
+ * @return True if the setupFormWithServices operation was called, false
+ * otherwise.
+ */
+ public boolean setupFormWithServicesWasCalled() {
+ return setupAfterServices;
+ }
+
}
\ No newline at end of file
diff --git a/tests/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/nuclear/MOOSEModelTester.java b/tests/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/nuclear/MOOSEModelTester.java
index 61285ef8c..8c633278f 100644
--- a/tests/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/nuclear/MOOSEModelTester.java
+++ b/tests/org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/nuclear/MOOSEModelTester.java
@@ -177,8 +177,7 @@ public void checkConstruction() {
.retrieveEntry("MOOSE-Based Application");
assertNotNull(mooseAppEntry);
assertEquals(1, mooseAppEntry.getId());
- assertEquals("No MOOSE apps were found.",
- mooseAppEntry.getDefaultValue());
+ assertEquals("None", mooseAppEntry.getDefaultValue());
assertEquals(mooseAppEntry.getDefaultValue(), mooseAppEntry.getValue());
// Check the output file Entry
diff --git a/tests/org.eclipse.ice.materials.test/META-INF/MANIFEST.MF b/tests/org.eclipse.ice.materials.test/META-INF/MANIFEST.MF
index 3a2edd7cb..8c0b83457 100644
--- a/tests/org.eclipse.ice.materials.test/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.ice.materials.test/META-INF/MANIFEST.MF
@@ -6,4 +6,5 @@ Bundle-Version: 2.0.0
Fragment-Host: org.eclipse.ice.materials;bundle-version="2.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Require-Bundle: org.junit
-Import-Package: org.eclipse.ice.datastructures.ICEObject
+Import-Package: ca.odell.glazedlists.gui,
+ org.eclipse.ice.datastructures.ICEObject
diff --git a/tests/org.eclipse.ice.materials.test/src/org/eclipse/ice/materials/test/MaterialWritableTableFormatTester.java b/tests/org.eclipse.ice.materials.test/src/org/eclipse/ice/materials/test/MaterialWritableTableFormatTester.java
new file mode 100644
index 000000000..045002c37
--- /dev/null
+++ b/tests/org.eclipse.ice.materials.test/src/org/eclipse/ice/materials/test/MaterialWritableTableFormatTester.java
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 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
+ *******************************************************************************/
+package org.eclipse.ice.materials.test;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.ice.datastructures.form.Material;
+import org.eclipse.ice.materials.MaterialWritableTableFormat;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * This class is responsible for testing {@link MaterialWritableTableFormat}.
+ *
+ * @author Jay Jay Billings
+ *
+ */
+public class MaterialWritableTableFormatTester {
+
+ /**
+ * The column names to use for the test
+ */
+ private static ArrayList columnNames;
+
+ /**
+ * The test material
+ */
+ private static Material material;
+
+ /**
+ * The table format to test
+ */
+ private static MaterialWritableTableFormat tableFormat;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+
+ // Create the Material for the test
+ material = new Material();
+ material.setName("Fluffy");
+ material.setProperty("A", 1.0);
+ material.setProperty("B", 2.0);
+
+ // Store the property names
+ columnNames = new ArrayList();
+ columnNames.addAll(material.getProperties().keySet());
+
+ // Create the table format
+ tableFormat = new MaterialWritableTableFormat(columnNames);
+
+ return;
+ }
+
+ /**
+ * Test method for
+ * {@link org.eclipse.ice.materials.MaterialWritableTableFormat#getColumnCount()}
+ * .
+ */
+ @Test
+ public void testGetColumnCount() {
+ // It should contain all of the properties names + 1 because of the
+ // "Name" column.
+ assertEquals(columnNames.size() + 1, tableFormat.getColumnCount());
+ }
+
+ /**
+ * Test method for
+ * {@link org.eclipse.ice.materials.MaterialWritableTableFormat#getColumnName(int)}
+ * .
+ */
+ @Test
+ public void testGetColumnName() {
+
+ // Check the "Name" column.
+ assertEquals("Name",tableFormat.getColumnName(0));
+
+ // Just make sure the column names exist. Checking the order is a little
+ // overkill. Start at 1 because "Name" is always there.
+ for (int i = 1; i < columnNames.size(); i++) {
+ assertTrue(columnNames.contains(tableFormat.getColumnName(i)));
+ }
+
+ return;
+ }
+
+ /**
+ * Test method for
+ * {@link org.eclipse.ice.materials.MaterialWritableTableFormat#getColumnValue(org.eclipse.ice.datastructures.form.Material, int)}
+ * .
+ */
+ @Test
+ public void testGetColumnValue() {
+
+ // Reset the property values since the tests can run out of order.
+ material.setProperty("A", 1.0);
+ material.setProperty("B", 2.0);
+
+ // Check that the value is either the value for A or the value for B.
+ // Since there is no guarantee on order, this is the only good way to do
+ // it.
+ Object value = tableFormat.getColumnValue(material, 0);
+ assertEquals(value, "Fluffy");
+ Double dValue = (Double) tableFormat.getColumnValue(material, 1);
+ assertTrue(dValue.equals(1.0) || dValue.equals(2.0));
+ dValue = (Double) tableFormat.getColumnValue(material, 2);
+ assertTrue(dValue.equals(1.0) || dValue.equals(2.0));
+
+ return;
+ }
+
+ /**
+ * Test method for
+ * {@link org.eclipse.ice.materials.MaterialWritableTableFormat#isEditable(org.eclipse.ice.datastructures.form.Material, int)}
+ * .
+ */
+ @Test
+ public void testIsEditable() {
+ assertTrue(tableFormat.isEditable(material, 0));
+ }
+
+ /**
+ * Test method for
+ * {@link org.eclipse.ice.materials.MaterialWritableTableFormat#setColumnValue(org.eclipse.ice.datastructures.form.Material, java.lang.Object, int)}
+ * .
+ */
+ @Test
+ public void testSetColumnValue() {
+ assertEquals(material, tableFormat.setColumnValue(material, 2.5, 0));
+ }
+
+}
diff --git a/tests/org.eclipse.ice.materials.test/src/org/eclipse/ice/materials/test/XMLMaterialDatabaseTester.java b/tests/org.eclipse.ice.materials.test/src/org/eclipse/ice/materials/test/XMLMaterialDatabaseTester.java
index b34aa5733..a4cccd7ee 100644
--- a/tests/org.eclipse.ice.materials.test/src/org/eclipse/ice/materials/test/XMLMaterialDatabaseTester.java
+++ b/tests/org.eclipse.ice.materials.test/src/org/eclipse/ice/materials/test/XMLMaterialDatabaseTester.java
@@ -25,12 +25,15 @@
import org.eclipse.ice.datastructures.ICEObject.ICEList;
import org.eclipse.ice.datastructures.form.Material;
+import org.eclipse.ice.materials.MaterialWritableTableFormat;
import org.eclipse.ice.materials.XMLMaterialsDatabase;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
+import ca.odell.glazedlists.gui.TableFormat;
+
/**
* This class is responsible for testing the XMLMaterialsDatabase class. Since
* it is generally hard to test a service that needs to be stopped and started
@@ -102,7 +105,8 @@ public void checkDatabase() {
Material co2 = TestMaterialFactory.createCO2();
Material h2o = TestMaterialFactory.createH2O();
ArrayList materials = new ArrayList();
- ArrayList defaultMaterials = (ArrayList) materials.clone();
+ ArrayList defaultMaterials = (ArrayList) materials
+ .clone();
ICEList jaxbMaterialsList = new ICEList();
materials.add(h2o);
materials.add(co2);
@@ -195,14 +199,27 @@ public void checkDatabase() {
assertTrue(reloadedMaterials.contains(material));
}
- // Stop the service and restart it to make sure the defaults persist.
+ // Stop the service and restart it to make sure the defaults
+ // persist.
database.stop();
database.start();
reloadedMaterials = database.getMaterials();
for (Material material : defaultMaterials) {
assertTrue(reloadedMaterials.contains(material));
}
-
+
+ // Check the implementation of IElementSource provided by
+ // the database. Make sure the EventList is correct.
+ assertEquals(reloadedMaterials.size(), database.getElements()
+ .size());
+ assertEquals(reloadedMaterials.get(0), database.getElements()
+ .get(0));
+ // The table format is checked in detail in its own test, so just
+ // make sure it isn't null and that it is the right type.
+ TableFormat format = database.getTableFormat();
+ assertNotNull(format);
+ assertTrue(format instanceof MaterialWritableTableFormat);
+
// Kill the service for completeness I suppose.
database.stop();
} catch (NullPointerException | JAXBException e) {
diff --git a/tests/org.eclipse.ice.reflectivity.test/META-INF/MANIFEST.MF b/tests/org.eclipse.ice.reflectivity.test/META-INF/MANIFEST.MF
index a169621c7..9ef0ff75a 100644
--- a/tests/org.eclipse.ice.reflectivity.test/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.ice.reflectivity.test/META-INF/MANIFEST.MF
@@ -7,4 +7,10 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Require-Bundle: org.junit;bundle-version="4.11.0",
org.eclipse.ice.item;bundle-version="2.0.0",
org.eclipse.ice.datastructures;bundle-version="2.0.0"
-Import-Package: org.eclipse.ice.reflectivity
+Import-Package: org.apache.commons.math;version="2.1.0",
+ org.eclipse.core.resources,
+ org.eclipse.core.runtime;version="3.4.0",
+ org.eclipse.ice.io.csv,
+ org.eclipse.ice.materials,
+ org.eclipse.ice.reflectivity,
+ org.eclipse.ui.forms.widgets
diff --git a/tests/org.eclipse.ice.reflectivity.test/src/org/eclipse/ice/reflectivity/test/ReflectivityCalculatorTester.java b/tests/org.eclipse.ice.reflectivity.test/src/org/eclipse/ice/reflectivity/test/ReflectivityCalculatorTester.java
new file mode 100644
index 000000000..fbf1633d8
--- /dev/null
+++ b/tests/org.eclipse.ice.reflectivity.test/src/org/eclipse/ice/reflectivity/test/ReflectivityCalculatorTester.java
@@ -0,0 +1,660 @@
+/*******************************************************************************
+ * 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, John Ankner
+ *******************************************************************************/
+package org.eclipse.ice.reflectivity.test;
+
+import static org.junit.Assert.*;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.ice.datastructures.ICEObject.ListComponent;
+import org.eclipse.ice.datastructures.form.Form;
+import org.eclipse.ice.io.csv.CSVReader;
+import org.eclipse.ice.reflectivity.ReflectivityProfile;
+import org.eclipse.ice.reflectivity.ScatteringDensityProfile;
+import org.eclipse.ice.reflectivity.ReflectivityCalculator;
+import org.eclipse.ice.reflectivity.Slab;
+import org.eclipse.ice.reflectivity.Tile;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.apache.commons.math.MathException;
+
+/**
+ * This class tests {@link org.eclipse.ice.reflectivity.ReflectivityCalculator}.
+ *
+ * @author Jay Jay Billings, John Ankner
+ *
+ */
+public class ReflectivityCalculatorTester {
+
+ /**
+ * The CSV file that will be tested
+ */
+ private static IFile testFile;
+ /**
+ * The reader that will be tested.
+ */
+ private static CSVReader reader;
+
+ /**
+ * The set of slabs that define the system.
+ */
+ private static Slab[] slabs;
+
+ /**
+ * The project used by the test. It currently points to the
+ * CSVLoaderTesterWorkspace because the reflectivity CSV files are also used
+ * in the CSV tests.
+ */
+ private static IProject project;
+
+ /**
+ * A default tolerance for the tests.
+ */
+ private double tol = 1.0e-3;
+
+ /**
+ * This class loads the files for the test.
+ *
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+
+ // Get the file separator used on this system, which is different across
+ // OSes.
+ String separator = System.getProperty("file.separator");
+ // Create the path for the reflectivity file in the ICE tests directory
+ String userHome = System.getProperty("user.home");
+ IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+ String projectName = "CSVLoaderTesterWorkspace";
+ String filename = "getSpecRefSqrdMod_q841.csv";
+ IPath projectPath = new Path(userHome + separator + "ICETests"
+ + separator + projectName + separator + ".project");
+
+ // Setup the project
+ try {
+ // Create the project description
+ IProjectDescription desc = ResourcesPlugin.getWorkspace()
+ .loadProjectDescription(projectPath);
+ // Get the project handle and create it
+ project = workspaceRoot.getProject(desc.getName());
+ project.create(desc, new NullProgressMonitor());
+ // Open the project if it is not already open
+ if (project.exists() && !project.isOpen()) {
+ project.open(new NullProgressMonitor());
+ }
+ // Refresh the workspace
+ project.refreshLocal(IResource.DEPTH_INFINITE,
+ new NullProgressMonitor());
+ // Create the IFile handle for the csv file
+ testFile = project.getFile(filename);
+ } catch (CoreException e) {
+ // Catch exception for creating the project
+ e.printStackTrace();
+ fail();
+ }
+
+ // Create the reader
+ reader = new CSVReader();
+
+ // Create the slabs that define the system, starting with air
+ Slab air = new Slab();
+ air.thickness = 200.0;
+
+ // NiOx
+ Slab niOx = new Slab();
+ niOx.scatteringLength = (0.00000686 + 0.00000715) / 2.0;
+ niOx.trueAbsLength = 2.27931868269305E-09;
+ niOx.incAbsLength = 4.74626235093697E-09;
+ niOx.thickness = 22.0;
+ niOx.interfaceWidth = 4.0 * 2.35;
+
+ // Ni
+ Slab ni = new Slab();
+ ni.scatteringLength = 9.31e-6;
+ ni.trueAbsLength = 2.27931868269305E-09;
+ ni.incAbsLength = 4.74626235093697E-09;
+ ni.thickness = 551.0;
+ ni.interfaceWidth = 4.3 * 2.35;
+
+ // SiNiOx
+ Slab siNiOx = new Slab();
+ siNiOx.scatteringLength = (0.00000554 + 0.00000585) / 2.0;
+ siNiOx.trueAbsLength = 2.27931868269305E-09;
+ siNiOx.incAbsLength = 4.74626235093697E-09;
+ siNiOx.thickness = 42.0;
+ siNiOx.interfaceWidth = 7.0 * 2.35;
+
+ // SiOx
+ Slab si = new Slab();
+ si.scatteringLength = 2.070e-6;
+ si.trueAbsLength = 4.74981478870069E-11;
+ si.incAbsLength = 1.99769988072137E-12;
+ si.thickness = 100.0;
+ si.interfaceWidth = 17.5;
+
+ // Create the slab list
+ slabs = new Slab[5];
+ slabs[0] = air;
+ slabs[1] = niOx;
+ slabs[2] = ni;
+ slabs[3] = siNiOx;
+ slabs[4] = si;
+
+ return;
+
+ }
+
+ /**
+ * This class tests
+ * {@link ReflectivityCalculator#getExtensionLengths(double[], double, double, double, int, int, int)}
+ * .
+ */
+ @Test
+ public void testGetExtensionLengths() {
+ // Load the convolution file
+ Form form = reader.read(project.getFile("getExtensionLengths.csv"));
+ ListComponent lines = (ListComponent) form
+ .getComponent(1);
+ assertEquals(403, lines.size());
+
+ // Get the parameters and reference output values
+ String line[] = lines.get(0);
+ double delQ0 = Double.valueOf(line[0]);
+ double delQ1oQ = Double.valueOf(line[1]);
+ double wavelength = Double.valueOf(line[2]);
+ int numPoints = Integer.valueOf(line[3]);
+ int refNumLowPoints = Integer.valueOf(line[4]);
+ int refNumHighPoints = Integer.valueOf(line[5]);
+
+ // Load the q array. They are padded by numLowPoints for the
+ // convolution.
+ double[] waveVector = new double[lines.size() - 1];
+ for (int i = 0; i < lines.size() - 1; i++) {
+ line = lines.get(i + 1);
+ waveVector[i] = Double.valueOf(line[0]);
+ }
+ assertEquals(numPoints, waveVector.length);
+ assertEquals(4.401373320E-01, waveVector[numPoints - 1], 0.0);
+
+ // Call the function
+ int numLowPoints = 0, numHighPoints = 0;
+ ReflectivityCalculator calculator = new ReflectivityCalculator();
+ numLowPoints = calculator.getLowExtensionLength(waveVector, delQ0,
+ delQ1oQ, numPoints);
+ numHighPoints = calculator.getHighExtensionLength(waveVector, delQ0,
+ delQ1oQ, numPoints);
+
+ // Check the high and low extension lengths
+ assertEquals(refNumLowPoints, numLowPoints);
+ assertEquals(refNumHighPoints, numHighPoints);
+
+ return;
+ }
+
+ /**
+ * This class tests
+ * {@link ReflectivityCalculator#convolute(double[], double, double, double, int, int, double[])}
+ * .
+ */
+ @Test
+ public void testConvolute() {
+ // Load the convolution file
+ Form form = reader.read(project.getFile("convolute.csv"));
+ ListComponent lines = (ListComponent) form
+ .getComponent(1);
+ assertEquals(417, lines.size());
+
+ // The first line of the file contains all of the parameters
+ String[] line = lines.get(0);
+ double delQ0 = Double.valueOf(line[0]);
+ double delQ1oQ = Double.valueOf(line[1]);
+ double wavelength = Double.valueOf(line[2]);
+ int numPoints = Integer.valueOf(line[3]);
+ int numLowPoints = Integer.valueOf(line[4]);
+ int numHighPoints = Integer.valueOf(line[5]);
+
+ // Load the q and refFit arrays. They are padded by numLowPoints for the
+ // convolution.
+ double[] waveVector = new double[lines.size() - 1];
+ double[] refRefFit = new double[lines.size() - 1]; // Reference!
+ for (int i = 0; i < lines.size() - 1; i++) {
+ line = lines.get(i + 1);
+ waveVector[i] = Double.valueOf(line[0]);
+ refRefFit[i] = Double.valueOf(line[1]);
+ }
+ assertEquals(0.461926308814, waveVector[415], 0.0);
+ assertEquals(3.87921357905325E-09, refRefFit[415], 0.0);
+
+ // Load the tiles
+ form = reader.read(project.getFile("getSpecRefSqrdMod_q841.csv"));
+ ListComponent tileLines = (ListComponent) form
+ .getComponent(1);
+ Tile[] tiles = loadTiles(tileLines);
+ assertEquals(173, tiles.length);
+
+ // Compute the initial value of refFit. This code was adapted from the
+ // original VB code and it is called, in that code, right before
+ // ManConFixedLambda.
+ double[] refFit = new double[lines.size() - 1];
+ double qEff = 0.0;
+ ReflectivityCalculator calculator = new ReflectivityCalculator();
+ for (int i = 0; i < numHighPoints + numLowPoints + numPoints; i++) {
+ if (waveVector[i] < 1.0e-10) {
+ qEff = 1.0e-10;
+ } else {
+ qEff = waveVector[i];
+ }
+ refFit[i] = calculator.getModSqrdSpecRef(qEff, wavelength, tiles);
+ }
+
+ // Do the convolution and check the result against the reference values.
+ calculator.convolute(waveVector, delQ0, delQ1oQ, wavelength, numPoints,
+ numLowPoints, numHighPoints, refFit);
+ for (int i = 0; i < refFit.length; i++) {
+ // Most of these results agree to roughly 1e-4, but some of them
+ // disagree by as much as 3.2%. They are clustered around 90 <= i <=
+ // 101.
+ assertEquals(refRefFit[i], refFit[i],
+ Math.abs(refRefFit[i]) * 3.2e-2);
+ }
+
+ return;
+ }
+
+ /**
+ * This class tests
+ * {@link ReflectivityCalculator#getModSqrdSpecRef(double, double, Tile[])}.
+ */
+ @Test
+ public void testGetSpecRefSqrdMod() {
+
+ // Load the file
+ Form form = reader.read(project.getFile("getSpecRefSqrdMod_q841.csv"));
+ ListComponent lines = (ListComponent) form
+ .getComponent(1);
+
+ // Get the two single parameters and the final result out of the data
+ // for the first test case
+ String[] line = lines.get(0);
+ double waveVectorQ, wavelength, expectedSpecRefSqrd;
+ waveVectorQ = Double.valueOf(line[0]);
+ wavelength = Double.valueOf(line[1]);
+ expectedSpecRefSqrd = Double.valueOf(line[2]);
+
+ // Load the tiles from the rest of the data
+ Tile[] tiles = loadTiles(lines);
+ assertEquals(173, tiles.length);
+
+ // Get the squared modulus of the specular reflectivity with the values
+ // from the file for the first case.
+ ReflectivityCalculator calculator = new ReflectivityCalculator();
+ double specRefSqrd = calculator.getModSqrdSpecRef(waveVectorQ,
+ wavelength, tiles);
+ System.out.println(specRefSqrd + " " + expectedSpecRefSqrd);
+ System.out.println("RERR = " + (specRefSqrd - expectedSpecRefSqrd)
+ / expectedSpecRefSqrd);
+ assertEquals(expectedSpecRefSqrd, specRefSqrd,
+ Math.abs(expectedSpecRefSqrd) * tol);
+
+ // Get the two single parameters and the final result out of the data
+ // for the second test case
+ line = lines.get(1);
+ waveVectorQ = Double.valueOf(line[0]);
+ wavelength = Double.valueOf(line[1]);
+ expectedSpecRefSqrd = Double.valueOf(line[2]);
+ System.out.println(waveVectorQ + " " + wavelength + " "
+ + expectedSpecRefSqrd);
+
+ // Get the squared modulus of the specular reflectivity with the values
+ // from the file for the second case.
+ specRefSqrd = calculator.getModSqrdSpecRef(waveVectorQ, wavelength,
+ tiles);
+ System.out.println(specRefSqrd + " " + expectedSpecRefSqrd);
+ System.out.println("RERR = " + (specRefSqrd - expectedSpecRefSqrd)
+ / expectedSpecRefSqrd);
+ assertEquals(expectedSpecRefSqrd, specRefSqrd,
+ Math.abs(expectedSpecRefSqrd) * tol);
+
+ return;
+ }
+
+ /**
+ * This operation loads the set of Tiles from the reference file, ignoring
+ * the first and second lines that store the reference values.
+ *
+ * @param lines
+ * The ListComponent with the lines from the file
+ * @return the list of Tiles from the file
+ */
+ private Tile[] loadTiles(ListComponent lines) {
+
+ // Load all of the tiles
+ Tile[] tiles = new Tile[lines.size() - 2];
+ for (int i = 2; i < lines.size(); i++) {
+ // Load the line
+ String[] line = lines.get(i);
+ // Create the tile and load the data from the line
+ Tile tile = new Tile();
+ tile.scatteringLength = Double.valueOf(line[0]);
+ tile.trueAbsLength = Double.valueOf(line[1]);
+ tile.incAbsLength = Double.valueOf(line[2]);
+ tile.thickness = Double.valueOf(line[3]);
+ // Load the tile into the array
+ tiles[i - 2] = tile;
+ }
+
+ return tiles;
+ }
+
+ /**
+ * This operation tests
+ * {@link ReflectivityCalculator#getInterfacialProfile(int, double[], double[])}
+ * .
+ *
+ * @throws MathException
+ * This exception is thrown if the erf can't be computed during
+ * the calculation.
+ */
+ @Test
+ public void testGetInterfacialProfile() throws MathException {
+ // Get the file holding the test values
+ Form form = reader.read(project.getFile("genErf.csv"));
+ ListComponent lines = (ListComponent) form
+ .getComponent(1);
+ assertEquals(101, lines.size());
+
+ // Create the reference data. Start by getting the number of roughness
+ // steps to make and then get the zInt and rufInt arrays.
+ int numRough = Integer.valueOf(lines.get(0)[2]);
+ double[] refZInt = new double[ReflectivityCalculator.maxRoughSize];
+ double[] refRufInt = new double[ReflectivityCalculator.maxRoughSize];
+
+ // Load the reference arrays
+ for (int i = 0; i < ReflectivityCalculator.maxRoughSize; i++) {
+ String[] line = lines.get(i);
+ refZInt[i] = Double.valueOf(line[0]);
+ refRufInt[i] = Double.valueOf(line[1]);
+ }
+
+ // Create the test arrays
+ double[] zInt = new double[ReflectivityCalculator.maxRoughSize];
+ double[] rufInt = new double[ReflectivityCalculator.maxRoughSize];
+
+ // Create the calculator and get the interfacial profile
+ ReflectivityCalculator calc = new ReflectivityCalculator();
+ calc.getInterfacialProfile(numRough, zInt, rufInt);
+
+ // Check the results
+ System.out.println("numRough = " + numRough);
+ for (int i = 0; i < ReflectivityCalculator.maxRoughSize; i++) {
+ // These values agree exceptionally well, so I decided to check with
+ // the square of the tolerance (MUCH tighter bound) for zInt and
+ // 10*tol*tol for refRuf, which is still better than we need.
+ assertEquals(refZInt[i], zInt[i], Math.abs(refZInt[i]) * tol * tol);
+ assertEquals(refRufInt[i], rufInt[i], Math.abs(refRufInt[i]) * 10.0
+ * tol * tol);
+ }
+
+ return;
+ }
+
+ /**
+ * This operation tests {@link ReflectivityCalculator#generateTiles()}.
+ *
+ * @throws MathException
+ */
+ @Test
+ public void testGenerateTiles() throws MathException {
+
+ // Create the calculator
+ ReflectivityCalculator calculator = new ReflectivityCalculator();
+
+ // Create the test arrays
+ double[] zInt = new double[ReflectivityCalculator.maxRoughSize];
+ double[] rufInt = new double[ReflectivityCalculator.maxRoughSize];
+
+ // Get the interfacial profile
+ int numRough = 41;
+ calculator.getInterfacialProfile(numRough, zInt, rufInt);
+
+ // Generate the tiles
+ Tile[] genTiles = calculator.generateTiles(slabs, numRough, zInt,
+ rufInt);
+
+ // Load the reference tiles
+ Form form = reader.read(project.getFile("getSpecRefSqrdMod_q841.csv"));
+ ListComponent tileLines = (ListComponent) form
+ .getComponent(1);
+ Tile[] refTiles = loadTiles(tileLines);
+ assertEquals(173, refTiles.length);
+
+ // Check the generated tiles against the reference data
+ assertEquals(refTiles.length, genTiles.length);
+ for (int i = 0; i < refTiles.length; i++) {
+ System.out.println("Tile = " + i);
+ // Scattering length
+ assertEquals(refTiles[i].scatteringLength,
+ genTiles[i].scatteringLength,
+ Math.abs(refTiles[i].scatteringLength * tol));
+ // True absorption cross section
+ assertEquals(refTiles[i].trueAbsLength, genTiles[i].trueAbsLength,
+ Math.abs(refTiles[i].trueAbsLength * tol));
+ // Incoherent absorption cross section
+ assertEquals(refTiles[i].incAbsLength, genTiles[i].incAbsLength,
+ Math.abs(refTiles[i].incAbsLength * tol));
+ // Thickness
+ assertEquals(refTiles[i].thickness, genTiles[i].thickness,
+ Math.abs(refTiles[i].thickness * tol));
+ }
+ System.out.println(refTiles.length + " " + genTiles.length);
+
+ return;
+ }
+
+ /**
+ * This operation tests
+ * {@link ReflectivityCalculator#convoluteReflectivity()}.
+ */
+ @Test
+ public void testConvoluteReflectivity() {
+
+ // Load the reference tiles
+ Form form = reader.read(project.getFile("getSpecRefSqrdMod_q841.csv"));
+ ListComponent tileLines = (ListComponent) form
+ .getComponent(1);
+ Tile[] refTiles = loadTiles(tileLines);
+ assertEquals(173, refTiles.length);
+
+ // Load the parameters and reference data
+ form = reader.read(project.getFile("conRefTileFixedLambda.csv"));
+ ListComponent refLines = (ListComponent) form
+ .getComponent(1);
+ assertEquals(403, refLines.size());
+
+ // Get the parameters
+ double deltaQ0 = Double.valueOf(refLines.get(0)[0]);
+ double deltaQ1ByQ = Double.valueOf(refLines.get(0)[1]);
+ double lambda = Double.valueOf(refLines.get(0)[2]);
+ boolean getRQ4 = Boolean.valueOf(refLines.get(0)[3]);
+
+ // Get the reference reflectivity results and the q input array
+ double[] waveVector = new double[402];
+ double[] refReflectivity = new double[402];
+
+ // Load the reference arrays.
+ for (int i = 1; i < 403; i++) {
+ String[] line = refLines.get(i);
+ refReflectivity[i - 1] = Double.valueOf(line[0]);
+ waveVector[i - 1] = Double.valueOf(line[1]);
+ }
+
+ // Do the calculation
+ ReflectivityCalculator calc = new ReflectivityCalculator();
+ double[] reflectivity = calc.convoluteReflectivity(deltaQ0, deltaQ1ByQ,
+ lambda, getRQ4, waveVector, refTiles);
+
+ // Check the results
+ assertEquals(refReflectivity.length, reflectivity.length);
+ for (int i = 0; i < refReflectivity.length; i++) {
+ // Four percent error is the best that I can do on this because the
+ // behavior at the end points does not match. I think it is due to
+ // an accumulation of errors from other sources.
+ assertEquals(refReflectivity[i], reflectivity[i],
+ Math.abs(refReflectivity[i]) * 0.04);
+ }
+
+ return;
+ }
+
+ /**
+ * This operation tests
+ * {@link ReflectivityCalculator#getScatteringDensityProfile()}.
+ */
+ @Test
+ public void testGetProfile() {
+ // Load the reference tiles
+ Form form = reader.read(project.getFile("getSpecRefSqrdMod_q841.csv"));
+ ListComponent tileLines = (ListComponent) form
+ .getComponent(1);
+ Tile[] refTiles = loadTiles(tileLines);
+ assertEquals(173, refTiles.length);
+
+ // Load the reference data
+ form = reader.read(project.getFile("plotProfile.csv"));
+ ListComponent refLines = (ListComponent) form
+ .getComponent(1);
+ assertEquals(346, refLines.size());
+
+ // Get the reference reflectivity results and the q input array
+ double[] refDepth = new double[346];
+ double[] refScatteringDensity = new double[346];
+
+ // Load the reference arrays.
+ for (int i = 0; i < refDepth.length; i++) {
+ String[] line = refLines.get(i);
+ refDepth[i] = Double.valueOf(line[0]);
+ refScatteringDensity[i] = Double.valueOf(line[1]);
+ }
+
+ // Get the profile
+ ReflectivityCalculator calc = new ReflectivityCalculator();
+ ScatteringDensityProfile profile = calc
+ .getScatteringDensityProfile(refTiles);
+
+ // Check the values
+ assertEquals(refDepth.length, profile.depth.length);
+ assertEquals(refScatteringDensity.length,
+ profile.scatteringDensity.length);
+ for (int i = 0; i < refDepth.length; i++) {
+ assertEquals(refDepth[i], profile.depth[i], Math.abs(refDepth[i])
+ * tol);
+ assertEquals(refScatteringDensity[i], profile.scatteringDensity[i],
+ Math.abs(refScatteringDensity[i]) * 3.0 * tol);
+ }
+
+ return;
+ }
+
+ /**
+ * This operation tests
+ * {@link ReflectivityCalculator#getReflectivityProfile()}.
+ */
+ @Test
+ public void testGetReflectivityProfile() {
+
+ // Load the parameters and reference data
+ Form form = reader.read(project.getFile("conRefTileFixedLambda.csv"));
+ ListComponent refLines = (ListComponent) form
+ .getComponent(1);
+ assertEquals(403, refLines.size());
+
+ // Get the parameters
+ double deltaQ0 = Double.valueOf(refLines.get(0)[0]);
+ double deltaQ1ByQ = Double.valueOf(refLines.get(0)[1]);
+ double lambda = Double.valueOf(refLines.get(0)[2]);
+ boolean getRQ4 = Boolean.valueOf(refLines.get(0)[3]);
+
+ // Get the reference reflectivity results and the q input array
+ double[] waveVector = new double[402];
+ double[] refReflectivity = new double[402];
+
+ // Load the reference arrays. Skip the first line because this file has
+ // additional parameters on that line.
+ for (int i = 1; i < 403; i++) {
+ String[] line = refLines.get(i);
+ refReflectivity[i - 1] = Double.valueOf(line[0]);
+ waveVector[i - 1] = Double.valueOf(line[1]);
+ }
+
+ // Load the reference data for the scattering density profile
+ form = reader.read(project.getFile("plotProfile.csv"));
+ ListComponent refPlotProfileLines = (ListComponent) form
+ .getComponent(1);
+ assertEquals(346, refPlotProfileLines.size());
+
+ // Get the reference reflectivity results and the q input array
+ double[] refDepth = new double[346];
+ double[] refScatteringDensity = new double[346];
+
+ // Load the reference arrays.
+ for (int i = 0; i < refDepth.length; i++) {
+ String[] line = refPlotProfileLines.get(i);
+ refDepth[i] = Double.valueOf(line[0]);
+ refScatteringDensity[i] = Double.valueOf(line[1]);
+ }
+
+ // Calculate the reflectivity profile
+ ReflectivityCalculator calc = new ReflectivityCalculator();
+ ReflectivityProfile profile = calc.getReflectivityProfile(slabs, 41,
+ deltaQ0, deltaQ1ByQ, lambda, waveVector, false);
+
+ // Check the results
+ assertEquals(refReflectivity.length, profile.reflectivity.length);
+ assertEquals(waveVector.length, profile.waveVector.length);
+ // Check the reflectivity values
+ //System.out.println("----- Dumping Reflectivity ----- ");
+ for (int i = 0; i < refReflectivity.length; i++) {
+ // They should be exact because the wave vector is an input
+ assertEquals(waveVector[i], profile.waveVector[i],0.0);
+ // Four percent error is the best that I can do on the reflectivity
+ // because the behavior at the end points does not match. I think it
+ // is due to an accumulation of errors from other sources.
+ assertEquals(refReflectivity[i], profile.reflectivity[i],
+ Math.abs(refReflectivity[i]) * 0.04);
+ //System.out.println(profile.waveVector[i]+","+profile.reflectivity[i]);
+ }
+ //System.out.println("----- Dumping Scattering Density ----- ");
+ // Check the scattering density values
+ assertEquals(refDepth.length, profile.depth.length);
+ assertEquals(refScatteringDensity.length,
+ profile.scatteringDensity.length);
+ for (int i = 0; i < refDepth.length; i++) {
+ assertEquals(refDepth[i], profile.depth[i], Math.abs(refDepth[i])
+ * tol);
+ assertEquals(refScatteringDensity[i], profile.scatteringDensity[i],
+ Math.abs(refScatteringDensity[i]) * 3.0 * tol);
+ //System.out.println(profile.depth[i]+","+profile.scatteringDensity[i]);
+ }
+
+ return;
+ }
+
+}
diff --git a/tests/org.eclipse.ice.reflectivity.test/src/org/eclipse/ice/reflectivity/test/ReflectivityModelBuilderTester.java b/tests/org.eclipse.ice.reflectivity.test/src/org/eclipse/ice/reflectivity/test/ReflectivityModelBuilderTester.java
new file mode 100644
index 000000000..8636324bd
--- /dev/null
+++ b/tests/org.eclipse.ice.reflectivity.test/src/org/eclipse/ice/reflectivity/test/ReflectivityModelBuilderTester.java
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (c) 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
+ *******************************************************************************/
+package org.eclipse.ice.reflectivity.test;
+
+import static org.junit.Assert.*;
+
+import java.util.List;
+
+import org.eclipse.ice.datastructures.ICEObject.ListComponent;
+import org.eclipse.ice.datastructures.form.Material;
+import org.eclipse.ice.materials.IMaterialsDatabase;
+import org.eclipse.ice.reflectivity.ReflectivityModel;
+import org.eclipse.ice.reflectivity.ReflectivityModelBuilder;
+import org.junit.Test;
+
+import ca.odell.glazedlists.EventList;
+import ca.odell.glazedlists.gui.TableFormat;
+
+/**
+ * This class is responsible for making sure that the ReflectivityModelBuilder
+ * can correctly build a ReflectivityModel.
+ *
+ * @author Jay Jay Billings
+ *
+ */
+public class ReflectivityModelBuilderTester implements IMaterialsDatabase {
+
+ /**
+ * Test method for
+ * {@link org.eclipse.ice.item.AbstractItemBuilder#build(org.eclipse.core.resources.IProject)}
+ * .
+ */
+ @Test
+ public void testBuild() {
+
+ // This test is identical to the ReflectivityModelTester, but it does
+ // everything through the builder instead of creating it directly. The
+ // important part is to make sure that the ListComponent has an
+ // ElementSource. That is, that the setupFormWithServices() operation is
+ // called.
+
+ // Local Declarations
+ int listID = 1;
+ ListComponent list;
+
+ // Create the builder
+ ReflectivityModelBuilder builder = new ReflectivityModelBuilder();
+ builder.setMaterialsDatabase(this);
+
+ // Just create one with the nullary constructor
+ // No need to check the Item with a IProject instance
+ ReflectivityModel model = (ReflectivityModel) builder.build(null);
+
+ // Make sure we have a form and some components
+ assertNotNull(model.getForm());
+ assertEquals(1, model.getForm().getComponents().size());
+
+ // Get the table component
+ list = (ListComponent) model.getForm().getComponent(listID);
+
+ // Make sure it's not null and the name is correct
+ assertNotNull(list);
+ assertEquals("Reflectivity Input Data", list.getName());
+
+ // Make sure that the element source of the list is set to insure that
+ // setupFormWithServices() worked.
+ assertNotNull(list.getElementSource());
+ assertEquals(list.getElementSource(), this);
+
+ }
+
+ @Override
+ public EventList getElements() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public TableFormat getTableFormat() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public List getMaterials() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void addMaterial(Material material) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void deleteMaterial(String name) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void deleteMaterial(Material material) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateMaterial(Material material) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void restoreDefaults() {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/tests/org.eclipse.ice.reflectivity.test/src/org/eclipse/ice/reflectivity/test/ReflectivityModelTester.java b/tests/org.eclipse.ice.reflectivity.test/src/org/eclipse/ice/reflectivity/test/ReflectivityModelTester.java
index 8a46998bc..53be5e101 100644
--- a/tests/org.eclipse.ice.reflectivity.test/src/org/eclipse/ice/reflectivity/test/ReflectivityModelTester.java
+++ b/tests/org.eclipse.ice.reflectivity.test/src/org/eclipse/ice/reflectivity/test/ReflectivityModelTester.java
@@ -14,47 +14,33 @@
import static org.junit.Assert.*;
+import java.util.List;
+
+import org.eclipse.ice.datastructures.ICEObject.IElementSource;
import org.eclipse.ice.datastructures.ICEObject.ListComponent;
import org.eclipse.ice.datastructures.form.Material;
import org.eclipse.ice.datastructures.form.TableComponent;
+import org.eclipse.ice.materials.IMaterialsDatabase;
import org.eclipse.ice.reflectivity.ReflectivityModel;
import org.junit.BeforeClass;
import org.junit.Test;
+import ca.odell.glazedlists.EventList;
+import ca.odell.glazedlists.gui.TableFormat;
+
/**
- * This class is responsible for testing the ReflectivityModel.
+ * This class is responsible for testing the ReflectivityModel. It implements
+ * the IMaterialsDatabase interface so that it can make sure the reflectivity
+ * model initializes properly when setupFormWithServices() is called.
+ *
* @author Jay Jay Billings
*
*/
-public class ReflectivityModelTester {
+public class ReflectivityModelTester implements IMaterialsDatabase {
/**
- *
- *
- * This operation sets up the workspace. It copies the necessary MOOSE data
- * files into ${workspace}/MOOSE.
- *
* This operation checks the ReflectivityModel and makes sure that it can
* properly construct its Form.
- *
- *
- *
- * @generated
- * "UML to Java (com.ibm.xtools.transform.uml2.java5.internal.UML2JavaTransform)"
*/
@Test
public void checkConstruction() {
@@ -63,23 +49,78 @@ public void checkConstruction() {
// Local Declarations
int listID = 1;
ListComponent list;
-
+
// Just create one with the nullary constructor
// No need to check the Item with a IProject instance
ReflectivityModel model = new ReflectivityModel();
+ model.setMaterialsDatabase(this);
+ model.setupFormWithServices();
// Make sure we have a form and some components
assertNotNull(model.getForm());
assertEquals(1, model.getForm().getComponents().size());
-
+
// Get the table component
list = (ListComponent) model.getForm().getComponent(listID);
-
+
// Make sure it's not null and the name is correct
assertNotNull(list);
assertEquals("Reflectivity Input Data", list.getName());
-
- // end-user-code
+
+ // Make sure that the element source of the list is set to insure that
+ // setupFormWithServices() worked.
+ assertNotNull(list.getElementSource());
+ assertEquals(list.getElementSource(),this);
+
+ return;
+ }
+
+ @Override
+ public EventList getElements() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public TableFormat getTableFormat() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public List getMaterials() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void addMaterial(Material material) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void deleteMaterial(String name) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void deleteMaterial(Material material) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateMaterial(Material material) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void restoreDefaults() {
+ // TODO Auto-generated method stub
+
}
}