本文整理汇总了Java中org.eclipse.emf.common.command.Command类的典型用法代码示例。如果您正苦于以下问题:Java Command类的具体用法?Java Command怎么用?Java Command使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Command类属于org.eclipse.emf.common.command包,在下文中一共展示了Command类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: popStackFrameReply
import org.eclipse.emf.common.command.Command; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @see org.eclipse.gemoc.dsl.debug.ide.IModelUpdater#popStackFrameReply(org.eclipse.gemoc.dsl.debug.Thread)
*/
public StackFrame popStackFrameReply(final Thread thread) {
final Command command = new RecordingCommand(domain, "Pop Stack Frame Reply") {
StackFrame res;
@Override
protected void doExecute() {
res = ThreadUtils.popStackFrameReply(thread);
}
@Override
public Collection<?> getResult() {
final java.util.List<Object> list = new ArrayList<Object>();
list.add(res);
return list;
}
};
doExecute(command);
return (StackFrame)command.getResult().iterator().next();
}
示例2: pushStackFrameReply
import org.eclipse.emf.common.command.Command; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @see org.eclipse.gemoc.dsl.debug.ide.IModelUpdater#pushStackFrameReply(org.eclipse.gemoc.dsl.debug.Thread,
* java.lang.String, org.eclipse.emf.ecore.EObject, org.eclipse.emf.ecore.EObject, boolean)
*/
public StackFrame pushStackFrameReply(final Thread thread, final String name, final EObject context,
final EObject instruction, final boolean canStepInto) {
final Command command = new RecordingCommand(domain, "Push Stack Frame Reply") {
StackFrame res;
@Override
protected void doExecute() {
res = ThreadUtils.pushStackFrameReply(thread, name, context, instruction, canStepInto);
}
@Override
public Collection<?> getResult() {
final java.util.List<Object> list = new ArrayList<Object>();
list.add(res);
return list;
}
};
doExecute(command);
return (StackFrame)command.getResult().iterator().next();
}
示例3: commandStackChanged
import org.eclipse.emf.common.command.Command; //导入依赖的package包/类
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();
}
}
}
});
}
示例4: doExecute
import org.eclipse.emf.common.command.Command; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.transaction.RecordingCommand#doExecute()
*/
@Override
protected void doExecute() {
if (this.layers.isEmpty() && this.representation instanceof DDiagram) {
this.exportedDiagram = (DDiagram) this.representation;
if (!isRepresentationOpened && refreshRepresentations) {
// Force a refresh of the representation
DialectManager.INSTANCE.refresh(exportedDiagram, new NullProgressMonitor());
}
} else {
// copy representation
this.exportedDiagram = (DDiagram) DialectManager.INSTANCE.copyRepresentation(this.representation,
this.representation.getName() + SUFFIXE_COPY, session, MONITOR);
// activate layers list.
Command compoundCmd = activateLayers(this.exportedDiagram);
if (!isRepresentationOpened) {
new GMFDiagramUpdater(session, (DDiagram) representation);
}
session.getTransactionalEditingDomain().getCommandStack().execute(compoundCmd);
}
}
示例5: allocateIds
import org.eclipse.emf.common.command.Command; //导入依赖的package包/类
/**
* Allocates ID's to recently pasted nodes.
*
* @param nodes the recently pasted nodes
* @param command the command responsible for adding the nodes
*/
private void allocateIds(final List<GNode> nodes, final CompoundCommand command) {
final EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor(graphEditor.getModel());
final EAttribute feature = ModelPackage.Literals.GNODE__ID;
for (final GNode node : nodes) {
if (checkNeedsNewId(node, nodes)) {
final String id = allocateNewId();
final Command setCommand = SetCommand.create(domain, node, feature, id);
if (setCommand.canExecute()) {
command.appendAndExecute(setCommand);
}
graphEditor.getSkinLookup().lookupNode(node).initialize();
}
}
}
示例6: execute
import org.eclipse.emf.common.command.Command; //导入依赖的package包/类
@Execute
public void execute(
@Optional @Named(IServiceConstants.ACTIVE_SELECTION) Object selection,
EditingDomainController editingDomainController) {
System.out.println("delete");
if (selection instanceof EObject) {
EditingDomain ed = null; // editingDomainController.getEditingDomain((EObject)
// selection);
if (ed != null) {
Command command = SetCommand.create(ed, selection,
BtsmodelPackage.ADMINISTRATIV_DATA_OBJECT__STATE,
BTSConstants.OBJECT_STATE_TERMINATED);
ed.getCommandStack().execute(command);
}
else {
((AdministrativDataObject) selection)
.setState(BTSConstants.OBJECT_STATE_TERMINATED);
}
}
}
示例7: getTargetEntry
import org.eclipse.emf.common.command.Command; //导入依赖的package包/类
private BTSPassportEntry getTargetEntry(BTSPassportEntry targetEntry,
BTSPassportEntry sourceSubEntry, CompoundCommand compoundCommand) {
BTSPassportEntry targetSubEntry = null;
for (BTSPassportEntry e : targetEntry.getChildren())
{
if (e.getType() != null && e.getType().equals(sourceSubEntry.getType()))
{
return e;
}
}
if (sourceSubEntry instanceof BTSPassportEntryGroup)
{
targetSubEntry = BtsCorpusModelFactory.eINSTANCE.createBTSPassportEntryGroup();
}
else
{
targetSubEntry = BtsCorpusModelFactory.eINSTANCE.createBTSPassportEntryItem();
}
targetSubEntry.setType(sourceSubEntry.getType());
Command addCommand = AddCommand.create(editingDomain, targetEntry, BtsCorpusModelPackage.eINSTANCE.getBTSPassportEntry_Children(), targetSubEntry);
compoundCommand.append(addCommand);
return targetSubEntry;
}
示例8: getTargetEntryFromPassport
import org.eclipse.emf.common.command.Command; //导入依赖的package包/类
private BTSPassportEntry getTargetEntryFromPassport(BTSPassport target,
BTSPassportEntry sourceEntry, CompoundCommand compoundCommand) {
BTSPassportEntry targetEntry = null;
for (BTSPassportEntry e : target.getChildren())
{
if (e.getType() != null && e.getType().equals(sourceEntry.getType()))
{
return e;
}
}
targetEntry = BtsCorpusModelFactory.eINSTANCE.createBTSPassportEntryGroup();
targetEntry.setType(sourceEntry.getType());
Command addCommand = AddCommand.create(editingDomain, target, BtsCorpusModelPackage.eINSTANCE.getBTSPassport_Children(), targetEntry);
compoundCommand.append(addCommand);
return targetEntry;
}
示例9: run
import org.eclipse.emf.common.command.Command; //导入依赖的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();
}
}
}
示例10: persistTracemodel
import org.eclipse.emf.common.command.Command; //导入依赖的package包/类
private void persistTracemodel(String tracemodelPath, EObject stateSystem) {
URI outputUri = EMFUtil.createFileURI(tracemodelPath);
Resource traceResource = resourceSet.createResource(outputUri);
Command cmd = new AddCommand(editingDomain,
traceResource.getContents(), stateSystem);
editingDomain.getCommandStack().execute(cmd);
HashMap<String, Object> options = new HashMap<String, Object>();
options.put(XMIResource.OPTION_SCHEMA_LOCATION, true);
// TODO what is the matter with hrefs?
options.put(XMIResource.OPTION_PROCESS_DANGLING_HREF,
XMIResource.OPTION_PROCESS_DANGLING_HREF_DISCARD);
try {
traceResource.save(options);
} catch (IOException e) {
e.printStackTrace();
Assert.fail();
}
}
示例11: transactionAboutToCommit
import org.eclipse.emf.common.command.Command; //导入依赖的package包/类
@Override
public Command transactionAboutToCommit(ResourceSetChangeEvent event) {
detectDuplicateNotifications(event);
CompoundCommand compound = new SafeCompoundCommand("ConsistencyMaintenance");
for (IConsistencyMaintenanceListener listener : consistencyMaintenanceListeners) {
try {
Command command = listener.createConsistencyMaintenanceCommand(event);
if (command != null) {
compound.append(command);
}
} catch (RuntimeException e) {
String message = "RuntimeException from IConsistencyMaintenanceListener: " + listener.getClass();
Logger.getLogger(ExtensionPointResourceSetListener.class).error(message, e);
}
}
if (compound.isEmpty()) {
return null;
}
return compound;
}
示例12: addTriggers
import org.eclipse.emf.common.command.Command; //导入依赖的package包/类
@Override
public void addTriggers(TriggerCommand triggers) {
// extract out only the triggered commands (exclude the triggering command)
List<Command> triggerCommands = triggers.getTriggers();
Command triggerCommand;
if (triggerCommands.isEmpty()) {
return;
}
// bug 165026: Must copy the list, because it may be read-only like
// GMF's NOOP_TRIGGER command
triggerCommand = new ConditionalRedoCommand.Compound(
new java.util.ArrayList<Command>(triggerCommands));
if (this.triggers == null) {
this.triggers = triggerCommand;
// record the triggers in my change description
triggerChange = new CommandChangeDescription(triggerCommand);
change.add(triggerChange);
} else {
this.triggers = triggerChange.chain(triggerCommand);
}
}
示例13: createSetCommand
import org.eclipse.emf.common.command.Command; //导入依赖的package包/类
@Override
protected Command createSetCommand(EditingDomain domain, EObject owner,
EStructuralFeature feature, Object value, int index) {
if (TemporalPackage.Literals.TEMPORAL_MEMBER__START_TIME == feature) {
return new SetTemporalCommand(domain, owner, feature, value, index);
}
if (TemporalPackage.Literals.TEMPORAL_MEMBER__END_TIME == feature) {
return new SetTemporalCommand(domain, owner, feature, value, index);
}
if (TemporalPackage.Literals.TEMPORAL_MEMBER__DURATION == feature) {
return new SetTemporalCommand(domain, owner, feature, value, index);
}
if (TemporalPackage.Literals.TEMPORAL_MEMBER__SCHEDULED == feature) {
return new SetScheduledCommand(domain, owner, feature, value, index);
}
return super.createSetCommand(domain, owner, feature, value, index);
}
示例14: transactionAboutToCommit
import org.eclipse.emf.common.command.Command; //导入依赖的package包/类
@Override
public Command transactionAboutToCommit(ResourceSetChangeEvent event) {
EPlan plan = getTimeline().getPlan();
List<Notification> notifications = event.getNotifications();
for (Notification notification : notifications) {
Object notifier = notification.getNotifier();
if (notifier instanceof PlanTemporalMember) {
PlanTemporalMember member = (PlanTemporalMember) notifier;
if (member.getPlanElement() == plan) {
Object feature = notification.getFeature();
if (TemporalPackage.Literals.TEMPORAL_MEMBER__START_TIME == feature
|| TemporalPackage.Literals.TEMPORAL_MEMBER__END_TIME == feature
|| TemporalPackage.Literals.PLAN_TEMPORAL_MEMBER__START_BOUNDARY == feature
|| TemporalPackage.Literals.PLAN_TEMPORAL_MEMBER__END_BOUNDARY == feature) {
return new RunnableRecordingCommand("refresh timeline page", new Runnable() {
@Override
public void run() {
refreshPage();
}
});
}
}
}
}
return null;
}
示例15: transactionAboutToCommit
import org.eclipse.emf.common.command.Command; //导入依赖的package包/类
@Override
public Command transactionAboutToCommit(ResourceSetChangeEvent event) {
List<Notification> notifications = event.getNotifications();
for (Notification notification : notifications) {
List<Plot> addedPlots = EMFUtils.getAddedObjects(notification, Plot.class);
List<Plot> removedPlots = EMFUtils.getAddedObjects(notification, Plot.class);
if (!addedPlots.isEmpty() || !removedPlots.isEmpty()) {
return new RunnableRecordingCommand("refresh timeline page", new Runnable() {
@Override
public void run() {
refreshPageInDisplayThread();
}
});
}
}
return null;
}