Execute(Parent: IControl): Boolean;
Execute(Parent: System.Windows.Forms.Control): Boolean;
Parent. Theparent component, for which a dialog box opens modally.
The Execute method executes a dialog box and after that returns whether the OK button is pressed.
If the OK button is clicked in the dialog box, the method returns True; if the Cancel button is clicked, the method returns False.
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.
The requirements and result of the Fore.NET example execution match with those in the Fore example. Use Fore.NET analogs instead of Fore components.
Imports Prognoz.Platform.Forms.Net;
Imports Prognoz.Platform.Interop.ExtCtrls;
Imports Prognoz.Platform.Interop.Metabase;
Public Partial Class TESTForm: Prognoz.Platform.Forms.Net.ForeNetForm
Public Constructor TESTForm();
Begin
InitializeComponent();
End Constructor;
OpenDlg: MetabaseOpenDialogNet;
Private Sub TESTForm_Load(sender: System.Object; e: System.EventArgs);
Var
MB: IMetabase;
Filters: IMetabaseDialogFilters;
Filter: IMetabaseDialogFilter;
Begin
MB := Self.Metabase;
OpenDlg := New MetabaseOpenDialogNet();
//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();
(Filter As IMetabaseDialogMetaclassFilter).ObjectMetaclass := MetabaseObjectMetaclass.DATASET_CLASS;
Filter.Description := "Data sets";
Filters.AddFilter(Filter);
//Filter for selecting only cubes
Filter := New MetabaseDialogMetaclassFilter();
(Filter As IMetabaseDialogMetaclassFilter).ObjectMetaclass := MetabaseObjectMetaclass.CUBE_CLASS;
Filter.Description := "Cubes";
Filters.AddFilter(Filter);
End Sub;
Private Sub button1_Click(sender: System.Object; e: System.EventArgs);
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];
System.Diagnostics.Debug.WriteLine(MDesc.Id);
End For;
Else
System.Diagnostics.Debug.WriteLine(OpenDlg.Object.Id);
End If;
End If;
End Sub;
End Class;
See also: