package rs.sol.sampleapps.gallery; import rs.sol.sampleapps.Document; import rs.sol.sampleapps.PictureFromGallery; import rs.sol.sampleapps.commands.AddToGallery; import rs.sol.sampleapps.commands.MoveWithinGallery; import rs.sol.sampleapps.commands.RemoveFromGallery; import rs.sol.sampleapps.gui.GUIGalleryPanel; import rs.sol.soloist.server.builtindomains.builtincommands.CmdCreateObjectOfClass; import rs.sol.soloist.server.builtindomains.builtindatatypes.Boolean; import rs.sol.soloist.server.guiconfiguration.components.GUIButtonComponent; import rs.sol.soloist.server.guiconfiguration.components.GUICommandComponent; import rs.sol.soloist.server.guiconfiguration.components.GUIDisclosurePanel; import rs.sol.soloist.server.guiconfiguration.components.GUILabelComponent; import rs.sol.soloist.server.guiconfiguration.components.GUIPanelComponent; import rs.sol.soloist.server.guiconfiguration.components.PerformImmediately; import rs.sol.soloist.server.guiconfiguration.construction.GUIComponentBinding; import rs.sol.soloist.server.guiconfiguration.elementcomponents.GUIEdit; import rs.sol.soloist.server.guiconfiguration.layout.TableLayoutData; import rs.sol.soloist.server.guiconfiguration.layout.VerticalAlignment; import rs.sol.soloist.server.guiconfiguration.nonvisualcompoments.GUIBooleanFilter; import rs.sol.soloist.server.guiconfiguration.nonvisualcompoments.GUIBufferComponent; import rs.sol.soloist.server.guiconfiguration.nonvisualcompoments.GUIRelayComponent; import rs.sol.soloist.server.uml.concepts.runtime.ISlot; public class GalleryFragment { private ISlot owner; public ISlot ipOwner(){ return owner; } public static MoveWithinGallery cmdMoveWithinGallery = new MoveWithinGallery(); public static RemoveFromGallery cmdRemoveFromGallery = new RemoveFromGallery(); public GalleryFragment(GUIPanelComponent rootPanel) { GUIRelayComponent ownerRelay = GUIRelayComponent.create(rootPanel); owner = ownerRelay.ipRelay(); GUIDisclosurePanel newPictureDisclosure = GUIDisclosurePanel.create(rootPanel, "Add picture to gallery"); GUIPanelComponent subDisclosure = GUIPanelComponent.createFlow(newPictureDisclosure); subDisclosure.setStyle("disclosureForm"); GUIPanelComponent table = GUIPanelComponent.createTable(subDisclosure); table.setStyle("table"); CmdCreateObjectOfClass cmd = new CmdCreateObjectOfClass(); cmd.setClass(PictureFromGallery.CLASSIFIER); GUICommandComponent cmdNewBlank = GUICommandComponent.create(rootPanel, cmd, PerformImmediately.NOTHING); GUIBooleanFilter gbf = GUIBooleanFilter.create(rootPanel); GUIComponentBinding.create(newPictureDisclosure.opOpen(), gbf.ipInput()); GUIComponentBinding.create(gbf.opYes(), cmdNewBlank.ipClick()); int row = 0; GUILabelComponent.create(table, "Title", row++, 0).setStyle("formLabel"); GUILabelComponent.create(table, "Description", row++, 0).setStyle("formLabel"); GUILabelComponent.create(table, "Picture", row++, 0).setStyle("formLabel"); row = 0; GUIEdit title = GUIEdit.createField(table, Document.PROPERTIES.title, row++, 1); GUIEdit descrip = GUIEdit.createField(table, Document.PROPERTIES.description, row++, 1); descrip.setMaxLength(2000); descrip.setMultiline(true); descrip.setSize("265px", "192px"); GUIPanelComponent picUpload = GUIEdit.createPicture(table, PictureFromGallery.PROPERTIES.picture, true); picUpload.setRowColumn(row++, 1); GUIPanelComponent picture = GUIEdit.createPicture(table, PictureFromGallery.PROPERTIES.picture, false); picture.setRowColumn(0, 2, 4, 1); picture.setCellAlignment(null, VerticalAlignment.TOP); GUIComponentBinding.create(cmdNewBlank, CmdCreateObjectOfClass.PROPERTIES.output, title.ipElement()); GUIComponentBinding.create(cmdNewBlank, CmdCreateObjectOfClass.PROPERTIES.output, descrip.ipElement()); GUIComponentBinding.create(cmdNewBlank, CmdCreateObjectOfClass.PROPERTIES.output, picUpload.ipRelay1()); GUIComponentBinding.create(cmdNewBlank, CmdCreateObjectOfClass.PROPERTIES.output, picture.ipRelay1()); GUIButtonComponent cmdAdd = GUIButtonComponent.create(table, "Add picture", new AddToGallery()); cmdAdd.setLayoutData(TableLayoutData.create(row++, 0)); GUIComponentBinding.create(ownerRelay.opRelay(), cmdAdd, AddToGallery.PROPERTIES.galleryOwner); GUIComponentBinding.create(cmdNewBlank, CmdCreateObjectOfClass.PROPERTIES.output, cmdAdd, AddToGallery.PROPERTIES.picture); GUIGalleryPanel galleryPanel = new GUIGalleryPanel(); rootPanel.add(galleryPanel); GUIComponentBinding.create(ownerRelay.opRelay(), galleryPanel.ipElement()); GUIComponentBinding.create(cmdAdd.opCommandExecuted(), galleryPanel.ipRefreshContents()); GUIBufferComponent gbc = GUIBufferComponent.create(rootPanel, false, Boolean.FALSE); GUIComponentBinding.create(gbc.opOutput(), newPictureDisclosure.ipOpen()); GUIComponentBinding.create(cmdAdd.opCommandExecuted(), gbc.ipSend()); } }