本文整理汇总了Java中org.eclipse.emf.edit.command.CommandParameter类的典型用法代码示例。如果您正苦于以下问题:Java CommandParameter类的具体用法?Java CommandParameter怎么用?Java CommandParameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommandParameter类属于org.eclipse.emf.edit.command包,在下文中一共展示了CommandParameter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: run
import org.eclipse.emf.edit.command.CommandParameter; //导入依赖的package包/类
@Override
public void run() {
InputDialog inputDialog = new InputDialog(null, "Provide String", "Provide a new Name for the EClass", eclass.getName(), null);
int open = inputDialog.open();
if (open == Dialog.OK) {
String newName = inputDialog.getValue();
Resource resource = eclass.eResource();
ResourceSet resourceSet = resource.getResourceSet();
TransactionalEditingDomain domain = TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain(resourceSet);
try{
if (domain != null){
Command setCommand = domain.createCommand(SetCommand.class, new CommandParameter(eclass,
EcorePackage.Literals.ENAMED_ELEMENT__NAME, newName));
domain.getCommandStack().execute(setCommand);
try {
resource.save(Collections.emptyMap());
} catch (IOException e) {
e.printStackTrace();
}
}
}finally{
domain.dispose();
}
}
}
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:26,代码来源:RenameActionProvider.java
示例2: createCommand
import org.eclipse.emf.edit.command.CommandParameter; //导入依赖的package包/类
@Override
public Command createCommand(Object object, final EditingDomain domain, Class<? extends Command> commandClass, CommandParameter commandParameter) {
final ReferencedObjectRow row = (ReferencedObjectRow) object;
if (SetCommand.class == commandClass) {
return createSetCommand(row, domain, commandParameter);
} else if (AddCommand.class == commandClass) {
return createAddCommand(row, domain, commandParameter);
}
return super.createCommand(object, domain, commandClass, commandParameter);
}
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:11,代码来源:ReferencedObjectRowItemProvider.java
示例3: createAddCommand
import org.eclipse.emf.edit.command.CommandParameter; //导入依赖的package包/类
private Command createAddCommand(final ReferencedObjectRow row, final EditingDomain domain, CommandParameter commandParameter) {
final CompoundCommand cmd = new CompoundCommand();
for (EPlanElement pe : getPlanElements(commandParameter.getCollection())) {
new PlanVisitor() {
@Override
protected void visit(EPlanElement element) {
EObject data = element.getData();
if (data != null) {
for (EReference r : data.eClass().getEReferences()) {
EObject reference = row.getReference();
if (r.getEReferenceType().isSuperTypeOf(reference.eClass())) {
if (r.isMany()) {
cmd.append(AddCommand.create(domain, data, r, Collections.singletonList(reference)));
} else {
cmd.append(SetCommand.create(domain, data, r, reference));
}
}
}
}
}
}.visitAll(pe);
}
if (!cmd.isEmpty()) {
return cmd;
} else {
return null;
}
}
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:30,代码来源:ReferencedObjectRowItemProvider.java
示例4: createSetCommand
import org.eclipse.emf.edit.command.CommandParameter; //导入依赖的package包/类
private Command createSetCommand(final ReferencedObjectRow row, final EditingDomain domain, CommandParameter commandParameter) {
final CompoundCommand cmd = new CompoundCommand();
for (EPlanElement pe : getPlanElements(commandParameter.getValue())) {
new PlanVisitor() {
@Override
protected void visit(EPlanElement element) {
EObject data = element.getData();
if (data != null) {
for (EReference r : data.eClass().getEReferences()) {
EObject reference = row.getReference();
if (r.getEReferenceType().isSuperTypeOf(reference.eClass())) {
if (r.isMany()) {
cmd.append(SetCommand.create(domain, data, r, Collections.singletonList(reference)));
} else {
cmd.append(SetCommand.create(domain, data, r, reference));
}
}
}
}
}
}.visitAll(pe);
}
if (!cmd.isEmpty()) {
return cmd;
} else {
return null;
}
}
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:30,代码来源:ReferencedObjectRowItemProvider.java
示例5: createCommand
import org.eclipse.emf.edit.command.CommandParameter; //导入依赖的package包/类
@Override
public Command createCommand(Object object, final EditingDomain domain, Class<? extends Command> commandClass, CommandParameter commandParameter) {
final FeatureValueRow row = (FeatureValueRow) object;
if (SetCommand.class == commandClass) {
return createSetCommand(row, domain, commandParameter);
} else if (AddCommand.class == commandClass) {
return createAddCommand(row, domain, commandParameter);
}
return super.createCommand(object, domain, commandClass, commandParameter);
}
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:11,代码来源:FeatureValueRowItemProvider.java
示例6: createAddCommand
import org.eclipse.emf.edit.command.CommandParameter; //导入依赖的package包/类
private Command createAddCommand(final FeatureValueRow row, final EditingDomain domain, CommandParameter commandParameter) {
final CompoundCommand cmd = new CompoundCommand();
for (EPlanElement pe : getPlanElements(commandParameter.getCollection())) {
new PlanVisitor() {
@Override
protected void visit(EPlanElement element) {
EObject data = element.getData();
if (data != null) {
String valueLiteral = row.getValueLiteral();
String featureName = row.getFeatureName();
EClass eClass = data.eClass();
EStructuralFeature feature = eClass.getEStructuralFeature(featureName);
if (feature != null) {
Object value = null;
if (feature instanceof EAttribute) {
EAttribute eAttribute = (EAttribute)feature;
value = EcoreUtil.createFromString(eAttribute.getEAttributeType(), valueLiteral);
} else {
LogUtil.error("value for attribute literal impossible");
}
if (value != null) {
if (feature.isMany()) {
cmd.append(AddCommand.create(domain, data, feature, Collections.singletonList(value)));
} else {
cmd.append(SetCommand.create(domain, data, feature, value));
}
}
}
}
}
}.visitAll(pe);
}
if (!cmd.isEmpty()) {
return cmd;
}
return null;
}
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:38,代码来源:FeatureValueRowItemProvider.java
示例7: createSetCommand
import org.eclipse.emf.edit.command.CommandParameter; //导入依赖的package包/类
private Command createSetCommand(final FeatureValueRow row, final EditingDomain domain, CommandParameter commandParameter) {
final CompoundCommand cmd = new CompoundCommand();
for (EPlanElement pe : getPlanElements(commandParameter.getValue())) {
new PlanVisitor() {
@Override
protected void visit(EPlanElement element) {
EObject data = element.getData();
if (data != null) {
String valueLiteral = row.getValueLiteral();
String featureName = row.getFeatureName();
EClass eClass = data.eClass();
EStructuralFeature feature = eClass.getEStructuralFeature(featureName);
if (feature != null) {
Object value = null;
if (feature instanceof EAttribute) {
EAttribute eAttribute = (EAttribute)feature;
value = EcoreUtil.createFromString(eAttribute.getEAttributeType(), valueLiteral);
} else {
LogUtil.error("value for EReference literal impossible");
}
if (value != null) {
if (feature.isMany()) {
cmd.append(SetCommand.create(domain, data, feature, Collections.singletonList(value)));
} else {
cmd.append(SetCommand.create(domain, data, feature, value));
}
}
}
}
}
}.visitAll(pe);
}
if (!cmd.isEmpty()) {
return cmd;
}
return super.createCommand(row, domain, SetCommand.class, commandParameter);
}
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:38,代码来源:FeatureValueRowItemProvider.java
示例8: copyAndPasteFromClipboardCommand
import org.eclipse.emf.edit.command.CommandParameter; //导入依赖的package包/类
/**
* Tests the copy to clipboard and paste from clipboard command.
*/
@Test
public void copyAndPasteFromClipboardCommand() {
final TestElement leafSection = Create.testElement();
final TestElement actor = Create.testElement();
leafSection.getContainedElements().add(actor);
new EMFStoreCommand() {
@Override
protected void doRun() {
getProject().addModelElement(leafSection);
}
}.run(false);
final EditingDomain editingDomain = ESWorkspaceProviderImpl.getInstance().getEditingDomain();
// copy to clipboard
final Collection<EObject> toCopy = new ArrayList<EObject>();
toCopy.add(actor);
final Command copyCommand = editingDomain.createCommand(CopyToClipboardCommand.class, new CommandParameter(
null,
null, toCopy));
editingDomain.getCommandStack().execute(copyCommand);
// paste from clipboard
final Command pasteCommand = editingDomain.createCommand(PasteFromClipboardCommand.class, new CommandParameter(
leafSection, TestmodelPackage.Literals.TEST_ELEMENT__CONTAINED_ELEMENTS, Collections.emptyList(),
CommandParameter.NO_INDEX));
editingDomain.getCommandStack().execute(pasteCommand);
final EObject copyOfTestElement = leafSection.getContainedElements().get(1);
final ModelElementId actorId = ModelUtil.getProject(actor).getModelElementId(actor);
final ModelElementId copyOfTestElementId = ModelUtil.getProject(copyOfTestElement).getModelElementId(
copyOfTestElement);
assertTrue(actorId.equals(actorId));
assertTrue(!copyOfTestElementId.equals(actorId));
}
开发者ID:edgarmueller,项目名称:emfstore-rest,代码行数:43,代码来源:CommandTest.java
示例9: copyAndPasteFromClipboardCommandDirectCreation
import org.eclipse.emf.edit.command.CommandParameter; //导入依赖的package包/类
/**
* Tests the copy to clipboard and paste from clipboard command.
*/
@Test
public void copyAndPasteFromClipboardCommandDirectCreation() {
final TestElement leafSection = Create.testElement();
final TestElement actor = Create.testElement();
leafSection.getContainedElements().add(actor);
new EMFStoreCommand() {
@Override
protected void doRun() {
getProject().addModelElement(leafSection);
}
}.run(false);
final EditingDomain editingDomain = ESWorkspaceProviderImpl.getInstance().getEditingDomain();
// copy
final Command command = CopyToClipboardCommand.create(editingDomain, actor);
editingDomain.getCommandStack().execute(command);
// paste
final Command pasteCommand = PasteFromClipboardCommand.create(editingDomain, leafSection,
TestmodelPackage.Literals.TEST_ELEMENT__CONTAINED_ELEMENTS, CommandParameter.NO_INDEX);
editingDomain.getCommandStack().execute(pasteCommand);
final EObject copyOfTestElementRead = leafSection.getContainedElements().get(1);
final ModelElementId actorId = ModelUtil.getProject(actor).getModelElementId(actor);
final ModelElementId copyOfTestElementReadId = ModelUtil.getProject(copyOfTestElementRead).getModelElementId(
copyOfTestElementRead);
assertFalse(actorId.equals(copyOfTestElementReadId));
}
开发者ID:edgarmueller,项目名称:emfstore-rest,代码行数:36,代码来源:CommandTest.java
示例10: copyAndPasteCommandDirectCreation
import org.eclipse.emf.edit.command.CommandParameter; //导入依赖的package包/类
/**
* Tests the copy and paste commands.
*/
@Test
public void copyAndPasteCommandDirectCreation() {
final TestElement leafSection = Create.testElement();
final TestElement actor = Create.testElement();
leafSection.getContainedElements().add(actor);
new EMFStoreCommand() {
@Override
protected void doRun() {
getProject().addModelElement(leafSection);
}
}.run(false);
final EditingDomain editingDomain = ESWorkspaceProviderImpl.getInstance().getEditingDomain();
// copy
final Command command = CopyCommand.create(editingDomain, actor);
editingDomain.getCommandStack().execute(command);
// paste
final TestElement copyOfTestElement = (TestElement) command.getResult().toArray()[0];
final Collection<TestElement> toPaste = new ArrayList<TestElement>();
toPaste.add(copyOfTestElement);
final Command pasteCommand = AddCommand.create(editingDomain, leafSection,
TestmodelPackage.Literals.TEST_ELEMENT__CONTAINED_ELEMENTS, toPaste, CommandParameter.NO_INDEX);
editingDomain.getCommandStack().execute(pasteCommand);
final EObject copyOfTestElementRead = leafSection.getContainedElements().get(1);
final ModelElementId actorId = ModelUtil.getProject(actor).getModelElementId(actor);
final ModelElementId copyOfTestElementReadId = ModelUtil.getProject(copyOfTestElementRead).getModelElementId(
copyOfTestElementRead);
assertFalse(actorId.equals(copyOfTestElementReadId));
}
开发者ID:edgarmueller,项目名称:emfstore-rest,代码行数:42,代码来源:CommandTest.java
示例11: removeCommand
import org.eclipse.emf.edit.command.CommandParameter; //导入依赖的package包/类
/**
* Tests the remove command.
*/
@Test
public void removeCommand() {
final TestElement leafSection = Create.testElement();
final TestElement actor = Create.testElement();
leafSection.getContainedElements().add(actor);
new EMFStoreCommand() {
@Override
protected void doRun() {
getProject().addModelElement(leafSection);
}
}.run(false);
final EditingDomain editingDomain = ESWorkspaceProviderImpl.getInstance().getEditingDomain();
// remove
final Collection<TestElement> toRemove = new ArrayList<TestElement>();
toRemove.add(actor);
final Command copyCommand = editingDomain.createCommand(RemoveCommand.class, new CommandParameter(leafSection,
TestmodelPackage.Literals.TEST_ELEMENT__CONTAINED_ELEMENTS, toRemove));
if (copyCommand.canExecute()) {
editingDomain.getCommandStack().execute(copyCommand);
} else {
fail(COMMAND_NOT_EXECUTABLE);
}
assertEquals(0, leafSection.getContainedElements().size());
assertTrue(editingDomain.getCommandStack().canUndo());
// undo the command
editingDomain.getCommandStack().undo();
assertEquals(1, leafSection.getContainedElements().size());
assertTrue(editingDomain.getCommandStack().canRedo());
// redo the command
editingDomain.getCommandStack().redo();
assertEquals(0, leafSection.getContainedElements().size());
}
开发者ID:edgarmueller,项目名称:emfstore-rest,代码行数:42,代码来源:CommandTest.java
示例12: getNewChildDescriptor
import org.eclipse.emf.edit.command.CommandParameter; //导入依赖的package包/类
/**
* Returns the new child descriptor for creating a new child of the given feature for the given object.
*
* @param eObject the object a child should created for
* @param childFeature the feature of the children
* @return the {@link CommandParameter} (new child descriptor)
*/
public static CommandParameter getNewChildDescriptor(EObject eObject, EStructuralFeature childFeature) {
EditingDomain editingDomain = getEditingDomain(eObject);
ItemProviderAdapter itemProvider = getItemProvider(eObject);
for (Object object : itemProvider.getNewChildDescriptors(eObject, editingDomain, null)) {
CommandParameter childDescriptor = (CommandParameter) object;
if (childDescriptor.getFeature() == childFeature) {
return childDescriptor;
}
}
return null;
}
开发者ID:mjorod,项目名称:textram,代码行数:21,代码来源:EMFEditUtil.java
示例13: createCommand
import org.eclipse.emf.edit.command.CommandParameter; //导入依赖的package包/类
@Override
public Command createCommand ( final Object object, final EditingDomain domain, final Class<? extends Command> commandClass, final CommandParameter commandParameter )
{
// TODO Auto-generated method stub
return super.createCommand ( object, domain, commandClass, commandParameter );
}
开发者ID:eclipse,项目名称:neoscada,代码行数:7,代码来源:LevelItemProvider.java
示例14: selectionChanged
import org.eclipse.emf.edit.command.CommandParameter; //导入依赖的package包/类
/**
* This implements {@link org.eclipse.jface.viewers.ISelectionChangedListener},
* handling {@link org.eclipse.jface.viewers.SelectionChangedEvent}s by querying for the children and siblings
* that can be added to the selected object and updating the menus accordingly.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
public void selectionChanged(SelectionChangedEvent event) {
// Remove any menu items for old selection.
//
if (createChildMenuManager != null) {
depopulateManager(createChildMenuManager, createChildActions);
}
if (createSiblingMenuManager != null) {
depopulateManager(createSiblingMenuManager, createSiblingActions);
}
if (createPolicyMenuManager != null) {
depopulateManager(createPolicyMenuManager, createSiblingActions);
}
// Query the new selection for appropriate new child/sibling descriptors
//
Collection<?> newChildDescriptors = null;
Collection<?> newSiblingDescriptors = null;
ISelection selection = event.getSelection();
if (selection instanceof IStructuredSelection && ((IStructuredSelection)selection).size() == 1) {
Object object = ((IStructuredSelection)selection).getFirstElement();
EditingDomain domain = ((IEditingDomainProvider)activeEditorPart).getEditingDomain();
newChildDescriptors = domain.getNewChildDescriptors(object, null);
newSiblingDescriptors = domain.getNewChildDescriptors(null, object);
}
Collection<Object> newPolicyDescriptors = new LinkedList<Object>();
if (newChildDescriptors != null) {
for(Object p: newChildDescriptors) {
if (p instanceof CommandParameter && ((CommandParameter)p).value instanceof SchedulingPolicy) {
newPolicyDescriptors.add(p);
}
}
}
createPolicyActions = generateCreateChildActions(newPolicyDescriptors, selection);
// Generate actions for selection; populate and redraw the menus.
//
createChildActions = generateCreateChildActions(newChildDescriptors, selection);
createSiblingActions = generateCreateSiblingActions(newSiblingDescriptors, selection);
if (createChildMenuManager != null) {
populateManager(createChildMenuManager, createChildActions, null);
createChildMenuManager.update(true);
}
if (createSiblingMenuManager != null) {
populateManager(createSiblingMenuManager, createSiblingActions, null);
createSiblingMenuManager.update(true);
}
if (createPolicyMenuManager != null) {
populateManager(createPolicyMenuManager, createPolicyActions, null);
createPolicyMenuManager.update(true);
}
}
开发者ID:polarsys,项目名称:time4sys,代码行数:64,代码来源:DesignActionBarContributor.java
示例15: PlanElementDelegatingWrapperItemProvider
import org.eclipse.emf.edit.command.CommandParameter; //导入依赖的package包/类
public PlanElementDelegatingWrapperItemProvider(Object value, Object owner, AdapterFactory adapterFactory) {
super(value, owner, null, CommandParameter.NO_INDEX, adapterFactory);
}
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:4,代码来源:PlanElementDelegatingWrapperItemProvider.java
示例16: copyAndPasteCommand
import org.eclipse.emf.edit.command.CommandParameter; //导入依赖的package包/类
/**
* Tests the copy and paste commands.
*/
@Test
public void copyAndPasteCommand() {
final TestElement leafSection = Create.testElement();
final TestElement actor = Create.testElement();
leafSection.getContainedElements().add(actor);
new EMFStoreCommand() {
@Override
protected void doRun() {
getProject().addModelElement(leafSection);
}
}.run(false);
final EditingDomain editingDomain = ESWorkspaceProviderImpl.getInstance().getEditingDomain();
// copy
final CopyCommand.Helper helper = new CopyCommand.Helper();
final CopyCommand command = (CopyCommand) editingDomain.createCommand(CopyCommand.class, new CommandParameter(
actor,
null, helper));
editingDomain.getCommandStack().execute(command);
// paste
final TestElement copyOfTestElement = (TestElement) helper.get(actor);
final Collection<TestElement> toPaste = new ArrayList<TestElement>();
toPaste.add(copyOfTestElement);
final Command pasteCommand = editingDomain.createCommand(AddCommand.class, new CommandParameter(leafSection,
TestmodelPackage.Literals.TEST_ELEMENT__CONTAINED_ELEMENTS, toPaste, CommandParameter.NO_INDEX));
editingDomain.getCommandStack().execute(pasteCommand);
final EObject copyOfTestElementRead = leafSection.getContainedElements().get(1);
final ModelElementId actorId = ModelUtil.getProject(actor).getModelElementId(actor);
final ModelElementId copyOfTestElementReadId = ModelUtil.getProject(copyOfTestElementRead).getModelElementId(
copyOfTestElementRead);
assertFalse(actorId.equals(copyOfTestElementReadId));
}
开发者ID:edgarmueller,项目名称:emfstore-rest,代码行数:46,代码来源:CommandTest.java
示例17: cutAndPasteFromClipboardCommand
import org.eclipse.emf.edit.command.CommandParameter; //导入依赖的package包/类
/**
* Tests the copy to clipboard and paste from clipboard command.
*/
@Test
public void cutAndPasteFromClipboardCommand() {
final TestElement leafSection = Create.testElement();
final TestElement actor = Create.testElement();
leafSection.getContainedElements().add(actor);
ProjectUtil.addElement(getProjectSpace().toAPI(), leafSection);
final EditingDomain editingDomain = ESWorkspaceProviderImpl.getInstance().getEditingDomain();
// cut to clipboard
final Collection<TestElement> toCut = new ArrayList<TestElement>();
toCut.add(actor);
final Command copyCommand = editingDomain.createCommand(CutToClipboardCommand.class, new CommandParameter(
leafSection, TestmodelPackage.Literals.TEST_ELEMENT__CONTAINED_ELEMENTS, toCut));
editingDomain.getCommandStack().execute(copyCommand);
assertEquals(0, leafSection.getContainedElements().size());
assertTrue(editingDomain.getCommandStack().canUndo());
// undo the cut command
editingDomain.getCommandStack().undo();
assertEquals(1, leafSection.getContainedElements().size());
assertTrue(editingDomain.getCommandStack().canRedo());
// redo the cut command
editingDomain.getCommandStack().redo();
assertEquals(0, leafSection.getContainedElements().size());
// paste from clipboard
final Command pasteCommand = editingDomain.createCommand(PasteFromClipboardCommand.class, new CommandParameter(
leafSection,
TestmodelPackage.Literals.TEST_ELEMENT__CONTAINED_ELEMENTS, Collections.emptyList(),
CommandParameter.NO_INDEX));
editingDomain.getCommandStack().execute(pasteCommand);
// assert that the ids are not equal
assertEquals(1, leafSection.getContainedElements().size());
// undo the paste command
editingDomain.getCommandStack().undo();
assertEquals(0, leafSection.getContainedElements().size());
// redo the paste command
editingDomain.getCommandStack().redo();
assertEquals(1, leafSection.getContainedElements().size());
}
开发者ID:edgarmueller,项目名称:emfstore-rest,代码行数:58,代码来源:CommandTest.java
示例18: cutAndPasteFromClipboardCommand_DirectCreation
import org.eclipse.emf.edit.command.CommandParameter; //导入依赖的package包/类
/**
* Tests the cut to clipboard and paste from clipboard command.
*/
@Test
public void cutAndPasteFromClipboardCommand_DirectCreation() {
final TestElement leafSection = Create.testElement();
final TestElement actor = Create.testElement();
leafSection.getContainedElements().add(actor);
new EMFStoreCommand() {
@Override
protected void doRun() {
getProject().addModelElement(leafSection);
}
}.run(false);
final EditingDomain editingDomain = ESWorkspaceProviderImpl.getInstance().getEditingDomain();
// copy to clipboard
final Command cutCommand = CutToClipboardCommand.create(editingDomain, leafSection,
TestmodelPackage.Literals.TEST_ELEMENT__CONTAINED_ELEMENTS, actor);
if (cutCommand.canExecute()) {
editingDomain.getCommandStack().execute(cutCommand);
} else {
fail(COMMAND_NOT_EXECUTABLE);
}
assertEquals(0, leafSection.getContainedElements().size());
assertTrue(editingDomain.getCommandStack().canUndo());
// undo the cut command
editingDomain.getCommandStack().undo();
assertEquals(1, leafSection.getContainedElements().size());
assertTrue(editingDomain.getCommandStack().canRedo());
// redo the cut command
editingDomain.getCommandStack().redo();
assertEquals(0, leafSection.getContainedElements().size());
// paste from clipboard
final Command pasteCommand = PasteFromClipboardCommand.create(editingDomain, leafSection,
TestmodelPackage.Literals.TEST_ELEMENT__CONTAINED_ELEMENTS,
CommandParameter.NO_INDEX);
if (pasteCommand.canExecute()) {
editingDomain.getCommandStack().execute(pasteCommand);
assertEquals(1, leafSection.getContainedElements().size());
} else {
fail(COMMAND_NOT_EXECUTABLE);
}
// undo the paste command
editingDomain.getCommandStack().undo();
assertEquals(0, leafSection.getContainedElements().size());
// redo the paste command
editingDomain.getCommandStack().redo();
assertEquals(1, leafSection.getContainedElements().size());
}
开发者ID:edgarmueller,项目名称:emfstore-rest,代码行数:62,代码来源:CommandTest.java
示例19: deleteCommand
import org.eclipse.emf.edit.command.CommandParameter; //导入依赖的package包/类
/**
* Tests the delete command.
*/
@Test
public void deleteCommand() {
final TestElement leafSection = Create.testElement();
final TestElement actor = Create.testElement();
leafSection.getContainedElements().add(actor);
Add.toProject(getLocalProject(), leafSection);
clearOperations();
assertEquals(0, getProjectSpace().getOperations().size());
final EditingDomain editingDomain = ESWorkspaceProviderImpl.getInstance().getEditingDomain();
// delete
final Collection<TestElement> toDelete = new ArrayList<TestElement>();
toDelete.add(actor);
// delete actor from model elements feature
final Command command = editingDomain.createCommand(DeleteCommand.class, new CommandParameter(leafSection,
TestmodelPackage.Literals.TEST_ELEMENT__CONTAINED_ELEMENTS, toDelete));
if (command.canExecute()) {
editingDomain.getCommandStack().execute(command);
} else {
fail(COMMAND_NOT_EXECUTABLE);
}
assertEquals(0, leafSection.getContainedElements().size());
// undo delete
assertTrue(editingDomain.getCommandStack().canUndo());
assertEquals(1, getProjectSpace().getOperations().size());
// undo the command - add actor to model elements feature
editingDomain.getCommandStack().undo();
assertEquals(1, leafSection.getContainedElements().size());
// // assertEquals(0, getProjectSpace().getOperations().size());
assertTrue(editingDomain.getCommandStack().canRedo());
// redo the command - delete again
editingDomain.getCommandStack().redo();
assertEquals(0, leafSection.getContainedElements().size());
}
开发者ID:edgarmueller,项目名称:emfstore-rest,代码行数:48,代码来源:CommandTest.java
示例20: cutAndPasteFromClipboardCommandComplex
import org.eclipse.emf.edit.command.CommandParameter; //导入依赖的package包/类
public void cutAndPasteFromClipboardCommandComplex() {
final TestElement leafSection = Create.testElement();
final TestElement workPackage = Create.testElement();
final TestElement user = Create.testElement();
workPackage.setName(SPRINT1);
workPackage.setNonContained_NTo1(user);
final TestElement ai1 = Create.testElement();
ai1.setName(AI12);
ai1.setContainer2(workPackage);
final TestElement ai2 = Create.testElement();
ai2.setName(AI22);
ai2.setContainer2(workPackage);
leafSection.getContainedElements().add(workPackage);
leafSection.getContainedElements().add(user);
new EMFStoreCommand() {
@Override
protected void doRun() {
getProject().addModelElement(leafSection);
clearOperations();
}
}.run(false);
final ModelElementId workPackageId = getProject().getModelElementId(workPackage);
final EditingDomain editingDomain = ESWorkspaceProviderImpl.getInstance().getEditingDomain();
// cut the element
final Command command = CutToClipboardCommand.create(editingDomain, workPackage);
editingDomain.getCommandStack().execute(command);
assertTrue(ESWorkspaceProviderImpl.getInstance().getEditingDomain().getClipboard().contains(workPackage));
assertEquals(1, ModelUtil.getAllContainedModelElements(leafSection, false).size());
assertTrue(getProject().contains(workPackageId));
final Command pasteCommand = PasteFromClipboardCommand.create(editingDomain, leafSection,
TestmodelPackage.Literals.TEST_ELEMENT__CONTAINED_ELEMENTS, CommandParameter.NO_INDEX);
editingDomain.getCommandStack().execute(pasteCommand);
assertEquals(4, ModelUtil.getAllContainedModelElements(leafSection, false).size());
assertTrue(getProject().contains(workPackageId));
assertEquals(2, getProjectSpace().getOperations().size());
}
开发者ID:edgarmueller,项目名称:emfstore-rest,代码行数:48,代码来源:CommandTest.java
注:本文中的org.eclipse.emf.edit.command.CommandParameter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论