Esempio n. 1
0
    def getResourceFolderParts(cls, target):
        if not inspect.isclass(target):
            target = target.__class__

        out = []
        prefix = ClassUtils.getAttrFromClass(target, cls.RESOURCE_FOLDER_PREFIX, None)
        if prefix:
            out.extend(prefix.split('/') if isinstance(prefix, basestring) else prefix)
        resourceName = ClassUtils.getAttrFromClass(target, cls.RESOURCE_FOLDER_NAME, None)
        out.append(resourceName if resourceName else target.__name__)
        return out
Esempio n. 2
0
    def getResourceFolderParts(cls, target):
        if not inspect.isclass(target):
            target = target.__class__

        out = []

        prefix = ClassUtils.getAttrFromClass(target, cls.RESOURCE_FOLDER_PREFIX, None)
        if prefix:
            out.extend(prefix.split('/') if StringUtils.isStringType(prefix) else prefix)

        resourceName = ClassUtils.getAttrFromClass(target, cls.RESOURCE_FOLDER_NAME, None)
        widget = ClassUtils.getAttrFromClass(target, cls.RESOURCE_WIDGET_FILE, None)
        if widget:
            widget = widget.split('/') if StringUtils.isStringType(widget) else widget
            out.extend(widget[:-1])

        if resourceName or not widget:
            out.append(resourceName if resourceName else target.__name__)
        return out
Esempio n. 3
0
    def _activateWidgetDisplayImpl(self, **kwargs):
        d = kwargs.get('definition', None)
        self._definition = d

        self._header.setLabel(d['name'])
        if d['id'] not in self._widgetClasses:
            widgetClass = ClassUtils.dynamicImport(d['module'])
            self.addWidgetChild(d['id'], widgetClass, True)
        self.setActiveWidget(d['id'])

        self._helpBox.setVisible(self._helpComm.loadContent(self._currentWidget))
Esempio n. 4
0
    def __init__(self, request, rootPackage =None, **kwargs):
        """ Creates a new ApiRouterView instance.
            @param rootPackage - The root package in which the router will import views. By default
                the module will look in same package as the router class. Packages can be absolute,
                or relative to the current package. """

        super(ApiRouterView, self).__init__(request, **kwargs)

        # Determine root package
        self._root = rootPackage if rootPackage else ClassUtils.getModulePackage(self.__class__, 1)

        zargs = self.getArg('zargs', None)
        if zargs:
            try:
                self._zargs = JSON.fromString(zargs)
            except Exception as err:
                self._zargs = None
        else:
            self._zargs = None
        self._signature = StringUtils.toUnicode(self.getArg('sig', ''))

        self._incomingTimestamp = None
        self._outgoingTimestamp = None
Esempio n. 5
0
    def _activateWidgetDisplayImpl(self, **kwargs):
        super(CadenceToolViewerWidget, self)._activateWidgetDisplayImpl(**kwargs)

        d = kwargs.get('definition', None)
        self._definition = d

        self._header.setLabel(d['name'])
        if d['id'] not in self._widgetClasses:
            widgetClass = None
            try:
                widgetClass = ClassUtils.dynamicImport(d['module'])
                self.addWidgetChild(d['id'], widgetClass)
            except Exception as err:
                self.mainWindow.log.writeError([
                    'Activating Tool',
                    'ID: ' + str(d['id']),
                    'MODULE: ' + str(d['module']),
                    'CLASS: ' + str(widgetClass) ], err)
                self.mainWindow.hideLoading(self)
                self.refreshGui()
                return

        self.setActiveWidget(d['id'])

        if not self._currentWidget:
            self.mainWindow.hideLoading(self)
            self.refreshGui()
            return

        hasHelp = self._helpComm.loadContent(self._currentWidget)
        self._helpBox.setVisible(False)
        self._hasHelp = hasHelp
        self._header.toggleHelpButton(self._hasHelp)

        self.mainWindow.hideLoading(self)
        self.refreshGui()