def create_space_content(self, data):
        from openalea.core import cli

        session = GlobalDataManager().get_data_by_name("Session")
        if not session:
            self.logger.error("Couldn't retreive session, logger view cannot be created")
            return
        session = session.obj

        interpreterModel = data.obj
        #managers:
        from openalea.secondnature import layouts
        from openalea.secondnature import applets
        from openalea.secondnature import project
        mgrs = {"layMan":layouts.LayoutManager(),
                "appMan":applets.AppletFactoryManager(),
                "prjMan":project.ProjectManager()}
        view  = self.shellCls(interpreterModel, cli.get_welcome_msg())
        cli.init_interpreter(interpreterModel, session, mgrs)
        return SpaceContent(view)
Esempio n. 2
0
    def __init__(self, session, parent=None):
        """
        @param session : user session
        @param parent : parent window
        """
        qt.QtGui.QMainWindow.__init__(self, parent)
        SignalSlotListener.__init__(self)
        ui_mainwindow.Ui_MainWindow.__init__(self)
        self.setupUi(self)
        self.setAcceptDrops(True)
        self.setAttribute(qt.QtCore.Qt.WA_QuitOnClose)

        self.tabWorkspace.removeTab(0)
        self.tabWorkspace.setTabsClosable(True)
        self.ws_cpt = 0

        if hasattr(AbstractEvaluation, "__provenance__"):
            self._prov = AbstractEvaluation.__provenance__
        else:
            self._prov = False

        #last opened nodes
        self._last_opened = []

        #lower tab pane : python shell, logger...
        self.lowerpane = qt.QtGui.QTabWidget()
        self.splitter.addWidget(self.lowerpane)

        # python interpreter
        try:
            interpreter = get_interpreter()
        except NameError:
            InterpreterClass = get_interpreter_class()
            interpreter = InterpreterClass()

        # interpreter init defered after session init
        shellclass = get_shell_class()
        self.interpreterWidget = shellclass(interpreter,
                                            cli.get_welcome_msg())

        GraphOperator.globalInterpreter = interpreter
        self.lowerpane.addTab(self.interpreterWidget, "Python Shell")

        if logger.QT_LOGGING_MODEL_AVAILABLE:
            # openalea logger
            model = logger.LoggerOffice().get_handler("qt")
            view = LoggerView(parent=self.lowerpane, model=model)
            self.lowerpane.addTab(view, "Logging")

        # search list view
        self.search_model = SearchModel()
        self.searchListView = \
            SearchListView(self, self.searchview)
        self.searchListView.setModel(self.search_model)
        self.vboxlayout3.addWidget(self.searchListView)
        self.searchListView.clicked.connect(self.on_package_manager_focus_change)

        # help widget
        self.helpWidget = helpwidget.HelpWidget()
        css = pj(misc.__path__[0], "..", "..", "..",
                 "share", "_static", "openalea.css")
        self.helpWidget.set_stylesheet_file(css)
        self.poolTabWidget.addTab(self.helpWidget, "Help")

        # Widgets
        self.connect(self.tabWorkspace, qt.QtCore.SIGNAL("contextMenuEvent(QContextMenuEvent)"),
                     self.contextMenuEvent)
        self.tabWorkspace.currentChanged.connect(self.ws_changed)
        self.search_lineEdit.editingFinished.connect(self.search_node)
        self.tabWorkspace.tabCloseRequested.connect(self.close_tab_workspace)

        # Help Menu
        self.action_About.triggered.connect(self.about)
        self.actionOpenAlea_Web.triggered.connect(self.web)
        self.action_Help.triggered.connect(self.help)

        # File Menu
        self.action_New_Session.triggered.connect(self.new_session)
        self.action_Open_Session.triggered.connect(self.open_session)
        self.action_Save_Session.triggered.connect(self.save_session)
        self.actionSave_as.triggered.connect(self.save_as)
        self.action_Quit.triggered.connect(self.quit)

        self.action_Image.triggered.connect(self.export_image)
        self.action_Svg.triggered.connect(self.export_image_svg)

        # Package Manager Menu
        self.action_Auto_Search.triggered.connect(self.reload_all)
        self.action_Add_File.triggered.connect(self.add_pkgdir)
        self.actionFind_Node.triggered.connect(self.find_node)
        self.action_New_Network.triggered.connect(self.new_graph)
        self.actionNew_Python_Node.triggered.connect(self.new_python_node)
        self.actionNew_Package.triggered.connect(self.new_package)
        self.action_Data_File.triggered.connect(self.new_data)

        # DataPool Menu
        self.actionClear_Data_Pool.triggered.connect(self.clear_data_pool)

        # Python Menu
        self.action_Execute_script.triggered.connect(
            self.exec_python_script)
        self.actionOpen_Console.triggered.connect(
            self.open_python_console)
        self.actionClea_r_Console.triggered.connect(
            self.clear_python_console)

        # WorkspaceMenu
        self.__operatorAction = dict([(self.action_Run, "graph_run"),
                                      (self.actionInvalidate, "graph_invalidate"),
                                      (self.actionReset, "graph_reset"),
                                      (self.actionConfigure_I_O, "graph_configure_io"),
                                      (self.actionGroup_Selection, "graph_group_selection"),
                                      (self.action_Copy, "graph_copy"),
                                      (self.action_Paste, "graph_paste"),
                                      (self.action_Cut, "graph_cut"),
                                      (self.action_Delete_2, "graph_remove_selection"),
                                      (self.action_Close_current_workspace, "graph_close"),
                                      (self.action_Export_to_Factory, "graph_export_to_factory"),
                                      (self.actionReload_from_Model, "graph_reload_from_factory"),
                                      (self.actionExport_to_Application, "graph_export_application"),
                                      (self.actionPreview_Application, "graph_preview_application"),
                                      (self.actionAlignHorizontally, "graph_align_selection_horizontal"),
                                      (self.actionAlignLeft, "graph_align_selection_left"),
                                      (self.actionAlignRight, "graph_align_selection_right"),
                                      (self.actionAlignMean, "graph_align_selection_mean"),
                                      (self.actionDistributeHorizontally, "graph_distribute_selection_horizontally"),
                                      (self.actionDistributeVertically, "graph_distribute_selection_vertically"),
                                      (self.actionSetCustomColor, "graph_set_selection_color"),
                                      (self.actionUseCustomColor, "graph_use_user_color")])

        self._last_open_action_group = qt.QtGui.QActionGroup(self)
        self.connect(self._last_open_action_group,
                     qt.QtCore.SIGNAL("triggered(QAction*)"),
                     self.reopen_last)
        self.action_New_Empty_Workspace.triggered.connect(self.new_workspace)
        self.menu_Workspace.aboutToShow.connect(self.__wsMenuShow)
        self.menu_Workspace.aboutToShow.connect(self.__wsMenuHide)
        for ac, fname in self.__operatorAction.iteritems():
            f = self.__make_operator_action_connector(ac, fname)
            ac.triggered.connect(f)

        self.actionTo_script.triggered.connect(self.to_python_script)

        # Window Mneu
        self.actionPreferences.triggered.connect(self.open_preferences)
        self.actionDisplay_Package_Manager.toggled.connect(self.display_leftpanel)
        self.actionDisplay_Workspaces.toggled.connect(self.display_rightpanel)

        #load personnal GUI settings
        self.read_settings()

        #############
        # Provenance
        #############
        if PROVENANCE:
            self.menu_provenance = qt.QtGui.QMenu(self.menubar)
            self.menu_provenance.setObjectName("menu_provenance")
            self.menu_provenance.setTitle(qt.QtGui.QApplication.translate("MainWindow", "&Provenance", None, qt.QtGui.QApplication.UnicodeUTF8))

            self.action_activ_prov = qt.QtGui.QAction(self)
            self.action_activ_prov.setCheckable(True)
            prov = self.get_provenance()
            self.action_activ_prov.setChecked(prov)
            self.action_activ_prov.setObjectName("action_activ_prov")
            self.action_activ_prov.setText(qt.QtGui.QApplication.translate("MainWindow", "Connect/Disconnect Provenance", None, qt.QtGui.QApplication.UnicodeUTF8))

            self.action_show_prov = qt.QtGui.QAction(self)
            self.action_show_prov.setCheckable(False)
            self.action_show_prov.setObjectName("action_show_prov")
            self.action_show_prov.setText(qt.QtGui.QApplication.translate("MainWindow", "Show Provenance", None, qt.QtGui.QApplication.UnicodeUTF8))

            self.menu_provenance.addAction(self.action_activ_prov)
            self.menu_provenance.addAction(self.action_show_prov)

            self.menubar.addAction(self.menu_provenance.menuAction())

            self.action_activ_prov.toggled.connect(self.set_provenance)
            self.action_show_prov.triggered.connect(self.show_provenance)