Don't try to debug it. It is on a shared net server and can be debug only on my network.
[code]
ort javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import javax.swing.table.DefaultTableModel.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import sharednet.*;
import sharednet.immaccs.*;
import sharednet.immaccs.SNReflection;
import query_c.SNQuery_cPackage.*;
import sharednet.ConnectionManagement.*;
import sharednet_c.SNBase_cPackage.eClassId;
import sharednet_c.*;
import sharednet.query.*;
import sharednet.filter.ClientIDFilter;
public class FirstFrame extends JFrame
{
//mine
Container contentPane, NewcontentPane;
JTextArea output;
JScrollPane tablePane;
JDialog helpDialog, refreshDialog, newDialog, tableDialog;
JMenuBar menuBar;
JMenu fileMenu, editMenu, helpMenu, viewMenu, submenu;
JMenuItem ExitmenuItem, menuItem, NewmenuItem, RefreshmenuItem;
JCheckBoxMenuItem RefNamecbMenuItem, OwnercbMenuItem,
ObjectcbMenuItem, ClassIDcbMenuItem;
JRadioButtonMenuItem rbMenuItem;
JList newList;
MenuListener menuListener, RefreshmenuListener,
ObjectmenuListener;
MenuListener OwnermenuListener, ReferencemenuListener,
ClassIDmenuListener;
QueryListener queryListener;
JLabel newLabel, label, tableLabel;
JButton newButton, button, tableButton;
CloseHelpListener closeListener, NewcloseListener,
TablecloseListener;
String text;
JOptionPane NewoptionPane;
JTable defaultTable;
TablePopup tablePopup;
ListSelectionModel lsm;
int selectedRow, numColumns;
private boolean ALLOW_COLUMN_SELECTION= false;
private boolean ALLOW_ROW_SELECTION= true;
//SNBase Platform;
SNBase[] resultObjects = null;
JList list;
JTable table;
SNAPI snapi = null;
String appName = "QueryDriver";
String userName = "QueryDriver";
eClassId classId = eClassId.SNBase_;
String queryString = "1==1";
eOrderBy orderBy = eOrderBy.LOCATION;
String server = "";
SNQuery snquery = null;
Object[][] tabledata;
Object[] objects;
int temp=1;
static final String columnheaders[]= new String []{ "Object Name",
"Reference", "ClassId", "Owner" };
public FirstFrame()
{
//super(new BorderLayout()); //theirs
//mine
setTitle ("Object Viewer");
setSize (328,920);
addWindowListener (new WindowAdapter ()
{//b/g window listener
public void windowActivated (WindowEvent e)
{
}
public void windowClosed (WindowEvent e)
{
//System.out.println ("Window Closed.");
System.exit (0);
}
public void windowClosing (WindowEvent e)
{
//System.out.println ("Window Closing.");
System.exit (0);
}
public void windowDeactivated (WindowEvent e)
{
//System.out.println ("Window Deactivated");
}
public void windowDeiconified (WindowEvent e)
{
//System.out.println ("Window Deiconified.");
}
public void windowIconified (WindowEvent e)
{
//System.out.println ("Window Iconified.");
}
public void windowOpened (WindowEvent e)
{
//System.out.println ("Window Opened.");
}
});//end of window listener
//Create the menu bar.
menuBar = new JMenuBar();
setJMenuBar(menuBar);
//Build the first menu.
fileMenu = new JMenu("File");
fileMenu.setMnemonic(KeyEvent.VK_F);
menuBar.add(fileMenu);
//JMenuItems
NewmenuItem = new JMenuItem("New Query",
KeyEvent.VK_N);
NewmenuItem.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_1, ActionEvent.ALT_MASK));
fileMenu.add(NewmenuItem);
queryListener= new QueryListener();
NewmenuItem.addActionListener (queryListener);
NewmenuItem.setActionCommand("new");
ExitmenuItem = new JMenuItem("Exit", KeyEvent.VK_X);
ExitmenuItem.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_F4, ActionEvent.ALT_MASK));
fileMenu.add(ExitmenuItem);
menuListener= new MenuListener();
ExitmenuItem.addActionListener (menuListener);
ExitmenuItem.setActionCommand("exit");
//Build the second menu.
editMenu = new JMenu("Edit");
editMenu.setMnemonic(KeyEvent.VK_E);
menuBar.add(editMenu);
//JMenuItems
RefreshmenuItem = new JMenuItem("Refresh",
KeyEvent.VK_R);
RefreshmenuItem.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_2, ActionEvent.ALT_MASK));
editMenu.add(RefreshmenuItem);
RefreshmenuListener= new MenuListener();
RefreshmenuItem.addActionListener (RefreshmenuListener);
RefreshmenuItem.setActionCommand("refresh");
refreshDialog = new JDialog(this, "Refresh");
refreshDialog.setBackground(Color.gray);
refreshDialog.setSize(250, 100);
// "text" of refresh dialog box
label = new JLabel("Version 1.0 "+
"Created by Keiyia Jackson");
refreshDialog.getContentPane().add(label, "North");
// button to close help dialog box
button = new JButton("click when done reading");
refreshDialog.getContentPane().add(button, "South");
closeListener = new CloseHelpListener();
button.addActionListener(closeListener);
//Build the third menu.
viewMenu = new JMenu("View");
viewMenu.setMnemonic(KeyEvent.VK_V);
menuBar.add(viewMenu);
//a group of radio button menu items
viewMenu.addSeparator();
//Group group = new ButtonGroup();
ObjectcbMenuItem = new JCheckBoxMenuItem("Object Name");
ObjectcbMenuItem.setSelected(true);
ObjectcbMenuItem.setMnemonic(KeyEvent.VK_O);
//group.add(cbMenuItem);
viewMenu.add(ObjectcbMenuItem);
ObjectmenuListener= new MenuListener();
ObjectcbMenuItem.addActionListener (ObjectmenuListener);
ObjectcbMenuItem.setState(false);
ObjectcbMenuItem.setActionCommand("ObjName");
RefNamecbMenuItem = new JCheckBoxMenuItem
("Reference Name");
RefNamecbMenuItem.setMnemonic(KeyEvent.VK_C);
//group.add(cbMenuItem);
viewMenu.add(RefNamecbMenuItem);
ReferencemenuListener= new MenuListener();
RefNamecbMenuItem.addActionListener
(ReferencemenuListener);
RefNamecbMenuItem.setActionCommand("RefName");
ClassIDcbMenuItem = new JCheckBoxMenuItem("Class ID");
ClassIDcbMenuItem.setMnemonic(KeyEvent.VK_C);
//group.add(cbMenuItem);
viewMenu.add(ClassIDcbMenuItem);
ClassIDmenuListener= new MenuListener();
ClassIDcbMenuItem.addActionListener (ClassIDmenuListener);
ClassIDcbMenuItem.setActionCommand("ClassID");
OwnercbMenuItem = new JCheckBoxMenuItem("Owner");
OwnercbMenuItem.setMnemonic(KeyEvent.VK_W);
//group.add(cbMenuItem);
viewMenu.add(OwnercbMenuItem);
OwnermenuListener= new MenuListener();
OwnercbMenuItem.addActionListener (OwnermenuListener);
OwnercbMenuItem.setActionCommand("Owner");
//Build the fourth menu.
helpMenu = new JMenu("Help");
helpMenu.setMnemonic(KeyEvent.VK_H);
menuBar.add(helpMenu);
//menuBar.setHelpMenu(menu);
menuListener= new MenuListener();
menuItem = new JMenuItem("About...", KeyEvent.VK_H);
helpMenu.add(menuItem);
menuListener= new MenuListener();
menuItem.addActionListener (menuListener);
menuItem.setActionCommand("help");
helpDialog = new JDialog(this, "Help");
helpDialog.setBackground(Color.gray);
helpDialog.setSize(250, 100);
// "text" of help dialog box
label = new JLabel("Version 1.0 "+
"Created by Keiyia Jackson");
helpDialog.getContentPane().add(label, "North");
// button to close help dialog box
button = new JButton("click when done reading");
helpDialog.getContentPane().add(button, "South");
closeListener = new CloseHelpListener();
button.addActionListener(closeListener);
for (int i=0;i<213 ;i++ )
{
tabledata = new Object [213][4];
tabledata[i][0] = new String(" ");
tabledata[i][1] = new String(" ");
tabledata[i][2] = new String(" ");
tabledata[i][3] = new String(" ");
}
defaultTable = new JTable(tabledata,
columnheaders);
tablePane = new JScrollPane(defaultTable,
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
defaultTable.setPreferredScrollableViewportSize
(new java.awt.Dimension(750, 950));
tablePopup = new TablePopup(defaultTable);
defaultTable.addMouseListener(new MouseAdapter()
{
public void mouseReleased (MouseEvent e)
{
if (e.isPopupTrigger())
tablePopup.show (e.getComponent(),
e.getX(), e.getY());
}
});
defaultTable.setVisible(true);
defaultTable.setSelectionMode
(ListSelectionModel.SINGLE_SELECTION);
if (ALLOW_ROW_SELECTION)
{
ListSelectionModel row =defaultTable.getSelectionModel();
row.addListSelectionListener(new ListSelectionListener()
{
public void valueChanged(ListSelectionEvent e)
{
//Ignore extra messages.
if (e.getValueIsAdjusting())
return;
lsm =(ListSelectionModel)e.getSource();
if (lsm.isSelectionEmpty())
{
output.append("No rows are selected.");
output.append("\n");
}
else
{
selectedRow = lsm.getMinSelectionIndex();
if (resultObjects!=null)
{
try
{
output.setText(SNReflection.print(resultObjects[selectedRow], false));
}
catch (Exception exc)
{
exc.printStackTrace();
System.out.print(exc);
output.setText("Unable to display object.");
}
}
else
output.setText("No data found");
}
}
});
}
else
{
defaultTable.setRowSelectionAllowed(false);
}
if (ALLOW_COLUMN_SELECTION)
{ // false by default
if (ALLOW_ROW_SELECTION)
{
//We allow both row and column selection, which
//implies that we *really* want to allow individual
//cell selection.
defaultTable.setCellSelectionEnabled(true);
}
defaultTable.setColumnSelectionAllowed(true);
ListSelectionModel colSM =
defaultTable.getColumnModel().getSelectionModel();
colSM.addListSelectionListener(new ListSelectionListener()
{
public void valueChanged(ListSelectionEvent e)
{
//Ignore extra messages.
if (e.getValueIsAdjusting())
return;
lsm = (ListSelectionModel)e.getSource();
if (lsm.isSelectionEmpty())
{
output.append("No columns are selected.");
//output.append(SNReflection.print("No columns are selected."));
output.append("\n");
}
else
{
int selectedCol = lsm.getMinSelectionIndex();
output.append("Column " + selectedCol
+ " is now selected.");
output.append("\n");
}
}
});
}
//Build output area.
output = new JTextArea (1,10);
output.setEditable(false);
JScrollPane outputPane = new JScrollPane(output,
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
//Do the layout.
JSplitPane splitPane = new JSplitPane
(JSplitPane.HORIZONTAL_SPLIT);
getContentPane().add(splitPane, BorderLayout.CENTER);
//left half
JPanel leftHalf = new JPanel();
leftHalf.setLayout(new BoxLayout
(leftHalf, BoxLayout.X_AXIS));
JPanel tableContainer = new JPanel(new GridLayout(1,1));
tableContainer.add(tablePane);
tablePane.setPreferredSize(new java.awt.Dimension(970, 235));
leftHalf.setBorder(BorderFactory.createEmptyBorder(5,5,0,5));
leftHalf.add(tableContainer);
leftHalf.add(tablePane, BorderLayout.CENTER);
leftHalf.setPreferredSize(new java.awt.Dimension(400,500 ));
splitPane.add(leftHalf);
//right half
JPanel rightHalf = new JPanel(new BorderLayout());
rightHalf.add(outputPane, BorderLayout.CENTER);
rightHalf.setPreferredSize(new java.awt.Dimension(450, 500));
splitPane.add(rightHalf);
//popup dialog for selected cell
/**********************
tableDialog = new JDialog(this, "Row" );
tableDialog.setBackground(Color.gray);
tableDialog.setSize(250, 100);
******************************/
// Find a server connection.
ConnectionObject connectionObject = null;
ConnectionManagement connectionMgr = new ConnectionManagement();
try
{
connectionMgr.initialize();
}
catch (Exception ex)
{
ex.printStackTrace();
System.out.println("Did not initialize");
}
connectionObject = connectionMgr.getDefaultConnection();
try
{
snapi = new SNAPI(userName, appName, connectionObject);
snquery = new SNQuery (snapi, connectionObject);
}
catch (Exception ex)
{
ex.printStackTrace();
System.out.println("Query was not submitted");
}
}
private class QueryListener implements ActionListener
{
public void actionPerformed (ActionEvent event)
{
String cmd=event.getActionCommand();
if (cmd.equals("new"))
{
String request = JOptionPane.showInputDialog
( null,"Query:");
if (request!=null)
{
System.out.println( "OK selected" );
try
{
objects = snquery.submitQuery(
classId,
queryString,
orderBy,
new Position(0.d, 0.d, 0.f, 0, 0, "I'm here"),
new Position(0.d, 0.d, 0.f, 0, 0, "No here"));
resultObjects=new SNBase[objects.length];
for (int i=0;i<objects.length ;i++ )>
{
resultObjects[i]=snapi.resolve((String)objects[i]);
}
//SNAPI.resolve(resultObjects);
}
catch (Exception ex)
{
ex.printStackTrace();
System.out.println ("Failed");
}
System.out.println("Ran submitQuery");
System.out.println("Length = " + resultObjects.length);
try
{
for (int i=0; i<resultObjects.length; i++)>
{
//System.out.println("index = " + i);
String name=resultObjects[i].objectName();
System.out.println( name);
tabledata[i][0] = resultObjects[i].objectName();
//tabledata[i][1] = ((IMMACCSObject)resultObjects[i]).referenceName();
tabledata[i][1] = new String ("refrenceName");
tabledata[i][2] = resultObjects[i].classId();
tabledata[i][3] = resultObjects[i].owner();
getContentPane().repaint();
//temp=i;
}
}
catch (Exception exc)
{
exc.printStackTrace();
System.out.println("Error filling in column values.");
}
}
else
System.out.println( "CANCEL selected" );
}
}
};
private class QueryListener implements ActionListener
{
public void actionPerformed (ActionEvent event)
{
String cmd=event.getActionCommand();
if (cmd.equals("new"))
{
String request = JOptionPane.showInputDialog
( null,"Query:");
if (request!=null)
{
System.out.println( "OK selected" );
try
{
objects = snquery.submitQuery(
classId,
queryString,
orderBy,
new Position(0.d, 0.d, 0.f, 0, 0, "I'm here"),
new Position(0.d, 0.d, 0.f, 0, 0, "No here"));
resultObjects=new SNBase[objects.length];
for (int i=0;i<objects.length ;i++ )>
{
resultObjects[i]=snapi.resolve((String)objects[i]);
}
//SNAPI.resolve(resultObjects);
}
catch (Exception ex)
{
ex.printStackTrace();
System.out.println ("Failed");
}
System.out.println("Ran submitQuery");
System.out.println("Length = " + resultObjects.length);
try
{
for (int i=0; i<resultObjects.length; i++)>
{
//System.out.println("index = " + i);
String name=resultObjects[i].objectName();
System.out.println( name);
tabledata[i][0] = resultObjects[i].objectName();
//tabledata[i][1] = ((IMMACCSObject)resultObjects[i]).referenceName();
tabledata[i][1] = new String ("refrenceName");
tabledata[i][2] = resultObjects[i].classId();
tabledata[i][3] = resultObjects[i].owner();
getContentPane().repaint();
//temp=i;
}
}
catch (Exception exc)
{
exc.printStackTrace();
System.out.println("Error filling in column values.");
}
}
else
System.out.println( "CANCEL selected" );
}
}
};
private class MenuListener implements ActionListener
{//b/g of menulistener
public void actionPerformed(ActionEvent event)
{//b/g of actionperformed
String cmd=event.getActionCommand();
// action command for this action
if (cmd.equals("exit"))
{
System.out.println ("Window Closing.");
System.exit(0);
}
if (cmd.equals("help"))
{
System.out.println ("Help.");
helpDialog.show();
}
/**************************
So far refresh just returns the default query
**************************/
if (cmd.equals("refresh"))
{
//System.out.println ("Refresh.");
//resubmit the query
try
{
objects = snquery.submitQuery(
classId,
queryString,
orderBy,
new Position(0.d, 0.d, 0.f, 0, 0, "I'm here"),
new Position(0.d, 0.d, 0.f, 0, 0, "No here"));
resultObjects=new SNBase[objects.length];
for (int i=0;i<objects.length ;i++ )>
{
resultObjects[i]=snapi.resolve((String)objects[i]);
}
}
catch (Exception ex)
{
ex.printStackTrace();
System.out.println ("Failed");
}
System.out.println("Ran resubmitQuery");
System.out.println("Length = " + resultObjects.length);
try
{
for (int i=0; i<resultObjects.length; i++)>
{
String name=resultObjects[i].objectName();
//System.out.println("Index = " + i);
System.out.println( name);
tabledata[i][0] = resultObjects[i].objectName();
//tabledata[i][1] = ((IMMACCSObject)resultObjects[i]).referenceName();
tabledata[i][1] = new String ("refrenceName");
tabledata[i][2] = resultObjects[i].classId();
tabledata[i][3] = resultObjects[i].owner();
getContentPane().repaint();
//defaultTable.newDataAvailable();
//defaultTable.newRowsAdded(null);
}
}
catch (Exception exc)
{
exc.printStackTrace();
System.out.println("Error filling in column values.");
}
System.out.println("refresh");
}
if (ObjectcbMenuItem.isSelected())
{
//System.out.println (ObjectcbMenuItem.getState());
TableColumn column0=null;
column0=defaultTable.getColumnModel().getColumn(0);
column0.setMaxWidth(500);
column0.setMinWidth(15);
column0.setPreferredWidth(500);
}
else
{
//System.out.println (ObjectcbMenuItem.getState());
TableColumn column0=null;
column0=defaultTable.getColumnModel().getColumn(0);
column0.setMaxWidth(0);
column0.setMinWidth(0);
column0.setPreferredWidth(0);
}
if (RefNamecbMenuItem.isSelected())
{
//System.out.println (RefNamecbMenuItem.getState());
TableColumn column1=null;
column1=defaultTable.getColumnModel().getColumn(1);
column1.setMaxWidth(500);
column1.setMinWidth(15);
column1.setPreferredWidth(500);
}
else
{
//System.out.println (RefNamecbMenuItem.getState());
TableColumn column1=null;
column1=defaultTable.getColumnModel().getColumn(1);
column1.setMaxWidth(0);
column1.setMinWidth(0);
column1.setPreferredWidth(0);
}
if (ClassIDcbMenuItem.isSelected())
{
//System.out.println (ClassIDcbMenuItem.getState());
TableColumn column2=null;
column2=defaultTable.getColumnModel().getColumn(2);
column2.setMaxWidth(500);
column2.setMinWidth(15);
column2.setPreferredWidth(500);
}
else
{
//System.out.println (ClassIDcbMenuItem.getState());
TableColumn column2=null;
column2=defaultTable.getColumnModel().getColumn(2);
column2.setMaxWidth(0);
column2.setMinWidth(0);
column2.setPreferredWidth(0);
}
if (OwnercbMenuItem.isSelected())
{
//System.out.println (OwnercbMenuItem.getState());
TableColumn column3=null;
column3=defaultTable.getColumnModel().getColumn(3);
column3.setMaxWidth(500);
column3.setMinWidth(15);
column3.setPreferredWidth(500);
}
else
{
//System.out.println (OwnercbMenuItem.getState());
TableColumn column3=null;
column3=defaultTable.getColumnModel().getColumn(3);
column3.setMaxWidth(0);
column3.setMinWidth(0);
column3.setPreferredWidth(0);
}
}//end of actionperformed
}//end of menulistener
//close the help box
private class CloseHelpListener implements ActionListener
{//b/g of CloseHelpListener
public void actionPerformed(ActionEvent event)
{
helpDialog.setVisible(false);
refreshDialog.setVisible (false);
tableDialog.setVisible(false);
}
}//end of CloseHelpListener
class TablePopup extends JPopupMenu
{//b/g of TablePopup
public TablePopup(JTable defaultTable)
{
JMenuItem listAttribute = new JMenuItem
("List Attributes");
listAttribute.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
System.out.println("List Attributes");
tableDialog.setVisible (true);
}
});
add(listAttribute);
add(new JSeparator());
}
} //end of TablePopup
}
[code]