Differences
This shows you the differences between two versions of the page.
|
bank_advisers [2012/04/02 11:34] srdjan.lukovic [GUI Code] |
bank_advisers [2012/07/09 10:51] (current) srdjan.lukovic [GUI Code] |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Bank Advisers Sample ====== | + | ====== Bank Advisers ====== |
| - | ... | + | |
| + | **Bank Advisers** is a [[SOLoist Sample Applications|SOLoist sample application]] that combines several features presented in the previous examples, most notably [[Edit Person's Details|Edit Object Details]], [[Person Tables|Grids]], [[Persons and Bank Accounts|CRUD]], and [[Association Editor|Selection List]]. | ||
| + | |||
| + | All objects of the class //BankAdviser// are shown in a grid. Attribute slots of these objects can be edited in the grid fields. | ||
| + | |||
| + | Objects of the class // BankAdviser// can be created or deleted with the command buttons. | ||
| + | |||
| + | Selecting one //Bank Adviser// from the grid will enable the checkbox editor in the Clients list. Ticking a checkbox next to a //Person// object in the list will make that person a client of the selected //Bank Adviser//. | ||
| ==== Live example ==== | ==== Live example ==== | ||
| Line 6: | Line 13: | ||
| [[http://soloistdemo.org/SampleApplications/bankadvisers.html]]\\ | [[http://soloistdemo.org/SampleApplications/bankadvisers.html]]\\ | ||
| [[http://soloistdemo.org/SampleApplications/oql?q=SELECT+b%2C+b.name%2C+b.gender%2C+b.age%2C+b.dateOfBirth%2C+b.height%2C+b.isMarried%2C+b.photo%2C+b.rootFolder%2C+b.bank%2C+b.myDepartment%0D%0AFROM+BankAdviser+b&f=html | OQL Query: Bank Advisers]] | [[http://soloistdemo.org/SampleApplications/oql?q=SELECT+b%2C+b.name%2C+b.gender%2C+b.age%2C+b.dateOfBirth%2C+b.height%2C+b.isMarried%2C+b.photo%2C+b.rootFolder%2C+b.bank%2C+b.myDepartment%0D%0AFROM+BankAdviser+b&f=html | OQL Query: Bank Advisers]] | ||
| + | |{{screen:bankadvisers.png?250}}| | ||
| ===== UML Model ===== | ===== UML Model ===== | ||
| Line 11: | Line 19: | ||
| ===== Business Logic Code ===== | ===== Business Logic Code ===== | ||
| - | <code java> | + | <code java FetchPersonsOnly.java> |
| - | //FetchPersonsOnly.java | + | |
| public void execute() | public void execute() | ||
| // -------------<SOL id="1a6091eb-09c4-4579-8d13-14cd0d54d44c:___throw__" /> | // -------------<SOL id="1a6091eb-09c4-4579-8d13-14cd0d54d44c:___throw__" /> | ||
| Line 43: | Line 50: | ||
| import rs.sol.soloist.server.builtindomains.builtincommands.CmdCreateObjectOfClass; | import rs.sol.soloist.server.builtindomains.builtincommands.CmdCreateObjectOfClass; | ||
| import rs.sol.soloist.server.builtindomains.builtincommands.CmdDestroyObject; | import rs.sol.soloist.server.builtindomains.builtincommands.CmdDestroyObject; | ||
| - | import rs.sol.soloist.server.builtindomains.builtindatatypes.Integer; | ||
| - | import rs.sol.soloist.server.builtindomains.builtindatatypes.Text; | ||
| import rs.sol.soloist.server.guiconfiguration.components.GUIApplicationComponent; | import rs.sol.soloist.server.guiconfiguration.components.GUIApplicationComponent; | ||
| import rs.sol.soloist.server.guiconfiguration.components.GUIButtonComponent; | import rs.sol.soloist.server.guiconfiguration.components.GUIButtonComponent; | ||
| Line 51: | Line 56: | ||
| import rs.sol.soloist.server.guiconfiguration.components.GUIPanelComponent; | import rs.sol.soloist.server.guiconfiguration.components.GUIPanelComponent; | ||
| import rs.sol.soloist.server.guiconfiguration.components.PerformImmediately; | import rs.sol.soloist.server.guiconfiguration.components.PerformImmediately; | ||
| - | import rs.sol.soloist.server.guiconfiguration.construction.GUIComponent; | ||
| import rs.sol.soloist.server.guiconfiguration.construction.GUIComponentBinding; | import rs.sol.soloist.server.guiconfiguration.construction.GUIComponentBinding; | ||
| - | import rs.sol.soloist.server.guiconfiguration.elementcomponents.GUICollectionInput; | + | import rs.sol.soloist.server.guiconfiguration.elementcomponents.GUIEdit; |
| - | import rs.sol.soloist.server.guiconfiguration.elementcomponents.GUIElementComponent; | + | import rs.sol.soloist.server.guiconfiguration.elementcomponents.GUIInput; |
| - | import rs.sol.soloist.server.guiconfiguration.elementcomponents.GUIInputKind; | + | |
| - | import rs.sol.soloist.server.guiconfiguration.elementcomponents.GUIListWidget; | + | |
| - | import rs.sol.soloist.server.guiconfiguration.elementcomponents.GUISlotEditorKind; | + | |
| - | import rs.sol.soloist.server.guiconfiguration.elementcomponents.GUITableWidget; | + | |
| - | import rs.sol.soloist.server.guiconfiguration.layout.CellLayoutData; | + | |
| import rs.sol.soloist.server.guiconfiguration.layout.VerticalAlignment; | import rs.sol.soloist.server.guiconfiguration.layout.VerticalAlignment; | ||
| import rs.sol.soloist.server.guiconfiguration.nonvisualcompoments.GUIFindAllInstancesSAPComponent; | import rs.sol.soloist.server.guiconfiguration.nonvisualcompoments.GUIFindAllInstancesSAPComponent; | ||
| Line 76: | Line 75: | ||
| { | { | ||
| GUIApplicationComponent page = new GUIApplicationComponent(); | GUIApplicationComponent page = new GUIApplicationComponent(); | ||
| - | page.name.set(Text.fromString("BankAdvisers")); | + | page.setName("BankAdvisers"); |
| SoloistServiceServlet.registerApplication(page); | SoloistServiceServlet.registerApplication(page); | ||
| GUIContext context = createContextAndStyles(); | GUIContext context = createContextAndStyles(); | ||
| - | page.context.set(context); | + | page.setContext(context); |
| GUIPanelComponent root = GUIPanelComponent.createFlow(page); | GUIPanelComponent root = GUIPanelComponent.createFlow(page); | ||
| GUILabelComponent title = GUILabelComponent.create(root, "Bank Advisers"); | GUILabelComponent title = GUILabelComponent.create(root, "Bank Advisers"); | ||
| - | title.styleName.set(Text.fromString("titleStyle")); | + | title.setStyle("titleStyle"); |
| GUIPanelComponent topPanel = GUIPanelComponent.createFlow(root); | GUIPanelComponent topPanel = GUIPanelComponent.createFlow(root); | ||
| - | topPanel.styleName.set(Text.fromString("topPanel")); | + | topPanel.setStyle("topPanel"); |
| - | GUIFindAllInstancesSAPComponent allBankAdvisers = GUIFindAllInstancesSAPComponent.create(root, BankAdviser.FQ_TYPE_NAME); | + | GUIFindAllInstancesSAPComponent allBankAdvisers = GUIFindAllInstancesSAPComponent.create(root, BankAdviser.CLASSIFIER); |
| - | // column components | + | // Column components |
| - | GUIElementComponent nameEditor = GUIElementComponent.createSlotEditor(null, Person.PROPERTIES.name); | + | GUIEdit nameEditor = GUIEdit.createField(null, Person.PROPERTIES.name); |
| - | GUIElementComponent bankNameEditor = GUIElementComponent.createSlotEditor(null, BankAdviser.PROPERTIES.bank); | + | GUIEdit bankNameEditor = GUIEdit.createField(null, BankAdviser.PROPERTIES.bank); |
| - | GUIElementComponent genderEditor = GUIElementComponent.createSlotEditor(null, Person.PROPERTIES.gender); | + | GUIEdit genderEditor = GUIEdit.createField(null, Person.PROPERTIES.gender); |
| - | GUIElementComponent ageEditor = GUIElementComponent.createSlotEditor(null, Person.PROPERTIES.age); | + | GUIEdit ageEditor = GUIEdit.createField(null, Person.PROPERTIES.age); |
| - | GUIElementComponent isMarriedEditor = GUIElementComponent.createSlotEditor(null, Person.PROPERTIES.isMarried); | + | GUIEdit isMarriedEditor = GUIEdit.createField(null, Person.PROPERTIES.isMarried); |
| - | // column header texts and oredering of column components | + | // Column header texts and oredering of column components |
| - | GUITableWidget gtw = GUITableWidget.create(new String[]{"Bank Adviser", "Name", "Bank Name", "Age", "Gender", "Is married"}, | + | GUIInput editableTable = GUIInput.createTable(topPanel, "Bank Adviser", "Name", "Bank Name", "Age", "Gender", "Is married"); |
| - | new GUIComponent[]{nameEditor, bankNameEditor, ageEditor, genderEditor, isMarriedEditor}); | + | editableTable.setColumnComponents(nameEditor, bankNameEditor, ageEditor, genderEditor, isMarriedEditor); |
| + | editableTable.setMinRows(3); // min rows to show if there is no data in the table | ||
| - | gtw.minRows.set(Integer.valueOf(3)); // min rows to show if there is no data in the table | + | GUIComponentBinding.create(allBankAdvisers.opValue(), editableTable.ipCollection()); |
| - | GUIElementComponent editableTable = GUIElementComponent.create(topPanel, new GUIInputKind(), gtw, new GUICollectionInput()); // the very table | + | |
| - | + | ||
| - | GUIComponentBinding.create(allBankAdvisers.value, GUICollectionInput.get(editableTable).collection); | + | |
| GUIPanelComponent buttonsPanel = GUIPanelComponent.createHorizontal(topPanel, VerticalAlignment.MIDDLE); | GUIPanelComponent buttonsPanel = GUIPanelComponent.createHorizontal(topPanel, VerticalAlignment.MIDDLE); | ||
| - | buttonsPanel.styleName.set(Text.fromString("margin3")); | + | buttonsPanel.setStyle("margin3"); |
| CmdCreateObjectOfClass createCmd = new CmdCreateObjectOfClass(); | CmdCreateObjectOfClass createCmd = new CmdCreateObjectOfClass(); | ||
| - | createCmd.className.set(Text.fromString(BankAdviser.FQ_TYPE_NAME)); | + | createCmd.setClass(BankAdviser.CLASSIFIER); |
| GUIButtonComponent createAdviserButton = GUIButtonComponent.create(buttonsPanel, "Create Bank Adviser", createCmd); | GUIButtonComponent createAdviserButton = GUIButtonComponent.create(buttonsPanel, "Create Bank Adviser", createCmd); | ||
| + | |||
| CmdDestroyObject destroyCmd = new CmdDestroyObject(); | CmdDestroyObject destroyCmd = new CmdDestroyObject(); | ||
| - | destroyCmd.type.set(Text.fromString(BankAdviser.FQ_TYPE_NAME)); | + | destroyCmd.setType(BankAdviser.CLASSIFIER); |
| GUIButtonComponent destroyAdviserButton = GUIButtonComponent.create(buttonsPanel, "Delete Bank Adviser", destroyCmd); | GUIButtonComponent destroyAdviserButton = GUIButtonComponent.create(buttonsPanel, "Delete Bank Adviser", destroyCmd); | ||
| - | GUIComponentBinding.create(editableTable.value, destroyAdviserButton, CmdDestroyObject.PROPERTIES.input); | + | GUIComponentBinding.create(editableTable.opValue(), destroyAdviserButton, CmdDestroyObject.PROPERTIES.input); |
| - | GUIComponentBinding.create(createAdviserButton.commandExecuted, allBankAdvisers.refresh); // this is to tell SAP to read advisers again | + | GUIComponentBinding.create(createAdviserButton.opCommandExecuted(), allBankAdvisers.ipRefresh()); // this is to tell SAP to read advisers again |
| - | GUIComponentBinding.create(destroyAdviserButton.commandExecuted, allBankAdvisers.refresh); // this is to tell SAP to read advisers again | + | GUIComponentBinding.create(destroyAdviserButton.opCommandExecuted(), allBankAdvisers.ipRefresh()); // this is to tell SAP to read advisers again |
| - | GUILabelComponent.create(topPanel, "Clients").styleName.set(Text.fromString("padding3")); | + | GUILabelComponent clientsLabel = GUILabelComponent.create(topPanel, "Clients"); |
| + | clientsLabel.setStyle("padding3"); | ||
| + | |||
| + | GUIEdit clients = GUIEdit.createList(topPanel, BankAdviser.PROPERTIES.myClients); | ||
| + | clients.setSize("250px", "300px"); | ||
| + | clients.setStyle("listEditor"); | ||
| - | GUICommandComponent allPersons = GUICommandComponent.create(topPanel, new FetchPersonsOnly(), PerformImmediately.NOTHING); // invisible command: fetches all persons, but not bank advisers | + | // invisible command: fetches all persons, but not bank advisers |
| - | GUIElementComponent clients = GUIElementComponent.create(topPanel, GUISlotEditorKind.create(BankAdviser.PROPERTIES.myClients), new GUIListWidget(), new GUICollectionInput()); | + | GUICommandComponent allPersons = GUICommandComponent.create(root, new FetchPersonsOnly(), PerformImmediately.NOTHING); |
| - | CellLayoutData.setSize(clients, "250px", "300px"); | + | GUIComponentBinding.create(allPersons, FetchPersonsOnly.PROPERTIES.fetchedPersons, clients.ipCollection()); |
| - | clients.styleName.set(Text.fromString("listEditor")); | + | GUIComponentBinding.create(editableTable.opValue(), clients.ipElement()); |
| - | GUIComponentBinding.create(allPersons, FetchPersonsOnly.PROPERTIES.fetchedPersons, GUICollectionInput.get(clients).collection); | + | GUIComponentBinding.create(page.opStart(), allPersons.ipClick()); |
| - | GUIComponentBinding.create(editableTable.value, GUISlotEditorKind.get(clients).element); | + | |
| - | GUIComponentBinding.create(page.start, allPersons.click); | + | |
| } | } | ||
| Line 135: | Line 136: | ||
| { | { | ||
| GUIContext context = new GUIContext(); | GUIContext context = new GUIContext(); | ||
| - | context.supercontext.set(DefaultContextInit.getRoot()); | + | DefaultContextInit.getRoot().addContext(context); |
| - | // this how Person objects will look like in the GUI? | + | // This is how Person objects will look like in the GUI. |
| GUIObjectSetting person = GUIObjectSetting.create(context, Person.CLASSIFIER); | GUIObjectSetting person = GUIObjectSetting.create(context, Person.CLASSIFIER); | ||
| GUITextFeature.createName(person, Person.PROPERTIES.name); | GUITextFeature.createName(person, Person.PROPERTIES.name); | ||