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


Java SetCommand类代码示例

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


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

示例1: execute

import org.eclipse.emf.edit.command.SetCommand; //导入依赖的package包/类
@Override
public Object execute ( final ExecutionEvent event ) throws ExecutionException
{

    final IEditorPart editor = getActivePage ().getActiveEditor ();

    byte b = (byte)1;
    for ( final Attribute attribute : SelectionHelper.iterable ( getSelection (), Attribute.class ) )
    {
        EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor ( attribute );

        if ( domain == null && editor instanceof IEditingDomainProvider )
        {
            domain = ( (IEditingDomainProvider)editor ).getEditingDomain ();
        }

        SetCommand.create ( domain, attribute, ProtocolPackage.Literals.ATTRIBUTE__FIELD_NUMBER, b ).execute ();

        b++;
    }

    return null;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:24,代码来源:FillFieldNumbersHandler.java

示例2: setConnection

import org.eclipse.emf.edit.command.SetCommand; //导入依赖的package包/类
public void setConnection ( final Driver driver )
{
    final CompoundManager manager = new CompoundManager ();

    for ( final ExternalValue v : SelectionHelper.iterable ( getSelection (), ExternalValue.class ) )
    {
        final EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor ( v );
        if ( domain == null )
        {
            continue;
        }
        manager.append ( domain, SetCommand.create ( domain, v, ComponentPackage.Literals.EXTERNAL_VALUE__CONNECTION, driver ) );
    }

    manager.executeAll ();
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:17,代码来源:SetConnectionHandler.java

示例3: setExternalName

import org.eclipse.emf.edit.command.SetCommand; //导入依赖的package包/类
public void setExternalName ( final CompiledScript script ) throws Exception
{
    final CompoundManager manager = new CompoundManager ();

    for ( final ExternalValue v : SelectionHelper.iterable ( this.selection, ExternalValue.class ) )
    {
        final EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor ( v );
        if ( domain == null )
        {
            continue;
        }
        final String name = evalName ( script, v );
        manager.append ( domain, SetCommand.create ( domain, v, ComponentPackage.Literals.EXTERNAL_VALUE__SOURCE_NAME, name ) );
    }

    manager.executeAll ();
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:18,代码来源:SetExternalNameWizard.java

示例4: allocateIds

import org.eclipse.emf.edit.command.SetCommand; //导入依赖的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();
        }
    }
}
 
开发者ID:Heverton,项目名称:grapheditor,代码行数:27,代码来源:TitledSkinController.java

示例5: execute

import org.eclipse.emf.edit.command.SetCommand; //导入依赖的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);
		}
	}
}
 
开发者ID:cplutte,项目名称:bts,代码行数:22,代码来源:DeleteHandler.java

示例6: run

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

示例7: allocateIds

import org.eclipse.emf.edit.command.SetCommand; //导入依赖的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 = GraphPackage.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();
        }
    }
}
 
开发者ID:tesis-dynaware,项目名称:graph-editor,代码行数:27,代码来源:TitledSkinController.java

示例8: setUMLModelPathProperty

import org.eclipse.emf.edit.command.SetCommand; //导入依赖的package包/类
/**
 * update the property 'UMLModelURL' of the top 'MappedStructure' node (but do not save the file yet)
 */
public boolean setUMLModelPathProperty(MapperEditor me, String path)
{
	// check the mappings have been opened in the editor
	MappedStructure ms  = WorkBenchUtil.mappingRoot(me);
	if (ms == null) return false;
	
	/* if possible, convert the path to a 'platform:/resource/' URI string;
	 * otherwise convert it to a 'file:/' URI string  */
	String storedPath = FileUtil.URIFromPath(path).toString();
	
	// make an editing command to set the URL, and execute it
	EditingDomain ed = me.editingDomain();		
	SetCommand sc = new SetCommand(ed,ms,
				MapperPackage.eINSTANCE.getMappedStructure_UMLModelURL(),
				storedPath);
	ed.getCommandStack().execute(sc);	
	return true;
}
 
开发者ID:openmapsoftware,项目名称:mappingtools,代码行数:22,代码来源:MapperActionDelegate.java

示例9: SetTopElementNameCommand

import org.eclipse.emf.edit.command.SetCommand; //导入依赖的package包/类
public SetTopElementNameCommand(EditingDomain domain,
		EObject owner,
		EStructuralFeature fr,
		Object value)
{
	super(0);
	this.domain = domain;
	this.feature = fr;
	if ((owner instanceof MappedStructure) && (value instanceof String)) try
	{
		elName = (String)value;
		ms = (MappedStructure)owner;
		structureDef = ms.getStructureDefinition();
		append(new SetCommand(domain,ms,feature,elName));
	}
	catch (MapperException ex) {}
}
 
开发者ID:openmapsoftware,项目名称:mappingtools,代码行数:18,代码来源:SetTopElementNameCommand.java

示例10: execute

import org.eclipse.emf.edit.command.SetCommand; //导入依赖的package包/类
public void execute()
{
	// execute the first appended command, to set the 'Top Element Name' property of the MappedStructure
	super.execute();

	// attach the root Element object, and its subtree defined by the type, to the MappedStructure object
	EStructuralFeature f = MapperPackage.Literals.MAPPED_STRUCTURE__ROOT_ELEMENT;
	try{
		ElementDef newEl = structureDef.nameStructure(elName);
		appendAndExecute(new SetCommand(domain,ms,f,newEl));
		
		// set the top Element type property of the mapped Structure to be that of the actual top Element
		EStructuralFeature g = MapperPackage.Literals.MAPPED_STRUCTURE__TOP_ELEMENT_TYPE;
		appendAndExecute(new SetCommand(domain,ms,g,newEl.getType()));
		
		/* At one stage (5/09) I set the expanded flag to true on the newly added Element,
		 * in order to avoid a validation error; but this was wrong, because usually
		 * the top element has a type, which has not been expanded */
		/*
		appendAndExecute(new SetCommand(domain,newEl,
				MapperPackage.eINSTANCE.getElementDef_Expanded(),
				new Boolean(true)));
		*/							
	}
	catch (MapperException ex){System.out.println(ex.getMessage());}
}
 
开发者ID:openmapsoftware,项目名称:mappingtools,代码行数:27,代码来源:SetTopElementNameCommand.java

示例11: SetTopElementTypeCommand

import org.eclipse.emf.edit.command.SetCommand; //导入依赖的package包/类
public SetTopElementTypeCommand(EditingDomain domain,
		EObject owner,
		EStructuralFeature fr,
		Object value)
{
	super(0);
	this.domain = domain;
	this.feature = fr;
	if ((owner instanceof MappedStructure)&& (value instanceof String)) try
	{
		topType = (String)value;
		ms = (MappedStructure)owner;
		structureDef = ms.getStructureDefinition();
		append(new SetCommand(domain,ms,feature,topType));
	}
	catch (MapperException ex) {}
	
}
 
开发者ID:openmapsoftware,项目名称:mappingtools,代码行数:19,代码来源:SetTopElementTypeCommand.java

示例12: execute

import org.eclipse.emf.edit.command.SetCommand; //导入依赖的package包/类
public void execute()
{
	// execute the first appended command, to set the 'Top Element Type' property of the MappedStructure
	super.execute();
	
	try{
		// attach the root Element object, and its subtree defined by the type, to the MappedStructure object
		EStructuralFeature f = MapperPackage.Literals.MAPPED_STRUCTURE__ROOT_ELEMENT;
		ElementDef newEl = structureDef.typeStructure(topType);
		appendAndExecute(new SetCommand(domain,ms,f,newEl));
		
		// set the top Element name property of the mapped Structure to be that of the actual top Element
		EStructuralFeature g = MapperPackage.Literals.MAPPED_STRUCTURE__TOP_ELEMENT_NAME;
		appendAndExecute(new SetCommand(domain,ms,g,newEl.getName()));
		
		// set the expanded flag to true on the newly added Element
		appendAndExecute(new SetCommand(domain,newEl,
				MapperPackage.eINSTANCE.getElementDef_Expanded(),
				new Boolean(true)));
		
	}
	catch (MapperException ex){System.out.println(ex.getMessage());}
}
 
开发者ID:openmapsoftware,项目名称:mappingtools,代码行数:24,代码来源:SetTopElementTypeCommand.java

示例13: setMaster

import org.eclipse.emf.edit.command.SetCommand; //导入依赖的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 ();
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:29,代码来源:SetMasterHandler.java

示例14: setValue

import org.eclipse.emf.edit.command.SetCommand; //导入依赖的package包/类
@Override
protected void setValue(Object element, Object value) {
    final Definition definition = (Definition) element;
    if (!definition.getKey().equals(value)) {
        editingDomain.getCommandStack().execute(
                SetCommand.create(editingDomain, definition, GenconfPackage.Literals.DEFINITION__KEY, value));
    }
}
 
开发者ID:ObeoNetwork,项目名称:M2Doc,代码行数:9,代码来源:CustomGenconfEditor.java

示例15: updateLayoutValues

import org.eclipse.emf.edit.command.SetCommand; //导入依赖的package包/类
/**
 * Updates the model's layout values to match those in the skin instances.
 *
 * <p>
 * This method adds set operations to the given compound command but does <b>not</b> execute it.
 * </p>
 *
 * @param command a {@link CompoundCommand} to which the set commands will be added
 * @param model the {@link GModel} whose layout values should be updated
 * @param skinLookup the {@link SkinLookup} in use for this graph editor instance
 */
public static void updateLayoutValues(final CompoundCommand command, final GModel model, final SkinLookup skinLookup) {

    final EditingDomain editingDomain = getEditingDomain(model);

    if (editingDomain != null) {

        for (final GNode node : model.getNodes()) {

            final Region nodeRegion = skinLookup.lookupNode(node).getRoot();

            command.append(SetCommand.create(editingDomain, node, NODE_X, nodeRegion.getLayoutX()));
            command.append(SetCommand.create(editingDomain, node, NODE_Y, nodeRegion.getLayoutY()));
            command.append(SetCommand.create(editingDomain, node, NODE_WIDTH, nodeRegion.getWidth()));
            command.append(SetCommand.create(editingDomain, node, NODE_HEIGHT, nodeRegion.getHeight()));
        }

        for (final GConnection connection : model.getConnections()) {

            for (final GJoint joint : connection.getJoints()) {

                final GJointSkin jointSkin = skinLookup.lookupJoint(joint);
                final Region jointRegion = jointSkin.getRoot();

                final double x = jointRegion.getLayoutX() + jointSkin.getWidth() / 2;
                final double y = jointRegion.getLayoutY() + jointSkin.getHeight() / 2;

                command.append(SetCommand.create(editingDomain, joint, JOINT_X, x));
                command.append(SetCommand.create(editingDomain, joint, JOINT_Y, y));
            }
        }
    }
}
 
开发者ID:Heverton,项目名称:grapheditor,代码行数:44,代码来源:Commands.java


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