use of org.eclipse.wst.xsd.ui.internal.editor.search.XSDSearchListDialogDelegate in project webtools.sourceediting by eclipse.
the class SetBaseTypeAction method run.
public void run() {
Object selection = ((IStructuredSelection) getSelection()).getFirstElement();
if (selection instanceof XSDBaseAdapter) {
selection = ((XSDBaseAdapter) selection).getTarget();
boolean complexType = selection instanceof XSDComplexTypeDefinition;
boolean simpleType = selection instanceof XSDSimpleTypeDefinition;
if (complexType || simpleType) {
if (getWorkbenchPart() instanceof IEditorPart) {
IEditorPart editor = (IEditorPart) getWorkbenchPart();
ComponentReferenceEditManager manager = (ComponentReferenceEditManager) editor.getAdapter(XSDComplexTypeBaseTypeEditManager.class);
ComponentSpecification newValue;
IComponentDialog dialog = null;
dialog = manager.getBrowseDialog();
if (dialog != null) {
if (simpleType) {
((XSDSearchListDialogDelegate) dialog).showComplexTypes(false);
}
if (dialog.createAndOpen() == Window.OK) {
newValue = dialog.getSelectedComponent();
manager.modifyComponentReference(selection, newValue);
}
}
}
}
}
}
use of org.eclipse.wst.xsd.ui.internal.editor.search.XSDSearchListDialogDelegate in project webtools.sourceediting by eclipse.
the class XSDSimpleTypeSection method handleWidgetSelection.
private void handleWidgetSelection(SelectionEvent e) {
if (e.widget == typesCombo) {
IEditorPart editor = getActiveEditor();
if (editor == null)
return;
ComponentReferenceEditManager manager = (ComponentReferenceEditManager) editor.getAdapter(XSDComplexTypeBaseTypeEditManager.class);
String selection = typesCombo.getText();
ComponentSpecification newValue;
IComponentDialog dialog = null;
if (selection.equals(Messages._UI_COMBO_BROWSE)) {
dialog = manager.getBrowseDialog();
((XSDSearchListDialogDelegate) dialog).showComplexTypes(false);
} else if (selection.equals(Messages._UI_COMBO_NEW)) {
dialog = manager.getNewDialog();
((NewTypeDialog) dialog).allowComplexType(false);
}
if (dialog != null) {
if (dialog.createAndOpen() == Window.OK) {
newValue = dialog.getSelectedComponent();
manager.modifyComponentReference(input, newValue);
}
} else // use the value from selected quickPick item
{
newValue = getComponentSpecFromQuickPickForValue(selection, manager);
if (newValue != null)
manager.modifyComponentReference(input, newValue);
}
} else if (e.widget == varietyCombo) {
if (input != null) {
if (input instanceof XSDSimpleTypeDefinition) {
XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition) input;
Element parent = st.getElement();
String variety = varietyCombo.getText();
if (variety.equals(XSDVariety.ATOMIC_LITERAL.getName())) {
// $NON-NLS-1$
typesLabel.setText(XSDEditorPlugin.getXSDString("_UI_LABEL_BASE_TYPE_WITH_COLON"));
st.setVariety(XSDVariety.ATOMIC_LITERAL);
// $NON-NLS-1$
addCreateElementActionIfNotExist(XSDConstants.RESTRICTION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_RESTRICTION"), parent, null);
} else if (variety.equals(XSDVariety.UNION_LITERAL.getName())) {
// $NON-NLS-1$
typesLabel.setText(XSDEditorPlugin.getXSDString("_UI_LABEL_MEMBERTYPES"));
st.setVariety(XSDVariety.UNION_LITERAL);
// $NON-NLS-1$
addCreateElementActionIfNotExist(XSDConstants.UNION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_UNION"), parent, null);
} else if (variety.equals(XSDVariety.LIST_LITERAL.getName())) {
// $NON-NLS-1$
typesLabel.setText(XSDEditorPlugin.getXSDString("_UI_LABEL_ITEM_TYPE"));
st.setVariety(XSDVariety.LIST_LITERAL);
// $NON-NLS-1$
addCreateElementActionIfNotExist(XSDConstants.LIST_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_LIST"), parent, null);
}
}
}
}
}
use of org.eclipse.wst.xsd.ui.internal.editor.search.XSDSearchListDialogDelegate in project webtools.sourceediting by eclipse.
the class XSDElementDeclarationSection method handleWidgetSelection.
private void handleWidgetSelection(SelectionEvent e) {
if (e.widget == typeCombo) {
IEditorPart editor = getActiveEditor();
if (editor == null)
return;
ComponentReferenceEditManager manager = (ComponentReferenceEditManager) editor.getAdapter(XSDTypeReferenceEditManager.class);
String selection = typeCombo.getText();
ComponentSpecification newValue;
IComponentDialog dialog = null;
if (selection.equals(Messages._UI_COMBO_BROWSE)) {
dialog = manager.getBrowseDialog();
((XSDSearchListDialogDelegate) dialog).showComplexTypes(true);
} else if (selection.equals(Messages._UI_COMBO_NEW)) {
dialog = manager.getNewDialog();
((NewTypeDialog) dialog).allowComplexType(true);
}
if (dialog != null) {
if (dialog.createAndOpen() == Window.OK) {
newValue = dialog.getSelectedComponent();
XSDElementDeclaration elementDeclaration = ((XSDElementDeclaration) input).getResolvedElementDeclaration();
manager.modifyComponentReference(elementDeclaration, newValue);
} else {
typeCombo.setText(typeName);
}
} else // use the value from selected quickPick item
{
newValue = getComponentSpecFromQuickPickForValue(selection, manager);
if (newValue != null)
manager.modifyComponentReference(input, newValue);
}
} else if (e.widget == componentNameCombo) {
IEditorPart editor = getActiveEditor();
if (editor == null)
return;
ComponentReferenceEditManager manager = (ComponentReferenceEditManager) editor.getAdapter(XSDElementReferenceEditManager.class);
String selection = componentNameCombo.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 {
componentNameCombo.setText("");
}
} else // use the value from selected quickPick item
{
newValue = getComponentSpecFromQuickPickForValue(selection, manager);
if (newValue != null)
manager.modifyComponentReference(input, newValue);
}
} else if (e.widget == maxCombo) {
updateMaxAttribute();
} else if (e.widget == minCombo) {
updateMinAttribute();
}
}
use of org.eclipse.wst.xsd.ui.internal.editor.search.XSDSearchListDialogDelegate in project webtools.sourceediting by eclipse.
the class XSDAttributeDeclarationSection method handleWidgetSelection.
private void handleWidgetSelection(SelectionEvent e) {
if (e.widget == typeCombo) {
IEditorPart editor = getActiveEditor();
if (editor == null)
return;
ComponentReferenceEditManager manager = (ComponentReferenceEditManager) editor.getAdapter(XSDTypeReferenceEditManager.class);
String selection = typeCombo.getText();
ComponentSpecification newValue;
IComponentDialog dialog = null;
if (selection.equals(Messages._UI_COMBO_BROWSE)) {
dialog = manager.getBrowseDialog();
((XSDSearchListDialogDelegate) dialog).showComplexTypes(false);
} else if (selection.equals(Messages._UI_COMBO_NEW)) {
dialog = manager.getNewDialog();
((NewTypeDialog) dialog).allowComplexType(false);
}
if (dialog != null) {
if (dialog.createAndOpen() == Window.OK) {
newValue = dialog.getSelectedComponent();
XSDAttributeDeclaration xsdAttribute = ((XSDAttributeDeclaration) input).getResolvedAttributeDeclaration();
manager.modifyComponentReference(xsdAttribute, newValue);
} else {
typeCombo.setText(typeName);
}
} else // use the value from selected quickPick item
{
newValue = getComponentSpecFromQuickPickForValue(selection, manager);
if (newValue != null)
manager.modifyComponentReference(input, newValue);
}
} else if (e.widget == componentNameCombo) {
IEditorPart editor = getActiveEditor();
if (editor == null)
return;
ComponentReferenceEditManager manager = (ComponentReferenceEditManager) editor.getAdapter(XSDAttributeReferenceEditManager.class);
String selection = componentNameCombo.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 {
componentNameCombo.setText(refName);
}
} else // use the value from selected quickPick item
{
newValue = getComponentSpecFromQuickPickForValue(selection, manager);
if (newValue != null)
manager.modifyComponentReference(input, newValue);
}
} else {
XSDAttributeDeclaration xsdAttribute = (XSDAttributeDeclaration) input;
Element element = xsdAttribute.getElement();
if (e.widget == usageCombo) {
final String newValue = usageCombo.getText();
if (element != null) {
PropertiesChangeCommand command = new PropertiesChangeCommand(element, org.eclipse.wst.xsd.ui.internal.common.util.Messages._UI_USAGE) {
protected void doExecuteSteps() {
if (newValue.length() == 0)
element.removeAttribute(XSDConstants.USE_ATTRIBUTE);
else
element.setAttribute(XSDConstants.USE_ATTRIBUTE, newValue);
}
};
getCommandStack().execute(command);
}
} else if (e.widget == formCombo) {
final String newValue = formCombo.getText();
if (element != null) {
PropertiesChangeCommand command = new PropertiesChangeCommand(element, org.eclipse.wst.xsd.ui.internal.common.util.Messages._UI_LABEL_FORM) {
protected void doExecuteSteps() {
if (newValue.length() == 0)
element.removeAttribute(XSDConstants.FORM_ATTRIBUTE);
else
element.setAttribute(XSDConstants.FORM_ATTRIBUTE, newValue);
}
};
getCommandStack().execute(command);
}
} else if (e.widget == defaultButton) {
boolean newValue = defaultButton.getSelection();
if (element != null) {
if (newValue) {
if (element.hasAttribute(XSDConstants.FIXED_ATTRIBUTE)) {
final String value = element.getAttribute(XSDConstants.FIXED_ATTRIBUTE);
PropertiesChangeCommand command = new PropertiesChangeCommand(element, org.eclipse.wst.xsd.ui.internal.common.util.Messages._UI_DEFAULT) {
protected void doExecuteSteps() {
element.removeAttribute(XSDConstants.FIXED_ATTRIBUTE);
element.setAttribute(XSDConstants.DEFAULT_ATTRIBUTE, value);
}
};
getCommandStack().execute(command);
}
}
}
} else if (e.widget == fixedButton) {
boolean newValue = fixedButton.getSelection();
if (element != null) {
if (newValue) {
if (element.hasAttribute(XSDConstants.DEFAULT_ATTRIBUTE)) {
final String value = element.getAttribute(XSDConstants.DEFAULT_ATTRIBUTE);
PropertiesChangeCommand command = new PropertiesChangeCommand(element, org.eclipse.wst.xsd.ui.internal.common.util.Messages._UI_FIXED) {
protected void doExecuteSteps() {
element.removeAttribute(XSDConstants.DEFAULT_ATTRIBUTE);
element.setAttribute(XSDConstants.FIXED_ATTRIBUTE, value);
}
};
getCommandStack().execute(command);
}
}
}
}
}
super.doWidgetSelected(e);
}
Aggregations