Commit f3f806bd authored by Jay Jay Billings's avatar Jay Jay Billings

Added ICE XML Content Type.

Started refactoring the client to properly load Items. Added an XML
content type and describer for loading forms. Cleaned up various and
sundry things around the platform.
Signed-off-by: default avatarJay Jay Billings <billingsjj@ornl.gov>
parent a7a1604c
......@@ -540,18 +540,4 @@ public class ClientTester {
}
/**
* <p>
* checkFS() checks that a valid file system representation is returned from
* Core.
* </p>
*
*/
@Test
public void checkFS() {
// Assert that getFileSystem returns a valid ICEObject
assertNotNull(iCEClient.getFileSystem());
return;
}
}
\ No newline at end of file
......@@ -26,4 +26,5 @@ Import-Package: javax.ws.rs.core,
Service-Component: OSGI-INF/clientComponent.xml
Require-Bundle: org.eclipse.ice.datastructures;bundle-version="2.1.7",
com.sun.jersey;bundle-version="1.17.0",
org.eclipse.ice.client.compatibility;bundle-version="2.0.0"
org.eclipse.ice.client.compatibility;bundle-version="2.0.0",
org.eclipse.core.runtime;bundle-version="3.11.0"
......@@ -19,12 +19,7 @@ import java.util.Hashtable;
import java.util.concurrent.atomic.AtomicBoolean;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.ice.client.common.internal.ClientHolder;
import org.eclipse.ice.core.iCore.ICore;
import org.eclipse.ice.datastructures.ICEObject.Identifiable;
......@@ -42,7 +37,12 @@ import org.eclipse.ice.iclient.uiwidgets.ITextEditor;
import org.eclipse.ice.iclient.uiwidgets.IUpdateEventListener;
import org.eclipse.ice.iclient.uiwidgets.IWidgetClosedListener;
import org.eclipse.ice.iclient.uiwidgets.IWidgetFactory;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.EditorPart;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
......@@ -65,8 +65,9 @@ import org.slf4j.LoggerFactory;
*
* @author Jay Jay Billings
*/
public class Client implements IUpdateEventListener, IProcessEventListener, ISimpleResourceProvider,
IWidgetClosedListener, IClient {
public class Client extends EditorPart
implements IUpdateEventListener, IProcessEventListener,
ISimpleResourceProvider, IWidgetClosedListener, IClient {
/**
* Logger for handling event messages and other information.
......@@ -88,7 +89,7 @@ public class Client implements IUpdateEventListener, IProcessEventListener, ISim
private ArrayList<IErrorBox> errorBoxWidgets;
/**
*
* The widget factory used to create widgets.
*/
private IWidgetFactory iWidgetFactory;
......@@ -268,7 +269,7 @@ public class Client implements IUpdateEventListener, IProcessEventListener, ISim
}
}
/**
/*
* (non-Javadoc)
*
* @see IClient#setCoreService(ICore core)
......@@ -279,7 +280,7 @@ public class Client implements IUpdateEventListener, IProcessEventListener, ISim
iCore = core;
}
/**
/*
* (non-Javadoc)
*
* @see IClient#createItem(String itemType)
......@@ -479,7 +480,7 @@ public class Client implements IUpdateEventListener, IProcessEventListener, ISim
return;
}
/**
/*
* (non-Javadoc)
*
* @see IClient#connectToCore(String hostname, int port)
......@@ -512,7 +513,7 @@ public class Client implements IUpdateEventListener, IProcessEventListener, ISim
return status;
}
/**
/*
* (non-Javadoc)
*
* @see IClient#getItems()
......@@ -522,7 +523,7 @@ public class Client implements IUpdateEventListener, IProcessEventListener, ISim
return getCore().getItemList();
}
/**
/*
* (non-Javadoc)
*
* @see IClient#deleteItem(int id)
......@@ -535,7 +536,7 @@ public class Client implements IUpdateEventListener, IProcessEventListener, ISim
}
/**
/*
* (non-Javadoc)
*
* @see IClient#importFile(URI file)
......@@ -549,7 +550,7 @@ public class Client implements IUpdateEventListener, IProcessEventListener, ISim
return;
}
/**
/*
* (non-Javadoc)
*
* @see IUpdateEventListener#formUpdated(Form form)
......@@ -592,7 +593,7 @@ public class Client implements IUpdateEventListener, IProcessEventListener, ISim
}
/**
/*
* (non-Javadoc)
*
* @see IProcessEventListener#processSelected(Form form, String process)
......@@ -608,7 +609,7 @@ public class Client implements IUpdateEventListener, IProcessEventListener, ISim
return;
}
/**
/*
* (non-Javadoc)
*
* @see IProcessEventListener#cancelRequested(Form form, String process)
......@@ -623,7 +624,7 @@ public class Client implements IUpdateEventListener, IProcessEventListener, ISim
return;
}
/**
/*
* (non-Javadoc)
*
* @see ISimpleResourceProvider#loadResource(ICEResource resource)
......@@ -644,7 +645,7 @@ public class Client implements IUpdateEventListener, IProcessEventListener, ISim
}
}
/**
/*
* (non-Javadoc)
*
* @see IWidgetClosedListener#closedOK()
......@@ -656,7 +657,7 @@ public class Client implements IUpdateEventListener, IProcessEventListener, ISim
}
/**
/*
* (non-Javadoc)
*
* @see IWidgetClosedListener#cancelled()
......@@ -668,22 +669,59 @@ public class Client implements IUpdateEventListener, IProcessEventListener, ISim
}
/**
/*
* (non-Javadoc)
*
* @see IClient#getFileSystem()
* @see org.eclipse.ice.iclient.IClient#importFileAsItem(java.net.URI,
* java.lang.String)
*/
@Override
public Object getFileSystem() {
public int importFileAsItem(URI file, String itemType) {
// Pass the call on to the core
return Integer.valueOf(getCore().importFileAsItem(file, itemType));
}
@Override
public void doSave(IProgressMonitor monitor) {
// TODO Auto-generated method stub
return getCore().getFileSystem(1);
}
@Override
public int importFileAsItem(URI file, String itemType) {
public void doSaveAs() {
// TODO Auto-generated method stub
// Pass the call on to the core
return Integer.valueOf(getCore().importFileAsItem(file, itemType));
}
@Override
public void init(IEditorSite site, IEditorInput input)
throws PartInitException {
throwSimpleError("It's working!");
}
@Override
public boolean isDirty() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isSaveAsAllowed() {
// TODO Auto-generated method stub
return false;
}
@Override
public void createPartControl(Composite parent) {
// TODO Auto-generated method stub
}
@Override
public void setFocus() {
// TODO Auto-generated method stub
}
......
......@@ -29,18 +29,6 @@ import org.eclipse.ice.iclient.uiwidgets.IWidgetFactory;
* @author Jay Jay Billings
*/
public interface IClient {
/**
* <p>
* This operation retrieves a representation of the file system from the
* Core.
* </p>
*
* @return <p>
* A hierarchical list of the workspace directories available to the
* Eclipse User.
* </p>
*/
public Object getFileSystem();
/**
* <p>
......
......@@ -40,33 +40,30 @@ import org.junit.Test;
* <p>
* The FormTester is responsible for testing the Form class.
* </p>
*
*
* @author Jay Jay Billings
*/
public class FormTester {
/**
* The form to be tested
*/
private Form form;
/**
*
* A data component used in the form
*/
private DataComponent dataComponent;
/**
* <p>
* The TestComponentListener used to subscribe to and check notifications
* from the Form.
* </p>
*
*/
private TestComponentListener testComponentListener;
/**
* <p>
* This operation tests the Form by calling the constructor and checking the
* getters and setters for the operations inherited from ICEObject.
* </p>
*/
@Test
public void checkCreation() {
......@@ -160,7 +157,7 @@ public class FormTester {
* IComponentListener against it and making sure that it receives status
* updates from the Form class.
* </p>
*
*
*/
@Test
public void checkNotifications() {
......@@ -193,7 +190,7 @@ public class FormTester {
* is consistent. It also checks that getActionList() returns null for a
* Form created with a null value for the list of Actions.
* </p>
*
*
*/
@Test
public void checkActionList() {
......@@ -228,7 +225,7 @@ public class FormTester {
* This operation checks the Form by making sure that it can be marked as
* ready or not ready.
* </p>
*
*
*/
@Test
public void checkReadiness() {
......@@ -254,7 +251,7 @@ public class FormTester {
* This operation checks the Form to insure that its equals() operation
* works.
* </p>
*
*
*/
@Test
public void checkEquality() {
......@@ -393,7 +390,7 @@ public class FormTester {
* This operation checks the Form to ensure that its copy() and clone()
* operations work as specified.
* </p>
*
*
*/
@Test
public void checkCopying() {
......@@ -502,10 +499,10 @@ public class FormTester {
* This operation checks the ability of the Form to persist itself to XML
* and to load itself from an XML input stream.
* </p>
* @throws IOException
* @throws JAXBException
* @throws NullPointerException
*
* @throws IOException
* @throws JAXBException
* @throws NullPointerException
*
*/
@Test
public void checkXMLPersistence() throws NullPointerException, JAXBException, IOException {
......@@ -523,10 +520,10 @@ public class FormTester {
ArrayList<String> actionList = new ArrayList<String>();
ICEJAXBHandler xmlHandler = new ICEJAXBHandler();
ArrayList<Class> classList = new ArrayList<Class>();
// Inform the JAXBContext of all relevant classes.
// Inform the JAXBContext of all relevant classes.
classList.addAll(new ICEJAXBClassProvider().getClasses());
DataComponent dataComponent = new DataComponent();
DataComponent dataComponent2 = new DataComponent();
Entry entry1 = new Entry();
......@@ -626,7 +623,7 @@ public class FormTester {
// create a new instance of a different variable to compare
loadedForm = new Form();
// load into Form();
// load into Form
loadedForm = (Form) xmlHandler.read(classList, inputStream);
/* check contents */
......
......@@ -6,9 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Initial API and implementation and/or initial documentation - Jay Jay Billings,
* Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson,
* Claire Saunders, Matthew Wang, Anna Wojtowicz
* Initial API and implementation and/or initial documentation -
* Jay Jay Billings
*******************************************************************************/
package org.eclipse.ice.datastructures.ICEObject;
......@@ -25,7 +24,7 @@ import javax.xml.bind.Unmarshaller;
/**
* This class is responsible for reading and writing JAXB-annotated classes into
* and out of ICE.
*
*
* @author Jay Jay Billings
*/
public class ICEJAXBHandler {
......@@ -33,7 +32,7 @@ public class ICEJAXBHandler {
/**
* This operation reads an instance of a particular class type from the
* input stream into a Java Object.
*
*
* @param classList
* The class list from which JAXB annotations should be read.
* @param inputStream
......@@ -77,7 +76,7 @@ public class ICEJAXBHandler {
* input stream into a Java Object. This operation requires both the Object
* and the specific class type because some classes, such as local classes,
* do return the appropriate class type from a call to "this.getClass()."
*
*
* @param dataObject
* An Object that is an instance of the Class that is parsed to
* create the XML InputStream.
......
/**
*
*/
package org.eclipse.ice.persistence.xml.test;
/*******************************************************************************
* 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Initial API and implementation and/or initial documentation -
* Jay Jay Billings
*******************************************************************************/
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import org.eclipse.core.runtime.content.ITextContentDescriber;
import org.eclipse.ice.persistence.xml.XMLFormContentDescriber;
import org.junit.Ignore;
import org.junit.Test;
/**
* This class is responsible for testing
* {@link org.eclipse.ice.persistence.xml.XMLFormContentDescriber}.
*
* @author Jay Jay Billings
*
*/
public class XMLFormContentDescriberTester {
// Load some text from a VIBE KV Pair Item.
String xmlForm = "<?xml version=\"1.0\" encoding=\"UTF-8\" "
+ "standalone=\"yes\"?><VibeKVPair itemType=\"Model\" "
+ "status=\"2\" builderName=\"VIBE Key-Value Pair\" "
+ "description=\"Generate input files for VIBE.\" id=\"1\" "
+ "name=\"VIBE Key-Value Pair\"><Form itemID=\"1\" "
+ "description=\"Generate input files for VIBE.\" id=\"1\" "
+ "name=\"VIBE Key-Value Pair\">"
+ "<componentList></componentList></Form><AllowedActions>Export "
+ "to key-value pair output</AllowedActions><itemBuilderName>"
+ "VIBE Key-Value Pair</itemBuilderName></VibeKVPair>";
/**
* Test method for
* {@link org.eclipse.ice.persistence.xml.XMLFormContentDescriber#describe(java.io.InputStream, org.eclipse.core.runtime.content.IContentDescription)}
* .
*
* It is sufficient to only test the first describe() operation since it
* delegates the work to the second.
*
* @throws IOException
* This exception is thrown if the stream cannot be read for
* some reason.
*/
@Test
public void testDescribe() throws IOException {
// Test with valid text.
assertEquals(ITextContentDescriber.VALID, runTest(xmlForm));
return;
}
/**
* Test method for
* {@link org.eclipse.ice.persistence.xml.XMLFormContentDescriber#getSupportedOptions()}
* .
*/
@Ignore
@Test
public void testGetSupportedOptions() {
fail("Not yet implemented");
return;
}
/**
* Test method for
* {@link org.eclipse.ice.persistence.xml.XMLFormContentDescriber#describe(java.io.Reader, org.eclipse.core.runtime.content.IContentDescription)}
* .
*/
@Test
public void testBadText() {
// Test with bad text.
try {
assertEquals(ITextContentDescriber.INVALID, runTest("foo"));
} catch (IOException e) {
// Complain and fail since these cases should not have produced
// IOExceptions.
e.printStackTrace();
fail();
}
return;
}
/**
* This operation runs the actual tests in place of the individual test
* operations.
*
* @param text
* The text that should be used in the test.
* @throws IOException
* This exception is thrown if there is an IO error.
*/
private int runTest(String text) throws IOException {
// Create the describer
XMLFormContentDescriber describer = new XMLFormContentDescriber();
// Convert the text to an input stream
ByteArrayInputStream stream = new ByteArrayInputStream(text.getBytes());
// Check the text
return describer.describe(stream, null);
}
}
......@@ -9,7 +9,7 @@
* Initial API and implementation and/or initial documentation -
* Jay Jay Billings
*******************************************************************************/
package xmlpp.test;
package org.eclipse.ice.persistence.xml.test;
import static org.junit.Assert.*;
......
......@@ -10,7 +10,7 @@
* Jordan H. Deyton, Dasha Gorin, Alexander J. McCaskey, Taylor Patterson,
* Claire Saunders, Matthew Wang, Anna Wojtowicz
*******************************************************************************/
package xmlpp.test;
package org.eclipse.ice.persistence.xml.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
......
......@@ -25,5 +25,17 @@
class="org.eclipse.ice.persistence.xml.XMLPersistenceExtensionFactory">
</implementation>
</extension>
<extension
id="org.eclipse.ice.persistence.xml.contentTypes"
name="ICE XML Content Type"
point="org.eclipse.core.contenttype.contentTypes">
<content-type
base-type="org.eclipse.core.runtime.xml"
describer="org.eclipse.ice.persistence.xml.XMLFormContentDescriber"
file-extensions="xml"
id="org.eclipse.ice.persistence.xml.contentType.Form"
name="ICE Form"
priority="normal">
</content-type>
</extension>
</plugin>
/*******************************************************************************
* 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Initial API and implementation and/or initial documentation -
* Jay Jay Billings
*******************************************************************************/
package org.eclipse.ice.persistence.xml;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;