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 open_vistrail_without_prompt(self, locator, version=None,
                                  execute_workflow=False):
     """open_vistrail_without_prompt(locator_class, version: int or str,
                                     execute_workflow: bool) -> None
     Open vistrail depending on the locator class given.
     If a version is given, the workflow is shown on the Pipeline View.
     I execute_workflow is True the workflow will be executed.
     """
     if not locator.is_valid():
             ok = locator.update_from_gui()
     else:
         ok = True
     if ok:
         # TODO: Passing in False here breaks the without_prompt intention
         # of the code, but do we even need the distinction in the plug-in?
         view = self.viewManager.open_vistrail(locator, version, False)
         if view == None:
             return
         if CaptureAPI.isReadOnly():
             self.addonToolBar.setEnabled(True)
             self.interactionToolBar.setEnabled(True)
             self.editMenu.setEnabled(True)
             self.toolsMenu.setEnabled(True)
             self.viewMenu.setEnabled(True)
         else:
             self.saveFileAsAction.setEnabled(True)
         if version:
             self.emit(QtCore.SIGNAL("changeViewState(int)"), 0)
             self.viewModeChanged(0)
         else:
             self.emit(QtCore.SIGNAL("changeViewState(int)"), 1)
             self.viewModeChanged(1)
         if execute_workflow:
             self.execute_current_pipeline()
    def vistrailChanged(self):
        """ vistrailChanged() -> None
        An action was performed on the current vistrail

        """
        if not CaptureAPI.isReadOnly():
            self.saveFileAction.setEnabled(True)
            self.saveFileAsAction.setEnabled(True)
 def versionSelectionChange(self, versionId):
     """ versionSelectionChange(versionId: int) -> None
     Setup state of actions
     
     """
     self.undoAction.setEnabled(versionId>0)
     currentView = self.viewManager.currentWidget()
     if currentView:
         self.redoAction.setEnabled(currentView.can_redo())
     else:
         self.redoAction.setEnabled(False)
     if not CaptureAPI.isReadOnly():
         self.snapshotAction.setEnabled(versionId>0)
    def currentVistrailChanged(self, vistrailView):
        """ currentVistrailChanged(vistrailView: QVistrailView) -> None
        Redisplay the new title of vistrail

        """
        self.execStateChange()
        if vistrailView:
            self.setWindowTitle(self.title + ' - ' +
                                vistrailView.windowTitle())
            if not CaptureAPI.isReadOnly():
                self.saveFileAction.setEnabled(True)
                self.saveFileAsAction.setEnabled(True)
        else:
            self.setWindowTitle(self.title)
            self.saveFileAction.setEnabled(False)
            self.saveFileAsAction.setEnabled(False)

        if vistrailView and vistrailView.viewAction:
            vistrailView.viewAction.setText(vistrailView.windowTitle())
            if not vistrailView.viewAction.isChecked():
                vistrailView.viewAction.setChecked(True)
def QVM_save_vistrail(self, locator_class,
                      vistrailView=None,
                      force_choose_locator=False):
    """
    
    force_choose_locator=True triggers 'save as' behavior
    """
    import CaptureAPI
    if CaptureAPI.isReadOnly():
        return False

    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
    def createActions(self):
        """ createActions() -> None
        Construct Plug-in specific actions

        """
        QBuilderWindow.createActions(self)

        # Modify Core Actions
        self.redoAction.setShortcuts(['Shift+Z','Ctrl+Y'])
        self.quitVistrailsAction = QtGui.QAction('Quit Plug-In', self)
        self.quitVistrailsAction.setShortcut('Ctrl+Q')
        self.quitVistrailsAction.setStatusTip('Exit Plug-In')
        self.editPreferencesAction.setStatusTip('Edit plug-in preferences')
        self.helpAction = QtGui.QAction(self.tr('About Provenance Explorer...'), self)

        # Create plugin specific actions
        self.keepViewAction = QtGui.QAction(CurrentTheme.VIEW_ON_ICON, 'Lock View', self)
        self.keepViewAction.setEnabled(True)
        self.keepViewAction.setCheckable(True)
        if int(CaptureAPI.getPreference('VisTrailsUseRecordedViews')):
            self.keepViewAction.setChecked(0)
            self.keepViewAction.setIcon(CurrentTheme.VIEW_OFF_ICON)
        else:
            self.keepViewAction.setChecked(1)
        self.keepViewAction.setStatusTip('Lock the current view settings while navigating versions')

        self.expandBranchAction = QtGui.QAction('Expand Branch', self)
        self.expandBranchAction.setEnabled(True)
        self.expandBranchAction.setStatusTip('Expand all versions in the tree below the current version')

        self.collapseBranchAction = QtGui.QAction('Collapse Branch', self)
        self.collapseBranchAction.setEnabled(True)
        self.collapseBranchAction.setStatusTip('Collapse all expanded versions in the tree below the current version')

        self.collapseAllAction = QtGui.QAction('Collapse All', self)
        self.collapseAllAction.setEnabled(True)
        self.collapseAllAction.setStatusTip('Collapse all expanded branches of the tree')

        self.hideBranchAction = QtGui.QAction('Hide Branch', self)
        if core.system.systemType in ['Darwin']:
            self.hideBranchAction.setShortcut('Meta+H')
        else:
            self.hideBranchAction.setShortcut('Ctrl+H')
        self.hideBranchAction.setEnabled(True)
        self.hideBranchAction.setStatusTip('Hide all versions in the tree including and below the current version')

        self.showAllAction = QtGui.QAction('Show All', self)
        self.showAllAction.setEnabled(True)
        self.showAllAction.setStatusTip('Show all hidden versions')

        self.resetViewAction = QtGui.QAction('Frame All', self)
        if core.system.systemType in ['Darwin']:
            self.resetViewAction.setShortcut('Meta+A')
        else:
            self.resetViewAction.setShortcut('A')
        self.resetViewAction.setShortcutContext(QtCore.Qt.WidgetShortcut)
        self.resetViewAction.setStatusTip('Reset tree view to show all versions')

        self.focusViewAction = QtGui.QAction('Frame Selection', self)
        if core.system.systemType in ['Darwin']:
            self.focusViewAction.setShortcut('Meta+F')
        else:
            self.focusViewAction.setShortcut('F')
        self.focusViewAction.setShortcutContext(QtCore.Qt.WidgetShortcut)
        self.focusViewAction.setStatusTip('Reset tree view to show selected version')

        self.timeStatsAllAction = QtGui.QAction('Compute Statistics', self)
        self.timeStatsAllAction.setEnabled(True)
        self.timeStatsAllAction.setStatusTip('Show time statistics for entire version tree')
        
        self.timeStatsAction = QtGui.QAction('Compute Sequence Statistics...', self)
        self.timeStatsAction.setEnabled(True)
        self.timeStatsAction.setStatusTip('Show time statistics between two versions')

        self.snapshotAction = QtGui.QAction('Create Snapshot', self)
        self.snapshotAction.setEnabled(False)
        self.snapshotAction.setStatusTip('Create a new version with the contents of the current scene')

        self.visDiffAction = QtGui.QAction('Compute Visual Difference...', self)
        self.visDiffAction.setEnabled(True)
        self.visDiffAction.setStatusTip('Visually display differences between two versions')

        self.copyOperationAction = QtGui.QAction('Copy', self)
        self.copyOperationAction.setShortcut('Ctrl+C')
        self.copyOperationAction.setEnabled(True)
        self.copyOperationAction.setStatusTip('Copy the selected operation to the clipboard')

        self.copySequenceAction = QtGui.QAction('Copy Sequence...', self)
        self.copySequenceAction.setEnabled(True)
        self.copySequenceAction.setStatusTip('Copy a sequence of operations to the clipboard')

        self.pasteOperationAction = QtGui.QAction('Paste', self)
        self.pasteOperationAction.setShortcut('Ctrl+V')
        self.pasteOperationAction.setEnabled(False)
        self.pasteOperationAction.setStatusTip('Paste operations from the clipboard to selected version')

        # Reader
        if CaptureAPI.isReadOnly():
            self.newVistrailAction.setText('&New (Pro)')
            self.newVistrailAction.setEnabled(False)
            self.saveFileAction.setText('&Save (Pro)')
            self.saveFileAction.setEnabled(False)
            self.saveFileAsAction.setText('Save as... (Pro)')
            self.saveFileAsAction.setEnabled(False)
            self.timeStatsAllAction.setText('Compute Statistics... (Pro)')
            self.timeStatsAllAction.setEnabled(False)
            self.timeStatsAction.setText('Compute Sequence Statistics... (Pro)')
            self.timeStatsAction.setEnabled(False)
            self.snapshotAction.setText('Take Snapshot (Pro)')
            self.snapshotAction.setEnabled(False)
            self.copyOperationAction.setText('Copy (Pro)')
            self.copyOperationAction.setEnabled(False)
            self.copySequenceAction.setText('Copy Sequence... (Pro)')
            self.copySequenceAction.setEnabled(False)
            self.pasteOperationAction.setText('Paste (Pro)')
            self.pasteOperationAction.setEnabled(False)
            self.hideBranchAction.setText('Hide Branch (Pro)')
            self.hideBranchAction.setEnabled(False)
            self.showAllAction.setText('Show All (Pro)')
            self.showAllAction.setEnabled(False)
示例#8
0
    def __init__(self, parent=None):
        """ Construct a simple dialog layout """
        QtGui.QDialog.__init__(self, parent)
        self.setWindowTitle("Provenance Explorer Preferences")
        layout = QtGui.QVBoxLayout(self)
        self.setLayout(layout)

        # vistrails window always on top
        self.alwaysOnTopCB = QtGui.QCheckBox("Plug-in window always on top")
        state = CaptureAPI.getPreference("VisTrailsAlwaysOnTop")
        if state is not None:
            state = int(CaptureAPI.getPreference("VisTrailsAlwaysOnTop"))
            if state:
                self.alwaysOnTopCB.setCheckState(QtCore.Qt.Checked)
            else:
                self.alwaysOnTopCB.setCheckState(QtCore.Qt.Unchecked)
            layout.addWidget(self.alwaysOnTopCB)

        # The number of visible versions edit box
        self.numberOfVisibleVersionsSB = QtGui.QSpinBox()
        if CaptureAPI.getPreference("VisTrailsNumberOfVisibleVersions") is not None:
            novLayout = QtGui.QHBoxLayout()
            layout.addLayout(novLayout)
            novLayout.setMargin(0)

            novLabel = QtGui.QLabel("Number of recent versions visible")
            novLayout.addWidget(novLabel)

            novLayout.addWidget(self.numberOfVisibleVersionsSB)
            self.numberOfVisibleVersionsSB.setRange(0, 1000)
            self.numberOfVisibleVersionsSB.setValue(int(CaptureAPI.getPreference("VisTrailsNumberOfVisibleVersions")))
            novLayout.addStretch()

        # Enabling snapshots
        self.snapShotCB = QtGui.QCheckBox("Take state snapshots")
        self.numSnapshotTB = QtGui.QSpinBox()
        state = CaptureAPI.getPreference("VisTrailsSnapshotEnabled")
        if state is not None:
            layout.addSpacing(10)
            state = int(CaptureAPI.getPreference("VisTrailsSnapshotEnabled"))
            if state:
                self.snapShotCB.setCheckState(QtCore.Qt.Checked)
            else:
                self.snapShotCB.setCheckState(QtCore.Qt.Unchecked)
            layout.addWidget(self.snapShotCB)
            self.connect(self.snapShotCB, QtCore.SIGNAL("clicked()"), self.updateState)

            # The number of actions before a snapshot
            if CaptureAPI.getPreference("VisTrailsSnapshotCount") is not None:
                nosLayout = QtGui.QHBoxLayout()
                layout.addLayout(nosLayout)
                nosLayout.setMargin(0)

                nosLabel = QtGui.QLabel("Number of actions between snapshots")
                nosLayout.addWidget(nosLabel)

                nosLayout.addWidget(self.numSnapshotTB)
                self.numSnapshotTB.setRange(0, 1000)
                self.numSnapshotTB.setValue(int(CaptureAPI.getPreference("VisTrailsSnapshotCount")))
                self.numSnapshotTB.setEnabled(state)
                nosLayout.addStretch()

        # Enabling Autosave
        self.autosaveCB = QtGui.QCheckBox("Autosave")
        self.autosaveDelayTB = QtGui.QSpinBox()
        state = CaptureAPI.getPreference("VisTrailsAutosaveEnabled")
        if state is not None:
            layout.addSpacing(10)
            state = int(CaptureAPI.getPreference("VisTrailsAutosaveEnabled"))
            if state:
                self.autosaveCB.setCheckState(QtCore.Qt.Checked)
            else:
                self.autosaveCB.setCheckState(QtCore.Qt.Unchecked)
            layout.addWidget(self.autosaveCB)
            self.connect(self.autosaveCB, QtCore.SIGNAL("clicked()"), self.updateState)

            # The delay in minutes between autosaves
            if CaptureAPI.getPreference("VisTrailsAutosaveDelay") is not None:
                adLayout = QtGui.QHBoxLayout()
                layout.addLayout(adLayout)
                adLayout.setMargin(0)

                adLabel = QtGui.QLabel("Minutes between autosave")
                adLayout.addWidget(adLabel)

                adLayout.addWidget(self.autosaveDelayTB)
                self.autosaveDelayTB.setRange(1, 100)
                self.autosaveDelayTB.setValue(int(CaptureAPI.getPreference("VisTrailsAutosaveDelay")))
                self.autosaveDelayTB.setEnabled(state)
                adLayout.addStretch()

        # Store files in vt
        self.fileStoreCB = QtGui.QCheckBox("Store opened and imported files in vistrail")
        if CaptureAPI.getPreference("VisTrailsStoreFiles") is not None:
            layout.addSpacing(10)
            state = int(CaptureAPI.getPreference("VisTrailsStoreFiles"))
            if state:
                self.fileStoreCB.setCheckState(QtCore.Qt.Checked)
            else:
                self.fileStoreCB.setCheckState(QtCore.Qt.Unchecked)
            layout.addWidget(self.fileStoreCB)

        # A space
        layout.addSpacing(10)
        layout.addStretch()

        # Then the buttons
        bLayout = QtGui.QHBoxLayout()
        layout.addLayout(bLayout)
        bLayout.addStretch()

        self.saveButton = QtGui.QPushButton("Save")
        bLayout.addWidget(self.saveButton)

        self.cancelButton = QtGui.QPushButton("Cancel")
        bLayout.addWidget(self.cancelButton)
        bLayout.addStretch()

        # Connect buttons to dialog handlers
        self.connect(self.saveButton, QtCore.SIGNAL("clicked()"), self.accept)
        self.connect(self.cancelButton, QtCore.SIGNAL("clicked()"), self.reject)

        controller = getBuilderWindow().viewManager.currentWidget().controller
        controller.set_num_versions_always_shown(self.numberOfVisibleVersionsSB.value())

        # Reader specific GUI
        if CaptureAPI.isReadOnly():
            self.autosaveCB.setText("Autosave (Pro)")
            self.autosaveCB.setEnabled(False)
            adLabel.setText("Minutes between autosave (Pro)")
            adLabel.setEnabled(False)
            self.autosaveDelayTB.setEnabled(False)
            self.fileStoreCB.setText("Store opened and imported files in vistrail (Pro)")
            self.fileStoreCB.setEnabled(False)
            self.snapShotCB.setText("Take state snapshots (Pro)")
            self.snapShotCB.setEnabled(False)
            nosLabel.setText("Number of actions between snapshots (Pro)")
            nosLabel.setEnabled(False)
            self.numSnapshotTB.setEnabled(False)
def QVM_closeVistrail(self, vistrailView=None, quiet=False):
    """ closeVistrail(vistrailView: QVistrailView, quiet: bool) -> bool
    Close the current active vistrail
    
    """
    import CaptureAPI
    if CaptureAPI.isReadOnly():
        quiet=True
    
    if hasattr(self, "canCancelClose"):
        canCancel = self.canCancelClose
    else:
        canCancel = True
        
    if not vistrailView:
        vistrailView = self.currentWidget()
    vistrailView.flush_changes()
    
    if vistrailView:
        if not quiet and vistrailView.controller.changed:
            text = vistrailView.controller.name
            if text=='':
                text = 'Untitled%s'%core.system.vistrails_default_file_type()
            text = ('Vistrail ' +
                    QtCore.Qt.escape(text) +
                    ' contains unsaved changes.\n Do you want to '
                    'save changes before closing it?')
            
            if canCancel:
                res = QtGui.QMessageBox.information(getBuilderWindow(),
                                                    'Vistrails',
                                                    text, 
                                                    '&Save', 
                                                    '&Discard',
                                                    'Cancel',
                                                    0,
                                                    2)
            else:
                res = QtGui.QMessageBox.information(getBuilderWindow(),
                                                    'Vistrails',
                                                    text, 
                                                    '&Save', 
                                                    '&Discard')
        else:
            res = 1
        if res == 0:
            locator = vistrailView.controller.locator
            if locator is None:
                class_ = FileLocator()
            else:
                class_ = type(locator)
            return self.save_vistrail(class_)
        elif res == 2:
            return False
        self.removeVistrailView(vistrailView)
        if self.count()==0:
            self.emit(QtCore.SIGNAL('currentVistrailChanged'), None)
            self.emit(QtCore.SIGNAL('versionSelectionChange'), -1)
    if vistrailView == self._first_view:
        self._first_view = None
    return True