Search in sources :

Example 1 with UpdateNameCommand

use of org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand in project webtools.sourceediting by eclipse.

the class XSDAttributeGroupDefinitionSection method doHandleEvent.

public void doHandleEvent(Event event) {
    super.doHandleEvent(event);
    if (event.widget == nameText) {
        String newValue = nameText.getText().trim();
        if (input instanceof XSDNamedComponent) {
            XSDNamedComponent namedComponent = (XSDNamedComponent) input;
            if (!validateSection())
                return;
            Command command = null;
            // Make sure an actual name change has taken place
            String oldName = namedComponent.getName();
            if (!newValue.equals(oldName)) {
                command = new UpdateNameCommand(Messages._UI_ACTION_RENAME, namedComponent, newValue);
            }
            if (command != null && getCommandStack() != null) {
                getCommandStack().execute(command);
            }
        // doReferentialIntegrityCheck(namedComponent, newValue);
        }
    }
}
Also used : UpdateNameCommand(org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand) XSDNamedComponent(org.eclipse.xsd.XSDNamedComponent) UpdateNameCommand(org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand) Command(org.eclipse.gef.commands.Command)

Example 2 with UpdateNameCommand

use of org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand in project webtools.sourceediting by eclipse.

the class XSDElementDeclarationSection method doHandleEvent.

public void doHandleEvent(Event event) {
    if (event.type == SWT.Traverse) {
        if (event.detail == SWT.TRAVERSE_ARROW_NEXT || event.detail == SWT.TRAVERSE_ARROW_PREVIOUS) {
            isTraversing = true;
            return;
        }
    }
    super.doHandleEvent(event);
    if (event.widget == nameText) {
        String newValue = nameText.getText().trim();
        if (input instanceof XSDElementDeclaration) {
            XSDElementDeclaration namedComponent = ((XSDElementDeclaration) input).getResolvedElementDeclaration();
            if (!validateSection())
                return;
            Command command = null;
            // Make sure an actual name change has taken place
            String oldName = namedComponent.getName();
            if (!newValue.equals(oldName)) {
                command = new UpdateNameCommand(org.eclipse.wst.xsd.ui.internal.common.util.Messages._UI_ACTION_RENAME, namedComponent, newValue);
            }
            if (command != null && getCommandStack() != null) {
                getCommandStack().execute(command);
            }
        // doReferentialIntegrityCheck(namedComponent, newValue);
        }
    }
}
Also used : UpdateNameCommand(org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand) UpdateNameCommand(org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand) Command(org.eclipse.gef.commands.Command) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration)

Example 3 with UpdateNameCommand

use of org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand in project webtools.sourceediting by eclipse.

the class XSDSimpleTypeSection method doHandleEvent.

// TODO: Common this up with element declaration
public void doHandleEvent(Event event) {
    if (event.type == SWT.Traverse) {
        if (event.detail == SWT.TRAVERSE_ARROW_NEXT || event.detail == SWT.TRAVERSE_ARROW_PREVIOUS) {
            isTraversing = true;
            return;
        }
    }
    if (event.widget == nameText) {
        if (!nameText.getEditable())
            return;
        String newValue = nameText.getText().trim();
        if (input instanceof XSDNamedComponent) {
            XSDNamedComponent namedComponent = (XSDNamedComponent) input;
            if (!validateSection())
                return;
            Command command = null;
            // Make sure an actual name change has taken place
            String oldName = namedComponent.getName();
            if (!newValue.equals(oldName)) {
                command = new UpdateNameCommand(Messages._UI_ACTION_RENAME, namedComponent, newValue);
            }
            if (command != null && getCommandStack() != null) {
                getCommandStack().execute(command);
            }
        }
    }
}
Also used : UpdateNameCommand(org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand) XSDNamedComponent(org.eclipse.xsd.XSDNamedComponent) UpdateNameCommand(org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand) Command(org.eclipse.gef.commands.Command)

Example 4 with UpdateNameCommand

use of org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand in project webtools.sourceediting by eclipse.

the class XSDModelGroupDefinitionSection method doHandleEvent.

public void doHandleEvent(Event event) {
    super.doHandleEvent(event);
    if (event.widget == nameText) {
        String newValue = nameText.getText().trim();
        if (input instanceof XSDNamedComponent) {
            XSDNamedComponent namedComponent = (XSDNamedComponent) input;
            if (!validateSection())
                return;
            Command command = null;
            // Make sure an actual name change has taken place
            String oldName = namedComponent.getName();
            if (!newValue.equals(oldName)) {
                command = new UpdateNameCommand(Messages._UI_ACTION_RENAME, namedComponent, newValue);
            }
            if (command != null && getCommandStack() != null) {
                getCommandStack().execute(command);
            }
        // doReferentialIntegrityCheck(namedComponent, newValue);
        }
    }
}
Also used : UpdateNameCommand(org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand) XSDNamedComponent(org.eclipse.xsd.XSDNamedComponent) UpdateNameCommand(org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand) Command(org.eclipse.gef.commands.Command)

Example 5 with UpdateNameCommand

use of org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand in project webtools.sourceediting by eclipse.

the class XSDComplexTypeSection method doHandleEvent.

public void doHandleEvent(Event event) {
    if (event.type == SWT.Traverse) {
        if (event.detail == SWT.TRAVERSE_ARROW_NEXT || event.detail == SWT.TRAVERSE_ARROW_PREVIOUS) {
            isTraversing = true;
            return;
        }
    }
    super.doHandleEvent(event);
    if (event.widget == nameText) {
        if (!nameText.getEditable())
            return;
        String newValue = nameText.getText().trim();
        if (input instanceof XSDNamedComponent) {
            XSDNamedComponent namedComponent = (XSDNamedComponent) input;
            if (!validateSection())
                return;
            Command command = null;
            // Make sure an actual name change has taken place
            String oldName = namedComponent.getName();
            if (!newValue.equals(oldName)) {
                command = new UpdateNameCommand(org.eclipse.wst.xsd.ui.internal.common.util.Messages._UI_ACTION_RENAME, namedComponent, newValue);
            }
            if (command != null && getCommandStack() != null) {
                getCommandStack().execute(command);
            }
        // doReferentialIntegrityCheck(namedComponent, newValue);
        }
    }
}
Also used : UpdateNameCommand(org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand) XSDNamedComponent(org.eclipse.xsd.XSDNamedComponent) UpdateNameCommand(org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand) Command(org.eclipse.gef.commands.Command)

Aggregations

Command (org.eclipse.gef.commands.Command)6 UpdateNameCommand (org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand)6 XSDNamedComponent (org.eclipse.xsd.XSDNamedComponent)4 BaseCommand (org.eclipse.wst.xsd.ui.internal.common.commands.BaseCommand)1 UpdateAttributeValueCommand (org.eclipse.wst.xsd.ui.internal.common.commands.UpdateAttributeValueCommand)1 XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)1 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)1 Element (org.w3c.dom.Element)1