Archive for the ‘Java’ Category

Using Java to Read Record Data in ClassForm for ARS 7.0

Sunday, November 22nd, 2009

Using Java to Read Record Data in ClassForm for ARS 7.0

////////////////////////////////////////////////////////////////////////////
///Start Query Records By Qualification/////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////

Entry entry;
//Prepare to Query a Form on ARSystem 7.0

NameID formName = new NameID(getClassName());
//Set the Field criteria to retrieve all field info
//———————————————————————-
FieldCriteria fCriteria = new FieldCriteria();
fCriteria.setRetrieveAll(true);

//Retrieve all types of fields
//———————————————————————-
FieldListCriteria fListCrit =
new FieldListCriteria(formName, new Timestamp(0),
FieldType.AR_ALL_FIELD);

//Load the field array with all fields in the test form
//———————————————————————-
Field[] formFields = FieldFactory.findObjects(userInfo,
fListCrit, fCriteria);

//Create the search qualifier
//———————————————————————-
QualifierInfo myQualifier = Util.ARGetQualifier(userInfo,
getSearchString(), formFields, null,
Constants.AR_QUALCONTEXT_DEFAULT);

FieldFactory.getFactory().releaseInstance(formFields);

//Set the EntryListCriteria
//———————————————————————-
EntryListCriteria listCriteria = new EntryListCriteria();
listCriteria.setSchemaID(formName);
listCriteria.setQualifier(myQualifier);

//Define which fields to retrieve in the results list
//Note that the total width including separators must be <256 chracters
//Here the total width=15+12+25+3*1=58
//3*1 is three separators of 1 character each
//———————————————————————-
EntryListFieldInfo[] entryListFieldList =
new EntryListFieldInfo[getUsedFieldIds().length];

for (int i = 0; i < getUsedFieldIds().length; i++) {
entryListFieldList[i] = new EntryListFieldInfo(
new FieldID(Long.parseLong(getUsedFieldIds()[i].toString())),
5, ” “);
}
//Set the Entry Criteria
//———————————————————————-
EntryCriteria criteria = new EntryCriteria();
criteria.setEntryListFieldInfo(entryListFieldList);

//Make the call to retrieve the query results list
Integer nMatches = null;

//Set it to false to return all entries regardless of locale
//———————————————————————-
Entry[] entryInfo = EntryFactory.findObjects(userInfo,
listCriteria, criteria, false, nMatches);

log.debug(“Query returned===” + entryInfo.length + ” matches.”);

for (int i = 0; i < entryInfo.length; i++) {

for (int ii=0;ii<entryInfo[i].getEntryItems().length-1;ii++)  {

try {

log.debug(ii+ “.)Value===” + entryInfo[i].getEntryItems()[ii].getValue().toString() + “====” );

} catch (NullPointerException ex) {
log.debug(i + “.)” + ex.getLocalizedMessage());
}

}
}

///////////////////////////////////////////////////////////////////////////////
///End Query Records By Qualification/////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

Using Java to Read Record Data in ClassForm for ARS 7.1

Sunday, November 22nd, 2009

Using Java to Reading Record Data in ClassForm for ARS 7.1

////////////////////////////////////////////////////////////////////////////////
///Start Query Records By Qualification/////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//Set the Field criteria to retrieve all field info
//———————————————————————-
List<Field> fields = userInfo.getListFieldObjects(formName);

//Create the search qualifier
//———————————————————————-
QualifierInfo myQualifier = userInfo.parseQualification(getQueryString(),
fields, null, Constants.AR_QUALCONTEXT_DEFAULT);

OutputInteger nMatches = new OutputInteger();
List<SortInfo> sortOrder = new ArrayList<SortInfo>();
sortOrder.add(new SortInfo(2, Constants.AR_SORT_ASCENDING));
int[] fieldIds = intArray.getIntArray(getUsedFieldIds());

List<Entry> entryList = userInfo.getListEntryObjects(formName, myQualifier, 0,
Constants.AR_NO_MAX_LIST_RETRIEVE, sortOrder, fieldIds, true, nMatches);

for (int i = 0; i < entryList.size(); i++) {

try {

Entry entry = userInfo.getEntry(formName, entryList.get(i).getEntryId(), null);

for(int ii=0;ii<fieldIds.length-1;ii++){
log.debug(ii +”.) Value” + (entry.get(fieldIds[ii]).getValue() != null ? entry.get(fieldIds[ii]).getValue().toString():”null”) + “”);
}

} catch (NullPointerException ex) {
log.debug(i + “.)” + ex.getLocalizedMessage());
}

}
//////////////////////////////////////////////////////////////////////////////
///End Query Records By Qualification/////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

Using Java to handle Mouse Button Click Events

Saturday, November 21st, 2009

package application1.example.swing;
 
import javax.swing.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
 
public class MouseClickEventDemo extends JFrame {
    public MouseClickEventDemo() {
        initComponents();
    }
 
    private void initComponents() {
        setSize(300, 300);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 
        final JTextArea textArea = new JTextArea();
        textArea.setText(“Click Me!”);
 
        textArea.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                if (e.getButton() == MouseEvent.NOBUTTON)
                {
                    textArea.setText(“No button clicked…”);
                } else if (e.getButton() == MouseEvent.BUTTON1) {
                    textArea.setText(“Button 1 clicked…”);
                } else if (e.getButton() == MouseEvent.BUTTON2) {
                    textArea.setText(“Button 2 clicked…”);
                } else if (e.getButton() == MouseEvent.BUTTON3) {
                    textArea.setText(“Button 3 clicked…”);
                }
 
                textArea.append(“Number of click: ” + e.getClickCount());
                textArea.append(“Click position (X, Y):  ” + e.getX() + “, ” + e.getY());
            }
        });
 
        getContentPane().add(textArea);
    }
 
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                new MouseClickEventDemo().setVisible(true);
            }
        });
    }
}