Differences
This shows you the differences between two versions of the page.
|
person_tables [2012/04/02 11:14] srdjan.lukovic [Person's Tables] |
person_tables [2012/07/09 10:49] (current) srdjan.lukovic [GUI Code] |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Person's Tables ====== | + | ====== Grids ====== |
| - | This sample presents Person's details in tabular views. | + | |
| + | **Grids** is a [[SOLoist Sample Applications|SOLoist sample application]] that demonstrates various tabular views of object details. | ||
| ==== Live example ==== | ==== Live example ==== | ||
| Line 6: | Line 7: | ||
| [[http://soloistdemo.org/SampleApplications/personstable.html]]\\ | [[http://soloistdemo.org/SampleApplications/personstable.html]]\\ | ||
| [[http://soloistdemo.org/SampleApplications/oql?q=SELECT+p%2C+p.name%2C+p.gender%2C+p.age%2C+p.dateOfBirth%2C+p.height%2C+p.isMarried%2C+p.photo%2C+p.rootFolder%0D%0AFROM+Person+p&f=html | OQL Query: Persons]] | [[http://soloistdemo.org/SampleApplications/oql?q=SELECT+p%2C+p.name%2C+p.gender%2C+p.age%2C+p.dateOfBirth%2C+p.height%2C+p.isMarried%2C+p.photo%2C+p.rootFolder%0D%0AFROM+Person+p&f=html | OQL Query: Persons]] | ||
| + | |{{screen:personstable.png?250}}| | ||
| ===== UML Model ===== | ===== UML Model ===== | ||
| Line 20: | Line 22: | ||
| import rs.sol.soloist.helpers.init.Initializer; | import rs.sol.soloist.helpers.init.Initializer; | ||
| import rs.sol.soloist.helpers.init.InitializerFailedException; | import rs.sol.soloist.helpers.init.InitializerFailedException; | ||
| - | import rs.sol.soloist.server.builtindomains.builtindatatypes.Boolean; | ||
| - | 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.GUILabelComponent; | import rs.sol.soloist.server.guiconfiguration.components.GUILabelComponent; | ||
| import rs.sol.soloist.server.guiconfiguration.components.GUIPanelComponent; | import rs.sol.soloist.server.guiconfiguration.components.GUIPanelComponent; | ||
| - | 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.GUISlotEditorKind; | + | |
| - | import rs.sol.soloist.server.guiconfiguration.elementcomponents.GUITableWidget; | + | |
| import rs.sol.soloist.server.guiconfiguration.nonvisualcompoments.GUIFindAllInstancesSAPComponent; | import rs.sol.soloist.server.guiconfiguration.nonvisualcompoments.GUIFindAllInstancesSAPComponent; | ||
| import rs.sol.soloist.server.guiconfiguration.style.GUIContext; | import rs.sol.soloist.server.guiconfiguration.style.GUIContext; | ||
| Line 48: | Line 43: | ||
| { | { | ||
| GUIApplicationComponent page = new GUIApplicationComponent(); | GUIApplicationComponent page = new GUIApplicationComponent(); | ||
| - | page.name.set(Text.fromString("PersonsTable")); | + | page.setName("PersonsTable"); |
| SoloistServiceServlet.registerApplication(page); | SoloistServiceServlet.registerApplication(page); | ||
| GUIContext context = createContextAndStyles(); | GUIContext context = createContextAndStyles(); | ||
| - | page.context.set(context); | + | page.setContext(context); |
| GUIPanelComponent root = GUIPanelComponent.createVertical(page); | GUIPanelComponent root = GUIPanelComponent.createVertical(page); | ||
| GUILabelComponent title = GUILabelComponent.create(root, "Persons Table"); | GUILabelComponent title = GUILabelComponent.create(root, "Persons Table"); | ||
| - | 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 allPersons = GUIFindAllInstancesSAPComponent.create(root, Person.FQ_TYPE_NAME); // this component fetches all persons | + | // This component fetches all persons |
| + | GUIFindAllInstancesSAPComponent allPersons = GUIFindAllInstancesSAPComponent.create(root, Person.CLASSIFIER); | ||
| - | GUILabelComponent.create(topPanel, "Editable fields").styleName.set(Text.fromString("subtitle")); | + | GUILabelComponent.create(topPanel, "Editable fields").setStyle("subtitle"); |
| createPersonsTable(topPanel, allPersons, false, false); | createPersonsTable(topPanel, allPersons, false, false); | ||
| - | GUILabelComponent.create(topPanel, "Readonly fields").styleName.set(Text.fromString("subtitle")); | + | GUILabelComponent.create(topPanel, "Readonly fields").setStyle("subtitle"); |
| createPersonsTable(topPanel, allPersons, true, false); | createPersonsTable(topPanel, allPersons, true, false); | ||
| - | GUILabelComponent.create(topPanel, "Readonly fields as labels").styleName.set(Text.fromString("subtitle")); | + | GUILabelComponent.create(topPanel, "Readonly fields as labels").setStyle("subtitle"); |
| createPersonsTable(topPanel, allPersons, true, true); | createPersonsTable(topPanel, allPersons, true, true); | ||
| } | } | ||
| Line 74: | Line 70: | ||
| { | { | ||
| // column components | // column components | ||
| - | GUIElementComponent nameEditor = GUIElementComponent.createSlotEditor(null, Person.PROPERTIES.name); | + | GUIEdit nameEditor = GUIEdit.createField(null, Person.PROPERTIES.name); |
| - | GUISlotEditorKind.get(nameEditor).readOnly.set(Boolean.valueOf(readonly)); | + | nameEditor.setReadOnly(readonly); |
| - | GUISlotEditorKind.get(nameEditor).displayAsLabel.set(Boolean.valueOf(displayAsLabel)); | + | nameEditor.setDisplayAsLabel(displayAsLabel); |
| - | + | ||
| - | GUIElementComponent genderEditor = GUIElementComponent.createSlotEditor(null, Person.PROPERTIES.gender); | + | |
| - | GUISlotEditorKind.get(genderEditor).readOnly.set(Boolean.valueOf(readonly)); | + | |
| - | GUISlotEditorKind.get(genderEditor).displayAsLabel.set(Boolean.valueOf(displayAsLabel)); | + | |
| - | + | ||
| - | GUIElementComponent ageEditor = GUIElementComponent.createSlotEditor(null, Person.PROPERTIES.age); | + | |
| - | GUISlotEditorKind.get(ageEditor).readOnly.set(Boolean.valueOf(readonly)); | + | |
| - | GUISlotEditorKind.get(ageEditor).displayAsLabel.set(Boolean.valueOf(displayAsLabel)); | + | |
| - | GUIElementComponent dateOfBirthEditor = GUIElementComponent.createSlotEditor(null, Person.PROPERTIES.dateOfBirth); | + | GUIEdit genderEditor = GUIEdit.createField(null, Person.PROPERTIES.gender); |
| - | GUISlotEditorKind.get(dateOfBirthEditor).readOnly.set(Boolean.valueOf(readonly)); | + | genderEditor.setReadOnly(readonly); |
| - | GUISlotEditorKind.get(dateOfBirthEditor).displayAsLabel.set(Boolean.valueOf(displayAsLabel)); | + | genderEditor.setDisplayAsLabel(displayAsLabel); |
| - | GUIElementComponent heightEditor = GUIElementComponent.createSlotEditor(null, Person.PROPERTIES.height); | + | GUIEdit ageEditor = GUIEdit.createField(null, Person.PROPERTIES.age); |
| - | GUISlotEditorKind.get(heightEditor).readOnly.set(Boolean.valueOf(readonly)); | + | ageEditor.setReadOnly(readonly); |
| - | GUISlotEditorKind.get(heightEditor).displayAsLabel.set(Boolean.valueOf(displayAsLabel)); | + | ageEditor.setDisplayAsLabel(displayAsLabel); |
| - | GUIElementComponent isMarriedEditor = GUIElementComponent.createSlotEditor(null, Person.PROPERTIES.isMarried); | + | GUIEdit dateOfBirthEditor = GUIEdit.createField(null, Person.PROPERTIES.dateOfBirth); |
| - | GUISlotEditorKind.get(isMarriedEditor).readOnly.set(Boolean.valueOf(readonly)); | + | dateOfBirthEditor.setReadOnly(readonly); |
| - | GUISlotEditorKind.get(isMarriedEditor).displayAsLabel.set(Boolean.valueOf(displayAsLabel)); | + | dateOfBirthEditor.setDisplayAsLabel(displayAsLabel); |
| - | // column header texts and oredering of column components | + | GUIEdit heightEditor = GUIEdit.createField(null, Person.PROPERTIES.height); |
| - | GUITableWidget gtw = GUITableWidget.create(new String[]{"Person", "Name", "Gender", "Age", "Date of Birth", "Height", "Is Married"}, | + | heightEditor.setReadOnly(readonly); |
| - | new GUIComponent[]{nameEditor, genderEditor, ageEditor, dateOfBirthEditor, heightEditor, isMarriedEditor}); | + | heightEditor.setDisplayAsLabel(displayAsLabel); |
| - | gtw.minRows.set(Integer.valueOf(3)); // min rows to show if there is no data in the table | + | GUIEdit isMarriedEditor = GUIEdit.createField(null, Person.PROPERTIES.isMarried); |
| - | GUIElementComponent editableTable = GUIElementComponent.create(root, new GUIInputKind(), gtw, new GUICollectionInput()); // the very table | + | isMarriedEditor.setReadOnly(readonly); |
| + | isMarriedEditor.setDisplayAsLabel(displayAsLabel); | ||
| - | GUIComponentBinding.create(allPersons.value, GUICollectionInput.get(editableTable).collection); | + | GUIInput editableTable = GUIInput.createTable(root, "Person", "Name", "Gender", "Age", "Date of Birth", "Height", "Is Married"); |
| + | editableTable.setColumnComponents(nameEditor, genderEditor, ageEditor, dateOfBirthEditor, heightEditor, isMarriedEditor); | ||
| + | editableTable.setMinRows(3); // min rows to show if there is no data in the table | ||
| + | GUIComponentBinding.create(allPersons.opValue(), editableTable.ipCollection()); | ||
| } | } | ||
| Line 111: | Line 103: | ||
| { | { | ||
| GUIContext context = new GUIContext(); | GUIContext context = new GUIContext(); | ||
| - | context.supercontext.set(DefaultContextInit.getRoot()); | + | DefaultContextInit.getRoot().addContext(context); |
| GUIObjectSetting person = GUIObjectSetting.create(context, Person.CLASSIFIER); | GUIObjectSetting person = GUIObjectSetting.create(context, Person.CLASSIFIER); | ||