Before you can complete the steps in this
example, you must have a plug-in project includes the
com.businessobjects.crystalreports.designer.sdk
library, defines the
com.businessobjects.crystalreports.designer.sdk.ReportEditorPage
extension point, and includes a class that implements the UI for a report
designer page.
This example shows how to attach a page to the
Crystal Reports editor by
implementing the
com.businessobjects.crystalreports.designer.sdk.ICrystalReportsEditorPage
interface and adding the
attachToEditor and
attachOnStart methods.
Open the class that implements the
ReportEditorPage extension
point.
For example, open
MyReportPage.java.
Implement the
ICrystalReportsEditorPage
interface.
Include the import statements used in this
example.
import com.businessobjects.crystalreports.designer.sdk.ICrystalReportsEditorPage;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IPropertyListener;
Implement the
ICrystalReportsEditorPage
interface.
public class MyReportPage extends EditorPart implements ICrystalReportsEditorPage
{
...
}
Add the
attachToEditormethod to set the
editor, and call the
setInput
method.
public void attachToEditor(ICrystalReportsEditor editor)
{
myEditor = editor;
setInput(myEditor.getEditorInput());
myEditor.addPropertyListener (new IPropertyListener ()
{
public void propertyChanged(Object source, int propID)
{
if (propID == IEditorPart.PROP_INPUT)
setInput (myEditor.getEditorInput());
}
});
}
}
Implement the
attachOnStart method.
Note: It is recommended to attach the editor
the first time the page is made active. Return
false to attach
the page the first time it is made active. Return
true to attach
the page when the editor is loaded.
public boolean attachOnStart()
{
return false;
}
The page is initialized, and it
appears in the report editor.