Java Reference
In-Depth Information
13.2.4
Rename a Saved Object
In this Admin console, when the user enters a new object name in the
“Name” column on the GUI screen and validates this new name by
hitting the RETURN key, the Java graphical framework throws an
event which is translated as a setValueAt method call on the underly-
ing TableModel . The code of setValueAt is shown here:
1.
public void setValueAt (Object iValue,
2.
int iRowIndex,
3.
int iColumnIndex) {
if (iColumnIndex 0) {
4.
String lOldName (String) getValueAt(iRowIndex, iColumnIndex);
5.
String lNewName (String) iValue;
6.
7.
try {
8.
handlerRename(lOldName, lNewName);
9.
} catch (JDMException lException) {
lNewName lOldName;
10.
11.
displayJDMException(lException);
12.
} finally {
mMiningObjects[iRowIndex] lNewName;
13.
14.
}
15.
}
16.
}
This code shows that our system accepts only the first column to
be edited as shown by the test at line 4. It resets the old value in
case of error and displays the cause to the user. Of course, besides
changing the value in the GUI, the action must rename the object in
the MOR; this is the role of the method called handlerRename shown
here:
1. private void handlerRename(String iOldName,
2.
String iNewName) throws JDMException {
NamedObject lNamedObject getSelectedNamedObjectType();
3.
4.
mDmeConn.renameObject(iOldName, iNewName, lNamedObject);
5. }
The call to renameObject at line 4 asks the DME to perform the
operation in the MOR.
 
Search WWH ::




Custom Search