You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
SIPRP/trunk/siprp/ficha/FichaAptidaoEditorManager.java

212 lines
5.0 KiB

/*
* FichaAptidaoEditorManager.java
*
* Created on 30 de Março de 2004, 19:23
*/
package siprp.ficha;
import com.evolute.utils.editormanager.*;
/**
*
* @author fpalma
*/
public class FichaAptidaoEditorManager extends EditorManager
{
private static final EditorManagerFactory FACTORY = new FichaAptidaoEditorManagerFactory();
public static EditorManagerFactory getEditorManagerFactory()
{
return FACTORY;
}
/** Creates a new instance of FichaAptidaoEditorManager */
public FichaAptidaoEditorManager( Editor ed, int i )
{
super( ed, i );
}
/** Creates a new instance of FichaAptidaoEditorManager */
public FichaAptidaoEditorManager( Editor ed, int i, EditorManagerInterface subMan )
{
super( ed, i, subMan );
throw new RuntimeException( "FichaAptidaoEditorManager cannot have subManagers" );
}
/** Creates a new instance of FichaAptidaoEditorManager */
public FichaAptidaoEditorManager( Editor ed, int i, EditorManagerInterface subMan[] )
{
super( ed, i, subMan );
throw new RuntimeException( "FichaAptidaoEditorManager cannot have subManagers" );
}
public boolean isEditing()
{
if( state != STATE_UNSELECT )
{
return true;
}
return false;
}
public void enable()
{
// System.out.println( "EditorManager: enable " + this );
editor.enableComponents( index, false );
// new, edit, cancel, save, delete, select
editor.actions( index, true, false, false, false, false, true );
enabled = true;
}
public void disable()
{
// System.out.println( "EditorManager: disable " + this );
editor.clear( index );
editor.enableComponents( index, false );
// new, edit, cancel, save, delete, select
editor.actions( index, false, false, false, false, false, false );
enabled = false;
state = STATE_UNSELECT;
}
public void unlock(boolean direction)
{
editor.enableComponents( index, false );
if( enabled )
{
if( state == STATE_UNSELECT )
{
// new, edit, cancel, save, delete, select
editor.actions( index, true, false, false, false, false, true );
}
else
{
// new, edit, cancel, save, delete, select
editor.actions( index, true, true, false, false, true, true );
}
}
}
public void select()
{
// System.out.println( "EditorManager: select " + this );
// new, edit, cancel, save, delete, select
editor.actions( index, true, true, true, true, true, true );
state = STATE_EDIT;
}
public void unselect()
{
// System.out.println( "EditorManager: select " + this );
// new, edit, cancel, save, delete, select
editor.actions( index, true, false, false, false, false, true );
state = STATE_UNSELECT;
}
public void newItem()
{
// System.out.println( "EditorManager: new " + this );
switch( state )
{
case STATE_EDIT: case STATE_NEW:
saveItem();
break;
}
editor.enableComponents( index, true );
// new, edit, cancel, save, delete, select
editor.actions( index, false, false, true, true, true, false );
state = STATE_NEW;
}
public void cancelItem()
{
// System.out.println( "EditorManager: cancel " + this );
if( state == STATE_NEW )
{
editor.clear( index );
editor.enableComponents( index, false );
// new, edit, cancel, save, delete, select
editor.actions( index, true, false, false, false, false, true );
state = STATE_UNSELECT;
}
else if( state == STATE_EDIT )
{
editor.reload( index );
editor.enableComponents( index, true );
// new, edit, cancel, save, delete, select
editor.actions( index, true, true, true, true, true, true );
state = STATE_EDIT;
}
}
public void saveItem()
{
// System.out.println( "EditorManager: save " + this );
if( ! editor.save( index ) )
{
return;
}
editor.enableComponents( index, false );
// new, edit, cancel, save, delete, select
editor.actions( index, true, true, false, false, true, true );
state = STATE_EDIT;
}
public void deleteItem()
{
// System.out.println( "EditorManager: delete " + this );
if( editor.delete( index ) )
{
editor.clear( index );
editor.enableComponents( index, false );
// new, edit, cancel, save, delete, select
editor.actions( index, true, false, false, false, false, true );
state = STATE_UNSELECT;
}
}
public void refresh()
{
// System.out.println( "EditorManager: refresh " + this );
if( !enabled )
{
disable();
return;
}
switch( state )
{
case STATE_NEW:
editItem();
state = STATE_NEW;
break;
case STATE_EDIT:
editItem();
break;
case STATE_SELECT:
throw new RuntimeException( "FichaAptidaoEditorManager cannot be in STATE_SELECT" );
case STATE_UNSELECT:
enable();
break;
}
}
public void editItem()
{
state = STATE_EDIT;
editor.actions( index, false, false, true, true, true, false );
}
public void lock(boolean direction)
{
throw new RuntimeException( "lock cannot be called on FichaAptidaoEditorManager" );
}
public void registerMain(EditorManagerInterface mainMan)
{
throw new RuntimeException( "registerMain cannot be called on FichaAptidaoEditorManager" );
}
}