本文整理汇总了Java中org.eclipse.emf.transaction.TransactionalEditingDomain.getResourceSet方法的典型用法代码示例。如果您正苦于以下问题:Java TransactionalEditingDomain.getResourceSet方法的具体用法?Java TransactionalEditingDomain.getResourceSet怎么用?Java TransactionalEditingDomain.getResourceSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.transaction.TransactionalEditingDomain
的用法示例。
在下文中一共展示了TransactionalEditingDomain.getResourceSet方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: notifySirius
import org.eclipse.emf.transaction.TransactionalEditingDomain; //导入方法依赖的package包/类
/**
* Notifies Sirius about a change in the given {@link DSLBreakpoint}.
*
* @param instructionUri
* the {@link URI} of the instruction to refresh.
*/
public void notifySirius(Set<URI> instructionUris) {
final Map<String, Set<String>> toRefresh = representationToRefresh;
for (IEditingSession session : SessionUIManager.INSTANCE
.getUISessions()) {
final TransactionalEditingDomain transactionalEditingDomain = session
.getSession().getTransactionalEditingDomain();
final ResourceSet resourceSet = transactionalEditingDomain
.getResourceSet();
final boolean instructionPresent = isOneInstructionPresent(
instructionUris, resourceSet);
if (instructionPresent) {
final List<DRepresentation> representations = getRepresentationsToRefresh(
toRefresh, session);
refreshRepresentations(transactionalEditingDomain,
representations);
}
}
}
示例2: execute
import org.eclipse.emf.transaction.TransactionalEditingDomain; //导入方法依赖的package包/类
public static Object execute(TransactionalEditingDomain editingDomain, RecordingCommand command) {
final CommandStack commandStack = editingDomain.getCommandStack();
ResourceSet rs = editingDomain.getResourceSet();
IExecutionCheckpoint checkpoint = IExecutionCheckpoint.CHECKPOINTS.get(rs);
Object result = null;
try {
if (checkpoint != null) {
checkpoint.allow(rs, true);
}
commandStack.execute(command);
if (command.getResult() != null && command.getResult().size() == 1) {
result = command.getResult().iterator().next();
}
} finally {
if (checkpoint != null) {
checkpoint.allow(rs, false);
}
}
return result;
}
示例3: createEmfFileForDiagram
import org.eclipse.emf.transaction.TransactionalEditingDomain; //导入方法依赖的package包/类
public static void createEmfFileForDiagram(URI diagramResourceUri, final Diagram diagram) {
// Create a resource set and EditingDomain
final TransactionalEditingDomain editingDomain = GraphitiUiInternal.getEmfService().createResourceSetAndEditingDomain();
final ResourceSet resourceSet = editingDomain.getResourceSet();
// Create a resource for this file.
final Resource resource = resourceSet.createResource(diagramResourceUri);
final CommandStack commandStack = editingDomain.getCommandStack();
commandStack.execute(new RecordingCommand(editingDomain) {
@Override
protected void doExecute() {
resource.setTrackingModification(true);
resource.getContents().add(diagram);
}
});
save(editingDomain, Collections.<Resource, Map<?, ?>> emptyMap());
editingDomain.dispose();
}
示例4: run
import org.eclipse.emf.transaction.TransactionalEditingDomain; //导入方法依赖的package包/类
/**
* @generated
*/
public void run(IAction action) {
TransactionalEditingDomain editingDomain = GMFEditingDomainFactory.INSTANCE
.createEditingDomain();
ResourceSet resourceSet = editingDomain.getResourceSet();
EObject diagramRoot = null;
try {
Resource resource = resourceSet.getResource(domainModelURI, true);
diagramRoot = (EObject) resource.getContents().get(0);
} catch (WrappedException ex) {
StatemachineDiagramEditorPlugin.getInstance().logError(
"Unable to load resource: " + domainModelURI, ex); //$NON-NLS-1$
}
if (diagramRoot == null) {
MessageDialog.openError(getShell(),
Messages.InitDiagramFile_ResourceErrorDialogTitle,
Messages.InitDiagramFile_ResourceErrorDialogMessage);
return;
}
Wizard wizard = new StatemachineNewDiagramFileWizard(domainModelURI,
diagramRoot, editingDomain);
wizard.setWindowTitle(NLS.bind(Messages.InitDiagramFile_WizardTitle,
StatemachineEditPart.MODEL_ID));
StatemachineDiagramEditorUtil.runWizard(getShell(), wizard,
"InitDiagramFile"); //$NON-NLS-1$
}
示例5: createDiagram
import org.eclipse.emf.transaction.TransactionalEditingDomain; //导入方法依赖的package包/类
/**
* Create a diagram with given URIs.
*
* @param diagramURI
* URI for the diagram file
* @param modelURI
* URI for the model file
* @param progressMonitor
* progress monitor
* @return a resource for the new diagram file
*/
private Resource createDiagram(final URI diagramURI, final URI modelURI,
final IProgressMonitor progressMonitor) {
progressMonitor.beginTask("Creating diagram and model files", 2);
// create a resource set and editing domain
TransactionalEditingDomain editingDomain = GraphitiUi.getEmfService()
.createResourceSetAndEditingDomain();
ResourceSet resourceSet = editingDomain.getResourceSet();
CommandStack commandStack = editingDomain.getCommandStack();
// create resources for the diagram and domain model files
final Resource diagramResource = resourceSet.createResource(diagramURI);
final Resource modelResource = resourceSet.createResource(modelURI);
if (diagramResource != null && modelResource != null) {
commandStack.execute(new RecordingCommand(editingDomain) {
@Override
protected void doExecute() {
createModel(diagramResource, diagramURI.lastSegment(), modelResource,
modelURI.lastSegment());
}
});
progressMonitor.worked(1);
try {
modelResource.save(createSaveOptions());
diagramResource.save(createSaveOptions());
} catch (IOException exception) {
IStatus status = new Status(IStatus.ERROR, PLUGIN_ID,
"Unable to store model and diagram resources", exception);
StatusManager.getManager().handle(status);
}
setCharset(WorkspaceSynchronizer.getFile(modelResource));
setCharset(WorkspaceSynchronizer.getFile(diagramResource));
}
progressMonitor.done();
return diagramResource;
}
示例6: createEmfFileForDiagram
import org.eclipse.emf.transaction.TransactionalEditingDomain; //导入方法依赖的package包/类
public static TransactionalEditingDomain createEmfFileForDiagram(URI diagramResourceUri, final Diagram diagram,
final InputStream contentStream, final IFile resourceFile) {
// Create a resource set and EditingDomain
final TransactionalEditingDomain editingDomain = DiagramEditorFactory.createResourceSetAndEditingDomain();
final ResourceSet resourceSet = editingDomain.getResourceSet();
// Create a resource for this file.
final Resource resource = resourceSet.createResource(diagramResourceUri);
final CommandStack commandStack = editingDomain.getCommandStack();
commandStack.execute(new RecordingCommand(editingDomain) {
@Override
protected void doExecute() {
resource.setTrackingModification(true);
if (contentStream == null) {
resource.getContents().add(diagram);
} else {
try {
resourceFile.create(contentStream, IResource.FORCE, null);
} catch (CoreException e) {
// TODO
e.printStackTrace();
}
}
}
});
save(editingDomain, Collections.<Resource, Map<?, ?>> emptyMap());
return editingDomain;
}