def applyButton_clicked_cb(self, widget):
        """Callback executed when the user clicks on the apply button"""
        workspacePath = self.getSelectedWorkspace()
        # We verify the workspace can be loaded.
        # if it can, we stop the current GTK
        if workspacePath is None or len(workspacePath) == 0:
            self.setError(_("No workspace provided."))
        else:
            logging.debug("Create the requested workspace")
            try:
                ResourcesConfiguration.createWorkspace(workspacePath)
            except OSError as e:
                self.log.warning("Impossible to create a workspace : {0}".format(e))
                self.setError("Impossible to create a workspace here.")

                return

            (workspace, error) = (Workspace.loadWorkspace(self._selectedWorkspace))
            if workspace is not None:
                # If we managed to load the given workspace, we save it and stop the GTK
                ResourcesConfiguration.generateUserFile(self._selectedWorkspace)
                self.loadedWorkspace = workspace
                self.stop()
            else:
                self.setError(error)
    def applyButton_clicked_cb(self, widget):
        """Callback executed when the user clicks on the apply button"""
        workspacePath = self.getSelectedWorkspace()
        # We verify the workspace can be loaded.
        # if it can, we stop the current GTK
        if workspacePath is None or len(workspacePath) == 0:
            self.setError(_("No workspace provided."))
        else:
            logging.debug("Create the requested workspace")
            try:
                ResourcesConfiguration.createWorkspace(workspacePath)
            except OSError as e:
                self.log.warning(
                    "Impossible to create a workspace : {0}".format(e))
                self.setError("Impossible to create a workspace here.")

                return

            (workspace,
             error) = (Workspace.loadWorkspace(self._selectedWorkspace))
            if workspace is not None:
                # If we managed to load the given workspace, we save it and stop the GTK
                ResourcesConfiguration.generateUserFile(
                    self._selectedWorkspace)
                self.loadedWorkspace = workspace
                self.stop()
            else:
                self.setError(error)
예제 #3
0
    def switchWorkspace_activate_cb(self, action):
        """Callback executed when the user requests to switch to
        another workspace"""

        finish = False
        errorMessage = None
        while not finish:
            #open dialogbox
            builder2 = Gtk.Builder()
            builder2.add_from_file(os.path.join(
                ResourcesConfiguration.getStaticResources(),
                "ui",
                "dialogbox.glade"))

            dialog = builder2.get_object("switchWorkspace")
            dialog.set_transient_for(self.view.mainWindow)

            applybutton = builder2.get_object("switchWorkspaceApplyButton")
            fileChooserButton = builder2.get_object("switchWorkspaceFileChooserButton")
            fileChooserButton.connect("current-folder-changed", self.fileSetFileChooser_switchWorkspace_cb, applybutton)

            if errorMessage is not None:
                # Display a warning message on the dialog box
                warnLabel = builder2.get_object("switchWorkspaceWarnLabel")
                warnLabel.set_text(errorMessage)
                warnBox = builder2.get_object("switchWorkspaceWarnBox")
                warnBox.show_all()

            result = dialog.run()

            if result == 0:
                selectedFolder = fileChooserButton.get_current_folder()
                dialog.destroy()

                if selectedFolder is None:
                    errorMessage = _("No directory selected")
                else:
                    # we verify if its an empty directory
                    if len(os.listdir(selectedFolder)) > 0:
                        # is a valid workspace directory
                        errorMessage = Workspace.isFolderAValidWorkspace(selectedFolder)
                        if errorMessage is None:
                            try:
                                (self.currentWorkspace, error) = (Workspace.loadWorkspace(selectedFolder))
                                self.currentProject = self.currentWorkspace.getLastProject()
                                finish = True
                                errorMessage = None
                                self.view.currentWorkspaceHasChanged()
                            except Exception, e:
                                errorMessage = _("An error occurred while loading workspace.")
                                logging.warn("Error while loading workspace declared in folder {0}: {1}".format(selectedFolder, e))
                    else:
                        # create a new workspace
                        try:
                            self.currentWorkspace = ResourcesConfiguration.createWorkspace(selectedFolder)
                            finish = True
                            errorMessage = None
                            self.view.currentWorkspaceHasChanged()
                        except Exception, e:
                            errorMessage = _("An error occurred while creating workspace.")
                            logging.warn("Error while creating workspace declared in folder {0}: {1}".format(selectedFolder, e))
예제 #4
0
    def switchWorkspace_activate_cb(self, action):
        """Callback executed when the user requests to switch to
        another workspace"""

        finish = False
        errorMessage = None
        while not finish:
            #open dialogbox
            builder2 = Gtk.Builder()
            builder2.add_from_file(os.path.join(
                ResourcesConfiguration.getStaticResources(),
                "ui",
                "dialogbox.glade"))

            dialog = builder2.get_object("switchWorkspace")
            dialog.set_transient_for(self.view.mainWindow)

            applybutton = builder2.get_object("switchWorkspaceApplyButton")
            fileChooserButton = builder2.get_object("switchWorkspaceFileChooserButton")
            fileChooserButton.connect("current-folder-changed", self.fileSetFileChooser_switchWorkspace_cb, applybutton)

            if errorMessage is not None:
                # Display a warning message on the dialog box
                warnLabel = builder2.get_object("switchWorkspaceWarnLabel")
                warnLabel.set_text(errorMessage)
                warnBox = builder2.get_object("switchWorkspaceWarnBox")
                warnBox.show_all()

            result = dialog.run()

            if result == 0:
                selectedFolder = fileChooserButton.get_current_folder()
                dialog.destroy()

                if selectedFolder is None:
                    errorMessage = _("No directory selected")
                else:
                    # we verify if its an empty directory
                    if len(os.listdir(selectedFolder)) > 0:
                        # is a valid workspace directory
                        errorMessage = Workspace.isFolderAValidWorkspace(selectedFolder)
                        if errorMessage is None:
                            try:
                                (self.currentWorkspace, error) = (Workspace.loadWorkspace(selectedFolder))
                                self.currentProject = self.currentWorkspace.getLastProject()
                                finish = True
                                errorMessage = None
                                self.view.currentWorkspaceHasChanged()
                            except Exception, e:
                                errorMessage = _("An error occurred while loading workspace.")
                                logging.warn("Error while loading workspace declared in folder {0}: {1}".format(selectedFolder, e))
                    else:
                        # create a new workspace
                        try:
                            self.currentWorkspace = ResourcesConfiguration.createWorkspace(selectedFolder)
                            finish = True
                            errorMessage = None
                            self.view.currentWorkspaceHasChanged()
                        except Exception, e:
                            errorMessage = _("An error occurred while creating workspace.")
                            logging.warn("Error while creating workspace declared in folder {0}: {1}".format(selectedFolder, e))