from typing import List
from qgis._core import QgsAction, Qgis
open_xplan_object_action_text = '\nfrom qgis.utils import active_plugins\nfrom qgis.utils import active_plugins\nfrom qgis.utils import plugins\nfrom SAGisXPlanung.utils import CLASSES\nfrom SAGisXPlanung.XPlanungItem import XPlanungItem\n\nif not \'SAGisXPlanung\' in active_plugins:\n    iface.messageBar().pushInfo("SAGis XPlanung", "SAGis XPlanung Plugin nicht aktiviert!")\nelse:\n    project = QgsProject.instance()\n    layer = QgsProject.instance().mapLayer(\'[% @layer_id %]\')\n\n    plan_xid = layer.customProperty(f\'xplanung/plan-xid\')\n    xtype = layer.customProperty(f\'xplanung/type\')\n    xid = layer.customProperties().value(f\'xplanung/feat-{[%@id%]}\')\n    xplan_item = XPlanungItem(xid=xid, xtype=CLASSES[xtype], plan_xid=plan_xid)\n\n    plugins[\'SAGisXPlanung\'].dockWidget.showObjectAttributes(xplan_item)\n'

def default_actions() -> List[QgsAction]:
    action = QgsAction(Qgis.AttributeActionType.GenericPython, 'SAGis XPlanung: Objekt öffnen', open_xplan_object_action_text)
    scopes = {'Field', 'Feature'}
    action.setActionScopes(scopes)
    return [action]