def save_as(self, save_bundle, version=None):
     save_bundle = _ZIPFileLocator.save(self, save_bundle, True, version)
     for obj in save_bundle.get_db_objs():
         klass = self.get_convert_klass(obj.vtType)
         klass.convert(obj)
         obj.locator = self
     # Need to update thumbnail cache since files have moved
     ThumbnailCache.getInstance().add_entries_from_files(save_bundle.thumbnails)
     return save_bundle
Esempio n. 2
0
 def save_as(self, save_bundle, version=None):
     save_bundle = _ZIPFileLocator.save(self, save_bundle, True, version)
     for obj in save_bundle.get_db_objs():
         klass = self.get_convert_klass(obj.vtType)
         klass.convert(obj)
         obj.locator = self
     # Need to update thumbnail cache since files have moved
     ThumbnailCache.getInstance().add_entries_from_files(
         save_bundle.thumbnails)
     return save_bundle
    def setupVersion(self, node, action, tag, description):
        """ setupPort(node: DotNode,
                      action: DBAction,
                      tag: str,
                      description: str) -> None
        Update the version dimensions and id
        
        """
        # Lauro:
        # what was this hacking??? the coordinates inside
        # the input "node" should come to this point ready. This is
        # not the point to do layout calculations (e.g. -node.p.y/2)

        # Carlos:
        # This is not layout as much as dealing with the way Qt
        # specifies rectangles. Besides, moving this back here reduces
        # code duplication, and allows customized behavior for
        # subclasses.

        rect = QtCore.QRectF(node.p.x-node.width/2.0,
                             node.p.y-node.height/2.0,
                             node.width,
                             node.height)
        validLabel = True
        if tag is None:
            label = ''
            validLabel=False
        else:
            label = tag

        self.id = node.id
        self.label = label
        if description is None:
            self.descriptionLabel = ''
        else:
            self.descriptionLabel = description
        if validLabel:
            textToDraw=self.label
        else:
            textToDraw=self.descriptionLabel
        
        if (ThumbnailCache.getInstance().conf.mouseHover and
            action and action.thumbnail is not None):
            fname = ThumbnailCache.getInstance().get_abs_name_entry(action.thumbnail)
            self.setToolTip('<img src="%s" height="128" border="1"/>'%fname)
        else:
            self.setToolTip('')    
        self.text.changed(node.p.x, node.p.y, textToDraw, validLabel)
        self.setRect(rect)
Esempio n. 4
0
    def setupVersion(self, node, action, tag, description):
        """ setupPort(node: DotNode,
                      action: DBAction,
                      tag: str,
                      description: str) -> None
        Update the version dimensions and id
        
        """
        # Lauro:
        # what was this hacking??? the coordinates inside
        # the input "node" should come to this point ready. This is
        # not the point to do layout calculations (e.g. -node.p.y/2)

        # Carlos:
        # This is not layout as much as dealing with the way Qt
        # specifies rectangles. Besides, moving this back here reduces
        # code duplication, and allows customized behavior for
        # subclasses.

        rect = QtCore.QRectF(node.p.x - node.width / 2.0,
                             node.p.y - node.height / 2.0, node.width,
                             node.height)
        validLabel = True
        if tag is None:
            label = ''
            validLabel = False
        else:
            label = tag

        self.id = node.id
        self.label = label
        if description is None:
            self.descriptionLabel = ''
        else:
            self.descriptionLabel = description
        if validLabel:
            textToDraw = self.label
        else:
            textToDraw = self.descriptionLabel

        if (ThumbnailCache.getInstance().conf.mouseHover and action
                and action.thumbnail is not None):
            fname = ThumbnailCache.getInstance().get_abs_name_entry(
                action.thumbnail)
            self.setToolTip('<img src="%s" height="128" border="1"/>' % fname)
        else:
            self.setToolTip('')
        self.text.changed(node.p.x, node.p.y, textToDraw, validLabel)
        self.setRect(rect)
 def add_mashup_entities_from_mashuptrail(self, mashuptrail):
     added_entry_keys = set()
     inv_tag_map = {}
     tagMap = mashuptrail.getTagMap()
     tags = tagMap.keys()
     if len(tags) > 0:
         tags.sort()
         for tag in tags:
             version_id = tagMap[tag]
             inv_tag_map[version_id] = tag
             action = mashuptrail.actionMap[version_id]
             mashup = mashuptrail.getMashup(version_id)
             mashup.name = tag
             #make sure we identify a mashup by its version
             mashup.id = action.id
             entity_key = (mashuptrail.id,version_id)
             self.mshp_entity_map[entity_key] = \
                self.create_mashup_entity(mashuptrail.id, mashup, action)
             added_entry_keys.add(entity_key)
             # get thumbnail for the workflow it points
             thumb_version = mashuptrail.vtVersion
             thumbnail = self.vistrail.get_thumbnail(thumb_version)
             if thumbnail is not None:
                 cache = ThumbnailCache.getInstance()
                 path = cache.get_abs_name_entry(thumbnail)
                 if path:
                     entity = ThumbnailEntity(path)
                     mshp_entity = self.mshp_entity_map[entity_key]
                     mshp_entity.children.append(entity)
                     entity.parent = mshp_entity
     return inv_tag_map
Esempio n. 6
0
 def add_mashup_entities_from_mashuptrail(self, mashuptrail):
     added_entry_keys = set()
     inv_tag_map = {}
     tagMap = mashuptrail.getTagMap()
     tags = tagMap.keys()
     if len(tags) > 0:
         tags.sort()
         for tag in tags:
             version_id = tagMap[tag]
             inv_tag_map[version_id] = tag
             action = mashuptrail.actionMap[version_id]
             mashup = mashuptrail.getMashup(version_id)
             mashup.name = tag
             #make sure we identify a mashup by its version
             mashup.id = action.id
             entity_key = (mashuptrail.id, version_id)
             self.mshp_entity_map[entity_key] = \
                self.create_mashup_entity(mashuptrail.id, mashup, action)
             added_entry_keys.add(entity_key)
             # get thumbnail for the workflow it points
             thumb_version = mashuptrail.vtVersion
             thumbnail = self.vistrail.get_thumbnail(thumb_version)
             if thumbnail is not None:
                 cache = ThumbnailCache.getInstance()
                 path = cache.get_abs_name_entry(thumbnail)
                 if path:
                     entity = ThumbnailEntity(path)
                     mshp_entity = self.mshp_entity_map[entity_key]
                     mshp_entity.children.append(entity)
                     entity.parent = mshp_entity
     return inv_tag_map
Esempio n. 7
0
 def add_mashup_entity(self, mashuptrail, version_id, tag=None):
     if not hasattr(self.vistrail, 'mashups'):
         return
     if mashuptrail not in self.vistrail.mashups:
         return
     action = mashuptrail.actionMap[version_id]
     mashup = mashuptrail.getMashup(version_id)
     if tag:
         mashup.name = tag
     mashup.id = action.id
     entity_key = (mashuptrail.id, version_id)
     self.mshp_entity_map[entity_key] = \
                self.create_mashup_entity(mashuptrail.id, mashup, action)
     # get thumbnail for the workflow it points
     thumb_version = mashuptrail.vtVersion
     thumbnail = self.vistrail.get_thumbnail(thumb_version)
     if thumbnail is not None:
         cache = ThumbnailCache.getInstance()
         path = cache.get_abs_name_entry(thumbnail)
         if path:
             entity = ThumbnailEntity(path)
             mshp_entity = self.mshp_entity_map[entity_key]
             mshp_entity.children.append(entity)
             entity.parent = mshp_entity
     return self.mshp_entity_map[entity_key]
Esempio n. 8
0
 def update_icon(self):
     """ update_icon() -> None
     Compose workflow icons into a spreadsheet icon
     """
     size = 24
     pic = QtGui.QPixmap(size, size)
     cols, rows = self.parent().sheetSize(self.sheetName)
     w, h = size/cols, size/rows
     painter = QtGui.QPainter(pic)
     painter.fillRect(0, 0, size, size, QtCore.Qt.lightGray)
     vistrail = self.parent().view.controller.vistrail
     for pos, item in self.pos_to_item.iteritems(): 
         if vistrail.has_thumbnail(item.workflowVersion):
             x, y = pos
             tname = vistrail.get_thumbnail(item.workflowVersion)
             cache = ThumbnailCache.getInstance()
             path = cache.get_abs_name_entry(tname)
             if path:
                 pixmap = QtGui.QPixmap(path)
                 painter.fillRect(h*y, w*x, h, w, QtCore.Qt.white)
                 painter.drawPixmap(h*y, w*x, h, w, pixmap.scaled(h, w, transformMode=QtCore.Qt.SmoothTransformation))
     # draw spreadsheet grid
     painter.setPen(QtCore.Qt.black)
     for x in xrange(rows+1):
         painter.drawLine(x*h-0.01, 0, x*h-0.01, size)
     for y in xrange(cols+1):
         painter.drawLine(0, y*w-0.01, size, y*w-0.01)
     painter.end()
     self.setIcon(0, QtGui.QIcon(pic))
Esempio n. 9
0
 def save_as(self, save_bundle, version=None):
     save_bundle = _DBLocator.save(self, save_bundle, True, version)
     for obj in save_bundle.get_db_objs():
         klass = self.get_convert_klass(obj.vtType)
         klass.convert(obj)
         obj.locator = self
     # Need to copy images into thumbnail cache directory so references
     # won't become invalid if they are in a temp dir that gets destroyed
     # when the previous locator is closed
     import shutil
     thumb_cache = ThumbnailCache.getInstance()
     thumb_cache_dir = thumb_cache.get_directory()
     new_thumbnails = []
     for thumbnail in save_bundle.thumbnails:
         if os.path.dirname(thumbnail) == thumb_cache_dir:
             new_thumbnails.append(thumbnail)
         else:
             cachedir_thumbnail = os.path.join(thumb_cache_dir,
                                               os.path.basename(thumbnail))
             try:
                 shutil.copyfile(thumbnail, cachedir_thumbnail)
                 new_thumbnails.append(cachedir_thumbnail)
             except Exception, e:
                 debug.critical('copying %s -> %s failed: %s' % \
                                    (thumbnail, cachedir_thumbnail, str(e)))
 def add_mashup_entity(self, mashuptrail, version_id, tag=None):
     if not hasattr(self.vistrail, 'mashups'):
         return
     if mashuptrail not in self.vistrail.mashups:
         return
     action = mashuptrail.actionMap[version_id]
     mashup = mashuptrail.getMashup(version_id)
     if tag:
         mashup.name = tag
     mashup.id = action.id
     entity_key = (mashuptrail.id,version_id)
     self.mshp_entity_map[entity_key] = \
                self.create_mashup_entity(mashuptrail.id, mashup, action)
     # get thumbnail for the workflow it points
     thumb_version = mashuptrail.vtVersion
     thumbnail = self.vistrail.get_thumbnail(thumb_version)
     if thumbnail is not None:
         cache = ThumbnailCache.getInstance()
         path = cache.get_abs_name_entry(thumbnail)
         if path:
             entity = ThumbnailEntity(path)
             mshp_entity = self.mshp_entity_map[entity_key]
             mshp_entity.children.append(entity)
             entity.parent = mshp_entity
     return self.mshp_entity_map[entity_key]
Esempio n. 11
0
    def add_workflow_entity(self, version_id):
        if version_id not in self.vistrail.actionMap:
            return
        action = self.vistrail.actionMap[version_id]
        tag = None
        if self.vistrail.has_tag(version_id):
            tag = self.vistrail.get_tag(version_id)
        try:
            workflow = self.vistrail.getPipeline(version_id)
        except:
            import traceback
            debug.critical(
                "Failed to construct pipeline '%s'" %
                (tag if tag else version_id), traceback.format_exc())
            workflow = self.vistrail.getPipeline(0)
        if tag:
            workflow.name = tag
        # if workflow already exists, we want to update it...
        # spin through self.children and look for matching
        # workflow entity?
        # self.children.append(WorkflowEntity(workflow))
        self.wf_entity_map[version_id] = \
            self.create_workflow_entity(workflow, action)

        # get thumbnail
        thumbnail = self.vistrail.get_thumbnail(version_id)
        if thumbnail is not None:
            cache = ThumbnailCache.getInstance()
            path = cache.get_abs_name_entry(thumbnail)
            if path:
                entity = ThumbnailEntity(path)
                self.wf_entity_map[action.id].children.append(entity)
                entity.parent = self.wf_entity_map[action.id]
        return self.wf_entity_map[version_id]
Esempio n. 12
0
 def update_icon(self):
     """ update_icon() -> None
     Compose workflow icons into a spreadsheet icon
     """
     size = 24
     pic = QtGui.QPixmap(size, size)
     cols, rows = self.parent().sheetSize(self.sheetName)
     w, h = size / cols, size / rows
     painter = QtGui.QPainter(pic)
     painter.fillRect(0, 0, size, size, QtCore.Qt.lightGray)
     vistrail = self.parent().view.controller.vistrail
     for pos, item in self.pos_to_item.iteritems():
         if vistrail.has_thumbnail(item.workflowVersion):
             x, y = pos
             tname = vistrail.get_thumbnail(item.workflowVersion)
             cache = ThumbnailCache.getInstance()
             path = cache.get_abs_name_entry(tname)
             if path:
                 pixmap = QtGui.QPixmap(path)
                 painter.fillRect(h * y, w * x, h, w, QtCore.Qt.white)
                 painter.drawPixmap(
                     h * y, w * x, h, w,
                     pixmap.scaled(
                         h, w,
                         transformMode=QtCore.Qt.SmoothTransformation))
     # draw spreadsheet grid
     painter.setPen(QtCore.Qt.black)
     for x in xrange(rows + 1):
         painter.drawLine(x * h - 0.01, 0, x * h - 0.01, size)
     for y in xrange(cols + 1):
         painter.drawLine(0, y * w - 0.01, size, y * w - 0.01)
     painter.end()
     self.setIcon(0, QtGui.QIcon(pic))
    def add_workflow_entity(self, version_id):
        if version_id not in self.vistrail.actionMap:
            return
        action = self.vistrail.actionMap[version_id]
        tag = None
        if self.vistrail.has_tag(version_id):
            tag = self.vistrail.get_tag(version_id)
        try:
            workflow = self.vistrail.getPipeline(version_id)
        except:
            import traceback
            debug.critical("Failed to construct pipeline '%s'" % 
                               (tag if tag else version_id),
                           traceback.format_exc())
            workflow = self.vistrail.getPipeline(0)
        if tag:
            workflow.name = tag
        # if workflow already exists, we want to update it...
        # spin through self.children and look for matching
        # workflow entity?
        # self.children.append(WorkflowEntity(workflow))
        self.wf_entity_map[version_id] = \
            self.create_workflow_entity(workflow, action)

        # get thumbnail
        thumbnail = self.vistrail.get_thumbnail(version_id)
        if thumbnail is not None:
            cache = ThumbnailCache.getInstance()
            path = cache.get_abs_name_entry(thumbnail)
            if path:
                entity = ThumbnailEntity(path)
                self.wf_entity_map[action.id].children.append(entity)
                entity.parent = self.wf_entity_map[action.id]
        return self.wf_entity_map[version_id]
Esempio n. 14
0
    def save_vistrail(self, locator_class,
                      vistrailView=None,
                      force_choose_locator=False):
        """

        force_choose_locator=True triggers 'save as' behavior
        """
        global bobo

        if not vistrailView:
            vistrailView = self.currentWidget()
        vistrailView.flush_changes()
        if vistrailView:
            gui_get = locator_class.save_from_gui
            # get a locator to write to
            if force_choose_locator:
                locator = gui_get(self, Vistrail.vtType,
                                  vistrailView.controller.locator)
            else:
                locator = (vistrailView.controller.locator or
                           gui_get(self, Vistrail.vtType,
                                   vistrailView.controller.locator))
            if locator == untitled_locator():
                locator = gui_get(self, Vistrail.vtType,
                                  vistrailView.controller.locator)
            # if couldn't get one, ignore the request
            if not locator:
                return False
            # update collection
            try:
                vistrailView.controller.write_vistrail(locator)
            except Exception, e:
                debug.critical('An error has occurred', str(e))
                raise
                return False
            try:
                thumb_cache = ThumbnailCache.getInstance()
                vistrailView.controller.vistrail.thumbnails = \
                    vistrailView.controller.find_thumbnails(
                        tags_only=thumb_cache.conf.tagsOnly)
                vistrailView.controller.vistrail.abstractions = \
                    vistrailView.controller.find_abstractions(
                        vistrailView.controller.vistrail, True)

                collection = Collection.getInstance()
                url = locator.to_url()
                # create index if not exist
                entity = collection.fromUrl(url)
                if entity:
                    # find parent vistrail
                    while entity.parent:
                        entity = entity.parent 
                else:
                    entity = collection.updateVistrail(url, vistrailView.controller.vistrail)
                # add to relevant workspace categories
                collection.add_to_workspace(entity)
                collection.commit()
            except Exception, e:
                debug.critical('Failed to index vistrail', str(e))
Esempio n. 15
0
    def update_title(self):
        """ update_title() -> None
        Update title using version, tag name, position and span
        """
        project = self.parent()
        while type(project) != QProjectItem:
            project = project.parent()
            vistrail = project.view.controller.vistrail
        tag_map = vistrail.get_tagMap()
        action_map = vistrail.actionMap
        count = 0
        version = self.workflowVersion

        while True:
            if version in tag_map or version <= 0:
                if version in tag_map:
                    name = tag_map[version]
                else:
                    name = "untitled"
                count_str = ""
                if count > 0:
                    count_str = "*"
                    name = name + count_str
                break
            version = action_map[version].parent
            count += 1


#        name = project.view.controller.get_pipeline_name(self.workflowVersion)[10:]
        if self.workflowPos is not None:
            name = name + ' @ %s%s' % (chr(ord('A') + self.workflowPos[1]),
                                       self.workflowPos[0] + 1)
        if self.workflowSpan is not None:
            name = name + ' to %s%s' % (
                chr(ord('A') + self.workflowPos[1] + self.workflowSpan[1] - 1),
                self.workflowPos[0] + self.workflowSpan[0])
        self.setText(0, name)

        version = self.workflowVersion
        if vistrail.has_thumbnail(version):
            tname = vistrail.get_thumbnail(version)
            cache = ThumbnailCache.getInstance()
            path = cache.get_abs_name_entry(tname)
            if path:
                pixmap = QtGui.QPixmap(path)
                self.setIcon(
                    0,
                    QtGui.QIcon(
                        pixmap.scaled(
                            24,
                            24,
                            transformMode=QtCore.Qt.SmoothTransformation)))
                tooltip = """<html>%(name)s<br/><img border=0 src='%(path)s'/></html>
                        """ % {
                    'name': name,
                    'path': path
                }
                self.setToolTip(0, tooltip)
 def load(self, klass=None):
     from core.vistrail.vistrail import Vistrail
     if klass is None:
         klass = Vistrail
     save_bundle = _DBLocator.load(self, klass.vtType, ThumbnailCache.getInstance().get_directory())
     for obj in save_bundle.get_db_objs():
         klass = self.get_convert_klass(obj.vtType)
         klass.convert(obj)
         obj.locator = self
     return save_bundle
Esempio n. 17
0
    def __init__(self, parent, persistent_config, temp_config):
        """
        QThumbnailConfiguration(parent: QWidget, 
        configuration_object: ConfigurationObject) -> None

        """
        QtGui.QWidget.__init__(self, parent)
        self._configuration = None
        self._temp_configuration = None
        self._cache = ThumbnailCache.getInstance()
        self.create_widgets()
        self.update_state(persistent_config, temp_config)
        self.connect_signals()
    def __init__(self, parent, persistent_config, temp_config):
        """
        QThumbnailConfiguration(parent: QWidget, 
        configuration_object: ConfigurationObject) -> None

        """
        QtGui.QWidget.__init__(self, parent)
        self._configuration = None
        self._temp_configuration = None
        self._cache = ThumbnailCache.getInstance()
        self.create_widgets()
        self.update_state(persistent_config, temp_config)
        self.connect_signals()
Esempio n. 19
0
    def update_title(self):
        """ update_title() -> None
        Update title using version, tag name, position and span
        """
        project = self.parent()
        while type(project) != QProjectItem:
            project = project.parent()
            vistrail = project.view.controller.vistrail
        tag_map = vistrail.get_tagMap()
        action_map = vistrail.actionMap
        count = 0
        version = self.workflowVersion

        while True:
            if version in tag_map or version <= 0:
                if version in tag_map:
                    name = tag_map[version]
                else:
                    name = "untitled"
                count_str = ""
                if count > 0:
                    count_str = "*"
                    name = name + count_str
                break
            version = action_map[version].parent
            count += 1
        
#        name = project.view.controller.get_pipeline_name(self.workflowVersion)[10:]
        if self.workflowPos is not None:
            name = name + ' @ %s%s' % (chr(ord('A') + self.workflowPos[1]),
                                        self.workflowPos[0]+1)
        if self.workflowSpan is not None:
            name = name + ' to %s%s' % (chr(ord('A') + self.workflowPos[1] +
                                                   self.workflowSpan[1]-1),
                                 self.workflowPos[0] + self.workflowSpan[0])
        self.setText(0, name)

        version = self.workflowVersion
        if vistrail.has_thumbnail(version):
            tname = vistrail.get_thumbnail(version)
            cache = ThumbnailCache.getInstance()
            path = cache.get_abs_name_entry(tname)
            if path:
                pixmap = QtGui.QPixmap(path)
                self.setIcon(0, QtGui.QIcon(pixmap.scaled(24, 24, transformMode=QtCore.Qt.SmoothTransformation)))
                tooltip = """<html>%(name)s<br/><img border=0 src='%(path)s'/></html>
                        """ % {'name':name, 'path':path}
                self.setToolTip(0, tooltip)
 def update(self, thumbnail):
     self.thumbnail = thumbnail
     if self.thumbnail is not None:
         # store in cache if not already there
         cache = ThumbnailCache.getInstance()
         cache._copy_thumbnails([thumbnail])
         self.name = os.path.basename(thumbnail)
         statinfo = os.stat(self.thumbnail)
         self.user = statinfo[stat.ST_UID]
         self.size = statinfo[stat.ST_SIZE]
         time = datetime(*localtime(statinfo[stat.ST_MTIME])[:6]).strftime('%d %b %Y %H:%M:%S')
         self.mod_time = ''
         self.create_time = time
         self.description = ""
         self.url = 'test'
         self.was_updated = True
Esempio n. 21
0
 def update(self, thumbnail):
     self.thumbnail = thumbnail
     if self.thumbnail is not None:
         # store in cache if not already there
         cache = ThumbnailCache.getInstance()
         cache._copy_thumbnails([thumbnail])
         self.name = os.path.basename(thumbnail)
         statinfo = os.stat(self.thumbnail)
         self.user = statinfo[stat.ST_UID]
         self.size = statinfo[stat.ST_SIZE]
         time = datetime(*localtime(statinfo[stat.ST_MTIME])[:6]).strftime(
             '%d %b %Y %H:%M:%S')
         self.mod_time = ''
         self.create_time = time
         self.description = ""
         self.url = 'test'
         self.was_updated = True
Esempio n. 22
0
 def load(self, klass=None):
     from core.vistrail.vistrail import Vistrail
     if klass is None:
         klass = Vistrail
     save_bundle = _DBLocator.load(
         self, klass.vtType,
         ThumbnailCache.getInstance().get_directory())
     if klass.vtType == DBWorkflow.vtType:
         wf = save_bundle
         klass = self.get_convert_klass(wf.vtType)
         klass.convert(wf)
         wf.locator = self
         return wf
     for obj in save_bundle.get_db_objs():
         klass = self.get_convert_klass(obj.vtType)
         klass.convert(obj)
         obj.locator = self
     return save_bundle
Esempio n. 23
0
    def updateVersion(self, versionNumber):
        """ updateVersion(versionNumber: int) -> None

        """
        if self.controller:
            vistrail = self.controller.vistrail
            if versionNumber in vistrail.actionMap.keys():
                action = vistrail.actionMap[versionNumber]
                if action and vistrail.has_thumbnail(action.id):
                    cache = ThumbnailCache.getInstance()
                    fname = cache.get_abs_name_entry(
                        vistrail.get_thumbnail(action.id))
                    if fname is not None:
                        pixmap = QtGui.QPixmap(fname)
                        self.thumbs.setPixmap(pixmap)
                        self.thumbs.adjustSize()
                    self.thumbs.setFrameShape(QtGui.QFrame.StyledPanel)
                    return

        self.thumbs.setPixmap(QtGui.QPixmap())
        self.thumbs.setFrameShape(QtGui.QFrame.NoFrame)
    def updateVersion(self, versionNumber):
        """ updateVersion(versionNumber: int) -> None

        """
        if self.controller:
            vistrail = self.controller.vistrail
            if versionNumber in vistrail.actionMap.keys():
                action = vistrail.actionMap[versionNumber]
                if action and vistrail.has_thumbnail(action.id):
                    cache = ThumbnailCache.getInstance()
                    fname = cache.get_abs_name_entry(
                        vistrail.get_thumbnail(action.id))
                    if fname is not None:
                        pixmap = QtGui.QPixmap(fname)
                        self.thumbs.setPixmap(pixmap)
                        self.thumbs.adjustSize()
                    self.thumbs.setFrameShape(QtGui.QFrame.StyledPanel)
                    return
                
        self.thumbs.setPixmap(QtGui.QPixmap())
        self.thumbs.setFrameShape(QtGui.QFrame.NoFrame)
 def save_as(self, save_bundle, version=None):
     save_bundle = _DBLocator.save(self, save_bundle, True, version)
     for obj in save_bundle.get_db_objs():
         klass = self.get_convert_klass(obj.vtType)
         klass.convert(obj)
         obj.locator = self
     # Need to copy images into thumbnail cache directory so references
     # won't become invalid if they are in a temp dir that gets destroyed
     # when the previous locator is closed
     import shutil
     thumb_cache = ThumbnailCache.getInstance()
     thumb_cache_dir = thumb_cache.get_directory()
     new_thumbnails = []
     for thumbnail in save_bundle.thumbnails:
         if os.path.dirname(thumbnail) == thumb_cache_dir:
             new_thumbnails.append(thumbnail)
         else:
             cachedir_thumbnail = os.path.join(thumb_cache_dir, os.path.basename(thumbnail))
             try:
                 shutil.copyfile(thumbnail, cachedir_thumbnail)
                 new_thumbnails.append(cachedir_thumbnail)
             except Exception, e:
                 debug.critical('copying %s -> %s failed: %s' % \
                                    (thumbnail, cachedir_thumbnail, str(e)))