From e9d6d3fd03cf1553e4e1f34d628f99695d76f65b Mon Sep 17 00:00:00 2001 From: Frederico Palma Date: Wed, 31 Mar 2004 10:56:22 +0000 Subject: [PATCH] no message git-svn-id: https://svn.coded.pt/svn/SIPRP@15 bb69d46d-e84e-40c8-a05a-06db0d633741 --- .../ficha/FichaAptidaoEditorManager.java | 210 ++++++++++++++++++ .../FichaAptidaoEditorManagerFactory.java | 38 ++++ trunk/siprp/ficha/FichaWindow.java | 23 +- 3 files changed, 269 insertions(+), 2 deletions(-) create mode 100644 trunk/siprp/ficha/FichaAptidaoEditorManager.java create mode 100644 trunk/siprp/ficha/FichaAptidaoEditorManagerFactory.java diff --git a/trunk/siprp/ficha/FichaAptidaoEditorManager.java b/trunk/siprp/ficha/FichaAptidaoEditorManager.java new file mode 100644 index 00000000..624e5dde --- /dev/null +++ b/trunk/siprp/ficha/FichaAptidaoEditorManager.java @@ -0,0 +1,210 @@ +/* + * 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, true, 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, false ); + // new, edit, cancel, save, delete, select + editor.actions( index, true, true, false, false, 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, true, 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() + { + throw new RuntimeException( "editItem cannot be called on FichaAptidaoEditorManager" ); + } + + 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" ); + } + +} diff --git a/trunk/siprp/ficha/FichaAptidaoEditorManagerFactory.java b/trunk/siprp/ficha/FichaAptidaoEditorManagerFactory.java new file mode 100644 index 00000000..a626c7d2 --- /dev/null +++ b/trunk/siprp/ficha/FichaAptidaoEditorManagerFactory.java @@ -0,0 +1,38 @@ +/* + * FichaAptidaoEditorManagerFactory.java + * + * Created on 30 de Março de 2004, 20:48 + */ + +package siprp.ficha; + +import com.evolute.utils.editormanager.*; +/** + * + * @author fpalma + */ +public class FichaAptidaoEditorManagerFactory + implements EditorManagerFactory +{ + + /** Creates a new instance of FichaAptidaoEditorManagerFactory */ + public FichaAptidaoEditorManagerFactory() + { + } + + public EditorManagerInterface createEditorManager(Editor ed, int i) + { + return new FichaAptidaoEditorManager( ed, i ); + } + + public EditorManagerInterface createEditorManager(Editor ed, int i, EditorManagerInterface[] subMan) + { + return new FichaAptidaoEditorManager( ed, i, subMan ); + } + + public EditorManagerInterface createEditorManager(Editor ed, int i, EditorManagerInterface subMan) + { + return new FichaAptidaoEditorManager( ed, i, subMan ); + } + +} diff --git a/trunk/siprp/ficha/FichaWindow.java b/trunk/siprp/ficha/FichaWindow.java index 72170d08..4976fbe1 100644 --- a/trunk/siprp/ficha/FichaWindow.java +++ b/trunk/siprp/ficha/FichaWindow.java @@ -23,7 +23,7 @@ public class FichaWindow extends TabbedWindow private ExamePanel examePanel; private static int permissions[][] = - new int[][]{ { NEW_INDEX, CANCEL_INDEX, SAVE_INDEX, DELETE_INDEX, SELECT_BYNAME_INDEX } }; + new int[][]{ { NEW_INDEX, CANCEL_INDEX, SAVE_INDEX, DELETE_INDEX } }; /** Creates a new instance of FichaWindow */ public FichaWindow() @@ -31,6 +31,7 @@ public class FichaWindow extends TabbedWindow { super( new UpperPanel(), new String[]{ "Empresa/Trabalhador", "Exame" }, createPermissions( permissions ) ); + setEditorManagerFactory( FichaAptidaoEditorManager.getEditorManagerFactory() ); upperPanel = (UpperPanel) getUpperPanel(); setupComponents(); } @@ -95,6 +96,24 @@ public class FichaWindow extends TabbedWindow examePanel = new ExamePanel(); gridbag.setConstraints( examePanel, constraints ); exameRecomendacoesPanel.add( examePanel ); - + } + + public boolean save( int index ) + { + return true; + } + + public boolean newItem( int index ) + { + return true; + } + + public boolean delete( int index ) + { + return true; + } + + public void reload( int index ) + { } }