Search in sources :

Example 1 with ComponentSearchListDialogConfiguration

use of org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSearchListDialogConfiguration in project webtools.sourceediting by eclipse.

the class AddXSDRedefinableContentAction method run.

public void run() {
    Object selection = ((IStructuredSelection) getSelection()).getFirstElement();
    if (selection instanceof XSDBaseAdapter) {
        selection = ((XSDBaseAdapter) selection).getTarget();
    }
    if (selection instanceof XSDRedefine) {
        ComponentSearchListDialogConfiguration configuration = new ComponentSearchListDialogConfiguration();
        configuration.setDescriptionProvider(new RedefineDescriptor());
        configuration.setSearchListProvider(new RedefineSearchListProvider((XSDRedefine) selection, this));
        ComponentSearchListDialog dialog = new ComponentSearchListDialog(Display.getDefault().getActiveShell(), Messages._UI_LABEL_REDEFINE_COMPONENT, configuration) {

            protected Control createDialogArea(Composite parent) {
                // Adjust the dialog's initial size.
                Composite mainComposite = (Composite) super.createDialogArea(parent);
                GridData gridData = (GridData) mainComposite.getLayoutData();
                gridData.heightHint = 500;
                gridData.widthHint = 350;
                return mainComposite;
            }
        };
        dialog.create();
        dialog.setBlockOnOpen(true);
        int result = dialog.open();
        if (result == Window.OK) {
            ComponentSpecification selectedComponent = dialog.getSelectedComponent();
            buildRedefine((XSDRedefine) selection, selectedComponent);
        }
    }
}
Also used : XSDRedefine(org.eclipse.xsd.XSDRedefine) ComponentSearchListDialog(org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSearchListDialog) Composite(org.eclipse.swt.widgets.Composite) ComponentSpecification(org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification) GridData(org.eclipse.swt.layout.GridData) XSDBaseAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ComponentSearchListDialogConfiguration(org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSearchListDialogConfiguration)

Example 2 with ComponentSearchListDialogConfiguration

use of org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSearchListDialogConfiguration in project webtools.sourceediting by eclipse.

the class XSDSearchListDialogDelegate method createAndOpen.

public int createAndOpen() {
    Shell shell = XSDEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell();
    int returnValue = Window.CANCEL;
    ScopedComponentSearchListDialog dialog = null;
    // so it's easier to see the difference between how we config for an element vs type?
    if (metaName == ELEMENT_META_NAME) {
        XSDComponentDescriptionProvider descriptionProvider = new XSDComponentDescriptionProvider();
        final XSDElementsSearchListProvider searchListProvider = new XSDElementsSearchListProvider(currentFile, schemas);
        ComponentSearchListDialogConfiguration configuration = new ComponentSearchListDialogConfiguration();
        configuration.setDescriptionProvider(descriptionProvider);
        configuration.setSearchListProvider(searchListProvider);
        configuration.setFilterLabelText(Messages._UI_LABEL_NAME_SEARCH_FILTER_TEXT);
        configuration.setListLabelText(Messages._UI_LABEL_ELEMENTS_COLON);
        // configuration.setNewComponentHandler(new NewElementButtonHandler());
        // TODO externalize string
        dialog = new ScopedComponentSearchListDialog(shell, Messages._UI_LABEL_SET_ELEMENT_REFERENCE, configuration);
    } else if (metaName == ATTRIBUTE_META_NAME) {
        XSDComponentDescriptionProvider descriptionProvider = new XSDComponentDescriptionProvider();
        final XSDAttributeSearchListProvider searchListProvider = new XSDAttributeSearchListProvider(currentFile, schemas);
        ComponentSearchListDialogConfiguration configuration = new ComponentSearchListDialogConfiguration();
        configuration.setDescriptionProvider(descriptionProvider);
        configuration.setSearchListProvider(searchListProvider);
        configuration.setFilterLabelText(Messages._UI_LABEL_NAME_SEARCH_FILTER_TEXT);
        configuration.setListLabelText(Messages._UI_LABEL_ATTRIBUTES_COLON);
        dialog = new ScopedComponentSearchListDialog(shell, Messages._UI_LABEL_SET_ATTRIBUTE_REFERENCE, configuration);
    } else if (metaName == TYPE_META_NAME) {
        XSDComponentDescriptionProvider descriptionProvider = new XSDComponentDescriptionProvider();
        final XSDTypesSearchListProvider searchListProvider = new XSDTypesSearchListProvider(currentFile, schemas);
        if (!showComplexTypes)
            searchListProvider.showComplexTypes(false);
        ComponentSearchListDialogConfiguration configuration = new ComponentSearchListDialogConfiguration();
        configuration.setDescriptionProvider(descriptionProvider);
        configuration.setSearchListProvider(searchListProvider);
        // configuration.setNewComponentHandler(new NewTypeButtonHandler());
        configuration.setFilterLabelText(Messages._UI_LABEL_NAME_SEARCH_FILTER_TEXT);
        configuration.setListLabelText(Messages._UI_LABEL_TYPES_COLON);
        // $NON-NLS-1$
        dialog = new ScopedComponentSearchListDialog(shell, Messages._UI_LABEL_SET_TYPE, configuration);
    }
    if (dialog != null) {
        dialog.setCurrentResource(currentFile);
        dialog.setBlockOnOpen(true);
        dialog.create();
        returnValue = dialog.open();
        if (returnValue == Window.OK) {
            selection = dialog.getSelectedComponent();
        }
    }
    return returnValue;
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ScopedComponentSearchListDialog(org.eclipse.wst.common.ui.internal.search.dialogs.ScopedComponentSearchListDialog) ComponentSearchListDialogConfiguration(org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSearchListDialogConfiguration)

Aggregations

ComponentSearchListDialogConfiguration (org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSearchListDialogConfiguration)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 GridData (org.eclipse.swt.layout.GridData)1 Composite (org.eclipse.swt.widgets.Composite)1 Shell (org.eclipse.swt.widgets.Shell)1 ComponentSearchListDialog (org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSearchListDialog)1 ComponentSpecification (org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification)1 ScopedComponentSearchListDialog (org.eclipse.wst.common.ui.internal.search.dialogs.ScopedComponentSearchListDialog)1 XSDBaseAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter)1 XSDRedefine (org.eclipse.xsd.XSDRedefine)1