UPDATE: The process needs to set as the active object first. THe new question is how to do this.
PetrelSystem.ActiveObjectService.GetActiveObject<Process>()
The above call doesn't work. Is there another way to set the active object for processes? There doesn't seem to be one Type for a process in the process tree so I doubt anything using generics will work.
OLD QUESTION: I'm having trouble launching a process's settings dialog using the API call DialogBuilder.ShowSettings(object domainObject). It seems to work for the Import Data process but I can't get it to launch any other dialogs.
I have tried traversing the Processes tree to get the process domain objects and I have tried using PetrelSystem.ProcessDiagram.FindProcess(string name) to obtain the process. Both have the same result when passed into DialogBuilder.ShowSettings.
Is this a known issue with the API in 2011?
This is how I traverse the tree
IObservableElementEnumerableFactory service = CoreSystem.GetService<IObservableElementEnumerableFactory>(PetrelProject.Processes);
IObservableElementEnumerable elemEnum = service.GetEnumerable(PetrelProject.Processes);
indentLevel++;
if (elemEnum != null)
{
foreach (object obj in elemEnum)
{
var cmo = cmoMananeger.CreateCMO(obj, addText, indentLevel);
//add it to tree then add its children
if (cmo != null)
{
if (indentLevel > 0)
{
comboBox1.Items.Add(cmo);
processToCMO.Add(cmo, obj);
}
traverseTree(obj, indentLevel, addText);
}
}
}
indentLevel--;
And then try to launch the process after
var process = processToCMO[comboBox1.SelectedItem as ContextMenuObject];
if (!PetrelSystem.DialogBuilder.IsSettingsVisible(process))
PetrelSystem.DialogBuilder.ShowSettings(process);
This is how I'm trying to launch the process via the find process method
var PROCESS = PetrelSystem.ProcessDiagram.FindProcess((comboBox1.SelectedItem as ContextMenuObject).DisplayText);
if (PROCESS != null)
{
if (!PetrelSystem.DialogBuilder.IsSettingsVisible(PROCESS))
PetrelSystem.DialogBuilder.ShowSettings(PROCESS);
}
The method I'm using works fine for other panes like the input and models. It is only the processes pane that it is having problems with.
Cheers for the help!