com.ibm.productivity.tools.ui.views
Class DefaultRichDocumentView

java.lang.Object
  extended by org.eclipse.core.commands.common.EventManager
      extended by org.eclipse.ui.part.WorkbenchPart
          extended by org.eclipse.ui.part.ViewPart
              extended by com.ibm.productivity.tools.ui.views.DefaultRichDocumentView
All Implemented Interfaces:
RichDocumentView, org.eclipse.core.runtime.IAdaptable, org.eclipse.core.runtime.IExecutableExtension, org.eclipse.ui.IPersistable, org.eclipse.ui.ISaveablePart, org.eclipse.ui.ISaveablePart2, org.eclipse.ui.IViewPart, org.eclipse.ui.IWorkbenchPart, org.eclipse.ui.IWorkbenchPart2, org.eclipse.ui.IWorkbenchPart3, org.eclipse.ui.part.IWorkbenchPartOrientation

public class DefaultRichDocumentView
extends org.eclipse.ui.part.ViewPart
implements RichDocumentView, org.eclipse.ui.ISaveablePart2

This is the default Eclipse ViewPart to manipulate a 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 user.


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.ISaveablePart2
CANCEL, DEFAULT, NO, YES
 
Fields inherited from interface org.eclipse.ui.ISaveablePart
PROP_DIRTY
 
Fields inherited from interface org.eclipse.ui.IWorkbenchPart
PROP_TITLE
 
Constructor Summary
DefaultRichDocumentView()
           
 
Method Summary
 void addOperationListener(OperationListener listener)
          Adds an OperationListener into the view.
 void createPartControl(org.eclipse.swt.widgets.Composite arg0)
           
 void dispose()
           
 void doSave(org.eclipse.core.runtime.IProgressMonitor arg0)
           
 void doSaveAs()
           
 void executeOperation(Operation operation)
          Starts the operation in the view.
 java.lang.Object getAdapter(java.lang.Class clz)
           
 RichDocumentType getDocumentType()
          Gets the type of the current document.
 java.lang.String getFilePath()
          Gets the absolute path of the document loaded in the view.
 java.lang.Object getUNOModel()
          Returns the com.sun.star.frame.XModel object when the operation is started.
 boolean isDirty()
           
 boolean isSaveAsAllowed()
           
 boolean isSaveOnCloseNeeded()
           
 int promptToSaveOnClose()
           
 void removeOperationListener(OperationListener listener)
          Removes a registered OperationListener from the view.
 void setFocus()
           
 
Methods inherited from class org.eclipse.ui.part.ViewPart
getViewSite, init, init, saveState, setInitializationData
 
Methods inherited from class org.eclipse.ui.part.WorkbenchPart
addPartPropertyListener, addPropertyListener, getContentDescription, getOrientation, getPartName, getPartProperties, getPartProperty, getSite, getTitle, getTitleImage, getTitleToolTip, removePartPropertyListener, removePropertyListener, setPartProperty, 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
 

Field Detail

VIEW_ID

public static final java.lang.String VIEW_ID
The ID for this ViewPart.

See Also:
Constant Field Values
Constructor Detail

DefaultRichDocumentView

public DefaultRichDocumentView()
Method Detail

setFocus

public void setFocus()
Specified by:
setFocus in interface org.eclipse.ui.IWorkbenchPart
Specified by:
setFocus in class org.eclipse.ui.part.WorkbenchPart

getAdapter

public java.lang.Object getAdapter(java.lang.Class clz)
Specified by:
getAdapter in interface org.eclipse.core.runtime.IAdaptable
Overrides:
getAdapter in class org.eclipse.ui.part.WorkbenchPart

createPartControl

public void createPartControl(org.eclipse.swt.widgets.Composite arg0)
Specified by:
createPartControl in interface org.eclipse.ui.IWorkbenchPart
Specified by:
createPartControl in class org.eclipse.ui.part.WorkbenchPart

dispose

public void dispose()
Specified by:
dispose in interface org.eclipse.ui.IWorkbenchPart
Overrides:
dispose in class org.eclipse.ui.part.WorkbenchPart

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();

    com.sun.star.lang.XMultiServiceFactory factory = (com.sun.star.lang.XMultiServiceFactory)
        UnoRuntime.queryInterface(com.sun.star.lang.XMultiServiceFactory.class, obj);
    com.sun.star.text.XTextDocument textDoc = (com.sun.star.text.XTextDocument) 
        UnoRuntime.queryInterface(com.sun.star.text.XTextDocument.class, obj);
    obj = factory.createInstance("com.sun.star.text.TextTable");

    com.sun.star.text.XTextTable table = (com.sun.star.text.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.

promptToSaveOnClose

public int promptToSaveOnClose()
Specified by:
promptToSaveOnClose in interface org.eclipse.ui.ISaveablePart2

doSave

public void doSave(org.eclipse.core.runtime.IProgressMonitor arg0)
Specified by:
doSave in interface org.eclipse.ui.ISaveablePart

doSaveAs

public void doSaveAs()
Specified by:
doSaveAs in interface org.eclipse.ui.ISaveablePart

isDirty

public boolean isDirty()
Specified by:
isDirty in interface org.eclipse.ui.ISaveablePart

isSaveAsAllowed

public boolean isSaveAsAllowed()
Specified by:
isSaveAsAllowed in interface org.eclipse.ui.ISaveablePart

isSaveOnCloseNeeded

public boolean isSaveOnCloseNeeded()
Specified by:
isSaveOnCloseNeeded in interface org.eclipse.ui.ISaveablePart

getDocumentType

public RichDocumentType getDocumentType()
Description copied from interface: RichDocumentView
Gets the type of the current document.

Specified by:
getDocumentType in interface RichDocumentView
Returns:
type of current document.
See Also:
RichDocumentType

getFilePath

public java.lang.String getFilePath()
Description copied from interface: RichDocumentView
Gets the absolute path of the document loaded in the view. For example, c:\\test.odt on Windows® operating systems, and /home/test.odt on Linux® operating systems.

Specified by:
getFilePath in interface RichDocumentView
Returns:
absolute path of current document