本文整理汇总了Java中org.eclipse.emf.transaction.util.TransactionUtil.getEditingDomain方法的典型用法代码示例。如果您正苦于以下问题:Java TransactionUtil.getEditingDomain方法的具体用法?Java TransactionUtil.getEditingDomain怎么用?Java TransactionUtil.getEditingDomain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.transaction.util.TransactionUtil
的用法示例。
在下文中一共展示了TransactionUtil.getEditingDomain方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setQueriesSamples
import org.eclipse.emf.transaction.util.TransactionUtil; //导入方法依赖的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: restoreState
import org.eclipse.emf.transaction.util.TransactionUtil; //导入方法依赖的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;
}
}
}
示例3: restoreState
import org.eclipse.emf.transaction.util.TransactionUtil; //导入方法依赖的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;
}
}
}
示例4: linkActivated
import org.eclipse.emf.transaction.util.TransactionUtil; //导入方法依赖的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);
}
}
示例5: linkPressed
import org.eclipse.emf.transaction.util.TransactionUtil; //导入方法依赖的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);
}
});
}
}
示例6: restoreState
import org.eclipse.emf.transaction.util.TransactionUtil; //导入方法依赖的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;
}
}
}
示例7: fillDiagramFromPtolemyModel
import org.eclipse.emf.transaction.util.TransactionUtil; //导入方法依赖的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;
}
示例8: execute
import org.eclipse.emf.transaction.util.TransactionUtil; //导入方法依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException {
view = unwrap(HandlerUtil.getCurrentSelection(event));
TransactionalEditingDomain editingDomain = TransactionUtil
.getEditingDomain(view);
ToggleCommand toggleCommand = new ToggleCommand(editingDomain, view);
try {
OperationHistoryFactory.getOperationHistory().execute(
toggleCommand, new NullProgressMonitor(), null);
} catch (ExecutionException e) {
e.printStackTrace();
}
return null;
}
示例9: modify
import org.eclipse.emf.transaction.util.TransactionUtil; //导入方法依赖的package包/类
/**
* Executes the modification in a transactional command.
*/
public void modify() {
if (! isApplicable()) throw new IllegalStateException("Modification " + getClass().getSimpleName() + " is not executable.");
final EObject semanticObject = getTargetView().getElement();
AbstractTransactionalCommand refactoringCommand = new AbstractTransactionalCommand(
TransactionUtil.getEditingDomain(semanticObject), getClass().getName(), Collections.EMPTY_LIST) {
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
try {
AbstractSemanticModification.this.execute(semanticObject, getTargetView());
} catch (Exception ex) {
ex.printStackTrace();
return CommandResult.newErrorCommandResult(ex);
}
return CommandResult.newOKCommandResult();
}
};
executeCommand(refactoringCommand, semanticObject.eResource());
}
示例10: getParseCommand
import org.eclipse.emf.transaction.util.TransactionUtil; //导入方法依赖的package包/类
/**
* @generated
*/
protected ICommand getParseCommand(IAdaptable adapter, Object[] values,
int flags) {
if (values == null
|| validateNewValues(values).getCode() != IParserEditStatus.EDITABLE) {
return UnexecutableCommand.INSTANCE;
}
EObject element = (EObject) adapter.getAdapter(EObject.class);
TransactionalEditingDomain editingDomain = TransactionUtil
.getEditingDomain(element);
if (editingDomain == null) {
return UnexecutableCommand.INSTANCE;
}
CompositeTransactionalCommand command = new CompositeTransactionalCommand(
editingDomain, "Set Values"); //$NON-NLS-1$
for (int i = 0; i < values.length; i++) {
command.compose(getModificationCommand(element,
editableFeatures[i], values[i]));
}
return command;
}
示例11: getParseCommand
import org.eclipse.emf.transaction.util.TransactionUtil; //导入方法依赖的package包/类
/**
* @generated
*/
protected ICommand getParseCommand(IAdaptable adapter, Object[] values,
int flags) {
if (values == null
|| validateNewValues(values).getCode() != IParserEditStatus.EDITABLE) {
return UnexecutableCommand.INSTANCE;
}
EObject element = (EObject) adapter.getAdapter(EObject.class);
TransactionalEditingDomain editingDomain = TransactionUtil
.getEditingDomain(element);
if (editingDomain == null) {
return UnexecutableCommand.INSTANCE;
}
CompositeTransactionalCommand command = new CompositeTransactionalCommand(
editingDomain, "Set Values"); //$NON-NLS-1$
for (int i = 0; i < values.length; i++) {
command.compose(getModificationCommand(element,
editableFeatures[i], values[i]));
}
return command;
}
示例12: getParseCommand
import org.eclipse.emf.transaction.util.TransactionUtil; //导入方法依赖的package包/类
@Override
public ICommand getParseCommand(IAdaptable element, final String newLabel, int flags) {
final EObject modelObj = (EObject) element.getAdapter(EObject.class);
TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(modelObj);
if (editingDomain == null) {
return UnexecutableCommand.INSTANCE;
}
IFile affectedFile = WorkspaceSynchronizer.getFile(modelObj.eResource());
return new AbstractTransactionalCommand(
editingDomain,
"Set Values",
affectedFile == null ? null : Collections.singletonList(affectedFile)
) {
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
return new CommandResult(updateValues(modelObj, newLabel));
}
};
}
示例13: addQuery
import org.eclipse.emf.transaction.util.TransactionUtil; //导入方法依赖的package包/类
private void addQuery(String name, String value, QueryType queryType, Model model) {
if(!containsQuery(name, value, model)) {
Query q = new QueryImpl();
q.setName(name); q.setValue(value); q.setType(queryType); q.setSystem(false);
TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(model);
domain.getCommandStack().execute(new RecordingCommand(domain) {
public void doExecute() {
model.getQuery().add(q);
}
});
}
}
示例14: dynamicCheck
import org.eclipse.emf.transaction.util.TransactionUtil; //导入方法依赖的package包/类
/**
* This method is used by a java extension which is called every time a query value is updated in the queries table
* @param model The model instance drawn in the Sirius diagram
* @return errors The String of all error messages related to the queries parsing. Empty if no errors.
*/
public static ArrayList<String> dynamicCheck(Model model) {
ArrayList<String> errors;
Logger<String> logger = new TraceLogger();
// Check the conversion of the model and the validity of queries
SimQRiSirius sim = new SimQRiSirius(100, true, logger, true);
errors = sim.fillModelWithSiriusData(model);
// Metamodel transaction in order to set queries error message into the "error" field of "Query" entities.
boolean hasError;
for(Query q : model.getQuery()) {
hasError = false;
for(String error : errors) {
if(error.contains(q.getValue())) {
TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(q);
domain.getCommandStack().execute(new RecordingCommand(domain) {
public void doExecute() {
String[] errSplit = error.split("]");
q.setError(errSplit[1]);
}
});
hasError = true;
}
}
if(!hasError) q.setError("");
}
return errors;
}
示例15: linkPressed
import org.eclipse.emf.transaction.util.TransactionUtil; //导入方法依赖的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() {
AnalyzedSystem analyzed = ((Project) project_p).deriveAnalyzedSystem(true);
((Project) project_p).setAnalysis(analyzed);
}
});
}
}