Ejemplo n.º 1
0
    def __create_side_panel(self, configuration):
        self.__clean_side_panel()

        connectors = []
        for key in System.ports:
            if System.ports[key].language == self.plugin.language:
                connectors.append(key)

        data = {"label": _("Type"), "name": "type", "values": connectors}
        field = ComboField(data, None)
        self.side_panel.pack_start(field, False, False, 1)
        if configuration is not None: field.set_value(configuration["type"])

        data = {"label": _("Label"), "name": "label"}
        field = StringField(data, None)
        self.side_panel.pack_start(field, False, False, 1)
        if configuration is not None: field.set_value(configuration["label"])

        data = {"label": _("Name"), "name": "name"}
        field = StringField(data, None)
        self.side_panel.pack_start(field, False, False, 1)
        if configuration is not None: field.set_value(configuration["name"])

        button = Gtk.Button.new_with_label("Save")
        button.connect("clicked", self.__on_save, None)
        self.side_panel.pack_start(button, False, False, 1)
        self.side_panel.show_all()
Ejemplo n.º 2
0
    def __init__(self, code_template_manager, code_template_name):
        self.code_template_manager = code_template_manager
        Gtk.Dialog.__init__(self, _("Code Template Editor"),
                            self.code_template_manager, 0,
                            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                             Gtk.STOCK_SAVE, Gtk.ResponseType.OK))

        self.main_control = self
        self.set_default_size(600, 300)

        vbox = Gtk.VBox()
        box = self.get_content_area()
        box.pack_start(vbox, True, True, 0)

        self.name = StringField({"label": _("Name")}, None)
        self.type = StringField({"label": _("Type")}, None)
        self.description = StringField({"label": _("Description")}, None)
        self.language = StringField({"label": _("Language")}, None)
        self.command = CodeField({"label": _("")}, None)
        self.extension = StringField({"label": _("Extension")}, None)
        self.code = CodeField({"label": _("")}, None)

        if code_template_name is not None:
            System()
            self.name.set_value(System.code_templates[code_template_name].name)
            self.type.set_value(System.code_templates[code_template_name].type)
            self.description.set_value(
                System.code_templates[code_template_name].description)
            self.language.set_value(
                System.code_templates[code_template_name].language)
            self.command.set_value(
                System.code_templates[code_template_name].command)
            self.extension.set_value(
                System.code_templates[code_template_name].extension)
            self.code.set_value(System.code_templates[code_template_name].code)

        vbox.pack_start(self.name, False, False, 1)
        vbox.pack_start(self.type, False, False, 1)
        vbox.pack_start(self.description, False, False, 1)
        vbox.pack_start(self.language, False, False, 1)
        vbox.pack_start(self.extension, False, False, 1)

        self.codes = Gtk.Notebook()
        self.codes.set_scrollable(True)
        vbox.pack_start(self.codes, True, True, 1)

        self.codes.append_page(self.code, Gtk.Label(_("Code")))
        self.codes.append_page(self.command, Gtk.Label(_("Command")))

        self.show_all()
        result = self.run()
        if result == Gtk.ResponseType.OK:
            self.__save()
        self.close()
        self.destroy()
Ejemplo n.º 3
0
    def __create_default_directory_tab(self):
        vbox = Gtk.VBox()
        self.default_directory_tab.add(vbox)

        data = {
            "label": _("Default directory:"),
            "value": self.properties.default_directory
        }
        self.default_directory = OpenFileField(data, None)
        vbox.add(self.default_directory)

        # Default directory
        data = {
            "label": _("Default Filename:"),
            "value": self.properties.default_filename
        }
        self.default_filename = StringField(data, None)
        vbox.add(self.default_filename)

        vbox.add(
            Gtk.Label(
                _("\nName Wildcards:\n" + "\t%d = Date | %n = diagram name |"
                  " %t = time value | %l = language\n")))

        self.default_directory_tab.show_all()
Ejemplo n.º 4
0
    def __init__(self, plugin_editor, plugin):
        Gtk.ScrolledWindow.__init__(self)

        self.plugin_editor = plugin_editor
        self.plugin = plugin

        for widget in self.get_children():
            self.remove(widget)
        vbox = Gtk.VBox()
        self.add(vbox)

        data = {"label": _("Label"), "value": plugin.label}
        self.label_field = StringField(data, self.__on_edit)

        data = {"label": _("Language"), "value": plugin.language}
        self.language_field = StringField(data, self.__on_edit)

        data = {"label": _("Framework"), "value": plugin.framework}
        self.framework_field = StringField(data, self.__on_edit)

        data = {"label": _("Plugin Type"), "value": plugin.type}
        self.type_field = StringField(data, self.__on_edit)

        data = {"label": _("Group"), "value": plugin.group}
        self.group_field = StringField(data, self.__on_edit)

        data = {"label": _("Color"), "value": plugin.get_color()}
        self.color_field = ColorField(data, self.__on_edit)
        self.color_field.set_parent_window(self.plugin_editor)

        data = {"label": _("Help"), "value": plugin.help}
        self.help_field = CommentField(data, self.__on_edit)

        vbox.pack_start(self.label_field, False, False, 1)
        vbox.pack_start(self.language_field, False, False, 1)
        vbox.pack_start(self.framework_field, False, False, 1)
        vbox.pack_start(self.type_field, False, False, 1)
        vbox.pack_start(self.group_field, False, False, 1)
        vbox.pack_start(self.color_field, False, False, 1)
        vbox.pack_start(self.help_field, False, False, 1)

        self.show_all()
Ejemplo n.º 5
0
 def __create_side_panel(self, configuration):
     self.__clean_side_panel()
     for key in configuration:
         data = {"label": _(key),
                 "name":key,
                 "value":str(configuration[key])}
         field = StringField(data, None)
         if key == "type":
             field.field.set_property("editable", False)
         self.side_panel.pack_start(field, False, False, 1)
     button = Gtk.Button.new_with_label("Save")
     button.connect("clicked", self.__on_props_edit_ok, None)
     self.side_panel.pack_start(button, False, False, 1)
     self.side_panel.show_all()
Ejemplo n.º 6
0
class PluginCommonEditor(Gtk.ScrolledWindow):
    """
    This class contains methods related the PluginManager class
    """

    # ----------------------------------------------------------------------
    def __init__(self, plugin_editor, plugin):
        Gtk.ScrolledWindow.__init__(self)

        self.plugin_editor = plugin_editor
        self.plugin = plugin

        for widget in self.get_children():
            self.remove(widget)
        vbox = Gtk.VBox()
        self.add(vbox)

        data = {"label": _("Label"), "value": plugin.label}
        self.label_field = StringField(data, self.__on_edit)

        data = {"label": _("Language"), "value": plugin.language}
        self.language_field = StringField(data, self.__on_edit)

        data = {"label": _("Framework"), "value": plugin.framework}
        self.framework_field = StringField(data, self.__on_edit)

        data = {"label": _("Plugin Type"), "value": plugin.type}
        self.type_field = StringField(data, self.__on_edit)

        data = {"label": _("Group"), "value": plugin.group}
        self.group_field = StringField(data, self.__on_edit)

        data = {"label": _("Color"), "value": plugin.get_color()}
        self.color_field = ColorField(data, self.__on_edit)
        self.color_field.set_parent_window(self.plugin_editor)

        data = {"label": _("Help"), "value": plugin.help}
        self.help_field = CommentField(data, self.__on_edit)

        vbox.pack_start(self.label_field, False, False, 1)
        vbox.pack_start(self.language_field, False, False, 1)
        vbox.pack_start(self.framework_field, False, False, 1)
        vbox.pack_start(self.type_field, False, False, 1)
        vbox.pack_start(self.group_field, False, False, 1)
        vbox.pack_start(self.color_field, False, False, 1)
        vbox.pack_start(self.help_field, False, False, 1)

        self.show_all()

    # ----------------------------------------------------------------------
    def __on_edit(self, widget=None, data=None):
        self.type_field.set_value("mosaicode.extensions." + \
                self.language_field.get_value().lower() + "." + \
                self.framework_field.get_value().lower() + "." + \
                self.label_field.get_value().lower().replace(" ","")
                )

        self.plugin.type = self.type_field.get_value()
        self.plugin.language = self.language_field.get_value()
        self.plugin.framework = self.framework_field.get_value()

        self.plugin.label = self.label_field.get_value()
        self.plugin.group = self.group_field.get_value()
        self.plugin.color = self.color_field.get_value()
        self.plugin.help = self.help_field.get_value()
Ejemplo n.º 7
0
    def __init__(self, port_manager, port):
        self.port_manager = port_manager
        Gtk.Dialog.__init__(self, _("Port Editor"), self.port_manager, 0,
                            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                             Gtk.STOCK_SAVE, Gtk.ResponseType.OK))

        self.main_control = self
        self.set_default_size(600, 300)

        vbox = Gtk.VBox()
        box = self.get_content_area()
        box.pack_start(vbox, True, True, 0)

        self.type = StringField({"label": _("Type")}, None)
        self.language = StringField({"label": _("Language")}, None)
        self.label = StringField({"label": _("Label")}, None)
        self.color = ColorField({"label": _("Color")}, None)
        self.color.set_parent_window(self)
        self.code = CodeField({"label": _("Code")}, None)
        self.multiple = CheckField({"label": _("Multiple")}, None)

        self.input_code_widgets = []
        self.output_code_widgets = []
        for code in Plugin().codes:
            self.input_code_widgets.append(CodeField({"label": ""}, None))
            self.output_code_widgets.append(CodeField({"label": ""}, None))

        if port is not None:
            System()
            self.type.set_value(port)
            self.language.set_value(System.ports[port].language)
            self.label.set_value(System.ports[port].label)
            self.color.set_value(System.ports[port].color)
            self.code.set_value(System.ports[port].code)
            self.multiple.set_value(System.ports[port].multiple)

            count = 0
            for code in Plugin().codes:
                self.input_code_widgets[count].set_value(
                    System.ports[port].input_codes[count])
                self.output_code_widgets[count].set_value(
                    System.ports[port].output_codes[count])
                count = count + 1

        vbox.pack_start(self.type, False, False, 1)
        vbox.pack_start(self.language, False, False, 1)
        vbox.pack_start(self.label, False, False, 1)
        vbox.pack_start(self.color, False, False, 1)
        vbox.pack_start(self.multiple, False, False, 1)

        self.code_notebook = Gtk.Notebook()
        self.code_notebook.set_scrollable(True)
        vbox.pack_start(self.code_notebook, True, True, 1)
        self.code_notebook.append_page(self.code,
                                       Gtk.Label(_("Connection Code")))

        count = 0
        for code_widget in self.input_code_widgets:
            self.code_notebook.append_page(code_widget, Gtk.Label(_("Input Code " + \
                    str(count))))
            count = count + 1

        count = 0
        for code_widget in self.output_code_widgets:
            self.code_notebook.append_page(code_widget, Gtk.Label(_("Output Code " + \
                    str(count))))
            count = count + 1

        self.show_all()
        result = self.run()
        if result == Gtk.ResponseType.OK:
            self.__save()
        self.close()
        self.destroy()