home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-08-14 | 2.3 KB | 78 lines |
- // JFScomponent.java
- // The base component from which all JFS client applets are derived. This
- // means that a file browser can load a client program to handle some file
- // type, and be sure that it has certain needed methods.
- import java.awt.*;
- import JFSclient;
-
- public abstract class JFScomponent extends Panel
- {
- JFSclient client; // connection to JFS server
-
- // init
- // This method is called after the constructor, for the component
- // to create it's user interface. If the component is being loaded
- // only to load() and print() something, this method will not be
- // called. Note - if init() is called, then it is guaranteed to be
- // before connect() and load().
- void init(java.applet.Applet a) { }
-
- // connect
- // Use the given client (which should be already connected and
- // authenticated) for communication. The component should only
- // enable itself when this method is called.
- void connect(JFSclient c)
- {
- client = c;
- }
-
- // load
- // Load the given file. It must be of some type that this
- // component can handle
- void load(String file, int ver) throws RequestException
- {
- throw new RequestException("No load method defined for "+
- this.getClass().getName());
- }
-
- // render
- // Render a representation of the loaded data into a Graphics. This
- // could be called by a program like a word processor that can
- // embed other data into a document.
- void render(Graphics g, int w, int h) { }
-
- // wantedsize
- // Return the size that this component would like to be. There is
- // no guarantee that it will actually get to be this size though.
- abstract Dimension wantedsize();
-
- // print
- // Prints the current document to the given printer, which is of
- // the given type (ie. Postscript, Text, ...)
- void print(String printer, String type) throws RequestException
- {
- throw new RequestException("No print method defined for "+
- this.getClass().getName());
- }
-
- // save
- // A convenience function for writing data to a file. If the file
- // doesn't already exist then the version actually used is
- // set to something sensible.
- void save(byte data[], String file, String type, int ver, boolean m)
- throws RequestException
- {
- boolean exists = true;
- try client.statfile(file);
- catch(RequestException e)
- exists = false;
- if (!exists) {
- if (m) ver = 1;
- else ver = 0;
- }
- client.put(file, ver, data, type);
- client.setcurrent(file, type);
- }
- }
-
-