本文整理汇总了Java中org.eclipse.emf.transaction.TransactionalEditingDomain类的典型用法代码示例。如果您正苦于以下问题:Java TransactionalEditingDomain类的具体用法?Java TransactionalEditingDomain怎么用?Java TransactionalEditingDomain使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TransactionalEditingDomain类属于org.eclipse.emf.transaction包,在下文中一共展示了TransactionalEditingDomain类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setQueriesSamples
import org.eclipse.emf.transaction.TransactionalEditingDomain; //导入依赖的package包/类
/**
*
* @param sqlogger "Monte-Carlo" simulation results
* @param model The instance of the SimQRi model
* @deprecated
* This method set simulation results to queries objects of the Sirius Metamodel instance.
* No longer used due to a too long time for setting results when there are a lot of queries
*/
@SuppressWarnings("unused")
private void setQueriesSamples(TraceLogger sqlogger, Model model) {
Iterator<SamplingTuple> itProbes = sqlogger.logs().mcSamplings().probesSampling().iterator();
while(itProbes.hasNext()) {
SamplingTuple probes = itProbes.next();
for(Query q : model.getQuery()) {
if(q.getName().equals(probes.name())) {
TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(q);
domain.getCommandStack().execute(new RecordingCommand(domain) {
public void doExecute() {
// q.setResult("");
// q.setMax(String.format("%.2f", JsonFormat.jsonToDouble(probes.samplingStr(), "max")));
// q.setMin(String.format("%.2f", JsonFormat.jsonToDouble(probes.samplingStr(), "min")));
// q.setMean(String.format("%.2f", JsonFormat.jsonToDouble(probes.samplingStr(), "mean")));
// q.setVariance(String.valueOf(JsonFormat.jsonToDouble(probes.samplingStr(), "variance")));
}
});
}
}
}
}
示例2: canHandle
import org.eclipse.emf.transaction.TransactionalEditingDomain; //导入依赖的package包/类
@Override
/*
* This is the operation used to act as a StepManager in K3. We return true
* if we have the same editing domain as the object. (non-Javadoc)
*
* @see fr.inria.diverse.k3.al.annotationprocessor.stepmanager.IStepManager#
* canHandle (java.lang.Object)
*/
public boolean canHandle(Object caller) {
if (caller instanceof EObject) {
EObject eObj = (EObject) caller;
org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain = getEditingDomain(eObj);
return editingDomain == this.editingDomain;
}
return false;
}
示例3: notifySirius
import org.eclipse.emf.transaction.TransactionalEditingDomain; //导入依赖的package包/类
/**
* Notifies Sirius about a change in the given {@link DSLBreakpoint}.
*
* @param instructionUris
* the {@link URI}s of the instructions to refresh.
* @param debugModelID
* the debug model identifier
*/
public void notifySirius(Set<URI> instructionUris, String debugModelID) {
Map<String, Set<String>> toRefresh = representationToRefresh.get(debugModelID);
if (toRefresh != null) {
for (IEditingSession session : SessionUIManager.INSTANCE.getUISessions()) {
final TransactionalEditingDomain transactionalEditingDomain = session.getSession()
.getTransactionalEditingDomain();
final boolean instructionPresent = isOneInstructionPresent(instructionUris,
transactionalEditingDomain.getResourceSet());
if (instructionPresent) {
final List<DRepresentation> representations = getRepresentationsToRefresh(toRefresh,
session);
refreshRepresentations(transactionalEditingDomain, representations);
}
}
}
}
示例4: restoreState
import org.eclipse.emf.transaction.TransactionalEditingDomain; //导入依赖的package包/类
@Override
public void restoreState(State<?, ?> state) {
if (modelResource != null && state instanceof GenericState) {
try {
final TransactionalEditingDomain ed = TransactionUtil.getEditingDomain(modelResource);
if (ed != null) {
final RecordingCommand command = new RecordingCommand(ed, "") {
protected void doExecute() {
restoreStateExecute((GenericState) state);
}
};
CommandExecution.execute(ed, command);
}
} catch (Exception e) {
throw e;
}
}
}
示例5: createSession
import org.eclipse.emf.transaction.TransactionalEditingDomain; //导入依赖的package包/类
public Session createSession(ResourceSet set, final URI sessionResourceURI, IProgressMonitor monitor) throws CoreException {
final TransactionalEditingDomain transactionalEditingDomain = EditingDomainFactoryService.INSTANCE.getEditingDomainFactory().createEditingDomain(set);
// Configure the resource set, its is done here and not before the
// editing domain creation which could provide its own resource set.
transactionalEditingDomain.getResourceSet().eAdapters().add(new SiriusCrossReferenceAdapterImpl());
if (Movida.isEnabled()) {
transactionalEditingDomain.getResourceSet().setURIConverter(new ViewpointURIConverter((ViewpointRegistry) org.eclipse.sirius.business.api.componentization.ViewpointRegistry.getInstance()));
}
// Create or load the session.
boolean alreadyExistingResource = exists(sessionResourceURI, transactionalEditingDomain.getResourceSet());
Session session = null;
if (alreadyExistingResource) {
session = loadSessionModelResource(sessionResourceURI, transactionalEditingDomain, monitor);
} else {
session = createSessionResource(sessionResourceURI, transactionalEditingDomain, monitor);
}
return session;
}
示例6: 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);
}
}
}
示例7: refreshRepresentations
import org.eclipse.emf.transaction.TransactionalEditingDomain; //导入依赖的package包/类
/**Refreshes given {@link DRepresentation} in the given {@link TransactionalEditingDomain}.
* @param transactionalEditingDomain the {@link TransactionalEditingDomain}
* @param representations the {@link List} of {@link DRepresentation} to refresh
*/
public void refreshRepresentations(
final TransactionalEditingDomain transactionalEditingDomain,
final List<DRepresentation> representations) {
// TODO prevent the editors from getting dirty
if (representations.size() != 0) {
final RefreshRepresentationsCommand refresh = new RefreshRepresentationsCommand(
transactionalEditingDomain,
new NullProgressMonitor(),
representations);
try {
CommandExecution.execute(transactionalEditingDomain, refresh);
} catch (Exception e){
String repString = representations.stream().map(r -> r.getName()).collect(Collectors.joining(", "));
Activator.getDefault().getLog().log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, "Failed to refresh Sirius representation(s)["+repString+"], we hope to be able to do it later", e));
}
}
}
示例8: 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;
}
示例9: restoreState
import org.eclipse.emf.transaction.TransactionalEditingDomain; //导入依赖的package包/类
@Override
public void restoreState(State<?, ?> state) {
if (modelResource != null && state instanceof fsmTrace.States.SpecificState) {
try {
final TransactionalEditingDomain ed = TransactionUtil.getEditingDomain(modelResource);
if (ed != null) {
final RecordingCommand command = new RecordingCommand(ed, "") {
protected void doExecute() {
restoreStateExecute((fsmTrace.States.SpecificState) state);
}
};
CommandExecution.execute(ed, command);
}
} catch (Exception e) {
throw e;
}
}
}
示例10: linkActivated
import org.eclipse.emf.transaction.TransactionalEditingDomain; //导入依赖的package包/类
@Override
public void linkActivated(final HyperlinkEvent event) {
Session session = ActivityExplorerManager.INSTANCE.getSession();
RefreshEditorsPrecommitListener repl = session.getRefreshEditorsListener();
repl.notify(SessionListener.REPRESENTATION_CHANGE);
repl.notify(SessionListener.SEMANTIC_CHANGE);
EObject root = ActivityExplorerManager.INSTANCE.getRootSemanticModel();
if (root instanceof Project) {
Project rootProject = (Project) root;
final EList<BehaviorScenario> bsList = rootProject.getDesign().getWorkloadBehavior().getBehavior();
if (bsList.isEmpty()) {
final BehaviorScenario bs = GqamFactory.eINSTANCE.createBehaviorScenario();
final TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(rootProject);
domain.getCommandStack().execute(new RecordingCommand(domain) {
public void doExecute() {
bsList.add(bs);
}
});
}
linkPressed(event, bsList.get(0), session);
}
}
示例11: linkPressed
import org.eclipse.emf.transaction.TransactionalEditingDomain; //导入依赖的package包/类
@Override
protected void linkPressed(final HyperlinkEvent event, final EObject project_p, final Session session) {
if (project_p instanceof Project) {
TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(project_p);
domain.getCommandStack().execute(new RecordingCommand(domain) {
@Override
protected void doExecute() {
final Project prj = ((Project) project_p);
final Mapping mapping = ToPeriodicDerivation.getOrApply(prj);
final DesignModel toBeAnalysedModel = (DesignModel) mapping.getSubLinks().get(0).getUniqueTargetValue("copy");
final URI uri = prj.eResource().getURI();
IPath path = new Path(uri.toPlatformString(true));
final String filename = path.lastSegment().replaceAll(".time4sys", "-report.asciidoc");
path = path.removeLastSegments(1);
path = path.append(filename);
IWorkspaceRoot wrkspc = ResourcesPlugin.getWorkspace().getRoot();
final IFile output = wrkspc.getFile(path);
generateReport(toBeAnalysedModel, output, null);
}
});
}
}
示例12: restoreState
import org.eclipse.emf.transaction.TransactionalEditingDomain; //导入依赖的package包/类
@Override
public void restoreState(State<?, ?> state) {
if (modelResource != null && state instanceof minitlTrace.States.SpecificState) {
try {
final TransactionalEditingDomain ed = TransactionUtil.getEditingDomain(modelResource);
if (ed != null) {
final RecordingCommand command = new RecordingCommand(ed, "") {
protected void doExecute() {
restoreStateExecute((minitlTrace.States.SpecificState) state);
}
};
CommandExecution.execute(ed, command);
}
} catch (Exception e) {
throw e;
}
}
}
示例13: executeCommand
import org.eclipse.emf.transaction.TransactionalEditingDomain; //导入依赖的package包/类
@Override
public void executeCommand(final Runnable r) {
if (editorPart instanceof DiagramDocumentEditor) {
// GMF editors use transactional editing domains. Thus,
// the command needs to be executed within a transaction.
RecordingCommand rc = new RecordingCommand((TransactionalEditingDomain) getEditingDomain()) {
@Override
protected void doExecute() {
r.run();
}
};
getEditingDomain().getCommandStack().execute(rc);
getEditingDomain().getCommandStack().undo();
} else {
// EMF tree editors use regular editing domains, thus the
// Runnable can be executed directly.
r.run();
}
}
示例14: openNewEMFDiagramEditorPart
import org.eclipse.emf.transaction.TransactionalEditingDomain; //导入依赖的package包/类
public IEditorPart openNewEMFDiagramEditorPart(URL modelURL, URL diagramURL) {
MockEditingDomainFactory fact = new MockEditingDomainFactory();
TransactionalEditingDomain editingDomain = fact.createEditingDomain(modelURL);
// TODO: actually open diagram, this currently results in exception
// Resource diagRes = Models.loadModel(diagramURL);
// editingDomain.getResourceSet().getResources().add(diagRes);
IGMFEditor result = createNiceMock(IGMFEditor.class);
reset(result);
expect(result.getEditingDomain()).andReturn(editingDomain).anyTimes();
replay(result);
this.activeEditorPart = result;
currentEditors.add(result);
workbenchMock.changedEditorPart(result, EditorPartMgmtEvent.OPEN);
return result;
}
示例15: performIssueValidationFixingTransactional
import org.eclipse.emf.transaction.TransactionalEditingDomain; //导入依赖的package包/类
private void performIssueValidationFixingTransactional(Collection<TransactionalEditingDomain> domains,
Resource documentResource) throws OperationCanceledError {
final Collection<Issue> detectedIssues = new ArrayList<>();
domains.stream().filter(TransactionalEditingDomainImpl.class::isInstance)
.map(TransactionalEditingDomainImpl.class::cast).forEach(d -> setValidatorFactory(d, detectedIssues));
Runnable lastCommandStackAction = null;
for (TransactionalEditingDomain domain : domains) {
if (lastCommandStackAction == null) {
lastCommandStackAction = createFixingRecordingCommand(domain, documentResource, detectedIssues);
} else {
lastCommandStackAction = createDelegatingRecordingCommand(domain, lastCommandStackAction);
}
}
Optional.ofNullable(lastCommandStackAction).ifPresent(Runnable::run);
}