本文整理汇总了Java中org.eclipse.emf.edit.command.AddCommand类的典型用法代码示例。如果您正苦于以下问题:Java AddCommand类的具体用法?Java AddCommand怎么用?Java AddCommand使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AddCommand类属于org.eclipse.emf.edit.command包,在下文中一共展示了AddCommand类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateTemplateCustomProperties
import org.eclipse.emf.edit.command.AddCommand; //导入依赖的package包/类
/**
* Updates {@link TemplateCustomProperties}.
*
* @param uri
* the template {@link URI}
*/
private void updateTemplateCustomProperties(URI uri) {
final URI absoluteURI = uri.resolve(getGenconfResource().getURI());
if (URIConverter.INSTANCE.exists(absoluteURI, null)) {
try {
templateCustomProperties = POIServices.getInstance().getTemplateCustomProperties(absoluteURI);
final Generation generation = getGeneration();
final List<Definition> newDefinitions = GenconfUtils.getNewDefinitions(generation,
templateCustomProperties);
editingDomain.getCommandStack().execute(AddCommand.create(editingDomain, generation,
GenconfPackage.GENERATION__DEFINITIONS, newDefinitions));
// CHECKSTYLE:OFF
} catch (Exception e) {
// CHECKSTYLE:ON
templateCustomProperties = null;
}
}
}
示例2: setNewJoints
import org.eclipse.emf.edit.command.AddCommand; //导入依赖的package包/类
/**
* Removes any existing joints from the connection and creates a new set of joints at the given positions.
*
* <p>
* This is executed as a single compound command and is therefore a single element in the undo-redo stack.
* </p>
*
* @param positions a list of {@link Point2D} instances speciying the x and y positions of the new joints
* @param connection the connection in which the joints will be set
*/
public static void setNewJoints(final List<Point2D> positions, final GConnection connection) {
final EditingDomain editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(connection);
final CompoundCommand command = new CompoundCommand();
command.append(RemoveCommand.create(editingDomain, connection, JOINTS, connection.getJoints()));
for (final Point2D position : positions) {
final GJoint newJoint = ModelFactory.eINSTANCE.createGJoint();
newJoint.setX(position.getX());
newJoint.setY(position.getY());
command.append(AddCommand.create(editingDomain, connection, JOINTS, newJoint));
}
if (command.canExecute()) {
editingDomain.getCommandStack().execute(command);
}
}
示例3: addPastedElements
import org.eclipse.emf.edit.command.AddCommand; //导入依赖的package包/类
/**
* Adds the pasted elements to the graph editor via a single EMF command.
*
* @param pastedNodes the pasted nodes to be added
* @param pastedConnections the pasted connections to be added
* @param consumer a consumer to allow custom commands to be appended to the paste command
*/
private void addPastedElements(final List<GNode> pastedNodes, final List<GConnection> pastedConnections,
final BiConsumer<List<GNode>, CompoundCommand> consumer) {
final EditingDomain editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(model);
final CompoundCommand command = new CompoundCommand();
for (final GNode pastedNode : pastedNodes) {
command.append(AddCommand.create(editingDomain, model, NODES, pastedNode));
}
for (final GConnection pastedConnection : pastedConnections) {
command.append(AddCommand.create(editingDomain, model, CONNECTIONS, pastedConnection));
}
if (command.canExecute()) {
editingDomain.getCommandStack().execute(command);
}
if (consumer != null) {
consumer.accept(pastedNodes, command);
}
}
示例4: getTargetEntry
import org.eclipse.emf.edit.command.AddCommand; //导入依赖的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;
}
示例5: getTargetEntryFromPassport
import org.eclipse.emf.edit.command.AddCommand; //导入依赖的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;
}
示例6: persistTracemodel
import org.eclipse.emf.edit.command.AddCommand; //导入依赖的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();
}
}
示例7: setNewJoints
import org.eclipse.emf.edit.command.AddCommand; //导入依赖的package包/类
/**
* Removes any existing joints from the connection and creates a new set of joints at the given positions.
*
* <p>
* This is executed as a single compound command and is therefore a single element in the undo-redo stack.
* </p>
*
* @param positions a list of {@link Point2D} instances speciying the x and y positions of the new joints
* @param connection the connection in which the joints will be set
*/
public static void setNewJoints(final List<Point2D> positions, final GConnection connection) {
final EditingDomain editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(connection);
final CompoundCommand command = new CompoundCommand();
command.append(RemoveCommand.create(editingDomain, connection, JOINTS, connection.getJoints()));
for (final Point2D position : positions) {
final GJoint newJoint = GraphFactory.eINSTANCE.createGJoint();
newJoint.setX(position.getX());
newJoint.setY(position.getY());
command.append(AddCommand.create(editingDomain, connection, JOINTS, newJoint));
}
if (command.canExecute()) {
editingDomain.getCommandStack().execute(command);
}
}
示例8: addPerCommand
import org.eclipse.emf.edit.command.AddCommand; //导入依赖的package包/类
/**
* Adds <code>newValue</code> to the many-valued feature of <code>eObject</code> using an AddCommand. Exceptions are
* caught if <code>ignoreAndLog</code> is true, otherwise a RuntimeException might be
* thrown if the command fails.
*
* @param eObject the EObject to which <code>newObject</code> shall be added
* @param feature the EStructuralFeature that <code>newObject</code> shall be added to
* @param newValue the Object that shall be added to <code>feature</code>
* @param index the index where to add the object or null if it should be added to the end.
* @see AddCommand#AddCommand(EditingDomain, EObject, EStructuralFeature, Object)
*/
public void addPerCommand(EObject eObject, EStructuralFeature feature, Object newValue, Integer index) {
try {
if (feature.isUnique() && ((Collection<?>) eObject.eGet(feature)).contains(newValue)) {
// unique feature already contains object -> nothing to do
return;
}
EditingDomain domain = config.getEditingDomain();
if (index == null) {
domain.getCommandStack().execute(new AddCommand(domain, eObject, feature, newValue));
} else {
domain.getCommandStack().execute(new AddCommand(domain, eObject, feature, newValue, index));
}
// BEGIN SUPRESS CATCH EXCEPTION
} catch (RuntimeException e) {
// END SUPRESS CATCH EXCEPTION
handle(e, config);
}
}
示例9: addPerCommand
import org.eclipse.emf.edit.command.AddCommand; //导入依赖的package包/类
/**
* Adds <code>newValue</code> to the many-valued feature of
* <code>eObject</code> using an AddCommand. Exceptions are caught if
* <code>ignoreAndLog</code> is true, otherwise a RuntimeException might be
* thrown if the command fails.
*
* @param eObject
* the EObject to which <code>newObject</code> shall be added
* @param feature
* the EStructuralFeature that <code>newObject</code> shall be
* added to
* @param newValue
* the Object that shall be added to <code>feature</code>
* @param exceptionLog
* the current log of exceptions
* @param ignoreAndLog
* should exceptions be ignored and added to
* <code>exceptionLog</code>?
* @return <code>newValue</code> if the <code>AddCommand</code> was
* performed successful or <code>null</code> if it failed
* @see AddCommand#AddCommand(EditingDomain, EObject, EStructuralFeature,
* Object)
*/
public EObject addPerCommand(EObject eObject,
EStructuralFeature feature, Object newValue,
Set<RuntimeException> exceptionLog, boolean ignoreAndLog) {
EditingDomain domain = AdapterFactoryEditingDomain
.getEditingDomainFor(eObject);
try {
if (feature.isUnique()
&& ((Collection<?>) eObject.eGet(feature))
.contains(newValue)) {
// unique feature already contains object -> nothing to do
return null;
}
new AddCommand(domain, eObject, feature, newValue).doExecute();
if (newValue instanceof EObject) {
return (EObject) newValue;
} else {
return null;
}
} catch (RuntimeException e) {
handle(e, exceptionLog, ignoreAndLog);
return null;
}
}
示例10: setMaster
import org.eclipse.emf.edit.command.AddCommand; //导入依赖的package包/类
public void setMaster ( final MasterServer master, final MasterMode masterMode )
{
final CompoundManager manager = new CompoundManager ();
for ( final MasterAssigned v : SelectionHelper.iterable ( getSelection (), MasterAssigned.class ) )
{
final EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor ( v );
if ( domain == null )
{
continue;
}
switch ( masterMode )
{
case ADD:
manager.append ( domain, AddCommand.create ( domain, v, ComponentPackage.Literals.MASTER_ASSIGNED__MASTER_ON, master ) );
break;
case REPLACE:
manager.append ( domain, SetCommand.create ( domain, v, ComponentPackage.Literals.MASTER_ASSIGNED__MASTER_ON, Collections.singletonList ( master ) ) );
break;
case DELETE:
manager.append ( domain, RemoveCommand.create ( domain, v, ComponentPackage.Literals.MASTER_ASSIGNED__MASTER_ON, master ) );
break;
}
}
manager.executeAll ();
}
示例11: addNode
import org.eclipse.emf.edit.command.AddCommand; //导入依赖的package包/类
/**
* Adds a node to the model.
*
* <p>
* The node's x, y, width, and height values should be set before calling this method.
* </p>
*
* @param model the {@link GModel} to which the node should be added
* @param node the {@link GNode} to add to the model
*/
public static void addNode(final GModel model, final GNode node) {
final EditingDomain editingDomain = getEditingDomain(model);
if (editingDomain != null) {
final Command command = AddCommand.create(editingDomain, model, NODES, node);
if (command.canExecute()) {
editingDomain.getCommandStack().execute(command);
}
}
}
示例12: addConnection
import org.eclipse.emf.edit.command.AddCommand; //导入依赖的package包/类
/**
* Adds a connection to the model.
*
* @param model the {@link GModel} to which the connection should be added
* @param source the source {@link GConnector} of the new connection
* @param target the target {@link GConnector} of the new connection
* @param type the type attribute for the new connection
* @param joints the list of {@link GJoint} instances to be added inside the new connection
* @return the newly-executed {@link CompoundCommand} that added the connection
*/
public static CompoundCommand addConnection(final GModel model, final GConnector source, final GConnector target,
final String type, final List<GJoint> joints) {
final EditingDomain editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(model);
if (editingDomain != null) {
final CompoundCommand command = new CompoundCommand();
final GConnection connection = ModelFactory.eINSTANCE.createGConnection();
command.append(AddCommand.create(editingDomain, model, CONNECTIONS, connection));
if (type != null) {
command.append(SetCommand.create(editingDomain, connection, CONNECTION_TYPE, type));
}
command.append(SetCommand.create(editingDomain, connection, SOURCE, source));
command.append(SetCommand.create(editingDomain, connection, TARGET, target));
command.append(AddCommand.create(editingDomain, source, CONNECTOR_CONNECTIONS, connection));
command.append(AddCommand.create(editingDomain, target, CONNECTOR_CONNECTIONS, connection));
for (final GJoint joint : joints) {
command.append(AddCommand.create(editingDomain, connection, JOINTS, joint));
}
if (command.canExecute()) {
editingDomain.getCommandStack().execute(command);
}
return command;
} else {
return null;
}
}
示例13: checkAndReload
import org.eclipse.emf.edit.command.AddCommand; //导入依赖的package包/类
protected void checkAndReload(Command command) {
if (command instanceof DeleteCommand
|| command instanceof CompoundCommand
|| command instanceof AddCommand
|| command instanceof RemoveCommand) {
loadRelations();
}
}
示例14: checkAndReload
import org.eclipse.emf.edit.command.AddCommand; //导入依赖的package包/类
private void checkAndReload(Command command) {
if (command instanceof DeleteCommand
|| command instanceof CompoundCommand
|| command instanceof AddCommand
|| command instanceof RemoveCommand) {
CTabItem tabItem = tabFolder.getSelection();
reloadGenericTabItem(tabItem);
tabItem.setData("reloaded", genericTabsReloadRequiredCounter++);
}
}
示例15: addNewColumn
import org.eclipse.emf.edit.command.AddCommand; //导入依赖的package包/类
public ColumnEditingFacade addNewColumn() {
Column column = ColumnFactory.eINSTANCE.createColumn();
Command cmd = AddCommand.create(getEditingDomain(),
table,
TablePackage.Literals.TABLE__COLUMNS,
column);
execute(cmd);
return edit(column);
}