IMetabaseDialog.Execute

Syntax

Execute(Parent: IControl): Boolean;

Parameters

Parent. Theparent component, for which a dialog box opens modally.

Description

The Execute method executes a dialog box and after that returns whether the OK button is pressed.

Comments

If the OK button is clicked in the dialog box, the method returns True; if the Cancel button is clicked, the method returns False.

Example

Executing the example requires a form with the Button1 button. The OnCreate event handler is set for the form. The OnClick event handler is set for the button. A folder with the FCubes identifier is also required in the repository. A folder with the FStdCube identifier is created in this folder. Add links to the ExtCtrls and Metabase system assemblies. See below full code of the form.

Class TESTForm: Form
    Button1: Button;
    OpenDlg: IMetabaseOpenDialog;

    Sub TESTFormOnCreate(Sender: Object; Args: IEventArgs);
    Var
        MB: IMetabase;
        Filters: IMetabaseDialogFilters;
        Filter: IMetabaseDialogFilter;
    Begin
        MB := MetabaseClass.Active;
        OpenDlg := New MetabaseOpenDialog.Create;
        //Root and original catalogues
        OpenDlg.Root := MB.ItemById("FCubes");
        OpenDlg.InitialFolder := MB.ItemById("FStdCube");
        //Multiple selection possibility
        OpenDlg.MultiSelect := True;
        //Dialog box title
        OpenDlg.Title := "Selecting of data source(s)";
        Filters := OpenDlg.Filters;
        //Filter for selecting data sets, based on which cubes can be built
        Filter := New MetabaseDialogMetaclassFilter.Create;
        (Filter As IMetabaseDialogMetaclassFilter).ObjectMetaclass := MetabaseObjectMetaclass.DATASET_CLASS;
        Filter.Description := "Data sets";
        Filters.AddFilter(Filter);
        //Filter for selecting only cubes
        Filter := New MetabaseDialogMetaclassFilter.Create;
        (Filter As IMetabaseDialogMetaclassFilter).ObjectMetaclass := MetabaseObjectMetaclass.CUBE_CLASS;
        Filter.Description := "Cubes";
        Filters.AddFilter(Filter);
    End Sub TESTFormOnCreate;

    Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
    Var
        MDescs: IMetabaseObjectDescriptorList;
        MDesc: IMetabaseObjectDescriptor;
        i: Integer;
    Begin
        OpenDlg.FilterIndex := 0;
        If OpenDlg.Execute(Self) Then
            MDescs := OpenDlg.Objects;
            //Viewing list of selected objects
            If MDescs.Count > 1 Then
                For i := 0 To MDescs.Count - 1 Do
                    MDesc := MDescs.Item(i);
                    Debug.WriteLine(MDesc.Id);
                End For;
            Else
                Debug.WriteLine(OpenDlg.Object.Id);
            End If;
        End If;
    End Sub Button1OnClick;
End Class TESTForm;

The MetabaseOpenDialog component is dynamically created when running the form in the OnCreate event. A root and an original folders, dialog box header are determined for the component. It is set whether multiple objects and object filters that will be available in the dialog box can be selected. Clicking the button displays the dialog box. By default, all objects specified in filters will be available for selection. If an object or objects are selected in the dialog box, and the OK button is clicked, the list of object identifiers is displayed in the development environment console.

See also:

IMetabaseDialog