Search in sources :

Example 1 with SetCommand

use of org.eclipse.emf.edit.command.SetCommand in project statecharts by Yakindu.

the class StatechartDefinitionSection method createNameLabel.

protected void createNameLabel(Composite labelComposite) {
    Text nameLabel = new Text(labelComposite, SWT.SINGLE | SWT.NORMAL);
    GridDataFactory.fillDefaults().indent(5, 1).grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(nameLabel);
    nameLabel.setText(getStatechartName());
    nameLabel.setEditable(isStatechart());
    nameLabel.setBackground(ColorConstants.white);
    nameModificationListener = new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            if (getContextObject() instanceof Statechart) {
                getSash().setRedraw(false);
                TransactionalEditingDomain domain = getTransactionalEditingDomain();
                SetCommand command = new SetCommand(domain, getContextObject(), BasePackage.Literals.NAMED_ELEMENT__NAME, nameLabel.getText());
                domain.getCommandStack().execute(command);
                refresh(nameLabel.getParent());
                getSash().setRedraw(true);
            }
        }
    };
    nameLabel.addModifyListener(nameModificationListener);
}
Also used : ModifyEvent(org.eclipse.swt.events.ModifyEvent) TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) ModifyListener(org.eclipse.swt.events.ModifyListener) Statechart(org.yakindu.sct.model.sgraph.Statechart) StyledText(org.eclipse.swt.custom.StyledText) Text(org.eclipse.swt.widgets.Text) SetCommand(org.eclipse.emf.edit.command.SetCommand)

Example 2 with SetCommand

use of org.eclipse.emf.edit.command.SetCommand in project statecharts by Yakindu.

the class StatechartDefinitionSection method setInlineStyleValue.

protected void setInlineStyleValue(BooleanValueStyle inlineStyle, TransactionalEditingDomain domain) {
    SetCommand command = new SetCommand(domain, inlineStyle, NotationPackage.Literals.BOOLEAN_VALUE_STYLE__BOOLEAN_VALUE, !inlineStyle.isBooleanValue());
    domain.getCommandStack().execute(command);
}
Also used : SetCommand(org.eclipse.emf.edit.command.SetCommand)

Aggregations

SetCommand (org.eclipse.emf.edit.command.SetCommand)2 TransactionalEditingDomain (org.eclipse.emf.transaction.TransactionalEditingDomain)1 StyledText (org.eclipse.swt.custom.StyledText)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 Text (org.eclipse.swt.widgets.Text)1 Statechart (org.yakindu.sct.model.sgraph.Statechart)1