• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TransactionalEditingDomainImpl类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



TransactionalEditingDomainImpl类属于org.eclipse.emf.transaction.impl包,在下文中一共展示了TransactionalEditingDomainImpl类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testRefactoring

import org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl; //导入依赖的package包/类
protected void testRefactoring(String pathToInitialSct, String pathToExpectedSct, String contextElementName) {
	Statechart initial = models
			.loadStatechartFromResource(pathToInitialSct);

	TransactionalEditingDomainImpl.FactoryImpl.INSTANCE.createEditingDomain(initial.eResource().getResourceSet());
	
	View contextView = getViewForState(initial, contextElementName);

	AbstractRefactoring<View> refactoring = getRefactoring();
	refactoring.setContextObjects(Collections.singletonList(contextView));
	
	AbstractSCTResource initialRes = (AbstractSCTResource) initial.eResource();
	initialRes.setSerializerEnabled(true);
	refactoring.execute();
	initialRes.setSerializerEnabled(false);

	Statechart expected = models
			.loadStatechartFromResource(pathToExpectedSct);
	
	compareStatecharts(initial, expected);
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:22,代码来源:ViewBasedRefactoringTest.java


示例2: performIssueValidationFixingTransactional

import org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl; //导入依赖的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);
}
 
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:21,代码来源:CooperateCDOXtextEditor.java


示例3: setValidatorFactory

import org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl; //导入依赖的package包/类
private static void setValidatorFactory(TransactionalEditingDomainImpl domainImpl,
        final Collection<Issue> detectedIssues) {
    domainImpl.setValidatorFactory(new DelegatingValidatorFactory() {
        @Override
        public TransactionValidator createReadWriteValidator() {
            return new DelegatingTransactionValidator(super.createReadWriteValidator()) {
                @Override
                public IStatus validate(Transaction tx) {
                    IStatus result = super.validate(tx);
                    if (result.isOK() && !detectedIssues.isEmpty()) {
                        return new Status(IStatus.ERROR, result.getPlugin(), "There are unfixed issues remaining.");
                    }
                    return result;
                }

            };
        }
    });
}
 
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:20,代码来源:CooperateCDOXtextEditor.java


示例4: checkedWriting

import org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl; //导入依赖的package包/类
public static <T> T checkedWriting(Object object, final RunnableWithResult<T> runnable, Map<Object, Object> options) throws InterruptedException, RollbackException {

		final EditingDomain domain = EMFUtils.getAnyDomain(object);
		if (domain instanceof TransactionalEditingDomain) {
			TransactionalEditingDomain transactionDomain = (TransactionalEditingDomain) domain;
			checkForDeadlock(transactionDomain);
			InternalTransaction transaction = ((TransactionalEditingDomainImpl) transactionDomain).getActiveTransaction();
			if ((transaction != null) && (transaction.getOwner() == Thread.currentThread()) && !transaction.isReadOnly()) {
				// nested writing
				runnable.run();
				return runnable.getResult();
			}
			TransactionalCommandStack stack = (TransactionalCommandStack) domain.getCommandStack();
			if (stack != null) {
				Map writingOptions = getWritingOptions(domain);
				Map newOptions = new HashMap();
				if (options != null) {
					newOptions.putAll(options);
				}
				if (writingOptions != null) {
					newOptions.putAll(writingOptions);
				}
				writingOptions = newOptions;
				stack.execute(new RunnableRecordingCommand("writing", runnable), writingOptions);
			} else {
				runnable.run();
			}
		} else {
			runnable.run();
		}
		return runnable.getResult();
	}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:33,代码来源:TransactionUtils.java


示例5: getEditingDomain

import org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.emf.emfstore.client.provider.ESEditingDomainProvider#getEditingDomain(org.eclipse.emf.ecore.resource.ResourceSet)
 */
public EditingDomain getEditingDomain(ResourceSet resourceSet) {
	final TransactionalEditingDomain domain = new TransactionalEditingDomainImpl(new ComposedAdapterFactory(
		ComposedAdapterFactory.Descriptor.Registry.INSTANCE), new EMFStoreTransactionalCommandStack(), resourceSet);
	((FactoryImpl) TransactionalEditingDomain.Factory.INSTANCE).mapResourceSet(domain);
	TransactionalEditingDomain.Registry.INSTANCE.add(TRANSACTIONAL_EDITINGDOMAIN_ID, domain);
	domain.setID(TRANSACTIONAL_EDITINGDOMAIN_ID);
	return domain;
}
 
开发者ID:edgarmueller,项目名称:emfstore-rest,代码行数:14,代码来源:TransactionalEditingDomainProvider.java


示例6: initializeEditingDomain

import org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl; //导入依赖的package包/类
/**
 * This sets up the editing domain for the model editor.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void initializeEditingDomain() {
	// Create an adapter factory that yields item providers.
	//
	adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);

	adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
	adapterFactory.addAdapterFactory(new EcoreItemProviderAdapterFactory());
	adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());

	// Create the command stack that will notify this editor as commands are executed.
	//
	TransactionalCommandStack commandStack = new TransactionalCommandStackImpl();

	// Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus.
	//
	commandStack.addCommandStackListener
		(new CommandStackListener() {
			 public void commandStackChanged(final EventObject event) {
				 getContainer().getDisplay().asyncExec
					 (new Runnable() {
						  public void run() {
							  firePropertyChange(IEditorPart.PROP_DIRTY);

							  // Try to select the affected objects.
							  //
							  Command mostRecentCommand = ((CommandStack)event.getSource()).getMostRecentCommand();
							  if (mostRecentCommand != null) {
								  setSelectionToViewer(mostRecentCommand.getAffectedObjects());
							  }
							  for (Iterator<PropertySheetPage> i = propertySheetPages.iterator(); i.hasNext(); ) {
								  PropertySheetPage propertySheetPage = i.next();
								  if (propertySheetPage.getControl().isDisposed()) {
									  i.remove();
								  }
								  else {
									  propertySheetPage.refresh();
								  }
							  }
						  }
					  });
			 }
		 });

	// Create the editing domain with a special command stack.
	//
	editingDomain = new TransactionalEditingDomainImpl(adapterFactory, commandStack);//, new HashMap<Resource, Boolean>());
}
 
开发者ID:Nasdanika,项目名称:codegen-ecore,代码行数:54,代码来源:EcoreEditor.java


示例7: initializeEditingDomain

import org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl; //导入依赖的package包/类
/**
 * This sets up the editing domain for the model editor.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * 
 * @generated NOT
 * @deprecated
 */
protected void initializeEditingDomain() {
    // Create an adapter factory that yields item providers.
    //
    adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);

    adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
    adapterFactory.addAdapterFactory(new GenconfItemProviderAdapterFactory());
    adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());

    // Create the command stack that will notify this editor as commands are executed.
    //
    TransactionalCommandStack commandStack = new TransactionalCommandStackImpl();

    // Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus.
    //
    commandStack.addCommandStackListener(new CommandStackListener() {
        public void commandStackChanged(final EventObject event) {
            getContainer().getDisplay().asyncExec(new Runnable() {
                public void run() {
                    firePropertyChange(IEditorPart.PROP_DIRTY);

                    // Try to select the affected objects.
                    //
                    Command mostRecentCommand = ((CommandStack) event.getSource()).getMostRecentCommand();
                    if (mostRecentCommand != null) {
                        setSelectionToViewer(mostRecentCommand.getAffectedObjects());
                    }
                    for (Iterator<PropertySheetPage> i = propertySheetPages.iterator(); i.hasNext();) {
                        PropertySheetPage propertySheetPage = i.next();
                        if (propertySheetPage.getControl().isDisposed()) {
                            i.remove();
                        } else {
                            propertySheetPage.refresh();
                        }
                    }
                }
            });
        }
    });

    // Create the editing domain with a special command stack.
    //
    editingDomain = new TransactionalEditingDomainImpl(adapterFactory, commandStack);
}
 
开发者ID:ObeoNetwork,项目名称:M2Doc,代码行数:53,代码来源:GenconfEditor.java


示例8: getWritingOptions

import org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl; //导入依赖的package包/类
private static Map<?, ?> getWritingOptions(EditingDomain domain) {
	if (domain instanceof TransactionalEditingDomainImpl)
		return ((TransactionalEditingDomainImpl) domain).getDefaultTransactionOptions();
	return WRITING_OPTIONS;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:6,代码来源:TransactionUtils.java


示例9: runExclusive

import org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl; //导入依赖的package包/类
public static <T> T runExclusive(TransactionalEditingDomain d, Runnable read) throws InterruptedException {
	InternalTransactionalEditingDomain domain = (InternalTransactionalEditingDomain) d;
	Transaction active = domain.getActiveTransaction();
	Transaction tx = null;
	long start = -1;
	if ((active == null) || !(active.isActive() && active.isReadOnly() && (active.getOwner() == Thread.currentThread()))) {
		start = System.currentTimeMillis();
		// only need to start a new transaction if we don't already have
		// exclusive read-only access
		tx = domain.startTransaction(true, getWritingOptions(domain));
	}
	final RunnableWithResult<?> rwr = (read instanceof RunnableWithResult) ? (RunnableWithResult<?>) read : null;
	try {
		read.run();
	} finally {
		if ((tx != null) && (tx.isActive())) {
			// commit the transaction now
			try {
				tx.commit();
				if (rwr != null) {
					rwr.setStatus(Status.OK_STATUS);
				}
			} catch (RollbackException e) {
				Tracing.catching(TransactionalEditingDomainImpl.class, "runExclusive", e); //$NON-NLS-1$
				EMFTransactionPlugin.INSTANCE.log(new MultiStatus(EMFTransactionPlugin.getPluginId(), EMFTransactionStatusCodes.READ_ROLLED_BACK, new IStatus[] { e.getStatus() }, Messages.readTxRollback, null));
				if (rwr != null) {
					rwr.setStatus(e.getStatus());
				}
			}
		}
	}
	if (start != -1) {
		long duration = System.currentTimeMillis() - start;
		if (duration > 2 * 1000) {
			LogUtil.warn("runnable " + read + " held transaction for " + (duration / 1000.0) + " seconds");
		}
	}
	if (rwr != null) {
		@SuppressWarnings("unchecked")
		T result = (T) rwr.getResult();
		return result;
	}
	return null;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:45,代码来源:TransactionUtils.java


示例10: doExecute

import org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl; //导入依赖的package包/类
@Override
protected void doExecute(Command command, Map<?, ?> options) throws InterruptedException, RollbackException {
	// default the transaction options to not perform EMF validation or allow undo 
	if (options == null) {
		options = DEFAULT_TRANSACTION_OPTIONS;
	}
	InternalTransaction tx = createTransaction(command, options);
	boolean completed = false;
	
	try {
		basicExecute(command);
		
		// new in EMF 2.4:  AbortExecutionException can cause the
		// command not to be added to the undo stack
		completed = mostRecentCommand == command;
		
		// commit the transaction now
		TransactionalEditingDomainImpl domain = (TransactionalEditingDomainImpl)tx.getEditingDomain();
		if (domain != null && domain.getChangeRecorder() != null) {
			tx.commit();
		} else {
			tx = null;
		}
	} catch (OperationCanceledException e) {
		// snuff the exception, because this is expected (user asked to
		//    cancel the model change).  We will rollback, below
	} finally {
		if (tx != null) {
			if (tx.isActive()) {
				// roll back (some exception, possibly being thrown now or
				//    an operation cancel, has occurred)
				rollback(tx);
                handleRollback(command, null);
			} else {
				// the transaction has already incorporated the triggers
				//    into its change description, so the recording command
				//    doesn't need them again
				if (!(command instanceof RecordingCommand) && completed) {
					Command triggerCommand = tx.getTriggers();
					if (triggerCommand != null) {
						// replace the executed command by a compound of the
						//    original and the trigger commands
						CompoundCommand compound = new ConditionalRedoCommand.Compound();
						compound.append(mostRecentCommand);
						compound.append(triggerCommand);
						mostRecentCommand = compound;
					}
				}
			}
		}
	}
       clearStack(command);
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:54,代码来源:FixedTransactionalCommandStackImpl.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EnhancedRandom类代码示例发布时间:2022-05-23
下一篇:
Java CLProgram类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap