Search in sources :

Example 1 with UpdateComplexTypeDerivationBy

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

the class XSDComplexTypeSection method handleWidgetSelection.

private void handleWidgetSelection(SelectionEvent e) {
    if (e.widget == baseTypeCombo) {
        IEditorPart editor = getActiveEditor();
        if (editor == null)
            return;
        ComponentReferenceEditManager manager = (ComponentReferenceEditManager) editor.getAdapter(XSDComplexTypeBaseTypeEditManager.class);
        String selection = baseTypeCombo.getText();
        ComponentSpecification newValue;
        IComponentDialog dialog = null;
        if (selection.equals(Messages._UI_COMBO_BROWSE)) {
            dialog = manager.getBrowseDialog();
        } else if (selection.equals(Messages._UI_COMBO_NEW)) {
            dialog = manager.getNewDialog();
        }
        if (dialog != null) {
            if (dialog.createAndOpen() == Window.OK) {
                newValue = dialog.getSelectedComponent();
                manager.modifyComponentReference(input, newValue);
            } else {
                refresh();
            }
        }
    } else if (e.widget == derivedByCombo) {
        XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition) input;
        String value = derivedByCombo.getText();
        Command command = new UpdateComplexTypeDerivationBy(complexType, value);
        if (getCommandStack() != null) {
            getCommandStack().execute(command);
        }
    }
    super.doWidgetSelected(e);
}
Also used : IComponentDialog(org.eclipse.wst.xsd.ui.internal.adt.edit.IComponentDialog) XSDComplexTypeBaseTypeEditManager(org.eclipse.wst.xsd.ui.internal.editor.XSDComplexTypeBaseTypeEditManager) UpdateNameCommand(org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand) Command(org.eclipse.gef.commands.Command) ComponentSpecification(org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification) ComponentReferenceEditManager(org.eclipse.wst.xsd.ui.internal.adt.edit.ComponentReferenceEditManager) IEditorPart(org.eclipse.ui.IEditorPart) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) UpdateComplexTypeDerivationBy(org.eclipse.wst.xsd.ui.internal.common.commands.UpdateComplexTypeDerivationBy)

Aggregations

Command (org.eclipse.gef.commands.Command)1 IEditorPart (org.eclipse.ui.IEditorPart)1 ComponentSpecification (org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification)1 ComponentReferenceEditManager (org.eclipse.wst.xsd.ui.internal.adt.edit.ComponentReferenceEditManager)1 IComponentDialog (org.eclipse.wst.xsd.ui.internal.adt.edit.IComponentDialog)1 UpdateComplexTypeDerivationBy (org.eclipse.wst.xsd.ui.internal.common.commands.UpdateComplexTypeDerivationBy)1 UpdateNameCommand (org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand)1 XSDComplexTypeBaseTypeEditManager (org.eclipse.wst.xsd.ui.internal.editor.XSDComplexTypeBaseTypeEditManager)1 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)1