本文整理汇总了Java中org.eclipse.emf.cdo.eresource.CDOResource类的典型用法代码示例。如果您正苦于以下问题:Java CDOResource类的具体用法?Java CDOResource怎么用?Java CDOResource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CDOResource类属于org.eclipse.emf.cdo.eresource包,在下文中一共展示了CDOResource类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: startCDOServer
import org.eclipse.emf.cdo.eresource.CDOResource; //导入依赖的package包/类
@BeforeClass
public static void startCDOServer() throws IOException, CommitException {
server = new CDOServer(false);
server.start();
IConnector connector = M2DocCDOUtils
.getConnector(CDOServer.PROTOCOL + "://" + CDOServer.IP + ":" + CDOServer.PORT);
CDOSession session = M2DocCDOUtils.openSession(connector, CDOServer.REPOSITORY_NAME, CDOServer.USER_NAME,
CDOServer.PASSWORD);
final CDOTransaction transaction = M2DocCDOUtils.openTransaction(session);
final CDOResource resource = transaction.createResource("anydsl.ecore");
final ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl());
final Resource anyDSLResource = resourceSet.getResource(URI.createFileURI("resources/anydsl.ecore"), true);
resource.getContents().addAll(anyDSLResource.getContents());
resource.save(null);
transaction.commit();
transaction.close();
session.close();
connector.close();
if (!EMFPlugin.IS_ECLIPSE_RUNNING) {
ConfigurationProviderService.getInstance().register(CONFIGURATION_PROVIDER);
M2DocUtils.registerServicesConfigurator(SERVICES_CONFIGURATOR_DESCRIPTOR);
}
}
开发者ID:ObeoNetwork,项目名称:M2Doc,代码行数:26,代码来源:ServerWithoutAuthentication.java
示例2: startCDOServer
import org.eclipse.emf.cdo.eresource.CDOResource; //导入依赖的package包/类
@BeforeClass
public static void startCDOServer() throws IOException, CommitException {
server = new CDOServer(true);
server.start();
IConnector connector = M2DocCDOUtils
.getConnector(CDOServer.PROTOCOL + "://" + CDOServer.IP + ":" + CDOServer.PORT);
CDOSession session = M2DocCDOUtils.openSession(connector, CDOServer.REPOSITORY_NAME, CDOServer.USER_NAME,
CDOServer.PASSWORD);
final CDOTransaction transaction = M2DocCDOUtils.openTransaction(session);
final CDOResource resource = transaction.createResource("anydsl.ecore");
final ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl());
final Resource anyDSLResource = resourceSet.getResource(URI.createFileURI("resources/anydsl.ecore"), true);
resource.getContents().addAll(anyDSLResource.getContents());
resource.save(null);
transaction.commit();
transaction.close();
session.close();
connector.close();
if (!EMFPlugin.IS_ECLIPSE_RUNNING) {
ConfigurationProviderService.getInstance().register(CONFIGURATION_PROVIDER);
M2DocUtils.registerServicesConfigurator(SERVICES_CONFIGURATOR_DESCRIPTOR);
}
}
开发者ID:ObeoNetwork,项目名称:M2Doc,代码行数:26,代码来源:ServerWithAuthentication.java
示例3: createUsers
import org.eclipse.emf.cdo.eresource.CDOResource; //导入依赖的package包/类
private static void createUsers(CDOTransaction transaction) {
CDOResource r1 = transaction.getOrCreateResource("u1");
r1.getContents().clear();
User u1 = ModelFactory.eINSTANCE.createUser();
u1.setName("Bob");
r1.getContents().add(u1);
CDOResource r2 = transaction.getOrCreateResource("u2");
r2.getContents().clear();
User u2 = ModelFactory.eINSTANCE.createUser();
u2.setName("Peter");
u2.getFriends().add(u1);
r2.getContents().add(u2);
}
开发者ID:emfjson,项目名称:emfjson-samples,代码行数:17,代码来源:Main.java
示例4: getElementResource
import org.eclipse.emf.cdo.eresource.CDOResource; //导入依赖的package包/类
@Test
public void getElementResource() throws Exception {
final IBase base = new BaseRegistryTests.TestBase();
base.getFactory().addDescriptor(ICDORepositoryLocation.class,
new BaseElementFactory.FactoryDescriptor<TestCDORepositoryLocation>(
TestCDORepositoryLocation.class));
base.getFactory().addDescriptor(ICDOResourceLocation.class,
new BaseElementFactory.FactoryDescriptor<TestCDOResourceLocation>(
TestCDOResourceLocation.class));
final ILocation container = MappingUtils.getConnectorRegistry().createLocation(base, transaction);
final TestCDOFolderLocation location = new TestCDOFolderLocation();
location.setContainer(container);
location.setPath(resource.getPath());
final Object element = connector.getElement(location);
assertTrue(element instanceof CDOResource);
assertEquals(resource.getPath(), ((CDOResource)element).getPath());
}
开发者ID:ModelWriter,项目名称:Source,代码行数:22,代码来源:CDOResourceNodeConnectorTests.java
示例5: attacheObject
import org.eclipse.emf.cdo.eresource.CDOResource; //导入依赖的package包/类
@Test
public void attacheObject() throws Exception {
final CDOMappingBaseListener listener = new CDOMappingBaseListener();
final String path = this.getClass().getCanonicalName() + "/attacheObject.resource";
final CDOResource resource = transaction.createResource(path);
resource.save(null);
transaction.commit();
transaction.getSession().addListener(listener);
final ProductionCompany eObject = AnydslPackage.eINSTANCE.getAnydslFactory()
.createProductionCompany();
resource.getContents().add(eObject);
eObject.setName("MyCompany");
resource.save(null);
transaction.commit();
transaction.getSession().removeListener(listener);
assertEquals(0, MappingUtils.getMappingRegistry().getBases().size());
}
开发者ID:ModelWriter,项目名称:Source,代码行数:21,代码来源:CDOMappingBaseListenerTests.java
示例6: detacheObject
import org.eclipse.emf.cdo.eresource.CDOResource; //导入依赖的package包/类
@Test
public void detacheObject() throws Exception {
final CDOMappingBaseListener listener = new CDOMappingBaseListener();
final String path = this.getClass().getCanonicalName() + "/detacheObject.resource";
final CDOResource resource = transaction.createResource(path);
final ProductionCompany eObject = AnydslPackage.eINSTANCE.getAnydslFactory()
.createProductionCompany();
resource.getContents().add(eObject);
eObject.setName("MyCompany");
resource.save(null);
transaction.commit();
transaction.getSession().addListener(listener);
resource.getContents().clear();
resource.save(null);
transaction.commit();
transaction.getSession().removeListener(listener);
assertEquals(0, MappingUtils.getMappingRegistry().getBases().size());
}
开发者ID:ModelWriter,项目名称:Source,代码行数:22,代码来源:CDOMappingBaseListenerTests.java
示例7: attacheBase
import org.eclipse.emf.cdo.eresource.CDOResource; //导入依赖的package包/类
@Test
public void attacheBase() throws Exception {
final CDOMappingBaseListener listener = new CDOMappingBaseListener();
final String path = this.getClass().getCanonicalName() + "/attacheBase.resource";
final CDOResource resource = transaction.createResource(path);
resource.save(null);
transaction.commit();
transaction.getSession().addListener(listener);
final Base eObject = MappingPackage.eINSTANCE.getMappingFactory().createBase();
resource.getContents().add(eObject);
eObject.setName("MyBase");
resource.save(null);
transaction.commit();
transaction.getSession().removeListener(listener);
assertEquals(1, MappingUtils.getMappingRegistry().getBases().size());
assertEquals("MyBase", MappingUtils.getMappingRegistry().getBases().iterator().next().getName());
MappingUtils.getMappingRegistry().unregister(eObject);
}
开发者ID:ModelWriter,项目名称:Source,代码行数:22,代码来源:CDOMappingBaseListenerTests.java
示例8: detacheBase
import org.eclipse.emf.cdo.eresource.CDOResource; //导入依赖的package包/类
@Test
public void detacheBase() throws Exception {
final CDOMappingBaseListener listener = new CDOMappingBaseListener();
transaction.getSession().addListener(listener);
final String path = this.getClass().getCanonicalName() + "/detacheBase.resource";
final CDOResource resource = transaction.createResource(path);
final Base eObject = MappingPackage.eINSTANCE.getMappingFactory().createBase();
resource.getContents().add(eObject);
eObject.setName("MyBase");
resource.save(null);
transaction.commit();
assertEquals(1, MappingUtils.getMappingRegistry().getBases().size());
assertEquals("MyBase", MappingUtils.getMappingRegistry().getBases().iterator().next().getName());
resource.getContents().clear();
resource.save(null);
transaction.commit();
transaction.getSession().removeListener(listener);
assertEquals(0, MappingUtils.getMappingRegistry().getBases().size());
}
开发者ID:ModelWriter,项目名称:Source,代码行数:24,代码来源:CDOMappingBaseListenerTests.java
示例9: getLocationType
import org.eclipse.emf.cdo.eresource.CDOResource; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @see org.eclipse.mylyn.docs.intent.mapping.connector.IConnector#getLocationType(java.lang.Class,
* java.lang.Object)
*/
public Class<? extends ILocation> getLocationType(Class<? extends ILocationContainer> containerType,
Object element) {
final Class<? extends ILocation> res;
if (element instanceof CDOResource) {
res = ICDOResourceLocation.class;
} else if (element instanceof CDOTextResource) {
// TODO text file delegates ?
res = ICDOTextResourceLocation.class;
} else if (element instanceof CDOBinaryResource) {
// TODO binary file delegates ?
res = ICDOBinaryResourceLocation.class;
} else if (element instanceof CDOResourceFolder) {
res = ICDOFolderLocation.class;
} else {
res = null;
}
return res;
}
开发者ID:ModelWriter,项目名称:Source,代码行数:27,代码来源:CDOResourceNodeConnector.java
示例10: getContainer
import org.eclipse.emf.cdo.eresource.CDOResource; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @see org.eclipse.mylyn.docs.intent.mapping.connector.IContainerProvider#getContainer(java.lang.Object)
*/
public Object getContainer(Object element) {
final Object res;
if (element instanceof CDOResource) {
res = ((CDOResource)element).cdoView();
} else if (element instanceof EObject) {
final Resource resource = ((EObject)element).eResource();
if (resource instanceof CDOResource) {
res = resource;
} else {
res = null;
}
} else {
res = null;
}
return res;
}
开发者ID:ModelWriter,项目名称:Source,代码行数:24,代码来源:CDOContainerProvider.java
示例11: getResource
import org.eclipse.emf.cdo.eresource.CDOResource; //导入依赖的package包/类
/**
* Gets the resource of the textual diagram in the commit's current version.
*
* @param commit
* the commit info of the commit
* @param currentView
* the current view on the diagram
* @return the corresponding resource
*/
public CDOResource getResource(CDOView currentView, IFile file) {
ConcreteSyntaxModel concreteSyntaxModel = getConcreteSyntaxModel(currentView, file);
if (concreteSyntaxModel == null) {
return null;
}
EObject rootElement = concreteSyntaxModel.getRootElement();
URI rootURI = EcoreUtil.getURI(rootElement);
String resourcePath = CDOURIUtil.extractResourcePath(rootURI);
try {
return currentView.getResource(resourcePath);
} catch (InvalidURIException e) {
LOGGER.trace(e.getMessage(), e);
return null;
}
}
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:25,代码来源:ComparisonManager.java
示例12: createAndRegisterResourceListener
import org.eclipse.emf.cdo.eresource.CDOResource; //导入依赖的package包/类
@Override
protected IListener createAndRegisterResourceListener(CDOResource r) {
IListener cdoChangeListener = new IListener() {
@Override
public void notifyEvent(IEvent event) {
if (event instanceof CDOViewInvalidationEvent) {
CDOViewInvalidationEvent realEvent = (CDOViewInvalidationEvent) event;
if (realEvent.getDirtyObjects().stream().map(o -> o.eResource())
.filter(r -> r instanceof CDOResource).anyMatch(getObservedResource()::equals)) {
handleResourceChange();
}
}
}
};
r.cdoView().addListener(cdoChangeListener);
return cdoChangeListener;
}
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:18,代码来源:CDOResourceChangeObserver.java
示例13: reloadResource
import org.eclipse.emf.cdo.eresource.CDOResource; //导入依赖的package包/类
private static void reloadResource(Resource r) throws IOException {
if (r instanceof CDOResource) {
CDOResource realResource = (CDOResource) r;
CDOSession session = realResource.cdoView().getSession();
if (session == null) {
throw new IOException("Could not refresh resource because session is not available.");
}
session.refresh();
} else {
r.unload();
ResourceSet rs = r.getResourceSet();
if (rs != null && rs.getURIConverter().exists(r.getURI(), Collections.emptyMap())) {
r.load(Collections.emptyMap());
}
}
}
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:17,代码来源:ReloadingResourceChangeManager.java
示例14: createEditorInput
import org.eclipse.emf.cdo.eresource.CDOResource; //导入依赖的package包/类
private IEditorInput createEditorInput() {
EObject rootElement = getConcreteSyntaxModel().getRootElement();
Resource r = createPlainResource(rootElement);
if (rootElement.eResource() instanceof CDOResource) {
r = createCDOResource(rootElement);
}
URI originalUri = r.getURI();
String[] segments = originalUri.segments();
String modelName = segments[segments.length - 1];
String resourceExtension = originalUri.fileExtension();
String plainName = modelName.replaceFirst("\\." + resourceExtension + "$", "");
String launcherName = plainName + ".di";
segments[segments.length - 1] = launcherName;
URI uriToLaunch = URI.createHierarchicalURI(originalUri.scheme(), originalUri.authority(), originalUri.device(),
segments, originalUri.query(), originalUri.fragment());
return new CooperateURIEditorInput(uriToLaunch, getLauncherFile());
}
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:20,代码来源:PapyrusCDOLauncher.java
示例15: createModelNodes
import org.eclipse.emf.cdo.eresource.CDOResource; //导入依赖的package包/类
private static ModelNode[] createModelNodes(IProject project) {
String resourceName = project.getName(); //TODO this should not be located here but at a central location
CDOSession session = CDOConnectionManager.getInstance().acquireSession(project);
try {
CDOView view = session.openView();
try {
if (!view.hasResource(resourceName)) {
return ArrayUtils.toArray();
}
CDOResourceFolder cdoFolder = view.getResourceFolder(resourceName);
return cdoFolder.getNodes().stream().filter(n -> "notation".equals(n.getExtension())).filter(CDOResource.class::isInstance).map(r -> new ModelNode(getBaseName(r))).toArray(ModelNode[]::new);
} finally {
IOUtil.closeSilent(view);
}
} finally {
CDOConnectionManager.getInstance().releaseSession(session);
}
}
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:19,代码来源:ModelContentProvider.java
示例16: getCDOView
import org.eclipse.emf.cdo.eresource.CDOResource; //导入依赖的package包/类
@Override
public Optional<CDOView> getCDOView() {
try {
IPageManager pageManager = getEditorPart().getServicesRegistry().getService(IPageManager.class);
Set<CDOView> cdoViews = pageManager.allPages().stream().filter(EObject.class::isInstance)
.map(EObject.class::cast).map(EObject::eResource).filter(CDOResource.class::isInstance)
.map(CDOResource.class::cast).map(CDOResource::cdoView).filter(Objects::nonNull)
.collect(Collectors.toSet());
if (cdoViews.isEmpty()) {
LOGGER.warn("Could not find CDO view.");
} else {
if (cdoViews.size() > 1) {
LOGGER.warn("Got multiple CDO views. Taking the first one.");
}
return Optional.of(cdoViews.iterator().next());
}
} catch (ServiceException e) {
LOGGER.warn("Could not load services registry.", e);
}
return Optional.empty();
}
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:22,代码来源:FocusManagerGraphical.java
示例17: saveNotation
import org.eclipse.emf.cdo.eresource.CDOResource; //导入依赖的package包/类
@Override
public void saveNotation() {
System.out.println("Saving notation");
CDOResource resource = generalTransaction.getOrCreateResource(concreteSyntaxPath); //$NON-NLS-1$
// try {
// resource.getContents().clear();
// resource.getContents().add(concreteSyntaxDefinition);
// resource.save(null);
// } catch (IOException e) {
// }
try {
generalTransaction.commit();
} catch (CommitException e) {
e.printStackTrace();
}
loadNotation();
}
开发者ID:SOM-Research,项目名称:collaboro,代码行数:22,代码来源:CDOModelManager.java
示例18: saveEcoreModel
import org.eclipse.emf.cdo.eresource.CDOResource; //导入依赖的package包/类
@Override
public void saveEcoreModel() {
System.out.println("Saving ecore model");
CDOResource resource = generalTransaction.getOrCreateResource(abstractSyntaxPath); //$NON-NLS-1$
// try {
// resource.getContents().clear();
// resource.getContents().add(ePackage);
// resource.save(null);
// } catch (IOException e) {
// }
try {
generalTransaction.commit();
} catch (CommitException e) {
e.printStackTrace();
}
loadEcoreModel();
}
开发者ID:SOM-Research,项目名称:collaboro,代码行数:22,代码来源:CDOModelManager.java
示例19: saveHistory
import org.eclipse.emf.cdo.eresource.CDOResource; //导入依赖的package包/类
@Override
public void saveHistory() {
System.out.println("Saving history");
CDOResource resource = generalTransaction.getOrCreateResource(historyPath); //$NON-NLS-1$
// try {
// resource.getContents().clear();
// resource.getContents().add(history);
// resource.save(null);
// } catch (IOException e) {
// }
try {
generalTransaction.commit();
} catch (CommitException e) {
e.printStackTrace();
}
loadHistory();
}
开发者ID:SOM-Research,项目名称:collaboro,代码行数:22,代码来源:CDOModelManager.java
示例20: getResources
import org.eclipse.emf.cdo.eresource.CDOResource; //导入依赖的package包/类
/**
* Lists {@link CDOResource} of the given {@link CDOView}.
*
* @param view
* the {@link CDOView}
* @return the {@link List} of {@link CDOResource} from the given {@link CDOView}
*/
public static List<CDOResource> getResources(CDOView view) {
final List<CDOResource> res = new ArrayList<CDOResource>();
for (EObject eObj : view.getRootResource().eContents()) {
res.add((CDOResource) eObj);
}
return res;
}
开发者ID:ObeoNetwork,项目名称:M2Doc,代码行数:17,代码来源:M2DocCDOUtils.java
注:本文中的org.eclipse.emf.cdo.eresource.CDOResource类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论