use of org.eclipse.emf.transaction.TransactionalEditingDomain in project tdi-studio-se by Talend.
the class BusinessDocumentProvider method saveDocumentToFile.
/**
* @generated
*/
protected void saveDocumentToFile(IDocument document, IFile file, boolean overwrite, IProgressMonitor monitor) throws CoreException {
Diagram diagram = (Diagram) document.getContent();
Resource diagramResource = diagram.eResource();
IDiagramDocument diagramDocument = (IDiagramDocument) document;
TransactionalEditingDomain domain = diagramDocument.getEditingDomain();
List resources = domain.getResourceSet().getResources();
//$NON-NLS-1$
monitor.beginTask("Saving diagram", resources.size() + 1);
super.saveDocumentToFile(document, file, overwrite, new SubProgressMonitor(monitor, 1));
for (Iterator it = resources.iterator(); it.hasNext(); ) {
Resource nextResource = (Resource) it.next();
//$NON-NLS-1$
monitor.setTaskName("Saving " + nextResource.getURI());
if (nextResource != diagramResource && nextResource.isLoaded()) {
try {
nextResource.save(Collections.EMPTY_MAP);
} catch (IOException e) {
BusinessDiagramEditorPlugin.getInstance().logError("Unable to save resource: " + nextResource.getURI(), //$NON-NLS-1$
e);
}
}
monitor.worked(1);
}
monitor.done();
}
use of org.eclipse.emf.transaction.TransactionalEditingDomain in project tdi-studio-se by Talend.
the class BusinessStructuralFeatureParser method getParseCommand.
/**
* @generated
*/
public ICommand getParseCommand(IAdaptable adapter, Object[] values) {
EObject element = (EObject) adapter.getAdapter(EObject.class);
if (element == null) {
return UnexecutableCommand.INSTANCE;
}
TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(element);
if (editingDomain == null) {
return UnexecutableCommand.INSTANCE;
}
Object value = values.length == 1 ? values[0] : null;
ICommand command = getModificationCommand(element, feature, value);
return new CompositeTransactionalCommand(editingDomain, command.getLabel(), Collections.singletonList(command));
}
use of org.eclipse.emf.transaction.TransactionalEditingDomain in project tdi-studio-se by Talend.
the class BusinessStructuralFeaturesParser method getParseCommand.
/**
* @generated
*/
public ICommand getParseCommand(IAdaptable adapter, Object[] values) {
EObject element = (EObject) adapter.getAdapter(EObject.class);
if (element == null) {
return UnexecutableCommand.INSTANCE;
}
TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(element);
if (editingDomain == null) {
return UnexecutableCommand.INSTANCE;
}
//$NON-NLS-1$
CompositeTransactionalCommand command = new CompositeTransactionalCommand(editingDomain, "Set Values");
for (int i = 0; i < values.length; i++) {
EStructuralFeature feature = (EStructuralFeature) features.get(i);
command.compose(getModificationCommand(element, feature, values[i]));
}
return command;
}
use of org.eclipse.emf.transaction.TransactionalEditingDomain in project Palladio-Editors-Sirius by PalladioSimulator.
the class OperationsEditorSection method createViewerCellEditors.
/* (non-Javadoc)
* @see org.palladiosimulator.editors.commons.tabs.generic.EditorSection#createViewerCellEditors(org.eclipse.swt.widgets.Table)
*/
@Override
protected CellEditor[] createViewerCellEditors(Table table) {
CellEditor[] editors = new CellEditor[columnNames.length];
editors[SIGNATURENAME_COLUMN_INDEX] = new TextCellEditor(table);
// create 'DeleteCellValueListener' and as SelectionListener to the 'TableVewer'
OperationDeleteCellValueListener cellValueListener = new OperationDeleteCellValueListener(viewer);
viewer.addSelectionChangedListener(cellValueListener);
editors[RETURNTYPE_COLUMN_INDEX] = new TypeDialogCellEditor(table, cellValueListener) {
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(org.eclipse.swt.widgets.Control)
*/
@Override
protected Object openDialogBox(Control cellEditorWindow) {
TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(getSelectedSignature());
ArrayList<Object> filterList = new ArrayList<Object>();
filterList.add(DataType.class);
filterList.add(Repository.class);
ArrayList<EReference> additionalReferences = new ArrayList<EReference>();
CallDataTypeDialog dialog = new CallDataTypeDialog(cellEditorWindow.getShell(), filterList, additionalReferences, editingDomain.getResourceSet());
dialog.setProvidedService(DataType.class);
dialog.open();
if (!(dialog.getResult() instanceof DataType))
return null;
return dialog.getResult();
}
};
editors[PARAMETER_COLUMN_INDEX] = new DialogCellEditor(table) {
@Override
protected Object openDialogBox(Control cellEditorWindow) {
ParametersDialog dialog = new ParametersDialog(cellEditorWindow.getShell(), getSelectedSignature());
if (dialog.open() == Dialog.OK)
viewer.refresh();
return null;
}
};
return editors;
}
use of org.eclipse.emf.transaction.TransactionalEditingDomain in project Palladio-Editors-Sirius by PalladioSimulator.
the class NewModelWizard method createResource.
private void createResource(final Session session, final IProgressMonitor monitor) {
final TransactionalEditingDomain domain = session.getTransactionalEditingDomain();
final CreateModelCommand createModelCommand = new CreateModelCommand(domain, this.modelURI, this.modelObject);
domain.getCommandStack().execute(createModelCommand);
domain.getCommandStack().execute(new AddSemanticResourceCommand(session, this.modelObject.eResource().getURI(), SubMonitor.convert(monitor)));
}
Aggregations