• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java ObjectUndoContext类的典型用法和代码示例

java 1次浏览

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

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

示例1: stop

点赞 3

import org.eclipse.core.commands.operations.ObjectUndoContext; //导入依赖的package包/类
public void stop(BundleContext context) throws Exception {
  if (fRefactoringUndoContext != null) {
    IUndoContext workspaceContext =
        (IUndoContext) ResourcesPlugin.getWorkspace().getAdapter(IUndoContext.class);
    if (workspaceContext instanceof ObjectUndoContext) {
      ((ObjectUndoContext) workspaceContext).removeMatch(fRefactoringUndoContext);
    }
  }
  if (fgUndoManager != null) fgUndoManager.shutdown();
  final RefactoringHistoryService service = RefactoringHistoryService.getInstance();
  service.disconnect();
  if (fRefactoringHistoryListener != null)
    service.removeHistoryListener(fRefactoringHistoryListener);
  RefactoringContributionManager.getInstance().disconnect();
  super.stop(context);
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:17,
代码来源:RefactoringCorePlugin.java

示例2: init

点赞 3

import org.eclipse.core.commands.operations.ObjectUndoContext; //导入依赖的package包/类
/**
 * @throws PartInitException
 */
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
	setSite(site);
	setInput(input);
	listener = new EditorPartInputActivationListener(this);
	IFile file = CommonUtils.getAdapter(input, IFile.class);
	IProject project = file.getProject();
	synchronizer = new ProjectResourceSetSynchronizer(project, gov.nasa.ensemble.emf.transaction.TransactionUtils.createTransactionResourceSet());
	ResourceSet resourceSet = synchronizer.getResourceSet();
	resourceSet.setURIConverter(new ProjectURIConverter(project));
	resourceSet.getPackageRegistry().put(ChartPackage.eNS_URI, ChartPackage.eINSTANCE);
	profileSynchronizer = ProfileSynchronizer.createInstance(project, resourceSet);
	editingDomain = gov.nasa.ensemble.emf.transaction.TransactionUtils.getDomain(resourceSet);
	undoContext = new ObjectUndoContext(getEditingDomain());
	site.setSelectionProvider(new EnsembleSelectionProvider(this.toString()));
	UndoRedoUtils.setupUndoRedo(site.getActionBars(), site, undoContext);
	createModel(input);
	editingDomain.addResourceSetListener(pageExtentListener);
}
 

开发者ID:nasa,
项目名称:OpenSPIFe,
代码行数:23,
代码来源:ChartEditor.java

示例3: getUndoContext

点赞 2

import org.eclipse.core.commands.operations.ObjectUndoContext; //导入依赖的package包/类
public static IUndoContext getUndoContext() {
  if (fRefactoringUndoContext == null) {
    fRefactoringUndoContext = new RefactoringUndoContext();
    IUndoContext workspaceContext =
        (IUndoContext) ResourcesPlugin.getWorkspace().getAdapter(IUndoContext.class);
    if (workspaceContext instanceof ObjectUndoContext) {
      ((ObjectUndoContext) workspaceContext).addMatch(fRefactoringUndoContext);
    }
    IOperationHistory operationHistory = OperationHistoryFactory.getOperationHistory();
    operationHistory.setLimit(fRefactoringUndoContext, 5);
  }
  return fRefactoringUndoContext;
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:14,
代码来源:RefactoringCorePlugin.java

示例4: ProfileDataPointsEditor

点赞 2

import org.eclipse.core.commands.operations.ObjectUndoContext; //导入依赖的package包/类
public ProfileDataPointsEditor(Composite parent, DetailProviderParameter parameter) {
	EObject target = parameter.getTarget();
	if (!(target instanceof Profile)) {
		throw new IllegalArgumentException("ProfileDataPointEditor target must be a Profile.");
	}
	Profile profile = (Profile) target;
	IItemPropertyDescriptor pd = parameter.getPropertyDescriptor();
	FormToolkit toolkit = parameter.getDetailFormToolkit();

	String displayName = EMFDetailUtils.getDisplayName(profile, pd);
	Section section = DetailFormToolkit.createSection(toolkit, parent, displayName, null, false);
	Composite sectionComposite = toolkit.createComposite(section);
	sectionComposite.setLayout(new GridLayout(2, false));
	section.setClient(sectionComposite);

	String editabilityText = (isProfileEditable(profile) ? EDITABLE_MESSAGE : READ_ONLY_MESSAGE);
	Label editabilityLabel = toolkit.createLabel(sectionComposite, editabilityText);
	editabilityLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 2, 1));

	final TreeTableViewer viewer = createTreeTableViewer(sectionComposite, toolkit, profile);
	EditingDomain domain = EMFUtils.getAnyDomain(profile);
	IUndoContext undoContext = new ObjectUndoContext(domain);
	ProfileEditorModel editorModel = new ProfileEditorModel(isProfileEditable(profile), undoContext);
	viewer.setEditorModel(editorModel);
	viewer.setInput(profile);
	parent.layout(true);
}
 

开发者ID:nasa,
项目名称:OpenSPIFe,
代码行数:28,
代码来源:ProfileDataPointsEditor.java

示例5: checkReadOnly

点赞 2

import org.eclipse.core.commands.operations.ObjectUndoContext; //导入依赖的package包/类
protected IStatus checkReadOnly(IUndoableOperation operation) {
	for (IUndoContext context : operation.getContexts()) {
		if (context instanceof ObjectUndoContext) {
			ObjectUndoContext objectUndoContext = (ObjectUndoContext) context;
			if (objectUndoContext.getObject() instanceof EditingDomain) {
				EditingDomain domain = (EditingDomain) objectUndoContext.getObject();
				ResourceSet resourceSet = domain.getResourceSet();
				List<Resource> resources = new ArrayList<Resource>(resourceSet.getResources());
				for (Resource resource : resources) {
					if (resource instanceof PlanResourceImpl) {
						for (EObject content : resource.getContents()) {
							if (content instanceof EPlan && !EPlanUtils.isTemplatePlan(content)) {
								EPlan plan = (EPlan) content;
								if (domain.isReadOnly(resource)
									|| (!registry.canModify(plan) 
											&& !registry.canModifyStructure(plan))) {
									Throwable exception = new IllegalStateException("checkReadOnly failed: " + operation);
									LogUtil.error(exception);
									return new Status(IStatus.ERROR, "gov.nasa.ensemble.core.plan.editor", 7, "plan is read only", exception); 
								}
							}
						}
					}
				}
			}
		}
	}
	return Status.OK_STATUS;
}
 

开发者ID:nasa,
项目名称:OpenSPIFe,
代码行数:30,
代码来源:PlanReadOnlyOperationApprover.java

示例6: initializeOperationHistory

点赞 2

import org.eclipse.core.commands.operations.ObjectUndoContext; //导入依赖的package包/类
private void initializeOperationHistory() {
	// create a unique undo context to
	// represent this view's undo history
	undoContext = new ObjectUndoContext(this);

	// set the undo limit for this context based on the preference
	HISTORY.setLimit(undoContext, 99);

	// 初始化“重做、”“撤销”菜单项
	undoRedoGroup = new UndoRedoActionGroup(getSite(), undoContext, true);
}
 

开发者ID:heartsome,
项目名称:translationstudio8,
代码行数:12,
代码来源:XLIFFEditorImplWithNatTable.java

示例7: getUndoLevel

点赞 2

import org.eclipse.core.commands.operations.ObjectUndoContext; //导入依赖的package包/类
/**
 * Returns current undo level.
 * 
 * @return current undo level.
 */
private int getUndoLevel( )
{
	SourceViewer viewer = getViewer( );
	IUndoableOperation[] history = viewer == null ? null
			: OperationHistoryFactory.getOperationHistory( )
					.getUndoHistory( new ObjectUndoContext( viewer.getDocument( ) ) );

	return history == null ? -1 : history.length;
}
 

开发者ID:eclipse,
项目名称:birt,
代码行数:15,
代码来源:JSEditor.java

示例8: getUndoContext

点赞 2

import org.eclipse.core.commands.operations.ObjectUndoContext; //导入依赖的package包/类
public static IUndoContext getUndoContext(EditingDomain domain) {
	if (domain != null) {
		return new ObjectUndoContext(domain);
	}
	return IOperationHistory.GLOBAL_UNDO_CONTEXT;
}
 

开发者ID:nasa,
项目名称:OpenSPIFe,
代码行数:7,
代码来源:EMFUtils.java

示例9: getCommand

点赞 2

import org.eclipse.core.commands.operations.ObjectUndoContext; //导入依赖的package包/类
@Override
public Command getCommand(Request request) {
	if (understandsRequest(request)) {
		ChangeBoundsRequest cbr = (ChangeBoundsRequest)request;
		Point location = cbr.getLocation();
		EditPart targetEditPart = getViewer().findObjectAtExcluding(location, Collections.emptyList(), new TreeTimelineDataRowConditional());
		if (targetEditPart != null) {
			Object model = targetEditPart.getModel();
			Set<EPlanElement> elements = new HashSet<EPlanElement>();
			for (Object object : ((ChangeBoundsRequest)request).getEditParts()) {
				EPlanElement pe = null;
				if (object instanceof EPlanElement) {
					pe = (EPlanElement) object;
				} else if (((EditPart)object).getModel() instanceof EPlanElement) {
					pe = (EPlanElement) ((EditPart)object).getModel();
				}
				if (pe != null) {
					elements.add(pe);
				}
			}
			if (!elements.isEmpty()) {
				EditingDomain domain = EMFUtils.getAnyDomain(getTimeline().getTimelineModel());
				if (domain != null) {
					org.eclipse.emf.common.command.Command command = null;
					if (REQ_CHANGE_VALUE_VIA_DROP.equals(request.getType())) {
						command = SetCommand.create(domain, model, null, elements);
					} else if (REQ_ADD_VALUE_VIA_DROP.equals(request.getType())) {
						command = AddCommand.create(domain, model, null, elements);
					}
					if (command != null) {
						IUndoContext undoContext = EMFUtils.getUndoContext(domain);
						CommandUndoableOperation op = new CommandUndoableOperation(domain, command);
						op.addContext(new ObjectUndoContext(domain));
						return new OperationCommand(undoContext, op , getTimeline().getControl(), getViewer().getSite());
					}
				}
			}
		}
	}
	return super.getCommand(request);
}
 

开发者ID:nasa,
项目名称:OpenSPIFe,
代码行数:42,
代码来源:ValueDropEditPolicy.java

示例10: execute

点赞 2

import org.eclipse.core.commands.operations.ObjectUndoContext; //导入依赖的package包/类
@Override
protected void execute() throws Throwable {
	List<EObject> targets = new ArrayList<EObject>();
	List<IItemPropertyDescriptor> pds = new ArrayList<IItemPropertyDescriptor>();
	EObject target = parameter.getTarget();
	if (target instanceof MultiEObject) {
		targets.addAll(((MultiEObject) target).getEObjects());
		pds.addAll(((MultiItemPropertyDescriptor) parameter.getPropertyDescriptor()).getPropertyDescriptors());
	} else {
		targets.add(target);
		pds.add(parameter.getPropertyDescriptor());
	}

	if (targets.isEmpty()) {
		return;
	}

	domain = AdapterFactoryEditingDomain.getEditingDomainFor(targets.get(0));
	ObjectUndoContext domainUndoContext = new ObjectUndoContext(domain);
	if (!hasContext(domainUndoContext)) {
		addContext(domainUndoContext);
	}

	compoundCommand = new CompoundCommand();
	for (int i = 0; i < pds.size(); i++) {
		IItemPropertyDescriptor pd = pds.get(i);
		EObject model = target = targets.get(i);
		EStructuralFeature feature = (EStructuralFeature) pd.getFeature(model);
		EObject commandOwner = EMFDetailUtils.getCommandOwner(pd, model);
		if (commandOwner != null) {
			model = commandOwner;
		}
		for (Object referencedObject : map.keySet()) {
			TriState triState = map.get(referencedObject);
			if (TriState.QUASI == triState) {
				continue;
			}
			boolean contained = ((Collection) model.eGet(feature)).contains(referencedObject);
			TriState originalTriState = originalMap.get(referencedObject);
			if (!CommonUtils.equals(triState, originalTriState)) {
				if (TriState.TRUE == triState && !contained) {
					compoundCommand.append(AddCommand.create(domain, model, feature, referencedObject));
				} else if (TriState.FALSE == triState && contained) {
					compoundCommand.append(RemoveCommand.create(domain, model, feature, referencedObject));
				}
			}
		}
	}
	if (!compoundCommand.isEmpty()) {
		gov.nasa.ensemble.emf.transaction.TransactionUtils.writing(domain, new Runnable() {
			@Override
			public void run() {
				compoundCommand.execute();
			}
		});
	}
}
 

开发者ID:nasa,
项目名称:OpenSPIFe,
代码行数:58,
代码来源:UniqueMultiSelectSetOperation.java

示例11: createEMFTreeTableViewer

点赞 2

import org.eclipse.core.commands.operations.ObjectUndoContext; //导入依赖的package包/类
public static TreeTableViewer<EObject, EAttribute> createEMFTreeTableViewer(Composite parent, EStructuralFeature structuralFeature, EClass eClass, EditingDomain editingDomain, boolean forceTreeParent, boolean useDefaultSortColumn, boolean isScrollable, boolean editable) {
	EPackage ePackage = eClass.getEPackage();
	EObject eObject = ePackage.getEFactoryInstance().create(eClass);
	AdapterFactory domainAdapterFactory = EMFUtils.getAdapterFactory(editingDomain);
	IItemPropertySource source = (IItemPropertySource) domainAdapterFactory.adapt(eObject, IItemPropertySource.class);

	List<ITreeTableColumn> columns = new ArrayList<ITreeTableColumn>();
	for (final IItemPropertyDescriptor descriptor : source.getPropertyDescriptors(eObject)) {
		if (!isVisible(descriptor.getFeature(eObject))) {
			continue;
		}
		DetailProviderParameter parameter = new DetailProviderParameter();
		parameter.setPropertyDescriptor(descriptor);
		parameter.setTarget(eObject);
		ITreeTableColumn column = null;
		IEMFTreeTableProvider provider = EMFUtils.adapt(eObject, IEMFTreeTableProvider.class);
		if (provider != null) {
			column = provider.getTreeTableColumn(parameter);
		}
		if (column == null) {
			String displayName = EMFDetailUtils.getDisplayName(eObject, descriptor);
			int columnWidth = getColumnWidth(eObject, descriptor);
			column = new ValidatedReferenceTreeTableColumn(parameter, displayName, columnWidth, editable);
		}
		columns.add(column);
	}
	
	TreeTableColumnConfiguration configuration = new TreeTableColumnConfiguration(columns.get(0), columns, (useDefaultSortColumn) ? columns.get(0) : null);
	TreeTableComposite composite = new TreeTableComposite(parent, configuration, useDefaultSortColumn, isScrollable);
	// this odd "if" preserves existing semantics that conflated sorting with layouts
	if (useDefaultSortColumn) {
		composite.setLayout(new FillLayout());
	} else {
		composite.setLayout(new TreeTableColumnLayout(true));
	}
	TreeTableViewer<EObject, EAttribute> viewer = new ReflowingTreeTableViewer<EObject, EAttribute>(composite, configuration, null);
	
	if(forceTreeParent) {
		viewer.getTree().setParent(parent);
	}
	
	AdapterFactory adapterFactory = EMFUtils.getAdapterFactory(editingDomain);
	viewer.setEditorModel(new IEnsembleEditorModel.STUB(new ObjectUndoContext(editingDomain)));
	viewer.setContentProvider(new EMFTreeTableContentProvider(adapterFactory, structuralFeature, eClass));
	viewer.setLabelProvider(new EMFTreeTableLabelProvider(adapterFactory));
	return viewer;		
}
 

开发者ID:nasa,
项目名称:OpenSPIFe,
代码行数:48,
代码来源:EMFTreeTableUtils.java

示例12: setUp

点赞 2

import org.eclipse.core.commands.operations.ObjectUndoContext; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
	super.setUp();

	undoContext = new ObjectUndoContext(this);
	
	START_ANYTIME_AFTER.getPoint().setEndpoint(Timepoint.START);
	START_ANYTIME_AFTER.setEarliest(TIME_A);
	START_ANYTIME_AFTER.setRationale("START_ANYTIME_AFTER");
	
	START_ANYTIME_BEFORE.getPoint().setEndpoint(Timepoint.START);
	START_ANYTIME_BEFORE.setLatest(TIME_A);
	START_ANYTIME_BEFORE.setRationale("START_ANYTIME_BEFORE");
	
	START_ANYTIME_BEFORE_ZERO_MIN.getPoint().setEndpoint(Timepoint.START);
	START_ANYTIME_BEFORE_ZERO_MIN.setEarliest(TIME_ZERO);
	START_ANYTIME_BEFORE_ZERO_MIN.setLatest(TIME_B);
	START_ANYTIME_BEFORE_ZERO_MIN.setRationale("START_ANYTIME_BEFORE_ZERO_MIN");
	
	START_ANYTIME_BETWEEN.getPoint().setEndpoint(Timepoint.START);
	START_ANYTIME_BETWEEN.setEarliest(TIME_A);
	START_ANYTIME_BETWEEN.setLatest(TIME_B);
	START_ANYTIME_BETWEEN.setRationale("START_ANYTIME_BETWEEN");
	
	START_EXACTLY_AT.getPoint().setEndpoint(Timepoint.START);
	START_EXACTLY_AT.setEarliest(TIME_A);
	START_EXACTLY_AT.setLatest(TIME_A);
	START_EXACTLY_AT.setRationale("START_EXACTLY_AT");
	
	END_ANYTIME_AFTER.getPoint().setEndpoint(Timepoint.END);
	END_ANYTIME_AFTER.setEarliest(TIME_B);
	END_ANYTIME_AFTER.setRationale("END_ANYTIME_AFTER");
	
	END_ANYTIME_BEFORE.getPoint().setEndpoint(Timepoint.END);
	END_ANYTIME_BEFORE.setLatest(TIME_B);
	END_ANYTIME_BEFORE.setRationale("END_ANYTIME_BEFORE");
	
	END_ANYTIME_BEFORE_ZERO_MIN.getPoint().setEndpoint(Timepoint.END);
	END_ANYTIME_BEFORE_ZERO_MIN.setEarliest(TIME_ZERO);
	END_ANYTIME_BEFORE_ZERO_MIN.setLatest(TIME_B);
	END_ANYTIME_BEFORE_ZERO_MIN.setRationale("END_ANYTIME_BEFORE_ZERO_MIN");
	
	END_EXACTLY_AT.getPoint().setEndpoint(Timepoint.END);
	END_EXACTLY_AT.setEarliest(TIME_A);
	END_EXACTLY_AT.setLatest(TIME_A);
	END_EXACTLY_AT.setRationale("END_EXACTLY_AT");
	
	END_ANYTIME_BETWEEN.getPoint().setEndpoint(Timepoint.END);
	END_ANYTIME_BETWEEN.setEarliest(TIME_A);
	END_ANYTIME_BETWEEN.setLatest(TIME_B);
	END_ANYTIME_BETWEEN.setRationale("END_ANYTIME_BETWEEN");
}
 

开发者ID:nasa,
项目名称:OpenSPIFe,
代码行数:53,
代码来源:TestTemporalBoundColumn.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)