import java.io.IOException;
import java.util.Collections;
import java.util.Map;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.XMIResource;
import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
import com.founder.fix.bpmn2extensions.connector.Connector;
import com.founder.fix.bpmn2extensions.connector.ConnectorFactory;
import com.founder.fix.bpmn2extensions.connector.ConnectorPackage;
import com.founder.fix.bpmn2extensions.connectormenu.ConnectormenuFactory;
import com.founder.fix.bpmn2extensions.connectormenu.Menu;
import com.founder.fix.bpmn2extensions.connectormenu.Node;
import com.founder.fix.bpmn2extensions.flowconnector.FlowConnectorDefinition;
import com.founder.fix.bpmn2extensions.flowconnector.FlowConnectorFactory;
import com.founder.fix.bpmn2extensions.flowconnector.FlowConnectorPackage;
import com.founder.fix.bpmn2extensions.flowconnector.Input;
import com.founder.fix.bpmn2extensions.flowconnector.Items;
import com.founder.fix.bpmn2extensions.flowconnector.Page;
import com.founder.fix.bpmn2extensions.flowconnector.Password;
import com.founder.fix.bpmn2extensions.flowconnector.Select;
import com.founder.fix.bpmn2extensions.flowconnector.Text;
import com.founder.fix.bpmn2extensions.flowconnector.Widget;
import com.founder.fix.bpmn2extensions.flowconnector.util.FlowConnectorResourceImpl;
import com.founder.fix.bpmn2extensions.sqlmappingconfig.DataBaseTableConfig;
import com.founder.fix.bpmn2extensions.sqlmappingconfig.SqlMappingConfig;
import com.founder.fix.bpmn2extensions.sqlmappingconfig.SqlmappingconfigFactory;
import com.founder.fix.bpmn2extensions.sqlmappingconfig.SqlmappingconfigPackage;
public class test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
ConnectormenuFactory.eINSTANCE.eClass();
Menu flowConnectorDefinition=ConnectormenuFactory.eINSTANCE.createMenu();
Node node=ConnectormenuFactory.eINSTANCE.createNode();
node.setId("1");
Node node1=ConnectormenuFactory.eINSTANCE.createNode();
Node node2=ConnectormenuFactory.eINSTANCE.createNode();
node.getNode().add(node1);
node.getNode().add(node2);
flowConnectorDefinition.getNode().add(node);
// As of here we preparing to save the model content
// Register the XMI resource factory for the .website extension
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
Map<String, Object> m = reg.getExtensionToFactoryMap();
m.put("xml", new XMIResourceFactoryImpl());
// Obtain a new resource set
FlowConnectorResourceImpl resource = new FlowConnectorResourceImpl(URI
.createURI("website/My1.xml"));
resource.setEncoding("UTF-8");
resource.getContents().add(flowConnectorDefinition);
try {
resource.save(Collections.EMPTY_MAP);
} catch (IOException e) {
e.printStackTrace();
}
//resource.getDefaultSaveOptions().put(XMLResource.OPTION_KEEP_DEFAULT_CONTENT, Boolean.TRUE);
// Now save the content.
try {
resource.save(Collections.EMPTY_MAP);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//load();
}
public static FlowConnectorDefinition load() {
// Initialize the model
ConnectorPackage.eINSTANCE.eClass();
// Register the XMI resource factory for the .website extension
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
Map<String, Object> m = reg.getExtensionToFactoryMap();
m.put("xml", new XMIResourceFactoryImpl());
// Obtain a new resource set
ResourceSet resSet = new ResourceSetImpl();
// Get the resource
Resource resource = resSet.getResource(URI.createURI("website/My1.xml"), true);
// Get the first model element and cast it to the right type, in my
// example everything is hierarchical included in this first node
FlowConnectorDefinition myWeb = (FlowConnectorDefinition) resource.getContents().get(0);
Select select=(Select)myWeb.getPage().get(0).getWidget().get(0);
//select.getItems().get(0).getMixed();
return myWeb;
}
}