def create_first_vistrail(self):
        """ create_first_vistrail() -> None

        """
        # FIXME: when interactive and non-interactive modes are separated,
        # this autosave code can move to the viewManager
        if not self.dbDefault and untitled_locator().has_temporaries():
            if not FileLocator().prompt_autosave(self):
                untitled_locator().clean_temporaries()

        if self.viewManager.newVistrail(True, False):
            self.viewModeChanged(1)
        self.viewManager.set_first_view(self.viewManager.currentView())
        
        # Pre-compute default values for existing nodes in a new scene
        controller = self.viewManager.currentWidget().controller
        controller.store_preset_attributes()
        controller.change_selected_version(0)
        self.connect(controller,
                     QtCore.SIGNAL('versionWasChanged'),
                     self.versionSelectionChange)

        self.updateAddonToolBar(self.viewManager.currentWidget())
        
        if CaptureAPI.isReadOnly():
            self.viewManager.currentWidget().hide()
            self.addonToolBar.setEnabled(False)
            self.interactionToolBar.setEnabled(False)
            self.editMenu.setEnabled(False)
            self.toolsMenu.setEnabled(False)
            self.viewMenu.setEnabled(False)
            self.open_vistrail_default()
def QVM_newVistrail(self, recover_files=True, callBeforeNewVistrail=True):
    """ newVistrail() -> (None or QVistrailView)
    Create a new vistrail with no name. If user cancels process,
    returns None.

    FIXME: We should do the interactive parts separately.
    
    """
    if self.single_document_mode and self.currentView():
        if not self.closeVistrail():
            return None

    # we're actually going to do it
    if callBeforeNewVistrail:
        import CaptureAPI
        CaptureAPI.beforeNewVistrail()

    if recover_files and untitled_locator().has_temporaries():
        import copy
        locator = copy.copy(untitled_locator())
        vistrail = locator.load()
    else:
        locator = None
        vistrail = Vistrail()
    return self.set_vistrail_view(vistrail, locator)
 def create_first_vistrail(self):
     """ create_first_vistrail() -> None
     Create untitled vistrail in interactive mode
     """
     # FIXME: when interactive and non-interactive modes are separated,
     # this autosave code can move to the viewManager
     if not self.dbDefault and untitled_locator().has_temporaries():
         if not FileLocator().prompt_autosave(self):
             untitled_locator().clean_temporaries()
     if self.viewManager.newVistrail(True):
         self.emit(QtCore.SIGNAL("changeViewState(int)"), 0)
         self.viewModeChanged(0)
     self.viewManager.set_first_view(self.viewManager.currentView())
    def save_vistrail(self, locator_class,
                      vistrailView=None,
                      force_choose_locator=False):
        """

        force_choose_locator=True triggers 'save as' behavior
        """
        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
            try:
                vistrailView.controller.write_vistrail(locator)
            except Exception, e:
                QtGui.QMessageBox.critical(None,
                                           'Vistrails',
                                           str(e))
                return False
            return True
Beispiel #5
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))
    def newVistrail(self, recover_files=True):
        """ newVistrail() -> (None or QVistrailView)
        Create a new vistrail with no name. If user cancels process,
        returns None.

        FIXME: We should do the interactive parts separately.
        
        """
        if self.single_document_mode and self.currentView():
            if not self.closeVistrail():
                return None
        if recover_files and untitled_locator().has_temporaries():
            locator = copy.copy(untitled_locator())
            vistrail = locator.load()
        else:
            locator = None
            vistrail = Vistrail()
        return self.set_vistrail_view(vistrail, locator)
Beispiel #7
0
    def newVistrail(self, recover_files=True):
        """ newVistrail() -> (None or QVistrailView)
        Create a new vistrail with no name. If user cancels process,
        returns None.

        FIXME: We should do the interactive parts separately.
        
        """
        if self.single_document_mode and self.currentView():
            if not self.closeVistrail():
                return None
        if recover_files and untitled_locator().has_temporaries():
            locator = copy.copy(untitled_locator())
        else:
            locator = None
        try:
            (vistrail, abstraction_files, thumbnail_files, _) = load_vistrail(locator)
        except ModuleRegistryException, e:
            debug.critical("Module registry error for %s" %
                           str(e.__class__.__name__), str(e))
 def new_vistrail(self, recover_files=True):
     # if self.single_document_mode and self.currentView():
     #     if not self.closeVistrail():
     #         return None
     if recover_files and untitled_locator().has_temporaries():
         locator = copy.copy(untitled_locator())
     else:
         locator = None
     # try:
     #     (vistrail, abstraction_files, thumbnail_files) = load_vistrail(locator)
     # except ModuleRegistryException, e:
     #     debug.critical("Module registry error for %s" %
     #                    str(e.__class__.__name__), str(e))
     # except Exception, e:
     #     debug.critical('An error has occurred', str(e))
     #     raise
     # return self.set_vistrail_view(vistrail, locator, abstraction_files,
     #                               thumbnail_files)
     
     self.open_vistrail(locator)
Beispiel #9
0
    def new_vistrail(self, recover_files=True):
        # if self.single_document_mode and self.currentView():
        #     if not self.closeVistrail():
        #         return None
        if recover_files and untitled_locator().has_temporaries():
            locator = copy.copy(untitled_locator())
        else:
            locator = None
        # try:
        #     (vistrail, abstraction_files, thumbnail_files) = load_vistrail(locator)
        # except ModuleRegistryException, e:
        #     debug.critical("Module registry error for %s" %
        #                    str(e.__class__.__name__), str(e))
        # except Exception, e:
        #     debug.critical('An error has occurred', str(e))
        #     raise
        # return self.set_vistrail_view(vistrail, locator, abstraction_files,
        #                               thumbnail_files)

        self.open_vistrail(locator)
    def save_log(self, locator_class, force_choose_locator=True):
        vistrailView = self.currentWidget()

        if vistrailView:
            vistrailView.flush_changes()
            gui_get = locator_class.save_from_gui
            if force_choose_locator:
                locator = gui_get(self, Log.vtType,
                                  vistrailView.controller.locator)
            else:
                locator = (vistrailView.controller.locator or
                           gui_get(self, Log.vtType,
                                   vistrailView.controller.locator))
            if locator == untitled_locator():
                locator = gui_get(self, Log.vtType,
                                  vistrailView.controller.locator)
            if not locator:
                return False
            vistrailView.controller.write_log(locator)
            return True
Beispiel #11
0
    def save_registry(self, locator_class, force_choose_locator=True):
        vistrailView = self.currentWidget()

        if vistrailView:
            vistrailView.flush_changes()
            gui_get = locator_class.save_from_gui
            if force_choose_locator:
                locator = gui_get(self, ModuleRegistry.vtType,
                                  vistrailView.controller.locator)
            else:
                locator = (vistrailView.controller.locator or
                           gui_get(self, ModuleRegistry.vtType,
                                   vistrailView.controller.locator))
            if locator == untitled_locator():
                locator = gui_get(self, ModuleRegistry.vtType,
                                  vistrailView.controller.locator)
            if not locator:
                return False
            vistrailView.controller.write_registry(locator)
            return True
        return False
Beispiel #12
0
    def export_stable(self, locator_class=XMLFileLocator,
                      force_choose_locator=True):
        vistrailView = self.currentWidget()
        vistrailView.flush_changes()

        if vistrailView:
            vistrailView.flush_changes()
            gui_get = locator_class.save_from_gui
            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 not locator:
                return False
            vistrailView.controller.write_vistrail(locator, '1.0.1')
            return True
        return False