From 01b3b5cc54fa6a689197a87eec590eaa7b12c7f4 Mon Sep 17 00:00:00 2001 From: Willem Cazander Date: Mon, 26 Nov 2012 16:08:45 +0100 Subject: [PATCH] made first demo almost fully working --- src/site/apt/features.apt | 72 +-- .../metamodel/MetaModelSchemaAutoEntry.java | 196 +++++-- .../SchemaAutoEntryElementConfigurator.java | 3 +- .../vasc/ejb3/VascServiceRemoteBackend.java | 227 ++++++++ .../vasc/ejb3/VascServiceManagerImpl.java | 147 +++--- .../AbstractVascEntryControllerLocal.java | 74 ++- .../core/AbstractVascEntryGroupLocal.java | 50 ++ .../vasc/core/AbstractVascEntryLinkLocal.java | 12 +- .../vasc/core/AbstractVascEntryLocal.java | 38 +- .../net/forwardfire/vasc/core/VascEntry.java | 7 + .../vasc/core/VascEntryAccessType.java | 28 +- .../vasc/core/VascEntryController.java | 6 + .../vasc/core/VascEntryControllerLocal.java | 2 + .../forwardfire/vasc/core/VascEntryGroup.java | 35 ++ .../vasc/core/VascEntryGroupLocal.java | 41 ++ .../forwardfire/vasc/core/VascEntryLink.java | 2 +- .../vasc/core/VascEntryLinkLocal.java | 2 +- .../forwardfire/vasc/core/VascEntryLocal.java | 15 +- .../vasc/impl/DefaultVascEntryGroup.java | 36 ++ .../entry/config/VascDefaultsFinalizer.java | 4 +- .../frontend/DefaultVascFrontendHelper.java | 2 +- .../impl/jndi/JndiVascControllerFactory.java | 10 + .../x4o/VascEntryElementConfigurator.java | 15 +- .../resources/META-INF/vasc/vasc-lang.eld | 6 + vasc-demo/vasc-demo-server/pom.xml | 1 + .../.project | 17 + .../pom.xml | 42 ++ .../src/main/assembly/bin.xml | 48 ++ .../src/main/scripts/client.bat | 38 ++ .../src/main/scripts/client.sh} | 4 +- .../vasc-demo-server-build/pom.xml | 6 + .../src/main/assembly/bin.xml | 9 +- .../src/main/directory/conf/server.xml | 12 +- .../conf/{server-tech => vasc.d}/demo-csv.xml | 15 +- .../auto-pg.xml => vasc.d/demo-pg.xml} | 6 - .../conf/{server-tech => vasc.d}/readme.txt | 0 .../manager.xml => vasc.d/tech-admin.xml} | 45 +- .../tech-server.xml} | 15 +- .../main/scripts/{run.bat => shutdown.bat} | 5 +- .../src/main/scripts/shutdown.sh | 38 ++ .../src/main/scripts/startup.bat | 39 ++ .../src/main/scripts/startup.sh | 39 ++ .../vasc-demo-server-core/pom.xml | 6 +- .../demo/server/core/VascTechDemoStartup.java | 1 + .../core/service/VascControllerService.java | 26 + .../demo/server/tomcat/TomcatService.java | 2 - .../vasc/demo/server/ui/JConsolePanel.java | 86 +-- .../vasc/demo/server/ui/JFireBorder.java | 148 ++++++ .../vasc/demo/server/ui/JStartupPanel.java | 20 - .../vasc/demo/server/ui/JStatusPanel.java | 499 ++++++++++-------- .../demo/server/ui/ServerGuiApplication.java | 172 ++++-- .../vasc/demo/server/ui/load/JLoadDialog.java | 241 +++++++++ .../JLoadStepMetaCsv.java} | 24 +- .../JLoadStepMetaJdbc.java} | 108 ++-- .../JLoadStepMetaMongodb.java} | 108 ++-- .../server/ui/load/JLoadStepMiscInfo.java | 98 ++++ .../server/ui/load/JLoadStepSelectTables.java | 180 +++++++ .../server/ui/load/JLoadStepWriteFile.java | 118 +++++ .../vasc/demo/server/ui/load/LoadStep.java} | 38 +- .../demo/server/ui/load/LoadStepData.java | 50 ++ .../server/ui/load/LoadVascXmlWriter.java | 242 +++++++++ .../server/core/service/resources/init-db.sql | 37 -- .../resources/ServerGuiApplication.properties | 2 +- .../vasc/demo/server/ui/resources/icon.png | Bin 0 -> 264 bytes .../server/ui/resources/laf-colors.properties | 12 + .../demo/server/ui/resources/tray-icon.png | Bin 644 -> 400 bytes .../vasc-demo-tech-client-swing/pom.xml | 5 + .../vasc/demo/client/swing/JMainPanel.java | 250 +-------- .../demo/client/swing/JMainPanelMenuBar.java | 128 +---- .../client/swing/VascDemoSwingClient.java | 324 ++++-------- .../client/swing/VascDemoUserLoginDialog.java | 334 ++++-------- .../main/resources/META-INF/client.login.conf | 6 - .../resources/META-INF/root-bundle.properties | 13 + .../resources/VascDemoSwingClient.properties | 32 ++ .../vasc-demo-tech-ejb3/pom.xml | 30 +- .../ejb3/menu/VascMenuControllerImpl.java | 141 ++--- .../demo/tech/ejb3/menu/model/VascMenu.java | 94 +--- .../tech/ejb3/menu/model/VascMenuGroup.java | 67 +-- .../tech/ejb3/user/ClientUserController.java | 22 + ...mpl.java => ClientUserControllerImpl.java} | 29 +- ...al.java => ClientUserControllerLocal.java} | 2 +- ...e.java => ClientUserControllerRemote.java} | 2 +- .../tech/ejb3/user/LoginUserController.java | 21 - .../vasc-demo-tech/vasc-demo-tech-web/pom.xml | 16 +- .../demo/tech/web/beans/UserController.java | 2 +- .../src/main/webapp/WEB-INF/ejb-jar.xml | 8 +- .../template/structure/main-body-menu.xhtml | 4 +- .../AbstractJSFVascFacesControllerEJB.java | 185 +------ .../lib/i18n/MergeableResourceBundle.java | 9 + .../i18n/bundle/RootApplicationBundle_by.java | 3 +- .../i18n/bundle/RootApplicationBundle_da.java | 3 +- .../i18n/bundle/RootApplicationBundle_de.java | 3 +- .../i18n/bundle/RootApplicationBundle_en.java | 3 +- .../i18n/bundle/RootApplicationBundle_es.java | 3 +- .../i18n/bundle/RootApplicationBundle_fr.java | 3 +- .../i18n/bundle/RootApplicationBundle_it.java | 3 +- .../i18n/bundle/RootApplicationBundle_nl.java | 3 +- .../i18n/bundle/RootApplicationBundle_pl.java | 3 +- .../i18n/bundle/RootApplicationBundle_pt.java | 3 +- .../i18n/bundle/RootApplicationBundle_ro.java | 3 +- .../i18n/bundle/RootApplicationBundle_ru.java | 3 +- .../i18n/bundle/RootApplicationBundle_sv.java | 3 +- .../lib/i18n/config/BundleConfigParser.java | 30 +- .../test/i18n/VascBundleCheckEntryKeys.java | 20 + 104 files changed, 3259 insertions(+), 2181 deletions(-) create mode 100644 vasc-core-ejb3-client/src/main/java/net/forwardfire/vasc/ejb3/VascServiceRemoteBackend.java create mode 100644 vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryGroupLocal.java rename vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuComparator.java => vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryAccessType.java (70%) create mode 100644 vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryGroup.java create mode 100644 vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryGroupLocal.java create mode 100644 vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryGroup.java create mode 100644 vasc-demo/vasc-demo-server/vasc-demo-server-build-client-swing/.project create mode 100644 vasc-demo/vasc-demo-server/vasc-demo-server-build-client-swing/pom.xml create mode 100644 vasc-demo/vasc-demo-server/vasc-demo-server-build-client-swing/src/main/assembly/bin.xml create mode 100644 vasc-demo/vasc-demo-server/vasc-demo-server-build-client-swing/src/main/scripts/client.bat rename vasc-demo/vasc-demo-server/{vasc-demo-server-build/src/main/scripts/run.sh => vasc-demo-server-build-client-swing/src/main/scripts/client.sh} (92%) rename vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/directory/conf/{server-tech => vasc.d}/demo-csv.xml (80%) rename vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/directory/conf/{server-tech/auto-pg.xml => vasc.d/demo-pg.xml} (98%) rename vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/directory/conf/{server-tech => vasc.d}/readme.txt (100%) rename vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/directory/conf/{server-tech/manager.xml => vasc.d/tech-admin.xml} (75%) rename vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/directory/conf/{server-admin/server-files.xml => vasc.d/tech-server.xml} (77%) rename vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/scripts/{run.bat => shutdown.bat} (92%) create mode 100644 vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/scripts/shutdown.sh create mode 100644 vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/scripts/startup.bat create mode 100644 vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/scripts/startup.sh create mode 100644 vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/JFireBorder.java delete mode 100644 vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/JStartupPanel.java create mode 100644 vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadDialog.java rename vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/{actions/JDialogMetaCsv.java => load/JLoadStepMetaCsv.java} (83%) rename vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/{actions/JDialogMetaJdbc.java => load/JLoadStepMetaJdbc.java} (54%) rename vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/{actions/JDialogMetaMongodb.java => load/JLoadStepMetaMongodb.java} (52%) create mode 100644 vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadStepMiscInfo.java create mode 100644 vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadStepSelectTables.java create mode 100644 vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadStepWriteFile.java rename vasc-demo/{vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuGroupComparator.java => vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/LoadStep.java} (68%) create mode 100644 vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/LoadStepData.java create mode 100644 vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/LoadVascXmlWriter.java create mode 100644 vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/resources/net/forwardfire/vasc/demo/server/ui/resources/icon.png create mode 100644 vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/resources/net/forwardfire/vasc/demo/server/ui/resources/laf-colors.properties delete mode 100644 vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/META-INF/client.login.conf create mode 100644 vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/META-INF/root-bundle.properties create mode 100644 vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/net/forwardfire/vasc/demo/client/swing/resources/VascDemoSwingClient.properties create mode 100644 vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/ClientUserController.java rename vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/{LoginUserControllerImpl.java => ClientUserControllerImpl.java} (59%) rename vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/{LoginUserControllerLocal.java => ClientUserControllerLocal.java} (54%) rename vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/{LoginUserControllerRemote.java => ClientUserControllerRemote.java} (54%) delete mode 100644 vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/LoginUserController.java diff --git a/src/site/apt/features.apt b/src/site/apt/features.apt index dc9e8d1..208f5d6 100644 --- a/src/site/apt/features.apt +++ b/src/site/apt/features.apt @@ -58,8 +58,8 @@ zie tables statline.cbs.nl voor bs asielverzoeken nl - Extjs - Swing - WS - - SWT via SwingWT - - JSF (met utr plugin) + - SWT + - JSF @@ -167,34 +167,6 @@ public class BlogPost { - - vasc - - admin=true - backend=extjs - path=/js/extjs/* - - - vasc - /vasc/* - - - -EmployeeDataSource dataSource = new EmployeeDataSource(); -dataSource.setJdbcTemplate(new JdbcTemplate(employeeDataSource())); - FilteringPaginator filteringPaginator = new FilteringPaginator(dataSource, EmployeeReportObject.class); - JsfCrudAdapter adapter = new JsfCrudAdapter(filteringPaginator, (CrudController)empCrud().getController()){ - public Serializable getEntity() { - Object object = ((Row)getModel().getRowData()).getObject(); - EmployeeReportObject employeeReportObject = (EmployeeReportObject) object; - Employee employee = new Employee(); - employee.setId(employeeReportObject.getId()); - return employee; - } - }; - - return adapter; - EVt; @@ -223,46 +195,8 @@ EVt; -@SuppressWarnings({ "unchecked", "serial" }) -@Bean(scope = DefaultScopes.SESSION) -public JsfCrudAdapter empRecordCrud() { - EmployeeDataSource dataSource = new EmployeeDataSource(); - dataSource.setJdbcTemplate(new JdbcTemplate(employeeDataSource())); - FilteringPaginator filteringPaginator = new FilteringPaginator(dataSource, EmployeeReportObject.class); - JsfCrudAdapter adapter = new JsfCrudAdapter(filteringPaginator, (CrudController)empCrud().getController()){ - public Serializable getEntity() { - Object object = ((Row)getModel().getRowData()).getObject(); - EmployeeReportObject employeeReportObject = (EmployeeReportObject) object; - Employee employee = new Employee(); - employee.setId(employeeReportObject.getId()); - return employee; - } - }; - - return adapter; -} - - - - - - - - - - - - - - tables = null; private String tableInclude = null; private String tableExclude = null; private String entryPrefix = null; + private String vascGroupId = null; + + private Map resultEntries = null; + private Map resultEntryGroups = null; + private Map resultBackends = null; public MetaModelSchemaAutoEntry() { logger = Logger.getLogger(MetaModelSchemaAutoEntry.class.getName()); + tables = new ArrayList(); + resultEntries = new HashMap(); + resultEntryGroups = new HashMap(); + resultBackends = new HashMap(); } - public void autoCreateEntries(VascController vascController) { + public void autoFillResult(VascController vascController) { if (getDataContextProvider()==null) { throw new NullPointerException("Can't auto create entries with null dataContextProvider."); } @@ -72,6 +90,10 @@ public class MetaModelSchemaAutoEntry { DataContext ds = getDataContextProvider().getDataContext(); for (String table:ds.getDefaultSchema().getTableNames()) { + if (tables.isEmpty()==false && tables.contains(table)==false) { + logger.finer("Excluding table: "+table+" because not in table list."); + continue; + } if (getTableInclude()!=null && table.matches(getTableInclude())==false) { logger.finer("Excluding table: "+table+" from include rule."); continue; @@ -84,10 +106,22 @@ public class MetaModelSchemaAutoEntry { } } + public void autoAddResultToController() { + for (VascBackend backend:resultBackends.values()) { + ((VascBackendControllerLocal)getVascController().getVascBackendController()).addVascBackend(backend); + } + for (VascEntryLocal ve:resultEntries.values()) { + ((VascEntryControllerLocal)getVascController().getVascEntryController()).addVascEntry(ve); + } + for (VascEntryGroupLocal veg:resultEntryGroups.values()) { + ((VascEntryControllerLocal)getVascController().getVascEntryController()).addVascEntryGroup(veg); + } + } + private VascController getVascController() { return vascController; } - + private void createMetaEntry(DataContext ds,String id,String tableName) { logger.fine("Creating entry id: "+id+" of table: "+tableName); Table metaTable = null; @@ -117,28 +151,28 @@ public class MetaModelSchemaAutoEntry { ve.setId(id); ve.setBackendId(id+"_backend"); ve.setPrimaryKeyFieldId(backend.getTableId()); + ve.setVascGroupId(getVascGroupId()); createFields(ve,cols); for (Relationship rs:metaTable.getRelationships()) { logger.finer("Found relation FT: "+rs.getForeignTable().getName()+" PT: "+rs.getPrimaryTable().getName()); if (tableName.equals(rs.getForeignTable().getName())==false) { logger.finer("Creating Link entry for: "+rs.getForeignColumns()[0].getName()+" of table: "+rs.getForeignTable().getName()); - createLinkEntry(rs,ve,metaTable,id+"_"+rs.getForeignTable().getName()+"_"+rs.getForeignColumns()[0].getName()+"_link"); + createLinkEntry(rs,ve,metaTable); + //createLinkEntry(rs,ve,metaTable,id+"_"+rs.getForeignTable().getName()+"_"+rs.getForeignColumns()[0].getName()+"_link"); } else { logger.finer("Creating List entry for: "+rs.getPrimaryColumns()[0].getName()+" of table: "+rs.getPrimaryTable().getName()); - createListEntry(rs,ve,metaTable,id+"_"+rs.getPrimaryTable().getName()+"_"+rs.getPrimaryColumns()[0].getName()+"_list"); + createListEntry(rs,ve,metaTable); + //createListEntry(rs,ve,metaTable,id+"_"+rs.getPrimaryTable().getName()+"_"+rs.getPrimaryColumns()[0].getName()+"_list"); } } - try { - ((VascBackendControllerLocal)getVascController().getVascBackendController()).addVascBackend(backend); - ((VascEntryControllerLocal)getVascController().getVascEntryController()).addVascEntry(ve); - } catch (Exception ee) { - ee.printStackTrace(); - } + resultBackends.put(backend.getId(),backend); + resultEntries.put(ve.getId(),ve); } - private void createLinkEntry(Relationship rs2,VascEntryLocal ve,Table metaTable,String id) { + private void createLinkEntry(Relationship rs2,VascEntryLocal ve,Table metaTable) { + String id = getEntryPrefix()+"_"+metaTable.getName()+"_link"; MetaModelVascBackend backendLink = new MetaModelVascBackend(); backendLink.setId(id+"_backend"); backendLink.setDataContextProvider(getDataContextProvider()); @@ -159,6 +193,8 @@ public class MetaModelSchemaAutoEntry { veLink.setId(id); veLink.setBackendId(id+"_backend"); veLink.setPrimaryKeyFieldId(backendLink.getTableId()); + veLink.setVascGroupId(getVascGroupId()); + veLink.setAccessType(VascEntryAccessType.ENTRY_LIST); createFields(veLink,cols); for (Relationship rs:rs2.getForeignTable().getRelationships()) { @@ -168,32 +204,31 @@ public class MetaModelSchemaAutoEntry { //createLinkEntry(rs,ve,rs2.getForeignTable(),id+"_"+rs.getForeignTable().getName()+"_"+rs.getForeignColumns()[0].getName()+"_link"); } else { logger.fine("Creating List entry for: "+rs.getPrimaryColumns()[0].getName()+" of table: "+rs.getPrimaryTable().getName()); - createListEntry(rs,veLink,rs2.getForeignTable(),id+"_"+rs.getPrimaryTable().getName()+"_"+rs.getPrimaryColumns()[0].getName()+"_list"); + createListEntry(rs,veLink,rs2.getForeignTable()); + //createListEntry(rs,veLink,rs2.getForeignTable(),id+"_"+rs.getPrimaryTable().getName()+"_"+rs.getPrimaryColumns()[0].getName()+"_list"); } } - try { - ((VascBackendControllerLocal)getVascController().getVascBackendController()).addVascBackend(backendLink); - ((VascEntryControllerLocal)getVascController().getVascEntryController()).addVascEntry(veLink); - - DefaultVascEntryLink vle = new DefaultVascEntryLink(); - vle.setId(id+"Link"); - vle.setVascLinkEntryType(VascEntryLinkType.DEFAULT_TYPE); - vle.setVascEntryId(id); - vle.addEntryParameterFieldId(rs2.getForeignColumns()[0].getName(), rs2.getPrimaryColumns()[0].getName()); - - ve.addVascEntryLink(vle); - - } catch (Exception e) { - e.printStackTrace(); + if (resultBackends.containsKey(backendLink.getId())==false) { + resultBackends.put(backendLink.getId(),backendLink); + resultEntries.put(veLink.getId(),veLink); } + + DefaultVascEntryLink vle = new DefaultVascEntryLink(); + vle.setId(id+"Link"); + vle.setVascEntryLinkType(VascEntryLinkType.DEFAULT_TYPE); + vle.setVascEntryId(id); + vle.addEntryParameterFieldId(rs2.getForeignColumns()[0].getName(), rs2.getPrimaryColumns()[0].getName()); + + ve.addVascEntryLink(vle); } - private void createListEntry(Relationship rs,VascEntry ve,Table metaTable,String id) { - MetaModelVascBackend backendLink = new MetaModelVascBackend(); - backendLink.setId(id+"_backend"); - backendLink.setDataContextProvider(getDataContextProvider()); - backendLink.setTable(rs.getPrimaryTable().getName()); + private void createListEntry(Relationship rs,VascEntry ve,Table metaTable) { + String id = getEntryPrefix()+"_"+metaTable.getName()+"_list"; + MetaModelVascBackend backendList = new MetaModelVascBackend(); + backendList.setId(id+"_backend"); + backendList.setDataContextProvider(getDataContextProvider()); + backendList.setTable(rs.getPrimaryTable().getName()); Column[] keys = rs.getPrimaryTable().getPrimaryKeys(); Column[] cols = rs.getPrimaryTable().getColumns(); @@ -201,33 +236,35 @@ public class MetaModelSchemaAutoEntry { return; } if (keys.length>0) { - backendLink.setTableId(keys[0].getName()); + backendList.setTableId(keys[0].getName()); } else { - backendLink.setTableId(cols[0].getName()); + backendList.setTableId(cols[0].getName()); } - DefaultVascEntry veLink = new DefaultVascEntry(); - veLink.setId(id); - veLink.setBackendId(id+"_backend"); - veLink.setPrimaryKeyFieldId(backendLink.getTableId()); - createFields(veLink,cols); - try { - VascEntryFieldLocal vef = (VascEntryFieldLocal)ve.getVascEntryFieldById(rs.getForeignColumns()[0].getName()); - if (vef==null) { - logger.warning("Could not find: "+rs.getForeignColumns()[0].getName()+" in ve: "+ve.getId()); - return; - } - vef.setVascEntryFieldType(getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeById("ListField")); - - VascSelectItemModelEntry itemModel = new VascSelectItemModelEntry(); - itemModel.setEntryId(veLink.getId()); - itemModel.setDisplayFieldId(veLink.getDisplayNameFieldId()); - vef.getVascEntryFieldType().setDataObject(itemModel); - - ((VascBackendControllerLocal)getVascController().getVascBackendController()).addVascBackend(backendLink); - ((VascEntryControllerLocal)getVascController().getVascEntryController()).addVascEntry(veLink); - } catch (Exception e) { - e.printStackTrace(); + DefaultVascEntry veList = new DefaultVascEntry(); + veList.setId(id); + veList.setBackendId(id+"_backend"); + veList.setPrimaryKeyFieldId(backendList.getTableId()); + veList.setVascGroupId(getVascGroupId()); + veList.setAccessType(VascEntryAccessType.ENTRY_LIST); + createFields(veList,cols); + + if (resultBackends.containsKey(backendList.getId())==false) { + resultBackends.put(backendList.getId(),backendList); + resultEntries.put(veList.getId(),veList); } + + VascEntryFieldLocal vef = (VascEntryFieldLocal)ve.getVascEntryFieldById(rs.getForeignColumns()[0].getName()); + if (vef==null) { + logger.warning("Could not find: "+rs.getForeignColumns()[0].getName()+" in ve: "+ve.getId()); + return; + } + vef.setVascEntryFieldType(getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeById("ListField")); + + VascSelectItemModelEntry itemModel = new VascSelectItemModelEntry(); + itemModel.setEntryId(veList.getId()); + itemModel.setDisplayFieldId(veList.getDisplayNameFieldId()); + vef.getVascEntryFieldType().setDataObject(itemModel); + } private void createFields(VascEntryLocal ve,Column[] cols) { @@ -317,4 +354,53 @@ public class MetaModelSchemaAutoEntry { public void setEntryPrefix(String entryPrefix) { this.entryPrefix = entryPrefix; } + + /** + * @return the vascGroupId + */ + public String getVascGroupId() { + return vascGroupId; + } + + /** + * @param vascGroupId the vascGroupId to set + */ + public void setVascGroupId(String vascGroupId) { + this.vascGroupId = vascGroupId; + } + + /** + * @return the resultEntries + */ + public Collection getResultEntries() { + return resultEntries.values(); + } + + /** + * @return the resultEntryGroups + */ + public Collection getResultEntryGroups() { + return resultEntryGroups.values(); + } + + /** + * @return the resultBackends + */ + public Collection getResultBackends() { + return resultBackends.values(); + } + + /** + * @return the tables + */ + public List getTables() { + return tables; + } + + public void addTable(String table) { + tables.add(table); + } + public void removeTable(String table) { + tables.remove(table); + } } diff --git a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/x4o/SchemaAutoEntryElementConfigurator.java b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/x4o/SchemaAutoEntryElementConfigurator.java index e8541a6..9dd4ede 100644 --- a/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/x4o/SchemaAutoEntryElementConfigurator.java +++ b/vasc-backend/vasc-backend-metamodel/src/main/java/net/forwardfire/vasc/backend/metamodel/x4o/SchemaAutoEntryElementConfigurator.java @@ -51,6 +51,7 @@ public class SchemaAutoEntryElementConfigurator extends AbstractElementConfigura } MetaModelSchemaAutoEntry autoEntry = (MetaModelSchemaAutoEntry)element.getElementObject(); VascController vascController = VascParser.getVascController(element.getElementLanguage()); - autoEntry.autoCreateEntries(vascController); + autoEntry.autoFillResult(vascController); + autoEntry.autoAddResultToController(); } } diff --git a/vasc-core-ejb3-client/src/main/java/net/forwardfire/vasc/ejb3/VascServiceRemoteBackend.java b/vasc-core-ejb3-client/src/main/java/net/forwardfire/vasc/ejb3/VascServiceRemoteBackend.java new file mode 100644 index 0000000..7f5b80c --- /dev/null +++ b/vasc-core-ejb3-client/src/main/java/net/forwardfire/vasc/ejb3/VascServiceRemoteBackend.java @@ -0,0 +1,227 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.ejb3; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; +import java.util.List; +import java.util.Map; + +import net.forwardfire.vasc.backend.VascBackend; +import net.forwardfire.vasc.backend.VascBackendState; +import net.forwardfire.vasc.core.VascEntry; +import net.forwardfire.vasc.core.VascEntryField; +import net.forwardfire.vasc.core.VascEntryFieldLocal; +import net.forwardfire.vasc.core.VascEntryLocal; +import net.forwardfire.vasc.core.VascException; +import net.forwardfire.vasc.core.entry.VascEntryFieldValue; +import net.forwardfire.vasc.core.entry.VascEntryRecordCreator; + +/** + * VascServiceRemoteBackend wraps VascBasckend to the ejb3 context. + * + * @author Willem Cazander + * @version 1.0 18 Nov 2012 + */ +public class VascServiceRemoteBackend implements VascBackend { + + private String backendId = null; + private VascServiceManager vascManager = null; + + public VascServiceRemoteBackend(VascServiceManager vascManager,String backendId) { + if (vascManager==null) { + throw new NullPointerException("Can't be remote backend on null VascServiceManager."); + } + if (backendId==null) { + throw new NullPointerException("Can't be remote backend on null backendId."); + } + this.vascManager=vascManager; + this.backendId=backendId; + + } + + public void startBackend() { + } + public void stopBackend() { + } + + public String getId() { + return backendId; + } + + public void setId(String id) { + // we cant change id + } + + public void delete(Object object) throws VascException { + Object[] args = new Object[1]; + args[0]=object; + vascManager.invokeBackendMethod(backendId, "delete", args); + } + + public long doRecordMoveDownById(VascBackendState state,Object primaryId) throws VascException { + Object[] args = new Object[2]; + args[0]=state; + args[1]=primaryId; + Object result = vascManager.invokeBackendMethod(backendId, "doRecordMoveDownById", args); + return (Long)result; + } + + public long doRecordMoveUpById(VascBackendState state, Object primaryId) throws VascException { + Object[] args = new Object[2]; + args[0]=state; + args[1]=primaryId; + Object result = vascManager.invokeBackendMethod(backendId, "doRecordMoveUpById", args); + return (Long)result; + } + + @SuppressWarnings("unchecked") + public List execute(VascBackendState state) throws VascException { + Object[] args = new Object[1]; + args[0]=state; + Object result = vascManager.invokeBackendMethod(backendId, "execute", args); + return (List)result; + } + + public long fetchTotalExecuteSize(VascBackendState state) { + Object[] args = new Object[1]; + args[0]=state; + Object result = vascManager.invokeBackendMethod(backendId, "fetchTotalExecuteSize", args); + return (Long)result; + } + + public boolean isPageable() { + Object[] args = new Object[0]; + Object result = vascManager.invokeBackendMethod(backendId, "isPageable", args); + return (Boolean)result; + } + + public boolean isRecordMoveable() { + Object[] args = new Object[0]; + Object result = vascManager.invokeBackendMethod(backendId, "isRecordMoveable", args); + return (Boolean)result; + } + + public boolean isSearchable() { + Object[] args = new Object[0]; + Object result = vascManager.invokeBackendMethod(backendId, "isSearchable", args); + return (Boolean)result; + } + + public boolean isSortable() { + Object[] args = new Object[0]; + Object result = vascManager.invokeBackendMethod(backendId, "isSortable", args); + return (Boolean)result; + } + + public Object merge(Object object) throws VascException { + Object[] args = new Object[1]; + args[0]=object; + Object result = vascManager.invokeBackendMethod(backendId, "merge", args); + return result; + } + + public void persist(Object object) throws VascException { + Object[] args = new Object[1]; + args[0]=object; + vascManager.invokeBackendMethod(backendId, "delete", args); + } + + public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) { + try { + field = ((VascEntryFieldLocal)field).clone(); // RM... + + ByteArrayOutputStream dataArray = new ByteArrayOutputStream(256); // it grows when needed + ObjectOutputStream objOutstream = new ObjectOutputStream(dataArray); + objOutstream.writeObject(field); + objOutstream.close(); + int objectSize = dataArray.size(); + System.out.println("Writing obj to field: "+objectSize); + } catch (Exception e) { + throw new RuntimeException(e); + } + Object[] args = new Object[1]; + args[0]=field; + Object result = vascManager.invokeBackendMethod(backendId, "provideVascEntryFieldValue", args); + return (VascEntryFieldValue)result; + } + + public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) { + VascEntryLocal clone = null; + try { + clone = ((VascEntryLocal)vascEntry).clone(); + clone.setVascFrontendController(null); + clone.setVascEntryFieldEventChannel(null); + } catch (CloneNotSupportedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + try { + ByteArrayOutputStream dataArray = new ByteArrayOutputStream(256); // it grows when needed + ObjectOutputStream objOutstream = new ObjectOutputStream(dataArray); + objOutstream.writeObject(clone); + objOutstream.close(); + //int objectSize = dataArray.size(); + //System.out.println("Writing obj to entry: "+objectSize); + } catch (IOException e) { + throw new RuntimeException(e); + } + Object[] args = new Object[1]; + args[0]=clone; + Object result = vascManager.invokeBackendMethod(backendId, "provideVascEntryRecordCreator", args); + return (VascEntryRecordCreator)result; + } + + @SuppressWarnings("unchecked") + public Map executePageSummary() { + Object[] args = new Object[0]; + Object result = vascManager.invokeBackendMethod(backendId, "executePageSummary", args); + return (Map)result; + } + + @SuppressWarnings("unchecked") + public Map executeTotalSummary() { + Object[] args = new Object[0]; + Object result = vascManager.invokeBackendMethod(backendId, "executeTotalSummary", args); + return (Map)result; + } + + public boolean isPageSummary() { + Object[] args = new Object[0]; + Object result = vascManager.invokeBackendMethod(backendId, "isPageSummary", args); + return (Boolean)result; + } + + public boolean isTotalSummary() { + Object[] args = new Object[0]; + Object result = vascManager.invokeBackendMethod(backendId, "isTotalSummary", args); + return (Boolean)result; + } + + public boolean isReadOnly() { + Object[] args = new Object[0]; + Object result = vascManager.invokeBackendMethod(backendId, "isReadOnly", args); + return (Boolean)result; + } +} diff --git a/vasc-core-ejb3-server/src/main/java/net/forwardfire/vasc/ejb3/VascServiceManagerImpl.java b/vasc-core-ejb3-server/src/main/java/net/forwardfire/vasc/ejb3/VascServiceManagerImpl.java index 1594670..bdd23e4 100644 --- a/vasc-core-ejb3-server/src/main/java/net/forwardfire/vasc/ejb3/VascServiceManagerImpl.java +++ b/vasc-core-ejb3-server/src/main/java/net/forwardfire/vasc/ejb3/VascServiceManagerImpl.java @@ -98,40 +98,28 @@ public class VascServiceManagerImpl implements VascServiceManagerRemote,VascServ // resourceBundle = ResourceBundle.getBundle(value); //} } - /* - if (entityManager==null) { - new NullPointerException("Have no entityManager"); - } - if (xpqlController==null) { - new NullPointerException("Have no xpqlController"); - }*/ - //if (resourceBundle==null) { - // new NullPointerException("Have no resourceBundle"); - //} long s = System.currentTimeMillis(); - + // get local jvm plugging controller if (vascController==null) { vascController = DefaultVascFactory.getDefaultVascController(); } - - for (String key:keys.keySet()) { - String value = keys.get(key); - if (key.startsWith("load")) { - // TODO made reuse working. - VascParser vp = new VascParser(vascController); - if (xpqlController!=null) { - vp.addELBean("xpqlController", new XpqlController()); - } - if (entityManager!=null) { - vp.addELBean("entityManagerProvider", new LocalEntityManagerProvider()); - } - vp.parseResource(value); - } - } - DefaultVascFactory.fillVascControllerLocalEntries((VascEntryControllerLocal) vascController.getVascEntryController(), vascController); - - + for (String key:keys.keySet()) { + String value = keys.get(key); + if (key.startsWith("load")) { + // TODO made reuse working. + VascParser vp = new VascParser(vascController); + if (xpqlController!=null) { + vp.addELBean("xpqlController", new XpqlController()); + } + if (entityManager!=null) { + vp.addELBean("entityManagerProvider", new LocalEntityManagerProvider()); + } + vp.parseResource(value); + } + } + DefaultVascFactory.fillVascControllerLocalEntries((VascEntryControllerLocal) vascController.getVascEntryController(), vascController); + long t = System.currentTimeMillis()-s; logger.info("Total loaded vasc entries: "+vascController.getVascEntryController().getVascEntryIds().size()+" in "+t+" ms."); } catch (Exception e) { @@ -139,56 +127,53 @@ public class VascServiceManagerImpl implements VascServiceManagerRemote,VascServ throw new RuntimeException("Error while init resources error: "+e.getMessage(),e); } } - - /** - * Loads xtes-xpql-ejb3.xml from meta-inf and gives the keys - */ - protected Map loadKeys() throws IOException { - - Properties properties = new Properties(); - - logger.fine("Getting urls"); - Enumeration e = Thread.currentThread().getContextClassLoader().getResources("META-INF/vasc-ejb3.xml"); - while(e.hasMoreElements()) { - URL u = e.nextElement(); - logger.finer("Loading reletive namespaces of: "+u+" for: META-INF/vasc-ejb3.xml"); - InputStream in = u.openStream(); - try { - properties.loadFromXML(in); - } finally { - if (in!=null) { - in.close(); - } - } - } - - - e = Thread.currentThread().getContextClassLoader().getResources("/META-INF/vasc-ejb3.xml"); - while(e.hasMoreElements()) { - URL u = e.nextElement(); - logger.finer("Loading root namespaces of: "+u+" for: /META-INF/vasc-ejb3.xml"); - InputStream in = u.openStream(); - try { - properties.loadFromXML(in); - } finally { - if (in!=null) { - in.close(); - } - } - } - logger.fine("done loading"); - - Map result = new HashMap(20); - for (Object key:properties.keySet()) { - if (key instanceof String) { - String key2 = (String) key; - String value = properties.getProperty(key2); - result.put(key2, value); - } - } - return result; - } - + + /** + * Loads xtes-xpql-ejb3.xml from meta-inf and gives the keys + */ + protected Map loadKeys() throws IOException { + Properties properties = new Properties(); + logger.fine("Getting urls"); + Enumeration e = Thread.currentThread().getContextClassLoader().getResources("META-INF/vasc-ejb3.xml"); + while(e.hasMoreElements()) { + URL u = e.nextElement(); + logger.finer("Loading reletive namespaces of: "+u+" for: META-INF/vasc-ejb3.xml"); + InputStream in = u.openStream(); + try { + properties.loadFromXML(in); + } finally { + if (in!=null) { + in.close(); + } + } + } + + e = Thread.currentThread().getContextClassLoader().getResources("/META-INF/vasc-ejb3.xml"); + while(e.hasMoreElements()) { + URL u = e.nextElement(); + logger.finer("Loading root namespaces of: "+u+" for: /META-INF/vasc-ejb3.xml"); + InputStream in = u.openStream(); + try { + properties.loadFromXML(in); + } finally { + if (in!=null) { + in.close(); + } + } + } + logger.fine("done loading"); + + Map result = new HashMap(20); + for (Object key:properties.keySet()) { + if (key instanceof String) { + String key2 = (String) key; + String value = properties.getProperty(key2); + result.put(key2, value); + } + } + return result; + } + /* public Map getResourceBundle(String locale) { Map result = new HashMap(resourceBundle.keySet().size()); @@ -199,7 +184,7 @@ public class VascServiceManagerImpl implements VascServiceManagerRemote,VascServ return result; } */ - + public List getVascEntryIds() { VascController v = getVascController(); if (v==null) { @@ -291,7 +276,7 @@ public class VascServiceManagerImpl implements VascServiceManagerRemote,VascServ return null; } - @SuppressWarnings("unchecked") + @SuppressWarnings({ "rawtypes" }) public void putAll(Map m) { } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryControllerLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryControllerLocal.java index debfe8f..e8c21f4 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryControllerLocal.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryControllerLocal.java @@ -37,9 +37,11 @@ import java.util.Map; abstract public class AbstractVascEntryControllerLocal implements VascEntryControllerLocal { private Map entries = null; + private Map groups = null; public AbstractVascEntryControllerLocal() { - entries = new HashMap(1000); + entries = Collections.synchronizedMap(new HashMap(1000)); + groups = Collections.synchronizedMap(new HashMap(100)); } /** @@ -93,4 +95,74 @@ abstract public class AbstractVascEntryControllerLocal implements VascEntryContr Collections.sort(result); // lets do abc for consistance behauvior. return result; } + + /** + * @see net.forwardfire.vasc.core.VascEntryController#getVascEntryByGroupId(java.lang.String) + */ + @Override + public List getVascEntryByGroupId(String groupId) { + if (groupId==null) { + throw new NullPointerException("Can't search null groupId."); + } + List result = new ArrayList(40); + for (VascEntryLocal entry:entries.values()) { + if (groupId.equals(entry.getVascGroupId())) { + result.add(entry.getId()); + } + } + return result; + } + + /** + * @see net.forwardfire.vasc.core.VascEntryController#getVascEntryGroupById(java.lang.String) + */ + @Override + public VascEntryGroup getVascEntryGroupById(String id) { + VascEntryGroupLocal result = groups.get(id); + if (result==null) { + return null; + } + try { + return result.clone(); + } catch (CloneNotSupportedException e) { + throw new NullPointerException("Could not clone entry: "+e.getMessage()); + } + } + + /** + * @see net.forwardfire.vasc.core.VascEntryController#getVascEntryGroupIds() + */ + @Override + public List getVascEntryGroupIds() { + List result = new ArrayList(groups.keySet()); + Collections.sort(result); // lets do abc for consistance behauvior. + return result; + } + + /** + * @see net.forwardfire.vasc.core.VascEntryControllerLocal#addVascEntryGroup(net.forwardfire.vasc.core.VascEntryGroupLocal) + */ + @Override + public void addVascEntryGroup(VascEntryGroupLocal group) { + if (group==null) { + throw new NullPointerException("Can't add null VascEntryGroup."); + } + if (group.getId()==null) { + throw new NullPointerException("Can't add VascEntryGroup with null Id."); + } + + // TODO: move + if (group.getName()==null) { + group.setName("vasc.entry.group."+group.getId()+".name"); + } + if (group.getDescription()==null) { + group.setDescription("vasc.entry.group."+group.getId()+".description"); + } + if (group.getImage()==null) { + group.setImage("vasc.entry.group."+group.getId()+".image"); + } + //group.getHelpId() + + groups.put(group.getId(), group); + } } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryGroupLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryGroupLocal.java new file mode 100644 index 0000000..d01258e --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryGroupLocal.java @@ -0,0 +1,50 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.core; + +import net.forwardfire.vasc.core.base.AbstractVascBaseIdRoleViewOrderMetaLocal; + +/** + * AbstractVascEntryGroupLocal + * + * @author Willem Cazander + * @version 1.0 Nov 23, 2012 + */ +@SuppressWarnings("serial") +abstract public class AbstractVascEntryGroupLocal extends AbstractVascBaseIdRoleViewOrderMetaLocal implements VascEntryGroupLocal { + + @Override + public VascEntryGroupLocal clone() throws CloneNotSupportedException { + Object clone = cloneCreate(); + cloneFields(clone); + return (VascEntryGroupLocal)clone; + } + + /* + @Override + public void cloneFields(Object cloneObject) throws CloneNotSupportedException { + super.cloneFields(cloneObject); + VascEntryGroupLocal clone = (VascEntryGroupLocal)cloneObject; + } + */ +} diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryLinkLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryLinkLocal.java index 251e752..9a61b4c 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryLinkLocal.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryLinkLocal.java @@ -41,7 +41,7 @@ abstract public class AbstractVascEntryLinkLocal extends AbstractVascBaseIdRoleV private String vascEntryId = null; private Map entryParameterFieldIds = new HashMap(3); private Map entryCreateFieldValues = new HashMap(3); - private VascEntryLinkType vascLinkEntryType = null; + private VascEntryLinkType vascEntryLinkType = null; private String doActionId = null; @@ -58,7 +58,7 @@ abstract public class AbstractVascEntryLinkLocal extends AbstractVascBaseIdRoleV VascEntryLinkLocal clone = (VascEntryLinkLocal)cloneObject; clone.setVascEntryId(getVascEntryId()); clone.setDoActionId(getDoActionId()); - clone.setVascLinkEntryType(getVascLinkEntryType()); + clone.setVascEntryLinkType(getVascEntryLinkType()); for (String key:getEntryParameterFieldIdKeys()) { clone.addEntryParameterFieldId(key, getEntryParameterFieldId(key)); } @@ -104,15 +104,15 @@ abstract public class AbstractVascEntryLinkLocal extends AbstractVascBaseIdRoleV /** * @return the vascLinkEntryType */ - public VascEntryLinkType getVascLinkEntryType() { - return vascLinkEntryType; + public VascEntryLinkType getVascEntryLinkType() { + return vascEntryLinkType; } /** * @param vascLinkEntryType the vascLinkEntryType to set */ - public void setVascLinkEntryType(VascEntryLinkType vascLinkEntryType) { - this.vascLinkEntryType = vascLinkEntryType; + public void setVascEntryLinkType(VascEntryLinkType vascEntryLinkType) { + this.vascEntryLinkType = vascEntryLinkType; } /** diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryLocal.java index 77e5448..65462f9 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryLocal.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/AbstractVascEntryLocal.java @@ -67,7 +67,8 @@ abstract public class AbstractVascEntryLocal extends AbstractVascBaseIdRoleCrudL private Boolean vascDisplayOnly = null; // todo rename private Boolean delete = null; private String rolesDelete = null; - + private VascEntryAccessType accessType = null; + private List vascFields = null; private List rowActions = null; private List columnActions = null; @@ -75,8 +76,8 @@ abstract public class AbstractVascEntryLocal extends AbstractVascBaseIdRoleCrudL private List exportActions = null; private List vascEntryFieldSets = null; private List vascEntryLinks = null; - - private Map entryParameters = null; + + private Map entryParameters = null; private VascEntryFieldEventChannel vascEntryFieldEventChannel = null; private Map> eventEntryFrontendEventListeners = null; private List eventEntryBackendEventListeners = null; @@ -85,6 +86,7 @@ abstract public class AbstractVascEntryLocal extends AbstractVascBaseIdRoleCrudL private Map> eventEntryFrontendActions = null; private String backendId = null; + private String vascGroupId = null; private VascFrontendController vascFrontendData = null; public AbstractVascEntryLocal() { @@ -134,6 +136,7 @@ abstract public class AbstractVascEntryLocal extends AbstractVascBaseIdRoleCrudL clone.setDelete(getDelete()); clone.setRolesDelete(getRolesDelete()); + clone.setAccessType(getAccessType()); for (VascEntryFieldLocal field:getVascEntryFieldsLocal()) { VascEntryFieldLocal fieldClone = field.clone(); @@ -185,6 +188,7 @@ abstract public class AbstractVascEntryLocal extends AbstractVascBaseIdRoleCrudL } } clone.setBackendId(getBackendId()); + clone.setVascGroupId(getVascGroupId()); } @@ -900,4 +904,32 @@ abstract public class AbstractVascEntryLocal extends AbstractVascBaseIdRoleCrudL public void setVascDisplayOnly(Boolean vascDisplayOnly) { this.vascDisplayOnly = vascDisplayOnly; } + + /** + * @return the vascGroupId + */ + public String getVascGroupId() { + return vascGroupId; + } + + /** + * @param vascGroupId the vascGroupId to set + */ + public void setVascGroupId(String vascGroupId) { + this.vascGroupId = vascGroupId; + } + + /** + * @return the accessType + */ + public VascEntryAccessType getAccessType() { + return accessType; + } + + /** + * @param accessType the accessType to set + */ + public void setAccessType(VascEntryAccessType accessType) { + this.accessType = accessType; + } } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntry.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntry.java index f993743..5f8e79f 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntry.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntry.java @@ -117,6 +117,11 @@ public interface VascEntry extends VascBaseIdRoleCrud { */ public String getRolesDelete(); + /** + * @return the accessType + */ + public VascEntryAccessType getAccessType(); + /** * @return the vascFields */ @@ -196,6 +201,8 @@ public interface VascEntry extends VascBaseIdRoleCrud { public String getBackendId(); + public String getVascGroupId(); + /** * @return the vascDisplayOnly */ diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuComparator.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryAccessType.java similarity index 70% rename from vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuComparator.java rename to vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryAccessType.java index a526dcb..7edc0c2 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuComparator.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryAccessType.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2012 forwardfire.net All rights reserved. + * Copyright 2007-2012 forwardfire.net All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided * that the following conditions are met: @@ -20,30 +20,22 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.forwardfire.vasc.demo.tech.ejb3.menu.model; +package net.forwardfire.vasc.core; import java.io.Serializable; -import java.util.Comparator; - - /** - * VascMenuComparator orders the menu group. + * The type of a VascEntryAccessType * * @author Willem Cazander - * @version 1.0 nov 17, 2012 + * @version 1.0 Nov 25, 2012 */ -public class VascMenuComparator implements Serializable,Comparator { +public enum VascEntryAccessType implements Serializable { - private static final long serialVersionUID = 386631856823832371L; + DIRECT, + DIRECT_PARAMETER, + ENTRY_LIST, + ENTRY_LINK; - public int compare(VascMenu m1, VascMenu m2) { - if (m1.getMenuOrder()==null) { - return 1; - } - if (m2.getMenuOrder()==null) { - return -1; - } - return m1.getMenuOrder().compareTo(m2.getMenuOrder()); - } + public static VascEntryAccessType DEFAULT_TYPE = VascEntryAccessType.DIRECT; } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryController.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryController.java index 7216686..4acd96a 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryController.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryController.java @@ -35,4 +35,10 @@ public interface VascEntryController { public VascEntry getVascEntryById(String id); public List getVascEntryIds(); + + public List getVascEntryByGroupId(String groupId); + + public VascEntryGroup getVascEntryGroupById(String id); + + public List getVascEntryGroupIds(); } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryControllerLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryControllerLocal.java index 7a88738..c98dbc1 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryControllerLocal.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryControllerLocal.java @@ -37,4 +37,6 @@ public interface VascEntryControllerLocal extends VascEntryController { public void removeVascEntry(String entryId); public VascEntryLocal getMasterVascEntryById(String entryId); + + public void addVascEntryGroup(VascEntryGroupLocal group); } \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryGroup.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryGroup.java new file mode 100644 index 0000000..bb6a028 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryGroup.java @@ -0,0 +1,35 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.core; + +import net.forwardfire.vasc.core.base.VascBaseIdRoleViewOrderMeta; + +/** + * VascLinkGroup binds multiple entries as one group. + * + * @author Willem Cazander + * @version 1.0 Nove 23, 2012 + */ +public interface VascEntryGroup extends VascBaseIdRoleViewOrderMeta { + +} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryGroupLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryGroupLocal.java new file mode 100644 index 0000000..f5c189e --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryGroupLocal.java @@ -0,0 +1,41 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.core; + +import net.forwardfire.vasc.core.base.VascBaseIdRoleViewOrderMetaLocal; + +/** + * VascEntryGroupLocal + * + * @author Willem Cazander + * @version 1.0 Nov 23, 2012 + */ +public interface VascEntryGroupLocal extends VascEntryGroup,VascBaseIdRoleViewOrderMetaLocal { + + /** + * Force impl to have public clone methode + * @return + * @throws CloneNotSupportedException + */ + public VascEntryGroupLocal clone() throws CloneNotSupportedException; +} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryLink.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryLink.java index 07c5f57..9a20991 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryLink.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryLink.java @@ -51,7 +51,7 @@ public interface VascEntryLink extends VascBaseIdRoleViewOrderMeta { /** * @return the vascLinkEntryType */ - public VascEntryLinkType getVascLinkEntryType(); + public VascEntryLinkType getVascEntryLinkType(); /** * @return the doActionId diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryLinkLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryLinkLocal.java index 5fad744..f4316e5 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryLinkLocal.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryLinkLocal.java @@ -46,7 +46,7 @@ public interface VascEntryLinkLocal extends VascEntryLink,VascBaseIdRoleViewOrde /** * @param vascLinkEntryType the vascLinkEntryType to set */ - public void setVascLinkEntryType(VascEntryLinkType vascLinkEntryType); + public void setVascEntryLinkType(VascEntryLinkType vascLinkEntryType); /** * @param doActionId the doActionId to set diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryLocal.java b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryLocal.java index 7e7a4f0..38a9f56 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryLocal.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/core/VascEntryLocal.java @@ -116,6 +116,11 @@ public interface VascEntryLocal extends VascEntry,VascBaseIdRoleCrudLocal { */ public void setRolesDelete(String rolesDelete); + /** + * @param accessType the accessType to set + */ + public void setAccessType(VascEntryAccessType accessType); + /** * @param vascField the vascField to add */ @@ -221,12 +226,12 @@ public interface VascEntryLocal extends VascEntry,VascBaseIdRoleCrudLocal { */ public Collection getVascEntryLinksLocal(); - - public void setVascFrontendController(VascFrontendController vascFrontendData); - + public void setVascFrontendController(VascFrontendController vascFrontendData); - public void setBackendId(String backendId); - + public void setBackendId(String backendId); + + public void setVascGroupId(String groupId); + /** * @param vascDisplayOnly the vascDisplayOnly to set */ diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryGroup.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryGroup.java new file mode 100644 index 0000000..c0cc443 --- /dev/null +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/DefaultVascEntryGroup.java @@ -0,0 +1,36 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.impl; + +import net.forwardfire.vasc.core.AbstractVascEntryGroupLocal; + +/** + * DefaultVascEntryGroup + * + * @author Willem Cazander + * @version 1.0 Nov 23, 2012 + */ +public class DefaultVascEntryGroup extends AbstractVascEntryGroupLocal { + + private static final long serialVersionUID = 853182253019347410L; +} \ No newline at end of file diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascDefaultsFinalizer.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascDefaultsFinalizer.java index 8a354a3..592ff61 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascDefaultsFinalizer.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/entry/config/VascDefaultsFinalizer.java @@ -182,8 +182,8 @@ public class VascDefaultsFinalizer implements VascEntryConfigFinalizer { if (vle.getVascEntryId()==null) { throw new IllegalArgumentException("All VascLinkEntry need an vascEntryId: "+id); } - if (vle.getVascLinkEntryType()==null) { - vle.setVascLinkEntryType(VascEntryLinkType.DEFAULT_TYPE); + if (vle.getVascEntryLinkType()==null) { + vle.setVascEntryLinkType(VascEntryLinkType.DEFAULT_TYPE); } } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendHelper.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendHelper.java index 9286ce2..85fb5b4 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendHelper.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/frontend/DefaultVascFrontendHelper.java @@ -68,7 +68,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper { result.add(link); continue; } - if (type.equals(link.getVascLinkEntryType())) { + if (type.equals(link.getVascEntryLinkType())) { result.add(link); } } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/jndi/JndiVascControllerFactory.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/jndi/JndiVascControllerFactory.java index ad57513..8610d24 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/jndi/JndiVascControllerFactory.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/jndi/JndiVascControllerFactory.java @@ -43,6 +43,7 @@ import net.forwardfire.vasc.core.VascEntryConfigController; import net.forwardfire.vasc.core.VascEntryController; import net.forwardfire.vasc.core.VascEntryControllerLocal; import net.forwardfire.vasc.core.VascEntryFieldTypeController; +import net.forwardfire.vasc.core.VascEntryGroup; import net.forwardfire.vasc.core.VascEventChannelController; import net.forwardfire.vasc.impl.DefaultVascFactory; @@ -139,6 +140,15 @@ public class JndiVascControllerFactory implements ObjectFactory { public VascEntry getVascEntryById(String id) { return entryController.getVascEntryById(id); } + public List getVascEntryByGroupId(String groupId) { + return entryController.getVascEntryByGroupId(groupId); + } + public VascEntryGroup getVascEntryGroupById(String id) { + return entryController.getVascEntryGroupById(id); + } + public List getVascEntryGroupIds() { + return entryController.getVascEntryGroupIds(); + } }); } diff --git a/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryElementConfigurator.java b/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryElementConfigurator.java index 6057597..77961f0 100644 --- a/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryElementConfigurator.java +++ b/vasc-core/src/main/java/net/forwardfire/vasc/impl/x4o/VascEntryElementConfigurator.java @@ -25,6 +25,7 @@ package net.forwardfire.vasc.impl.x4o; import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.core.VascEntryController; import net.forwardfire.vasc.core.VascEntryControllerLocal; +import net.forwardfire.vasc.core.VascEntryGroupLocal; import net.forwardfire.vasc.core.VascEntryLocal; import org.x4o.xml.element.AbstractElementConfigurator; @@ -43,14 +44,22 @@ public class VascEntryElementConfigurator extends AbstractElementConfigurator { * @see org.x4o.xml.element.AbstractElementConfigurator#doConfigEndTag(org.x4o.xml.element.Element) */ public void doConfigElement(Element element) throws ElementConfiguratorException { - VascEntryLocal entry = (VascEntryLocal)element.getElementObject(); + Object elementObject = element.getElementObject(); VascController vascController = VascParser.getVascController(element.getElementLanguage()); VascEntryController entryController = vascController.getVascEntryController(); if (entryController instanceof VascEntryControllerLocal) { - ((VascEntryControllerLocal)entryController).addVascEntry(entry); + if (elementObject instanceof VascEntryLocal) { + VascEntryLocal entry = (VascEntryLocal)elementObject; + ((VascEntryControllerLocal)entryController).addVascEntry(entry); + } else if (elementObject instanceof VascEntryGroupLocal) { + VascEntryGroupLocal entryGroup = (VascEntryGroupLocal)elementObject; + ((VascEntryControllerLocal)entryController).addVascEntryGroup(entryGroup); + } else { + throw new ElementConfiguratorException(this,"ElementObject is unknown instance: "+elementObject); + } } else { - throw new ElementConfiguratorException(this,"Can not add entry '"+entry.getId()+"' to VascEntryController because we have no access to VascEntryControllerLocal interface."); + throw new ElementConfiguratorException(this,"Can not run configurator because we have no access to VascEntryControllerLocal interface."); } } } \ No newline at end of file diff --git a/vasc-core/src/main/resources/META-INF/vasc/vasc-lang.eld b/vasc-core/src/main/resources/META-INF/vasc/vasc-lang.eld index fe55674..7335096 100644 --- a/vasc-core/src/main/resources/META-INF/vasc/vasc-lang.eld +++ b/vasc-core/src/main/resources/META-INF/vasc/vasc-lang.eld @@ -47,8 +47,14 @@ > + + + + + + diff --git a/vasc-demo/vasc-demo-server/pom.xml b/vasc-demo/vasc-demo-server/pom.xml index 60b584c..c25c433 100644 --- a/vasc-demo/vasc-demo-server/pom.xml +++ b/vasc-demo/vasc-demo-server/pom.xml @@ -13,5 +13,6 @@ vasc-demo-server-build vasc-demo-server-core + vasc-demo-server-build-client-swing \ No newline at end of file diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-build-client-swing/.project b/vasc-demo/vasc-demo-server/vasc-demo-server-build-client-swing/.project new file mode 100644 index 0000000..ce8963b --- /dev/null +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-build-client-swing/.project @@ -0,0 +1,17 @@ + + + vasc-demo-server-build-client-swing + + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.m2e.core.maven2Nature + + diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-build-client-swing/pom.xml b/vasc-demo/vasc-demo-server/vasc-demo-server-build-client-swing/pom.xml new file mode 100644 index 0000000..3d07ea1 --- /dev/null +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-build-client-swing/pom.xml @@ -0,0 +1,42 @@ + + 4.0.0 + + net.forwardfire.vasc.demo + vasc-demo-server + 0.4.1-SNAPSHOT + + vasc-demo-server-build-client-swing + pom + vasc-demo-server-build-client-swing + vasc-demo-server-build-client-swing + + + + org.apache.maven.plugins + maven-assembly-plugin + ${maven-assembly-plugin.version} + + + build-clients-assembly + package + + single + + + + src/main/assembly/bin.xml + + + + + + + + + + net.forwardfire.vasc.demo + vasc-demo-tech-client-swing + ${project.version} + + + \ No newline at end of file diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-build-client-swing/src/main/assembly/bin.xml b/vasc-demo/vasc-demo-server/vasc-demo-server-build-client-swing/src/main/assembly/bin.xml new file mode 100644 index 0000000..14e9fc3 --- /dev/null +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-build-client-swing/src/main/assembly/bin.xml @@ -0,0 +1,48 @@ + + + + bin + + zip + + true + vasc-demo-server-build-client-swing-${project.version} + + + /libs + false + false + runtime + + + + + ${project.basedir}/src/main/scripts/ + / + 755 + + + \ No newline at end of file diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-build-client-swing/src/main/scripts/client.bat b/vasc-demo/vasc-demo-server/vasc-demo-server-build-client-swing/src/main/scripts/client.bat new file mode 100644 index 0000000..63d7501 --- /dev/null +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-build-client-swing/src/main/scripts/client.bat @@ -0,0 +1,38 @@ +:: +:: Copyright (c) 2011, Willem Cazander +:: All rights reserved. +:: +:: Redistribution and use in source and binary forms, with or without modification, are permitted provided +:: that the following conditions are met: +:: +:: * Redistributions of source code must retain the above copyright notice, this list of conditions and the +:: following disclaimer. +:: * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and +:: the following disclaimer in the documentation and/or other materials provided with the distribution. +:: +:: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +:: EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +:: MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +:: THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +:: SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +:: OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +:: HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR +:: TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +:: SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +:: +@echo off +setlocal enableextensions + +:: Run in app dir +cd /d %~dp0 + +:: Config variables +set JAVA_OPTS=-Xms128m -Xmx512m -XX:MaxPermSize=128m +set MAIN_CLASS=net.forwardfire.vasc.demo.client.swing.VascDemoSwingClient +set CP=libs\* + +:: Launch application +java %JAVA_OPTS% -cp "%CP%" %MAIN_CLASS% + +endlocal +:: EOF diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/scripts/run.sh b/vasc-demo/vasc-demo-server/vasc-demo-server-build-client-swing/src/main/scripts/client.sh similarity index 92% rename from vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/scripts/run.sh rename to vasc-demo/vasc-demo-server/vasc-demo-server-build-client-swing/src/main/scripts/client.sh index 6298707..60bebdf 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/scripts/run.sh +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-build-client-swing/src/main/scripts/client.sh @@ -27,8 +27,8 @@ cd `dirname $0`; # Config variables JAVA="java"; -JAVA_OPTS="-Xms64m -Xmx256m"; -MAIN_CLASS="net.forwardfire.vasc.demo.server.core.VascTechDemoStartup"; +JAVA_OPTS="-Xms128m -Xmx512m -XX:MaxPermSize=128m"; +MAIN_CLASS="net.forwardfire.vasc.demo.client.swing.VascDemoSwingClient"; CP=`echo libs/*.jar | sed 's/ /:/g'`; # Launch application diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-build/pom.xml b/vasc-demo/vasc-demo-server/vasc-demo-server-build/pom.xml index a24bc34..97e6f72 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-build/pom.xml +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-build/pom.xml @@ -91,5 +91,11 @@ vasc-demo-tech-web ${project.version} + + net.forwardfire.vasc.demo + vasc-demo-server-build-client-swing + ${project.version} + pom + \ No newline at end of file diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/assembly/bin.xml b/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/assembly/bin.xml index a073519..cbc6d5d 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/assembly/bin.xml +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/assembly/bin.xml @@ -50,7 +50,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ${project.basedir}/src/main/scripts/ - / + /bin 755 @@ -71,5 +71,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ${project.basedir}/target/docs/ /docs + + ${project.parent.basedir}/vasc-demo-server-build-client-swing/target/ + /clients + + vasc-demo-server-build-client-swing-${project.version}-bin.zip + + \ No newline at end of file diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/directory/conf/server.xml b/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/directory/conf/server.xml index 6458f3f..d8e14bc 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/directory/conf/server.xml +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/directory/conf/server.xml @@ -8,14 +8,9 @@ - @@ -36,11 +31,6 @@ vascControllerProvider="net.forwardfire.vasc.demo.server.core.VascTechDemoControllerConfig" removeLocal="false" /> - diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/directory/conf/server-tech/demo-csv.xml b/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/directory/conf/vasc.d/demo-csv.xml similarity index 80% rename from vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/directory/conf/server-tech/demo-csv.xml rename to vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/directory/conf/vasc.d/demo-csv.xml index 52cf068..4152c2c 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/directory/conf/server-tech/demo-csv.xml +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/directory/conf/vasc.d/demo-csv.xml @@ -3,7 +3,12 @@ xmlns:v="http://vasc.forwardfire.net/xml/ns/vasc-lang" xmlns:mm="http://vasc.forwardfire.net/xml/ns/vasc-backend-metamodel" > - + + + - + @@ -33,10 +38,10 @@ - + diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/directory/conf/server-tech/auto-pg.xml b/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/directory/conf/vasc.d/demo-pg.xml similarity index 98% rename from vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/directory/conf/server-tech/auto-pg.xml rename to vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/directory/conf/vasc.d/demo-pg.xml index 5868a6b..5964b30 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/directory/conf/server-tech/auto-pg.xml +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/directory/conf/vasc.d/demo-pg.xml @@ -25,12 +25,6 @@ --> - - - - - - - - - + + + + + \ No newline at end of file diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/scripts/run.bat b/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/scripts/shutdown.bat similarity index 92% rename from vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/scripts/run.bat rename to vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/scripts/shutdown.bat index 7a38823..db54383 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/scripts/run.bat +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/scripts/shutdown.bat @@ -25,11 +25,12 @@ setlocal enableextensions :: Run in app dir cd /d %~dp0 +cd .. :: Config variables -set JAVA_OPTS=-Xms64m -Xmx256m +set JAVA_OPTS=-Xms128m -Xmx768m -XX:MaxPermSize=256m set MAIN_CLASS=net.forwardfire.vasc.demo.server.core.VascTechDemoStartup -set CP=libs\* +set CP=libs\tomcat-el-api-* libs\* :: Launch application java %JAVA_OPTS% -cp "%CP%" %MAIN_CLASS% diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/scripts/shutdown.sh b/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/scripts/shutdown.sh new file mode 100644 index 0000000..a6c2d96 --- /dev/null +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/scripts/shutdown.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# +# Copyright (c) 2011, Willem Cazander +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted provided +# that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions and the +# following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and +# the following disclaimer in the documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR +# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +# Run in app dir +cd `dirname $0`/..; + +# Config variables +JAVA="java"; +JAVA_OPTS="-Xms128m -Xmx768m -XX:MaxPermSize=256m"; +MAIN_CLASS="org.apache.catalina.startup.Bootstrap"; +CP=`echo libs/tomcat-* | sed 's/ /:/g'`; + +# Launch application +$JAVA $JAVA_OPTS -cp $CP $MAIN_CLASS stop; + +# EOF + diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/scripts/startup.bat b/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/scripts/startup.bat new file mode 100644 index 0000000..db54383 --- /dev/null +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/scripts/startup.bat @@ -0,0 +1,39 @@ +:: +:: Copyright (c) 2011, Willem Cazander +:: All rights reserved. +:: +:: Redistribution and use in source and binary forms, with or without modification, are permitted provided +:: that the following conditions are met: +:: +:: * Redistributions of source code must retain the above copyright notice, this list of conditions and the +:: following disclaimer. +:: * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and +:: the following disclaimer in the documentation and/or other materials provided with the distribution. +:: +:: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +:: EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +:: MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +:: THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +:: SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +:: OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +:: HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR +:: TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +:: SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +:: +@echo off +setlocal enableextensions + +:: Run in app dir +cd /d %~dp0 +cd .. + +:: Config variables +set JAVA_OPTS=-Xms128m -Xmx768m -XX:MaxPermSize=256m +set MAIN_CLASS=net.forwardfire.vasc.demo.server.core.VascTechDemoStartup +set CP=libs\tomcat-el-api-* libs\* + +:: Launch application +java %JAVA_OPTS% -cp "%CP%" %MAIN_CLASS% + +endlocal +:: EOF diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/scripts/startup.sh b/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/scripts/startup.sh new file mode 100644 index 0000000..e524524 --- /dev/null +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-build/src/main/scripts/startup.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# +# Copyright (c) 2011, Willem Cazander +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted provided +# that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions and the +# following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and +# the following disclaimer in the documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR +# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +# Run in app dir +cd `dirname $0`/..; + +# Config variables +JAVA="java"; +JAVA_OPTS="-Xms128m -Xmx768m -XX:MaxPermSize=256m"; +MAIN_CLASS="net.forwardfire.vasc.demo.server.core.VascTechDemoStartup"; +CP=`echo libs/tomcat-el-api-* libs/*.jar | sed 's/ /:/g'`; +# todo: tomcat-el-api needs loaded before javaee-api for ELResolver config. + +# Launch application +$JAVA $JAVA_OPTS -cp $CP $MAIN_CLASS; + +# EOF + diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/pom.xml b/vasc-demo/vasc-demo-server/vasc-demo-server-core/pom.xml index 6e1af45..64c580f 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-core/pom.xml +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/pom.xml @@ -170,11 +170,7 @@ myfaces-impl org.apache.myfaces.core - + diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/core/VascTechDemoStartup.java b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/core/VascTechDemoStartup.java index ea45674..a29b542 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/core/VascTechDemoStartup.java +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/core/VascTechDemoStartup.java @@ -205,6 +205,7 @@ public class VascTechDemoStartup { serverConfigService.stop(); tomcatService.stop(); databaseService.stop(); + swingGuiService.stop(); long stopTime = System.currentTimeMillis(); logger.info("VascTechDemo shutdown in "+(stopTime-startTime)+" ms."); } catch (Exception e) { diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/core/service/VascControllerService.java b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/core/service/VascControllerService.java index fde3a1d..bbdb951 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/core/service/VascControllerService.java +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/core/service/VascControllerService.java @@ -28,22 +28,29 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.lang.reflect.Field; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import java.util.Properties; import java.util.ResourceBundle; import java.util.logging.Logger; +import com.sun.faces.application.ApplicationAssociate; +import com.sun.faces.application.ApplicationResourceBundle; + import net.forwardfire.vasc.backend.VascBackendControllerLocal; import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryControllerLocal; +import net.forwardfire.vasc.core.VascEntryGroup; import net.forwardfire.vasc.core.VascEventChannelControllerLocal; import net.forwardfire.vasc.core.VascEventControllerListener; import net.forwardfire.vasc.core.VascEventControllerType; import net.forwardfire.vasc.demo.server.core.VascTechDemoStartup; import net.forwardfire.vasc.impl.DefaultVascFactory; import net.forwardfire.vasc.impl.x4o.VascParser; +import net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle; import net.forwardfire.vasc.test.i18n.VascBundleCheckEntryKeys; /** @@ -127,6 +134,10 @@ public class VascControllerService { VascEntry ve = vascController.getVascEntryController().getVascEntryById(veId); keys.putAll(checker.generateMissingKeys(ve)); } + for (String groupId:vascController.getVascEntryController().getVascEntryGroupIds()) { + VascEntryGroup veg = vascController.getVascEntryController().getVascEntryGroupById(groupId); + keys.putAll(checker.generateMissingKeys(veg)); + } if (keys.isEmpty()==false) { Properties p = new Properties(); File dataDir = new File("data"); @@ -150,6 +161,21 @@ public class VascControllerService { writePropertiesFile(p,resourceFile); ResourceBundle.clearCache(); + + //ApplicationResourceBundle appBundle = ApplicationAssociate.getCurrentInstance().getResourceBundles().get(RootApplicationBundle.class.getName()); + //Map resources = getFieldValue(appBundle, "resources"); + //resources.clear(); + } + } + + @SuppressWarnings("unchecked") + private T getFieldValue(Object object, String fieldName) { + try { + Field field = object.getClass().getDeclaredField(fieldName); + field.setAccessible(true); + return (T) field.get(object); + } catch (Exception e) { + return null; } } diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/tomcat/TomcatService.java b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/tomcat/TomcatService.java index 77bcd33..d83518a 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/tomcat/TomcatService.java +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/tomcat/TomcatService.java @@ -37,8 +37,6 @@ import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.logging.Logger; -import javax.ejb.embeddable.EJBContainer; - import net.forwardfire.vasc.demo.server.core.VascTechDemoStartup; import org.apache.catalina.Container; diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/JConsolePanel.java b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/JConsolePanel.java index 68c9729..2ce17fe 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/JConsolePanel.java +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/JConsolePanel.java @@ -22,23 +22,12 @@ package net.forwardfire.vasc.demo.server.ui; -import java.awt.Color; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.Enumeration; import java.util.logging.Handler; -import java.util.logging.Level; -import java.util.logging.LogManager; import java.util.logging.LogRecord; import java.util.logging.Logger; import java.util.logging.SimpleFormatter; -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JComboBox; -import javax.swing.JLabel; +import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; @@ -52,25 +41,19 @@ import javax.swing.SwingUtilities; * @author Willem Cazander * @version 1.0 May 12, 2012 */ -public class JConsolePanel extends JPanel implements ActionListener { +public class JConsolePanel extends JPanel { private static final long serialVersionUID = 485766723433479054L; private UILogHandler logHandler = null; - private JButton clearButton = null; - private JComboBox levelBox = null; private JTextArea logTextArea = null; - private JCheckBox autoScrollBox = null; private int logLinesMax = 255; public JConsolePanel() { - setLayout(new FlowLayout(FlowLayout.LEFT)); - JPanel wrap = new JPanel(); - wrap.setLayout(new SpringLayout()); - wrap.add(createHeader()); - wrap.add(createEditor()); - SpringLayoutGrid.makeCompactGrid(wrap,2,1); - add(wrap); - + setLayout(new SpringLayout()); + setBorder(new JFireBorder("Console Log",this)); + add(createEditor()); + SpringLayoutGrid.makeCompactGrid(this, 1, 1, 6, 6, 6, 6); + Logger rootLogger = Logger.getAnonymousLogger(); while (rootLogger.getParent()!=null) { rootLogger = rootLogger.getParent(); @@ -93,53 +76,14 @@ public class JConsolePanel extends JPanel implements ActionListener { rootLogger.removeHandler(logHandler); } - private JPanel createHeader() { - JPanel result = new JPanel(); - result.setBorder(BorderFactory.createLineBorder(Color.BLUE)); - result.setLayout(new FlowLayout(FlowLayout.LEFT)); - result.add(new JLabel("Log Level")); - levelBox = new JComboBox(new Level[] {Level.OFF,Level.SEVERE,Level.WARNING,Level.INFO,Level.FINE,Level.FINER,Level.FINEST,Level.ALL}); - levelBox.setSelectedItem(Level.INFO); - levelBox.addActionListener(this); - result.add(levelBox); - clearButton = new JButton("Clear"); - clearButton.addActionListener(this); - result.add(clearButton); - autoScrollBox = new JCheckBox("Autoscroll"); - autoScrollBox.setSelected(true); - result.add(autoScrollBox); - return result; - } - - private JPanel createEditor() { - JPanel result = new JPanel(); - result.setBorder(BorderFactory.createLineBorder(Color.BLUE)); - logTextArea = new JTextArea(5, 80); + private JComponent createEditor() { + logTextArea = new JTextArea(6, 80); logTextArea.setAutoscrolls(true); logTextArea.setEditable(false); - JScrollPane logScrollPane = new JScrollPane(logTextArea); - logScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); - logScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); - logScrollPane.getViewport().setOpaque(false); - result.add(logScrollPane); - return result; - } - - public void actionPerformed(ActionEvent e) { - if (clearButton.equals(e.getSource())) { - logTextArea.setText(""); - } else if (levelBox.equals(e.getSource()) && levelBox.getSelectedIndex()!=-1) { - Level level = (Level)levelBox.getSelectedItem(); - logHandler.setLevel(level); - Enumeration loggers = LogManager.getLogManager().getLoggerNames(); - while (loggers.hasMoreElements()) { - String name = loggers.nextElement(); - Logger logger = LogManager.getLogManager().getLogger(name); - if (logger!=null && name.contains("pulsefire")) { - logger.setLevel(level); // only set pulsefire code loggers - } - } - } + JScrollPane scrollPane = new JScrollPane(logTextArea); + scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); + scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + return scrollPane; } class UILogHandler extends Handler { @@ -169,9 +113,7 @@ public class JConsolePanel extends JPanel implements ActionListener { String tt = t.substring(l,t.length()); logTextArea.setText(tt); } - if (autoScrollBox.isSelected()) { - logTextArea.setCaretPosition(logTextArea.getText().length()); - } + logTextArea.setCaretPosition(logTextArea.getText().length()); } }); } diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/JFireBorder.java b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/JFireBorder.java new file mode 100644 index 0000000..52a2649 --- /dev/null +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/JFireBorder.java @@ -0,0 +1,148 @@ +package net.forwardfire.vasc.demo.server.ui; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.GradientPaint; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Insets; +import java.awt.RenderingHints; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; + +import javax.swing.JComponent; +import javax.swing.UIManager; +import javax.swing.border.Border; + +/** + * JFireBorder + * + * @author Willem Cazander + */ +public class JFireBorder implements Border,MouseListener { + + private int radius; + boolean entered = false; + private JComponent comp = null; + private String title; + static private JFireBorder lastFireBorder = null; + private GradientPaint gradientNormal = null; + private GradientPaint gradientEntered = null; + private int gradientWidth = 0; + + public JFireBorder(String title,JComponent comp) { + this.radius = 10; + this.comp=comp; + this.title = title; + comp.addMouseListener(this); + } + + public Insets getBorderInsets(Component c) { + return new Insets(getTitleHeight(c)+1, 1, radius-2, 1); + } + + public boolean isBorderOpaque() { + return true; + } + + + public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { + Graphics2D g2 = (Graphics2D)g; + g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + int titleHeight = getTitleHeight(c); + + if (gradientWidth!=width) { + gradientNormal = null; + gradientEntered = null; + } + gradientWidth = width; + + Color endColor = UIManager.getColor("control"); + if (endColor==null) { + endColor = c.getBackground(); + } + Color startColor = UIManager.getColor("nimbusBorder"); + if (startColor==null) { + startColor = c.getForeground(); + } + + //BufferedImage titleImage = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration().createCompatibleImage(width, height, Transparency.TRANSLUCENT); + if (gradientNormal==null) { + gradientNormal = new GradientPaint( + 0, 0, startColor, + titleHeight*5, width/3,endColor, + false); + } + if (gradientEntered==null) { + startColor = UIManager.getColor("nimbusFocus"); + if (startColor==null) { + startColor = c.getForeground(); + } + gradientEntered = new GradientPaint( + 0, 0, startColor, + titleHeight*5, width/3,endColor, + false); + } + if (entered) { + g2.setPaint(gradientEntered); + } else { + g2.setPaint(gradientNormal); + } + g2.fillRoundRect(x, y, width, titleHeight, radius, radius); + g2.fillRect(x,titleHeight/2,radius+1, titleHeight/2); + g2.drawRoundRect(x,y,width-1,height-1,radius,radius); + + if (title==null) { + return; + } + Font font = UIManager.getFont("TitledBorder.font"); + g2.setColor(c.getForeground()); + FontMetrics metrics = c.getFontMetrics(font); + g2.setFont(font); + g2.drawString(title,x+8,y+(titleHeight-metrics.getHeight())/2 +metrics.getAscent()); + } + + protected int getTitleHeight(Component c) { + Font font = UIManager.getFont("TitledBorder.font"); + FontMetrics metrics = c.getFontMetrics(font); + return (int)(metrics.getHeight() * 1.40); + } + + public GradientPaint getGradient() { + if (entered) { + return gradientEntered; + } else { + return gradientNormal; + } + } + + @Override + public void mouseClicked(MouseEvent e) { + } + @Override + public void mouseEntered(MouseEvent e) { + if (entered==true && lastFireBorder==this) { + return; + } + entered = true; + if (comp!=null) { + comp.repaint(); + if (lastFireBorder!=null) { + lastFireBorder.entered = false; + lastFireBorder.comp.repaint(); + } + lastFireBorder = this; + } + } + @Override + public void mouseExited(MouseEvent e) { + } + @Override + public void mousePressed(MouseEvent e) { + } + @Override + public void mouseReleased(MouseEvent e) { + } +} diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/JStartupPanel.java b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/JStartupPanel.java deleted file mode 100644 index af98c62..0000000 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/JStartupPanel.java +++ /dev/null @@ -1,20 +0,0 @@ -package net.forwardfire.vasc.demo.server.ui; - -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JProgressBar; - -public class JStartupPanel extends JPanel { - - private static final long serialVersionUID = -2880272130103870144L; - private JProgressBar bar = null; - - public JStartupPanel() { - - JLabel label = new JLabel("Starting up...."); - add(label); - - bar = new JProgressBar(); - add(bar); - } -} diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/JStatusPanel.java b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/JStatusPanel.java index 902db48..0b87682 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/JStatusPanel.java +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/JStatusPanel.java @@ -22,262 +22,295 @@ package net.forwardfire.vasc.demo.server.ui; -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.GridLayout; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.io.Serializable; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.lang.management.ManagementFactory; +import java.lang.management.ThreadInfo; +import java.lang.management.ThreadMXBean; -import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JLabel; import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JSplitPane; -import javax.swing.JTabbedPane; -import javax.swing.JTree; -import javax.swing.ScrollPaneConstants; -import javax.swing.SwingUtilities; -import javax.swing.event.TreeModelListener; -import javax.swing.tree.DefaultMutableTreeNode; -import javax.swing.tree.DefaultTreeModel; -import javax.swing.tree.TreeNode; +import javax.swing.SpringLayout; -import net.forwardfire.vasc.core.VascEntryLocal; +import org.apache.catalina.Context; +import org.apache.catalina.Server; +import org.apache.catalina.Service; + +import net.forwardfire.vasc.core.VascController; import net.forwardfire.vasc.demo.server.core.VascTechDemoStartup; -import net.forwardfire.vasc.demo.server.core.service.VascControllerService; -import net.forwardfire.vasc.frontend.swing.SwingPanelIntegration; -import net.forwardfire.vasc.frontend.swing.SwingPanelTabbed; +import net.forwardfire.vasc.demo.server.ui.load.JLoadDialog; +import net.forwardfire.vasc.demo.server.ui.load.JLoadDialog.LoadType; /** - * JMainPanel is the main panel/window of this demo. + * JStatusPanel is the main panel/window of this demo. * * @author Willem Cazander * @version 1.0 May 12, 2012 */ -public class JStatusPanel extends JPanel { +public class JStatusPanel extends JPanel implements ActionListener { private static final long serialVersionUID = 5834715323973411147L; - private VascControllerService vascManager = null; - private SwingPanelIntegration spi = null; - private JTabbedPane tabPane = null; - private JTree vascTree = null; - private JSplitPane bottomSplitPane = null; - private JSplitPane treeSplitPane = null; + private JButton stopButton = null; + private JButton playButton = null; + private JButton shutdownButton = null; + private JButton restartButton = null; + private JButton importJdbcButton = null; + private JButton importMongoButton = null; + private JButton importDataFileButton = null; + private JButton importDataPathButton = null; + private JLabel infoStatus = null; + private JLabel infoThreads = null; + private JLabel infoWorkers = null; + private JLabel infoSessions = null; + private JLabel infoHttpPort = null; + private JLabel infoVascGroups = null; + private JLabel infoVascEntries = null; + private JLabel infoVascBackends= null; - public JStatusPanel() { - this.vascManager=VascTechDemoStartup.getInstance().getVascControllerService(); - setLayout(new BorderLayout()); - add(createBottomSplit(), BorderLayout.CENTER); + public JStatusPanel() { + setLayout(new SpringLayout()); + + JPanel main = new JPanel(); + main.setLayout(new SpringLayout()); + main.add(createPanelInfoServer()); + main.add(createPanelInfoVasc()); + main.add(createPanelAction()); + main.add(createPanelImport()); + SpringLayoutGrid.makeCompactGrid(main, 2,2,0,0,6,6); + + JConsolePanel consolePanel = new JConsolePanel(); + add(main); + add(consolePanel); + SpringLayoutGrid.makeCompactGrid(this, 2,1,6,6,0,0); } - - private JSplitPane createBottomSplit() { - JSplitPane sp0 = createTreeSplit(); - JPanel sp1 = new JConsolePanel(); - bottomSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,sp0,sp1); - bottomSplitPane.setOneTouchExpandable(true); - bottomSplitPane.setResizeWeight(0.2); - bottomSplitPane.setDividerLocation(700); - sp0.setMinimumSize(new Dimension(400, 400)); - sp1.setMinimumSize(new Dimension(400, 150)); - return bottomSplitPane; - } - - private JSplitPane createTreeSplit() { - JScrollPane sp0 = createTreePane(); - JScrollPane sp1 = createContentPane(); - treeSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,sp0,sp1); - treeSplitPane.setOneTouchExpandable(true); - treeSplitPane.setResizeWeight(0.7); - treeSplitPane.setDividerLocation(200); - sp0.setMinimumSize(new Dimension(200, 400)); - sp1.setMinimumSize(new Dimension(400, 400)); - return treeSplitPane; - } - - - - class VascTreeModel extends DefaultTreeModel { - public VascTreeModel(TreeNode root) { - super(root); - } - private static final long serialVersionUID = -7436681803506994277L; + private JPanel createPanelInfoVasc() { + JPanel statusPanel = new JPanel(); + statusPanel.setBorder(new JFireBorder("Info Vasc",statusPanel)); + statusPanel.setLayout(new SpringLayout()); + + infoVascGroups = new JLabel("0"); + infoVascEntries = new JLabel("0"); + infoVascBackends = new JLabel("0"); + + statusPanel.add(new JLabel("Artifact:")); + statusPanel.add(new JLabel("vasc-demo-server-core")); + + statusPanel.add(new JLabel("Version:")); + statusPanel.add(new JLabel("0.X.X")); + + statusPanel.add(new JLabel("Groups:")); + statusPanel.add(infoVascGroups); + + statusPanel.add(new JLabel("Entries:")); + statusPanel.add(infoVascEntries); + + statusPanel.add(new JLabel("Backends:")); + statusPanel.add(infoVascBackends); + + SpringLayoutGrid.makeCompactGrid(statusPanel, 5, 2); + return statusPanel; + } + + private JPanel createPanelInfoServer() { + JPanel statusPanel = new JPanel(); + statusPanel.setBorder(new JFireBorder("Info Server",statusPanel)); + statusPanel.setLayout(new SpringLayout()); + + infoStatus = new JLabel("booting"); + infoThreads = new JLabel("0"); + infoWorkers = new JLabel("0"); + infoSessions = new JLabel("0"); + infoHttpPort = new JLabel("0"); + + statusPanel.add(new JLabel("Running:")); + statusPanel.add(infoStatus); + + statusPanel.add(new JLabel("HttpPort:")); + statusPanel.add(infoHttpPort); + + statusPanel.add(new JLabel("Threads:")); + statusPanel.add(infoThreads); + + statusPanel.add(new JLabel("Workers:")); + statusPanel.add(infoWorkers); + + statusPanel.add(new JLabel("Sessions:")); + statusPanel.add(infoSessions); + + SpringLayoutGrid.makeCompactGrid(statusPanel, 5, 2); + return statusPanel; + } - @Override - public void addTreeModelListener(TreeModelListener l) { - super.addTreeModelListener(l); + private JPanel createPanelImport() { + JPanel statusPanel = new JPanel(); + statusPanel.setBorder(new JFireBorder("Import",statusPanel)); + statusPanel.setLayout(new SpringLayout()); + + importJdbcButton = new JButton("Jdbc"); + importMongoButton = new JButton("Mongo"); + importDataFileButton = new JButton("DataFile"); + importDataPathButton = new JButton("DataPath"); + + importJdbcButton.addActionListener(this); + importMongoButton.addActionListener(this); + importDataFileButton.addActionListener(this); + importDataPathButton.addActionListener(this); + + importJdbcButton.setEnabled(false); + importMongoButton.setEnabled(false); + importDataFileButton.setEnabled(false); + importDataPathButton.setEnabled(false); + + statusPanel.add(new JLabel("Import Jdbc:")); + statusPanel.add(importJdbcButton); + + statusPanel.add(new JLabel("Import Mongo:")); + statusPanel.add(importMongoButton); + + statusPanel.add(new JLabel("Import File:")); + statusPanel.add(importDataFileButton); + + statusPanel.add(new JLabel("Data Directory:")); + statusPanel.add(importDataPathButton); + + SpringLayoutGrid.makeCompactGrid(statusPanel,2,4,6,6,0,0); + return statusPanel; + } + + private JPanel createPanelAction() { + JPanel actionPanel = new JPanel(); + actionPanel.setBorder(new JFireBorder("Actions",actionPanel)); + actionPanel.setLayout(new SpringLayout()); + + actionPanel.add(new JLabel("Catalina:")); + + playButton = new JButton("Play"); + playButton.setEnabled(false); + playButton.addActionListener(this); + actionPanel.add(playButton); + + stopButton = new JButton("Stop"); + stopButton.setEnabled(false); + stopButton.addActionListener(this); + actionPanel.add(stopButton); + + actionPanel.add(new JLabel("Application:")); + + restartButton = new JButton("Restart"); + restartButton.setEnabled(false); + restartButton.addActionListener(this); + actionPanel.add(restartButton); + + shutdownButton = new JButton("Shutdown"); + shutdownButton.setEnabled(false); + shutdownButton.addActionListener(this); + actionPanel.add(shutdownButton); + + SpringLayoutGrid.makeCompactGrid(actionPanel,2,3,6,6,0,0); + return actionPanel; + } + + public void startupDone() { + infoStatus.setText("running"); + + //restartButton.setEnabled(true); + shutdownButton.setEnabled(true); + + importJdbcButton.setEnabled(true); + importMongoButton.setEnabled(true); + //importDataFileButton.setEnabled(true); + //importDataPathButton.setEnabled(true); + + updateInfo(); + } + + @Override + public void actionPerformed(ActionEvent e) { + if (e.getSource().equals(shutdownButton)) { + VascTechDemoStartup.getInstance().shutdown(); + } else if (e.getSource().equals(importJdbcButton)) { + JLoadDialog dialog = new JLoadDialog(ServerGuiApplication.getInstance().getMainFrame(),LoadType.JDBC); + dialog.setVisible(true); + } else if (e.getSource().equals(importMongoButton)) { + JLoadDialog dialog = new JLoadDialog(ServerGuiApplication.getInstance().getMainFrame(),LoadType.MONGODB); + dialog.setVisible(true); + } else if (e.getSource().equals(importDataFileButton)) { + JLoadDialog dialog = new JLoadDialog(ServerGuiApplication.getInstance().getMainFrame(),LoadType.JDBC); + dialog.setVisible(true); + } else if (e.getSource().equals(importDataPathButton)) { + JLoadDialog dialog = new JLoadDialog(ServerGuiApplication.getInstance().getMainFrame(),LoadType.JDBC); + dialog.setVisible(true); } } - private JScrollPane createTreePane() { + public void updateInfo() { - DefaultMutableTreeNode root = new DefaultMutableTreeNode(new VascTreeNode(VascTreeNodeType.NONE,null)); + VascController vc = VascTechDemoStartup.getInstance().getVascControllerService().getVascController(); + if (vc==null) { + return; + } + Server server = VascTechDemoStartup.getInstance().getTomcatService().getServer(); + if (server==null) { + return; // still booting + } + Service service = server.findService("Catalina"); + if (service==null) { + return; + } + Context demoContext = VascTechDemoStartup.getInstance().getTomcatService().getApplicationContext(); - vascTree = new JTree(new VascTreeModel(root)); - vascTree.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - super.mouseClicked(e); - if (e.getClickCount() == 2 && vascTree.getSelectionModel().isSelectionEmpty()==false) { - try { - DefaultMutableTreeNode node = (DefaultMutableTreeNode)vascTree.getSelectionModel().getSelectionPath().getLastPathComponent(); - if (node.getUserObject() instanceof String) { - return; - } - VascTreeNode vascNode = (VascTreeNode)node.getUserObject(); - if (vascNode != null) { - if (vascNode.type == VascTreeNodeType.ENTRY) { - VascEntryLocal ee = (VascEntryLocal)vascManager.getVascController().getVascEntryController().getVascEntryById(vascNode.id); - vascManager.getVascController().getVascEntryConfigController().configVascFrontendController(vascManager.getVascController(), ee); - spi.createNewVascView(ee); - } - } - } catch (Exception ee) { - ee.printStackTrace(); + infoVascGroups.setText(""+vc.getVascEntryController().getVascEntryGroupIds().size()); + infoVascEntries.setText(""+vc.getVascEntryController().getVascEntryIds().size()); + infoVascBackends.setText(""+vc.getVascBackendController().getVascBackendIds().size()); + + int httpPort = service.findConnectors()[0].getPort(); + infoHttpPort.setText(""+httpPort); + infoThreads.setText(""+Thread.activeCount()); + + int sessions = 0; + int workers = 0; + + if (demoContext!=null) { + sessions = demoContext.getManager().getActiveSessions(); + } + + ThreadMXBean man = ManagementFactory.getThreadMXBean(); + ThreadInfo[] infos = man.getThreadInfo(man.getAllThreadIds()); + for (ThreadInfo info:infos) { + if (info.getThreadName()!=null && info.getThreadName().startsWith("http")) { + workers++; + } + + } + + infoWorkers.setText(""+workers); + infoSessions.setText(""+sessions); + } + + + /* + * + * + + JMenuItem openXmlItem = new JMenuItem("Import Xml"); + openXmlItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + try { + final JFileChooser fc = new JFileChooser(); + //fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + int returnVal = fc.showOpenDialog((JMenuItem)e.getSource()); + if (returnVal == JFileChooser.APPROVE_OPTION) { + File file = fc.getSelectedFile(); + //VascTechDemoStartup.getInstance().getVascControllerService().openFile(file); } + } catch (Exception e1) { + e1.printStackTrace(); } } - }); - - JPanel treePanel = new JPanel(); - treePanel.setLayout(new GridLayout(1,0)); - JScrollPane p = createJScrollPane(treePanel); - p.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); - p.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); - treePanel.add(vascTree); - - rebuildTree(); - return p; - } - - private JScrollPane createContentPane() { - JPanel contentPane = new JPanel(); - contentPane.setLayout(new GridLayout(1,0)); - JScrollPane p = createJScrollPane(contentPane); - - tabPane = new JTabbedPane(); - spi = new SwingPanelTabbed(tabPane); - contentPane.add(tabPane); - - return p; - } - - private JScrollPane createJScrollPane(JPanel innerPanel) { - JScrollPane scrollPane = new JScrollPane(innerPanel); - scrollPane.setBorder(BorderFactory.createEmptyBorder()); - scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); - scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); - scrollPane.getVerticalScrollBar().setUnitIncrement(10); - scrollPane.getHorizontalScrollBar().setUnitIncrement(10); - //innerPanel.setParentScrollPane(scrollPane); - return scrollPane; - } - - class VascTreeNode implements Serializable { - private static final long serialVersionUID = -1177727401194030822L; - public VascTreeNode() {} - public VascTreeNode(VascTreeNodeType type,String id) { this.type=type;this.id=id; } - public VascTreeNode(VascTreeNodeType type,String id,String entryId) { this.type=type;this.id=id;this.entryId=entryId; } - VascTreeNodeType type; - String id; - String entryId; - @Override - public String toString() { - return id; - } - - } - enum VascTreeNodeType { - NONE, - FIELD_TYPE, - BACKEND, - ENTRY - } - - public void rebuildTree() { - - DefaultMutableTreeNode root = (DefaultMutableTreeNode)vascTree.getModel().getRoot(); - root.removeAllChildren(); - - DefaultMutableTreeNode fieldTypes = new DefaultMutableTreeNode("VascFieldTypes"); - for (String id:vascManager.getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeIds()) { - DefaultMutableTreeNode typeNode = new DefaultMutableTreeNode(new VascTreeNode(VascTreeNodeType.FIELD_TYPE,id)); - fieldTypes.add(typeNode); - } - root.add(fieldTypes); - - DefaultMutableTreeNode backends = new DefaultMutableTreeNode("VascBackends"); - for (String id:vascManager.getVascController().getVascBackendController().getVascBackendIds()) { - DefaultMutableTreeNode backendNode = new DefaultMutableTreeNode(new VascTreeNode(VascTreeNodeType.BACKEND,id)); - backends.add(backendNode); - } - root.add(backends); - - DefaultMutableTreeNode entries = new DefaultMutableTreeNode("VascEntries"); - for (String id:vascManager.getVascController().getVascEntryController().getVascEntryIds()) { - //VascEntry ve = vascManager.getVascController().getVascEntryController().getVascEntryById(id); - DefaultMutableTreeNode entryNode = new DefaultMutableTreeNode(new VascTreeNode(VascTreeNodeType.ENTRY,id)); - entries.add(entryNode); - /* - DefaultMutableTreeNode fields = new DefaultMutableTreeNode("Fields"); - for (VascEntryField vef:ve.getVascEntryFields()) { - DefaultMutableTreeNode vefNode = new DefaultMutableTreeNode(new VascTreeNode(VascTreeNodeType.ENTRY_FIELD,vef.getId(),id)); - fields.add(vefNode); - } - entryNode.add(fields); - - DefaultMutableTreeNode fieldSets = new DefaultMutableTreeNode("FieldSets"); - for (VascEntryFieldSet vefs:ve.getVascEntryFieldSets()) { - DefaultMutableTreeNode vefsNode = new DefaultMutableTreeNode(new VascTreeNode(VascTreeNodeType.ENTRY_FIELD_SET,vefs.getId(),id)); - fieldSets.add(vefsNode); - } - entryNode.add(fieldSets); - - DefaultMutableTreeNode links = new DefaultMutableTreeNode("Links"); - for (VascLinkEntry vle:ve.getVascLinkEntries()) { - DefaultMutableTreeNode vefsNode = new DefaultMutableTreeNode(new VascTreeNode(VascTreeNodeType.ENTRY_FIELD_SET,vle.getId())); - links.add(vefsNode); - } - entryNode.add(links); - - DefaultMutableTreeNode filters = new DefaultMutableTreeNode("Backend Filters"); - for (VascBackendFilter vbf:ve.getVascBackendFilters()) { - DefaultMutableTreeNode vefsNode = new DefaultMutableTreeNode(new VascTreeNode(VascTreeNodeType.ENTRY_FIELD_SET,vbf.getClass().getSimpleName())); - filters.add(vefsNode); - } - entryNode.add(links); - - DefaultMutableTreeNode param = new DefaultMutableTreeNode("Backend Parameters"); - for (String key:ve.getEntryParameterKeys()) { - DefaultMutableTreeNode vefsNode = new DefaultMutableTreeNode(new VascTreeNode(VascTreeNodeType.ENTRY_FIELD_SET,key)); - param.add(vefsNode); - } - entryNode.add(param); - - - DefaultMutableTreeNode options = new DefaultMutableTreeNode("List Options"); - for (VascEntryField vef:ve.getListOptions()) { - DefaultMutableTreeNode vefsNode = new DefaultMutableTreeNode(new VascTreeNode(VascTreeNodeType.ENTRY_FIELD_SET,vef.getId())); - options.add(vefsNode); - } - entryNode.add(options); - */ - } - root.add(entries); - - SwingUtilities.updateComponentTreeUI(vascTree); - } - - public JTabbedPane getTabPane() { - return tabPane; - } - - - - - - public void changeEvent() { - rebuildTree(); - } + + }); + */ } diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/ServerGuiApplication.java b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/ServerGuiApplication.java index 67bb407..6fe1f6f 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/ServerGuiApplication.java +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/ServerGuiApplication.java @@ -23,28 +23,32 @@ package net.forwardfire.vasc.demo.server.ui; import java.awt.AWTException; -import java.awt.CheckboxMenuItem; +import java.awt.Color; import java.awt.Dimension; -import java.awt.Image; -import java.awt.Menu; +import java.awt.Font; import java.awt.MenuItem; import java.awt.PopupMenu; import java.awt.SystemTray; import java.awt.TrayIcon; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.io.IOException; +import java.io.InputStream; import java.net.URL; import java.util.EventObject; +import java.util.Properties; +import java.util.logging.Logger; import javax.swing.ImageIcon; -import javax.swing.JTabbedPane; +import javax.swing.JOptionPane; +import javax.swing.UIManager; import net.forwardfire.vasc.demo.server.core.VascTechDemoStartup; -import org.jdesktop.application.Application; import org.jdesktop.application.FrameView; import org.jdesktop.application.SingleFrameApplication; -import org.jdesktop.application.Application.ExitListener; /** * SwingGuiService Shows the demo swing gui and vasc swing frontend. @@ -54,77 +58,113 @@ import org.jdesktop.application.Application.ExitListener; */ public class ServerGuiApplication extends SingleFrameApplication { + private Logger logger = null; + private JStatusPanel statusPanel = null; + private ImageIcon serverIcon = null; + + public ServerGuiApplication() { + logger = Logger.getLogger(ServerGuiApplication.class.getName()); + } + protected void startup() { - addExitListener(new ShutdownManager()); + installColorsLaF(); + addExitListener(new CloseWindowExitListener()); + serverIcon = createImageIcon("/net/forwardfire/vasc/demo/server/ui/resources/icon.png", "Vasc Icon"); + statusPanel = new JStatusPanel(); FrameView mainView = getMainView(); - - mainView.setComponent(new JStartupPanel()); - mainView.getFrame().setMinimumSize(new Dimension(600,200)); - //mainView.getFrame().setResizable(false); + mainView.setComponent(statusPanel); + mainView.getFrame().setMinimumSize(new Dimension(640,480)); + mainView.getFrame().setMaximumSize(new Dimension(800,600)); + mainView.getFrame().addWindowListener(new UpdateInfoListener()); + show(mainView); - startSystemTray(); } - public void startupDone() { - getMainFrame().setVisible(false); + class UpdateInfoListener extends WindowAdapter { + @Override + public void windowActivated(WindowEvent e) { + System.out.println("vis: opened -ac"); + statusPanel.updateInfo(); + } + @Override + public void windowDeactivated(WindowEvent e) { + System.out.println("vis: closed - ac"); + } + } + class CloseWindowExitListener implements ExitListener { + @Override + public boolean canExit(EventObject event) { + if (event!=null && event.getSource().equals(ServerGuiApplication.this)) { + return true; + } else { + ServerGuiApplication.getInstance().getMainFrame().setVisible(false); + return false; + } + } + + @Override + public void willExit(EventObject event) { + } + } + + public void startupDone() { + statusPanel.startupDone(); + } + + /** + * Stop if requested from service + */ public void stop() { - exit(); + //shutdown(); + exit(new EventObject(this)); + } + + public ImageIcon getServerIcon() { + return serverIcon; } static public ServerGuiApplication getInstance() { return getInstance(ServerGuiApplication.class); } - - class ShutdownManager implements ExitListener { - public boolean canExit(EventObject e) { - return true; - } - public void willExit(EventObject event) { - VascTechDemoStartup.getInstance().shutdown(); - } - } - + private void startSystemTray() { if (!SystemTray.isSupported()) { return; } final PopupMenu popup = new PopupMenu(); - final TrayIcon trayIcon = new TrayIcon(createImage("/net/forwardfire/vasc/demo/server/ui/resources/tray-icon.png", "tray icon")); + final TrayIcon trayIcon = new TrayIcon(createImageIcon("/net/forwardfire/vasc/demo/server/ui/resources/tray-icon.png", "tray icon").getImage()); final SystemTray tray = SystemTray.getSystemTray(); MenuItem aboutItem = new MenuItem("About"); - MenuItem statusItem = new MenuItem("View Status"); - MenuItem logItem = new MenuItem("View Log"); - - - Menu displayMenu = new Menu("Launch"); - MenuItem errorItem = new MenuItem("Web client"); - MenuItem warningItem = new MenuItem("Swing client"); - MenuItem infoItem = new MenuItem("Swt client"); - MenuItem noneItem = new MenuItem("None"); - + aboutItem.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + JOptionPane.showMessageDialog(ServerGuiApplication.getInstance().getMainFrame(), "Vasc Demo Tech Server:\nIs build to test and demo different parts of the vasc package.", "About Vasc Demo", JOptionPane.PLAIN_MESSAGE); + } + }); + MenuItem statusItem = new MenuItem("Open Status"); + statusItem.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + getMainFrame().setVisible(true); + } + }); MenuItem exitItem = new MenuItem("Exit"); exitItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { - exit(); + VascTechDemoStartup.getInstance().shutdown(); } }); - popup.add(aboutItem); - popup.addSeparator(); - popup.add(statusItem); - popup.add(logItem); - popup.addSeparator(); - popup.add(displayMenu); - displayMenu.add(errorItem); - displayMenu.add(warningItem); - displayMenu.add(infoItem); - displayMenu.add(noneItem); + popup.add(exitItem); + popup.addSeparator(); + popup.add(aboutItem); + popup.add(statusItem); trayIcon.setPopupMenu(popup); @@ -135,11 +175,45 @@ public class ServerGuiApplication extends SingleFrameApplication { } } - protected static Image createImage(String path, String description) { + protected static ImageIcon createImageIcon(String path, String description) { URL imageURL = ServerGuiApplication.class.getResource(path); if (imageURL == null) { throw new NullPointerException("Could not find resource: "+path); } - return (new ImageIcon(imageURL, description)).getImage(); + return new ImageIcon(imageURL, description); + } + + private String installColorsLaF() { + UIManager.put("TabbedPane.font", Font.decode("SansSerif-BOLD-12")); + UIManager.put("TitledBorder.font", Font.decode("SansSerif-BOLD-16")); + UIManager.put("FireDial.font", Font.decode("SansSerif-9")); + + String colorName = "laf-colors"; + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + if (cl==null) { + cl = this.getClass().getClassLoader(); + } + InputStream in = cl.getResourceAsStream("net/forwardfire/vasc/demo/server/ui/resources/"+colorName+".properties"); + if (in==null) { + logger.warning("Color schema not found: "+colorName); + return "unknown"; + } + try { + Properties p = new Properties(); + p.load(in); + for (Object key:p.keySet()) { + String value = p.getProperty(key.toString()); + Color colorValue = Color.decode(value); + UIManager.put(key,colorValue); + } + } catch (IOException e) { + logger.warning("Could not load color schema: "+colorName+" error: "+e.getMessage()); + } finally { + try { + in.close(); + } catch (IOException e) { + } + } + return colorName; } } diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadDialog.java b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadDialog.java new file mode 100644 index 0000000..363342b --- /dev/null +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadDialog.java @@ -0,0 +1,241 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.demo.server.ui.load; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +import org.eobjects.metamodel.jdbc.JdbcDataContext; +import org.eobjects.metamodel.mongodb.MongoDbDataContext; + +import net.forwardfire.vasc.demo.server.ui.JFireBorder; +import net.forwardfire.vasc.demo.server.ui.ServerGuiApplication; + +/** + * JLoadDialog mini wizzard for loading. + * + * @author Willem Cazander + * @version 1.0 May 9, 2012 + */ +public class JLoadDialog extends JDialog implements ActionListener { + + private static final long serialVersionUID = -8638394652416472734L; + private JButton prev = null; + private JButton next = null; + private JButton cancel = null; + private List steps = null; + private int currentStep = 0; + private LoadStepData model = null; + private JPanel centerPanel = null; + private JLabel topLabel = null; + + public enum LoadType { + CSV, + JDBC, + MONGODB + } + + public JLoadDialog(Frame aFrame,LoadType type) { + setTitle("Load Edit Data"); + setIconImage(ServerGuiApplication.getInstance().getServerIcon().getImage()); + setMinimumSize(new Dimension(640,400)); + setPreferredSize(new Dimension(640,400)); + setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent we) { + clearAndHide(); + } + }); + JPanel mainPanel = new JPanel(); + // mainPanel.setBorder(); + // mainPanel.setLayout(new SpringLayout()); + mainPanel.setLayout(new BorderLayout()); + mainPanel.add(createPanelTop(),BorderLayout.PAGE_START); + + JPanel wrap = new JPanel(); + wrap.setLayout(new GridLayout(1,1)); + wrap.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); + + centerPanel = new JPanel(); + //centerPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); + centerPanel.setLayout(new GridLayout(1,1)); + centerPanel.setBorder(new JFireBorder(null,centerPanel)); + + wrap.add(centerPanel); + mainPanel.add(wrap,BorderLayout.CENTER); + + model = new LoadStepData(); + steps = new ArrayList(10); + + switch(type) { + case CSV: + break; + case JDBC: + steps.add(new JLoadStepMetaJdbc()); + break; + case MONGODB: + steps.add(new JLoadStepMetaMongodb()); + break; + } + steps.add(new JLoadStepSelectTables()); + steps.add(new JLoadStepMiscInfo()); + steps.add(new JLoadStepWriteFile()); + + centerPanel.add(steps.get(0).getPanel()); + + mainPanel.add(createPanelBottom(),BorderLayout.PAGE_END); + //SpringLayoutGrid.makeCompactGrid(mainPanel, 3, 1,6,6,6,6); + getContentPane().add(mainPanel); + pack(); + setLocationRelativeTo(aFrame); + } + + public void clearAndHide() { + setVisible(false); + + // clean up connection + if (model.dc instanceof JdbcDataContext) { + JdbcDataContext dc = (JdbcDataContext)model.dc; + try { + dc.getConnection().close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + if (model.dc instanceof MongoDbDataContext) { + MongoDbDataContext dc = (MongoDbDataContext)model.dc; + dc.getMongoDb().getMongo().close(); + } + } + + public JPanel createPanelTop() { + JPanel top = new JPanel(); + top.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); + top.setLayout(new GridLayout(1,1)); + JPanel wrap = new JPanel(); + wrap.setLayout(new FlowLayout(FlowLayout.LEFT)); + wrap.setBorder(new JFireBorder("Load",top)); + topLabel = new JLabel("Load data to edit..."); + wrap.add(topLabel); + top.add(wrap); + return top; + } + + public JPanel createPanelBottom() { + JPanel bottom = new JPanel(); + bottom.setLayout(new FlowLayout(FlowLayout.RIGHT)); + + prev = new JButton("Prev"); + next = new JButton("Next"); + cancel = new JButton("Cancel"); + + prev.addActionListener(this); + next.addActionListener(this); + cancel.addActionListener(this); + + prev.setEnabled(false); + + bottom.add(prev); + bottom.add(next); + bottom.add(cancel); + + return bottom; + } + + + public void actionPerformed(ActionEvent e) { + if (e.getSource().equals(prev)) { + gotoStepPrev(); + } else if (e.getSource().equals(next)) { + gotoStepNext(); + } if (e.getSource().equals(cancel)) { + clearAndHide(); + } + } + + public void gotoStepPrev() { + if (currentStep <= 0) { + return; + } + currentStep--; + centerPanel.removeAll(); + LoadStep step = steps.get(currentStep); + centerPanel.add(step.getPanel()); + topLabel.setText(step.getStepTitle()); + step.setupStep(model); + SwingUtilities.updateComponentTreeUI(centerPanel); + if (currentStep==0) { + prev.setEnabled(false); + } + next.setText("Next"); + } + + public void gotoStepNext() { + if (currentStep == steps.size()-1) { + // perform last step + LoadStep step = steps.get(currentStep); + boolean result = step.performStep(model); + if (result==false) { + return; + } + clearAndHide(); + return; + } + if (currentStep > steps.size()-1) { + return; + } + LoadStep step = steps.get(currentStep); + boolean result = step.performStep(model); + if (result==false) { + return; + } + currentStep++; + centerPanel.removeAll(); + step = steps.get(currentStep); + centerPanel.add(step.getPanel()); + topLabel.setText(step.getStepTitle()); + step.setupStep(model); + SwingUtilities.updateComponentTreeUI(centerPanel); + if (currentStep==steps.size()-1) { + next.setText("Finish"); + } + prev.setEnabled(true); + } +} diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/actions/JDialogMetaCsv.java b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadStepMetaCsv.java similarity index 83% rename from vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/actions/JDialogMetaCsv.java rename to vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadStepMetaCsv.java index 109620d..33528d8 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/actions/JDialogMetaCsv.java +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadStepMetaCsv.java @@ -20,27 +20,23 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.forwardfire.vasc.demo.server.ui.actions; +package net.forwardfire.vasc.demo.server.ui.load; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Frame; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; import java.io.File; import javax.swing.BorderFactory; import javax.swing.JButton; -import javax.swing.JDialog; import javax.swing.JFileChooser; import javax.swing.JLabel; import javax.swing.JPanel; import net.forwardfire.vasc.backend.metamodel.MetaModelDataContextCsv; import net.forwardfire.vasc.backend.metamodel.MetaModelSchemaAutoEntry; -import net.forwardfire.vasc.demo.server.core.VascTechDemoStartup; /** * JDialogMetaCsv Add and runs MetaModel Schema Auto Entry code. @@ -48,29 +44,21 @@ import net.forwardfire.vasc.demo.server.core.VascTechDemoStartup; * @author Willem Cazander * @version 1.0 May 9, 2012 */ -public class JDialogMetaCsv extends JDialog implements ActionListener { +public class JLoadStepMetaCsv extends JPanel implements ActionListener { private static final long serialVersionUID = -8638394652416472734L; - public JDialogMetaCsv(Frame aFrame) { - setTitle("Add csv file"); + public JLoadStepMetaCsv(Frame aFrame) { + //setTitle("Add csv file"); setMinimumSize(new Dimension(640,480)); setPreferredSize(new Dimension(999,666)); - setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); - addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent we) { - clearAndHide(); - } - }); JPanel mainPanel = new JPanel(); mainPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); mainPanel.setLayout(new BorderLayout()); //mainPanel.add(createPanelTop(),BorderLayout.NORTH); mainPanel.add(createPanelCenter(),BorderLayout.CENTER); //mainPanel.add(createPanelBottom(),BorderLayout.SOUTH); - getContentPane().add(mainPanel); - pack(); - setLocationRelativeTo(aFrame); + add(mainPanel); } public void clearAndHide() { @@ -95,7 +83,7 @@ public class JDialogMetaCsv extends JDialog implements ActionListener { MetaModelSchemaAutoEntry schema = new MetaModelSchemaAutoEntry(); schema.setDataContextProvider(ds); schema.setEntryPrefix(file.getName()); - schema.autoCreateEntries(VascTechDemoStartup.getInstance().getVascControllerService().getVascController()); + //schema.autoCreateEntries(VascTechDemoStartup.getInstance().getVascControllerService().getVascController()); //VascTechDemoStartup.getInstance().getVascControllerService().fireChangeEvent(); } } diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/actions/JDialogMetaJdbc.java b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadStepMetaJdbc.java similarity index 54% rename from vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/actions/JDialogMetaJdbc.java rename to vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadStepMetaJdbc.java index 9c37be3..c5f9b53 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/actions/JDialogMetaJdbc.java +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadStepMetaJdbc.java @@ -20,28 +20,21 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.forwardfire.vasc.demo.server.ui.actions; +package net.forwardfire.vasc.demo.server.ui.load; -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; +import java.awt.FlowLayout; +import java.sql.Connection; -import javax.swing.BorderFactory; -import javax.swing.JButton; import javax.swing.JComboBox; -import javax.swing.JDialog; import javax.swing.JLabel; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.SpringLayout; +import org.eobjects.metamodel.jdbc.JdbcDataContext; + import net.forwardfire.vasc.backend.metamodel.MetaModelDataContextJdbc; -import net.forwardfire.vasc.backend.metamodel.MetaModelSchemaAutoEntry; -import net.forwardfire.vasc.demo.server.core.VascTechDemoStartup; import net.forwardfire.vasc.demo.server.ui.SpringLayoutGrid; /** @@ -50,7 +43,7 @@ import net.forwardfire.vasc.demo.server.ui.SpringLayoutGrid; * @author Willem Cazander * @version 1.0 May 9, 2012 */ -public class JDialogMetaJdbc extends JDialog implements ActionListener { +public class JLoadStepMetaJdbc extends JPanel implements LoadStep { private static final long serialVersionUID = -8638394652416472734L; private JComboBox driverClassBox = null; @@ -59,31 +52,19 @@ public class JDialogMetaJdbc extends JDialog implements ActionListener { private JTextField passwordField = null; - public JDialogMetaJdbc(Frame aFrame) { - setTitle("Add jdbc"); - setMinimumSize(new Dimension(300,200)); - setPreferredSize(new Dimension(500,400)); - setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); - addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent we) { - clearAndHide(); - } - }); - JPanel mainPanel = new JPanel(); - mainPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); - mainPanel.setLayout(new BorderLayout()); - //mainPanel.add(createPanelTop(),BorderLayout.NORTH); - mainPanel.add(createPanelCenter(),BorderLayout.CENTER); - //mainPanel.add(createPanelBottom(),BorderLayout.SOUTH); - getContentPane().add(mainPanel); - pack(); - setLocationRelativeTo(aFrame); + public JLoadStepMetaJdbc() { + setLayout(new FlowLayout(FlowLayout.LEFT)); + add(createPanelCenter()); } - public void clearAndHide() { - setVisible(false); + public String getStepTitle() { + return "Connect to database."; } + public JPanel getPanel() { + return this; + } + public JPanel createPanelCenter() { JPanel result = new JPanel(); result.setLayout(new SpringLayout()); @@ -105,32 +86,41 @@ public class JDialogMetaJdbc extends JDialog implements ActionListener { passwordField = new JTextField("postgresql"); result.add(passwordField); - JButton fileButton = new JButton("Connect"); - fileButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - String url = connectUrlField.getText(); - MetaModelDataContextJdbc ds = new MetaModelDataContextJdbc(); - ds.setDriverClass((String)driverClassBox.getSelectedItem()); - ds.setConnectUrl(url); - ds.setUsername(usernameField.getText()); - ds.setPassword(passwordField.getText()); - String dbName = url.substring(url.lastIndexOf('/')+1,url.length()); - MetaModelSchemaAutoEntry schema = new MetaModelSchemaAutoEntry(); - schema.setDataContextProvider(ds); - schema.setEntryPrefix(dbName); - schema.autoCreateEntries(VascTechDemoStartup.getInstance().getVascControllerService().getVascController()); - //VascTechDemoStartup.getInstance().getVascControllerService().fireChangeEvent(); - } - }); - result.add(fileButton); - result.add(new JLabel("")); - - SpringLayoutGrid.makeCompactGrid(result, 5, 2); + SpringLayoutGrid.makeCompactGrid(result, 4, 2); return result; } - public void actionPerformed(ActionEvent arg0) { - // TODO Auto-generated method stub + public void setupStep(LoadStepData model) { - } + } + + @Override + public boolean performStep(LoadStepData model) { + String url = connectUrlField.getText(); + MetaModelDataContextJdbc ds = new MetaModelDataContextJdbc(); + ds.setDriverClass((String)driverClassBox.getSelectedItem()); + ds.setConnectUrl(url); + ds.setUsername(usernameField.getText()); + ds.setPassword(passwordField.getText()); + String dbName = url.substring(url.lastIndexOf('/')+1,url.length()); + + try { + Connection c = ds.getConnection(); + c.close(); + + if (model.dc instanceof JdbcDataContext) { + JdbcDataContext dc = (JdbcDataContext)model.dc; + dc.getConnection().close(); + } + + model.dcProvider = ds; + model.dc=ds.getDataContext(); + model.name=dbName; + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, "Fatal connect error:\n"+e.getMessage(), "Jdbc Connect Error", JOptionPane.ERROR_MESSAGE); + return false; + } + return true; + } } diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/actions/JDialogMetaMongodb.java b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadStepMetaMongodb.java similarity index 52% rename from vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/actions/JDialogMetaMongodb.java rename to vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadStepMetaMongodb.java index b88b33e..51cb9b6 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/actions/JDialogMetaMongodb.java +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadStepMetaMongodb.java @@ -20,65 +20,49 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.forwardfire.vasc.demo.server.ui.actions; +package net.forwardfire.vasc.demo.server.ui.load; -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.Frame; +import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JDialog; import javax.swing.JLabel; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.SpringLayout; +import org.eobjects.metamodel.mongodb.MongoDbDataContext; + +import com.mongodb.DB; + import net.forwardfire.vasc.backend.metamodel.MetaModelDataContextMongodb; -import net.forwardfire.vasc.backend.metamodel.MetaModelSchemaAutoEntry; -import net.forwardfire.vasc.demo.server.core.VascTechDemoStartup; import net.forwardfire.vasc.demo.server.ui.SpringLayoutGrid; /** - * JDialogMetaMongodb Add and runs MetaModel Schema Auto Entry code. + * JLoadStepMetaMongodb Add and runs MetaModel Schema Auto Entry code. * * @author Willem Cazander * @version 1.0 May 9, 2012 */ -public class JDialogMetaMongodb extends JDialog implements ActionListener { +public class JLoadStepMetaMongodb extends JPanel implements LoadStep,ActionListener { private static final long serialVersionUID = -8638394652416472734L; private JTextField hostNameField = null; private JTextField hostPortField = null; private JTextField databaseField = null; - public JDialogMetaMongodb(Frame aFrame) { - setTitle("Add mongodb"); - setMinimumSize(new Dimension(300,200)); - setPreferredSize(new Dimension(400,300)); - setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); - addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent we) { - clearAndHide(); - } - }); - JPanel mainPanel = new JPanel(); - mainPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); - mainPanel.setLayout(new BorderLayout()); - //mainPanel.add(createPanelTop(),BorderLayout.NORTH); - mainPanel.add(createPanelCenter(),BorderLayout.CENTER); - //mainPanel.add(createPanelBottom(),BorderLayout.SOUTH); - getContentPane().add(mainPanel); - pack(); - setLocationRelativeTo(aFrame); + public JLoadStepMetaMongodb() { + setLayout(new FlowLayout(FlowLayout.LEFT)); + add(createPanelCenter()); } - public void clearAndHide() { - setVisible(false); + public String getStepTitle() { + return "Connect to mongodb."; + } + + public JPanel getPanel() { + return this; } public JPanel createPanelCenter() { @@ -86,7 +70,7 @@ public class JDialogMetaMongodb extends JDialog implements ActionListener { result.setLayout(new SpringLayout()); result.add(new JLabel("Hostname")); - hostNameField = new JTextField("localhost"); + hostNameField = new JTextField("localhost",25); result.add(hostNameField); result.add(new JLabel("Port")); @@ -96,31 +80,45 @@ public class JDialogMetaMongodb extends JDialog implements ActionListener { result.add(new JLabel("Database")); databaseField = new JTextField("lefiona"); result.add(databaseField); - - JButton fileButton = new JButton("Connect"); - fileButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - MetaModelDataContextMongodb ds = new MetaModelDataContextMongodb(); - ds.setHostname(hostNameField.getText()); - ds.setPort(new Integer(hostPortField.getText())); - ds.setDatabase(databaseField.getText()); - - MetaModelSchemaAutoEntry schema = new MetaModelSchemaAutoEntry(); - schema.setDataContextProvider(ds); - schema.setEntryPrefix(ds.getDatabase()); - schema.autoCreateEntries(VascTechDemoStartup.getInstance().getVascControllerService().getVascController()); - //VascTechDemoStartup.getInstance().getVascControllerService().fireChangeEvent(); - } - }); - result.add(fileButton); - result.add(new JLabel("")); - - SpringLayoutGrid.makeCompactGrid(result, 4, 2); + + SpringLayoutGrid.makeCompactGrid(result, 3, 2); return result; } public void actionPerformed(ActionEvent arg0) { // TODO Auto-generated method stub + } + + public void setupStep(LoadStepData model) { + + } + + @Override + public boolean performStep(LoadStepData model) { + + MetaModelDataContextMongodb ds = new MetaModelDataContextMongodb(); + ds.setHostname(hostNameField.getText()); + ds.setPort(new Integer(hostPortField.getText())); + ds.setDatabase(databaseField.getText()); + + try { + DB mongoDB = ds.getMongodbConnection(); + mongoDB.getMongo().close(); + + if (model.dc instanceof MongoDbDataContext) { + MongoDbDataContext dc = (MongoDbDataContext)model.dc; + dc.getMongoDb().getMongo().close(); + } + + model.dcProvider = ds; + model.dc=ds.getDataContext(); + model.name=ds.getDatabase(); + } catch (Exception e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, "Fatal connect error:\n"+e.getMessage(), "Jdbc Connect Error", JOptionPane.ERROR_MESSAGE); + return false; + } + return true; } } diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadStepMiscInfo.java b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadStepMiscInfo.java new file mode 100644 index 0000000..dd3c848 --- /dev/null +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadStepMiscInfo.java @@ -0,0 +1,98 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.demo.server.ui.load; + +import java.awt.FlowLayout; + +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.SpringLayout; + +import net.forwardfire.vasc.demo.server.ui.SpringLayoutGrid; + +/** + * JLoadStepMiscInfo + * + * @author Willem Cazander + * @version 1.0 Nov 21, 2012 + */ +public class JLoadStepMiscInfo extends JPanel implements LoadStep { + + private static final long serialVersionUID = -8638394652416472734L; + private JTextField filenameField = null; + private JTextField groupIdField = null; + private JTextField rolesGroupField = null; + private JTextField rolesEntryField = null; + + public JLoadStepMiscInfo() { + setLayout(new FlowLayout(FlowLayout.LEFT)); + add(createPanelCenter()); + } + + public String getStepTitle() { + return "Select Info"; + } + + public JPanel getPanel() { + return this; + } + + public JPanel createPanelCenter() { + JPanel result = new JPanel(); + result.setLayout(new SpringLayout()); + + filenameField = new JTextField(); + groupIdField = new JTextField(); + rolesGroupField = new JTextField(); + rolesEntryField = new JTextField(); + + result.add(new JLabel("Filename:")); + result.add(filenameField); + result.add(new JLabel("groupId:")); + result.add(groupIdField); + result.add(new JLabel("rolesGroup:")); + result.add(rolesGroupField); + result.add(new JLabel("rolesEntry:")); + result.add(rolesEntryField); + + SpringLayoutGrid.makeCompactGrid(result, 4, 2); + return result; + } + + public void setupStep(LoadStepData model) { + filenameField.setText(model.name+".xml"); + groupIdField.setText(model.name); + rolesGroupField.setText("login,admin"); + rolesEntryField.setText("login,admin"); + } + + @Override + public boolean performStep(LoadStepData model) { + model.filename = filenameField.getText(); + model.groupId = groupIdField.getText(); + model.rolesGroup = rolesGroupField.getText(); + model.rolesEntry = rolesEntryField.getText(); + return true; + } +} diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadStepSelectTables.java b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadStepSelectTables.java new file mode 100644 index 0000000..710ffcb --- /dev/null +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadStepSelectTables.java @@ -0,0 +1,180 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.demo.server.ui.load; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.ScrollPaneConstants; +import javax.swing.SpringLayout; +import javax.swing.table.AbstractTableModel; + +import org.eobjects.metamodel.DataContext; + +import net.forwardfire.vasc.demo.server.ui.SpringLayoutGrid; + + +/** + * JLoadStepSelectTables select tables to load. + * + * @author Willem Cazander + * @version 1.0 May 9, 2012 + */ +public class JLoadStepSelectTables extends JPanel implements LoadStep { + + private static final long serialVersionUID = -8638394652416472734L; + private JTable table = null; + private MetaModelTableModel tableModel = null; + private DataContext dcOld = null; + + public JLoadStepSelectTables() { + setLayout(new SpringLayout()); + add(createPanelCenter()); + SpringLayoutGrid.makeCompactGrid(this, 1, 1, 6, 6, 6, 6); + } + + public String getStepTitle() { + return "Select Tables"; + } + + public JPanel getPanel() { + return this; + } + + public JComponent createPanelCenter() { + tableModel = new MetaModelTableModel(); + table = new JTable(tableModel); + table.setFillsViewportHeight(true); + table.setShowHorizontalLines(true); + table.setAutoscrolls(true); + //((JComponent) table.getDefaultRenderer(Boolean.class)).setOpaque(true);// let backgroup color work correctly + JScrollPane scrollPane = new JScrollPane(table); + scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); + scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); + return scrollPane; + } + + public void setupStep(LoadStepData model) { + if (model.tables.isEmpty() | (dcOld!=null && dcOld!=model.dc)) { + tableModel.setData(Arrays.asList(model.dc.getDefaultSchema().getTableNames())); + dcOld = model.dc; + } + } + + + @Override + public boolean performStep(LoadStepData model) { + model.tables.clear(); + for (TableRow row:tableModel.getData()) { + if (row.load) { + model.tables.add(row.table); + } + } + return true; + } + + class TableRow { + String table; + boolean load = true; + } + + class MetaModelTableModel extends AbstractTableModel { + + private static final long serialVersionUID = 5487313677918103654L; + private List data = new ArrayList(); + + public void setData(List tables) { + data.clear(); + for (String table:tables) { + TableRow row = new TableRow(); + row.table=table; + data.add(row); + } + fireTableDataChanged(); + } + + public List getData() { + return data; + } + + @Override + public Class getColumnClass(int columnIndex) { + if (columnIndex==0) { + return String.class; + } else { + return Boolean.class; + } + } + + + @Override + public int getColumnCount() { + return 2; + } + + @Override + public String getColumnName(int columnIndex) { + if (columnIndex==0) { + return "TableName"; + } else { + return "Import"; + } + } + + @Override + public int getRowCount() { + return data.size(); + } + + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + TableRow row = data.get(rowIndex); + if (columnIndex==0) { + return row.table; + } else { + return new Boolean(row.load); + } + } + + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + return columnIndex>0; + } + + @Override + public void setValueAt(Object value, int rowIndex, int columnIndex) { + if (columnIndex==1) { + TableRow row = data.get(rowIndex); + if (value instanceof Boolean) { + row.load = (Boolean)value; + } + } + } + } +} diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadStepWriteFile.java b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadStepWriteFile.java new file mode 100644 index 0000000..9ab5736 --- /dev/null +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/JLoadStepWriteFile.java @@ -0,0 +1,118 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.demo.server.ui.load; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.FileOutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; + +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.ScrollPaneConstants; +import javax.swing.SpringLayout; + +import org.x4o.xml.sax.XMLWriter; + +import net.forwardfire.vasc.core.VascController; +import net.forwardfire.vasc.demo.server.core.VascTechDemoStartup; +import net.forwardfire.vasc.demo.server.ui.SpringLayoutGrid; + +/** + * JLoadStepWriteFile writes the file. + * + * @author Willem Cazander + * @version 1.0 Nov 21, 2012 + */ +public class JLoadStepWriteFile extends JPanel implements LoadStep,ActionListener { + + private static final long serialVersionUID = -8638394652416472734L; + private JTextArea text = null; + + public JLoadStepWriteFile() { + setLayout(new SpringLayout()); + add(createPanelCenter()); + SpringLayoutGrid.makeCompactGrid(this, 1, 1, 6, 6, 6, 6); + } + + public String getStepTitle() { + return "Select Tables"; + } + + public JPanel getPanel() { + return this; + } + + public JComponent createPanelCenter() { + text = new JTextArea(13,45); + text.setAutoscrolls(true); + JScrollPane scrollPane = new JScrollPane(text); + scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); + scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + return scrollPane; + } + + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + + } + + public void setupStep(LoadStepData model) { + try { + VascController vc = VascTechDemoStartup.getInstance().getVascControllerService().getVascController(); + StringWriter out = new StringWriter(); + XMLWriter outXml = new XMLWriter(out); + LoadVascXmlWriter writer = new LoadVascXmlWriter(outXml,vc); + writer.writeXml(model); + + text.setText(out.getBuffer().toString()); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public boolean performStep(LoadStepData model) { + + try { + VascController vc = VascTechDemoStartup.getInstance().getVascControllerService().getVascController(); + File tmpFile = new File("conf/vasc.d/"+model.filename);// File.createTempFile("vasc","xml"); + System.out.println("write to : "+tmpFile); + Writer out = new OutputStreamWriter(new FileOutputStream(tmpFile)); + XMLWriter outXml = new XMLWriter(out); + LoadVascXmlWriter writer = new LoadVascXmlWriter(outXml,vc); + writer.writeXml(model); + + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return true; + } +} diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuGroupComparator.java b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/LoadStep.java similarity index 68% rename from vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuGroupComparator.java rename to vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/LoadStep.java index baeeaee..a703256 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuGroupComparator.java +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/LoadStep.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2012 forwardfire.net All rights reserved. + * Copyright 2007-2012 forwardfire.net All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided * that the following conditions are met: @@ -20,30 +20,24 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package net.forwardfire.vasc.demo.tech.ejb3.menu.model; - -import java.io.Serializable; -import java.util.Comparator; - - - /** - * VascMenuGroupComparator orders the menu group. + * LoadStep are the load wizzard steps. * * @author Willem Cazander - * @version 1.0 nov 17, 2012 + * @version 1.0 Nov 21, 2012 */ -public class VascMenuGroupComparator implements Serializable,Comparator { +package net.forwardfire.vasc.demo.server.ui.load; + + +import javax.swing.JPanel; + +public interface LoadStep { + + JPanel getPanel(); - private static final long serialVersionUID = 386631856823832371L; + String getStepTitle(); - public int compare(VascMenuGroup m1, VascMenuGroup m2) { - if (m1.getMenuOrder()==null) { - return 1; - } - if (m2.getMenuOrder()==null) { - return -1; - } - return m1.getMenuOrder().compareTo(m2.getMenuOrder()); - } -} \ No newline at end of file + void setupStep(LoadStepData model); + + boolean performStep(LoadStepData model); +} diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/LoadStepData.java b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/LoadStepData.java new file mode 100644 index 0000000..983f00d --- /dev/null +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/LoadStepData.java @@ -0,0 +1,50 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.demo.server.ui.load; + +import java.util.ArrayList; +import java.util.List; + +import org.eobjects.metamodel.DataContext; + +import net.forwardfire.vasc.backend.metamodel.MetaModelDataContextProvider; + +/** + * LoadStepData Simple model to load wizzard steps. + * + * @author Willem Cazander + * @version 1.0 Nov 21, 2012 + */ +public class LoadStepData { + + public String name = null; + public MetaModelDataContextProvider dcProvider = null; + public DataContext dc = null; + + public String filename = null; + public String groupId = null; + public String rolesGroup = null; + public String rolesEntry = null; + public List tables = new ArrayList(); + +} diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/LoadVascXmlWriter.java b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/LoadVascXmlWriter.java new file mode 100644 index 0000000..5f8c031 --- /dev/null +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/java/net/forwardfire/vasc/demo/server/ui/load/LoadVascXmlWriter.java @@ -0,0 +1,242 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.forwardfire.vasc.demo.server.ui.load; + +import net.forwardfire.vasc.backend.metamodel.MetaModelDataContextJdbc; +import net.forwardfire.vasc.backend.metamodel.MetaModelDataContextMongodb; +import net.forwardfire.vasc.backend.metamodel.MetaModelSchemaAutoEntry; +import net.forwardfire.vasc.backend.metamodel.MetaModelVascBackend; +import net.forwardfire.vasc.core.VascController; +import net.forwardfire.vasc.core.VascEntry; +import net.forwardfire.vasc.core.VascEntryField; +import net.forwardfire.vasc.core.VascEntryFieldType; +import net.forwardfire.vasc.core.VascEntryLink; +import net.forwardfire.vasc.core.VascEntryLinkType; +import net.forwardfire.vasc.impl.ui.VascSelectItemModelEntry; + +import org.xml.sax.SAXException; +import org.xml.sax.ext.DefaultHandler2; +import org.xml.sax.helpers.AttributesImpl; + +/** + * LoadVascXmlWriter writes the xml tags. + * note: need to move this to x4o + * + * @author Willem Cazander + * @version 1.0 Nov 22, 2012 + */ +public class LoadVascXmlWriter { + + private VascController vc = null; + private DefaultHandler2 xmlWriter = null; + + static private final String URI_VASC_ROOT = "http://vasc.forwardfire.net/xml/ns/vasc-root"; + static private final String URI_VASC_LANG = "http://vasc.forwardfire.net/xml/ns/vasc-lang"; + static private final String URI_META_MODEL = "http://vasc.forwardfire.net/xml/ns/vasc-backend-metamodel"; + static private final String URI_VASC_DEMO = "http://vasc.forwardfire.net/xml/ns/vasc-tech-demo"; + + public LoadVascXmlWriter(DefaultHandler2 xmlWriter,VascController vc) { + this.xmlWriter=xmlWriter; + this.vc=vc; + } + + public void writeXml(LoadStepData model) throws SAXException { + + MetaModelSchemaAutoEntry autoEntry = new MetaModelSchemaAutoEntry(); + autoEntry.setVascGroupId(model.groupId); + autoEntry.setEntryPrefix(model.name); + autoEntry.setDataContextProvider(model.dcProvider); + autoEntry.getTables().addAll(model.tables); + + autoEntry.autoFillResult(vc); + + xmlWriter.startDocument(); + + char[] msg; + msg = "\n".toCharArray(); + xmlWriter.ignorableWhitespace(msg,0,msg.length); + + xmlWriter.startPrefixMapping("vasc", URI_VASC_ROOT); + xmlWriter.startPrefixMapping("v", URI_VASC_LANG); + xmlWriter.startPrefixMapping("mm", URI_META_MODEL); + xmlWriter.startPrefixMapping("td", URI_VASC_DEMO); + + AttributesImpl atts = new AttributesImpl(); + xmlWriter.startElement (URI_VASC_ROOT, "root", "", atts); + + msg = "Auto generated vasc xml example.".toCharArray(); + xmlWriter.comment(msg,0,msg.length); + + writeGroup(model.groupId,model.rolesGroup); + writeMetaProvider(model); + + for (MetaModelVascBackend vb:autoEntry.getResultBackends()) { + writeEntryBackend(vb,model); + } + for (VascEntry ve:autoEntry.getResultEntries()) { + writeEntry(ve,model); + } + + + xmlWriter.endElement(URI_VASC_ROOT, "root", ""); + xmlWriter.endDocument(); + } + + private void writeMetaProvider(LoadStepData model) throws SAXException { + AttributesImpl atts = null; + if (model.dcProvider instanceof MetaModelDataContextMongodb) { + MetaModelDataContextMongodb mongo = (MetaModelDataContextMongodb)model.dcProvider; + + atts = new AttributesImpl(); + atts.addAttribute ("", "el.id", "", "", model.name+"DC"); + if (mongo.getHostname()!=null) { + atts.addAttribute ("", "hostname", "", "", mongo.getHostname()); + } + if (mongo.getDatabase()!=null) { + atts.addAttribute ("", "database", "", "", mongo.getDatabase()); + } + if (mongo.getUsername()!=null) { + atts.addAttribute ("", "username", "", "", mongo.getUsername()); + } + if (mongo.getPassword()!=null) { + atts.addAttribute ("", "password", "", "", mongo.getPassword()); + } + atts.addAttribute ("", "port", "", "", ""+mongo.getPort()); + + xmlWriter.startElement (URI_META_MODEL, "mongodbDataContext", "", atts); + xmlWriter.endElement(URI_META_MODEL, "mongodbDataContext", ""); + + } else if (model.dcProvider instanceof MetaModelDataContextJdbc) { + MetaModelDataContextJdbc jdbc = (MetaModelDataContextJdbc)model.dcProvider; + + atts = new AttributesImpl(); + atts.addAttribute ("", "name", "", "", "jdbc/load/"+model.name+"DS"); + atts.addAttribute ("", "auth", "", "", "Container"); + atts.addAttribute ("", "type", "", "", "javax.sql.DataSource"); + atts.addAttribute ("", "factory", "", "", "org.apache.tomcat.jdbc.pool.DataSourceFactory"); + atts.addAttribute ("", "initialSize", "", "", "1"); + atts.addAttribute ("", "minIdle", "", "", "1"); + atts.addAttribute ("", "username", "", "", jdbc.getUsername()); + atts.addAttribute ("", "password", "", "", jdbc.getPassword()); + atts.addAttribute ("", "driverClassName", "", "", jdbc.getDriverClass()); + atts.addAttribute ("", "url", "", "", jdbc.getConnectUrl()); + xmlWriter.startElement (URI_VASC_DEMO, "tomcatResource", "", atts); + xmlWriter.endElement(URI_VASC_DEMO, "tomcatResource", ""); + + atts = new AttributesImpl(); + atts.addAttribute ("", "el.id", "", "", model.name+"DC"); + atts.addAttribute ("", "jndiName", "", "", "java:jdbc/load/"+model.name+"DS"); + xmlWriter.startElement (URI_META_MODEL, "jndiDataSourceDataContext", "", atts); + xmlWriter.endElement(URI_META_MODEL, "jndiDataSourceDataContext", ""); + } + } + + private void writeGroup(String groupId,String roles) throws SAXException { + AttributesImpl atts = new AttributesImpl(); + atts.addAttribute ("", "id", "", "", groupId); + atts.addAttribute ("", "rolesView", "", "", roles); + xmlWriter.startElement (URI_VASC_LANG, "entryGroup", "", atts); + xmlWriter.endElement(URI_VASC_LANG, "entryGroup", ""); + } + + private void writeEntryBackend(MetaModelVascBackend vb,LoadStepData model) throws SAXException { + + AttributesImpl atts = new AttributesImpl(); + atts.addAttribute ("", "id", "", "", vb.getId()); + atts.addAttribute ("", "dataContextProvider", "", "", "${"+model.name+ "DC}"); + atts.addAttribute ("", "table", "", "", vb.getTable()); + atts.addAttribute ("", "tableId", "", "", vb.getTableId()); + + xmlWriter.startElement (URI_META_MODEL, "metaModelBackend", "", atts); + xmlWriter.endElement(URI_META_MODEL, "metaModelBackend", ""); + } + + private void writeEntry(VascEntry ve,LoadStepData model) throws SAXException { + + AttributesImpl atts = new AttributesImpl(); + atts.addAttribute ("", "id", "", "", ve.getId()); + atts.addAttribute ("", "backendId", "", "", ve.getBackendId()); + atts.addAttribute ("", "primaryKeyFieldId", "", "", ve.getPrimaryKeyFieldId()); + if (ve.getDisplayNameFieldId()!=null) { + atts.addAttribute ("", "displayNameFieldId", "", "", ve.getDisplayNameFieldId()); + } + if (ve.getVascGroupId()!=null) { + atts.addAttribute ("", "vascGroupId", "", "", ve.getVascGroupId()); + } + if (ve.getAccessType()!=null) { + atts.addAttribute ("", "accessType", "", "", ve.getAccessType().name()); + } + xmlWriter.startElement (URI_VASC_LANG, "entry", "", atts); + createFields(ve); + + for (VascEntryLink vel:ve.getVascEntryLinks()) { + atts = new AttributesImpl(); + atts.addAttribute ("", "id", "", "", vel.getId()); + if (vel.getVascEntryLinkType()!=null && vel.getVascEntryLinkType()!=VascEntryLinkType.DEFAULT_TYPE) { + atts.addAttribute ("", "vascEntryLinkType", "", "", ""+vel.getVascEntryLinkType()); + } + atts.addAttribute ("", "vascEntryId", "", "", vel.getVascEntryId()); + xmlWriter.startElement (URI_VASC_LANG, "link", "", atts); + + for (String key:vel.getEntryParameterFieldIdKeys()) { + String value = vel.getEntryParameterFieldId(key); + atts = new AttributesImpl(); + atts.addAttribute ("", "name", "", "", key); + atts.addAttribute ("", "valueFieldId", "", "", value); + xmlWriter.startElement (URI_VASC_LANG, "linkParameter", "", atts); + xmlWriter.endElement(URI_VASC_LANG, "linkParameter", ""); + } + xmlWriter.endElement(URI_VASC_LANG, "link", ""); + } + xmlWriter.endElement(URI_VASC_LANG, "entry", ""); + } + + private void createFields(VascEntry ve) throws SAXException { + for (VascEntryField f:ve.getVascEntryFields()) { + + AttributesImpl atts = new AttributesImpl(); + atts.addAttribute ("", "id", "", "", f.getId()); + VascEntryFieldType type = f.getVascEntryFieldType(); + if (type!=null) { + atts.addAttribute ("", "vascEntryFieldType", "", "", type.getId()); + } + if (f.getEditReadOnly()!=null) { + atts.addAttribute ("", "editReadOnly", "", "", ""+f.getEditReadOnly()); + } + //atts.addAttribute ("", "vascGroupId", "", "", model.groupId); + xmlWriter.startElement (URI_VASC_LANG, "field", "", atts); + + if (type!=null && "ListField".equals(type.getId())) { + VascSelectItemModelEntry link = (VascSelectItemModelEntry)type.getDataObject(); + atts = new AttributesImpl(); + atts.addAttribute ("", "entryId", "", "", ""+link.getEntryId()); + atts.addAttribute ("", "displayFieldId", "", "", ""+link.getDisplayFieldId()); + xmlWriter.startElement (URI_VASC_LANG, "vascSelectItemModel", "", atts); + xmlWriter.endElement(URI_VASC_LANG, "vascSelectItemModel", ""); + } + + + xmlWriter.endElement(URI_VASC_LANG, "field", ""); + } + } +} diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/resources/net/forwardfire/vasc/demo/server/core/service/resources/init-db.sql b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/resources/net/forwardfire/vasc/demo/server/core/service/resources/init-db.sql index c4cc64b..39c5c8f 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/resources/net/forwardfire/vasc/demo/server/core/service/resources/init-db.sql +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/resources/net/forwardfire/vasc/demo/server/core/service/resources/init-db.sql @@ -63,27 +63,6 @@ CREATE INDEX vasc_page_part_page_id_idx ON vasc_page_part(page_id); CREATE INDEX vasc_page_part_active_idx ON vasc_page_part(active); CREATE INDEX vasc_page_part_sitemap_idx ON vasc_page_part(sitemap); - -CREATE TABLE vasc_menu_group ( - id varchar not null primary key, - title varchar not null, - active BOOLEAN NOT NULL, - roles varchar not null, - menu_order integer not null, -); -CREATE INDEX vasc_menu_group_active_idx ON vasc_menu_group(active); - -CREATE TABLE vasc_menu ( - id IDENTITY not null primary key, - vasc_entry_id varchar not null, - title varchar not null, - active BOOLEAN NOT NULL, - roles varchar not null, - menu_order integer not null, - menu_group varchar not null -); -CREATE INDEX vasc_menu_active_idx ON vasc_menu(active); - CREATE TABLE vasc_menu_web ( id IDENTITY not null primary key, href varchar not null, @@ -135,22 +114,6 @@ INSERT INTO vasc_page_part VALUES(10,6, 'metamodel','', TRUE,TRUE,TRUE,3,'WIKI', -- INSERT INTO vasc_page VALUES(1, 'home','home','Welcome to the vasc demo, please login as admin to view all stuff.'); -INSERT INTO vasc_menu_group VALUES('demo', 'Demo',true,'',1); -INSERT INTO vasc_menu_group VALUES('meta', 'Meta',true,'',2); - -INSERT INTO vasc_menu VALUES(1,'metaPeople', 'People', true,'',1,'meta'); -INSERT INTO vasc_menu VALUES(2,'metaProjects', 'Projects',true,'',2,'meta'); - -INSERT INTO vasc_menu VALUES(3,'AdminVascUser', 'Users', true,'',1,'demo'); -INSERT INTO vasc_menu VALUES(4,'AdminVascUserRole', 'UserRole',true,'',2,'demo'); -INSERT INTO vasc_menu VALUES(5,'AdminVascUserChangeField','ChangeField', true,'',3,'demo'); -INSERT INTO vasc_menu VALUES(6,'AdminVascUserChangeLog', 'ChangeLog',true,'',4,'demo'); -INSERT INTO vasc_menu VALUES(7,'AdminVascPage', 'Pages', true,'',5,'demo'); -INSERT INTO vasc_menu VALUES(8,'AdminVascPagePart', 'PagesPart',true,'',6,'demo'); -INSERT INTO vasc_menu VALUES( 9,'AdminVascMenuWeb', 'MenuWeb', true,'',7,'demo'); -INSERT INTO vasc_menu VALUES(10,'AdminVascMenuGroup', 'MenuGroup',true,'',8,'demo'); -INSERT INTO vasc_menu VALUES(11,'AdminVascMenu', 'Menu', true,'',9,'demo'); - INSERT INTO vasc_menu_web VALUES(1, '/html/index.jsf','Home', '',true,'',1,'BAR_RIGHT'); INSERT INTO vasc_menu_web VALUES(2, '/html/admin/debug.jsf','Debug','',true,'admin',2,'BAR_RIGHT'); INSERT INTO vasc_menu_web VALUES(3, '/html/admin/index.jsf','Admin','',true,'admin',3,'BAR_RIGHT'); diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/resources/net/forwardfire/vasc/demo/server/ui/resources/ServerGuiApplication.properties b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/resources/net/forwardfire/vasc/demo/server/ui/resources/ServerGuiApplication.properties index dd21e39..ff7165d 100644 --- a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/resources/net/forwardfire/vasc/demo/server/ui/resources/ServerGuiApplication.properties +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/resources/net/forwardfire/vasc/demo/server/ui/resources/ServerGuiApplication.properties @@ -29,7 +29,7 @@ Application.homepage = http://vasc.forwardfire.org/ Application.vendorId = vasc Application.id = vascdemotech Application.lookAndFeel = com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel -#Application.icon = images/icon.png +Application.icon = icon.png Application.web.meta.robots = index, follow Application.web.meta.description = Vasc Tech Demo Web Frontends diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/resources/net/forwardfire/vasc/demo/server/ui/resources/icon.png b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/resources/net/forwardfire/vasc/demo/server/ui/resources/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3acf3fccad0aa44f3c39d2baf60ffe16c13396d8 GIT binary patch literal 264 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmPax1@l&g)GOnYM{_mPZ!4!i_>c-1@awM;BlTGZC5ty z-hY`l2EU{B&R?3OYcL~?Q&9B;pWg%d6E~j5cArkVqk^WinPs927RV<6QE--B^w(GUJ zujHewwO4cLP2HZTju+QI-rOg2W15Ql#?3pK!V+p3r#ksp3g3Em6X-w&Pgg&ebxsLQ E03b$Q)c^nh literal 0 HcmV?d00001 diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/resources/net/forwardfire/vasc/demo/server/ui/resources/laf-colors.properties b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/resources/net/forwardfire/vasc/demo/server/ui/resources/laf-colors.properties new file mode 100644 index 0000000..78b4673 --- /dev/null +++ b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/resources/net/forwardfire/vasc/demo/server/ui/resources/laf-colors.properties @@ -0,0 +1,12 @@ +# +# Default dark red color thema for pulsefire +# +text=#DF0A0A +info=#370A00 +control=#0A1428 +nimbusBase=#00050A +nimbusFocus=#0A6428 +nimbusOrange=#00960A +nimbusBorder=#34415E +nimbusDisabledText=#850F0F +nimbusLightBackground=#050A28 diff --git a/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/resources/net/forwardfire/vasc/demo/server/ui/resources/tray-icon.png b/vasc-demo/vasc-demo-server/vasc-demo-server-core/src/main/resources/net/forwardfire/vasc/demo/server/ui/resources/tray-icon.png index ca0c48ca5035b29c06e5c5c3ed7a12ce712884e7..9ce8d09884fe8ea52fefdd9b704aeddbd3eb91ec 100644 GIT binary patch delta 358 zcmV-s0h#`U1&{-f7aSl61^@s6b9#F800006VoOIv0RI600RN!9r<0M-Ab%MUCJ-^E zZ@>Tm0Ub$1K~z}7?N>=|!!Qsdg$dAOKa&4HB##N2IASj{pg8g}vJ|&y2QVy12XYpQ zHYMT62sk)?7J&<){9Rg4pRN_S5IPHN0aV?Bp5QM8#%#|5^Szz~_$)&K3wWh!>?LT= z0Mwt8q0JqndH6_uc>suMKYz9*pa_t2y}y>`CZC1!t=UT_}QXUf}!}@qx$B-_tTU7^5F5bM)byX z@24kCd6xb7?`V;%exbNsiKglZng!K3M z@bK`BY%MuiZqC=;XpyZcK~P9>jB}Z?SZZ*tvaZwG*!%3zztG&)MhSEP000SaNLh0L z01FcU01FcV0GgZ_00007bV*G`2iyx14M3!+$C;>JC$w1_S36!X3hEog? z?E`Y2sSrlmFd-yj{r_`{2=Xk(oEB|3O@S2*^^M~hv{{HqP+(Y+%!X+iHO{jr=cQP= zufjD$aS#87w*077{gQFPA8SO$Qr&XG{a5>rAr{<#Je`7~hR z0Fx0|^OEoHk5-rv3uzH9k?uONl+ecW< z*m0}46LAdQ_9|=y<4Lae=g>*66YbgubfVR=$5!@U2|d}ji}UNg@ATsEk=1*C)$fm& zVD*~i{od^Mmwi>GELdK<{y&G^%loFPCT<9IfqWf49yZktOxn}^+wJF{@A(G`DGvasc-core-ejb3-client ${project.version} + + net.forwardfire.vasc.lib + vasc-lib-i18n + ${project.version} + net.forwardfire.vasc.demo vasc-demo-tech-web diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/java/net/forwardfire/vasc/demo/client/swing/JMainPanel.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/java/net/forwardfire/vasc/demo/client/swing/JMainPanel.java index bb7a7fc..9d6884b 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/java/net/forwardfire/vasc/demo/client/swing/JMainPanel.java +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/java/net/forwardfire/vasc/demo/client/swing/JMainPanel.java @@ -27,27 +27,10 @@ import java.awt.Dimension; import java.awt.GridLayout; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.ObjectOutputStream; -import java.io.OutputStream; import java.io.Serializable; -import java.util.HashMap; import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Properties; -import java.util.ResourceBundle; -import javax.naming.Context; -import javax.naming.InitialContext; import javax.swing.BorderFactory; -import javax.swing.JMenu; -import javax.swing.JMenuItem; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSplitPane; @@ -60,32 +43,22 @@ import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreeNode; -import net.forwardfire.vasc.annotations.VascModelReference; import net.forwardfire.vasc.backend.VascBackend; -import net.forwardfire.vasc.backend.VascBackendController; import net.forwardfire.vasc.backend.VascBackendControllerLocal; -import net.forwardfire.vasc.backend.VascBackendState; -import net.forwardfire.vasc.backend.proxy.VascBackendProxyEventExecutor; import net.forwardfire.vasc.core.VascController; -import net.forwardfire.vasc.core.VascControllerLocal; -import net.forwardfire.vasc.core.VascControllerProvider; -import net.forwardfire.vasc.core.VascEntry; +import net.forwardfire.vasc.core.VascEntryConfigControllerLocal; import net.forwardfire.vasc.core.VascEntryControllerLocal; -import net.forwardfire.vasc.core.VascEntryField; -import net.forwardfire.vasc.core.VascEntryFieldLocal; import net.forwardfire.vasc.core.VascEntryLocal; import net.forwardfire.vasc.core.VascException; -import net.forwardfire.vasc.core.entry.VascEntryFieldValue; -import net.forwardfire.vasc.core.entry.VascEntryRecordCreator; import net.forwardfire.vasc.demo.tech.ejb3.menu.VascMenuController; import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenu; import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuGroup; import net.forwardfire.vasc.ejb3.VascServiceManager; +import net.forwardfire.vasc.ejb3.VascServiceRemoteBackend; import net.forwardfire.vasc.frontend.swing.SwingPanelIntegration; import net.forwardfire.vasc.frontend.swing.SwingPanelTabbed; -import net.forwardfire.vasc.impl.DefaultVascController; import net.forwardfire.vasc.impl.DefaultVascFactory; -import net.forwardfire.vasc.impl.entry.SetParameterBackendListener; +import net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle; /** * JMainPanel is the main panel/window of this demo. @@ -96,199 +69,23 @@ import net.forwardfire.vasc.impl.entry.SetParameterBackendListener; public class JMainPanel extends JPanel { private static final long serialVersionUID = 5834715323973411147L; - //private VascControllerService vascManager = null; private VascController vc = null; private VascMenuController vmc = null; private VascServiceManager vsm = null; private SwingPanelIntegration spi = null; private JTabbedPane tabPane = null; private JTree vascTree = null; - private JSplitPane bottomSplitPane = null; private JSplitPane treeSplitPane = null; public JMainPanel(VascServiceManager vsm,VascMenuController vmc) { - //this.vascManager=VascTechDemoStartup.getInstance().getVascControllerService(); this.vsm = vsm; this.vmc = vmc; - setLayout(new BorderLayout()); - add(createBottomSplit(), BorderLayout.CENTER); - - vc = createVascController(vsm); - - //vascManager.addVascServiceListener(this); - rebuildTree(); - } - - - class RemoteVascBackend implements VascBackend { - - private String backendId = null; - private VascServiceManager vascManager = null; + setLayout(new BorderLayout()); + add(createTreeSplit(), BorderLayout.CENTER); - public RemoteVascBackend(String backendId,VascServiceManager vascManager) { - this.backendId=backendId; - this.vascManager=vascManager; - } - - public void startBackend() { - } - public void stopBackend() { - } - - public void delete(Object object) throws VascException { - Object[] args = new Object[1]; - args[0]=object; - vascManager.invokeBackendMethod(backendId, "delete", args); - } - - public long doRecordMoveDownById(VascBackendState state,Object primaryId) throws VascException { - Object[] args = new Object[2]; - args[0]=state; - args[1]=primaryId; - Object result = vascManager.invokeBackendMethod(backendId, "doRecordMoveDownById", args); - return (Long)result; - } - - public long doRecordMoveUpById(VascBackendState state, Object primaryId) throws VascException { - Object[] args = new Object[2]; - args[0]=state; - args[1]=primaryId; - Object result = vascManager.invokeBackendMethod(backendId, "doRecordMoveUpById", args); - return (Long)result; - } - - @SuppressWarnings("unchecked") - public List execute(VascBackendState state) throws VascException { - Object[] args = new Object[1]; - args[0]=state; - Object result = vascManager.invokeBackendMethod(backendId, "execute", args); - return (List)result; - } - - public long fetchTotalExecuteSize(VascBackendState state) { - Object[] args = new Object[1]; - args[0]=state; - Object result = vascManager.invokeBackendMethod(backendId, "fetchTotalExecuteSize", args); - return (Long)result; - } - - public String getId() { - return backendId; - } - - public boolean isPageable() { - Object[] args = new Object[0]; - Object result = vascManager.invokeBackendMethod(backendId, "isPageable", args); - return (Boolean)result; - } - - public boolean isRecordMoveable() { - Object[] args = new Object[0]; - Object result = vascManager.invokeBackendMethod(backendId, "isRecordMoveable", args); - return (Boolean)result; - } - - public boolean isSearchable() { - Object[] args = new Object[0]; - Object result = vascManager.invokeBackendMethod(backendId, "isSearchable", args); - return (Boolean)result; - } - - public boolean isSortable() { - Object[] args = new Object[0]; - Object result = vascManager.invokeBackendMethod(backendId, "isSortable", args); - return (Boolean)result; - } - - public Object merge(Object object) throws VascException { - Object[] args = new Object[1]; - args[0]=object; - Object result = vascManager.invokeBackendMethod(backendId, "merge", args); - return result; - } - - public void persist(Object object) throws VascException { - Object[] args = new Object[1]; - args[0]=object; - vascManager.invokeBackendMethod(backendId, "delete", args); - } - - public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) { - - - - try { - field = ((VascEntryFieldLocal)field).clone(); // RM... - - ByteArrayOutputStream dataArray = new ByteArrayOutputStream(256); // it grows when needed - ObjectOutputStream objOutstream = new ObjectOutputStream(dataArray); - objOutstream.writeObject(field); - objOutstream.close(); - int objectSize = dataArray.size(); - System.out.println("Writing obj to field: "+objectSize); - } catch (Exception e) { - throw new RuntimeException(e); - } - Object[] args = new Object[1]; - args[0]=field; - Object result = vascManager.invokeBackendMethod(backendId, "provideVascEntryFieldValue", args); - return (VascEntryFieldValue)result; - } - - public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) { - VascEntryLocal clone = null; - try { - clone = ((VascEntryLocal)vascEntry).clone(); - clone.setVascFrontendController(null); - clone.setVascEntryFieldEventChannel(null); - } catch (CloneNotSupportedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - try { - ByteArrayOutputStream dataArray = new ByteArrayOutputStream(256); // it grows when needed - ObjectOutputStream objOutstream = new ObjectOutputStream(dataArray); - objOutstream.writeObject(clone); - objOutstream.close(); - //int objectSize = dataArray.size(); - //System.out.println("Writing obj to entry: "+objectSize); - } catch (IOException e) { - throw new RuntimeException(e); - } - Object[] args = new Object[1]; - args[0]=clone; - Object result = vascManager.invokeBackendMethod(backendId, "provideVascEntryRecordCreator", args); - return (VascEntryRecordCreator)result; - } - - public void setId(String id) { - // we cant change id - } - - public Map executePageSummary() { - return null; - } - - public Map executeTotalSummary() { - return null; - } - - public boolean isPageSummary() { - Object[] args = new Object[0]; - Object result = vascManager.invokeBackendMethod(backendId, "isPageSummary", args); - return (Boolean)result; - } - - public boolean isTotalSummary() { - Object[] args = new Object[0]; - Object result = vascManager.invokeBackendMethod(backendId, "isTotalSummary", args); - return (Boolean)result; - } - - public boolean isReadOnly() { - return false; - } + vc = createVascController(vsm); + rebuildTree(); } /** @@ -301,7 +98,8 @@ public class JMainPanel extends JPanel { // get local jvm plugging controller VascController c = DefaultVascFactory.getDefaultVascController(); - + + ((VascEntryConfigControllerLocal)c.getVascEntryConfigController()).setResourceBundle(RootApplicationBundle.class.getName()); /* DefaultVascEntryController con = new DefaultVascEntryController() { public VascEntry getVascEntryById(String id) { @@ -323,7 +121,7 @@ public class JMainPanel extends JPanel { for (String id:entryIds) { VascEntryLocal ve = (VascEntryLocal)vascManager.getVascEntry(id); String backendId = ve.getBackendId(); - VascBackend vb = new RemoteVascBackend(backendId,vascManager); + VascBackend vb = new VascServiceRemoteBackend(vascManager,backendId); /* for (String key:ve.getEntryParameterKeys()) { @@ -360,32 +158,18 @@ public class JMainPanel extends JPanel { } } - private JSplitPane createBottomSplit() { - JSplitPane sp0 = createTreeSplit(); - JPanel sp1 = new JPanel();//JConsolePanel(); - bottomSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,sp0,sp1); - bottomSplitPane.setOneTouchExpandable(true); - bottomSplitPane.setResizeWeight(0.2); - bottomSplitPane.setDividerLocation(700); - sp0.setMinimumSize(new Dimension(400, 400)); - sp1.setMinimumSize(new Dimension(400, 150)); - return bottomSplitPane; - } - private JSplitPane createTreeSplit() { JScrollPane sp0 = createTreePane(); JScrollPane sp1 = createContentPane(); treeSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,sp0,sp1); treeSplitPane.setOneTouchExpandable(true); - treeSplitPane.setResizeWeight(0.7); - treeSplitPane.setDividerLocation(200); + treeSplitPane.setResizeWeight(0.2); + treeSplitPane.setDividerLocation(170); sp0.setMinimumSize(new Dimension(200, 400)); sp1.setMinimumSize(new Dimension(400, 400)); return treeSplitPane; } - - class VascTreeModel extends DefaultTreeModel { public VascTreeModel(TreeNode root) { super(root); @@ -450,9 +234,9 @@ public class JMainPanel extends JPanel { JScrollPane p = createJScrollPane(contentPane); tabPane = new JTabbedPane(); - spi = new SwingPanelTabbed(tabPane); - contentPane.add(tabPane); - + spi = new SwingPanelTabbed(tabPane); + contentPane.add(tabPane); + return p; } @@ -500,9 +284,9 @@ public class JMainPanel extends JPanel { List groups = vmc.getFilteredMenuGroup(); for (VascMenuGroup group:groups) { - DefaultMutableTreeNode groupNode = new DefaultMutableTreeNode(new VascTreeNode(VascTreeNodeType.GROUP,group.getTitle())); + DefaultMutableTreeNode groupNode = new DefaultMutableTreeNode(new VascTreeNode(VascTreeNodeType.GROUP,VascDemoSwingClient.getInstance().i18n(group.getTitleKey()))); for (VascMenu vm:group.getMenus()) { - DefaultMutableTreeNode entryNode = new DefaultMutableTreeNode(new VascTreeNode(VascTreeNodeType.ENTRY,vm.getVascEntryId())); + DefaultMutableTreeNode entryNode = new DefaultMutableTreeNode(new VascTreeNode(VascTreeNodeType.ENTRY,VascDemoSwingClient.getInstance().i18n(vm.getTitleKey()))); groupNode.add(entryNode); } root.add(groupNode); diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/java/net/forwardfire/vasc/demo/client/swing/JMainPanelMenuBar.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/java/net/forwardfire/vasc/demo/client/swing/JMainPanelMenuBar.java index ed18899..ce8947a 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/java/net/forwardfire/vasc/demo/client/swing/JMainPanelMenuBar.java +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/java/net/forwardfire/vasc/demo/client/swing/JMainPanelMenuBar.java @@ -24,22 +24,14 @@ package net.forwardfire.vasc.demo.client.swing; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.io.File; -import java.util.List; -import javax.swing.JFileChooser; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JTabbedPane; -import net.forwardfire.vasc.backend.VascBackendControllerLocal; -import net.forwardfire.vasc.core.VascEntryControllerLocal; import net.forwardfire.vasc.core.VascException; import net.forwardfire.vasc.demo.tech.ejb3.menu.VascMenuController; -import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenu; -import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuGroup; - /** * JMainPanelMenuBar Adds all menu bar items. @@ -50,85 +42,73 @@ import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuGroup; public class JMainPanelMenuBar extends JMenuBar implements ActionListener { private static final long serialVersionUID = -2828428804621352725L; - private VascMenuController vmc = null; private JMainPanel mainPanel = null; - private List vascMenus = null; + //private List vascMenus = null; private JMenu clientFileMenu = null; private JMenu clientTabMenu = null; public JMainPanelMenuBar(VascMenuController vmc,JMainPanel mainPanel) { - this.vmc=vmc; this.mainPanel=mainPanel; clientFileMenu = new JMenu("File"); add(clientFileMenu); - JMenuItem logoutItem = new JMenuItem("Logout"); - logoutItem.addActionListener(new ActionListener() { + JMenuItem logoutItem = new JMenuItem("Logout"); + logoutItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { - /* - final JFileChooser fc = new JFileChooser(); - //fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - int returnVal = fc.showOpenDialog((JMenuItem)e.getSource()); - if (returnVal == JFileChooser.APPROVE_OPTION) { - File file = fc.getSelectedFile(); - //VascTechDemoStartup.getInstance().getVascControllerService().openFile(file); - } - */ + VascDemoSwingClient.getInstance().logout(); } catch (Exception e1) { e1.printStackTrace(); } } - - }); - clientFileMenu.add(logoutItem); - clientFileMenu.addSeparator(); - JMenuItem exitItem = new JMenuItem("Exit"); - exitItem.addActionListener(new ActionListener() { + }); + clientFileMenu.add(logoutItem); + clientFileMenu.addSeparator(); + JMenuItem exitItem = new JMenuItem("Exit"); + exitItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VascDemoSwingClient.getInstance().exit(); } - }); - clientFileMenu.add(exitItem); - + }); + clientFileMenu.add(exitItem); + /* List groups = vmc.getFilteredMenuGroup(); for (VascMenuGroup group:groups) { - JMenu menu = new JMenu(group.getTitle()); + JMenu menu = new JMenu(group.getTitleKey()); for (VascMenu vm:group.getMenus()) { - JMenuItem item = new JMenuItem(vm.getTitle()); + JMenuItem item = new JMenuItem(vm.getTitleKey()); item.putClientProperty("vascEntryId", vm.getVascEntryId()); item.addActionListener(this); menu.add(item); } add(menu); } + */ clientTabMenu = new JMenu("Tabs"); add(clientTabMenu); - JMenuItem item = new JMenuItem("Close tab"); - item.addActionListener(new ActionListener() { + JMenuItem item = new JMenuItem("Close tab"); + item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JTabbedPane tabPane = getTabPane(); if (tabPane.getSelectedIndex()>=0) { tabPane.removeTabAt(tabPane.getSelectedIndex()); // todo release vasc frontend } } - - }); - clientTabMenu.add(item); - JMenuItem itemAll = new JMenuItem("Close All tabs"); - itemAll.addActionListener(new ActionListener() { + }); + clientTabMenu.add(item); + JMenuItem itemAll = new JMenuItem("Close All tabs"); + itemAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - JTabbedPane tabPane = getTabPane(); for (int i=tabPane.getTabCount();i>0;i--) { tabPane.removeTabAt(i-1); // todo release vasc frontend } } - }); - clientTabMenu.add(itemAll); + }); + clientTabMenu.add(itemAll); } public JTabbedPane getTabPane() { @@ -148,66 +128,4 @@ public class JMainPanelMenuBar extends JMenuBar implements ActionListener { } } - - /* - private void createMenuItems() { - JMenuItem openXmlItem = new JMenuItem("Import Xml"); - openXmlItem.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - try { - final JFileChooser fc = new JFileChooser(); - //fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - int returnVal = fc.showOpenDialog((JMenuItem)e.getSource()); - if (returnVal == JFileChooser.APPROVE_OPTION) { - File file = fc.getSelectedFile(); - //VascTechDemoStartup.getInstance().getVascControllerService().openFile(file); - } - } catch (Exception e1) { - e1.printStackTrace(); - } - } - - }); - fileMenu.add(openXmlItem); - //JMenuItem closeXmlItem = new JMenuItem("Close"); - //fileMenu.add(closeXmlItem); - fileMenu.addSeparator(); - JMenuItem exitItem = new JMenuItem("Exit"); - exitItem.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - //JApplication.getInstance().exit(); - } - }); - fileMenu.add(exitItem); - - JMenuItem connectVascItem = new JMenuItem("Add Vasc"); - connectVascItem.setEnabled(false); - connectVascItem.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - - } - }); - vascMenu.add(connectVascItem); - - JMenuItem connectLdapItem = new JMenuItem("Add Ldap"); - connectLdapItem.setEnabled(false); - vascMenu.add(connectLdapItem); - vascMenu.addSeparator(); - - - vascMenu.addSeparator(); - JMenuItem removeEntryItem = new JMenuItem("Remove entry"); - removeEntryItem.setEnabled(false); - removeEntryItem.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - } - }); - vascMenu.add(removeEntryItem); - - - - - tabMenu.add(itemAll); - } -*/ } diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/java/net/forwardfire/vasc/demo/client/swing/VascDemoSwingClient.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/java/net/forwardfire/vasc/demo/client/swing/VascDemoSwingClient.java index 1d569da..e2bcad2 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/java/net/forwardfire/vasc/demo/client/swing/VascDemoSwingClient.java +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/java/net/forwardfire/vasc/demo/client/swing/VascDemoSwingClient.java @@ -1,14 +1,27 @@ +/* + * Copyright 2007-2012 forwardfire.net All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + package net.forwardfire.vasc.demo.client.swing; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.net.URLDecoder; -import java.nio.ByteBuffer; -import java.nio.channels.FileChannel; import java.text.MessageFormat; import java.util.ArrayList; import java.util.List; @@ -20,63 +33,58 @@ import java.util.logging.Logger; import javax.naming.CommunicationException; import javax.naming.Context; import javax.naming.InitialContext; -import javax.naming.NameClassPair; -import javax.naming.NamingException; -import javax.security.auth.Subject; import javax.security.auth.login.LoginContext; +import javax.swing.JFrame; import javax.swing.JOptionPane; import net.forwardfire.vasc.demo.tech.ejb3.menu.VascMenuController; -import net.forwardfire.vasc.demo.tech.ejb3.user.LoginUserController; +import net.forwardfire.vasc.demo.tech.ejb3.user.ClientUserController; import net.forwardfire.vasc.ejb3.VascServiceManager; +import net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle; import org.jdesktop.application.Application; import org.jdesktop.application.FrameView; import org.jdesktop.application.SingleFrameApplication; +/** + * VascDemoSwingClient is the main swing remote client. + * + * @author Willem Cazander + * @version 1.0 Nov 10, 2012 + */ public class VascDemoSwingClient extends SingleFrameApplication { - private static VascDemoSwingClient instance = null; static protected Context context = null; static protected LoginContext loginContext = null; private Logger logger = null; static public void main(String[] args) { - /* - instance = new VascDemoSwingClient(); - instance.initialize(args); - instance.startup(); - */ Application.launch(VascDemoSwingClient.class, new String[] {}); } + static public VascDemoSwingClient getInstance() { + return (VascDemoSwingClient)SingleFrameApplication.getInstance(); + } + @Override protected void startup() { logger = Logger.getLogger(VascDemoSwingClient.class.getName()); - createContext(); - try { - setJaasConfig(); - } catch (IOException e) { - e.printStackTrace(); - } doLogin(); - - JdniTreePrinter printer = new JdniTreePrinter(false); - StringBuffer buf = new StringBuffer(); - printer.printJNDITree(context, "", buf); - System.out.println(buf); - VascServiceManager vc = null; - LoginUserController luc = null; + ClientUserController cuc = null; VascMenuController vmc = null; try { vc = (VascServiceManager)context.lookup("vascServiceManagerRemote"); System.out.println("ob: "+vc); - luc = (LoginUserController)context.lookup("loginUserControllerRemote"); - System.out.println("fll: "+luc.doClientLogin()); + cuc = (ClientUserController)context.lookup("clientUserControllerRemote"); + System.out.println("fll: "+cuc.doClientLogin()); + + // i18n fixme !! + RootApplicationBundle bundle = (RootApplicationBundle)ResourceBundle.getBundle(RootApplicationBundle.class.getName()); + bundle.addBundleData(cuc.getResourceBundle(bundle.getLocale())); vmc = (VascMenuController)context.lookup("vascMenuControllerRemote"); } catch (Exception e) { @@ -86,126 +94,48 @@ public class VascDemoSwingClient extends SingleFrameApplication { JMainPanel mainPanel = new JMainPanel(vc,vmc); SingleFrameApplication a = (VascDemoSwingClient)getInstance(); // BIG NOTE because of 'launch' for auto conf swing. FrameView mainView = a.getMainView(); - + mainView.getFrame().setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mainView.setComponent(mainPanel); mainView.setMenuBar(new JMainPanelMenuBar(vmc,mainPanel)); - mainView.getFrame().setSize(600, 800); + mainView.getFrame().setSize(1000, 600); mainView.getFrame().setVisible(true); - } - /** - * Created an context to the showplanner server. - */ - private void createContext() { - Properties props = new Properties(); - String connectUrl = "http://localhost:8899/demo/ejb"; //System.getProperty("javaws.connecturl"); - logger.info("Connecting to: "+connectUrl); - props.put(Context.PROVIDER_URL, connectUrl ); - props.put("openejb.authentication.realmName", "vasc-auth-server"); - props.put(Context.SECURITY_PRINCIPAL,"admin"); - props.put(Context.SECURITY_CREDENTIALS,"admin123"); - props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory"); + public void logout() { + SingleFrameApplication a = (VascDemoSwingClient)getInstance(); // BIG NOTE because of 'launch' for auto conf swing. + FrameView mainView = a.getMainView(); + mainView.getFrame().setVisible(false); - try { - context = new InitialContext(props); - } catch (Exception e) { - e.printStackTrace(); - //logger.log(Level.WARNING,e.getMessage(),e); - //ExceptionDialog err = new ExceptionDialog(e,true); - //err.showOpenDialog(null,i18n(VascDemoSwingClient.class,"dialogTitle"),i18n(VascDemoSwingClient.class,"dialogContext")); - } + startup(); // ugly .. } - /** - * Sets our jaas config path - */ - private void setJaasConfig() throws IOException { - - // tomee - String path = System.getProperty("java.security.auth.login.config"); - if (path == null) { - URL url = VascDemoSwingClient.class.getClassLoader().getResource("META-INF/client.login.conf"); - - File tempFile = File.createTempFile("cached-", ".jar"); - tempFile.deleteOnExit(); - copyFile(url.openConnection().getInputStream(),tempFile); - String urlString = "file:"+tempFile.getAbsolutePath(); - //logger.info("Setting jaas config property to url: "+urlString); - System.setProperty("java.security.auth.login.config", urlString); - logger.info("Setting jaas config property to url: "+urlString); - /* - if (resource != null) { - path = URLDecoder.decode(resource.getFile()); - System.setProperty("java.security.auth.login.config", path); - - } else { - logger.warning("Could not find client.login.conf"); - }*/ - } - - /* jboss - URL url = Thread.currentThread().getContextClassLoader().getResource("META-INF/jaas.config"); - String urlString = url.toExternalForm(); - - // jdk1.6 update10 has different classloader, so just copy for the moment..... .. - if (urlString.startsWith("jar:")) { - File tempFile = File.createTempFile("cached-", ".jar"); - tempFile.deleteOnExit(); - copyFile(url.openConnection().getInputStream(),tempFile); - urlString = "file:"+tempFile.getAbsolutePath(); - } - - //logger.info("Setting jaas config property to url: "+urlString); - System.setProperty("java.security.auth.login.config", urlString); - */ - } - - private void copyFile(InputStream in, File out) throws IOException { - ByteBuffer buffer = ByteBuffer.allocate(1024*4); - byte[] bufferArray = buffer.array(); - FileChannel outputChannel = new FileOutputStream(out).getChannel(); - while (true) { - buffer.clear(); - int lim = in.read(bufferArray); - if (lim < 0) { - break; // could not read anymore - } - buffer.flip(); - buffer.limit(lim); - while (buffer.hasRemaining()) { - outputChannel.write(buffer); - } - } - outputChannel.close(); - } - /** * Do an login on the server */ private void doLogin() { VascDemoUserLoginDialog loginHandler = new VascDemoUserLoginDialog(); - try { - loginContext = new LoginContext("vasc-auth-client", loginHandler); - loginContext.login(); + loginHandler.setConnectUrl("http://localhost:8899/demo"); + /* + try { + loginContext = new LoginContext("vasc-auth-client", loginHandler); + loginContext.login(); } catch(Exception e) { - e.printStackTrace(); JOptionPane.showMessageDialog(null, i18n(this,"dialogNoLoginContext"),i18n(this,"dialogTitle"), JOptionPane.WARNING_MESSAGE); System.exit(1); - } + } + */ try { - // Subject subject = loginContext.getSubject(); - - if(doLoginTest()) { + loginHandler.handle(); + if(doLoginContext(loginHandler)) { return; } - loginContext.login(); - if(doLoginTest()) { + loginHandler.handle(); + if(doLoginContext(loginHandler)) { return; } - loginContext.login(); - if(doLoginTest()) { + loginHandler.handle(); + if(doLoginContext(loginHandler)) { return; } @@ -234,25 +164,45 @@ public class VascDemoSwingClient extends SingleFrameApplication { } /** - * Check if we have 'login' role on server. + * Create naming context and check if we have 'login' role on server. * @return * @throws Exception */ - private boolean doLoginTest() throws Exception { + private boolean doLoginContext(VascDemoUserLoginDialog loginHandler) throws Exception { + Properties props = new Properties(); + String connectUrl = loginHandler.getConnectUrl()+"/ejb"; + logger.info("Connecting to: "+connectUrl); + props.put(Context.PROVIDER_URL, connectUrl ); + props.put("openejb.authentication.realmName", "vasc-auth-server"); + props.put(Context.SECURITY_PRINCIPAL,loginHandler.getUsername()); + props.put(Context.SECURITY_CREDENTIALS,loginHandler.getPassword()); + props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory"); try { - LoginUserController loginManager = (LoginUserController)context.lookup("loginUserControllerRemote"); - loginManager.doClientLogin(); - return true; + context = new InitialContext(props); + ClientUserController loginManager = (ClientUserController)context.lookup("clientUserControllerRemote"); + loginManager.doClientLogin(); + return true; } catch (javax.naming.NameNotFoundException e) { JOptionPane.showMessageDialog(null, "Server is not deployed.\nPlease wait a couple of minuts and try again."); return false; - } catch (Exception e) { - JOptionPane.showMessageDialog(null, "Server error: "+e.getMessage()); - e.printStackTrace(); - return false; + } catch (Exception e) { + JOptionPane.showMessageDialog(null, "Server error: "+e.getMessage()); + e.printStackTrace(); + return false; } } + public String i18n(Object obj,String key,Object...params) { + if(obj==null) { throw new NullPointerException("Can't get key of null obj"); } + if (key==null) { throw new NullPointerException("key may not be null"); } + if(obj instanceof Class) { + key=((Class)obj).getName()+"."+key; + } else { + key=obj.getClass().getName()+"."+key; + } + return i18n(key,params); + } + /** * Some simple hardcoded i18n function here * @@ -260,102 +210,16 @@ public class VascDemoSwingClient extends SingleFrameApplication { * @param params * @return */ - static protected String i18n(Object obj,String key,Object...params) { - if(obj==null) { throw new NullPointerException("Can't get key of null obj"); } - if (key==null) { throw new NullPointerException("key may not be null"); } - if(obj instanceof Class) { - key=((Class)obj).getName()+"."+key; - } else { - key=obj.getClass().getName()+"."+key; - } - return key; - /* + public String i18n(String key,Object...params) { try { - String text = ResourceBundle.getBundle("resources.i18n.root").getString(key); + String text = ResourceBundle.getBundle(RootApplicationBundle.class.getName()).getString(key); if (params != null) { MessageFormat mf = new MessageFormat(text); text = mf.format(params, new StringBuffer(), null).toString(); } return text; } catch(MissingResourceException e){ - return "MISSING: '"+key+"'"; + return key; } - */ - } - - class JdniTreePrinter { - - boolean printXml = true; - - public JdniTreePrinter(boolean printXml) { - this.printXml=printXml; - } - - public void printJNDITree(javax.naming.Context context,String ct,StringBuffer buf) { - if (printXml) { - buf.append("\n"); - buf.append("\n"); - } - printTree(context,ct,buf); - if (printXml) { - buf.append("\n"); - } - } - - public void printTree(javax.naming.Context context,String ct,StringBuffer buf) { - try { - printNE(context,context.list(ct), ct,buf); - } catch (NamingException e) { - //ignore leaf node exception - } - } - - private void printNE(javax.naming.Context context,javax.naming.NamingEnumeration ne, String parentctx,StringBuffer buf) throws NamingException { - if (ne==null) { - return; - } - while (ne.hasMoreElements()) { - NameClassPair next = (NameClassPair) ne.nextElement(); - if (printXml) { - printIndent(buf); - buf.append("\n"); - increaseIndent(); - printTree(context,(parentctx.length() == 0) ? next.getName() : parentctx + "/" + next.getName(),buf); - decreaseIndent(); - - printIndent(buf); - buf.append("\n"); - } else { - printEntry(next,buf); - increaseIndent(); - printTree(context,(parentctx.length() == 0) ? next.getName() : parentctx + "/" + next.getName(),buf); - decreaseIndent(); - } - } - } - - private void printEntry(javax.naming.NameClassPair next,StringBuffer buf) { - printIndent(buf); - buf.append("-->"); - buf.append(next); - buf.append("\n"); - } - - - private int indentLevel = 0; - - private void increaseIndent() { - indentLevel += 4; - } - - private void decreaseIndent() { - indentLevel -= 4; - } - - private void printIndent(StringBuffer buf) { - for (int i = 0; i < indentLevel; i++) { - buf.append(" "); - } - } } } diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/java/net/forwardfire/vasc/demo/client/swing/VascDemoUserLoginDialog.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/java/net/forwardfire/vasc/demo/client/swing/VascDemoUserLoginDialog.java index 43bc3f3..4688e7f 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/java/net/forwardfire/vasc/demo/client/swing/VascDemoUserLoginDialog.java +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/java/net/forwardfire/vasc/demo/client/swing/VascDemoUserLoginDialog.java @@ -1,20 +1,27 @@ /* - * @(#)DialogCallbackHandler.java 1.9 03/12/19 + * Copyright 2007-2012 forwardfire.net All rights reserved. * - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package net.forwardfire.vasc.demo.client.swing; -import javax.security.auth.callback.Callback; -import javax.security.auth.callback.CallbackHandler; -import javax.security.auth.callback.ConfirmationCallback; -import javax.security.auth.callback.NameCallback; -import javax.security.auth.callback.PasswordCallback; -import javax.security.auth.callback.TextOutputCallback; -import javax.security.auth.callback.UnsupportedCallbackException; - import java.awt.Color; import java.awt.Component; import java.awt.Dimension; @@ -59,14 +66,15 @@ import javax.swing.JTextField; * * @see javax.security.auth.callback */ -public class VascDemoUserLoginDialog implements CallbackHandler { +public class VascDemoUserLoginDialog { - /* The parent window, or null if using the default parent */ private Component parentComponent; private static final int JPasswordFieldLen = 8; private int loginTry = 0; - private String userName = null; - + private String connectUrl = null; + private String username = null; + private String password = null; + /** * Creates a callback dialog with the default parent window. */ @@ -93,15 +101,9 @@ public class VascDemoUserLoginDialog implements CallbackHandler { } /** - * Handles the specified set of callbacks. - * - * @param callbacks - * the callbacks to handle - * @throws UnsupportedCallbackException - * if the callback is not an instance of NameCallback or - * PasswordCallback + * Handles the login dialog */ - public void handle(Callback[] callbacks) throws UnsupportedCallbackException { + public void handle() { this.loginTry++; /* Collect messages to display in the dialog */ final JPanel loginDesign = new JPanel(); @@ -110,32 +112,28 @@ public class VascDemoUserLoginDialog implements CallbackHandler { final JPanel logoPanel = new JPanel() { private static final long serialVersionUID = 10l; protected void paintComponent(Graphics g) { - Graphics2D g2d = (Graphics2D)g; - - // for antialiasing geometric shapes - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); - // for antialiasing text - g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON); - // to go for quality over speed - g2d.setRenderingHint(RenderingHints.KEY_RENDERING,RenderingHints.VALUE_RENDER_QUALITY); - + Graphics2D g2d = (Graphics2D)g; + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); + g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + g2d.setRenderingHint(RenderingHints.KEY_RENDERING,RenderingHints.VALUE_RENDER_QUALITY); + // Paint the default look of the panel. - super.paintComponent(g2d); + super.paintComponent(g2d); - int offsetX = 0; // for windows systems + int offsetX = 0; // for windows systems boolean isWindows = System.getProperty("os.name").toLowerCase().indexOf("windows") != -1; if (isWindows) { offsetX += 25; } - - g2d.setColor(Color.BLACK); + + g2d.setColor(Color.BLACK); g2d.fillRect(0,0,getWidth(),getHeight()); g2d.setColor(new Color(238,212,1)); - //int w = (getWidth()/2)-(logoImage.getWidth(null)/2); - //int h = (getHeight()/2)-(logoImage.getHeight(null)/2); - //g2d.drawImage(logoImage, w, h, this); - } + //int w = (getWidth()/2)-(logoImage.getWidth(null)/2); + //int h = (getHeight()/2)-(logoImage.getHeight(null)/2); + //g2d.drawImage(logoImage, w, h, this); + } }; logoPanel.setPreferredSize(new Dimension(200, 170)); logoPanel.setBorder(BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED)); @@ -148,92 +146,64 @@ public class VascDemoUserLoginDialog implements CallbackHandler { loginDesign.add(namePanel); loginDesign.add(Box.createVerticalStrut(5)); - final GridLayout messagesLayout = new GridLayout(2,2); + final GridLayout messagesLayout = new GridLayout(3,2); final JPanel messages = new JPanel(); messages.setLayout(messagesLayout); /* Collection actions to perform if the user clicks OK */ final List okActions = new ArrayList(2); - ConfirmationInfo confirmation = new ConfirmationInfo(); + + // Add server field + JLabel serverName = new JLabel("Server:"); + final JTextField serverField = new JTextField(getConnectUrl()); + messages.add(serverName); + messages.add(serverField); + okActions.add(new Action() { + public void perform() { + connectUrl = serverField.getText(); + } + }); // hackje for focus final JTextField name = new JTextField(); - confirmation.initialValue=name; + final JPasswordField pass = new JPasswordField(JPasswordFieldLen); - for (int i = 0; i < callbacks.length; i++) { - if (callbacks[i] instanceof TextOutputCallback) { - TextOutputCallback tc = (TextOutputCallback) callbacks[i]; - - switch (tc.getMessageType()) { - case TextOutputCallback.INFORMATION: - confirmation.messageType = JOptionPane.INFORMATION_MESSAGE; - break; - case TextOutputCallback.WARNING: - confirmation.messageType = JOptionPane.WARNING_MESSAGE; - break; - case TextOutputCallback.ERROR: - confirmation.messageType = JOptionPane.ERROR_MESSAGE; - break; - default: - throw new UnsupportedCallbackException(callbacks[i], "Unrecognized message type"); - } - messages.add(new JLabel(tc.getMessage())); - - } else if (callbacks[i] instanceof NameCallback) { - final NameCallback nc = (NameCallback) callbacks[i]; - - JLabel prompt = new JLabel(nc.getPrompt()); - String defaultName = nc.getDefaultName(); - - // if (check some property) - defaultName = ""; - if (defaultName != null) { - name.setText(defaultName); - } - // default to last user name - if (userName !=null ) { - name.setText(userName); - } - messages.add(prompt); - messages.add(name); - - /* Store the name back into the callback if OK */ - okActions.add(new Action() { - public void perform() { - nc.setName(name.getText()); - } - }); - - } else if (callbacks[i] instanceof PasswordCallback) { - final PasswordCallback pc = (PasswordCallback) callbacks[i]; - - JLabel prompt = new JLabel(pc.getPrompt()); - - final JPasswordField password = new JPasswordField(JPasswordFieldLen); - if (!pc.isEchoOn()) { - password.setEchoChar('*'); - } - messages.add(prompt); - messages.add(password); - - okActions.add(new Action() { - public void perform() { - pc.setPassword(password.getPassword()); - } - }); - - } else if (callbacks[i] instanceof ConfirmationCallback) { - ConfirmationCallback cc = (ConfirmationCallback) callbacks[i]; - - confirmation.setCallback(cc); - if (cc.getPrompt() != null) { - messages.add(new JLabel(cc.getPrompt())); - } - - } else { - throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback"); - } + JLabel prompt = new JLabel("Username:"); + String defaultName = null; + + // if (check some property) + defaultName = ""; + if (defaultName != null) { + name.setText(defaultName); } + // default to last user name + if (username !=null ) { + name.setText(username); + } + messages.add(prompt); + messages.add(name); + + /* Store the name back into the callback if OK */ + okActions.add(new Action() { + public void perform() { + username = name.getText(); + } + }); + + + prompt = new JLabel("Password:"); + + //if (!pc.isEchoOn()) { + pass.setEchoChar('*'); + //} + messages.add(prompt); + messages.add(pass); + + okActions.add(new Action() { + public void perform() { + password = new String(pass.getPassword()); + } + }); if (this.loginTry>1) { JPanel messagesPanel = new JPanel(); @@ -251,25 +221,17 @@ public class VascDemoUserLoginDialog implements CallbackHandler { loginDesign.add(messagesPanel); /* Display the dialog */ + Object[] options = null; /// JOptionPane(Object message, int messageType, int optionType, Icon icon, Object[] options, Object initialValue) - JOptionPane jop = new JOptionPane(loginDesign, JOptionPane.PLAIN_MESSAGE,confirmation.optionType,null, - confirmation.options,confirmation.initialValue); + JOptionPane jop = new JOptionPane(loginDesign, JOptionPane.PLAIN_MESSAGE,JOptionPane.OK_CANCEL_OPTION,null,options,name); JDialog dialog = jop.createDialog(parentComponent,"Vasc Demo Login"); // We alway request focus after the windows gets focus dialog.addWindowFocusListener(new WindowFocusListener() { - /** - * @see java.awt.event.WindowFocusListener#windowGainedFocus(java.awt.event.WindowEvent) - */ public void windowGainedFocus(WindowEvent arg0) { - //System.out.println("request focus window focus"); - name.requestFocus(); + name.requestFocus(); } - - /** - * @see java.awt.event.WindowFocusListener#windowLostFocus(java.awt.event.WindowEvent) - */ public void windowLostFocus(WindowEvent arg0) { } }); @@ -299,10 +261,7 @@ public class VascDemoUserLoginDialog implements CallbackHandler { // is null when escaping by window closing result = JOptionPane.CANCEL_OPTION; } - - // copy user name for next try - userName = name.getText(); - + /* Perform the OK actions */ if (result == JOptionPane.OK_OPTION || result == JOptionPane.YES_OPTION) { Iterator iterator = okActions.iterator(); @@ -312,97 +271,34 @@ public class VascDemoUserLoginDialog implements CallbackHandler { } else if (result == JOptionPane.CANCEL_OPTION || result == JOptionPane.NO_OPTION) { System.exit(1); } - confirmation.handleResult(result); } - + /** - * Provides assistance with translating between JAAS and Swing confirmation - * dialogs. + * @return the username */ - private static class ConfirmationInfo { - - private int[] translations; - - int optionType = JOptionPane.OK_CANCEL_OPTION; - Object[] options = null; - Object initialValue = null; - - int messageType = JOptionPane.QUESTION_MESSAGE; - - private ConfirmationCallback callback; - - /* Set the confirmation callback handler */ - void setCallback(ConfirmationCallback callback) throws UnsupportedCallbackException { - this.callback = callback; - - int confirmationOptionType = callback.getOptionType(); - switch (confirmationOptionType) { - case ConfirmationCallback.YES_NO_OPTION: - optionType = JOptionPane.YES_NO_OPTION; - translations = new int[] { - JOptionPane.YES_OPTION, ConfirmationCallback.YES, JOptionPane.NO_OPTION, ConfirmationCallback.NO, JOptionPane.CLOSED_OPTION, ConfirmationCallback.NO - }; - break; - case ConfirmationCallback.YES_NO_CANCEL_OPTION: - optionType = JOptionPane.YES_NO_CANCEL_OPTION; - translations = new int[] { - JOptionPane.YES_OPTION, ConfirmationCallback.YES, JOptionPane.NO_OPTION, ConfirmationCallback.NO, JOptionPane.CANCEL_OPTION, - ConfirmationCallback.CANCEL, JOptionPane.CLOSED_OPTION, ConfirmationCallback.CANCEL - }; - break; - case ConfirmationCallback.OK_CANCEL_OPTION: - optionType = JOptionPane.OK_CANCEL_OPTION; - translations = new int[] { - JOptionPane.OK_OPTION, ConfirmationCallback.OK, JOptionPane.CANCEL_OPTION, ConfirmationCallback.CANCEL, JOptionPane.CLOSED_OPTION, - ConfirmationCallback.CANCEL - }; - break; - case ConfirmationCallback.UNSPECIFIED_OPTION: - options = callback.getOptions(); - /* - * There's no way to know if the default option means to - * cancel the login, but there isn't a better way to guess - * this. - */ - translations = new int[] { - JOptionPane.CLOSED_OPTION, callback.getDefaultOption() - }; - break; - default: - throw new UnsupportedCallbackException(callback, "Unrecognized option type: " + confirmationOptionType); - } - - int confirmationMessageType = callback.getMessageType(); - switch (confirmationMessageType) { - case ConfirmationCallback.WARNING: - messageType = JOptionPane.WARNING_MESSAGE; - break; - case ConfirmationCallback.ERROR: - messageType = JOptionPane.ERROR_MESSAGE; - break; - case ConfirmationCallback.INFORMATION: - messageType = JOptionPane.INFORMATION_MESSAGE; - break; - default: - throw new UnsupportedCallbackException(callback, "Unrecognized message type: " + confirmationMessageType); - } - } - - /* Process the result returned by the Swing dialog */ - void handleResult(int result) { - if (callback == null) { - return; - } - - for (int i = 0; i < translations.length; i += 2) { - if (translations[i] == result) { - result = translations[i + 1]; - break; - } - } - callback.setSelectedIndex(result); - } + public String getUsername() { + return username; + } + + /** + * @return the password + */ + public String getPassword() { + return password; + } + + /** + * @return the connectUrl + */ + public String getConnectUrl() { + return connectUrl; + } + + /** + * @param connectUrl the connectUrl to set + */ + public void setConnectUrl(String connectUrl) { + this.connectUrl = connectUrl; } - } \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/META-INF/client.login.conf b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/META-INF/client.login.conf deleted file mode 100644 index 6fd4b6e..0000000 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/META-INF/client.login.conf +++ /dev/null @@ -1,6 +0,0 @@ - -vasc-auth-client { - org.apache.openejb.client.ClientLoginModule required - debug=true - openejb.server.uri="http://localhost:8899/demo/ejb"; -}; diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/META-INF/root-bundle.properties b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/META-INF/root-bundle.properties new file mode 100644 index 0000000..974b737 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/META-INF/root-bundle.properties @@ -0,0 +1,13 @@ + +config.charset=UTF-8 +config.bundles=bundle1 +#,bundle2 + +# bundle list to merge and load +bundle1.uri=net.forwardfire.vasc.demo.client.swing.resources.VascDemoSwingClient + +#bundle2.uri=data/vasc-bundle.properties +#bundle2.type=FILE +#bundle2.optional=true + + diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/net/forwardfire/vasc/demo/client/swing/resources/VascDemoSwingClient.properties b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/net/forwardfire/vasc/demo/client/swing/resources/VascDemoSwingClient.properties new file mode 100644 index 0000000..003c074 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-client-swing/src/main/resources/net/forwardfire/vasc/demo/client/swing/resources/VascDemoSwingClient.properties @@ -0,0 +1,32 @@ +# +# Copyright (c) 2011, Willem Cazander +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted provided +# that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions and the +# following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and +# the following disclaimer in the documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR +# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +# Application's properties +Application.name = Vasc Demo Tech +Application.title = VascDemoTech +Application.vendor = Willem Cazander +Application.homepage = http://vasc.forwardfire.org/ +Application.vendorId = vasc +Application.id = vascdemotech +Application.lookAndFeel = com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel +#Application.icon = images/icon.png diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/pom.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/pom.xml index 6e87542..c37ace3 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/pom.xml +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/pom.xml @@ -9,11 +9,29 @@ vasc-demo-tech-ejb3 vasc-demo-tech-ejb3 - - javax - javaee-api - ${javaee-api.version} - provided - + + net.forwardfire.vasc + vasc-core + ${project.version} + provided + + + net.forwardfire.vasc + vasc-core-ejb3-client + ${project.version} + provided + + + javax + javaee-api + ${javaee-api.version} + provided + + + net.forwardfire.vasc.lib + vasc-lib-i18n + ${project.version} + provided + \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/VascMenuControllerImpl.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/VascMenuControllerImpl.java index 757abe4..09af0cc 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/VascMenuControllerImpl.java +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/VascMenuControllerImpl.java @@ -37,9 +37,11 @@ import javax.naming.InitialContext; import javax.naming.NamingException; import javax.sql.DataSource; +import net.forwardfire.vasc.core.VascController; +import net.forwardfire.vasc.core.VascEntry; +import net.forwardfire.vasc.core.VascEntryAccessType; +import net.forwardfire.vasc.core.VascEntryGroup; import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenu; -import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuComparator; -import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuGroupComparator; import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuWebComparator; import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuGroup; import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuWeb; @@ -54,17 +56,12 @@ import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuWebType; public class VascMenuControllerImpl implements VascMenuControllerLocal,VascMenuControllerRemote { private VascMenuWebComparator vascMenuWebComparator = null; - private VascMenuGroupComparator vascMenuGroupComparator = null; - private VascMenuComparator vascMenuComparator = null; @Resource private SessionContext session; - public VascMenuControllerImpl() { vascMenuWebComparator = new VascMenuWebComparator(); - vascMenuGroupComparator = new VascMenuGroupComparator(); - vascMenuComparator = new VascMenuComparator(); } public List fetchVascMenuWeb() { @@ -104,78 +101,7 @@ public class VascMenuControllerImpl implements VascMenuControllerLocal,VascMenuC } return result; } - - public List fetchVascMenuGroup() { - List result = new ArrayList(50); - Connection connection = null; - try { - DataSource ds = getDataSource("openejb:Resource/jdbc/DemoManagerDataDS"); - connection = ds.getConnection(); - Statement s = connection.createStatement(); - s.execute("SELECT * FROM VASC_MENU_GROUP"); - ResultSet rs = s.getResultSet(); - while (rs.next()) { - VascMenuGroup menu = new VascMenuGroup(); - menu.setId(rs.getString(1)); - menu.setTitle(rs.getString(2)); - menu.setActive(rs.getBoolean(3)); - menu.setRoles(rs.getString(4)); - menu.setMenuOrder(rs.getInt(5)); - if (filterVascMenuRoles(menu.getActive(),menu.getRoles())==false) { - continue; - } - result.add(menu); - } - } catch (Exception e) { - e.printStackTrace(); - } finally { - if (connection!=null) { - try { - connection.close(); - } catch (Exception e) { - } - } - } - return result; - } - - public List fetchVascMenu() { - List result = new ArrayList(50); - Connection connection = null; - try { - DataSource ds = getDataSource("openejb:Resource/jdbc/DemoManagerDataDS"); - connection = ds.getConnection(); - Statement s = connection.createStatement(); - s.execute("SELECT * FROM VASC_MENU"); - ResultSet rs = s.getResultSet(); - while (rs.next()) { - VascMenu menu = new VascMenu(); - menu.setId(rs.getInt(1)); - menu.setVascEntryId(rs.getString(2)); - menu.setTitle(rs.getString(3)); - menu.setActive(rs.getBoolean(4)); - menu.setRoles(rs.getString(5)); - menu.setMenuOrder(rs.getInt(6)); - menu.setMenuGroup(rs.getString(7)); - if (filterVascMenuRoles(menu.getActive(),menu.getRoles())==false) { - continue; - } - result.add(menu); - } - } catch (Exception e) { - e.printStackTrace(); - } finally { - if (connection!=null) { - try { - connection.close(); - } catch (Exception e) { - } - } - } - return result; - } - - + private DataSource getDataSource(String name) throws SQLException { try { @@ -210,11 +136,28 @@ public class VascMenuControllerImpl implements VascMenuControllerLocal,VascMenuC } public List getFilteredMenuGroup() { - List result = fetchVascMenuGroup(); - for (VascMenuGroup group:result) { - group.setMenus(getFilteredMenu(group.getId())); + + VascController vc = null; + try { + Context initialContext = new InitialContext(); + vc = (VascController)initialContext.lookup("openejb:Resource/vasc/server-tech"); + } catch (Exception e) { + e.printStackTrace(); } - Collections.sort(result,vascMenuGroupComparator); + + List result = new ArrayList(20); + for (String groupdId:vc.getVascEntryController().getVascEntryGroupIds()) { + VascEntryGroup veg = vc.getVascEntryController().getVascEntryGroupById(groupdId); + if (filterVascMenuRoles(veg.getView(),veg.getRolesView())==false) { + continue; + } + VascMenuGroup group = new VascMenuGroup(); + group.setId(veg.getId()); + group.setTitleKey(veg.getName()); + group.setMenus(getFilteredMenu(group.getId())); + result.add(group); + } + // Collections.sort(result,vascMenuGroupComparator); return result; } @@ -222,13 +165,33 @@ public class VascMenuControllerImpl implements VascMenuControllerLocal,VascMenuC if (groupId==null) { throw new NullPointerException("Can't filter on null groupId."); } - List result = new ArrayList(15); - for (VascMenu menu:fetchVascMenu()) { - if (groupId.equals(menu.getMenuGroup())) { - result.add(menu); - } + VascController vc = null; + try { + Context initialContext = new InitialContext(); + vc = (VascController)initialContext.lookup("openejb:Resource/vasc/server-tech"); + } catch (Exception e) { + e.printStackTrace(); } - Collections.sort(result,vascMenuComparator); + List result = new ArrayList(15); + for (String vascEntryId:vc.getVascEntryController().getVascEntryByGroupId(groupId)) { + VascEntry ve = vc.getVascEntryController().getVascEntryById(vascEntryId); + if (ve.getAccessType()!=null && ( + ve.getAccessType()==VascEntryAccessType.ENTRY_LINK | + ve.getAccessType()==VascEntryAccessType.ENTRY_LIST + ) + ) { + continue; + } + if (filterVascMenuRoles(ve.getView(),ve.getRolesView())==false) { + continue; + } + VascMenu menu = new VascMenu(); + menu.setVascEntryId(ve.getId()); + menu.setVascGroupId(ve.getVascGroupId()); + menu.setTitleKey(ve.getName()); + result.add(menu); + } + // Collections.sort(result,vascMenuComparator); return result; } diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenu.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenu.java index 03a1d92..3c0037b 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenu.java +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenu.java @@ -33,109 +33,43 @@ import java.io.Serializable; public class VascMenu implements Serializable { private static final long serialVersionUID = 5087600835051760512L; - private Integer id = null; private String vascEntryId = null; - private String title = null; - private Boolean active = null; - private String roles = null; - private Integer menuOrder = null; - private String menuGroup = null; - - /** - * @return the id - */ - public Integer getId() { - return id; - } - - /** - * @param id the id to set - */ - public void setId(Integer id) { - this.id = id; - } - + private String titleKey = null; + private String vascGroupId = null; /** * @return the vascEntryId */ public String getVascEntryId() { return vascEntryId; } - /** * @param vascEntryId the vascEntryId to set */ public void setVascEntryId(String vascEntryId) { this.vascEntryId = vascEntryId; } - /** - * @return the title + * @return the titleKey */ - public String getTitle() { - return title; + public String getTitleKey() { + return titleKey; } - /** - * @param title the title to set + * @param titleKey the titleKey to set */ - public void setTitle(String title) { - this.title = title; + public void setTitleKey(String titleKey) { + this.titleKey = titleKey; } - /** - * @return the active + * @return the vascGroupId */ - public Boolean getActive() { - return active; + public String getVascGroupId() { + return vascGroupId; } - /** - * @param active the active to set + * @param vascGroupId the vascGroupId to set */ - public void setActive(Boolean active) { - this.active = active; - } - - /** - * @return the roles - */ - public String getRoles() { - return roles; - } - - /** - * @param roles the roles to set - */ - public void setRoles(String roles) { - this.roles = roles; - } - - /** - * @return the menuOrder - */ - public Integer getMenuOrder() { - return menuOrder; - } - - /** - * @param menuOrder the menuOrder to set - */ - public void setMenuOrder(Integer menuOrder) { - this.menuOrder = menuOrder; - } - - /** - * @return the menuGroup - */ - public String getMenuGroup() { - return menuGroup; - } - - /** - * @param menuGroup the menuGroup to set - */ - public void setMenuGroup(String menuGroup) { - this.menuGroup = menuGroup; + public void setVascGroupId(String vascGroupId) { + this.vascGroupId = vascGroupId; } } diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuGroup.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuGroup.java index a3815cb..ab4e494 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuGroup.java +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/menu/model/VascMenuGroup.java @@ -35,10 +35,7 @@ public class VascMenuGroup implements Serializable { private static final long serialVersionUID = -9154803561816570868L; private String id = null; - private String title = null; - private Boolean active = null; - private String roles = null; - private Integer menuOrder = null; + private String titleKey = null; private List menus = null; /** @@ -54,61 +51,19 @@ public class VascMenuGroup implements Serializable { public void setId(String id) { this.id = id; } + + /** + * @return the titleKey + */ + public String getTitleKey() { + return titleKey; + } /** - * @return the title + * @param titleKey the titleKey to set */ - public String getTitle() { - return title; - } - - /** - * @param title the title to set - */ - public void setTitle(String title) { - this.title = title; - } - - /** - * @return the active - */ - public Boolean getActive() { - return active; - } - - /** - * @param active the active to set - */ - public void setActive(Boolean active) { - this.active = active; - } - - /** - * @return the roles - */ - public String getRoles() { - return roles; - } - - /** - * @param roles the roles to set - */ - public void setRoles(String roles) { - this.roles = roles; - } - - /** - * @return the menuOrder - */ - public Integer getMenuOrder() { - return menuOrder; - } - - /** - * @param menuOrder the menuOrder to set - */ - public void setMenuOrder(Integer menuOrder) { - this.menuOrder = menuOrder; + public void setTitleKey(String titleKey) { + this.titleKey = titleKey; } /** diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/ClientUserController.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/ClientUserController.java new file mode 100644 index 0000000..f472cd1 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/ClientUserController.java @@ -0,0 +1,22 @@ +package net.forwardfire.vasc.demo.tech.ejb3.user; + +import java.util.List; +import java.util.Locale; +import java.util.Map; + +public interface ClientUserController { + + String doClientLogin(); + + Map getResourceBundle(Locale locale); + + List getResourceBundleLocales(); + + /* + void doClientLogout(); + + User getUser() throws Exception; + + List getClientRoles() throws Exception; + */ +} diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/LoginUserControllerImpl.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/ClientUserControllerImpl.java similarity index 59% rename from vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/LoginUserControllerImpl.java rename to vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/ClientUserControllerImpl.java index e7f3473..306cadb 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/LoginUserControllerImpl.java +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/ClientUserControllerImpl.java @@ -1,12 +1,19 @@ package net.forwardfire.vasc.demo.tech.ejb3.user; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; + import javax.annotation.Resource; import javax.annotation.security.RolesAllowed; import javax.ejb.SessionContext; import javax.ejb.Stateless; -@Stateless(name="loginUserController") -public class LoginUserControllerImpl implements LoginUserControllerLocal,LoginUserControllerRemote { +import net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle; + +@Stateless(name="clientUserController") +public class ClientUserControllerImpl implements ClientUserControllerLocal,ClientUserControllerRemote { @Resource private SessionContext session; @@ -54,4 +61,22 @@ public class LoginUserControllerImpl implements LoginUserControllerLocal,LoginUs return u.getUsername(); */ } + + public Map getResourceBundle(Locale locale) { + ResourceBundle bundle = ResourceBundle.getBundle(RootApplicationBundle.class.getName(), locale); + if (bundle instanceof RootApplicationBundle) { + RootApplicationBundle appBundle = (RootApplicationBundle)bundle; + return appBundle.getBundleData(); + } + throw new IllegalStateException("Loaded bundle: "+bundle+" is not RootApplicationBundle."); + } + + public List getResourceBundleLocales() { + ResourceBundle bundle = ResourceBundle.getBundle(RootApplicationBundle.class.getName()); + if (bundle instanceof RootApplicationBundle) { + RootApplicationBundle appBundle = (RootApplicationBundle)bundle; + return appBundle.getApplicationSupportedLocales(); + } + throw new IllegalStateException("Loaded bundle: "+bundle+" is not RootApplicationBundle."); + } } diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/LoginUserControllerLocal.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/ClientUserControllerLocal.java similarity index 54% rename from vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/LoginUserControllerLocal.java rename to vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/ClientUserControllerLocal.java index 0e150d4..0718fe7 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/LoginUserControllerLocal.java +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/ClientUserControllerLocal.java @@ -3,6 +3,6 @@ package net.forwardfire.vasc.demo.tech.ejb3.user; import javax.ejb.Local; @Local -public interface LoginUserControllerLocal extends LoginUserController { +public interface ClientUserControllerLocal extends ClientUserController { } diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/LoginUserControllerRemote.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/ClientUserControllerRemote.java similarity index 54% rename from vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/LoginUserControllerRemote.java rename to vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/ClientUserControllerRemote.java index 44cb392..27a5e35 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/LoginUserControllerRemote.java +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/ClientUserControllerRemote.java @@ -3,6 +3,6 @@ package net.forwardfire.vasc.demo.tech.ejb3.user; import javax.ejb.Remote; @Remote -public interface LoginUserControllerRemote extends LoginUserController { +public interface ClientUserControllerRemote extends ClientUserController { } diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/LoginUserController.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/LoginUserController.java deleted file mode 100644 index cdf90a5..0000000 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ejb3/src/main/java/net/forwardfire/vasc/demo/tech/ejb3/user/LoginUserController.java +++ /dev/null @@ -1,21 +0,0 @@ -package net.forwardfire.vasc.demo.tech.ejb3.user; - -import java.util.List; -import java.util.Map; - -import javax.ejb.Local; -import javax.ejb.Remote; - - -public interface LoginUserController { - - public String doClientLogin(); - - /* - public void doClientLogout(); - - public User getUser() throws Exception; - - public List getClientRoles() throws Exception; - */ -} diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/pom.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/pom.xml index 406404e..2c8edbd 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/pom.xml +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/pom.xml @@ -39,21 +39,7 @@ ${project.version} provided - - + javax javaee-api ${javaee-api.version} diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/UserController.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/UserController.java index 7985bf1..89c19cb 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/UserController.java +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/java/net/forwardfire/vasc/demo/tech/web/beans/UserController.java @@ -32,7 +32,7 @@ import javax.naming.Context; import javax.naming.InitialContext; import javax.servlet.http.HttpSession; -import net.forwardfire.vasc.demo.tech.ejb3.user.LoginUserController; +import net.forwardfire.vasc.demo.tech.ejb3.user.ClientUserController; import net.forwardfire.vasc.demo.tech.web.models.WebUser; /** diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/ejb-jar.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/ejb-jar.xml index 0bfee7e..924e08b 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/ejb-jar.xml +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/ejb-jar.xml @@ -12,10 +12,10 @@ Container - loginUserController - net.forwardfire.vasc.demo.tech.ejb3.user.LoginUserControllerLocal - net.forwardfire.vasc.demo.tech.ejb3.user.LoginUserControllerRemote - net.forwardfire.vasc.demo.tech.ejb3.user.LoginUserControllerImpl + clientUserController + net.forwardfire.vasc.demo.tech.ejb3.user.ClientUserControllerLocal + net.forwardfire.vasc.demo.tech.ejb3.user.ClientUserControllerRemote + net.forwardfire.vasc.demo.tech.ejb3.user.ClientUserControllerImpl Stateless Container diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-menu.xhtml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-menu.xhtml index eedbf3b..9daa9eb 100644 --- a/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-menu.xhtml +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-web/src/main/webapp/WEB-INF/template/structure/main-body-menu.xhtml @@ -8,11 +8,11 @@ diff --git a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/AbstractJSFVascFacesControllerEJB.java b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/AbstractJSFVascFacesControllerEJB.java index a7fea4b..613a12b 100644 --- a/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/AbstractJSFVascFacesControllerEJB.java +++ b/vasc-frontend/vasc-frontend-web-jsf/src/main/java/net/forwardfire/vasc/frontend/web/jsf/AbstractJSFVascFacesControllerEJB.java @@ -22,38 +22,25 @@ package net.forwardfire.vasc.frontend.web.jsf; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectOutputStream; import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; import java.util.List; -import java.util.Locale; import java.util.Map; import java.util.ResourceBundle; -import javax.faces.context.FacesContext; import javax.naming.Context; import javax.naming.InitialContext; import net.forwardfire.vasc.backend.VascBackend; import net.forwardfire.vasc.backend.VascBackendControllerLocal; -import net.forwardfire.vasc.backend.VascBackendState; import net.forwardfire.vasc.backend.proxy.VascBackendProxyEventExecutor; import net.forwardfire.vasc.core.VascController; -import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryControllerLocal; -import net.forwardfire.vasc.core.VascEntryField; import net.forwardfire.vasc.core.VascEntryLocal; -import net.forwardfire.vasc.core.VascException; -import net.forwardfire.vasc.core.entry.VascEntryFieldValue; -import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener; -import net.forwardfire.vasc.core.entry.VascEntryRecordCreator; import net.forwardfire.vasc.ejb3.VascServiceManager; -import net.forwardfire.vasc.frontend.VascFrontendController; +import net.forwardfire.vasc.ejb3.VascServiceRemoteBackend; import net.forwardfire.vasc.impl.DefaultVascFactory; -import net.forwardfire.vasc.impl.entry.DefaultVascEntryResourceResolver; import net.forwardfire.vasc.impl.entry.SetParameterBackendListener; @@ -166,174 +153,6 @@ abstract public class AbstractJSFVascFacesControllerEJB extends AbstractJSFVascF * @return */ - - - class RemoteVascBackend implements VascBackend { - - private String backendId = null; - private VascServiceManager vascManager = null; - - public RemoteVascBackend(String backendId,VascServiceManager vascManager) { - this.backendId=backendId; - this.vascManager=vascManager; - } - - public void startBackend() { - } - public void stopBackend() { - } - - public void delete(Object object) throws VascException { - Object[] args = new Object[1]; - args[0]=object; - vascManager.invokeBackendMethod(backendId, "delete", args); - } - - public long doRecordMoveDownById(VascBackendState state,Object primaryId) throws VascException { - Object[] args = new Object[2]; - args[0]=state; - args[1]=primaryId; - Object result = vascManager.invokeBackendMethod(backendId, "doRecordMoveDownById", args); - return (Long)result; - } - - public long doRecordMoveUpById(VascBackendState state, Object primaryId) throws VascException { - Object[] args = new Object[2]; - args[0]=state; - args[1]=primaryId; - Object result = vascManager.invokeBackendMethod(backendId, "doRecordMoveUpById", args); - return (Long)result; - } - - @SuppressWarnings("unchecked") - public List execute(VascBackendState state) throws VascException { - Object[] args = new Object[1]; - args[0]=state; - Object result = vascManager.invokeBackendMethod(backendId, "execute", args); - return (List)result; - } - - public long fetchTotalExecuteSize(VascBackendState state) { - Object[] args = new Object[1]; - args[0]=state; - Object result = vascManager.invokeBackendMethod(backendId, "fetchTotalExecuteSize", args); - return (Long)result; - } - - public String getId() { - return backendId; - } - - public boolean isPageable() { - Object[] args = new Object[0]; - Object result = vascManager.invokeBackendMethod(backendId, "isPageable", args); - return (Boolean)result; - } - - public boolean isRecordMoveable() { - Object[] args = new Object[0]; - Object result = vascManager.invokeBackendMethod(backendId, "isRecordMoveable", args); - return (Boolean)result; - } - - public boolean isSearchable() { - Object[] args = new Object[0]; - Object result = vascManager.invokeBackendMethod(backendId, "isSearchable", args); - return (Boolean)result; - } - - public boolean isSortable() { - Object[] args = new Object[0]; - Object result = vascManager.invokeBackendMethod(backendId, "isSortable", args); - return (Boolean)result; - } - - public Object merge(Object object) throws VascException { - Object[] args = new Object[1]; - args[0]=object; - Object result = vascManager.invokeBackendMethod(backendId, "merge", args); - return result; - } - - public void persist(Object object) throws VascException { - Object[] args = new Object[1]; - args[0]=object; - vascManager.invokeBackendMethod(backendId, "delete", args); - } - - public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) { - /* - try { - ByteArrayOutputStream dataArray = new ByteArrayOutputStream(256); // it grows when needed - ObjectOutputStream objOutstream = new ObjectOutputStream(dataArray); - objOutstream.writeObject(field); - objOutstream.close(); - int objectSize = dataArray.size(); - System.out.println("Writing obj to field: "+objectSize); - } catch (IOException e) { - throw new RuntimeException(e); - } - */ - Object[] args = new Object[1]; - args[0]=field; - Object result = vascManager.invokeBackendMethod(backendId, "provideVascEntryFieldValue", args); - return (VascEntryFieldValue)result; - } - - public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) { - VascEntryLocal clone = null; - try { - clone = ((VascEntryLocal)vascEntry).clone(); - clone.setVascFrontendController(null); - clone.setVascEntryFieldEventChannel(null); - } catch (CloneNotSupportedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - try { - ByteArrayOutputStream dataArray = new ByteArrayOutputStream(256); // it grows when needed - ObjectOutputStream objOutstream = new ObjectOutputStream(dataArray); - objOutstream.writeObject(clone); - objOutstream.close(); - //int objectSize = dataArray.size(); - //System.out.println("Writing obj to entry: "+objectSize); - } catch (IOException e) { - throw new RuntimeException(e); - } - Object[] args = new Object[1]; - args[0]=clone; - Object result = vascManager.invokeBackendMethod(backendId, "provideVascEntryRecordCreator", args); - return (VascEntryRecordCreator)result; - } - - public void setId(String id) { - // we cant change id - } - - public Map executePageSummary() { - return null; - } - - public Map executeTotalSummary() { - return null; - } - - public boolean isPageSummary() { - Object[] args = new Object[0]; - Object result = vascManager.invokeBackendMethod(backendId, "isPageSummary", args); - return (Boolean)result; - } - - public boolean isTotalSummary() { - Object[] args = new Object[0]; - Object result = vascManager.invokeBackendMethod(backendId, "isTotalSummary", args); - return (Boolean)result; - } - - public boolean isReadOnly() { - return false; - } - } /** * @return the vascController @@ -370,7 +189,7 @@ abstract public class AbstractJSFVascFacesControllerEJB extends AbstractJSFVascF for (String id:entryIds) { VascEntryLocal ve = (VascEntryLocal)vascManager.getVascEntry(id); String backendId = ve.getBackendId(); - VascBackend vb = new RemoteVascBackend(backendId,vascManager); + VascBackend vb = new VascServiceRemoteBackend(vascManager,backendId); for (String key:ve.getEntryParameterKeys()) { Object value = ve.getEntryParameter(key); diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/MergeableResourceBundle.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/MergeableResourceBundle.java index 15b330c..e3796c5 100644 --- a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/MergeableResourceBundle.java +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/MergeableResourceBundle.java @@ -59,6 +59,15 @@ public class MergeableResourceBundle extends ResourceBundle { bundleData.clear(); } + /** + * Returns copy of data of this loaded merged bundle. + */ + public Map getBundleData() { + Map result = new HashMap(bundleData.size()); + result.putAll(bundleData); + return result; + } + /** * @see java.util.ResourceBundle#handleGetObject(java.lang.String) */ diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_by.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_by.java index 362561e..9f7f580 100644 --- a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_by.java +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_by.java @@ -22,7 +22,6 @@ package net.forwardfire.vasc.lib.i18n.bundle; -import net.forwardfire.vasc.lib.i18n.AbstractRootApplicationBundle; import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; /** @@ -31,7 +30,7 @@ import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; * @author Willem Cazander * @version 1.0 Mar 8, 2012 */ -public class RootApplicationBundle_by extends AbstractRootApplicationBundle { +public class RootApplicationBundle_by extends RootApplicationBundle { @Override public SupportedBundleLocale getSupportedBundleLocale() { diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_da.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_da.java index 389cc8a..beec336 100644 --- a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_da.java +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_da.java @@ -22,7 +22,6 @@ package net.forwardfire.vasc.lib.i18n.bundle; -import net.forwardfire.vasc.lib.i18n.AbstractRootApplicationBundle; import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; /** @@ -31,7 +30,7 @@ import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; * @author Willem Cazander * @version 1.0 Mar 8, 2012 */ -public class RootApplicationBundle_da extends AbstractRootApplicationBundle { +public class RootApplicationBundle_da extends RootApplicationBundle { @Override public SupportedBundleLocale getSupportedBundleLocale() { diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_de.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_de.java index c3113b1..0d90c06 100644 --- a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_de.java +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_de.java @@ -22,7 +22,6 @@ package net.forwardfire.vasc.lib.i18n.bundle; -import net.forwardfire.vasc.lib.i18n.AbstractRootApplicationBundle; import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; /** @@ -31,7 +30,7 @@ import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; * @author Willem Cazander * @version 1.0 Mar 8, 2012 */ -public class RootApplicationBundle_de extends AbstractRootApplicationBundle { +public class RootApplicationBundle_de extends RootApplicationBundle { @Override public SupportedBundleLocale getSupportedBundleLocale() { diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_en.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_en.java index 88d9ab4..5b92ca2 100644 --- a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_en.java +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_en.java @@ -22,7 +22,6 @@ package net.forwardfire.vasc.lib.i18n.bundle; -import net.forwardfire.vasc.lib.i18n.AbstractRootApplicationBundle; import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; /** @@ -31,7 +30,7 @@ import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; * @author Willem Cazander * @version 1.0 Mar 8, 2012 */ -public class RootApplicationBundle_en extends AbstractRootApplicationBundle { +public class RootApplicationBundle_en extends RootApplicationBundle { @Override public SupportedBundleLocale getSupportedBundleLocale() { diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_es.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_es.java index b97b6f8..c387f97 100644 --- a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_es.java +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_es.java @@ -22,7 +22,6 @@ package net.forwardfire.vasc.lib.i18n.bundle; -import net.forwardfire.vasc.lib.i18n.AbstractRootApplicationBundle; import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; /** @@ -31,7 +30,7 @@ import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; * @author Willem Cazander * @version 1.0 Mar 8, 2012 */ -public class RootApplicationBundle_es extends AbstractRootApplicationBundle { +public class RootApplicationBundle_es extends RootApplicationBundle { @Override public SupportedBundleLocale getSupportedBundleLocale() { diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_fr.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_fr.java index 947a718..dbf2618 100644 --- a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_fr.java +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_fr.java @@ -22,7 +22,6 @@ package net.forwardfire.vasc.lib.i18n.bundle; -import net.forwardfire.vasc.lib.i18n.AbstractRootApplicationBundle; import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; /** @@ -31,7 +30,7 @@ import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; * @author Willem Cazander * @version 1.0 Mar 8, 2012 */ -public class RootApplicationBundle_fr extends AbstractRootApplicationBundle { +public class RootApplicationBundle_fr extends RootApplicationBundle { @Override public SupportedBundleLocale getSupportedBundleLocale() { diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_it.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_it.java index efac0d0..6b02c21 100644 --- a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_it.java +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_it.java @@ -22,7 +22,6 @@ package net.forwardfire.vasc.lib.i18n.bundle; -import net.forwardfire.vasc.lib.i18n.AbstractRootApplicationBundle; import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; /** @@ -31,7 +30,7 @@ import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; * @author Willem Cazander * @version 1.0 Mar 8, 2012 */ -public class RootApplicationBundle_it extends AbstractRootApplicationBundle { +public class RootApplicationBundle_it extends RootApplicationBundle { @Override public SupportedBundleLocale getSupportedBundleLocale() { diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_nl.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_nl.java index 333d298..3439c56 100644 --- a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_nl.java +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_nl.java @@ -22,7 +22,6 @@ package net.forwardfire.vasc.lib.i18n.bundle; -import net.forwardfire.vasc.lib.i18n.AbstractRootApplicationBundle; import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; /** @@ -31,7 +30,7 @@ import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; * @author Willem Cazander * @version 1.0 Mar 8, 2012 */ -public class RootApplicationBundle_nl extends AbstractRootApplicationBundle { +public class RootApplicationBundle_nl extends RootApplicationBundle { @Override public SupportedBundleLocale getSupportedBundleLocale() { diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_pl.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_pl.java index a455c93..3c87fca 100644 --- a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_pl.java +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_pl.java @@ -22,7 +22,6 @@ package net.forwardfire.vasc.lib.i18n.bundle; -import net.forwardfire.vasc.lib.i18n.AbstractRootApplicationBundle; import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; /** @@ -31,7 +30,7 @@ import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; * @author Willem Cazander * @version 1.0 Mar 8, 2012 */ -public class RootApplicationBundle_pl extends AbstractRootApplicationBundle { +public class RootApplicationBundle_pl extends RootApplicationBundle { @Override public SupportedBundleLocale getSupportedBundleLocale() { diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_pt.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_pt.java index 4dfe40a..f78b9b7 100644 --- a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_pt.java +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_pt.java @@ -22,7 +22,6 @@ package net.forwardfire.vasc.lib.i18n.bundle; -import net.forwardfire.vasc.lib.i18n.AbstractRootApplicationBundle; import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; /** @@ -31,7 +30,7 @@ import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; * @author Willem Cazander * @version 1.0 Mar 8, 2012 */ -public class RootApplicationBundle_pt extends AbstractRootApplicationBundle { +public class RootApplicationBundle_pt extends RootApplicationBundle { @Override public SupportedBundleLocale getSupportedBundleLocale() { diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_ro.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_ro.java index d97c342..71bb3de 100644 --- a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_ro.java +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_ro.java @@ -22,7 +22,6 @@ package net.forwardfire.vasc.lib.i18n.bundle; -import net.forwardfire.vasc.lib.i18n.AbstractRootApplicationBundle; import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; /** @@ -31,7 +30,7 @@ import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; * @author Willem Cazander * @version 1.0 Mar 8, 2012 */ -public class RootApplicationBundle_ro extends AbstractRootApplicationBundle { +public class RootApplicationBundle_ro extends RootApplicationBundle { @Override public SupportedBundleLocale getSupportedBundleLocale() { diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_ru.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_ru.java index 166f4f9..b7203cf 100644 --- a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_ru.java +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_ru.java @@ -22,7 +22,6 @@ package net.forwardfire.vasc.lib.i18n.bundle; -import net.forwardfire.vasc.lib.i18n.AbstractRootApplicationBundle; import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; /** @@ -31,7 +30,7 @@ import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; * @author Willem Cazander * @version 1.0 Mar 8, 2012 */ -public class RootApplicationBundle_ru extends AbstractRootApplicationBundle { +public class RootApplicationBundle_ru extends RootApplicationBundle { @Override public SupportedBundleLocale getSupportedBundleLocale() { diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_sv.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_sv.java index 86460e3..bd16c87 100644 --- a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_sv.java +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/bundle/RootApplicationBundle_sv.java @@ -22,7 +22,6 @@ package net.forwardfire.vasc.lib.i18n.bundle; -import net.forwardfire.vasc.lib.i18n.AbstractRootApplicationBundle; import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; /** @@ -31,7 +30,7 @@ import net.forwardfire.vasc.lib.i18n.SupportedBundleLocale; * @author Willem Cazander * @version 1.0 Mar 8, 2012 */ -public class RootApplicationBundle_sv extends AbstractRootApplicationBundle { +public class RootApplicationBundle_sv extends RootApplicationBundle { @Override public SupportedBundleLocale getSupportedBundleLocale() { diff --git a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/config/BundleConfigParser.java b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/config/BundleConfigParser.java index f483b11..f65a365 100644 --- a/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/config/BundleConfigParser.java +++ b/vasc-lib/vasc-lib-i18n/src/main/java/net/forwardfire/vasc/lib/i18n/config/BundleConfigParser.java @@ -49,21 +49,21 @@ public class BundleConfigParser { private Logger logger = null; public static final String CONFIG_RESOURCE_DEFAULT = "META-INF/root-bundle.properties"; - protected static final String DEFAULT_CHAR_SET = "UTF-8"; - protected List applicationSupportedLocales = null; - protected List bundlesConfigs = null; - protected List bundleNames = null; - protected Charset defaultCharSet = null; - - /** - * Creates new BundleConfigParser object. - */ + protected static final String DEFAULT_CHAR_SET = "UTF-8"; + protected List applicationSupportedLocales = null; + protected List bundlesConfigs = null; + protected List bundleNames = null; + protected Charset defaultCharSet = null; + + /** + * Creates new BundleConfigParser object. + */ public BundleConfigParser() { logger = Logger.getLogger(BundleConfigParser.class.getName()); applicationSupportedLocales = new ArrayList(10); bundlesConfigs = new ArrayList(10); - defaultCharSet = Charset.forName(DEFAULT_CHAR_SET); bundleNames = new ArrayList(10); + defaultCharSet = Charset.forName(DEFAULT_CHAR_SET); } /** @@ -258,11 +258,11 @@ public class BundleConfigParser { */ protected void readPropertiesConfig(Properties p) { try { - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - if (cl == null) { - cl = p.getClass().getClassLoader(); // fallback - } - readProperties(p,new InputStreamReader(cl.getResourceAsStream(CONFIG_RESOURCE_DEFAULT),defaultCharSet)); + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + if (cl == null) { + cl = p.getClass().getClassLoader(); // fallback + } + readProperties(p,new InputStreamReader(cl.getResourceAsStream(CONFIG_RESOURCE_DEFAULT),defaultCharSet)); } catch (Exception e) { throw new RuntimeException("Could not load resource: "+CONFIG_RESOURCE_DEFAULT+" error: "+e.getMessage(),e); } diff --git a/vasc-test/vasc-test-i18n/src/main/java/net/forwardfire/vasc/test/i18n/VascBundleCheckEntryKeys.java b/vasc-test/vasc-test-i18n/src/main/java/net/forwardfire/vasc/test/i18n/VascBundleCheckEntryKeys.java index 8dec266..05ed4db 100644 --- a/vasc-test/vasc-test-i18n/src/main/java/net/forwardfire/vasc/test/i18n/VascBundleCheckEntryKeys.java +++ b/vasc-test/vasc-test-i18n/src/main/java/net/forwardfire/vasc/test/i18n/VascBundleCheckEntryKeys.java @@ -32,6 +32,7 @@ import java.util.ResourceBundle; import net.forwardfire.vasc.core.VascEntry; import net.forwardfire.vasc.core.VascEntryField; import net.forwardfire.vasc.core.VascEntryFieldSet; +import net.forwardfire.vasc.core.VascEntryGroup; import net.forwardfire.vasc.core.VascEntryLink; import net.forwardfire.vasc.core.actions.VascAction; @@ -102,6 +103,25 @@ public class VascBundleCheckEntryKeys { return keys; } + public Map collectVascKeys(VascEntryGroup veg) { + Map keys = new HashMap(30); + keys.put(veg.getName(), veg.getId()); + keys.put(veg.getImage(), veg.getId()); + keys.put(veg.getDescription(), veg.getId()); + return keys; + } + + public Map generateMissingKeys(VascEntryGroup veg) { + Map keys = collectVascKeys(veg); + List keysResult = new ArrayList(keys.keySet()); + keysResult.removeAll(resourceBundle.keySet()); + Collections.sort(keysResult); + Map data = new HashMap(300); + for (String key:keysResult) { + data.put(key, keys.get(key)); + } + return data; + } public Map generateMissingKeys(VascEntry ve) { Map keys = collectVascKeys(ve);