git-svn-id: https://svn.code.sf.net/p/flaim/code/trunk@831 0109f412-320b-0410-ab79-c3e0c5ffbbe6
This commit is contained in:
7
xflaim/java/util/xedit/run.bat
Normal file
7
xflaim/java/util/xedit/run.bat
Normal file
@@ -0,0 +1,7 @@
|
||||
del xedit\*.class
|
||||
copy c:\work\openflaim\trunk\xflaim\build\win-x86-32\debug\java\xflaimjni.jar
|
||||
copy c:\work\openflaim\trunk\xflaim\build\win-x86-32\debug\lib\shared\xflaim.dll
|
||||
"c:\Program Files\Java\jdk1.5.0_06\bin\javac.exe" -g -classpath xflaimjni.jar;. xedit\*.java
|
||||
"c:\Program Files\Java\jdk1.5.0_06\bin\java.exe" -classpath xflaimjni.jar;. xedit.XEdit
|
||||
|
||||
:done
|
||||
49
xflaim/java/util/xedit/xedit/Attribute.java
Normal file
49
xflaim/java/util/xedit/xedit/Attribute.java
Normal file
@@ -0,0 +1,49 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Desc: Attributes
|
||||
//
|
||||
// Tabs: 3
|
||||
//
|
||||
// Copyright (c) 2004-2006 Novell, Inc. All Rights Reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of version 2 of the GNU General Public
|
||||
// License as published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, contact Novell, Inc.
|
||||
//
|
||||
// To contact Novell about this file by physical or electronic mail,
|
||||
// you may find current contact information at www.novell.com
|
||||
//
|
||||
// $Id: Attribute.java 3120 2006-01-19 13:41:12 -0700 (Thu, 19 Jan 2006) dsanders $
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
package xedit;
|
||||
import xflaim.*;
|
||||
|
||||
/**
|
||||
* To change the template for this generated type comment go to
|
||||
* Window->Preferences->Java->Code Generation->Code and Comments
|
||||
*/
|
||||
public class Attribute
|
||||
{
|
||||
Attribute(String sDesc, long lNodeId)
|
||||
{
|
||||
m_sDesc = sDesc;
|
||||
m_lNodeId = lNodeId;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return m_sDesc;
|
||||
}
|
||||
|
||||
String m_sDesc;
|
||||
long m_lNodeId;
|
||||
|
||||
}
|
||||
190
xflaim/java/util/xedit/xedit/AttributeSelector.java
Normal file
190
xflaim/java/util/xedit/xedit/AttributeSelector.java
Normal file
@@ -0,0 +1,190 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Desc: Attribute Selector
|
||||
//
|
||||
// Tabs: 3
|
||||
//
|
||||
// Copyright (c) 2004-2006 Novell, Inc. All Rights Reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of version 2 of the GNU General Public
|
||||
// License as published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, contact Novell, Inc.
|
||||
//
|
||||
// To contact Novell about this file by physical or electronic mail,
|
||||
// you may find current contact information at www.novell.com
|
||||
//
|
||||
// $Id: AttributeSelector.java 3120 2006-01-19 13:41:12 -0700 (Thu, 19 Jan 2006) dsanders $
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
package xedit;
|
||||
|
||||
import xflaim.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JDialog;
|
||||
|
||||
/**
|
||||
* To change the template for this generated type comment go to
|
||||
* Window->Preferences->Java->Code Generation->Code and Comments
|
||||
*/
|
||||
public class AttributeSelector extends JDialog implements ActionListener
|
||||
{
|
||||
|
||||
private JComboBox m_cbAttribute;
|
||||
private JButton m_btnOkay;
|
||||
private JButton m_btnCancel;
|
||||
private Attribute m_Attribute;
|
||||
|
||||
/**
|
||||
* @param owner
|
||||
* @throws java.awt.HeadlessException
|
||||
*/
|
||||
public AttributeSelector(
|
||||
Frame owner,
|
||||
DOMNode jRefNode,
|
||||
Attribute attribute)
|
||||
{
|
||||
super(owner, "Select Attribute", true);
|
||||
Container CP; // The content pane for this dialog
|
||||
GridBagLayout gridbag;
|
||||
GridBagConstraints constraints = new GridBagConstraints();
|
||||
Vector vAttributes;
|
||||
// Coordinates for location this window in the center of its parent.
|
||||
Point p;
|
||||
Dimension d;
|
||||
int x;
|
||||
int y;
|
||||
|
||||
setDefaultCloseOperation( DISPOSE_ON_CLOSE);
|
||||
CP = getContentPane();
|
||||
gridbag = new GridBagLayout();
|
||||
CP.setLayout( gridbag);
|
||||
|
||||
m_Attribute = attribute;
|
||||
|
||||
// Add the combobox.
|
||||
vAttributes = new Vector();
|
||||
|
||||
// Now get all of the attributes from the node
|
||||
try
|
||||
{
|
||||
boolean bFirst = true;
|
||||
DOMNode jAttr = null;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (bFirst)
|
||||
{
|
||||
bFirst = false;
|
||||
jAttr = jRefNode.getFirstAttribute(jAttr);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
jAttr = jAttr.getNextSibling(jAttr);
|
||||
}
|
||||
catch (XFlaimException ee)
|
||||
{
|
||||
if (ee.getRCode() == RCODE.NE_XFLM_DOM_NODE_NOT_FOUND)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Leave it for now.
|
||||
System.out.println(ee.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String sDesc = "<" + jAttr.getLocalName() + ">";
|
||||
long lNodeId = jAttr.getNodeId();
|
||||
vAttributes.add(new Attribute(sDesc, lNodeId));
|
||||
|
||||
}
|
||||
}
|
||||
catch (XFlaimException e)
|
||||
{
|
||||
// Leave it for now.
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
m_cbAttribute = new JComboBox( vAttributes);
|
||||
m_cbAttribute.setSelectedIndex(0);
|
||||
m_cbAttribute.addActionListener(this);
|
||||
|
||||
UITools.buildConstraints(constraints, 0, 0, 2, 1, 0, 0);
|
||||
|
||||
gridbag.setConstraints( m_cbAttribute, constraints);
|
||||
|
||||
CP.add( m_cbAttribute);
|
||||
|
||||
// Add the Okay button
|
||||
m_btnOkay = new JButton("Okay");
|
||||
m_btnOkay.setDefaultCapable(true);
|
||||
m_btnOkay.addActionListener(this);
|
||||
|
||||
UITools.buildConstraints(constraints, 0, 1, 1, 1, 60, 100);
|
||||
|
||||
gridbag.setConstraints( m_btnOkay, constraints);
|
||||
|
||||
CP.add( m_btnOkay);
|
||||
|
||||
// Add the Cancel button
|
||||
m_btnCancel = new JButton("Cancel");
|
||||
m_btnCancel.addActionListener(this);
|
||||
|
||||
UITools.buildConstraints(constraints, 1, 1, 1, 1, 40, 0);
|
||||
|
||||
gridbag.setConstraints( m_btnCancel, constraints);
|
||||
|
||||
CP.add( m_btnCancel);
|
||||
|
||||
setSize(200, 100);
|
||||
|
||||
p = owner.getLocationOnScreen();
|
||||
d = owner.getSize();
|
||||
x = (d.width - 200) / 2;
|
||||
y = (d.height - 100) / 2;
|
||||
setLocation(Math.max(0, p.x + x), Math.max(0, p.y + y));
|
||||
setVisible( true);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
||||
*/
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
Object obj = (Object)e.getSource();
|
||||
if (obj == m_cbAttribute || obj == m_btnOkay)
|
||||
{
|
||||
Attribute attr = (Attribute)m_cbAttribute.getSelectedItem();
|
||||
m_Attribute.m_lNodeId = attr.m_lNodeId;
|
||||
m_Attribute.m_sDesc = new String(attr.m_sDesc);
|
||||
if (obj == m_btnOkay)
|
||||
{
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Attribute.m_lNodeId = -1; // Make sure the caller knows we cancelled
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
49
xflaim/java/util/xedit/xedit/Collection.java
Normal file
49
xflaim/java/util/xedit/xedit/Collection.java
Normal file
@@ -0,0 +1,49 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Desc: Collections
|
||||
//
|
||||
// Tabs: 3
|
||||
//
|
||||
// Copyright (c) 2003,2005-2006 Novell, Inc. All Rights Reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of version 2 of the GNU General Public
|
||||
// License as published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, contact Novell, Inc.
|
||||
//
|
||||
// To contact Novell about this file by physical or electronic mail,
|
||||
// you may find current contact information at www.novell.com
|
||||
//
|
||||
// $Id: Collection.java 3120 2006-01-19 13:41:12 -0700 (Thu, 19 Jan 2006) dsanders $
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
package xedit;
|
||||
|
||||
/**
|
||||
* The Collection class defines a simple structure that can be used when selection
|
||||
* a collection. When instantiated, it is the object that is inserted into
|
||||
* the vector that is added to the combo Box, ultimatly displaying a drop-down list
|
||||
* of collections to choose from.
|
||||
*/
|
||||
public class Collection
|
||||
{
|
||||
Collection(String sName, int iNumber)
|
||||
{
|
||||
m_sName = sName;
|
||||
m_iNumber = iNumber;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return m_sName;
|
||||
}
|
||||
|
||||
public String m_sName;
|
||||
public int m_iNumber;
|
||||
}
|
||||
209
xflaim/java/util/xedit/xedit/CollectionSelector.java
Normal file
209
xflaim/java/util/xedit/xedit/CollectionSelector.java
Normal file
@@ -0,0 +1,209 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Desc: Collection Selector
|
||||
//
|
||||
// Tabs: 3
|
||||
//
|
||||
// Copyright (c) 2003-2006 Novell, Inc. All Rights Reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of version 2 of the GNU General Public
|
||||
// License as published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, contact Novell, Inc.
|
||||
//
|
||||
// To contact Novell about this file by physical or electronic mail,
|
||||
// you may find current contact information at www.novell.com
|
||||
//
|
||||
// $Id: CollectionSelector.java 3120 2006-01-19 13:41:12 -0700 (Thu, 19 Jan 2006) dsanders $
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
package xedit;
|
||||
|
||||
import xedit.*;
|
||||
import xflaim.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* The CollectionSelector is used to popup a dialog window that gives the
|
||||
* use a choice of collections to choose. The Collection parameter passed
|
||||
* into the constructor will be initialized to hold the collection the user
|
||||
* has chosen when this object exits. All of the work is done inthe constructor.
|
||||
* To use this class/object, simply create a new instance of it and check the
|
||||
* Collection object that was passed into the constructor.
|
||||
*/
|
||||
public class CollectionSelector extends JDialog implements ActionListener
|
||||
{
|
||||
private JComboBox m_cbCollection;
|
||||
private JButton m_btnOkay;
|
||||
private JButton m_btnCancel;
|
||||
private Collection m_Collection;
|
||||
|
||||
public CollectionSelector(
|
||||
Frame owner,
|
||||
DbSystem dbSystem,
|
||||
Db jDb,
|
||||
Collection collection)
|
||||
{
|
||||
super(owner, "Select Collection", true);
|
||||
|
||||
Container CP; // The content pane for this dialog
|
||||
GridBagLayout gridbag;
|
||||
GridBagConstraints constraints = new GridBagConstraints();
|
||||
Vector vCollections;
|
||||
DataVector SearchKey = null;
|
||||
DataVector FoundKey = null;
|
||||
// Coordinates for location this window in the center of its parent.
|
||||
Point p;
|
||||
Dimension d;
|
||||
int x;
|
||||
int y;
|
||||
|
||||
setDefaultCloseOperation( DISPOSE_ON_CLOSE);
|
||||
CP = getContentPane();
|
||||
gridbag = new GridBagLayout();
|
||||
CP.setLayout( gridbag);
|
||||
|
||||
m_Collection = collection;
|
||||
|
||||
// Add the combobox.
|
||||
vCollections = new Vector();
|
||||
vCollections.add(new Collection("Default Data ", xflaim.Collections.DATA));
|
||||
vCollections.add(new Collection("Dictionary ", xflaim.Collections.DICTIONARY));
|
||||
|
||||
// Now get all of the user defined collections from the database
|
||||
try
|
||||
{
|
||||
boolean bFirst = true;
|
||||
int iFlags;
|
||||
|
||||
SearchKey = dbSystem.createJDataVector();
|
||||
FoundKey = dbSystem.createJDataVector();
|
||||
|
||||
// Setup the search key.
|
||||
jDb.keyRetrieve(FlmDictIndex.NAME_INDEX,
|
||||
SearchKey,
|
||||
KeyRetrieveFlags.FO_FIRST,
|
||||
SearchKey);
|
||||
|
||||
SearchKey.setLong(0, ReserveID.ELM_COLLECTION_TAG);
|
||||
SearchKey.setString(1, "a");
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (bFirst)
|
||||
{
|
||||
bFirst = false;
|
||||
iFlags = KeyRetrieveFlags.FO_INCL;
|
||||
jDb.keyRetrieve(FlmDictIndex.NAME_INDEX, SearchKey, iFlags, FoundKey);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
iFlags = KeyRetrieveFlags.FO_EXCL;
|
||||
jDb.keyRetrieve(FlmDictIndex.NAME_INDEX, FoundKey, iFlags, FoundKey);
|
||||
|
||||
}
|
||||
|
||||
if (FoundKey == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (FoundKey.getLong(0) != ReserveID.ELM_COLLECTION_TAG)
|
||||
{
|
||||
break;
|
||||
}
|
||||
String sName = FoundKey.getString(1);
|
||||
int iNumber = (int)FoundKey.getLong(3);
|
||||
vCollections.add(new Collection(sName, iNumber));
|
||||
|
||||
}
|
||||
}
|
||||
catch (XFlaimException e)
|
||||
{
|
||||
// Leave it for now.
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
m_cbCollection = new JComboBox( vCollections);
|
||||
m_cbCollection.setSelectedIndex(0);
|
||||
m_cbCollection.addActionListener(this);
|
||||
|
||||
UITools.buildConstraints(constraints, 0, 0, 2, 1, 0, 0);
|
||||
|
||||
gridbag.setConstraints( m_cbCollection, constraints);
|
||||
|
||||
CP.add( m_cbCollection);
|
||||
|
||||
// Add the Okay button
|
||||
m_btnOkay = new JButton("Okay");
|
||||
m_btnOkay.setDefaultCapable(true);
|
||||
m_btnOkay.addActionListener(this);
|
||||
|
||||
UITools.buildConstraints(constraints, 0, 1, 1, 1, 60, 100);
|
||||
|
||||
gridbag.setConstraints( m_btnOkay, constraints);
|
||||
|
||||
CP.add( m_btnOkay);
|
||||
|
||||
// Add the Cancel button
|
||||
m_btnCancel = new JButton("Cancel");
|
||||
m_btnCancel.addActionListener(this);
|
||||
|
||||
UITools.buildConstraints(constraints, 1, 1, 1, 1, 40, 0);
|
||||
|
||||
gridbag.setConstraints( m_btnCancel, constraints);
|
||||
|
||||
CP.add( m_btnCancel);
|
||||
|
||||
setSize(200, 100);
|
||||
|
||||
p = owner.getLocationOnScreen();
|
||||
d = owner.getSize();
|
||||
x = (d.width - 200) / 2;
|
||||
y = (d.height - 100) / 2;
|
||||
setLocation(Math.max(0, p.x + x), Math.max(0, p.y + y));
|
||||
setVisible( true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
||||
*/
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
Object obj = (Object)e.getSource();
|
||||
if (obj == m_cbCollection || obj == m_btnOkay)
|
||||
{
|
||||
Collection coll = (Collection)m_cbCollection.getSelectedItem();
|
||||
m_Collection.m_iNumber = coll.m_iNumber;
|
||||
m_Collection.m_sName = new String(coll.m_sName);
|
||||
if (obj == m_btnOkay)
|
||||
{
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
81
xflaim/java/util/xedit/xedit/Document.java
Normal file
81
xflaim/java/util/xedit/xedit/Document.java
Normal file
@@ -0,0 +1,81 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Desc: Documents
|
||||
//
|
||||
// Tabs: 3
|
||||
//
|
||||
// Copyright (c) 2003,2005-2006 Novell, Inc. All Rights Reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of version 2 of the GNU General Public
|
||||
// License as published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, contact Novell, Inc.
|
||||
//
|
||||
// To contact Novell about this file by physical or electronic mail,
|
||||
// you may find current contact information at www.novell.com
|
||||
//
|
||||
// $Id: Document.java 3120 2006-01-19 13:41:12 -0700 (Thu, 19 Jan 2006) dsanders $
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
package xedit;
|
||||
|
||||
/**
|
||||
* The Document class represents a simple structure to hold essential details
|
||||
* about each document that is opened in XEdit. This class overrides the
|
||||
* equality testing method used by Vectors to test if one object is
|
||||
* equivalent to another. Instances of this class are stored in a vector
|
||||
* during program execution. The Vector.indexOf method is used to
|
||||
* locate the index of the Document in the vector.
|
||||
*/
|
||||
public class Document
|
||||
{
|
||||
public long m_lDocId;
|
||||
public int m_iCollection;
|
||||
public String m_sName;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public Document(
|
||||
String sName,
|
||||
long lDocId,
|
||||
int iCollection)
|
||||
{
|
||||
m_sName = sName;
|
||||
m_lDocId = lDocId;
|
||||
m_iCollection = iCollection;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return m_sName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the Object.equals(Object) method to compare
|
||||
* two Document objects for equivalence. They need not be the
|
||||
* same object, they just have to be internally identical.
|
||||
*/
|
||||
public boolean equals(Object doc)
|
||||
{
|
||||
Document d = (Document)doc;
|
||||
|
||||
if (m_lDocId == d.m_lDocId)
|
||||
{
|
||||
if (m_iCollection == d.m_iCollection)
|
||||
{
|
||||
if (m_sName.equals(d.m_sName))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
181
xflaim/java/util/xedit/xedit/DocumentSelector.java
Normal file
181
xflaim/java/util/xedit/xedit/DocumentSelector.java
Normal file
@@ -0,0 +1,181 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Desc: Document Selector
|
||||
//
|
||||
// Tabs: 3
|
||||
//
|
||||
// Copyright (c) 2003,2005-2006 Novell, Inc. All Rights Reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of version 2 of the GNU General Public
|
||||
// License as published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, contact Novell, Inc.
|
||||
//
|
||||
// To contact Novell about this file by physical or electronic mail,
|
||||
// you may find current contact information at www.novell.com
|
||||
//
|
||||
// $Id: DocumentSelector.java 3120 2006-01-19 13:41:12 -0700 (Thu, 19 Jan 2006) dsanders $
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
package xedit;
|
||||
|
||||
import xedit.*;
|
||||
import xflaim.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.Vector;
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* The DocumentSelector class provides a means of presenting a list of
|
||||
* documents in the database to the user. It will popup a window with a list
|
||||
* of documents, showing their root element.
|
||||
*/
|
||||
public class DocumentSelector extends JDialog implements ActionListener
|
||||
{
|
||||
|
||||
private JList m_lstList;
|
||||
private JButton m_btnOkay;
|
||||
private JButton m_btnCancel;
|
||||
private Document m_Document;
|
||||
|
||||
public DocumentSelector(
|
||||
Frame owner,
|
||||
Db jDb,
|
||||
int iCollection,
|
||||
Document document)
|
||||
{
|
||||
super(owner, "Select Document", true);
|
||||
|
||||
Container CP; // The content pane for this dialog
|
||||
GridBagLayout gridbag;
|
||||
GridBagConstraints constraints = new GridBagConstraints();
|
||||
Vector vDocuments;
|
||||
int iLength = 0;
|
||||
|
||||
// Coordinates for locating this window in the center of its parent.
|
||||
Point p;
|
||||
Dimension d;
|
||||
int x;
|
||||
int y;
|
||||
boolean bFirst = true;
|
||||
DOMNode jDoc = null;
|
||||
|
||||
setDefaultCloseOperation( DISPOSE_ON_CLOSE);
|
||||
CP = getContentPane();
|
||||
gridbag = new GridBagLayout();
|
||||
CP.setLayout( gridbag);
|
||||
|
||||
m_Document = document;
|
||||
|
||||
// Add the combobox.
|
||||
vDocuments = new Vector();
|
||||
// Get the list of documents
|
||||
for (;;)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (bFirst)
|
||||
{
|
||||
jDoc = jDb.getFirstDocument(iCollection, null);
|
||||
bFirst = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
jDoc = jDoc.getNextDocument(jDoc);
|
||||
}
|
||||
String sName = new String("<" + jDoc.getLocalName() + ">");
|
||||
long lDocId = jDoc.getNodeId();
|
||||
vDocuments.add(new Document(sName, lDocId, iCollection));
|
||||
if (sName.length() > iLength)
|
||||
{
|
||||
iLength = sName.length();
|
||||
}
|
||||
}
|
||||
catch (XFlaimException e)
|
||||
{
|
||||
if (e.getRCode() == RCODE.NE_XFLM_DOM_NODE_NOT_FOUND ||
|
||||
e.getRCode() == RCODE.NE_XFLM_NOT_FOUND)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_lstList = new JList( vDocuments);
|
||||
m_lstList.setSelectedIndex(0);
|
||||
//m_lstList.addActionListener(this);
|
||||
JScrollPane scrollPane = new JScrollPane();
|
||||
scrollPane.getViewport().setView(m_lstList);
|
||||
|
||||
UITools.buildConstraints(constraints, 0, 0, 2, 4, 100, 100);
|
||||
constraints.anchor = GridBagConstraints.NORTHWEST;
|
||||
constraints.fill = GridBagConstraints.BOTH;
|
||||
|
||||
gridbag.setConstraints( scrollPane, constraints);
|
||||
|
||||
CP.add( scrollPane);
|
||||
|
||||
// Add the Okay button
|
||||
m_btnOkay = new JButton("Okay");
|
||||
m_btnOkay.setDefaultCapable(true);
|
||||
m_btnOkay.addActionListener(this);
|
||||
|
||||
UITools.buildConstraints(constraints, 0, 5, 1, 1, 90, 100);
|
||||
constraints.anchor = GridBagConstraints.EAST;
|
||||
constraints.fill = GridBagConstraints.NONE;
|
||||
|
||||
gridbag.setConstraints( m_btnOkay, constraints);
|
||||
|
||||
CP.add( m_btnOkay);
|
||||
|
||||
// Add the Cancel button
|
||||
m_btnCancel = new JButton("Cancel");
|
||||
m_btnCancel.addActionListener(this);
|
||||
|
||||
UITools.buildConstraints(constraints, 1, 5, 1, 1, 10, 0);
|
||||
constraints.anchor = GridBagConstraints.WEST;
|
||||
|
||||
gridbag.setConstraints( m_btnCancel, constraints);
|
||||
|
||||
CP.add( m_btnCancel);
|
||||
|
||||
setSize(Math.max( iLength, 200), 200);
|
||||
|
||||
p = owner.getLocationOnScreen();
|
||||
d = owner.getSize();
|
||||
x = (d.width - Math.max( iLength, 200)) / 2;
|
||||
y = (d.height - 200) / 2;
|
||||
setLocation(Math.max(0, p.x + x), Math.max(0, p.y + y));
|
||||
setVisible( true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
||||
*/
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
Object obj = (Object)e.getSource();
|
||||
if (obj == m_btnOkay)
|
||||
{
|
||||
Document doc = (Document)m_lstList.getSelectedValue();
|
||||
m_Document.m_lDocId = doc.m_lDocId;
|
||||
m_Document.m_sName = new String(doc.m_sName);
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
143
xflaim/java/util/xedit/xedit/EditValueDialog.java
Normal file
143
xflaim/java/util/xedit/xedit/EditValueDialog.java
Normal file
@@ -0,0 +1,143 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Desc: Edit Value Dialog
|
||||
//
|
||||
// Tabs: 3
|
||||
//
|
||||
// Copyright (c) 2004-2006 Novell, Inc. All Rights Reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of version 2 of the GNU General Public
|
||||
// License as published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, contact Novell, Inc.
|
||||
//
|
||||
// To contact Novell about this file by physical or electronic mail,
|
||||
// you may find current contact information at www.novell.com
|
||||
//
|
||||
// $Id: EditValueDialog.java 3120 2006-01-19 13:41:12 -0700 (Thu, 19 Jan 2006) dsanders $
|
||||
//------------------------------------------------------------------------------
|
||||
package xedit;
|
||||
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Frame;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
/**
|
||||
* To change the template for this generated type comment go to
|
||||
* Window->Preferences->Java->Code Generation->Code and Comments
|
||||
*/
|
||||
public class EditValueDialog extends JDialog implements ActionListener
|
||||
{
|
||||
private JButton m_btnOkay;
|
||||
private JButton m_btnCancel;
|
||||
private JTextField m_textField;
|
||||
private NodeValue m_NodeValue;
|
||||
|
||||
/**
|
||||
* A class for editing the value of a DOM Node. All values aer treated as strings.
|
||||
* @param owner
|
||||
* @param sValue
|
||||
*/
|
||||
public EditValueDialog(
|
||||
String sTitle,
|
||||
Frame owner,
|
||||
NodeValue NodeValue)
|
||||
{
|
||||
super(owner, sTitle, true);
|
||||
|
||||
m_NodeValue = NodeValue;
|
||||
|
||||
Container CP; // The content pane for this dialog
|
||||
GridBagLayout gridbag;
|
||||
GridBagConstraints constraints = new GridBagConstraints();
|
||||
// Coordinates for location this window in the center of its parent.
|
||||
Point p;
|
||||
Dimension d;
|
||||
int x;
|
||||
int y;
|
||||
|
||||
setDefaultCloseOperation( DISPOSE_ON_CLOSE);
|
||||
CP = getContentPane();
|
||||
gridbag = new GridBagLayout();
|
||||
CP.setLayout( gridbag);
|
||||
|
||||
m_textField = new JTextField(NodeValue.getValue());
|
||||
m_textField.setEditable(true);
|
||||
JScrollPane sp = new JScrollPane(m_textField);
|
||||
|
||||
UITools.buildConstraints(constraints, 0, 0, 3, 1, 100, 100);
|
||||
constraints.anchor = GridBagConstraints.NORTHWEST;
|
||||
constraints.fill = GridBagConstraints.BOTH;
|
||||
gridbag.setConstraints( sp, constraints);
|
||||
|
||||
CP.add( sp);
|
||||
|
||||
|
||||
// Add the Okay button
|
||||
m_btnOkay = new JButton("Okay");
|
||||
m_btnOkay.setDefaultCapable(true);
|
||||
m_btnOkay.addActionListener(this);
|
||||
|
||||
UITools.buildConstraints(constraints, 1, 1, 1, 1, 60, 100);
|
||||
constraints.anchor = GridBagConstraints.CENTER;
|
||||
constraints.fill = GridBagConstraints.NONE;
|
||||
gridbag.setConstraints( m_btnOkay, constraints);
|
||||
|
||||
CP.add( m_btnOkay);
|
||||
|
||||
// Add the Cancel button
|
||||
m_btnCancel = new JButton("Cancel");
|
||||
m_btnCancel.addActionListener(this);
|
||||
|
||||
UITools.buildConstraints(constraints, 2, 1, 1, 1, 40, 0);
|
||||
|
||||
gridbag.setConstraints( m_btnCancel, constraints);
|
||||
|
||||
CP.add( m_btnCancel);
|
||||
|
||||
setSize(200, 100);
|
||||
|
||||
p = owner.getLocationOnScreen();
|
||||
d = owner.getSize();
|
||||
x = (d.width - 200) / 2;
|
||||
y = (d.height - 100) / 2;
|
||||
setLocation(Math.max(0, p.x + x), Math.max(0, p.y + y));
|
||||
setVisible( true);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
||||
*/
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
Object obj = (Object)e.getSource();
|
||||
if (obj == m_btnOkay)
|
||||
{
|
||||
m_NodeValue.setValue(m_textField.getText());
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
206
xflaim/java/util/xedit/xedit/FileImporter.java
Normal file
206
xflaim/java/util/xedit/xedit/FileImporter.java
Normal file
@@ -0,0 +1,206 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Desc: File Importer
|
||||
//
|
||||
// Tabs: 3
|
||||
//
|
||||
// Copyright (c) 2003,2005-2006 Novell, Inc. All Rights Reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of version 2 of the GNU General Public
|
||||
// License as published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, contact Novell, Inc.
|
||||
//
|
||||
// To contact Novell about this file by physical or electronic mail,
|
||||
// you may find current contact information at www.novell.com
|
||||
//
|
||||
// $Id: FileImporter.java 3120 2006-01-19 13:41:12 -0700 (Thu, 19 Jan 2006) dsanders $
|
||||
//------------------------------------------------------------------------------
|
||||
package xedit;
|
||||
|
||||
import xedit.*;
|
||||
import xflaim.*;
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* The FileImporter runs in a separate thre so that it does not block the main
|
||||
* XEdit thread while it imports documents into the database.
|
||||
*/
|
||||
public class FileImporter extends Thread
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public FileImporter(
|
||||
Frame owner,
|
||||
DbSystem dbSystem,
|
||||
String sDbName,
|
||||
int iCollection,
|
||||
String sFilename,
|
||||
String sDirectory,
|
||||
String [] sList) throws XFlaimException
|
||||
{
|
||||
super();
|
||||
m_iCollection = iCollection;
|
||||
m_sFilename = sFilename;
|
||||
m_sDirectory = sDirectory;
|
||||
m_sList = sList;
|
||||
m_dbSystem = dbSystem;
|
||||
m_owner = owner;
|
||||
|
||||
// Open our own copy of the database.
|
||||
m_jDb = dbSystem.dbOpen( sDbName, null, null, null, true);
|
||||
}
|
||||
|
||||
// Need to close the database we when we are done.
|
||||
public void finalize()
|
||||
{
|
||||
m_jDb.close();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
public void run()
|
||||
{
|
||||
countFiles( m_sFilename,
|
||||
m_sDirectory,
|
||||
m_sList);
|
||||
|
||||
m_box = new ProgressBox(m_owner, 500, 160, "Preparing to import files", "Filename:", 0, m_iFileCount);
|
||||
|
||||
importFile( m_iCollection,
|
||||
m_sFilename,
|
||||
m_sDirectory,
|
||||
m_sList);
|
||||
|
||||
}
|
||||
|
||||
/*=========================================================================
|
||||
* Desc: Method to iterate through a possible list of files and import every file in the directory.
|
||||
*========================================================================*/
|
||||
private void importFile(
|
||||
int iCollection,
|
||||
String sFilename,
|
||||
String sDirectory,
|
||||
String [] sList)
|
||||
{
|
||||
boolean bTransBegun = false;
|
||||
IStream jIStream = null;
|
||||
|
||||
if (m_box.Cancelled())
|
||||
{
|
||||
m_box.terminate();
|
||||
return;
|
||||
}
|
||||
|
||||
// A null sList indicates that we are looking at a file, so we can import it directly.
|
||||
if (sList == null)
|
||||
{
|
||||
m_iCurrentFile++;
|
||||
m_box.setLabel1("Importing file " + m_iCurrentFile + " of " + m_iFileCount);
|
||||
m_box.setLabel2("Filename: " + sFilename);
|
||||
|
||||
try
|
||||
{
|
||||
jIStream = m_dbSystem.openFileIStream(sFilename);
|
||||
m_jDb.transBegin(TransactionType.UPDATE_TRANS, 0, 0);
|
||||
bTransBegun = true;
|
||||
m_jDb.Import(jIStream, iCollection);
|
||||
m_jDb.transCommit();
|
||||
bTransBegun = false;
|
||||
}
|
||||
catch (XFlaimException e)
|
||||
{
|
||||
// Abort the transaction, then throw the exception up further.
|
||||
if (bTransBegun)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_jDb.transAbort();
|
||||
}
|
||||
catch (XFlaimException ex)
|
||||
{
|
||||
JOptionPane.showMessageDialog(null, "Exception occurred in import thread: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
JOptionPane.showMessageDialog(null, "Exception occurred in import thread: " + e.getMessage());
|
||||
}
|
||||
m_box.updateProgress(m_iCurrentFile);
|
||||
}
|
||||
// Otherwise we need to find the first file. If we come across a directory, we need to search it too.
|
||||
else
|
||||
{
|
||||
for (int iLoop = 0; iLoop < sList.length; iLoop++)
|
||||
{
|
||||
File f = new File(sFilename, sList[iLoop]);
|
||||
if (f.isDirectory())
|
||||
{
|
||||
importFile( iCollection,
|
||||
new String(f.getPath()),
|
||||
new String(f.getAbsolutePath()),
|
||||
f.list());
|
||||
}
|
||||
else
|
||||
{
|
||||
importFile( iCollection,
|
||||
new String(f.getPath()),
|
||||
sDirectory,
|
||||
null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void countFiles(
|
||||
String sFilename,
|
||||
String sDirectory,
|
||||
String [] sList)
|
||||
{
|
||||
if (sList == null)
|
||||
{
|
||||
m_iFileCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int iLoop = 0; iLoop < sList.length; iLoop++)
|
||||
{
|
||||
File f = new File(sFilename, sList[iLoop]);
|
||||
if (f.isDirectory())
|
||||
{
|
||||
countFiles( new String(f.getPath()),
|
||||
new String(f.getAbsolutePath()),
|
||||
f.list());
|
||||
}
|
||||
else
|
||||
{
|
||||
countFiles( new String(f.getPath()),
|
||||
sDirectory,
|
||||
null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------- Private members -----------------------------------*/
|
||||
private int m_iCollection;
|
||||
private String m_sFilename;
|
||||
private String m_sDirectory;
|
||||
private String [] m_sList;
|
||||
private DbSystem m_dbSystem;
|
||||
private Db m_jDb;
|
||||
private ProgressBox m_box;
|
||||
private int m_iFileCount = 0;
|
||||
private int m_iCurrentFile = 0;
|
||||
private Frame m_owner;
|
||||
}
|
||||
819
xflaim/java/util/xedit/xedit/NodeDialog.java
Normal file
819
xflaim/java/util/xedit/xedit/NodeDialog.java
Normal file
@@ -0,0 +1,819 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Desc: Node Dialog
|
||||
//
|
||||
// Tabs: 3
|
||||
//
|
||||
// Copyright (c) 2003-2006 Novell, Inc. All Rights Reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of version 2 of the GNU General Public
|
||||
// License as published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, contact Novell, Inc.
|
||||
//
|
||||
// To contact Novell about this file by physical or electronic mail,
|
||||
// you may find current contact information at www.novell.com
|
||||
//
|
||||
// $Id: NodeDialog.java 3120 2006-01-19 13:41:12 -0700 (Thu, 19 Jan 2006) dsanders $
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
package xedit;
|
||||
|
||||
import xflaim.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.*;
|
||||
import java.awt.*;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* To change the template for this generated type comment go to
|
||||
* Window->Preferences->Java->Code Generation->Code and Comments
|
||||
*/
|
||||
public class NodeDialog extends JDialog implements Runnable, ActionListener, ListSelectionListener, KeyListener
|
||||
{
|
||||
private XEdit m_owner;
|
||||
private DbSystem m_dbSystem;
|
||||
private Db m_jDb;
|
||||
private GridBagConstraints m_gbc;
|
||||
private GridBagLayout m_gbl;
|
||||
private long m_lNodeId;
|
||||
private JList m_NodeTypeList;
|
||||
private JList m_NodeTagList;
|
||||
private JRadioButton m_btnNewDocument;
|
||||
private JRadioButton m_btnNewSibling;
|
||||
private JRadioButton m_btnNewChild;
|
||||
private JRadioButton m_btnAnnotation;
|
||||
private final String m_sNewDocument = "New Document";
|
||||
private final String m_sNewSibling = "New Sibling";
|
||||
private final String m_sNewChild = "New Child";
|
||||
private final String m_sAnnotation = "Annotation";
|
||||
private JButton m_btnCancel;
|
||||
private JButton m_btnAdd;
|
||||
private JButton m_btnDone;
|
||||
private JTextField m_textField;
|
||||
private JLabel m_nodeTagLabel;
|
||||
private JScrollPane m_scrollPane;
|
||||
private int m_iCollection;
|
||||
private boolean m_bTypeSelected = false;
|
||||
private boolean m_bTagRequired = false;
|
||||
private boolean m_bTagSelected = false;
|
||||
private boolean m_bValueRequired = false;
|
||||
private boolean m_bValueEntered = false;
|
||||
|
||||
|
||||
/**
|
||||
* @param owner
|
||||
* @throws java.awt.HeadlessException
|
||||
*/
|
||||
public NodeDialog(
|
||||
XEdit owner,
|
||||
DbSystem dbSystem,
|
||||
String sDbFileName,
|
||||
long lNodeId,
|
||||
int iCollection) throws XFlaimException
|
||||
{
|
||||
super(owner, "XFLaim Node Dialog", true);
|
||||
|
||||
m_owner = owner;
|
||||
m_dbSystem = dbSystem;
|
||||
m_lNodeId = lNodeId;
|
||||
m_iCollection = iCollection;
|
||||
|
||||
// Open the database so we can have independant access
|
||||
m_jDb = m_dbSystem.dbOpen( sDbFileName, null, null, null, true);
|
||||
|
||||
m_gbl = new GridBagLayout();
|
||||
m_gbc = new GridBagConstraints();
|
||||
m_gbc.insets = new Insets(3, 6, 3, 6);
|
||||
|
||||
setDefaultCloseOperation( DISPOSE_ON_CLOSE);
|
||||
Container CP = getContentPane();
|
||||
CP.setLayout( m_gbl);
|
||||
|
||||
// Select Node Type label
|
||||
JLabel lbl1 = new JLabel("Select Node Type");
|
||||
UITools.buildConstraints(m_gbc, 0, 0, 2, 1, 0, 0);
|
||||
m_gbc.anchor = GridBagConstraints.NORTHWEST;
|
||||
m_gbl.addLayoutComponent(lbl1, m_gbc);
|
||||
CP.add(lbl1);
|
||||
|
||||
// Select Node Tag
|
||||
m_nodeTagLabel = new JLabel("Select Node Tag");
|
||||
m_nodeTagLabel.setVisible(false);
|
||||
UITools.buildConstraints(m_gbc, 3, 0, 2, 1, 0, 0);
|
||||
m_gbc.anchor = GridBagConstraints.NORTHWEST;
|
||||
m_gbl.addLayoutComponent(m_nodeTagLabel, m_gbc);
|
||||
CP.add(m_nodeTagLabel);
|
||||
|
||||
// Select Node Type list box
|
||||
Vector vNodeList = new Vector();
|
||||
buildNodeTypeList(vNodeList);
|
||||
m_NodeTypeList = new JList(vNodeList);
|
||||
m_NodeTypeList.addListSelectionListener(this);
|
||||
JScrollPane sp = new JScrollPane(m_NodeTypeList);
|
||||
UITools.buildConstraints(m_gbc, 0, 1, 2, 1, 0, 0);
|
||||
m_gbc.anchor = GridBagConstraints.WEST;
|
||||
m_gbl.addLayoutComponent(sp, m_gbc);
|
||||
CP.add(sp);
|
||||
|
||||
// Select Node Tag list box
|
||||
m_NodeTagList = new JList();
|
||||
m_NodeTagList.setEnabled(false); // Will be enabled later when a valid type is selected.
|
||||
m_NodeTagList.setVisible(false);
|
||||
m_NodeTagList.addListSelectionListener(this);
|
||||
m_scrollPane = new JScrollPane(m_NodeTagList);
|
||||
UITools.buildConstraints(m_gbc, 3, 1, 2, 1, 0, 0);
|
||||
m_gbc.anchor = GridBagConstraints.WEST;
|
||||
m_gbc.fill = GridBagConstraints.BOTH;
|
||||
m_gbl.addLayoutComponent(m_scrollPane, m_gbc);
|
||||
m_scrollPane.setVisible(false);
|
||||
CP.add(m_scrollPane);
|
||||
|
||||
// Radio Button - New Document
|
||||
m_btnNewDocument = new JRadioButton(m_sNewDocument);
|
||||
m_btnNewDocument.setActionCommand(m_sNewDocument);
|
||||
m_btnNewDocument.setSelected(m_lNodeId > 0 ? false : true);
|
||||
UITools.buildConstraints(m_gbc, 0, 2, 1, 1, 0, 0);
|
||||
m_gbc.anchor = GridBagConstraints.WEST;
|
||||
m_gbc.fill = GridBagConstraints.NONE;
|
||||
m_gbl.addLayoutComponent(m_btnNewDocument, m_gbc);
|
||||
CP.add(m_btnNewDocument);
|
||||
|
||||
// Radio button - New Sibling
|
||||
m_btnNewSibling = new JRadioButton(m_sNewSibling);
|
||||
m_btnNewSibling.setActionCommand(m_sNewSibling);
|
||||
m_btnNewSibling.setSelected(m_lNodeId > 0 ? true : false);
|
||||
if (m_lNodeId == 0)
|
||||
{
|
||||
m_btnNewSibling.setEnabled(false);
|
||||
}
|
||||
UITools.buildConstraints(m_gbc, 0, 3, 1, 1, 0, 0);
|
||||
m_gbc.anchor = GridBagConstraints.WEST;
|
||||
m_gbl.addLayoutComponent(m_btnNewSibling, m_gbc);
|
||||
CP.add(m_btnNewSibling);
|
||||
|
||||
// Radio Button - New Child
|
||||
m_btnNewChild = new JRadioButton(m_sNewChild);
|
||||
m_btnNewChild.setActionCommand(m_sNewChild);
|
||||
m_btnNewChild.setSelected(false);
|
||||
if (m_lNodeId == 0)
|
||||
{
|
||||
m_btnNewChild.setEnabled(false);
|
||||
}
|
||||
UITools.buildConstraints(m_gbc, 0, 4, 1, 1, 0, 0);
|
||||
m_gbc.anchor = GridBagConstraints.WEST;
|
||||
m_gbl.addLayoutComponent(m_btnNewChild, m_gbc);
|
||||
CP.add(m_btnNewChild);
|
||||
|
||||
// Radio Button - Annotation
|
||||
m_btnAnnotation = new JRadioButton(m_sAnnotation);
|
||||
m_btnAnnotation.setActionCommand(m_sAnnotation);
|
||||
m_btnAnnotation.setSelected(false);
|
||||
if (m_lNodeId == 0)
|
||||
{
|
||||
m_btnAnnotation.setEnabled(false);
|
||||
}
|
||||
UITools.buildConstraints(m_gbc, 0, 5, 1, 1, 0, 0);
|
||||
m_gbc.anchor = GridBagConstraints.WEST;
|
||||
m_gbl.addLayoutComponent(m_btnAnnotation, m_gbc);
|
||||
CP.add(m_btnAnnotation);
|
||||
|
||||
// Group the Radio Buttons
|
||||
ButtonGroup btnGroup = new ButtonGroup();
|
||||
btnGroup.add(m_btnNewDocument);
|
||||
btnGroup.add(m_btnNewSibling);
|
||||
btnGroup.add(m_btnNewChild);
|
||||
btnGroup.add(m_btnAnnotation);
|
||||
|
||||
// Enter new value
|
||||
JLabel lbl3 = new JLabel("Enter new value");
|
||||
UITools.buildConstraints(m_gbc, 0, 6, 2, 1, 0, 0);
|
||||
m_gbc.anchor = GridBagConstraints.WEST;
|
||||
m_gbl.addLayoutComponent(lbl3, m_gbc);
|
||||
CP.add(lbl3);
|
||||
|
||||
// Text box to hold the new value
|
||||
m_textField = new JTextField();
|
||||
m_textField.setEditable(true);
|
||||
m_textField.addActionListener(this);
|
||||
m_textField.setActionCommand("Value");
|
||||
m_textField.addKeyListener(this);
|
||||
UITools.buildConstraints(m_gbc, 0, 7, 5, 1, 0, 0);
|
||||
m_gbc.anchor = GridBagConstraints.WEST;
|
||||
m_gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||
m_gbl.addLayoutComponent(m_textField, m_gbc);
|
||||
CP.add(m_textField);
|
||||
|
||||
|
||||
// Cancel button
|
||||
m_btnCancel = new JButton("Cancel");
|
||||
m_btnCancel.setActionCommand("Cancel");
|
||||
m_btnCancel.addActionListener(this);
|
||||
UITools.buildConstraints(m_gbc, 2, 8, 1, 1, 0, 0);
|
||||
m_gbl.addLayoutComponent(m_btnCancel, m_gbc);
|
||||
CP.add(m_btnCancel);
|
||||
|
||||
// Add button
|
||||
m_btnAdd = new JButton("Add");
|
||||
m_btnAdd.setActionCommand("Add");
|
||||
m_btnAdd.addActionListener(this);
|
||||
m_btnAdd.setEnabled(false);
|
||||
UITools.buildConstraints(m_gbc, 3, 8, 1, 1, 0, 0);
|
||||
m_gbl.addLayoutComponent(m_btnAdd, m_gbc);
|
||||
CP.add(m_btnAdd);
|
||||
|
||||
// Done button
|
||||
m_btnDone = new JButton("Done");
|
||||
m_btnDone.setActionCommand("Done");
|
||||
m_btnDone.addActionListener(this);
|
||||
m_btnDone.setEnabled(false);
|
||||
UITools.buildConstraints(m_gbc, 4, 8, 1, 1, 0, 0);
|
||||
m_gbl.addLayoutComponent(m_btnDone, m_gbc);
|
||||
CP.add(m_btnDone);
|
||||
|
||||
this.pack();
|
||||
this.setResizable(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param m_NodeTypeList
|
||||
*/
|
||||
private void buildNodeTypeList(Vector vNodeList)
|
||||
{
|
||||
vNodeList.clear();
|
||||
vNodeList.add(new NodeType("Annotation", FlmDomNodeType.ANNOTATION_NODE));
|
||||
vNodeList.add(new NodeType("Attribute", FlmDomNodeType.ATTRIBUTE_NODE));
|
||||
vNodeList.add(new NodeType("CDATA Section", FlmDomNodeType.CDATA_SECTION_NODE));
|
||||
vNodeList.add(new NodeType("Comment", FlmDomNodeType.COMMENT_NODE));
|
||||
vNodeList.add(new NodeType("Data", FlmDomNodeType.DATA_NODE));
|
||||
vNodeList.add(new NodeType("Document", FlmDomNodeType.DOCUMENT_NODE));
|
||||
vNodeList.add(new NodeType("Element", FlmDomNodeType.ELEMENT_NODE));
|
||||
vNodeList.add(new NodeType("Processing Instruction", FlmDomNodeType.PROCESSING_INSTRUCTION_NODE));
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
public void run()
|
||||
{
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
||||
*/
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
String str = e.getActionCommand();
|
||||
|
||||
if (str.equals("Cancel"))
|
||||
{
|
||||
// Abort everything.
|
||||
this.dispose();
|
||||
}
|
||||
else if (str.equals("Add"))
|
||||
{
|
||||
// Update the database, but don't quit.
|
||||
if (m_btnNewDocument.isSelected())
|
||||
{
|
||||
try
|
||||
{
|
||||
NodeTag ntg = (NodeTag)m_NodeTagList.getSelectedValue();
|
||||
int iNumber = 0;
|
||||
|
||||
if (ntg != null)
|
||||
{
|
||||
iNumber = ntg.m_iNumber;
|
||||
}
|
||||
|
||||
m_lNodeId = m_owner.addDocument(
|
||||
m_iCollection,
|
||||
iNumber,
|
||||
m_textField.getText());
|
||||
if (m_lNodeId > 0)
|
||||
{
|
||||
m_btnNewSibling.setEnabled(true);
|
||||
m_btnNewChild.setEnabled(true);
|
||||
m_btnAnnotation.setEnabled(true);
|
||||
m_btnDone.setEnabled(true);
|
||||
}
|
||||
}
|
||||
catch (XFlaimException ee)
|
||||
{
|
||||
JOptionPane.showMessageDialog(
|
||||
this,
|
||||
"Database Exception occurred: " + ee.getMessage(),
|
||||
"Database Exception",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
else if (m_btnAnnotation.isSelected())
|
||||
{
|
||||
try
|
||||
{
|
||||
m_lNodeId = m_owner.addAnnotation(
|
||||
m_iCollection,
|
||||
m_textField.getText(),
|
||||
m_lNodeId);
|
||||
if (m_lNodeId > 0)
|
||||
{
|
||||
m_btnNewSibling.setEnabled(true);
|
||||
m_btnNewChild.setEnabled(true);
|
||||
m_btnAnnotation.setEnabled(true);
|
||||
m_btnDone.setEnabled(true);
|
||||
}
|
||||
}
|
||||
catch (XFlaimException ex)
|
||||
{
|
||||
JOptionPane.showMessageDialog(
|
||||
this,
|
||||
"Database Exception occurred: " + ex.getMessage(),
|
||||
"Database Exception",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean bIsSibling = false;
|
||||
if (m_btnNewSibling.isSelected())
|
||||
{
|
||||
bIsSibling = true;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
NodeType nt = (NodeType)m_NodeTypeList.getSelectedValue();
|
||||
NodeTag ntg = (NodeTag)m_NodeTagList.getSelectedValue();
|
||||
int iNumber = 0;
|
||||
|
||||
if (ntg != null)
|
||||
{
|
||||
iNumber = ntg.m_iNumber;
|
||||
}
|
||||
|
||||
m_lNodeId = m_owner.addNode(
|
||||
m_iCollection,
|
||||
nt.m_iType,
|
||||
iNumber,
|
||||
m_textField.getText(),
|
||||
bIsSibling,
|
||||
m_lNodeId);
|
||||
if (m_lNodeId > 0)
|
||||
{
|
||||
m_btnNewSibling.setEnabled(true);
|
||||
m_btnNewChild.setEnabled(true);
|
||||
m_btnAnnotation.setEnabled(true);
|
||||
m_btnDone.setEnabled(true);
|
||||
}
|
||||
}
|
||||
catch (XFlaimException ex)
|
||||
{
|
||||
JOptionPane.showMessageDialog(
|
||||
this,
|
||||
"Database Exception occurred: " + ex.getMessage(),
|
||||
"Database Exception",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (str.equals("Done"))
|
||||
{
|
||||
this.dispose();
|
||||
}
|
||||
else if (str.equals("Value"))
|
||||
{
|
||||
m_bValueEntered = true;
|
||||
enableButtons();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finalize method to ensure we close the local copy of the database.
|
||||
*/
|
||||
public void finalize()
|
||||
{
|
||||
if (m_jDb != null)
|
||||
{
|
||||
m_jDb.close();
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
|
||||
*/
|
||||
public void valueChanged(ListSelectionEvent e)
|
||||
{
|
||||
JList list = (JList)e.getSource();
|
||||
|
||||
Object obj = list.getSelectedValue();
|
||||
|
||||
if (obj instanceof NodeType)
|
||||
{
|
||||
NodeType nt = (NodeType)obj;
|
||||
|
||||
switch(nt.m_iType)
|
||||
{
|
||||
case FlmDomNodeType.ATTRIBUTE_NODE:
|
||||
{
|
||||
if (buildAttributeTagList())
|
||||
{
|
||||
m_nodeTagLabel.setText("Select Attribute Tag");
|
||||
m_nodeTagLabel.setVisible(true);
|
||||
m_bTypeSelected = true;
|
||||
m_bTagRequired = true;
|
||||
m_bTagSelected = false;
|
||||
m_bValueRequired = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FlmDomNodeType.ELEMENT_NODE:
|
||||
{
|
||||
if (buildElementTagList())
|
||||
{
|
||||
m_nodeTagLabel.setText("Select Element Tag");
|
||||
m_nodeTagLabel.setVisible(true);
|
||||
m_bTagRequired = true;
|
||||
m_bTagSelected = false;
|
||||
m_bTypeSelected = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FlmDomNodeType.DOCUMENT_NODE: // Same as Element Node - Root node.
|
||||
{
|
||||
if (buildElementTagList())
|
||||
{
|
||||
m_nodeTagLabel.setText("Select Root Tag");
|
||||
m_nodeTagLabel.setVisible(true);
|
||||
m_bTagRequired = true;
|
||||
m_bTagSelected = false;
|
||||
m_bTypeSelected = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FlmDomNodeType.ANNOTATION_NODE:
|
||||
{
|
||||
m_nodeTagLabel.setVisible(false);
|
||||
m_NodeTagList.setVisible(false);
|
||||
m_bTypeSelected = true;
|
||||
m_bTagRequired = false;
|
||||
m_bTagSelected = false;
|
||||
m_bValueRequired = true;
|
||||
m_scrollPane.setVisible(false);
|
||||
break;
|
||||
}
|
||||
case FlmDomNodeType.CDATA_SECTION_NODE:
|
||||
{
|
||||
m_nodeTagLabel.setVisible(false);
|
||||
m_NodeTagList.setVisible(false);
|
||||
m_bValueRequired = true;
|
||||
m_bTypeSelected = true;
|
||||
m_bTagRequired = false;
|
||||
m_bTagSelected = false;
|
||||
m_scrollPane.setVisible(false);
|
||||
break;
|
||||
}
|
||||
case FlmDomNodeType.COMMENT_NODE:
|
||||
{
|
||||
m_nodeTagLabel.setVisible(false);
|
||||
m_NodeTagList.setVisible(false);
|
||||
m_bTypeSelected = true;
|
||||
m_bTagRequired = false;
|
||||
m_bTagSelected = false;
|
||||
m_bValueRequired = true;
|
||||
m_scrollPane.setVisible(false);
|
||||
break;
|
||||
}
|
||||
case FlmDomNodeType.DATA_NODE:
|
||||
{
|
||||
m_nodeTagLabel.setVisible(false);
|
||||
m_NodeTagList.setVisible(false);
|
||||
m_bTypeSelected = true;
|
||||
m_bTagRequired = false;
|
||||
m_bTagSelected = false;
|
||||
m_bValueRequired = true;
|
||||
m_scrollPane.setVisible(false);
|
||||
break;
|
||||
}
|
||||
case FlmDomNodeType.PROCESSING_INSTRUCTION_NODE:
|
||||
{
|
||||
m_nodeTagLabel.setVisible(false);
|
||||
m_NodeTagList.setVisible(false);
|
||||
m_bTypeSelected = true;
|
||||
m_bTagRequired = false;
|
||||
m_bTagSelected = false;
|
||||
m_bValueRequired = true;
|
||||
m_scrollPane.setVisible(false);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
JOptionPane.showMessageDialog(
|
||||
this,
|
||||
"Invalid DOM Node Type",
|
||||
"Processing Error",
|
||||
JOptionPane.WARNING_MESSAGE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (obj instanceof NodeTag)
|
||||
{
|
||||
m_bTagSelected = true;
|
||||
}
|
||||
enableButtons();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void enableButtons()
|
||||
{
|
||||
if (m_bTypeSelected)
|
||||
{
|
||||
if (m_bTagRequired)
|
||||
{
|
||||
if (m_bTagSelected)
|
||||
{
|
||||
if (m_bValueRequired)
|
||||
{
|
||||
if (m_bValueEntered)
|
||||
{
|
||||
m_btnAdd.setEnabled(true);
|
||||
// m_btnDone.setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_btnAdd.setEnabled(false);
|
||||
m_btnDone.setEnabled(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_btnAdd.setEnabled(true);
|
||||
// m_btnDone.setEnabled(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_btnAdd.setEnabled(false);
|
||||
m_btnDone.setEnabled(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_bValueRequired)
|
||||
{
|
||||
if (m_bValueEntered)
|
||||
{
|
||||
m_btnAdd.setEnabled(true);
|
||||
// m_btnDone.setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_btnAdd.setEnabled(false);
|
||||
m_btnDone.setEnabled(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_btnAdd.setEnabled(true);
|
||||
// m_btnDone.setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private boolean buildElementTagList()
|
||||
{
|
||||
DataVector SearchKey = null;
|
||||
DataVector FoundKey = null;
|
||||
boolean bFirst = true;
|
||||
int iFlags;
|
||||
Vector vElements = new Vector();
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
SearchKey = m_dbSystem.createJDataVector();
|
||||
FoundKey = m_dbSystem.createJDataVector();
|
||||
|
||||
// Setup the search key.
|
||||
m_jDb.keyRetrieve(FlmDictIndex.NAME_INDEX,
|
||||
SearchKey,
|
||||
KeyRetrieveFlags.FO_FIRST,
|
||||
SearchKey);
|
||||
|
||||
SearchKey.setLong(0, ReserveID.ELM_ELEMENT_TAG);
|
||||
SearchKey.setString(1, "a");
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (bFirst)
|
||||
{
|
||||
bFirst = false;
|
||||
iFlags = KeyRetrieveFlags.FO_INCL;
|
||||
m_jDb.keyRetrieve(FlmDictIndex.NAME_INDEX, SearchKey, iFlags, FoundKey);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
iFlags = KeyRetrieveFlags.FO_EXCL;
|
||||
m_jDb.keyRetrieve(FlmDictIndex.NAME_INDEX, FoundKey, iFlags, FoundKey);
|
||||
|
||||
}
|
||||
|
||||
if (FoundKey == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (FoundKey.getLong(0) != ReserveID.ELM_ELEMENT_TAG)
|
||||
{
|
||||
break;
|
||||
}
|
||||
String sName = FoundKey.getString(1);
|
||||
int iNumber = (int)FoundKey.getLong(3);
|
||||
vElements.add(new NodeTag("<" + sName + ">", iNumber));
|
||||
}
|
||||
|
||||
if (vElements.size() > 0)
|
||||
{
|
||||
m_NodeTagList.removeAll();
|
||||
m_NodeTagList.setListData(vElements);
|
||||
m_NodeTagList.setEnabled(true);
|
||||
m_NodeTagList.setVisible(true);
|
||||
m_scrollPane.setVisible(true);
|
||||
}
|
||||
}
|
||||
catch (XFlaimException e)
|
||||
{
|
||||
JOptionPane.showMessageDialog(
|
||||
this,
|
||||
"Database Exception occured: " + e.getMessage(),
|
||||
"Database Exception",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
m_NodeTagList.setEnabled(false);
|
||||
m_NodeTagList.setVisible(false);
|
||||
m_scrollPane.setVisible(false);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private boolean buildAttributeTagList()
|
||||
{
|
||||
DataVector SearchKey = null;
|
||||
DataVector FoundKey = null;
|
||||
boolean bFirst = true;
|
||||
int iFlags;
|
||||
Vector vAttributes = new Vector();
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
SearchKey = m_dbSystem.createJDataVector();
|
||||
FoundKey = m_dbSystem.createJDataVector();
|
||||
|
||||
// Setup the search key.
|
||||
m_jDb.keyRetrieve(FlmDictIndex.NAME_INDEX,
|
||||
SearchKey,
|
||||
KeyRetrieveFlags.FO_FIRST,
|
||||
SearchKey);
|
||||
|
||||
SearchKey.setLong(0, ReserveID.ELM_ATTRIBUTE_TAG);
|
||||
SearchKey.setString(1, "a");
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (bFirst)
|
||||
{
|
||||
bFirst = false;
|
||||
iFlags = KeyRetrieveFlags.FO_INCL;
|
||||
m_jDb.keyRetrieve(FlmDictIndex.NAME_INDEX, SearchKey, iFlags, FoundKey);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
iFlags = KeyRetrieveFlags.FO_EXCL;
|
||||
m_jDb.keyRetrieve(FlmDictIndex.NAME_INDEX, FoundKey, iFlags, FoundKey);
|
||||
|
||||
}
|
||||
|
||||
if (FoundKey == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (FoundKey.getLong(0) != ReserveID.ELM_ATTRIBUTE_TAG)
|
||||
{
|
||||
break;
|
||||
}
|
||||
String sName = FoundKey.getString(1);
|
||||
int iNumber = (int)FoundKey.getLong(3);
|
||||
vAttributes.add(new NodeTag("<" + sName + ">", iNumber));
|
||||
}
|
||||
|
||||
if (vAttributes.size() > 0)
|
||||
{
|
||||
m_NodeTagList.removeAll();
|
||||
m_NodeTagList.setListData(vAttributes);
|
||||
m_NodeTagList.setEnabled(true);
|
||||
m_NodeTagList.setVisible(true);
|
||||
m_scrollPane.setVisible(true);
|
||||
}
|
||||
}
|
||||
catch (XFlaimException e)
|
||||
{
|
||||
JOptionPane.showMessageDialog(
|
||||
this,
|
||||
"Database Exception occured: " + e.getMessage(),
|
||||
"Database Exception",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
m_NodeTagList.setEnabled(false);
|
||||
m_NodeTagList.setVisible(false);
|
||||
m_scrollPane.setVisible(false);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent)
|
||||
*/
|
||||
public void keyPressed(KeyEvent e)
|
||||
{
|
||||
// BNot implementing
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
|
||||
*/
|
||||
public void keyReleased(KeyEvent e)
|
||||
{
|
||||
int i = m_textField.getText().length();
|
||||
if (i == 0)
|
||||
{
|
||||
m_bValueEntered = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bValueEntered = true;
|
||||
}
|
||||
enableButtons();
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
|
||||
*/
|
||||
public void keyTyped(KeyEvent e)
|
||||
{
|
||||
// Not implementing
|
||||
}
|
||||
/*
|
||||
public static void main(String[] args)
|
||||
{
|
||||
Frame f = new Frame();
|
||||
NodeDialog nd = null;
|
||||
// DbSystem dbSystem;
|
||||
// try
|
||||
// {
|
||||
// dbSystem = new DbSystem();
|
||||
// }
|
||||
// catch (XFlaimException e)
|
||||
// {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// String sDbFileName = "myxml.db";
|
||||
// NodePanel np = new NodePanel(null, 0);
|
||||
try
|
||||
{
|
||||
nd = new NodeDialog(f);
|
||||
}
|
||||
catch (XFlaimException e1)
|
||||
{
|
||||
e1.printStackTrace();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
Thread t = new Thread((Runnable)nd);
|
||||
|
||||
t.start();
|
||||
}
|
||||
*/
|
||||
}
|
||||
642
xflaim/java/util/xedit/xedit/NodePanel.java
Normal file
642
xflaim/java/util/xedit/xedit/NodePanel.java
Normal file
@@ -0,0 +1,642 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Desc: Node Panel
|
||||
//
|
||||
// Tabs: 3
|
||||
//
|
||||
// Copyright (c) 2003-2006 Novell, Inc. All Rights Reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of version 2 of the GNU General Public
|
||||
// License as published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, contact Novell, Inc.
|
||||
//
|
||||
// To contact Novell about this file by physical or electronic mail,
|
||||
// you may find current contact information at www.novell.com
|
||||
//
|
||||
// $Id: NodePanel.java 3120 2006-01-19 13:41:12 -0700 (Thu, 19 Jan 2006) dsanders $
|
||||
//------------------------------------------------------------------------------
|
||||
package xedit;
|
||||
|
||||
import xedit.*;
|
||||
import xflaim.*;
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* The Nodepanel class represents the DOM node that is being shown in the XEdit
|
||||
* main display window. It preseves essential state information. It acts as
|
||||
* as repository for the XEdit main body to interact with. There is a fixed
|
||||
* number of NodePanel objects in the XEdit main display that never changes.
|
||||
* As the user scrolls up or down, causing the nodes to be repositioned,
|
||||
* the content of each NodePanel is copied to the NodePanel immediately
|
||||
* adjacent to it. The NodePanels themselves are fixed in their location.
|
||||
*/
|
||||
public class NodePanel extends JPanel
|
||||
{
|
||||
private boolean m_bExpanded;
|
||||
private boolean m_bHasChildren;
|
||||
private long m_lNodeId;
|
||||
private long m_lDocId;
|
||||
private int m_iCollection;
|
||||
private XEdit m_root;
|
||||
private JLabel m_label;
|
||||
private GridBagLayout m_gbLayout;
|
||||
private GridBagConstraints m_gbConstraints;
|
||||
private int m_iRow;
|
||||
private boolean m_bClosing;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public NodePanel(
|
||||
XEdit root,
|
||||
int iRow)
|
||||
{
|
||||
m_lNodeId = -1;
|
||||
m_lDocId = -1;
|
||||
m_iCollection = -1;
|
||||
m_root = root;
|
||||
m_iRow = iRow;
|
||||
m_bHasChildren = false;
|
||||
m_bExpanded = false;
|
||||
m_bClosing = false;
|
||||
addMouseListener(m_root);
|
||||
|
||||
m_label = new JLabel();
|
||||
m_label.setFont(new Font("Courier", Font.PLAIN, 16));
|
||||
Dimension d = root.getSizeOfDisplay();
|
||||
setSize(d.width, 17);
|
||||
setMinimumSize(new Dimension(d.width, 17));
|
||||
|
||||
m_gbLayout = new GridBagLayout();
|
||||
m_gbConstraints = new GridBagConstraints();
|
||||
setLayout(m_gbLayout);
|
||||
addToPanel(m_label, 0, 0, 1, 1, 100, 100, false);
|
||||
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method reset the node panel.
|
||||
*/
|
||||
public void reset()
|
||||
{
|
||||
m_lNodeId = -1;
|
||||
m_iCollection = -1;
|
||||
m_bHasChildren = false;
|
||||
m_bExpanded = false;
|
||||
m_bClosing = false;
|
||||
m_lDocId = -1;
|
||||
setLabelText("");
|
||||
m_label.setForeground(Color.BLACK);
|
||||
Dimension d = m_root.getSizeOfDisplay();
|
||||
setSize(d.width, 17);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method return the row number that this node occupies
|
||||
*/
|
||||
public int getRow()
|
||||
{
|
||||
return m_iRow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the expanded state of the node
|
||||
*/
|
||||
public boolean isExpanded()
|
||||
{
|
||||
return m_bExpanded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method return the children status of the node (hasChildren)
|
||||
*/
|
||||
public boolean hasChildren()
|
||||
{
|
||||
return m_bHasChildren;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method return the node Id of the node
|
||||
*/
|
||||
public long getNodeId()
|
||||
{
|
||||
return m_lNodeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method return the document Id of the node
|
||||
*/
|
||||
public long getDocId()
|
||||
{
|
||||
return m_lDocId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method return the closing state of the node, i.e. is this a
|
||||
* closing node after expansion.
|
||||
*/
|
||||
public boolean isClosing()
|
||||
{
|
||||
return m_bClosing;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method to set the forground of the label to show that this node is
|
||||
* selected.
|
||||
*/
|
||||
public void selectNode()
|
||||
{
|
||||
if (m_lDocId > 0)
|
||||
{
|
||||
m_label.setForeground(Color.MAGENTA);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to reset the forground of the label to show that this node is
|
||||
* selected.
|
||||
*/
|
||||
public void deselectNode()
|
||||
{
|
||||
m_label.setForeground(Color.BLACK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to retrieve the collection for the current node.
|
||||
*/
|
||||
public int getCollection()
|
||||
{
|
||||
return m_iCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to copy a NodePanel. The Nodepane np will be copied into
|
||||
* this node.
|
||||
*/
|
||||
public void copyNode(
|
||||
NodePanel np)
|
||||
{
|
||||
m_bClosing = np.m_bClosing;
|
||||
m_bExpanded = np.m_bExpanded;
|
||||
m_bHasChildren = np.m_bHasChildren;
|
||||
m_iCollection = np.m_iCollection;
|
||||
m_lDocId = np.m_lDocId;
|
||||
m_lNodeId = np.m_lNodeId;
|
||||
m_label.setText(new String(np.m_label.getText()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to set the text that is being displayed by the NodePanel.
|
||||
* @param sText
|
||||
*/
|
||||
private void setLabelText(String sText)
|
||||
{
|
||||
m_label.setText(sText);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up everything needed to present the DOM node as a text string in
|
||||
* the NodePanel. All internal state variables are set accordingly.
|
||||
*
|
||||
* @param jDb
|
||||
* @param refNode
|
||||
* @param bExpanded
|
||||
* @param bClosing
|
||||
* @throws XFlaimException
|
||||
*/
|
||||
public void buildLabel(
|
||||
DOMNode refNode,
|
||||
boolean bExpanded,
|
||||
boolean bClosing,
|
||||
boolean bList) throws XFlaimException
|
||||
{
|
||||
String sText = null;
|
||||
String sExpand;
|
||||
String sTag = null;
|
||||
String sName = null;
|
||||
String sPrefix = null;
|
||||
String sValue = null;
|
||||
String[] saAttrTags = new String[100];
|
||||
String[] saAttrValues = new String[100];
|
||||
DOMNode attrNode = null;
|
||||
int iNumAttrs = 0;
|
||||
int iLevel;
|
||||
int iNodeType = refNode.getNodeType();
|
||||
|
||||
m_bHasChildren = refNode.hasChildren();
|
||||
m_bExpanded = bExpanded;
|
||||
m_lNodeId = refNode.getNodeId();
|
||||
m_lDocId = refNode.getDocumentId();
|
||||
if (m_lDocId == 0)
|
||||
{
|
||||
m_lDocId = m_lNodeId;
|
||||
}
|
||||
m_bClosing = bClosing;
|
||||
m_iCollection = refNode.getCollection();
|
||||
|
||||
iLevel = getLevel(refNode);
|
||||
|
||||
//The first thing on the label is a Plus sign (if the node has children).
|
||||
if (m_bHasChildren && !bList)
|
||||
{
|
||||
if (m_bExpanded)
|
||||
{
|
||||
sExpand = "-";
|
||||
}
|
||||
else
|
||||
{
|
||||
sExpand = "+";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sExpand = new String(" ");
|
||||
}
|
||||
|
||||
if ((iNodeType != FlmDomNodeType.DATA_NODE) &&
|
||||
(iNodeType != FlmDomNodeType.COMMENT_NODE))
|
||||
{
|
||||
sPrefix = refNode.getPrefix();
|
||||
sName = refNode.getLocalName();
|
||||
if (sPrefix != null && !sPrefix.equals(""))
|
||||
{
|
||||
sTag = sPrefix + ":" + sName;
|
||||
}
|
||||
else
|
||||
{
|
||||
sTag = sName;
|
||||
}
|
||||
}
|
||||
|
||||
// Check here to see if this document has only one node (ignoring attributes)
|
||||
// We want to make sure we assign the closing "/" only when the node that is
|
||||
// marked as closing, truly is closing off other nodes. This is due to
|
||||
// the way the up/down keys are used.
|
||||
if (bClosing)
|
||||
{
|
||||
if (!m_bHasChildren && m_lDocId == m_lNodeId)
|
||||
{
|
||||
m_bClosing = bClosing = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bClosing)
|
||||
{
|
||||
if (refNode.hasAttributes())
|
||||
{
|
||||
boolean bFirst = true;
|
||||
|
||||
for (iNumAttrs = 0;;iNumAttrs++)
|
||||
{
|
||||
// We don't know how many attributes this node has, so we will have to rely on catching an exception to
|
||||
// break out of this loop.
|
||||
try
|
||||
{
|
||||
if (bFirst)
|
||||
{
|
||||
attrNode = refNode.getFirstAttribute(null);
|
||||
bFirst = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
attrNode = attrNode.getNextSibling(attrNode);
|
||||
}
|
||||
}
|
||||
catch (XFlaimException e)
|
||||
{
|
||||
if (e.getRCode() == RCODE.NE_XFLM_DOM_NODE_NOT_FOUND)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
JOptionPane.showMessageDialog(
|
||||
this,
|
||||
"Exception occurred in Database: " + e.getMessage(),
|
||||
"Database Exception",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
} // try/catch
|
||||
|
||||
try
|
||||
{
|
||||
if (saAttrTags.length < iNumAttrs)
|
||||
{
|
||||
JOptionPane.showMessageDialog(
|
||||
this,
|
||||
"Too many attributes",
|
||||
"Internal Error",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
sPrefix = attrNode.getPrefix();
|
||||
sName = attrNode.getLocalName();
|
||||
if (sPrefix != null && !sPrefix.equals(""))
|
||||
{
|
||||
saAttrTags[iNumAttrs] = sPrefix + ":" + sName;
|
||||
}
|
||||
else
|
||||
{
|
||||
saAttrTags[iNumAttrs] = sName;
|
||||
}
|
||||
saAttrValues[iNumAttrs] = getNodeValue(attrNode);
|
||||
}
|
||||
catch (XFlaimException e)
|
||||
{
|
||||
JOptionPane.showMessageDialog(
|
||||
this,
|
||||
"Exception occurred in Database: " + e.getMessage(),
|
||||
"Database Exception",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
} // for - getting attributes.
|
||||
}
|
||||
}
|
||||
|
||||
// Now build the actual label.
|
||||
sText = sExpand + " ";
|
||||
if (!bList)
|
||||
{
|
||||
for (int i=0; i < iLevel; i++)
|
||||
{
|
||||
sText = sText + " ";
|
||||
}
|
||||
sText = sText + new Integer(iLevel).toString() + " ";
|
||||
}
|
||||
if (iNodeType == FlmDomNodeType.ELEMENT_NODE)
|
||||
{
|
||||
sText = sText + "<";
|
||||
if (bClosing)
|
||||
{
|
||||
sText = sText + "/";
|
||||
}
|
||||
sText = sText + sTag;
|
||||
|
||||
for (int i = 0; i < iNumAttrs; i++)
|
||||
{
|
||||
sText = sText + " " + saAttrTags[i] + "=\"" + saAttrValues[i] + "\"";
|
||||
}
|
||||
|
||||
if (!bClosing)
|
||||
{
|
||||
if (m_bHasChildren && !m_bExpanded)
|
||||
{
|
||||
sText = sText + "/>";
|
||||
}
|
||||
else
|
||||
{
|
||||
sText = sText + ">";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sText = sText + ">";
|
||||
}
|
||||
// Check for annotations.
|
||||
if (!bClosing && refNode.hasAnnotation())
|
||||
{
|
||||
DOMNode jAnnot = refNode.getAnnotation(null);
|
||||
sText += jAnnot.getString();
|
||||
}
|
||||
}
|
||||
else // Comment or Data Node. Don't handle other types right now.
|
||||
{
|
||||
if (iNodeType == FlmDomNodeType.COMMENT_NODE)
|
||||
{
|
||||
sText = sText + "<!--";
|
||||
}
|
||||
// Get the value of the data node.
|
||||
sValue = getNodeValue(refNode);
|
||||
sText = sText + sValue;
|
||||
if (iNodeType == FlmDomNodeType.COMMENT_NODE)
|
||||
{
|
||||
sText = sText + "-->";
|
||||
}
|
||||
}
|
||||
if (bList)
|
||||
{
|
||||
// Need to make sure we don't let the value get too long on a list. This
|
||||
// is a temporary measure to help find why the list page when listing
|
||||
// dictionary documents hooks the key events onto the horizontal scroll
|
||||
// bar.
|
||||
if (sText.length() > 65)
|
||||
{
|
||||
sText = sText.substring(0, 64);
|
||||
}
|
||||
}
|
||||
m_label.setText(sText);
|
||||
Dimension d = getSize();
|
||||
setSize(m_label.getWidth(), d.height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to calculate the indentation level of the node.
|
||||
*
|
||||
* @param refNode
|
||||
* @return
|
||||
* @throws XFlaimException
|
||||
*/
|
||||
private int getLevel(
|
||||
DOMNode refNode) throws XFlaimException
|
||||
{
|
||||
DOMNode parent = null;
|
||||
int iLevel = 0;
|
||||
boolean bFirst = true;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (bFirst)
|
||||
{
|
||||
bFirst = false;
|
||||
parent = refNode.getParentNode(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
parent = parent.getParentNode(parent);
|
||||
}
|
||||
iLevel++;
|
||||
}
|
||||
catch (XFlaimException e)
|
||||
{
|
||||
if (e.getRCode() == RCODE.NE_XFLM_DOM_NODE_NOT_FOUND)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return iLevel;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to retrieve the node Value as a text string suitable for
|
||||
* displaying.
|
||||
*
|
||||
* @param jNode
|
||||
* @return
|
||||
*/
|
||||
private String getNodeValue(
|
||||
DOMNode jNode)
|
||||
{
|
||||
int iDataType;
|
||||
String sValue = null;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
iDataType = jNode.getDataType();
|
||||
|
||||
switch (iDataType)
|
||||
{
|
||||
case FlmDataType.FLM_TEXT_TYPE:
|
||||
{
|
||||
sValue = jNode.getString();
|
||||
break;
|
||||
}
|
||||
case FlmDataType.FLM_NUMBER_TYPE:
|
||||
{
|
||||
long lValue = jNode.getLong();
|
||||
sValue = (new Long(lValue)).toString();
|
||||
break;
|
||||
}
|
||||
case FlmDataType.FLM_BINARY_TYPE:
|
||||
{
|
||||
// No supported yet.
|
||||
}
|
||||
default:
|
||||
|
||||
}
|
||||
}
|
||||
catch (XFlaimException e)
|
||||
{
|
||||
JOptionPane.showMessageDialog(this,
|
||||
"Database Exception occurred: " + e.getMessage(),
|
||||
"Database Exception",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return sValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the internal component (label) to the NodePanel, setting the
|
||||
* constraints as specified.
|
||||
*
|
||||
* @param comp
|
||||
* @param iColumn
|
||||
* @param iRow
|
||||
* @param iColSpan
|
||||
* @param iRowSpan
|
||||
* @param iColWeight
|
||||
* @param iRowWeight
|
||||
* @param bUpdateDisplay
|
||||
*/
|
||||
private void addToPanel(
|
||||
Component comp,
|
||||
int iColumn,
|
||||
int iRow,
|
||||
int iColSpan,
|
||||
int iRowSpan,
|
||||
int iColWeight,
|
||||
int iRowWeight,
|
||||
boolean bUpdateDisplay)
|
||||
{
|
||||
UITools.buildConstraints(m_gbConstraints, iColumn, iRow, iColSpan, iRowSpan, iColWeight, iRowWeight);
|
||||
m_gbConstraints.anchor = GridBagConstraints.LINE_START;
|
||||
m_gbConstraints.fill = GridBagConstraints.NONE;
|
||||
m_gbLayout.addLayoutComponent(comp, m_gbConstraints);
|
||||
add(comp);
|
||||
if (bUpdateDisplay)
|
||||
{
|
||||
m_root.updateDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
||||
*/
|
||||
// public void mouseClicked(MouseEvent e)
|
||||
// {
|
||||
// Point p;
|
||||
|
||||
// Select the row.
|
||||
// m_root.selectRow(this);
|
||||
|
||||
// if (e.getButton() == MouseEvent.BUTTON3)
|
||||
// {
|
||||
// popup the document menu.
|
||||
// m_popup = new JPopupMenu("Document Node Options");
|
||||
// m_popup.addFocusListener(this);
|
||||
// if (m_root.isMainPanel((JPanel)this.getParent()))
|
||||
// {
|
||||
// m_closeItem = m_popup.add("Close Document");
|
||||
// m_closeItem.addActionListener(this);
|
||||
// m_popup.addSeparator();
|
||||
// }
|
||||
|
||||
// if (m_bHasChildren)
|
||||
// {
|
||||
// if (m_bExpanded)
|
||||
// {
|
||||
// m_expandCollapseItem = m_popup.add("Collapse Node");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// m_expandCollapseItem = m_popup.add("Expand Node");
|
||||
// }
|
||||
// m_expandCollapseItem.addActionListener(this);
|
||||
// m_popup.addSeparator();
|
||||
// }
|
||||
|
||||
// m_deleteItem = m_popup.add("Delete Node");
|
||||
// m_deleteItem.addActionListener(this);
|
||||
// m_editItem = m_popup.add("Edit Node");
|
||||
// m_editItem.setEnabled(false);
|
||||
// m_editItem.addActionListener(this);
|
||||
|
||||
// Need to make sure the menu appears close to where our window is located.
|
||||
// p = e.getPoint();
|
||||
// m_popup.show(this, p.x, p.y);
|
||||
// }
|
||||
|
||||
// if (e.getButton() == MouseEvent.BUTTON1)
|
||||
// {
|
||||
// if (e.getClickCount() > 1)
|
||||
// {
|
||||
// Expand or Collapse the node.
|
||||
// if (m_bExpanded)
|
||||
// {
|
||||
// collapse();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// expand();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
56
xflaim/java/util/xedit/xedit/NodeTag.java
Normal file
56
xflaim/java/util/xedit/xedit/NodeTag.java
Normal file
@@ -0,0 +1,56 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Desc: Node Tag
|
||||
//
|
||||
// Tabs: 3
|
||||
//
|
||||
// Copyright (c) 2003-2006 Novell, Inc. All Rights Reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of version 2 of the GNU General Public
|
||||
// License as published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, contact Novell, Inc.
|
||||
//
|
||||
// To contact Novell about this file by physical or electronic mail,
|
||||
// you may find current contact information at www.novell.com
|
||||
//
|
||||
// $Id: NodeTag.java 3120 2006-01-19 13:41:12 -0700 (Thu, 19 Jan 2006) dsanders $
|
||||
//------------------------------------------------------------------------------
|
||||
package xedit;
|
||||
|
||||
import java.awt.Component;
|
||||
|
||||
/**
|
||||
* To change the template for this generated type comment go to
|
||||
* Window->Preferences->Java->Code Generation->Code and Comments
|
||||
*/
|
||||
public class NodeTag extends Component
|
||||
{
|
||||
|
||||
private String m_sName;
|
||||
int m_iNumber;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public NodeTag(
|
||||
String sName,
|
||||
int iNumber)
|
||||
{
|
||||
m_iNumber = iNumber;
|
||||
m_sName = sName;
|
||||
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return m_sName;
|
||||
}
|
||||
|
||||
}
|
||||
50
xflaim/java/util/xedit/xedit/NodeType.java
Normal file
50
xflaim/java/util/xedit/xedit/NodeType.java
Normal file
@@ -0,0 +1,50 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Desc: Node Type
|
||||
//
|
||||
// Tabs: 3
|
||||
//
|
||||
// Copyright (c) 2003,2005-2006 Novell, Inc. All Rights Reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of version 2 of the GNU General Public
|
||||
// License as published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, contact Novell, Inc.
|
||||
//
|
||||
// To contact Novell about this file by physical or electronic mail,
|
||||
// you may find current contact information at www.novell.com
|
||||
//
|
||||
// $Id: NodeType.java 3120 2006-01-19 13:41:12 -0700 (Thu, 19 Jan 2006) dsanders $
|
||||
//------------------------------------------------------------------------------
|
||||
package xedit;
|
||||
|
||||
import java.awt.Component;
|
||||
|
||||
/**
|
||||
* To change the template for this generated type comment go to
|
||||
* Window->Preferences->Java->Code Generation->Code and Comments
|
||||
*/
|
||||
public class NodeType extends Component
|
||||
{
|
||||
String m_sType;
|
||||
int m_iType;
|
||||
|
||||
public NodeType(
|
||||
String sType,
|
||||
int iType)
|
||||
{
|
||||
m_sType = sType;
|
||||
m_iType = iType;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return m_sType;
|
||||
}
|
||||
}
|
||||
54
xflaim/java/util/xedit/xedit/NodeValue.java
Normal file
54
xflaim/java/util/xedit/xedit/NodeValue.java
Normal file
@@ -0,0 +1,54 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Desc: Node Value
|
||||
//
|
||||
// Tabs: 3
|
||||
//
|
||||
// Copyright (c) 2004-2006 Novell, Inc. All Rights Reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of version 2 of the GNU General Public
|
||||
// License as published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, contact Novell, Inc.
|
||||
//
|
||||
// To contact Novell about this file by physical or electronic mail,
|
||||
// you may find current contact information at www.novell.com
|
||||
//
|
||||
// $Id: NodeValue.java 3120 2006-01-19 13:41:12 -0700 (Thu, 19 Jan 2006) dsanders $
|
||||
//------------------------------------------------------------------------------
|
||||
package xedit;
|
||||
|
||||
/**
|
||||
* To change the template for this generated type comment go to
|
||||
* Window->Preferences->Java->Code Generation->Code and Comments
|
||||
*/
|
||||
public class NodeValue
|
||||
{
|
||||
String m_sValue;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public NodeValue(
|
||||
String sValue)
|
||||
{
|
||||
m_sValue = sValue;
|
||||
}
|
||||
|
||||
public void setValue(
|
||||
String sValue)
|
||||
{
|
||||
m_sValue = sValue;
|
||||
}
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
return m_sValue;
|
||||
}
|
||||
|
||||
}
|
||||
156
xflaim/java/util/xedit/xedit/OpenDocumentSelector.java
Normal file
156
xflaim/java/util/xedit/xedit/OpenDocumentSelector.java
Normal file
@@ -0,0 +1,156 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Desc: Open Document Selector
|
||||
//
|
||||
// Tabs: 3
|
||||
//
|
||||
// Copyright (c) 2003,2005-2006 Novell, Inc. All Rights Reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of version 2 of the GNU General Public
|
||||
// License as published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, contact Novell, Inc.
|
||||
//
|
||||
// To contact Novell about this file by physical or electronic mail,
|
||||
// you may find current contact information at www.novell.com
|
||||
//
|
||||
// $Id: OpenDocumentSelector.java 3120 2006-01-19 13:41:12 -0700 (Thu, 19 Jan 2006) dsanders $
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* To change the template for this generated type comment go to
|
||||
* Window->Preferences->Java->Code Generation->Code and Comments
|
||||
*/
|
||||
|
||||
package xedit;
|
||||
import xedit.UITools;
|
||||
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Frame;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JScrollPane;
|
||||
|
||||
/**
|
||||
* To change the template for this generated type comment go to
|
||||
* Window->Preferences->Java->Code Generation->Code and Comments
|
||||
*/
|
||||
public class OpenDocumentSelector extends JDialog implements ActionListener
|
||||
{
|
||||
|
||||
private JList m_lstList;
|
||||
private JButton m_btnOkay;
|
||||
private JButton m_btnCancel;
|
||||
private int m_iItem;
|
||||
|
||||
public OpenDocumentSelector(
|
||||
Frame owner,
|
||||
Vector vDocList)
|
||||
{
|
||||
super(owner, "Select Open Document", true);
|
||||
|
||||
Container CP; // The content pane for this dialog
|
||||
GridBagLayout gridbag;
|
||||
GridBagConstraints constraints = new GridBagConstraints();
|
||||
|
||||
// Coordinates for locating this window in the center of its parent.
|
||||
Point p;
|
||||
Dimension d;
|
||||
int x;
|
||||
int y;
|
||||
|
||||
setDefaultCloseOperation( DISPOSE_ON_CLOSE);
|
||||
CP = getContentPane();
|
||||
gridbag = new GridBagLayout();
|
||||
CP.setLayout( gridbag);
|
||||
|
||||
m_iItem = -1;
|
||||
|
||||
// Add the list
|
||||
m_lstList = new JList( vDocList);
|
||||
m_lstList.setSelectedIndex(0);
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane();
|
||||
scrollPane.getViewport().setView(m_lstList);
|
||||
|
||||
UITools.buildConstraints(constraints, 0, 0, 2, 4, 100, 100);
|
||||
constraints.anchor = GridBagConstraints.NORTHWEST;
|
||||
constraints.fill = GridBagConstraints.BOTH;
|
||||
|
||||
gridbag.setConstraints( scrollPane, constraints);
|
||||
|
||||
CP.add( scrollPane);
|
||||
|
||||
// Add the Okay button
|
||||
m_btnOkay = new JButton("Okay");
|
||||
m_btnOkay.setDefaultCapable(true);
|
||||
m_btnOkay.addActionListener(this);
|
||||
|
||||
UITools.buildConstraints(constraints, 0, 5, 1, 1, 90, 100);
|
||||
constraints.anchor = GridBagConstraints.EAST;
|
||||
constraints.fill = GridBagConstraints.NONE;
|
||||
|
||||
gridbag.setConstraints( m_btnOkay, constraints);
|
||||
|
||||
CP.add( m_btnOkay);
|
||||
|
||||
// Add the Cancel button
|
||||
m_btnCancel = new JButton("Cancel");
|
||||
m_btnCancel.addActionListener(this);
|
||||
|
||||
UITools.buildConstraints(constraints, 1, 5, 1, 1, 10, 0);
|
||||
constraints.anchor = GridBagConstraints.WEST;
|
||||
|
||||
gridbag.setConstraints( m_btnCancel, constraints);
|
||||
|
||||
CP.add( m_btnCancel);
|
||||
|
||||
setSize(Math.max( 400, 200), 200);
|
||||
|
||||
p = owner.getLocationOnScreen();
|
||||
d = owner.getSize();
|
||||
x = (d.width - 400) / 2;
|
||||
y = (d.height - 300) / 2;
|
||||
setLocation(Math.max(0, p.x + x), Math.max(0, p.y + y));
|
||||
}
|
||||
|
||||
public int showDialog()
|
||||
{
|
||||
setVisible( true);
|
||||
return m_iItem;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
||||
*/
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
Object obj = (Object)e.getSource();
|
||||
if (obj == m_btnOkay)
|
||||
{
|
||||
m_iItem = m_lstList.getSelectedIndex();
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
258
xflaim/java/util/xedit/xedit/ProgressBox.java
Normal file
258
xflaim/java/util/xedit/xedit/ProgressBox.java
Normal file
@@ -0,0 +1,258 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Desc: Progress Box
|
||||
//
|
||||
// Tabs: 3
|
||||
//
|
||||
// Copyright (c) 2003,2005-2006 Novell, Inc. All Rights Reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of version 2 of the GNU General Public
|
||||
// License as published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, contact Novell, Inc.
|
||||
//
|
||||
// To contact Novell about this file by physical or electronic mail,
|
||||
// you may find current contact information at www.novell.com
|
||||
//
|
||||
// $Id: ProgressBox.java 3120 2006-01-19 13:41:12 -0700 (Thu, 19 Jan 2006) dsanders $
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
package xedit;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
import xedit.UITools;
|
||||
|
||||
/**
|
||||
* To change the template for this generated type comment go to
|
||||
* Window->Preferences->Java->Code Generation->Code and Comments
|
||||
*/
|
||||
public class ProgressBox extends JDialog implements ActionListener
|
||||
{
|
||||
private JLabel m_label1;
|
||||
private JLabel m_label2;
|
||||
private JCheckBox m_checkBox;
|
||||
private JButton m_button;
|
||||
private JProgressBar m_bar;
|
||||
private boolean m_bCloseOnExit = false;
|
||||
private boolean m_bToggled = false;
|
||||
private boolean m_bCancelPressed = false;
|
||||
|
||||
/**
|
||||
* @throws java.awt.HeadlessException
|
||||
*/
|
||||
public ProgressBox(
|
||||
Frame owner,
|
||||
int iWidth,
|
||||
int iHeight,
|
||||
String label1,
|
||||
String label2,
|
||||
int iMin,
|
||||
int iMax)
|
||||
{
|
||||
super();
|
||||
JPanel p1;
|
||||
JPanel p2;
|
||||
JPanel p3;
|
||||
JPanel p4;
|
||||
Container CP; // The content pane for this dialog
|
||||
// Coordinates for location this window in the center of its parent.
|
||||
Point p;
|
||||
Dimension d;
|
||||
int x;
|
||||
int y;
|
||||
|
||||
m_label1 = new JLabel(label1);
|
||||
m_label2 = new JLabel(label2);
|
||||
|
||||
setDefaultCloseOperation( DISPOSE_ON_CLOSE);
|
||||
CP = getContentPane();
|
||||
CP.setLayout( new GridLayout( 4, 1));
|
||||
|
||||
p1 = new JPanel();
|
||||
p1.add(m_label1);
|
||||
CP.add(p1);
|
||||
|
||||
p2 = new JPanel();
|
||||
p2.add(m_label2);
|
||||
CP.add(p2);
|
||||
|
||||
m_bar = new JProgressBar(iMin, iMax);
|
||||
m_bar.setStringPainted(true);
|
||||
if (iMax == 0)
|
||||
{
|
||||
m_bar.setIndeterminate(true);
|
||||
}
|
||||
GridBagLayout gbl = new GridBagLayout();
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
UITools.buildConstraints(gbc, 0, 0, 0, 0, 100, 100);
|
||||
gbc.fill = GridBagConstraints.BOTH;
|
||||
gbl.setConstraints(m_bar, gbc);
|
||||
p3 = new JPanel();
|
||||
p3.setLayout(gbl);
|
||||
p3.add(m_bar);
|
||||
CP.add(p3);
|
||||
|
||||
p4 = new JPanel();
|
||||
GridBagLayout grid = new GridBagLayout();
|
||||
p4.setLayout(grid);
|
||||
|
||||
m_checkBox = new JCheckBox();
|
||||
m_checkBox.setEnabled(true);
|
||||
m_checkBox.addActionListener(this);
|
||||
UITools.buildConstraints(gbc, 0, 0, 1, 1, 10, 100);
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
gbc.fill = GridBagConstraints.NONE;
|
||||
grid.setConstraints(m_checkBox, gbc);
|
||||
p4.add(m_checkBox);
|
||||
|
||||
JLabel lbl1 = new JLabel("Close when finished");
|
||||
UITools.buildConstraints(gbc, 1, 0, 1, 2, 60, 0);
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
gbc.fill = GridBagConstraints.NONE;
|
||||
grid.setConstraints(lbl1, gbc);
|
||||
p4.add(lbl1);
|
||||
|
||||
m_button = new JButton("Cancel");
|
||||
m_button.addActionListener(this);
|
||||
UITools.buildConstraints(gbc, 2, 0, 1, 1, 30, 0);
|
||||
gbc.anchor = GridBagConstraints.EAST;
|
||||
gbc.fill = GridBagConstraints.NONE;
|
||||
grid.setConstraints(m_button, gbc);
|
||||
p4.add(m_button);
|
||||
|
||||
CP.add(p4);
|
||||
|
||||
setSize(iWidth,iHeight);
|
||||
|
||||
if (owner != null)
|
||||
{
|
||||
p = owner.getLocationOnScreen();
|
||||
d = owner.getSize();
|
||||
x = (d.width - iWidth) / 2;
|
||||
y = (d.height - iHeight) / 2;
|
||||
setLocation(Math.max(0, p.x + x), Math.max(0, p.y + y));
|
||||
}
|
||||
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
||||
*/
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
Object obj = e.getSource();
|
||||
if (obj == m_checkBox)
|
||||
{
|
||||
m_bCloseOnExit = !m_bCloseOnExit;
|
||||
}
|
||||
else if (obj == m_button)
|
||||
{
|
||||
if (m_button.getText().equals("Cancel"))
|
||||
{
|
||||
m_bCancelPressed = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setLabel1( String newLabel1)
|
||||
{
|
||||
m_label1.setText( newLabel1);
|
||||
}
|
||||
|
||||
public void setLabel2( String newLabel2)
|
||||
{
|
||||
m_label2.setText( newLabel2);
|
||||
}
|
||||
|
||||
public void updateProgress( int iValue)
|
||||
{
|
||||
m_bar.setValue( iValue);
|
||||
if (iValue >= m_bar.getMaximum() && m_bar.getMaximum() > 0)
|
||||
{
|
||||
if (m_bCloseOnExit)
|
||||
{
|
||||
dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
toggleOkCancelButton();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void terminate()
|
||||
{
|
||||
dispose();
|
||||
}
|
||||
|
||||
private void toggleOkCancelButton()
|
||||
{
|
||||
if (m_bToggled)
|
||||
{
|
||||
m_button.setText("Cancel");
|
||||
m_bToggled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_button.setText("Okay");
|
||||
m_bToggled = true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean Cancelled()
|
||||
{
|
||||
return m_bCancelPressed;
|
||||
}
|
||||
|
||||
public void setMax( int iMax)
|
||||
{
|
||||
m_bar.setMaximum( iMax);
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
ProgressBox b = new ProgressBox(null, 400, 160, "Label 1Label 1Label 1Label 1Label 1Label 1Label 1",
|
||||
"Label 2Label 2Label 2Label 2Label 2Label 2Label 2",
|
||||
0, 999);
|
||||
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
if (i % 100 == 0)
|
||||
{
|
||||
b.setLabel1( "Importing file " + i + "of 1000");
|
||||
}
|
||||
b.setLabel2("Filename: xxxx" + i + ".xml");
|
||||
b.updateProgress(i);
|
||||
if (b.Cancelled())
|
||||
{
|
||||
b.terminate();
|
||||
break;
|
||||
}
|
||||
try
|
||||
{
|
||||
Thread.sleep(10);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Do nothing...
|
||||
}
|
||||
}
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
}
|
||||
159
xflaim/java/util/xedit/xedit/Status.java
Normal file
159
xflaim/java/util/xedit/xedit/Status.java
Normal file
@@ -0,0 +1,159 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Desc: Status
|
||||
//
|
||||
// Tabs: 3
|
||||
//
|
||||
// Copyright (c) 2003,2005-2006 Novell, Inc. All Rights Reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of version 2 of the GNU General Public
|
||||
// License as published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, contact Novell, Inc.
|
||||
//
|
||||
// To contact Novell about this file by physical or electronic mail,
|
||||
// you may find current contact information at www.novell.com
|
||||
//
|
||||
// $Id: Status.java 3120 2006-01-19 13:41:12 -0700 (Thu, 19 Jan 2006) dsanders $
|
||||
//------------------------------------------------------------------------------
|
||||
package xedit;
|
||||
import javax.swing.JLabel;
|
||||
|
||||
|
||||
/**
|
||||
* To change the template for this generated type comment go to
|
||||
* Window->Preferences->Java->Code Generation->Code and Comments
|
||||
*/
|
||||
public class Status
|
||||
{
|
||||
private boolean m_bDatabaseOpen;
|
||||
private String m_sDatabasePath;
|
||||
private JLabel m_label;
|
||||
private long m_lDocId;
|
||||
private long m_lNodeId;
|
||||
private boolean m_bTransaction = false;
|
||||
public int m_iCurrentNode = -2;
|
||||
public int m_iLastNode = -2;
|
||||
|
||||
|
||||
// Constructor
|
||||
Status()
|
||||
{
|
||||
m_bDatabaseOpen = false;
|
||||
m_sDatabasePath = null;
|
||||
m_label = null;
|
||||
m_lDocId = 0;
|
||||
m_lNodeId = 0;
|
||||
}
|
||||
|
||||
Status(
|
||||
JLabel label)
|
||||
{
|
||||
m_bDatabaseOpen = false;
|
||||
m_sDatabasePath = null;
|
||||
m_lDocId = 0;
|
||||
m_lNodeId = 0;
|
||||
m_label = label;
|
||||
updateLabel();
|
||||
}
|
||||
|
||||
public void setDatabaseOpen(
|
||||
boolean bOpen)
|
||||
{
|
||||
m_bDatabaseOpen = bOpen;
|
||||
updateLabel();
|
||||
}
|
||||
|
||||
public boolean getDatabaseOpen()
|
||||
{
|
||||
return m_bDatabaseOpen;
|
||||
}
|
||||
|
||||
public void setDatabasePath(
|
||||
String sDatabasePath)
|
||||
{
|
||||
m_sDatabasePath = sDatabasePath;
|
||||
updateLabel();
|
||||
}
|
||||
|
||||
public String getDatabasePath()
|
||||
{
|
||||
return m_sDatabasePath;
|
||||
}
|
||||
|
||||
public void setDocId(
|
||||
long lDocId)
|
||||
{
|
||||
m_lDocId = lDocId;
|
||||
updateLabel();
|
||||
}
|
||||
|
||||
public long getDocId()
|
||||
{
|
||||
return m_lDocId;
|
||||
}
|
||||
|
||||
public void setNodeId(
|
||||
long lNodeId)
|
||||
{
|
||||
m_lNodeId = lNodeId;
|
||||
updateLabel();
|
||||
}
|
||||
|
||||
public long getNodeId()
|
||||
{
|
||||
return m_lNodeId;
|
||||
}
|
||||
|
||||
public void setLabel(
|
||||
JLabel label)
|
||||
{
|
||||
m_label = label;
|
||||
updateLabel();
|
||||
}
|
||||
|
||||
public void setTransaction(
|
||||
boolean bTransaction)
|
||||
{
|
||||
m_bTransaction = bTransaction;
|
||||
updateLabel();
|
||||
}
|
||||
|
||||
public boolean getTransaction()
|
||||
{
|
||||
return m_bTransaction;
|
||||
}
|
||||
|
||||
public void updateLabel()
|
||||
{
|
||||
String sLabelText;
|
||||
String sDocNode = "";
|
||||
String sTransaction = m_bTransaction ? "Update" : "";
|
||||
|
||||
if (m_label != null)
|
||||
{
|
||||
if (m_bDatabaseOpen)
|
||||
{
|
||||
sLabelText = "Database: " + m_sDatabasePath;
|
||||
|
||||
if (m_lDocId > 0 && m_lNodeId > 0)
|
||||
{
|
||||
sDocNode = new String("\t" + new Long(m_lDocId).toString() +
|
||||
"/" + new Long(m_lNodeId).toString());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sLabelText = "No Database";
|
||||
}
|
||||
// m_label.setText(sLabelText + " " + sDocNode + " [" + m_iCurrentNode + "/" + m_iLastNode + "]");
|
||||
m_label.setText(sLabelText + " " + sDocNode + " " + sTransaction);
|
||||
}
|
||||
}
|
||||
}
|
||||
51
xflaim/java/util/xedit/xedit/UITools.java
Normal file
51
xflaim/java/util/xedit/xedit/UITools.java
Normal file
@@ -0,0 +1,51 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Desc: UI Tools
|
||||
//
|
||||
// Tabs: 3
|
||||
//
|
||||
// Copyright (c) 2003,2005-2006 Novell, Inc. All Rights Reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of version 2 of the GNU General Public
|
||||
// License as published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, contact Novell, Inc.
|
||||
//
|
||||
// To contact Novell about this file by physical or electronic mail,
|
||||
// you may find current contact information at www.novell.com
|
||||
//
|
||||
// $Id: UITools.java 3120 2006-01-19 13:41:12 -0700 (Thu, 19 Jan 2006) dsanders $
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
package xedit;
|
||||
import java.awt.GridBagConstraints;
|
||||
|
||||
/**
|
||||
* To change the template for this generated type comment go to
|
||||
* Window->Preferences->Java->Code Generation->Code and Comments
|
||||
*/
|
||||
public class UITools
|
||||
{
|
||||
public static void buildConstraints(
|
||||
GridBagConstraints gbc,
|
||||
int gx,
|
||||
int gy,
|
||||
int gw,
|
||||
int gh,
|
||||
int wx,
|
||||
int wy)
|
||||
{
|
||||
gbc.gridx = gx;
|
||||
gbc.gridy =gy;
|
||||
gbc.gridwidth = gw;
|
||||
gbc.gridheight = gh;
|
||||
gbc.weightx = wx;
|
||||
gbc.weighty = wy;
|
||||
}
|
||||
}
|
||||
3435
xflaim/java/util/xedit/xedit/XEdit.java
Normal file
3435
xflaim/java/util/xedit/xedit/XEdit.java
Normal file
File diff suppressed because it is too large
Load Diff
76
xflaim/java/util/xedit/xedit/XFileFilter.java
Normal file
76
xflaim/java/util/xedit/xedit/XFileFilter.java
Normal file
@@ -0,0 +1,76 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Desc: File Filter
|
||||
//
|
||||
// Tabs: 3
|
||||
//
|
||||
// Copyright (c) 2003,2005-2006 Novell, Inc. All Rights Reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of version 2 of the GNU General Public
|
||||
// License as published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, contact Novell, Inc.
|
||||
//
|
||||
// To contact Novell about this file by physical or electronic mail,
|
||||
// you may find current contact information at www.novell.com
|
||||
//
|
||||
// $Id: XFileFilter.java 3120 2006-01-19 13:41:12 -0700 (Thu, 19 Jan 2006) dsanders $
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
package xedit;
|
||||
import java.io.File;
|
||||
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
|
||||
|
||||
/**
|
||||
* To change the template for this generated type comment go to
|
||||
* Window->Preferences->Java->Code Generation->Code and Comments
|
||||
*/
|
||||
public class XFileFilter extends FileFilter
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public XFileFilter( String filter)
|
||||
{
|
||||
super();
|
||||
m_sFilter = filter;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see javax.swing.filechooser.FileFilter#accept(java.io.File)
|
||||
*/
|
||||
public boolean accept(File f)
|
||||
{
|
||||
String name = f.getName();
|
||||
if (f.isDirectory())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( name.endsWith(m_sFilter))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see javax.swing.filechooser.FileFilter#getDescription()
|
||||
*/
|
||||
public String getDescription()
|
||||
{
|
||||
return m_sFilter;
|
||||
}
|
||||
|
||||
String m_sFilter;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user