Quintiq file version 2.0
|
#parent: #root
|
Method SelectImportExportDatasetIfExists () id:Method_LibCal_GlobalState_SelectImportExportDatasetIfExists
|
{
|
#keys: '[131094.1.1070484365]'
|
Body:
|
[*
|
// Get the name of the ImportExport-dataset based on the name of planning-dataset.
|
componentMDS := null( ComponentMDSBase, owning );
|
mdsInstance := null( ComponentMDSInstance );
|
importExport := dhImportExport.Data();
|
|
if( not isnull( importExport ) )
|
{
|
// Get the full name of the dataset.
|
datasetName := LibCal_ImportExportDataset::GetFullName( importExport.GetDatasetName() );
|
|
// Find the ImportExport-dataset.
|
// Create a handle to the componentMDS, refresh it.
|
// An explicit refresh is required to see the ImportExport-dataset when it was just loaded by EnsureImportExportDataset().
|
componentMDS := ApplicationScope.ComponentMDS();
|
componentMDS.Refresh();
|
|
mdsInstance := select( componentMDS, ComponentMDSKinds.ComponentMDSInstances, instance,
|
instance.ComponentMDSKind().Kind() = LibCal_ImportExportDataset::DATASETKIND() and
|
instance.Parent().Name() = LibCal_ImportExportDataset::DATASETFOLDER() and
|
instance.Name() = datasetName );
|
}
|
|
// Select the dataset if it exists...
|
if( not isnull( mdsInstance ) )
|
{
|
// Explicitly check if the dataset is loaded, otherwise the Software will do it for you (and throw an error).
|
if( mdsInstance.IsLoaded() )
|
{
|
mdsInstance.ComponentMDSKind().SelectInstance( mdsInstance );
|
componentMDS.Apply();
|
}
|
}
|
else
|
{
|
// ... deselect the currenly selected ImportExport-dataset otherwise, because it belongs to a different planning-dataset.
|
mdsInstance := select( componentMDS, ComponentMDSKinds.ComponentMDSInstances, instance,
|
instance.ComponentMDSKind().Kind() = LibCal_ImportExportDataset::DATASETKIND() and
|
instance.IsSelected() );
|
if( not isnull( mdsInstance ) )
|
{
|
mdsInstance.ComponentMDSKind().DeselectAll();
|
componentMDS.Apply();
|
}
|
}
|
*]
|
}
|