@Override protected void onSelect(AjaxRequestTarget target, OClass selectedOClass) { redirectToCreateODocumentPage(target, selectedOClass); } });
@Override protected void onInstantiation() { super.onInstantiation(); setIcon(FAIconType.plus); setBootstrapType(BootstrapType.PRIMARY); setAutoNotify(false); }
if(!isStructureReadonly) table.addCommand(new CreateODocumentCommand(table, documentModel, propertyModel).add(securityBehaviour)); table.addCommand(new EditODocumentsCommand(table, modeModel, linkedClass).add(securityBehaviour)); table.addCommand(new SaveODocumentsCommand(table, modeModel).add(securityBehaviour));
protected void redirectToCreateODocumentPage(AjaxRequestTarget target, OClass oClass) { ODocument doc = new ODocument(oClass); if(propertyModel!=null && documentModel!=null) { OProperty property = propertyModel.getObject(); if(property!=null) { OProperty inverseProperty = CustomAttribute.PROP_INVERSE.getValue(property); if(inverseProperty!=null) { doc.field(inverseProperty.getName(), documentModel.getObject()); } } } // target.add(new ODocumentPage(doc).setModeObject(DisplayMode.EDIT)); setResponsePage(new ODocumentPage(doc).setModeObject(DisplayMode.EDIT)); }
public ListAllODocumentsWidget(String id, IModel<OClass> model, IModel<ODocument> widgetDocumentModel) { super(id, model, widgetDocumentModel); IModel<DisplayMode> modeModel = DisplayMode.VIEW.asModel(); String className = getModelObject().getName(); String sql = "select from " + className; OQueryDataProvider<ODocument> provider = new OQueryDataProvider<>(sql); oClassIntrospector.defineDefaultSorting(provider, getModelObject()); GenericTablePanel<ODocument> tablePanel = new GenericTablePanel<>("tablePanel", oClassIntrospector.getColumnsFor(getModelObject(), true, modeModel), provider, 20); final OrienteerDataTable<ODocument, String> table = tablePanel.getDataTable(); table.getCommandsToolbar().setDefaultModel(getModel()); table.addCommand(new CreateODocumentCommand(table, getModel())); table.addCommand(new EditODocumentsCommand(table, modeModel, getModel())); table.addCommand(new SaveODocumentsCommand(table, modeModel)); table.addCommand(new CopyODocumentCommand(table, getModel())); table.addCommand(new DeleteODocumentCommand(table, getModel())); table.addCommand(new ExportCommand<>(table, new PropertyModel<String>(model, "name"))); add(tablePanel); add(UpdateOnActionPerformedEventBehavior.INSTANCE_ALL_CONTINUE); addCommand(new BookmarkablePageLinkCommand<OClass>(newCommandId(), "command.gotoClass", OClassPage.class) { @Override public PageParameters getPageParameters() { return OClassPage.preparePageParameters(ListAllODocumentsWidget.this.getModelObject(), DisplayMode.VIEW); } }); }
@Override public void onClick(Optional<AjaxRequestTarget> targetOptional) { OClass oClass = classModel.getObject(); Collection<OClass> subClasses = oClass.getSubclasses(); if(subClasses==null || subClasses.isEmpty()) { //There is no subclasses, so no need to select particular subtype redirectToCreateODocumentPage(null, oClass); } else { targetOptional.ifPresent(modal::show); } }