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


Java Transaction类代码示例

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


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

示例1: setValidatorFactory

import org.eclipse.emf.transaction.Transaction; //导入依赖的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

示例2: stopRecording

import org.eclipse.emf.transaction.Transaction; //导入依赖的package包/类
/**
 * Stops recording changes and adds them to my composite change description,
 * unless undo recording is disabled by my options.
 */
private void stopRecording() {
	TransactionChangeRecorder recorder = getInternalDomain().getChangeRecorder();
	
	if (isUndoEnabled(this) && recorder.isRecording()) {
		Transaction active = getInternalDomain().getActiveTransaction();
		if ((active != null) && !isUndoEnabled(active)) {
			// the child is not recording, so we just suspend our change
			//    recording and resume it later.  This is a lightweight
			//    alternative to cutting a change description and starting
			//    a new one, later
			recorder.pause();
		} else {
			change.add(recorder.endRecording());
		}
	}
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:21,代码来源:FixedTransactionImpl.java

示例3: inheritOptions

import org.eclipse.emf.transaction.Transaction; //导入依赖的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

示例4: getAffectedObjects

import org.eclipse.emf.transaction.Transaction; //导入依赖的package包/类
@Override
public Collection<?> getAffectedObjects() {
    Transaction transaction = JavaBridge.getFieldFromClass(RecordingCommand.class, "transaction", this);
    if (transaction == null) {
        // TODO DW what to do, if transaction is null? when is this the case?
        return Collections.EMPTY_SET;
    }

    final TransactionChangeDescription changeDescription = transaction.getChangeDescription();
    final Collection<EObject> affectedEObjects = EMFChangeBridge.getAffectedObjects(changeDescription);

    return affectedEObjects;
}
 
开发者ID:vitruv-tools,项目名称:Vitruv,代码行数:14,代码来源:VitruviusRecordingCommand.java

示例5: createEditingDomain

import org.eclipse.emf.transaction.Transaction; //导入依赖的package包/类
/**
 * @see org.eclipse.emf.transaction.TransactionalEditingDomain.Factory#createEditingDomain()
 */
public TransactionalEditingDomain createEditingDomain() {
    // create an editing domain with a default resource set implementation
    // and delegating command execution to the default (workbench)
    // operation history
    TransactionalEditingDomain result = WorkspaceEditingDomainFactory.INSTANCE.createEditingDomain();

    // add an exception handler to the editing domain's command stack
    ((TransactionalCommandStack) result.getCommandStack()).setExceptionHandler(new CommandStackExceptionHandler());

    DefaultOptions defaults = TransactionUtil.getAdapter(result, DefaultOptions.class);
    if (defaults != null) {
        Map<Object, Object> options = new java.util.HashMap<Object, Object>();

        options.put(Transaction.OPTION_VALIDATE_EDIT, new WorkspaceValidateEditSupport() {
            @Override
            protected IStatus doValidateEdit(Transaction transaction, Collection<? extends Resource> resources,
                                             Object context) {
                if ((context == null) && (Display.getCurrent() != null)) {
                    // get the active shell for the context
                    // when validating on the UI thread
                    IWorkbench wb = PlatformUI.getWorkbench();
                    if (wb.getActiveWorkbenchWindow() != null) {
                        context = wb.getActiveWorkbenchWindow().getShell();
                    }
                }

                return super.doValidateEdit(transaction, resources, context);
            }
        });

        defaults.setDefaultTransactionOptions(options);
    }

    return result;
}
 
开发者ID:SK-HOLDINGS-CC,项目名称:NEXCORE-UML-Modeler,代码行数:39,代码来源:UMLEditingDomainFactory.java

示例6: validate

import org.eclipse.emf.transaction.Transaction; //导入依赖的package包/类
@Override
public IStatus validate(Transaction tx) {
    return delegationTarget.validate(tx);
}
 
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:5,代码来源:DelegatingTransactionValidator.java

示例7: getNotificationsForValidation

import org.eclipse.emf.transaction.Transaction; //导入依赖的package包/类
@Override
public List<Notification> getNotificationsForValidation(Transaction tx) {
    return delegationTarget.getNotificationsForValidation(tx);
}
 
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:5,代码来源:DelegatingTransactionValidator.java

示例8: getNotificationsForPrecommit

import org.eclipse.emf.transaction.Transaction; //导入依赖的package包/类
@Override
public List<Notification> getNotificationsForPrecommit(Transaction tx) {
    return delegationTarget.getNotificationsForPrecommit(tx);
}
 
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:5,代码来源:DelegatingTransactionValidator.java

示例9: getNotificationsForPostcommit

import org.eclipse.emf.transaction.Transaction; //导入依赖的package包/类
@Override
public List<Notification> getNotificationsForPostcommit(Transaction tx) {
    return delegationTarget.getNotificationsForPostcommit(tx);
}
 
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:5,代码来源:DelegatingTransactionValidator.java

示例10: unmodifiableEvent

import org.eclipse.emf.transaction.Transaction; //导入依赖的package包/类
private ResourceSetChangeEvent unmodifiableEvent(ResourceSetChangeEvent event) {
	TransactionalEditingDomain source = (TransactionalEditingDomain) event.getSource();
	Transaction transaction = event.getTransaction();
	List<Notification> notifications = Collections.unmodifiableList(new ArrayList<Notification>(event.getNotifications()));
	return new ResourceSetChangeEvent(source, transaction, notifications);
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:7,代码来源:ExtensionPointResourceSetListener.java

示例11: runExclusive

import org.eclipse.emf.transaction.Transaction; //导入依赖的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

示例12: getParent

import org.eclipse.emf.transaction.Transaction; //导入依赖的package包/类
@Override
public final Transaction getParent() {
	return parent;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:5,代码来源:FixedTransactionImpl.java

示例13: isUndoEnabled

import org.eclipse.emf.transaction.Transaction; //导入依赖的package包/类
/**
 * Queries whether the specified transaction should record undo information,
 * according to its {@link Transaction#getOptions() options} and
 * {@link Transaction#isReadOnly() read-only state}.
 * 
 * @param tx a transaction
 * @return <code>true</code> if the transaction should record undo
 *     information; <code>false</code>, otherwise
 */
protected static boolean isUndoEnabled(Transaction tx) {
	return !(tx.isReadOnly()
			|| hasOption(tx, OPTION_NO_UNDO)
			|| hasOption(tx, OPTION_UNPROTECTED));
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:15,代码来源:FixedTransactionImpl.java

示例14: isTriggerEnabled

import org.eclipse.emf.transaction.Transaction; //导入依赖的package包/类
/**
 * Queries whether the specified transaction should invoke pre-commit,
 * listeners, according to its {@link Transaction#getOptions() options} and
 * {@link Transaction#isReadOnly() read-only state}.
 * 
 * @param tx a transaction
 * @return <code>true</code> if the transaction should perform the pre-commit
 *     procedures; <code>false</code>, otherwise
 */
protected static boolean isTriggerEnabled(Transaction tx) {
	return !(tx.isReadOnly()
			|| hasOption(tx, OPTION_NO_TRIGGERS)
			|| hasOption(tx, OPTION_UNPROTECTED));
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:15,代码来源:FixedTransactionImpl.java

示例15: isNotificationEnabled

import org.eclipse.emf.transaction.Transaction; //导入依赖的package包/类
/**
 * Queries whether the specified transaction should send post-commit events,
 * according to its {@link Transaction#getOptions() options}.
 * 
 * @param tx a transaction
 * @return <code>true</code> if the transaction should send post-commit
 *     events; <code>false</code>, otherwise
 */
protected static boolean isNotificationEnabled(Transaction tx) {
	return !hasOption(tx, OPTION_NO_NOTIFICATIONS);
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:12,代码来源:FixedTransactionImpl.java


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