PhpDocumentImpl.java Sample

This topic inludes the source code for the PhpDocumentImpl.java Sample.

Sample Location

This sample is located in the following directory in your WebLogic Workshop installation:

BEA_HOME/weblogic81/samples/workshop/ExtensionDevKit/IdeDevKit/CustomProject/src/ideExtensions/customProject/

Sample Source Code


001 package ideExtensions.customProject; 
002 
003 import com.bea.ide.core.navigation.INavigationPoint;
004 import com.bea.ide.document.IDocument;
005 import com.bea.ide.document.IDocumentView;
006 import com.bea.ide.document.IDocumentViewInfo;
007 import com.bea.ide.lang.java.JavaDocument;
008 import com.bea.ide.lang.text.TextDocument;
009 import com.bea.ide.sourceeditor.EditorSvc;
010 import com.bea.ide.sourceeditor.driver.ISourceViewDriver;
011 import java.awt.Container;
012 import java.io.IOException;
013 import java.net.URI;
014 import java.util.ArrayList;
015 import javax.swing.Icon;
016 
017 /**
018  * A simple document implementation to manage the contents of 
019  * a PHP document, providing names for views of the document and 
020  * deferring to TextDocument for all other functionality.
021  */
022 public class PhpDocumentImpl extends TextDocument
023 
024     /**
025      * Constructs an instance of this class with the 
026      * handler class and a URI to the file that is a physical
027      * instance of the document. This merely calls the 
028      * TextDocument constructor.
029      */
030     public PhpDocumentImpl(Class handler, URI uriFilethrows IOException
031     {
032         super(handler, uriFile)
033     }
034 
035     /**
036      * Called by the IDE to retrieve the views of a PHP 
037      * document. This document implementation supports "two" views,
038      * source view and design view, although the two are 
039      * identical. The class used to define these views is
040      * contained within this class.
041      */    
042     public IDocumentViewInfo[] getViewInfo()
043     {
044         IDocumentViewInfo[] views = new IDocumentViewInfo[2];    
045         PhpViewInfo viewInfo = new PhpViewInfo(this);
046         viewInfo.setName("PHP Source View");
047         views[0= viewInfo;
048         viewInfo = new PhpViewInfo(this);   
049         viewInfo.setName("PHP Design View");
050         views[1= viewInfo;
051         return views;
052     }
053 
054     /**
055      * A simple way to provide a view of PHP files. 
056      * The getViewInfo method returns instances of this class
057      * to provide two view tabs: PHP Source View and 
058      * PHP Design View. The views are identical, of course,
059      * but this code illustrates how you respond to the IDE's
060      * request for views of a document.
061      */
062     class PhpViewInfo implements IDocumentViewInfo
063     {
064         
065         TextDocument m_doc;
066         String m_name;
067         
068         /**
069          * Constructs an instance of this view using the
070          * document handler class that contains this class.
071          
072          @param doc The document handler to build a 
073          * view of.
074          */
075         public PhpViewInfo(TextDocument doc)
076         {
077             m_doc = doc;   
078         }
079         /**
080          * Sets the name of the view as it should
081          * appear on the view's tab in the IDE.
082          
083          @param name The name to use for the view.
084          */
085         public void setName(String name)
086         {
087             m_name = name;   
088         }
089         /**
090          * Called by the IDE to get the name of the view.
091          */
092         public String getName()
093         {
094             return m_name;   
095         }
096         /**
097          * Called by the IDE to get the icon that should
098          * be displayed for this view.
099          */
100         public Icon getIcon() { return null}
101         /**
102          * Called by the IDE to get this view's description.
103          */
104         public String getDescription() { return "desc for php view...."}
105         /**
106          * Called by the IDE to create an instance of this view.
107          */
108         public IDocumentView createView() 
109         {
110            return EditorSvc.get().createSourceView(m_doc);
111         }
112     }    
113 
114 }