T42-2017: Customization Changes That Will Be Required for Workbook 2018
Workbook
With the changing of BIOVIA Workbook 2018 to use .NET 4 and JAVA 8, a number of changes to customizations are required.
Resolution:
With the changing of underlying packages like DevExpress, .Net 4, and JAVA, current customization may need some coding changes.
- Some DevExpress constructors have changed slightly. The constructor must be completed (which triggers the "Initialize" or "OnInitialize" methods) before the associated container can be populated with data. The data assignment can only be done after the constructor is complete. The 'OnInitialize' methods are not explicitly called, but are attached to the control's constructor.
- Here is an example of code that will need to be changed:
Bad Code:
public class PageWithControls : PropertyPage
{
private DevExpress.XtraGrid.GridControl _gridControl1;
// This constructor is called when the page is requested. It builds the page, and calls helpers to build each component as needed.
public PageWithControls()
{
Title = "Bad Page";
Control = new CustomizedGridControl();
}
}
public class CustomizedGridControl : DevExpress.XtraGrid.GridControl
{
// This constructor is called when a CustomizedGridControl is added to the page currently being built.
public CustomizedGridControl()
{
_gridControl1 = new DevExpress.XtraGrid.GridControl()
{
// CSS, size, margins, titles, event handlers, etc.
};
_gridControl1.DataSource = new List<string>() { "Value1", "Value2", "Value3" }; // this line is the problem, as it's assigning data inside the constructor
}
}
- Here is an example of how it should be done:
Good Code:
public class PageWithControls : PropertyPage
{
private DevExpress.XtraGrid.GridControl _gridControl1;
// This constructor is called when the page is requested. It builds the page, and calls helpers to build each component as needed.
public PageWithControls()
{
Title = "Good Page";
Control = new CustomizedGridControl();
// The control has now been initialized, so we can assign data to it here
_gridControl1.DataSource = new List<string>() { "Value1", "Value2", "Value3" };
}
}
public class CustomizedGridControl : DevExpress.XtraGrid.GridControl
{
// This constructor is called when a CustomizedGridControl is added to the page currently being built.
public CustomizedGridControl()
{
_gridControl1 = new DevExpress.XtraGrid.GridControl()
{
// CSS, size, margins, titles, event handlers, etc.
};
}
}
- Alternatively, you can override the "OnInitialize" method to populate the data there:
public class PageWithControls : PropertyPage
{
private DevExpress.XtraGrid.GridControl _gridControl1;
// This constructor is called when the page is requested. It builds the page, and calls helpers to build each component as needed.
public PageWithControls()
{
Title = "Alternative Good Page";
Control = new CustomizedGridControl();
}
// This is called when the PageWithControls() constructor is 'done'
protected override void OnInitialize()
{
base.OnInitialize();
// Initialization is complete, so we can assign data to the control now
_gridControl1.DataSource = new List<string>() { "Value1", "Value2", "Value3" };
}
}
public class CustomizedGridControl : DevExpress.XtraGrid.GridControl
{
// This constructor is called when a CustomizedGridControl is added to the page currently being built.
public CustomizedGridControl()
{
_gridControl1 = new DevExpress.XtraGrid.GridControl()
{
// CSS, size, margins, titles, event handlers, etc.
};
}
}
2. Some namespaces are now obsolete. Official replacements exist, and functionality should be unchanged.
- GridView.ShowGridMenu -> GridView.PopupMenuShowing
- GridView.GridMenuEventArgs -> GridView.PopupMenuShowingEventArgs
- XtraTreeList.TreeListMenuEventArgs -> XtraTreeList.PopupMenuShowingEventArgs
3. Some menu item lists' creation has changed. Items that were previously created with an initial 'hidden' attribute are no longer created until they're needed (and are removed when they're no longer needed). This change shouldn't present a problem except for some scripts that modify contextual menus without properly checking if the menu options they're attempting to modify actually exist.This means that changes for 'hidden' menus must check if they currently exist.
4. The Method 'GridView.CalcRowHeight()' now expects 4 parameters instead of 3. The 4th parameter "must be equal to the row's level". There is a 'GridView.GetRowLevel' method that can fill the fourth parameter. The CalcRowHeight method is "internal" to DevExpress, and not intended to be called directly. If you are using this method please go to DevExpress for help.
5. Some events referencing a RowHandle now claim that it is officially deprecated, as there are apparently cases where it won't exist. Users should be using ListSourceRowIndex instead, but will need to test that there are no functionality changes.