本文整理汇总了Java中org.eclipse.emf.transaction.TransactionalEditingDomain.dispose方法的典型用法代码示例。如果您正苦于以下问题:Java TransactionalEditingDomain.dispose方法的具体用法?Java TransactionalEditingDomain.dispose怎么用?Java TransactionalEditingDomain.dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.transaction.TransactionalEditingDomain
的用法示例。
在下文中一共展示了TransactionalEditingDomain.dispose方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fillDiagramFromPtolemyModel
import org.eclipse.emf.transaction.TransactionalEditingDomain; //导入方法依赖的package包/类
/**
* Iterate over all model elements in a Ptolemy II model, create corresponding elements in a Triq workflow diagram, and store the diagram file in the given
* destination folder.
*
* @param destFolder
* @param diagram
* @param ptolemyModel
* @return
*/
public static Diagram fillDiagramFromPtolemyModel(IFolder destFolder, Diagram diagram, ptolemy.actor.CompositeActor ptolemyModel) {
// Get the default resource set to hold the new resource
ResourceSet resourceSet = new ResourceSetImpl();
TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(resourceSet);
if (editingDomain == null) {
editingDomain = TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain(resourceSet);
}
FillDiagramFromPtolemyModelCommand operation = new FillDiagramFromPtolemyModelCommand(destFolder, editingDomain, diagram, ptolemyModel);
editingDomain.getCommandStack().execute(operation);
try {
operation.getCreatedResource().save(Collections.EMPTY_MAP);
} catch (IOException e) {
e.printStackTrace();
}
// Dispose the editing domain to eliminate memory leak
editingDomain.dispose();
return diagram;
}
示例2: 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();
}
示例3: run
import org.eclipse.emf.transaction.TransactionalEditingDomain; //导入方法依赖的package包/类
@Override
public void run() {
InputDialog inputDialog = new InputDialog(null, "Provide String", "Provide a new Name for the EClass", eclass.getName(), null);
int open = inputDialog.open();
if (open == Dialog.OK) {
String newName = inputDialog.getValue();
Resource resource = eclass.eResource();
ResourceSet resourceSet = resource.getResourceSet();
TransactionalEditingDomain domain = TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain(resourceSet);
try{
if (domain != null){
Command setCommand = domain.createCommand(SetCommand.class, new CommandParameter(eclass,
EcorePackage.Literals.ENAMED_ELEMENT__NAME, newName));
domain.getCommandStack().execute(setCommand);
try {
resource.save(Collections.emptyMap());
} catch (IOException e) {
e.printStackTrace();
}
}
}finally{
domain.dispose();
}
}
}
示例4: createDiagram
import org.eclipse.emf.transaction.TransactionalEditingDomain; //导入方法依赖的package包/类
public static ImportBpmnElementsCommand createDiagram(String processName, String bpmnFile,
IProject project, IContainer targetFolder) {
// Get the default resource set to hold the new resource
ResourceSet resourceSet = new ResourceSetImpl();
TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(resourceSet);
if (editingDomain == null) {
// Not yet existing, create one
editingDomain = TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain(resourceSet);
}
// Create the data within a command and save (must not happen inside
// the command since finishing the command will trigger setting the
// modification flag on the resource which will be used by the save
// operation to determine which resources need to be saved)
ImportBpmnElementsCommand operation = new ImportBpmnElementsCommand(
editingDomain, processName, bpmnFile, targetFolder);
editingDomain.getCommandStack().execute(operation);
try {
operation.getCreatedResource().save(null);
} catch (IOException e) {
IStatus status = new Status(IStatus.ERROR, ActivitiPlugin.getID(), e.getMessage(), e); //$NON-NLS-1$
ErrorDialog.openError(Display.getCurrent().getActiveShell(), "Error Occured", e.getMessage(), status);
}
// Dispose the editing domain to eliminate memory leak
editingDomain.dispose();
return operation;
}
示例5: doSave
import org.eclipse.emf.transaction.TransactionalEditingDomain; //导入方法依赖的package包/类
@Override
public void doSave(IProgressMonitor progressMonitor) {
super.doSave(progressMonitor);
IFile associatedBPMN2File = ((IFileEditorInput) getEditorInput()).getFile();
final IFile diagramFile = getAssociatedDiagramIFile(associatedBPMN2File);
if(diagramFile.exists() == false) {
String bpmnFile = associatedBPMN2File.getRawLocation().toFile().getAbsolutePath();
String processName = bpmnFile.substring(bpmnFile.lastIndexOf(File.separator) + 1);
processName = processName.replace(".xml", "");
processName = processName.replace(".bpmn20", "");
ImportBpmnUtil.createDiagram(processName, bpmnFile,
associatedBPMN2File.getProject(), associatedBPMN2File.getParent());
} else {
ResourceSet resourceSet = new ResourceSetImpl();
TransactionalEditingDomain domain = TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain(resourceSet);
final Diagram diagram = GraphitiUiInternal.getEmfService().getDiagramFromFile(diagramFile, domain.getResourceSet());
domain.getResourceSet().getResources().add(diagram.eResource());
try {
final IStorage storage = ((IFileEditorInput) getEditorInput()).getStorage();
DiagramUpdater operation = new DiagramUpdater(
domain, diagram, storage);
domain.getCommandStack().execute(operation);
diagram.eResource().save(null);
} catch (Exception e) {
IStatus status = new Status(IStatus.ERROR, ActivitiPlugin.getID(), e.getMessage(), e); //$NON-NLS-1$
ErrorDialog.openError(Display.getCurrent().getActiveShell(), "Failed to synchronize Activiti model file", e.getMessage(), status);
}
// Dispose the editing domain to eliminate memory leak
domain.dispose();
}
}