Changeset 1426

Show
Ignore:
Timestamp:
08/18/07 18:27:28 (6 years ago)
Author:
kop-labs
Message:

Delete Dependences

Location:
branch/k0p/umitInterfaceEditor
Files:
1 added
9 modified

Legend:

Unmodified
Added
Removed
  • branch/k0p/umitInterfaceEditor/Command.py

    r1089 r1426  
    146146        return None  
    147147         
    148  
     148class CommandContainer(TwiceCommand, Command): 
     149    def __init__(self, description, state, commands): 
     150        Command.__init__(self, description) 
     151        TwiceCommand.__init__(self, state) 
     152        self._commands = commands 
     153    def _execute_1(self): 
     154        for i in self._commands: 
     155            i.execute() 
     156    def _execute_2(self): 
     157        #XXX: Later should be fix because it's only work in state = TRUE! 
     158        self._commands.reverse() 
     159        for i in self._commands: 
     160            i.execute() 
     161     
     162         
     163         
     164     
     165     
    149166class CommandManager(gobject.GObject): 
    150167    __gsignals__ = { 
  • branch/k0p/umitInterfaceEditor/DependencesOption.py

    r1424 r1426  
    1010from umitCore.I18N import _ 
    1111import gobject 
     12 
     13 
    1214''' 
    1315DependecesOption is a Windows that shows the options in use 
     
    1618''' 
    1719 
     20 
     21 
     22 
     23 
    1824class DependenceOption(HIGDialog): 
    19     def __init__(self, option, restructfiles, results): 
     25    def __init__(self, option, restructfiles, profile, wizard): 
    2026        HIGDialog.__init__(self, _('Dependence of Option %s ' % option )) 
    2127        self.set_size_request(-1,300) 
    2228        self.restructfiles = restructfiles 
    23         self._results = results 
     29        self._profile = profile 
     30        self._wizard = wizard 
    2431        self._draw_widgets() 
    2532        self.show_all() 
    2633    def _draw_widgets(self): 
    27         self._label = gtk.Label(_('There is a problem deleting this option. This options have dependences: ')) 
     34        self._label = gtk.Label(_('There is a problem deleting this option. This options have dependences.  ')) 
     35        self._label_q = gtk.Label(_('Are you sure that can remove this option? Dependences should be removed too')) 
    2836        self._label.show() 
     37        self._label_q.show() 
    2938        self.vbox.pack_start(self._label, False, False) 
     39        self.vbox.pack_start(self._label_q, False, False) 
    3040        self._treeview_compare() 
    31         self.add_button(gtk.STOCK_YES, gtk.RESPONSE_CANCEL) 
    32         self.add_button(gtk.STOCK_NO, gtk.RESPONSE_OK) 
     41        self.add_button(gtk.STOCK_YES, gtk.RESPONSE_YES) 
     42        self.add_button(gtk.STOCK_NO, gtk.RESPONSE_NO) 
    3343        self.action_area.show_all() 
    3444    def _treeview_compare(self): 
    3545        self._model = gtk.TreeStore(gobject.TYPE_STRING) 
    36         for i in self._results: 
     46        profile = self._model.append( None, ['Profile']) 
     47        wizard = self._model.append( None, ['Wizard']) 
     48 
     49        for i in self._profile: 
    3750             
    38             parent = self._model.append( None, [i[0]]) 
     51            parent = self._model.append( profile, [i[0]]) 
    3952            inside = self._model.append( parent, [i[1]] ) 
    4053            if len(i) == 3: 
    4154                self._model.append(inside, [i[2]]) 
    42          
     55 
     56        for i in self._wizard: 
     57             
     58            parent = self._model.append( wizard, [i[0]]) 
     59            inside = self._model.append( parent, [i[1]] ) 
     60            if len(i) == 3: 
     61                self._model.append(inside, [i[2]])       
    4362        self._treeview = gtk.TreeView(self._model) 
    4463        column = gtk.TreeViewColumn() 
  • branch/k0p/umitInterfaceEditor/Main.py

    r1422 r1426  
    8484        self.create_profile_edit() 
    8585        self.create_wizard_edit() 
    86         self.opt_display.set_profilecore(self.profile_box.get_profilecore()) 
    87         self.opt_display.set_wizardcore(self.wizard_box.get_profilecore()) 
     86        self.opt_display.set_profile(self.profile_box) 
     87        self.opt_display.set_wizard(self.wizard_box) 
    8888         
    8989         
  • branch/k0p/umitInterfaceEditor/OptionManager.py

    r1424 r1426  
    4646from umitInterfaceEditor.OptionsCore import ListOptions, Option, ARG_TYPES 
    4747 
    48 from umitInterfaceEditor.Command import Command, TwiceCommand, command_manager 
     48from umitInterfaceEditor.Command import Command, TwiceCommand, CommandContainer, command_manager 
    4949from umitInterfaceEditor.RestructFiles import RestructFiles 
    5050from umitInterfaceEditor.DependencesOption import DependenceOption 
     51 
     52from umitInterfaceEditor.PageNotebook import CommandAddRemoveOption, CommandAddRemoveVoidplace 
    5153 
    5254''' 
     
    265267        self._profilecore = None  
    266268        self._wizardcore = None  
     269        self._notebook= None 
     270        self._profile = None  
     271        self._wizard = None  
    267272         
    268273        hbox = HIGHBox() 
     
    283288 
    284289        self.optionlist = option 
    285     def set_wizardcore(self, wizardcore): 
    286         self._wizardcore = wizardcore 
    287     def set_profilecore(self, profilecore): 
    288         self._profilecore = profilecore 
     290    def set_wizard(self, wizard): 
     291        self._wizard = wizard 
     292        self._wizardcore = wizard.get_profilecore() 
     293    def set_profile(self, profile): 
     294        self._profile = profile  
     295        self._profilecore = profile.get_profilecore() 
    289296    def set_options_list(self, options): 
    290297        ''' 
     
    313320        opt = Option(name, options, hint, arguments, need_root, arg_type) 
    314321        return opt 
     322     
    315323 
    316324    def delete_option(self, widget): 
     
    333341                                        self._wizardcore, 
    334342                                        self._profilecore) 
    335                 used = self.rf.get_places(name) 
     343                profile, wizard =  self.rf.get_places(name) 
     344                used = [] 
     345                for i in profile: 
     346                    used.append(i) 
     347                for i in wizard: 
     348                    used.append(i) 
    336349                if used == []: 
    337350                    cmd = CommandAddRemoveOptionMode(self.get_option(), 
     
    343356                else: 
    344357                    #Show Dialog Dependences etc!!! 
    345                     dep = DependenceOption(name, self.rf, used) 
    346                     dep.run() 
    347                     pass 
     358                    print used 
     359                    dep = DependenceOption(name, self.rf, profile, wizard) 
     360                    resp = dep.run() 
     361                    dep.destroy() 
     362                     
     363                    if resp == gtk.RESPONSE_YES: 
     364                        commands = [] 
     365                        for i in profile: 
     366                            boxedit = self._profile.notebook.get_page_name(i[0]) 
     367                            widget = boxedit.search_option(i[1]) 
     368                            cmd = CommandAddRemoveOption(widget, 
     369                                                         boxedit, 
     370                                                         self._profilecore, 
     371                                                         False) 
     372                             
     373                            cmd2 = CommandAddRemoveVoidplace(boxedit, 
     374                                                             widget, 
     375                                                             boxedit._coords, 
     376                                                             False) 
     377                            commands.append(cmd) 
     378                            commands.append(cmd2) 
     379                        #for i in wizard: 
     380                        #    print i  
     381                        cmd = CommandContainer('Remove option and deps', 
     382                                               True, 
     383                                               commands) 
     384                        command_manager.add_command(cmd) 
     385                     
     386                    else:  
     387                        return 
     388                     
     389                     
    348390                 
    349391                #self.optionlist.options.remove_option(name) 
     
    361403                d.run() 
    362404                d.destroy() 
    363          
     405     
     406     
     407    def set_notebook(self, notebook): 
     408        self._notebook = notebook 
     409     
    364410    def update_option(self, widget): 
    365411        """ 
  • branch/k0p/umitInterfaceEditor/PageNotebook.py

    r1415 r1426  
    634634     
    635635     
     636    def search_option(self, name): 
     637        ''' 
     638        returns widget  
     639         
     640        ''' 
     641        list = self._table.get_children() 
     642        result = None  
     643        for i in list :  
     644            if i.get_name() == name :  
     645                result = i 
     646                break 
     647        return result 
     648     
    636649    def set_profile_core(self, profile_core): 
    637650        self._profilecore = profile_core 
  • branch/k0p/umitInterfaceEditor/Profile.py

    r1414 r1426  
    221221            self._old_select.set_select(value) 
    222222            self._old_select=None 
     223     
     224     
     225    def get_page_name(self, name): 
     226        result = None  
     227        for i in self.sections_widgets_list: 
     228            if i.get_name() == name :  
     229                result = self.sections_widgets[i]  
     230                break  
     231        if result==None: 
     232            return  
     233        return self.get_nth_page(result) 
    223234     
    224235    def on_button_press(self, widget, event): 
  • branch/k0p/umitInterfaceEditor/ProfileCore.py

    r1407 r1426  
    493493        element.removeChild(node_next) 
    494494        element.insertBefore(node_next, node) 
    495          
    496  
     495     
     496    def get_opt_check(self, section, label): 
     497        elem = self.search_option(section,label) 
     498        return elem.getAttribute('option') 
    497499    def get_list_opt(self, section, label): 
    498500        ''' 
  • branch/k0p/umitInterfaceEditor/RestructFiles.py

    r1424 r1426  
    3636     
    3737    def _search(self, option, core): 
    38         group_list = self.profilecore.groups  
     38        group_list = core.groups  
    3939                 
    4040         
     
    6767    def _search_profile(self, option): 
    6868        return self._search(option, self.profilecore) 
     69    def _search_wizard(self, option): 
     70        return self._search(option, self.wizardcore) 
    6971 
    7072    def get_places(self,option): 
    71         result = self._search_profile(option) 
    72         return result 
     73        profile = self._search_profile(option) 
     74        wizard = self._search_wizard(option) 
     75        return profile, wizard 
    7376    def restruct_all_files(self): 
    7477        pass 
  • branch/k0p/umitInterfaceEditor/Tools.py

    r1414 r1426  
    559559        self._combo_type.connect('changed', self.change_combo) 
    560560         
     561        self._label_opt = HIGEntryLabel(_('Option')) 
     562        self._entry_opt = HIGTextEntry() 
     563        self._entry_opt.set_sensitive(False) 
     564         
    561565        #For option list open a dialog to add/remove options 
    562566        self._button_list = HIGButton('Edit Option List') 
     
    572576        self._table.attach(self._label_type, 0,1,1,2) 
    573577        self._table.attach(self._combo_type, 1,2,1, 2) 
     578 
    574579        self._table.attach(self._button_list, 0,2, 3,4) 
     580        self._table.attach(self._label_opt, 0,1, 4,5) 
     581        self._table.attach(self._entry_opt, 1,2,4,5) 
    575582         
    576583        self._box.pack_start(self._table, False, False) 
     
    624631        pass 
    625632    def hide_item(self): 
     633        self._label_opt.hide() 
     634        self._entry_opt.hide() 
    626635        self._button_list.hide() 
    627636        self._combo_type.hide() 
     
    636645        self._combo_type.hide() 
    637646        self._label_type.hide() 
     647        self._label_opt.hide() 
     648        self._entry_opt.hide() 
    638649        self._selected = selected 
    639650    def set_item(self, selected): 
    640651        self._entry_name.show() 
    641652        self._label_name.show() 
     653 
    642654        self._selected = selected 
    643655        if selected.get_name()!=None: 
     
    652664        if isinstance(child_label, gtk.HBox): 
    653665            #OptionCheck 
     666            self._label_opt.show() 
     667            self._entry_opt.show() 
     668            opt_ = self._profilecore.get_opt_check(self._boxeditable.get_name(), 
     669                                                  selected.get_name()) 
     670            self._entry_opt.set_text(opt_) 
    654671            self._button_list.hide() 
    655672            child_label.cbutton.set_label(self._entry_name.get_text()) 
     
    673690     
    674691    def disable_all(self): 
     692        self._label_opt.hide() 
     693        self._entry_opt.hide() 
    675694        self._button_list.hide() 
    676695        self._combo_type.hide()