当前位置: 首页>>代码示例>>Java>>正文


Java TransactionUtil类代码示例

本文整理汇总了Java中org.eclipse.emf.transaction.util.TransactionUtil的典型用法代码示例。如果您正苦于以下问题:Java TransactionUtil类的具体用法?Java TransactionUtil怎么用?Java TransactionUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TransactionUtil类属于org.eclipse.emf.transaction.util包,在下文中一共展示了TransactionUtil类的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")));
				   }
				});
			}
		}
	}
}
 
开发者ID:cetic,项目名称:SimQRI,代码行数:30,代码来源:Simulation.java

示例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;
		}
	}
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:20,代码来源:GenericStateManager.java

示例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;
		}
	}
}
 
开发者ID:eclipse,项目名称:gemoc-studio,代码行数:19,代码来源:FsmTraceStateManager.java

示例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);
	}
}
 
开发者ID:polarsys,项目名称:time4sys,代码行数:23,代码来源:BehaviorScenarioActivity.java

示例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);
			}
		});

	}
}
 
开发者ID:polarsys,项目名称:time4sys,代码行数:25,代码来源:DesignSimpleReport.java

示例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;
		}
	}
}
 
开发者ID:tetrabox,项目名称:minitl,代码行数:19,代码来源:MinitlTraceStateManager.java

示例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;
}
 
开发者ID:eclipse,项目名称:triquetrum,代码行数:31,代码来源:WizardUtils.java

示例8: buildContextMenu

import org.eclipse.emf.transaction.util.TransactionUtil; //导入依赖的package包/类
/**
 * @generated
 */
public void buildContextMenu(final IMenuManager menu) {
	getViewer().flush();
	try {
		TransactionUtil.getEditingDomain(
				(EObject) getViewer().getContents().getModel())
				.runExclusive(new Runnable() {

					public void run() {
						ContributionItemService
								.getInstance()
								.contributeToPopupMenu(
										DiagramEditorContextMenuProvider.this,
										part);
						menu.remove(ActionIds.ACTION_DELETE_FROM_MODEL);
						menu.appendToGroup("editGroup", deleteAction);
					}
				});
	} catch (Exception e) {
		StatemachineDiagramEditorPlugin.getInstance().logError(
				"Error building context menu", e);
	}
}
 
开发者ID:spoenemann,项目名称:xtext-gef,代码行数:26,代码来源:DiagramEditorContextMenuProvider.java

示例9: 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;
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:17,代码来源:ToggleSubRegionLayoutCommand.java

示例10: 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());
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:24,代码来源:AbstractSemanticModification.java

示例11: inheritOptions

import org.eclipse.emf.transaction.util.TransactionUtil; //导入依赖的package包/类
private void inheritOptions(Transaction parent) {
    // if we have no parent transaction, then we are a root and we "inherit"
    // the editing domain's default transaction options.  In the root case,
	// we don't consider whether an option is hereditary because, of course,
	// we aren't actually inheriting it from any other transaction
	final boolean isRoot = parent == null;
	@SuppressWarnings("null")
       Map<?, ?> parentOptions = isRoot ?
       	getDefaultOptions(getEditingDomain()) : parent.getOptions();
       
       if (parentOptions != null) {
		Transaction.OptionMetadata.Registry reg = TransactionUtil
			.getTransactionOptionRegistry(getEditingDomain());
		
           for (Object option : parentOptions.keySet()) {
			reg.getOptionMetadata(option).inherit(parentOptions,
				mutableOptions, isRoot);
           }            
       }
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:21,代码来源:FixedTransactionImpl.java

示例12: buildContextMenu

import org.eclipse.emf.transaction.util.TransactionUtil; //导入依赖的package包/类
/**
 * @generated
 */
public void buildContextMenu(final IMenuManager menu) {
	getViewer().flush();
	try {
		TransactionUtil.getEditingDomain(
				(EObject) getViewer().getContents().getModel())
				.runExclusive(new Runnable() {

					public void run() {
						ContributionItemService
								.getInstance()
								.contributeToPopupMenu(
										DiagramEditorContextMenuProvider.this,
										part);
						menu.remove(ActionIds.ACTION_DELETE_FROM_MODEL);
						menu.appendToGroup("editGroup", deleteAction);
					}
				});
	} catch (Exception e) {
		SmcDiagramEditorPlugin.getInstance().logError(
				"Error building context menu", e);
	}
}
 
开发者ID:road-framework,项目名称:ROADDesigner,代码行数:26,代码来源:DiagramEditorContextMenuProvider.java

示例13: 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;
}
 
开发者ID:road-framework,项目名称:ROADDesigner,代码行数:24,代码来源:AbstractParser.java

示例14: unloadModelResource

import org.eclipse.emf.transaction.util.TransactionUtil; //导入依赖的package包/类
private void unloadModelResource(final IFile file){

		logger.info("Alternative '"+ getName() +"' is unloading model resource: " + file.getFullPath().toString());

		try {
			TransactionUtil.runExclusive(editingDomain, new RunnableWithResult.Impl<Resource>(){

				@Override
				public void run() {
					Resource resource = getModelResource(file);
					if(resource != null){
						resource.unload();
						resSet.getResources().remove(resource);
					}
				}
			});
		} 
		catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
 
开发者ID:CloudScale-Project,项目名称:Environment,代码行数:22,代码来源:EditorInputEMF.java

示例15: loadExternalModel

import org.eclipse.emf.transaction.util.TransactionUtil; //导入依赖的package包/类
/**
 * Loads the EMF resource under specified file into the editing domain.
 * 
 * @param file
 * @return EMF Resource
 */
public Resource loadExternalModel(final IFile file){
	
	Resource resource = null;
	
	try {
		resource = TransactionUtil.runExclusive(editingDomain, new RunnableWithResult.Impl<Resource>(){
			
			@Override
			public void run() {
				
				Resource res = getModelResource(file);
				if(res == null){
					res = loadModelResource(file);
				}
				setResult(res);
				
			}
		});
	} catch (InterruptedException e) {
		e.printStackTrace();
	}
	
	return resource;
}
 
开发者ID:CloudScale-Project,项目名称:Environment,代码行数:31,代码来源:EditorInputEMF.java


注:本文中的org.eclipse.emf.transaction.util.TransactionUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。