com.ibm.productivity.tools.ui.views
Class DefaultRichDocumentView
java.lang.Object
org.eclipse.core.commands.common.EventManager
org.eclipse.ui.part.WorkbenchPart
org.eclipse.ui.part.ViewPart
com.ibm.productivity.tools.ui.views.DefaultRichDocumentView
- All Implemented Interfaces:
- org.eclipse.core.runtime.IAdaptable, org.eclipse.core.runtime.IExecutableExtension, org.eclipse.ui.IPersistable, org.eclipse.ui.IViewPart, org.eclipse.ui.IWorkbenchPart, org.eclipse.ui.IWorkbenchPart2, org.eclipse.ui.part.IWorkbenchPartOrientation, RichDocumentView
- public class DefaultRichDocumentView
- extends org.eclipse.ui.part.ViewPart
- implements RichDocumentView
This is the default Eclipse ViewPart to manipulate rich document. It implements
the RichDocumentView
interface to enhance the view by providing
document operation APIs.
The view is intended to be used directly or extended by client.
The following code demonstrates how to create a writer view.
public class WriterView extends DefaultRichDocumentView {
public WriterView() {
super();
}
public void createPartControl(Composite parent) {
super.createPartControl(parent);
createWriter();
}
private void createWriter()
{
NewOperation operation = OperationFactory.createNewOperation(RichDocumentType.DOCUMENT_TYPE );
this.executeOperation( operation );
}
}
- Since:
- 8.0.1
- See Also:
RichDocumentView
Field Summary |
static java.lang.String |
VIEW_ID
The id for this ViewPart. |
Fields inherited from interface org.eclipse.ui.IWorkbenchPart |
PROP_TITLE |
Methods inherited from class org.eclipse.ui.part.ViewPart |
getViewSite, init, init, saveState, setInitializationData |
Methods inherited from class org.eclipse.ui.part.WorkbenchPart |
addPropertyListener, getContentDescription, getOrientation, getPartName, getSite, getTitle, getTitleImage, getTitleToolTip, removePropertyListener, showBusy |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.eclipse.ui.IWorkbenchPart |
addPropertyListener, getSite, getTitle, getTitleImage, getTitleToolTip, removePropertyListener |
VIEW_ID
public static final java.lang.String VIEW_ID
- The id for this ViewPart.
- See Also:
- Constant Field Values
DefaultRichDocumentView
public DefaultRichDocumentView()
setFocus
public void setFocus()
- Specified by:
setFocus
in interface org.eclipse.ui.IWorkbenchPart
getAdapter
public java.lang.Object getAdapter(java.lang.Class clz)
- Specified by:
getAdapter
in interface org.eclipse.core.runtime.IAdaptable
createPartControl
public void createPartControl(org.eclipse.swt.widgets.Composite arg0)
- Specified by:
createPartControl
in interface org.eclipse.ui.IWorkbenchPart
dispose
public void dispose()
- Specified by:
dispose
in interface org.eclipse.ui.IWorkbenchPart
addOperationListener
public void addOperationListener(OperationListener listener)
- Description copied from interface:
RichDocumentView
- Adds an
OperationListener
into the view. If an operation is invoked,
the listener is notified.
- Specified by:
addOperationListener
in interface RichDocumentView
- Parameters:
listener
- - A listener to be notified when an operation is started.- See Also:
OperationListener
removeOperationListener
public void removeOperationListener(OperationListener listener)
- Description copied from interface:
RichDocumentView
- Removes a registered
OperationListener
from the view.
- Specified by:
removeOperationListener
in interface RichDocumentView
- Parameters:
listener
- - The listener to be removed- See Also:
OperationListener
executeOperation
public void executeOperation(Operation operation)
throws java.lang.UnsupportedOperationException
- Description copied from interface:
RichDocumentView
- Starts the operation in the view.
- Specified by:
executeOperation
in interface RichDocumentView
- Parameters:
operation
- - The operation to be started
- Throws:
java.lang.UnsupportedOperationException
- - If an error occurs while running the operation.- See Also:
Operation
getUNOModel
public java.lang.Object getUNOModel()
- Description copied from interface:
RichDocumentView
- Returns the com.sun.star.frame.XModel object when the operation is started.
The object is available after the operation is started successfully.
It is used to access the UNO APIs provided by the UNO service.
The following code demonstrates how to use the UNO model:
private void createTable( ) throws Exception {
NewOperation operation = ...;
Object obj = operation.getUNOModel();
XMultiServiceFactory factory = (XMultiServiceFactory) UnoRuntime
.queryInterface(XMultiServiceFactory.class, obj);
XTextDocument textDoc = (XTextDocument) UnoRuntime.queryInterface(
XTextDocument.class, obj);
obj = factory.createInstance("com.sun.star.text.TextTable");
XTextTable table = (XTextTable) UnoRuntime.queryInterface(
XTextTable.class, obj);
table.initialize(10, 10);
textDoc.getText().insertTextContent(textDoc.getText().getStart(),
table, false);
}
- Specified by:
getUNOModel
in interface RichDocumentView
- Returns:
- A com.sun.star.frame.XModel object for the created document