File: plugin_definition.py

package info (click to toggle)
python-envisageplugins 3.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,616 kB
  • ctags: 1,970
  • sloc: python: 7,047; makefile: 11; sh: 11; lisp: 1
file content (173 lines) | stat: -rw-r--r-- 5,054 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#-----------------------------------------------------------------------------
#
#  Copyright (c) 2007 by Enthought, Inc.
#  All rights reserved.
#
#-----------------------------------------------------------------------------

"""
A Data resource type plugin.

"""

# Enthought library imports.
from enthought.envisage import PluginDefinition
from enthought.envisage.action.action_plugin_definition import \
    Group, Location, Menu
from enthought.envisage.action.default_action import DefaultAction
from enthought.envisage.core.core_plugin_definition import ApplicationObject
from enthought.envisage.resource.resource_plugin_definition \
    import ResourceType, ResourceManager
from enthought.plugins.python_shell.python_shell_plugin_definition import \
    Namespace

# Local imports.
from data.plugin.services import IDATA_MODEL, IDATA_UI
from data.plugin.data_action_set import DataActionSet


##############################################################################
# Constants
##############################################################################

# This plugin's globally unique identifier.  Our usage's assume this is the
# python path to the package containing the plugin definition module.
ID = 'data.plugin'


##############################################################################
# Extensions.
##############################################################################

#### Actions and ActionSets ##################################################


class RenameDataAction(DefaultAction):
    description = 'Rename this data.'
    name = '&Rename'
    
class EditDataAction(DefaultAction):
    description = 'Edit data properties.'
    name = '&Edit Data Properties'


data_action_set = DataActionSet(
    actions = [
#        # Data action group
#        DeleteDataAction(
#            locations = [
#                Location(
#                    after='RenameData',
#                    path='DataContextMenu/ActionGroup',
#                    ),
#                ],
#            ),
        RenameDataAction(
            locations = [
                Location(path='DataContextMenu/ActionGroup'),
                ],
            ),
        EditDataAction(
            locations = [
                Location(path='DataContextMenu/ActionGroup'),
                ],
            ),
        ],

    groups = [
        # Data groups
        Group(
            id = 'ActionGroup',
            location = Location(
                # after='PersistenceGroup',
                path='DataContextMenu',
                ),
            ),
        ],

    id = '%s.data_action_set.Default' % ID,
    name = 'DataPlugin',
    )


#### Application Objects #####################################################

model_service = ApplicationObject(
    class_name = '%s.model_service.ModelService' % ID,
    uol = 'service://' + IDATA_MODEL,
    )

ui_service = ApplicationObject(
    class_name = '%s.ui_service.UiService' % ID,
    kw = {'model_service' : model_service.uol},
    uol = 'service://' + IDATA_UI,
    )


#### Resource Types ##########################################################

# References to other plugin's resource types
FOLDER = 'enthought.envisage.resource.folder_resource_type.FolderResourceType'
INSTANCE = ('enthought.envisage.resource.instance_resource_type.'
    'InstanceResourceType')

# References to our resource types
DATA_TYPE = ID + '.resource_type.data_resource_type.DataResourceType'

resource_types = ResourceManager(
    resource_types = [
        ResourceType(
            class_name = DATA_TYPE,
            #precedes = [FOLDER, INSTANCE],
            ),
        ],
    )


#### Shell Namespace #########################################################

# Import template code into the shell for scripting.
#namespace = Namespace(
#    commands = [
#        'from cp.data.api import *',
#        ]
#    )


##############################################################################
# The plugin definition.
##############################################################################

class DataPlugin(PluginDefinition):
    # The plugin's globally unique identifier.
    id = ID

    # General information about the plugin.
    name = 'Data Plugin'
    version = '0.0.1'
    provider_name = 'Enthought Inc'
    provider_url = 'www.enthought.com'
    autostart = True

    # The Id's of the plugins that this plugin requires.
    requires = [
        ]

    # The extension points offered by this plugin.
    extension_points = [
        DataActionSet,
        ]

    # The contributions that this plugin makes to extension points offered by
    # either itself or other plugins.
    extensions = [
        model_service,
        # namespace,
        resource_types,
        ui_service,
        data_action_set,
        ]


#### EOF #####################################################################