def buildDialog(dialog_type): """ This simply builds a returns a dialog """ # negative test first drop_down_lines = ['line 1', 'line 2', 'line 3', 'line 4', 'line 5', 'line 6', 'line 7', 'line 8', 'line 9', 'line a'] button_list = [ (False, 'This is the first line'), (False, 'This is really not a thing 1'), (True, 'This is really not a thing 2'), (True, 'This is really not a thing 3'), (False, 'This is really not a thing 4'), (True, 'This is really not a thing 5'), (False, 'This is really not a thing 6')] test_layout = [ Element('TextBox', {'name':'test_1', 'title':'Text Box', 'x':3, 'y':1, 'width':64, 'default': 'one', 'height': 10}), Element('TextField',{'name':'test_2', 'title':'Text Field', 'x':1, 'y':12, 'width':32, 'default': 'two'}), Element('TextField',{'name':'test_3', 'title':'Numeric', 'x':4, 'y':14, 'width':32, 'default': 'three' ,'input_type':'numeric'}), Element('TextField',{'name':'test_4', 'title':'Secret', 'x':5, 'y':16, 'width':32, 'input_type':'secret'}), Element('Button',{'name':'test_5', 'title':'OK', 'x':5, 'y':18}), Element('DropDown',{'name':'test_6', 'title':'Drop Down', 'x':5, 'y':20, 'height':5, 'default':3, 'items':drop_down_lines}), Element('ButtonList',{'name':'test_7', 'title':'Button List (single)', 'x':5, 'y':26, 'items':button_list}), Element('ButtonList',{'name':'test_8', 'title':'Button List (multiple)', 'x':5, 'y':36, 'items':button_list, 'type':'multiple'}), Element('TextBox', {'name':'test_9', 'title':'Text Box', 'x':3, 'y':46, 'width':64, 'default': 'one', 'height': 10, 'word-wrap':True, 'list':True}), ] return beorn_lib.Dialog(dialog_type, test_layout)
def getDialog(self, settings): scm_list = [] active_list = [] button_list = [] for scm in beorn_lib.scm.getSupportedSCMs(): selected = (scm.type == self.tab_window.getConfiguration('SCMFeature', 'preferred_scm')) scm_list.append((selected, scm.type)) value = scm.type in self.tab_window.getConfiguration('SCMFeature', 'enabled_scms') active_list.append((value, scm.type)) poll_period = self.tab_window.getConfiguration('SCMFeature', 'poll_period'); server_period = self.tab_window.getConfiguration('SCMFeature', 'server_period'); number_history_items = self.tab_window.getConfiguration('SCMFeature', 'number_history_items') dialog_layout = [ beorn_lib.dialog.Element('ButtonList',{'name': 'preferred_scm', 'title':'Default SCM', 'x':4, 'y':1, 'width':64, 'items': scm_list, 'type': 'single'}), beorn_lib.dialog.Element('TextField', {'name': 'poll_period', 'title':' Local Refresh Time', 'x':4, 'y':len(scm_list) + 3, 'width':6, 'default': str(int(float(poll_period))) ,'input_type':'numeric'}), beorn_lib.dialog.Element('TextField', {'name': 'server_check_period', 'title':' Server Refresh Time', 'x':4, 'y':len(scm_list) + 4, 'width':6, 'default': str(int(server_period)) ,'input_type':'numeric'}), beorn_lib.dialog.Element('TextField', {'name': 'number_history_items', 'title':'Number History Items', 'x':4, 'y':len(scm_list) + 5, 'width':6, 'default': str(number_history_items) ,'input_type':'numeric'}), beorn_lib.dialog.Element('ButtonList',{'name': 'enabled_scms', 'title':' Enabled SCMs', 'x':4, 'y':(len(scm_list)) + 7, 'width':64, 'items': active_list, 'type': 'multiple'}), beorn_lib.dialog.Element('Button', {'name': 'ok', 'title': 'OK', 'x': 25, 'y': len(scm_list) + 8 + len(button_list) + 2}), beorn_lib.dialog.Element('Button', {'name': 'cancel', 'title': 'CANCEL', 'x': 36, 'y': len(scm_list) + 8 + len(button_list) + 2}) ] return beorn_lib.Dialog(beorn_lib.dialog.DIALOG_TYPE_TEXT, dialog_layout)
def buildDialog(self, settings): result = None config_item = self.tab_window.getConfiguration(*settings.getKey()) supported = beorn_lib.scm.getSupportedSCMs() for item in supported: if item.type == settings.name: dialog_items = item.cls.getDialogLayout() if dialog_items is not None: dialog_layout = [] line = 1 for item in dialog_items: if item[0] == 'ButtonList': button_list = [] for entry in item[4]: if type(config_item[entry[0]]) == str: value = 'True' == config_item[entry[0]] else: value = config_item[entry[0]] button_list.append((value, entry[1])) parameters = { 'name': item[2], 'title': item[3], 'x': 4, 'y': line, 'width': 64, 'items': button_list, 'type': item[1]} line += len(item[4]) + 1 else: parameters = { 'name': item[2], 'title': item[3], 'x': 4, 'y': line, 'width': 64, 'default': config_item[item[2]], 'input_type': item[1]} dialog_layout.append(beorn_lib.dialog.Element(item[0], parameters)) line += 1 line += 1 dialog_layout.append(beorn_lib.dialog.Element('Button', {'name': 'ok', 'title': 'OK', 'x': 25, 'y': line})) dialog_layout.append(beorn_lib.dialog.Element('Button', {'name': 'cancel', 'title': 'CANCEL', 'x': 35, 'y': line})) result = beorn_lib.Dialog(beorn_lib.dialog.DIALOG_TYPE_TEXT, dialog_layout) break return result
def getDialog(self, settings): default = [] for engine in getSupportedNames(): default.append((self.default == engine, engine)) enabled = [] for engine in getSupportedNames(): enabled.append((engine in self.enabled_engines, engine)) dialog_layout = [ beorn_lib.dialog.Element('ButtonList',{'name': 'default_engine', 'title': 'Default Engine', 'x': 15, 'y': 3, 'width':64,'items': default, 'type': 'single'}), beorn_lib.dialog.Element('ButtonList',{'name': 'enabled_engines', 'title': 'Enabled Engines', 'x': 15, 'y': 5 + len(default), 'width':64,'items': enabled, 'type': 'multiple'}), beorn_lib.dialog.Element('Button', {'name': 'ok', 'title': 'OK', 'x': 25, 'y': 5 + (len(enabled)*2) + 2}), beorn_lib.dialog.Element('Button', {'name': 'cancel', 'title': 'CANCEL', 'x': 36, 'y': 5 + (len(enabled)*2) + 2}) ] return beorn_lib.Dialog(beorn_lib.dialog.DIALOG_TYPE_TEXT, dialog_layout)
def getDialog(self, settings): button_list = [(self.auto_tasks, "Automatically generate tasks for markers.")] markers = ','.join(self.marker_list) dialog_layout = [ beorn_lib.dialog.Element( 'ButtonList', { 'name': 'settings', 'title': 'Settings', 'x': 15, 'y': 1, 'width': 64, 'items': button_list, 'type': 'multiple' }), beorn_lib.dialog.Element( 'TextField', { 'name': 'markers', 'title': 'Marker List', 'x': 15, 'y': 4, 'width': 64, 'default': markers }), beorn_lib.dialog.Element('Button', { 'name': 'ok', 'title': 'OK', 'x': 35, 'y': 6 }), beorn_lib.dialog.Element('Button', { 'name': 'cancel', 'title': 'CANCEL', 'x': 46, 'y': 6 }) ] return beorn_lib.Dialog(beorn_lib.dialog.DIALOG_TYPE_TEXT, dialog_layout)
def getDialog(self, settings): suffix_string_list = ','.join(self.ignore_suffixes) directory_string_list = ','.join(self.ignore_directories) display_order = [] display_index = int( self.tab_window.getConfiguration('SourceTreeFeature', 'display_order')) for index, text in enumerate( ["Alphabetic Ordering", "Directories First", "Files First"]): if index == display_index: display_order.append((True, text)) else: display_order.append((False, text)) button_list = [ (self.tab_window.getConfiguration('SourceTreeFeature', 'hide_dot_files'), "Hide Dot files."), (self.tab_window.getConfiguration('SourceTreeFeature', 'show_hidden_files'), "Show hidden files."), (self.tab_window.getConfiguration('SourceTreeFeature', 'follow_current_file'), "Show the current file in the source tree.") ] dialog_layout = [ beorn_lib.dialog.Element( 'TextField', { 'name': 'ignore_suffixes', 'title': 'Suffix Ignore List ', 'x': 10, 'y': 1, 'default': suffix_string_list }), beorn_lib.dialog.Element( 'TextField', { 'name': 'ignore_directories', 'title': 'Directory Ignore List', 'x': 10, 'y': 2, 'default': directory_string_list }), beorn_lib.dialog.Element( 'ButtonList', { 'name': 'settings', 'title': 'Settings', 'x': 15, 'y': 3, 'width': 64, 'items': button_list, 'type': 'multiple' }), beorn_lib.dialog.Element( 'ButtonList', { 'name': 'display_order', 'title': 'Directory Tree Order', 'x': 4, 'y': 5 + len(button_list), 'width': 64, 'items': display_order, 'type': 'single' }), beorn_lib.dialog.Element('Button', { 'name': 'ok', 'title': 'OK', 'x': 25, 'y': 9 + len(button_list) }), beorn_lib.dialog.Element( 'Button', { 'name': 'cancel', 'title': 'CANCEL', 'x': 36, 'y': 9 + len(button_list) }) ] return beorn_lib.Dialog(beorn_lib.dialog.DIALOG_TYPE_TEXT, dialog_layout)
def buildDialog(self, settings): result = None config_item = self.tab_window.getConfiguration(*settings.getKey()) if config_item is None: def_conf = self.getDefaultConfiguration() config_item = def_conf.getConfigItem(*settings.getKey()) for engine in getSupportedEngines(): if engine.__name__ == settings.name: dialog_items = engine.getDialogLayout() line = 1 if dialog_items is not None: dialog_layout = [] for item in dialog_items: if item[0] == 'ButtonList': button_list = [] for entry in item[4]: if type(config_item[entry[0]]) == str: value = 'True' == config_item[entry[0]] else: value = config_item[entry[0]] button_list.append((value, entry[1])) parameters = { 'name': item[2], 'title': item[3], 'x': 4, 'y': line, 'width': 64, 'items': button_list, 'type': item[1]} line += len(item[4]) + 1 else: if item[2] in config_item: data = config_item[item[2]] else: data = '' # numeric or text parameters = { 'name': item[2], 'title': item[3], 'x': 4, 'y': line, 'width': 64, 'default': data, 'input_type': item[1]} dialog_layout.append(beorn_lib.dialog.Element(item[0], parameters)) line += 1 line += 1 dialog_layout.append(beorn_lib.dialog.Element('Button', {'name': 'ok', 'title': 'OK', 'x': 25, 'y': line})) dialog_layout.append(beorn_lib.dialog.Element('Button', {'name': 'cancel', 'title': 'CANCEL', 'x': 35, 'y': line})) result = beorn_lib.Dialog(beorn_lib.dialog.DIALOG_TYPE_TEXT, dialog_layout) break return result
def getDialog(self, settings): button_list = [ (self.tab_window.getConfiguration('TimeKeeperFeature', 'use_repo'), "Use repository for job/project names"), (self.tab_window.getConfiguration('TimeKeeperFeature', 'tracking'), "Is tracking turned on?") ] button_list_start = 4 buttons_line = button_list_start + len(button_list) + 4 dialog_layout = [ beorn_lib.dialog.Element( 'TextField', { 'name': 'default_job', 'title': 'Default Job', 'x': 19, 'y': 1, 'default': self.tab_window.getConfiguration('TimeKeeperFeature', 'default_job') }), beorn_lib.dialog.Element( 'TextField', { 'name': 'default_project', 'title': 'Default Project', 'x': 15, 'y': 2, 'default': self.tab_window.getConfiguration('TimeKeeperFeature', 'default_project') }), beorn_lib.dialog.Element( 'ButtonList', { 'name': 'settings', 'title': 'Settings', 'x': 15, 'y': button_list_start, 'width': 64, 'items': button_list, 'type': 'multiple' }), beorn_lib.dialog.Element( 'TextField', { 'name': 'max_stop_time', 'title': 'Max Idle Time', 'x': 15, 'y': button_list_start + len(button_list) + 2, 'width': 10, 'default': str( self.tab_window.getConfiguration( 'TimeKeeperFeature', 'max_stop_time')), 'input_type': 'numeric' }), beorn_lib.dialog.Element('Button', { 'name': 'ok', 'title': 'OK', 'x': 25, 'y': buttons_line }), beorn_lib.dialog.Element('Button', { 'name': 'cancel', 'title': 'CANCEL', 'x': 36, 'y': buttons_line }) ] return beorn_lib.Dialog(beorn_lib.dialog.DIALOG_TYPE_TEXT, dialog_layout)
def getDialog(self, settings): system_settings = [ (self.tab_window.getConfiguration('SettingsFeature', 'do_not_move_cwd'), "Hide Dot files."), (self.tab_window.getConfiguration('SettingsFeature', 'auto_create'), "Show hidden files.") ] enabled_features = [] enabled = self.tab_window.getConfiguration('SettingsFeature', 'enabled_features') if len(enabled) == 0: for feature in self.tab_window.getFeatures(): # if it is not enabled then just turn it on. enabled_features.append((True, feature.__class__.__name__)) else: for feature in self.tab_window.getFeatures(): if feature.__class__.__name__ in enabled: enable = True else: enable = False enabled_features.append((enable, feature.__class__.__name__)) dialog_layout = [ beorn_lib.dialog.Element( 'TextField', { 'name': 'root_directory', 'title': 'Root Directory ', 'x': 10, 'y': 1, 'width': 80, 'default': self.root_directory }), beorn_lib.dialog.Element( 'ButtonList', { 'name': 'settings', 'title': 'Settings', 'x': 15, 'y': 3, 'width': 64, 'items': system_settings, 'type': 'multiple' }), beorn_lib.dialog.Element( 'ButtonList', { 'name': 'enabled_features', 'title': 'Enabled Features', 'x': 15, 'y': 5 + len(system_settings), 'width': 64, 'items': enabled_features, 'type': 'multiple' }) ] # add the selection key for the features. select_keys = self.tab_window.getConfiguration('SettingsFeature', 'select_keys') if select_keys is None: # need to get the default configuration here default = self.DefaultSettingsConfigration() select_keys = default['select_keys'] if 'help' in select_keys: del select_keys['help'] index = 7 + len(system_settings) + len(enabled_features) for feature in select_keys: feat = self.tab_window.getFeature(feature) if feat is not None and feat.isSelectable(): name = ' Feature Select ' + feature dialog_layout.append( beorn_lib.dialog.Element( 'TextField', { 'name': 'key_' + feature, 'title': name.ljust(35), 'x': 10, 'y': index, 'width': 50, 'default': select_keys[feature] })) index += 1 dialog_layout += [ beorn_lib.dialog.Element( 'Button', { 'name': 'ok', 'title': 'OK', 'x': 25, 'y': 5 + len(dialog_layout) + len(system_settings) + len(enabled_features) }), beorn_lib.dialog.Element( 'Button', { 'name': 'cancel', 'title': 'CANCEL', 'x': 36, 'y': 5 + len(dialog_layout) + len(system_settings) + len(enabled_features) }) ] return beorn_lib.Dialog(beorn_lib.dialog.DIALOG_TYPE_TEXT, dialog_layout)