Title: Persistent Store Engine and Graphical Interface
1Persistent Store Engine and Graphical Interface
- SE690 Project
- by Edward Babayan
2JOPSE
- What is it?
- Its features
- JOPSE vs. Other Database Systems
- Design Characteristics
- Architecture details
- Swing Components vs. AWT Components
- Define Problems
- Outline Solutions
- Discuss the background and prerequisite knowledge
- Controls used in the Development Process
- Discuss the solutions/results/recommendations
- Summary of contributions
- Discuss Future Work and Direction
3JOPSE
- Stores data as objects in persistent way
- Easy to learn and user
- Platform independent
- Graphical implementation based on Java Object
Store technology (originally developed by Dr.
Jia)
4Java Object Store
- Console tool object database
- Used for persistent storage of objects
- Designed to be used with Java
- Completely implemented in Java
5JOPSE vs. Other Database Systems(RDMS)
- Stored Data Object Sets (special kind of
objects) vs. Tables - Data Records Elements (in the Object Set) vs.
Rows of records in a table - Queries Can be based on the values of fields or
the results of method invocations of the objects
in an Object Set. - Element Object Structure consists of fields and
methods. May be of different types. Its
polymorphic.
6JOPSE vs. Other Database Systems
- JOPSE vs. Object Relational Database
- Objects stored as Pure Java Objects vs. Blobs
- (binary large objects)
- JOPSE vs. SQLJ
- Pure Java Implementation vs. SQL embedded in
Java. (To use pure java for SQLJ, we need
preprocessor to convert SQLJ to pure Java
programs)
7Design Characteristics
- Simplicity easy to learn and use. The
persistent layer provided by the JOS database
component is nearly transparent to the
programmer. - Objects Sets extensions of the regular Java
collections and sets. - Lightweight small in size, efficient. The
Runtime Jar file of Object Store component is
only 55 KBs. - Extensibility - support a variety of
interchangeable implementations of the database,
storage and indexing policies.
8Architecture behind the Seen
- JOS component stores all database files in
specified directory. - Objects to be stored in JOS component must be
serializable implementing java.io.Serializable
interface. - Example
- public class User implements java.io.Serializable
- public User ()
- // Default contractor
-
- //Methods follow
- //Fields follow
-
9Architecture behind the Seen
- Some current functionality
- To store an object in the Object Store, we could
use one of the following methods - public void bind (Object object, String name)
- Creates new binding
- public void rebind (Object object, String name)
- Replaces current binding with the new one
10Architecture behind the Seen
- ObjectStoreManager class
- main class responsible for Opening object stores
for - read and write. If the object store does not
exist a - New one will be created and returned. Objects can
- be stored in the Object Store or in the Object
Set. - import xj.ostore.
- Â public class AddObjectUsers
- public static void main(String args)
- try
- ObjectStore odb ObjectStoreManager.open
(db1, ObjectStore.OPEN_READWRITE) - Â ObjectSet users odb.createObjectSet
(users) - Users.add (new User (user01, pw01,
Jack)) -
- odb.bind (new User (user01, pw01,
Jack), u1) - odb.bind (new User (user02, pw02,
Jill), u2) - odb.bind (new Student (Jack, 123450001,
3.6f), s1) - odb.bind (new Student (Jill, 123450002,
3.6f), s2) - odb.close()
- catch (ObjectStoreException e)
11Architecture behind the Seen
12Architecture behind the Seen
- Key Features of Object Store
- Storing/Retrieving Objects
- Creating Object sets
- Indexing and Selecting
- Query Predicates
- Updating Named Objects/ Updating Elements in the
Object Set - Removing Names Objects/ Removing Elements in the
Object Set - Deleting Object Store
13Graphical Interface
- Graphical User Interface Modeling
- Goal is to create interactive GUI
- Simple and Powerful Interface several iterations
are necessary! - Component Abstraction and Reuse
- Usage of object oriented GUI components,
encapsulated components called Visuals can be
used. - Visuals can easily be customized to fulfill
particular needs. - Maintenance Aspect
- More structured design results in enhancement of
maintainability. - Any change, enhancement or redesign of general
use can be performed in the base visual class.
14Swing Components vs. AWT Components
- Swing
- Part of JFC which encompass a group of features
to help people build graphical user interfaces
(GUIs) - Code name of the project that developed new GUI
components - First available as an Add-on to JDK1.1
- Java 2 strongly encourages to use Swing
components - Swing components start with letter J
- Swing components are in the package javax.swing
where is AWT components are in java.awt.
15Swing Components vs. AWT Components
- As a rule, programs should not use "heavyweight"
AWT components alongside Swing components.
Heavyweight components include all the
ready-to-use AWT components, such as Menu and
Scroll Pane, and all components that inherit from
the AWT Canvas and Panel classes. When Swing
components (and all other "lightweight"
components) overlap with heavyweight components,
the heavyweight component is always painted on
top.
16Swing Components vs. AWT Components
- What are JFC and Swing?
- The Swing components
- Include everything from buttons to split panes to
tables - Plug gable Look and Feel Support
- Gives any program that uses Swing components a
choice of looks and feels. For example, the same
program can use either the Java TM look and feel
or the Windows look and feel. - Java 2D API
- Easily incorporates high-quality 2D graphics,
text, and images in applications and applets. - Drag and Drop Support
- the ability to drag and drop between a Java
application and a native application
17Swing Components vs. AWT Components
- Swing components implemented with absolutely no
native code. - Swing components can be shipped as an Add on to
JDK1.1, in addition to being part of Java 2
platform - Swing lets you specify which look and feel your
program's GUI uses. By contrast, AWT components
always have the look and feel of the native
platform
18Swing Components vs. AWT Components
- Swing buttons and labels can display images
instead of, or in addition to, text. - Can easily add or change the borders drawn around
most Swing components. For example, it's easy to
put a box around the outside of a container or
label. - You can easily change the behavior or appearance
of a Swing component by either invoking methods
on it or creating a subclass of it. - Swing components don't have to be rectangular.
Buttons, for example, can be round. - Assistative technologies such as screen readers
can easily get information from Swing components.
For example, a tool can easily get the text
that's displayed on a button or label.
19Swing Components vs. AWT Components
- Be aware of a few got Chas when using Swing
components and AWT - Programs should not, as a rule, use "heavyweight"
components alongside Swing components.
Heavyweight components include all the
ready-to-use AWT components (such as Menu and
Scroll Pane) and all components that inherit from
the AWT Canvas and Panel classes. This
restriction exists because when Swing components
(and all other "lightweight" components) overlap
with heavyweight components, the heavyweight
component is always painted on top. - Swing components aren't thread safe. If you
modify a visible Swing component -- invoking its
set Text method, for example -- from anywhere but
an event handler, then you need to take special
steps to make the modification execute on the
event-dispatching thread. - The containment hierarchy for any window or
applet that contains Swing components must have a
Swing top-level container at the root of the
hierarchy. For example, a main window should be
implemented as a JFrame instance rather than as a
Frame instance. - You don't add components directly to a top-level
container such as a JFrame. Instead, you add
components to a container (called the content
pane) that is itself contained by the JFrame.
20Swing Component Hierarchy
21Define Tasks
- Dynamically creating Object Store if one doesnt
exist - Dynamically adding Objects / Object Sets to the
existing Object Store - Dynamically removing Objects / Object Sets from
the existing Object Store - Modifying existing Table View of data in
application to be able to see fields and their
related types of stored Objects inside a
particular Set selected. - Modifying existing Table View of data to be able
to see Column names as fields of Objects stored
in a Set and their values for instant updating of
information. - Building OstoreSecurityChecker tool to facilitate
process of validating Users to the System - Develop additional components that will minimize
the process of using command line tools currently
available for testing of the framework.
22Outline Solutions
- Extension of the Menu components
- Availability of Menus based on what is being
selected by user in GUI tool - The Concept of Select GUI Item and Choose Menu
- comes from the tool called DB Visualizer
developed by Minq Software AB, that is
lightweight database tool. - Object Tree adapts to the current database, shows
appropriate objects such as schemas. Database
data and table type information. - Ability to click on the column header and grids
are sorted ascending or descending order. Grids
are sized automatically according to the content - Intuitive and fast GUI
- User always geared toward the Menu bar for
assistance and becomes a natural action to do.
23Outline Solutions
- The concept of Select GUI Item and Right Click
Pop Up Menu - Gives right on the spot choice to make by user
based on the GUI item selected.
24Discuss the background and prerequisite knowledge
- Java Object Store Tutorial
- To learn its architecture and component classes,
specially xj.ostore.tool package. - Java Swing 1.1 Sun Micro Systems Tutorial
- To learn components such as Jdialogs, Jframes,
Jpanel, JscrollPane, JSplitPane, JTabbbedPane,
Jbutton, Jmenu, JTextField, Jlabel, Jtable, Jtree
and Reflection mechanism. - Great library of examples and sample codes!!!!!
- Quick Reference
- Beginning Java by Ivor Horton (WROX)
- How to Program in Java by Deitel Deitel
25Controls used in my development process
- Jlabel
- Ability to display images
- Supplying an Image Icon to the constructor
- Call to set Icon.
- Ability to place borders around the labels
- Ability to use HTML to format the label
- If the string for the Label begins with lthtmlgt
then the string is interpreted as HTML rather
than taken literally. - Lets you make multi-line labels
- Labels with mixed colors and fonts
- Capability has several significant limitations
- Only works in JDK 1.2.2 or later, or in Swing
1.1.1 or later - Label must begin with lthtmlgt, not ltHTMLgt
- Embedded images are not supported in the HTML.
- Jlabel fonts are ignored if HTML is used
- Example
- JLabel label new JLabel ("lthtmlgtBold Text")
26Controls used in my development process
- Jbutton
- Ability to associate images with buttons. Swing
introduced an utility class called Image Icon
that lets you very easily specify an image file. - To associate an image with a Jbutton is to pass
the Image Icon to the constructor, either in
place of the text or in addition to it. - Can change the alignment of the text or icon in
the button and change where the text is relative
to the icon. - Easily can set keyboard mnemonics via set
Mnemonic. This results in the specified character
being underlined on the button, and also in
ALT-char activating the button. - Ability to use HTML in Jbutton for labeling of
the buttons providing multi-line labels, mixed
fonts and colors. - JButton buttons new JButton2
-
- buttonst.setText("Add " classDefiner.getName()
) - buttonst.addActionListener(new
ActionListener() - public void actionPerformed(Action Event e)
- add_Object(e)
-
- )
27Controls used in my development process
- JFrame
- Components go in the content pane, not directly
in the frame. - Changing other properties (layout manager,
background color, etc.) also apply to the content
pane. - Access content pane via get Content Pane method,
or if you want to replace the content pane with
your container, use set Content Pane - Jframe closes automatically when you click on the
close button unlike AWT frames. - Your main Jframe still needs a Window Listener
while closing the last Jframe to exit Java. - Jpanel
- Used in the same way as Panel.
- Allocate it , drop components in it, then add the
Jpanel to some Container. - Also acts as a replacement for Canvas (there is
no JCanvas)
28Controls used in my development process
- JDialog
- Modal When a modal dialog is visible, it blocks
user input to all other windows in the program.
The dialogs that JOption Pane provides are modal. - To create a non-modal dialog, you must use the
Jdialog class directly. - Jdialog class is a subclass of the AWT
java.awt.Dialog class. - Adds to Dialog root Pane and support for a
default close operation. - Static methods in the JOptionPane class let you
easily create modal dialogs to show messages
(JOptionPane.showMessageDialog), to ask for
confirmation (JOptionPane.showConfirmDialog), let
the user enter text or to choose among predefined
options (JOptionPane.showInputDialog), or to
choose among a variety of buttons
(JOptionPane.showOptionDialog). Each of these
methods either returns an int specifying which
button was pressed, or String specifying the
option selected. - JDialog dlgOK new JDialog()
- JOptionPane paneOK new JOptionPane()
- paneOK.showMessageDialog(dlgOK, "ODB Home field
hasn't been filled!", "Java - ObjectStore Message Box", paneOK.WARNING_MESSAGE)
- dlgOK.getContentPane().add(paneOK)
29Controls used in my development process
- JTree
- Used to create Objects of type DefaultMutableTreeN
ode to act as the Node of the Tree. - Gets its data by querying its Data Model
- Node that can have children is called Branch node
- Node that has no children is called a Leaf node
- User Object when you supply a value to
DefaultMutableTreeNode constructor that acts as
the value at each node. The to String() method of
that User Object is what is displayed for each
node
30Controls used in my development process
- JTree
- Once we have some nodes, we hook them up together
in a tree structure via parent Node.add(child
Node). - We pass the node to JTree constructor
- Since trees can usually change size based on the
user input (expanding and collapsing nodes),
trees are usually placed inside a JScrollPane - DefaultMutableTreeNode root new
DefaultMutableTreeNode ("Root") - DefaultMutableTreeNode child1 new
DefaultMutableTreeNode ("Child 1") - root. add(child1)
- DefaultMutableTreeNode child2 new
DefaultMutableTreeNode ("Child 2") - root. add(child2)
- JTree tree new JTree (root)
- SomeWindow.add (new JScrollPane (tree))
- User Objects
- The argument to the DefaultMutableTreeNode
constructor - an object that contains or points to the data
associated with the tree node. - The user object can be a string, or it can be a
custom object - If you implement a custom object, you should
implement its to String method so that it returns
the string to be displayed for that node. - Responding to the Tree Node Selections is simple,
we implement TreeSelectionListener and register
it on the Tree.
31Controls used in my development process
- Jtree
- To customize display of the Tree control, you can
specify to draw lines detailing the relationships
between nodes, use this code tree.putClientProper
ty ("JTree.lineStyle", "Angled"). - If you want to change the Icons or text used in
describing the Nodes and branches, you can use
Default Tree Cell Render Component to do that by
using set Leaf Icon, set Close Icon, set Open
Icon and so on. Default Tree Cell Render
Component is a subclass of a JLabel. - Use Trees set Cell Renderer method to specify
that the Default Tree Cell Renderer paint its
nodes. - JScrollPane
- provides a scrollable view of a component. When
screen real estate is limited, use a scroll pane
to display a component that is large or one whose
size can change dynamically. - TextArea new JTextArea (5, 30)
- JScrollPane scroll Pane new JScrollPane
(textArea) - ContentPane.setPreferredSize (new Dimension (400,
100)) - ContentPane.add (scroll Pane, BorderLayout.CENTER)
- View port Object
- Used by JScrollPane to manager the visible area
of the client. The view port is responsible for
computing the bounds of the current visible area,
based on the positions of the scroll bars, and
displaying it.
32Controls used in my development process
- JSplit Pane
- displays two components, either side by side or
one on top of the other. By dragging the divider
that appears between the components, the user can
specify how much of the split pane's total area
goes to each component. You can divide screen
space among three or more components by putting
split panes inside of split panes. - Better put each component into a scroll pane.
Then put the scroll panes into the split pane.
This allows the user to view any part of a
component of interest, without requiring the
component to take up a lot of screen space or
adapt to displaying itself in varying amounts of
screen space. - //Create a split pane with the two scroll panes
in it. - SplitPane new JSplitPane (JSplitPane.HORIZONTAL
_SPLIT, - ListScrollPane, pictureScrollPane)
- SplitPane.setOneTouchExpandable (true)
- SplitPane.setDividerLocation (150)
- //Provide minimum sizes for the two components
in the split pane - Dimension minimumSize new Dimension (100, 50)
- ListScrollPane.setMinimumSize (minimumSize)
- PictureScrollPane.setMinimumSize (minimumSize)
33Controls used in my development process
- JTabbed Pane
- Allows to have several components to share the
same space - User chooses which component to view by selecting
the tab corresponding to the desired component - To create Tabbed Pane
- Instantiate JTabbedPane class
- Create components you wish it to display
- Add components to the tabbed pane using the add
Tab method. - JPanel contentPane new JPanel()
-
- tabbedPane.addTab(classDefiner.getName(), null,
- ContentPane, "Add " classDefiner.getName())
34Controls used in my development process
- JMenus
- Provides a space-saving way to let the user
choose one of several options. - Supports two kinds of keyboard alternatives
- Mnemonics and accelerators
- Mnemonics offer a way to use the keyboard to
navigate the menu hierarchy, increasing the
accessibility of programs. It makes already
visible menu item to be chosen - Accelerators offer keyboard shortcuts to bypass
navigating the menu hierarchy. It is key
combination that causes a menu item to be chosen,
whether or not it is visible. - You can also change the way menu Items are
displayed by changing Layout manager. The default
one is Box Layout.
35Controls used in my development process
- JTextField
- Used to provide text fields. Lets user enter
small amount of text. - If you need to provide password field an
editable text field that doesnt show the
characters the user types use the
JPasswordField class instead. - As a subclass of JtextComponent, it can be
configured and customized. - JPasswordField, as another security precaution,
stores its value as an array of characters,
rather than as string. By default a password
field displays an asterisk for each character
typed. The call to setEchoChar changes it to a
pound sign . - JTable
- Allows to display tables of data, optionally
allowing user to edit the data - It doesnt contain or cache data it is simply a
vie of your data - Each column in a table is represented by a
TableColumn object. - Two constructors that accept data
- Jtable(Object rowData, Object
columnNames) - Jtable(Vector rowData, Vector columnNames)
- These constructs make every cell editable, treat
all data the same ( as a String). - Every table gets its data from an Object that
implements TableModel interface. - Cell Renderer used to draw all of the cells in a
column. Often, this cell renderer is shared
between all columns that contain the same type of
data.
36Controls used in my development process
- Table
- Cell Editor when a user starts to edit the
cells data, this object takes over the cell,
controlling the cells editing behavior. - By Default. The cell renderer for a
Number-containing column uses a single Jlabel
instance to draw the appropriate numbers, right
aligned, on the columns cells. If the user
begins editing one of the cells, the default cell
editor uses a right-aligned JTextField to control
cell editing. - Currently, tables put the following types of data
in the list - Boolean renderered with a check box
- Number renderered by a right-aligned label
- Image Icon renderered by centered label
- Object renderered by a label that displays the
objects string value - Data Manipulator specialized table models. This
manipulator sits between the table and the data
model to control sorting of the tables data - You can use the Table Map and Table Sorter
classes when implementing your data manipulator.
Table Map.java implements TableModel and servers
as a super class for data manipulators. Table
Sorter.java is a Table Map subclass that sorts
the data provided by another table model. - Implementing Sorting with Table Sorter
37Controls used in my development process
- Implementing Sorting with Table Sort.
- TableSorter sorter new TableSorter (myModel)
- Jtable table new Jtable(sorter)
- Sorter.adddMouseListenerToHeaderInTable(table)
- REFLECTION
- Helps to create an Object if you dont know its
class name until run time - Helps to get values of an objects fields, even
if you dont know the name of the object, or even
its class until run time. - Given an object, you can find out what methods
its class defines, and then invokes the methods. - get Fields() method returns an array of Field
objects containing one object per accessible
public field. - A public field is accessible if it is a member of
either objects class, super class of objects
class, interface implemented by objects class or
interface extended from the interface implemented
by objects class. - Methods provided by Field class allow you to
retrieve fields name, type and set of
modifiers.You can even get and set a value of the
field
38Controls used in my development process
- REFLECTION
- You must be able to obtain values by
- Create a Class Object
- Create a Field object by invoking get Fields ()
on the Class Object - Invoke one of the get methods on the Field object
to get its value. - To retrieve Class object
- If the instance of the Class is available, you
can invoke Object.get Class. The get Class method
is useful when you want to examine an object but
you dont know its class. - Class c object.get Class()
- If you know the name of the class at compile
time, you can retrieve its Class object by
appending class to its name. In the next example,
the Class object that represents the Button class
is retrieved. - Class s java.awt.Button.class
- If the class name is unknown at compile time, but
available at run time, you can use forName
method. If the String name strg is set to
java.awt.Button then forName returns the Class
object associated with the Button class - Class c Class. forName(strg)
-
-
39Discuss solutions/results/recommendations
- independent creation of components that would
define the extension of Graphical Interface for
the current tool. - created a Testing Tree Control with the Test Menu
and continued to plug the menus in the Test
Application to see if my new developments would
perform to specifications that would be defined
later. - each control developed such as Menu Items to Add
Objects, Create Store, Delete Store, Close Store,
Objects Menu, Add Object Set, Remove Object were
all at first independent components that could be
plugged in and out of the testing application. - extended the main application and added new
components to the already existing menu bar for
more specific testing and validation of controls.
- Goal was to enable and disable menu items when a
user pressed particular DefaultMutableTreeNode in
the main tree and give user addition tools to
work with accordingly.
40Summary of Contributions
- Created new Menu Item to create Object Store
dynamically if one doesnt exist - Created confirmation Dialog to ask if use wants
to delete existing Object Store - Created input Dialog used to enter new
information for new Object Store to be created.
Its directory name and its name. - Developed OstoreSecurityChecker, which is a
console tool used separately from the application
to validate user to the System based on the users
that exists in the Java Object Store. - Extended application to include and show new
dynamic functionality existing in the Java Object
Store - Created Menu Item used for providing a Dialog to
add new Objects to Java Object Store. - Developed a Dialog used to add new Objects to
Java Object Store. Can be extends to add new
Objects. - Created a Menu Item to close current Java Object
Store application view. - Created Menu to add three menu items such as
Create OstoreItem, Delete OstoreITem, Close
Ostore Item menu Items. To manage their
availability. - Developed a Menu Item to add empty Object Sets to
Java Object Store. - Created a Menu Item to remove Objects/Object Set
(s) from the Object Store.
41Summary of Contributions
- Created a Reader and Writer to keep track of the
different Objects added to the system and
accessing the next counter to be used in the
addition of Objects to the Object Store. - Created a Validation Dialog box to message the
status of the fields filled in the Add Objects
Dialog. - Modified the view of Table to see Field and Type
Columns once the user clicks on the Set selected.
User is presented with the view of the fields and
their types that are defined in the Objects
stored in particular Set selected. - Modified the view of Table to see Object Field
Columns and their values if Available when user
clicks on the Leaf representing Object stored in
the Object Store directly or in the Object Set
selected. - Added Table listeners for Rows and Columns and
Cells of the Table that is used for
representation of data for further updating of
Objects information.
42Future work and directions
- Make Object Store Add Objects Dialog more
generic for development process and smaller in
size. - Modify Validator component to validate fields of
the Objects that currently is of protected type. - Modify table view to be able to update
information displayed on the fly for Objects/
Object Sets. - Debug currently existing code and modifications
to test full capabilities of application.
Optimize existing coding techniques, use of
pattern programming.