Listing of Source terminal/TerminalCutCopyParsing.javapackage se.entra.phantom.server;
/**
* This class handles the Terminal Cut/Copy parsing option
* of the panel CUTCOPY.
*/
public class TerminalCutCopyParsing extends VirtualComponentAdapter
{
/**
* Called to initialize the panel before it is displayed.
*
* <p>This function doesn't perform anything.
*/
@Override
public void onPanelCreate(VirtualPanel vp)
{
TerminalSettings ts=vp.getVirtualSessionManager().getTerminalFunctions().settings;
if ( ts.cutCopyParsing==1 ) vp.setChecked("WORD" ,1);
else if ( ts.cutCopyParsing==2 ) vp.setChecked("DATAONLY",1);
else vp.setChecked("FIELD" ,1);
}
/**
* Called to inform the listener that the panel is destroyed.
* Here, we enable all menu items in the main terminal
* panel.
*/
@Override
public void onPanelDestroy(VirtualPanel vp)
{
TerminalApplication ta=vp.getVirtualSessionManager().getTerminalApplication();
if ( ta!=null )
ta.enableTopMenuItems(true);
}
/**
* Push buttons and menu items generates this event when selected.
*/
@Override
public void onAction(VirtualPanel vp,String controlID)
{
if ( controlID.equals("CANCEL" ) ) close(vp);
else if ( controlID.equals("OK" ) ) performOK(vp);
else System.out.println("#TerminalCutCopyParsing, Command ID "+controlID+" not handled");
}
/**
* Closes this panel.
*/
private void close(VirtualPanel vp)
{
vp.dismissPanel(1);
}
/**
* Called when the close button of a panel is pressed,
* but before any other processing has been done. If this
* function returns false, the application close object
* will be called (if defined), otherwise a faked keypress
* of the Escape key is performed. If these two actions
* failed (because there is no close object or no button or
* menu item is connected to the Escape key), then the
* function <code>onPanelClose</code> is called.
*
* @return true to cancel all default processing.
*/
@Override
public boolean onPanelClosing(VirtualPanel vp)
{
close(vp);
return true;
}
/**
* Performs the OK change.
*/
public void performOK(VirtualPanel vp)
{
TerminalFunctions tf=vp.getVirtualSessionManager().getTerminalFunctions();
TerminalSettings ts=tf.settings;
if ( vp.isChecked("DATAONLY")!=0 ) ts.cutCopyParsing=2;
else if ( vp.isChecked("WORD" )!=0 ) ts.cutCopyParsing=1;
else ts.cutCopyParsing=0;
tf.updateClientTerminalSettings();
// Save the changes.
String err=tf.saveClientProperties();
if ( err==null )
{
// Remove panel.
vp.dismissPanel(0);
return;
}
// Log the event.
EventManager.logEvent(null,err,EventID.EVENTCLASS_ERROR);
}
}