package org.orienteer.core.component.command;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.model.IModel;
import org.orienteer.core.component.BootstrapType;
import org.orienteer.core.component.FAIconType;
import org.orienteer.core.component.property.DisplayMode;
import org.orienteer.core.component.structuretable.OrienteerStructureTable;
import org.orienteer.core.component.structuretable.StructureTableCommandsToolbar;

import com.orientechnologies.orient.core.db.record.OIdentifiable;
import com.orientechnologies.orient.core.id.ORID;
import com.orientechnologies.orient.core.record.impl.ODocument;

import org.orienteer.core.web.ODocumentPage;
import ru.ydn.wicket.wicketorientdb.security.ISecuredComponent;
import ru.ydn.wicket.wicketorientdb.security.OSecurityHelper;
import ru.ydn.wicket.wicketorientdb.security.OrientPermission;
import ru.ydn.wicket.wicketorientdb.security.RequiredOrientResource;

/**
 * {@link Command} for {@link OrienteerStructureTable} to save {@link ODocument}
 */
public class SaveODocumentCommand extends AbstractSaveCommand<ODocument> implements ISecuredComponent
{
	private static final long serialVersionUID = 1L;

	public SaveODocumentCommand(
			OrienteerStructureTable<ODocument, ?> structureTable,
			IModel<DisplayMode> displayModeModel) {
		super(structureTable, displayModeModel, structureTable.getModel());
		setIcon(FAIconType.save);
		setBootstrapType(BootstrapType.PRIMARY);
	}

	@Override
	public void onClick(AjaxRequestTarget target) {
		getModelObject().getRecord().save();
        	super.onClick(target);
	}

	@Override
	public RequiredOrientResource[] getRequiredResources() {
		ODocument doc = getModelObject();
		ORID orid = doc.getIdentity();
		OrientPermission permission = orid.isNew()?OrientPermission.CREATE:OrientPermission.UPDATE;
		return OSecurityHelper.requireOClass(doc.getSchemaClass(), permission);
	}
	
}

@@ -223,24 +223,87 @@
 FAIconType;%0A
+import org.orienteer.core.component.ICommandsSupportComponent;%0A
 import org.o
@@ -348,16 +348,16 @@
 ayMode;%0A
-
 import o
@@ -733,16 +733,17 @@
 ntPage;%0A
+%0A
 import r
@@ -1369,21 +1369,20 @@
 el) %7B%0A%09%09
-super
+this
 (structu
@@ -1436,16 +1436,215 @@
 del());%0A
+%09%7D%0A%09%0A%09public SaveODocumentCommand(%0A%09%09%09ICommandsSupportComponent%3CODocument%3E component,%0A%09%09%09IModel%3CDisplayMode%3E displayModeModel, IModel%3CODocument%3E model) %7B%0A%09%09super(component, displayModeModel, model);%0A
 %09%09setIco

Make constructor of SaveODocumentCommand more universe