本文整理汇总了Python中tactic.ui.widget.IconButtonWdg.add_behavior方法的典型用法代码示例。如果您正苦于以下问题:Python IconButtonWdg.add_behavior方法的具体用法?Python IconButtonWdg.add_behavior怎么用?Python IconButtonWdg.add_behavior使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tactic.ui.widget.IconButtonWdg
的用法示例。
在下文中一共展示了IconButtonWdg.add_behavior方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_display
# 需要导入模块: from tactic.ui.widget import IconButtonWdg [as 别名]
# 或者: from tactic.ui.widget.IconButtonWdg import add_behavior [as 别名]
def get_display(my):
top = my.top
if not HelpWdg.exists():
return top
alias = my.kwargs.get("alias")
description = my.kwargs.get("description")
if not description:
description = "Show Help"
if my.kwargs.get("use_icon"):
#help_button = SingleButtonWdg(title='Help', icon=IconWdg.HELP_BUTTON, show_arrow=False)
help_button = IconButtonWdg(title='Help', icon=IconWdg.HELP_BUTTON, show_arrow=False)
else:
help_button = ActionButtonWdg(title="?", tip=description, size='small')
top.add(help_button)
if not my.cbjs_action:
my.cbjs_action = '''
spt.help.set_top();
spt.help.load_alias(bvr.alias);
'''
help_button.add_behavior( {
'type': 'click_up',
'alias': alias,
'cbjs_action': my.cbjs_action
} )
return top
示例2: get_display
# 需要导入模块: from tactic.ui.widget import IconButtonWdg [as 别名]
# 或者: from tactic.ui.widget.IconButtonWdg import add_behavior [as 别名]
def get_display(my):
sobject = my.get_current_sobject()
my.search_key = SearchKey.get_by_sobject(sobject)
div = DivWdg()
div.add_class("hand")
title = "Show Item Details"
if my.widget:
widget = my.widget
else:
widget = IconButtonWdg(title=title, icon=IconWdg.ZOOM)
code = sobject.get_code()
name = sobject.get_value("name", no_exception=True)
if not name:
name = code
widget.add_behavior( {
'type': 'click_up',
'search_key': my.search_key,
'code': code,
'name': name,
'cbjs_action': '''
spt.tab.set_main_body_tab();
var class_name = 'tactic.ui.tools.TaskDetailPanelWdg';
var kwargs = {
search_key: bvr.search_key,
};
var mode = '';
var layout = bvr.src_el.getParent(".spt_tool_top");
if (layout != null) {
mode = 'tool'
}
if (mode == 'tool') {
spt.app_busy.show("Loading ...");
var layout = bvr.src_el.getParent(".spt_tool_top");
var element = layout.getElement(".spt_tool_content");
spt.panel.load(element, class_name, kwargs);
spt.app_busy.hide();
}
else {
var element_name = "detail_"+bvr.code;
var title = "Detail ["+bvr.name+"]";
spt.tab.add_new(element_name, title, class_name, kwargs);
}
'''
} )
div.add(widget)
return div
示例3: get_category_wdg
# 需要导入模块: from tactic.ui.widget import IconButtonWdg [as 别名]
# 或者: from tactic.ui.widget.IconButtonWdg import add_behavior [as 别名]
def get_category_wdg(my, category, mode="new"):
subscriptions = my.get_subscriptions(category, mode)
if not subscriptions:
return
div = DivWdg()
div.add_style("width: 100%")
title_div = DivWdg()
div.add(title_div)
title_div.add_style("padding: 10px")
title_div.add_border()
title_div.add_color("background", "background3")
title = category or "Subscriptions"
title_div.add("%s " % title)
summary_div = SpanWdg()
title_div.add(summary_div)
summary_div.add_style("font-size: 0.8em")
summary_div.add_style("opacity: 0.5")
search_keys = [x.get_search_key() for x in subscriptions]
button = ActionButtonWdg(title="Clear All")
div.add(button)
button.add_behavior( {
'type': 'click_up',
'search_keys': search_keys,
'cbjs_action': '''
var server = TacticServerStub.get();
for (var i = 0; i < bvr.search_keys.length; i++) {
var search_key = bvr.search_keys[i];
server.update(search_key, {'last_cleared':'NOW'});
spt.panel.refresh(bvr.src_el);
}
'''
} )
# types of subscriptions
table = Table()
table.add_style('width: 100%')
table.add_border()
table.add_color("background", "background3")
div.add(table)
ss = []
for subscription in subscriptions:
table.add_row()
td = table.add_cell()
message_code = subscription.get_value("message_code")
search = Search("sthpw/message")
search.add_filter("code", message_code)
message = search.get_sobject()
# show the thumb
if not message:
if mode == "all":
td = table.add_cell(FormatMessageWdg.get_preview_wdg(subscription))
td = table.add_cell()
td.add("No Messages")
continue
size = 60
msg_element = FormatMessageWdg(subscription=subscription, short_format='true')
# this is optional
msg_element.set_sobject(message)
description = msg_element.get_buffer_display()
#td = table.add_cell()
history_icon = IconButtonWdg(title="Subscription History", icon=IconWdg.HISTORY)
#td.add(icon)
message_code = subscription.get_value("message_code")
history_icon.add_behavior( {
'type': 'click_up',
'message_code': message_code,
'cbjs_action': '''
var class_name = 'tactic.ui.panel.FastTableLayoutWdg';
var message_code = bvr.message_code;
var kwargs = {
search_type: 'sthpw/message_log',
show_shelf: false,
expression: "@SOBJECT(sthpw/message_log['message_code','"+message_code+"'])",
view: 'history'
};
spt.tab.set_main_body_tab();
spt.tab.add_new("Message History", "Message History", class_name, kwargs);
'''
} )
#.........这里部分代码省略.........
示例4: get_chat_wdg
# 需要导入模块: from tactic.ui.widget import IconButtonWdg [as 别名]
# 或者: from tactic.ui.widget.IconButtonWdg import add_behavior [as 别名]
def get_chat_wdg(my, key, interval=False):
div = DivWdg()
div.add_class("spt_chat_session_top")
div.add_color("background", "background")
title_wdg = DivWdg()
div.add(title_wdg)
title_wdg.add_color("background", "background3")
title_wdg.add_style("padding: 5px")
title_wdg.add_style("font-weight: bold")
title_wdg.add_border()
icon = IconButtonWdg(title="Remove Chat", icon=IconWdg.DELETE)
icon.add_style("float: right")
icon.add_style("margin-top: -5px")
title_wdg.add(icon)
icon.add_behavior( {
'type': 'click_up',
'key': key,
'cbjs_action': '''
var server = TacticServerStub.get();
var top = bvr.src_el.getParent(".spt_chat_session_top");
spt.behavior.destroy_element(top);
'''
} )
current_user = Environment.get_user_name()
logins = Search.eval("@SOBJECT(sthpw/subscription['message_code','%s'].sthpw/login)" % key)
for login in logins:
if login.get_value("login") == current_user:
continue
thumb = ThumbWdg()
thumb.set_icon_size(45)
thumb.set_sobject(login)
thumb.add_style("float: left")
thumb.add_style("margin: -5px 10px 0px -5px")
title_wdg.add(thumb)
title_wdg.add(login.get_value("display_name"))
title_wdg.add("<br clear='all'/>")
history_div = DivWdg()
div.add(history_div)
history_div.add_class("spt_chat_history")
history_div.add_style("width: auto")
history_div.add_style("height: auto")
history_div.add_style("max-height: 400px")
history_div.add_style("padding: 5px")
history_div.add_class("spt_resizable")
history_div.add_border()
history_div.add_style("overflow-y: auto")
#history_div.add_style("font-size: 0.9em")
search = Search("sthpw/message_log")
search.add_filter("message_code", key)
search.add_order_by("timestamp")
message_logs = search.get_sobjects()
last_login = None;
last_date = None;
for message_log in message_logs:
login = message_log.get("login")
message = message_log.get("message")
timestamp = message_log.get_datetime_value("timestamp")
#timestamp = timestamp.strftime("%b %d, %Y - %H:%M")
timestamp_str = timestamp.strftime("%H:%M")
date_str = timestamp.strftime("%b %d, %Y")
msg = "";
msg += "<table style='margin-top: 5px; font-size: 0.9em; width: 100%'><tr><td colspan='2'>";
if date_str != last_date:
msg += "<br/><b style='font-size: 1.0em'>"+date_str+"</b><hr/></td></tr>";
msg += "<tr><td>";
last_login = None
if login != last_login:
msg += "<b>"+login+"</b><br/>";
msg += message.replace("\n",'<br/>');
msg += "</td><td style='text-align: right; margin-bottom: 5px; width: 75px; vertical-align: top'>";
msg += timestamp_str;
msg += "</td></tr></table>";
history_div.add(msg)
last_login = login
last_date = date_str
history_div.add_behavior( {
'type': 'load',
'cbjs_action': '''
bvr.src_el.scrollTop = bvr.src_el.scrollHeight;
'''
#.........这里部分代码省略.........
示例5: get_display
# 需要导入模块: from tactic.ui.widget import IconButtonWdg [as 别名]
# 或者: from tactic.ui.widget.IconButtonWdg import add_behavior [as 别名]
def get_display(self):
self.doc_mode = self.kwargs.get("doc_mode")
path = self.kwargs.get("path")
self.search_type = self.kwargs.get("search_type")
self.last_path = None
doc_key = self.kwargs.get("doc_key")
if doc_key:
self.doc = Search.get_by_search_key(doc_key)
snapshot = Snapshot.get_latest_by_sobject(self.doc)
if snapshot:
self.last_path = snapshot.get_lib_path_by_type('main')
path = self.doc.get_value("link")
# TEST TEST TEST
if not path:
#path = "/home/apache/pdf/mongodb.txt"
#path = "/home/apache/assets/google_docs.html"
#path = "/home/apache/pdf/star_wars.txt"
path = "https://docs.google.com/document/d/1AC_YR8X8wbKsshkJ1h8EjZuFIr41guvqXq3_PXgaqJ0/pub?embedded=true"
path = "https://docs.google.com/document/d/1WPUmXYoSkR2cz0NcyM2vqQYO6OGZW8BAiDL31YEj--M/pub"
#path = "https://docs.google.com/spreadsheet/pub?key=0Al0xl-XktnaNdExraEE4QkxVQXhaOFh1SHIxZmZMQ0E&single=true&gid=0&output=html"
path = "/home/apache/tactic/doc/alias.json"
if not self.search_type:
self.search_type = "test3/shot"
self.column = "description"
top = self.top
top.add_class("spt_document_top")
self.set_as_panel(top)
#table = Table()
table = ResizableTableWdg()
top.add(table)
table.add_row()
table.set_max_width()
left_td = table.add_cell()
left_td.add_style("vertical-align: top")
title = DivWdg()
left_td.add(title)
title.add_style("padding: 10px")
title.add_color("background", "background3")
button = IconButtonWdg(title="Refresh", icon=IconWdg.REFRESH)
title.add(button)
button.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
spt.app_busy.show("Reloading Document");
var top = bvr.src_el.getParent(".spt_document_top");
spt.panel.refresh(top);
spt.app_busy.hide();
'''
} )
button.add_style("float: left")
button = IconButtonWdg(title="Save", icon=IconWdg.SAVE)
title.add(button)
button.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
'''
} )
button.add_style("float: left")
if not self.doc_mode:
self.doc_mode = "text"
select = SelectWdg("doc_mode")
select.set_option("values", "text|formatted")
title.add(select)
select.set_value(self.doc_mode)
select.add_behavior( {
'type': 'change',
'cbjs_action': '''
spt.app_busy.show("Reloading Document");
var top = bvr.src_el.getParent(".spt_document_top");
var value = bvr.src_el.value;
top.setAttribute("spt_doc_mode", value);
spt.panel.refresh(top);
spt.app_busy.hide();
'''
} )
title.add("<br clear='all'/>")
#.........这里部分代码省略.........
示例6: get_display
# 需要导入模块: from tactic.ui.widget import IconButtonWdg [as 别名]
# 或者: from tactic.ui.widget.IconButtonWdg import add_behavior [as 别名]
def get_display(my):
top = DivWdg()
top.add_border()
top.add_style("padding: 10px")
top.add_color("color", "color")
top.add_gradient("background", "background", 0, -5)
#top.add_style("height: 550px")
top.add_behavior( {
'type': 'load',
'cbjs_action': '''
spt.named_events.fire_event("side_bar|hide_now", {} );
'''
} )
project = Project.get()
title = DivWdg()
title.add("Project Startup and Configuration")
title.add_style("font-size: 18px")
title.add_style("font-weight: bold")
title.add_style("text-align: center")
title.add_style("padding: 10px")
title.add_style("margin: -10px -10px 10px -10px")
top.add(title)
title.add_gradient("background", "background3", 5, -10)
shelf = DivWdg()
top.add(shelf)
shelf.add_style("margin-left: -8px")
shelf.add_style("width: 130px")
button_div = DivWdg()
shelf.add(button_div)
button_div.add_style("float: left")
button_div.add_style("margin-top: -3px")
security = Environment.get_security()
view_side_bar = security.check_access("builtin", "view_side_bar", "allow", default='allow')
if view_side_bar:
button = IconButtonWdg(title="Side Bar", icon=IconWdg.ARROW_LEFT)
button_div.add(button)
shelf.add("Toggle Side Bar")
shelf.add_attr("title", "Toggle Side Bar (or press '1')")
button.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
spt.named_events.fire_event("side_bar|toggle");
'''
} )
shelf.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
spt.named_events.fire_event("side_bar|toggle");
'''
} )
shelf.add_class("hand")
else:
shelf.add(" ")
search_wdg = Table()
top.add(search_wdg)
search_wdg.add_row()
search_wdg.add_class("spt_main_top")
search_wdg.add_style("padding: 10px")
search_wdg.add_style("margin: 20px auto")
search_wdg.add_style("width: 430px")
td = search_wdg.add_cell("Search: ")
td.add_style("vertical-align: top")
td.add_style("padding-top: 8px")
custom_cbk = {}
custom_cbk['enter'] = '''
var top = bvr.src_el.getParent(".spt_main_top");
var search_el = top.getElement(".spt_main_search");
var keywords = search_el.value;
if (keywords != '') {
var class_name = 'tactic.ui.panel.ViewPanelWdg';
var kwargs = {
'search_type': 'sthpw/sobject_list',
'view': 'result_list',
'keywords': keywords,
'simple_search_view': 'simple_filter',
//'show_shelf': false,
}
spt.tab.set_main_body_tab();
spt.tab.add_new("Search Results", "Search Results", class_name, kwargs);
}
'''
from tactic.ui.input import TextInputWdg, LookAheadTextInputWdg
#.........这里部分代码省略.........
示例7: get_collection_wdg
# 需要导入模块: from tactic.ui.widget import IconButtonWdg [as 别名]
# 或者: from tactic.ui.widget.IconButtonWdg import add_behavior [as 别名]
def get_collection_wdg(my):
div = DivWdg()
div.add_style("margin: 15px 0px")
title_div = DivWdg("Collection Manager")
div.add(title_div)
div.add_class("spt_collection_left")
title_div.add_style("font-size: 1.2em")
title_div.add_style("font-weight: bold")
div.add("<hr/>")
# Shelf
shelf_div = DivWdg()
div.add(shelf_div)
shelf_div.add_style("float: right")
shelf_div.add_style("margin-bottom: 15px")
#button = IconButtonWdg(title='Delete Selected Collection', icon="BS_TRASH")
#shelf_div.add(button)
#button.add_style("display: inline-block")
#button.add_style("width: auto")
button = IconButtonWdg(title='Add New Collection', icon="BS_PLUS")
shelf_div.add(button)
button.add_style("display: inline-block")
button.add_style("vertical-align: top")
insert_view = "edit_collection"
button.add_behavior( {
'type': 'click_up',
'insert_view': insert_view,
'search_type': my.search_type,
'cbjs_action': '''
kwargs = {
search_type: bvr.search_type,
mode: 'insert',
view: bvr.insert_view,
save_event: bvr.event_name,
show_header: false,
num_columns: 2,
default: {
_is_collection: true
}
};
var popup = spt.panel.load_popup('Add New Collection', 'tactic.ui.panel.EditWdg', kwargs);
'''
} )
text_div = DivWdg()
shelf_div.add(text_div)
custom_cbk = {}
custom_cbk['enter'] = '''
var top = bvr.src_el.getParent(".spt_collection_left");
var input = top.getElement(".spt_main_search");
var search_value = input.value.toLowerCase();
var collections = top.getElements(".spt_collection_div");
var num_result = 0;
for (i = 0; i < collections.length; i++) {
// Access the Collection title (without number count)
var collection_title = collections[i].attributes[0].value.toLowerCase();
if (collection_title.indexOf(search_value) != '-1') {
collections[i].style.display = "block";
num_result += 1;
}
else {
collections[i].style.display = "none";
}
}
// if no search results, display all
if (num_result == 0) {
for (i = 0; i < collections.length; i++) {
collections[i].style.display = "block";
}
}
'''
filters = []
filters.append(("_is_collection",True))
filters.append(("status","Verified"))
text = LookAheadTextInputWdg(
search_type = "workflow/asset",
column="name",
width="100%",
hint_text="Enter terms to filter collections...",
value_column="name",
filters=filters,
custom_cbk=custom_cbk,
is_collection=True
)
text.add_class("spt_main_search")
text_div.add(text)
#.........这里部分代码省略.........
示例8: get_display
# 需要导入模块: from tactic.ui.widget import IconButtonWdg [as 别名]
# 或者: from tactic.ui.widget.IconButtonWdg import add_behavior [as 别名]
def get_display(self):
top = self.top
self.set_as_panel(top)
top.add_class("spt_ingestion_top")
top.add_color("background", "background", -5)
self.data = {}
rules_div = DivWdg()
top.add(rules_div)
rules_div.add_style("padding: 10px")
rules_div.add("Rules: ")
rules_select = SelectWdg("rule_code")
rule_code = self.get_value('rule_code')
if rule_code:
rules_select.set_value(rule_code)
rules_select.set_option("query", "config/ingest_rule|code|title")
rules_select.add_empty_option("-- New --")
rules_div.add(rules_select)
rules_select.add_behavior( {
'type': 'change',
'cbjs_action': '''
var top = bvr.src_el.getParent(".spt_ingestion_top");
value = bvr.src_el.value;
var class_name = 'tactic.ui.tools.IngestionToolWdg';
spt.panel.load(top, class_name, {rule_code: value} );
'''
} )
rules_div.add("<hr/>")
# read from the database
if rule_code:
search = Search("config/ingest_rule")
search.add_filter("code", rule_code)
sobject = search.get_sobject()
else:
sobject = None
if sobject:
self.data = sobject.get_value("data")
if self.data:
self.data = jsonloads(self.data)
session_code = self.kwargs.get("session_code")
if session_code:
session = Search.get_by_code("config/ingest_session", session_code)
else:
if sobject:
session = sobject.get_related_sobject("config/ingest_session")
print("sobject: ", sobject.get_code(), sobject.get_value("spt_ingest_session_code"))
print("parent: ", session)
else:
session = None
if not session:
#session = SearchType.create("config/ingest_session")
#session.set_value("code", "session101")
#session.set_value("location", "local")
##session.set_value("base_dir", "C:")
top.add("No session defined!!!")
return top
rule = ""
filter = ""
ignore = ""
# get the base path
if sobject:
base_dir = sobject.get_value("base_dir")
else:
base_dir = ''
#else:
# base_dir = self.get_value("base_dir")
#if not base_dir:
# base_dir = ''
if sobject:
title = sobject.get_value("title")
else:
title = ''
if sobject:
code = sobject.get_value("code")
else:
code = ''
file_list = self.get_value("file_list")
scan_type = self.get_value("scan_type")
action_type = self.get_value("action_type")
rule = self.get_value("rule")
if not rule:
#.........这里部分代码省略.........
示例9: get_display
# 需要导入模块: from tactic.ui.widget import IconButtonWdg [as 别名]
# 或者: from tactic.ui.widget.IconButtonWdg import add_behavior [as 别名]
def get_display(my):
sobject = my.get_current_sobject()
use_parent = my.get_option("use_parent")
use_parent = use_parent in ['true', True]
#if use_parent in ['true', True]:
# sobject = sobject.get_parent()
# if not sobject:
# return DivWdg()
my.search_key = SearchKey.get_by_sobject(sobject)
div = DivWdg()
div.add_class("hand")
target_id = "main_body"
mode = my.get_option("mode")
#mode = "link"
title = "Show Item Details"
if my.widget:
widget = my.widget
elif mode == "link":
widget = HtmlElement.href()
column = my.get_option("link_column")
if not column:
column = "code"
widget.add( sobject.get_value(column) )
widget.add_style('text-decoration: underline')
else:
#widget = IconButtonWdg(title=title, icon=IconWdg.ZOOM)
widget = IconButtonWdg(title=title, icon="BS_SEARCH")
div.add_style("width: 26px")
div.add_style("margin-left: auto")
div.add_style("margin-right: auto")
code = sobject.get_code()
name = sobject.get_value("name", no_exception=True)
if not name:
name = code
search_type_obj = sobject.get_search_type_obj()
title = search_type_obj.get_title()
if not title:
title = "Detail"
title = _(title)
tab_element_names = my.kwargs.get("tab_element_names") or ""
detail_view = my.kwargs.get("detail_view") or ""
widget.add_behavior( {
'type': 'click_up',
'search_key': my.search_key,
'use_parent': use_parent,
'tab_element_names': tab_element_names,
'detail_view': detail_view,
'show_task_process': my.show_task_process,
'code': code,
'name': name,
'label': title,
'cbjs_action': '''
spt.tab.set_main_body_tab();
var class_name = 'tactic.ui.tools.SObjectDetailWdg';
var kwargs = {
search_key: bvr.search_key,
use_parent: bvr.use_parent,
tab_element_names: bvr.tab_element_names,
show_task_process: bvr.show_task_process,
detail_view: bvr.detail_view
};
var mode = '';
var layout = bvr.src_el.getParent(".spt_tool_top");
if (layout != null) {
mode = 'tool'
}
if (mode == 'tool') {
spt.app_busy.show("Loading ...");
var layout = bvr.src_el.getParent(".spt_tool_top");
var element = layout.getElement(".spt_tool_content");
spt.panel.load(element, class_name, kwargs);
spt.app_busy.hide();
}
else {
var element_name = "detail_"+bvr.code;
var title = bvr.label + " ["+bvr.name+"]";
spt.tab.add_new(element_name, title, class_name, kwargs);
}
'''
} )
#link_wdg = my.get_link_wdg(target_id, title, widget)
#div.add( link_wdg )
#.........这里部分代码省略.........
示例10: get_display
# 需要导入模块: from tactic.ui.widget import IconButtonWdg [as 别名]
# 或者: from tactic.ui.widget.IconButtonWdg import add_behavior [as 别名]
def get_display(my):
top = my.top
top.add_class("spt_branch_content")
my.set_as_panel(top)
top.add_color("color", "color")
top.add_color("background", "background")
#top.add_border()
#top.add_style("padding", "10px")
top.add_style("min-width: 600px")
top.add_style("min-height: 400px")
top.add_behavior( {
'type': 'load',
'cbjs_action': scm_get_onload_js()
} )
sync_dir = Environment.get_sandbox_dir()
project = Project.get()
depot = project.get_value("location", no_exception=True)
if not depot:
depot = project.get_code()
location = '//%s' % depot
branch = my.kwargs.get("branch")
if not branch:
branch = WidgetSettings.get_value_by_key("current_branch")
else:
WidgetSettings.set_value_by_key("current_branch", branch)
if not branch:
branch = 'main'
branches = my.kwargs.get("branches")
if not branches:
branches = []
elif isinstance(branches, basestring):
branches = branches.replace("'", '"')
branches = jsonloads(branches)
top.add_behavior( {
'type': 'load',
'depot': depot,
'sync_dir': sync_dir,
'cbjs_action': '''
spt.scm.sync_dir = bvr.sync_dir;
spt.scm.depot = bvr.depot;
'''
} )
inner = DivWdg()
top.add(inner)
table = Table()
inner.add(table)
table.add_style("width: 100%")
table.add_row()
th = table.add_header("")
th = table.add_header("Branches")
th.add_style("text-align: left")
th = table.add_header("Options")
th.add_style("text-align: left")
th = table.add_header("Owner")
th.add_style("text-align: left")
th = table.add_header("Check-out")
th.add_style("text-align: left")
bgcolor = table.get_color("background", -8)
table.add_relay_behavior( {
'type': 'mouseover',
'bvr_match_class': 'spt_branch_item',
'bgcolor': bgcolor,
'cbjs_action': '''
bvr.src_el.setStyle("background-color", bvr.bgcolor);
'''
} )
table.add_relay_behavior( {
'type': 'mouseout',
'bvr_match_class': 'spt_branch_item',
'cbjs_action': '''
bvr.src_el.setStyle("background-color", '');
'''
} )
table.add_relay_behavior( {
'type': 'mouseup',
'bvr_match_class': "spt_branch_radio",
'cbjs_action': '''
var value = bvr.src_el.value;
#.........这里部分代码省略.........
示例11: get_collection_wdg
# 需要导入模块: from tactic.ui.widget import IconButtonWdg [as 别名]
# 或者: from tactic.ui.widget.IconButtonWdg import add_behavior [as 别名]
def get_collection_wdg(my):
div = DivWdg()
div.add_style("margin: 15px 0px")
title_div = DivWdg("Collection Manager")
div.add(title_div)
div.add_class("spt_collection_left")
title_div.add_style("font-size: 1.2em")
title_div.add_style("font-weight: bold")
div.add("<hr/>")
# Shelf
shelf_div = DivWdg()
div.add(shelf_div)
shelf_div.add_style("float: right")
shelf_div.add_style("margin-bottom: 15px")
#button = IconButtonWdg(title='Delete Selected Collection', icon="BS_TRASH")
#shelf_div.add(button)
#button.add_style("display: inline-block")
#button.add_style("width: auto")
button = IconButtonWdg(title='Add New Collection', icon="BS_PLUS")
shelf_div.add(button)
button.add_style("display: inline-block")
button.add_style("vertical-align: top")
insert_view = "edit_collection"
button.add_behavior( {
'type': 'click_up',
'insert_view': insert_view,
'search_type': my.search_type,
'cbjs_action': '''
kwargs = {
search_type: bvr.search_type,
mode: 'insert',
view: bvr.insert_view,
save_event: bvr.event_name,
show_header: false,
num_columns: 2,
default: {
_is_collection: true
}
};
var popup = spt.panel.load_popup('Add New Collection', 'tactic.ui.panel.EditWdg', kwargs);
'''
} )
text_div = DivWdg()
shelf_div.add(text_div)
custom_cbk = {}
custom_cbk['enter'] = '''
var top = bvr.src_el.getParent(".spt_collection_left");
var input = top.getElement(".spt_main_search");
var search_value = input.value.toLowerCase();
var collections = top.getElements(".spt_collection_div");
var num_result = 0;
for (i = 0; i < collections.length; i++) {
// Access the Collection title (without number count)
var collection_title = collections[i].attributes[0].value.toLowerCase();
if (collection_title.indexOf(search_value) != '-1') {
collections[i].style.display = "block";
num_result += 1;
}
else {
collections[i].style.display = "none";
}
}
// if no search results, display all
if (num_result == 0) {
for (i = 0; i < collections.length; i++) {
collections[i].style.display = "block";
}
}
'''
filters = []
filters.append(("_is_collection",True))
filters.append(("status","Verified"))
text = LookAheadTextInputWdg(
search_type = "workflow/asset",
column="name",
width="100%",
height="30px",
hint_text="Enter terms to filter collections...",
value_column="name",
filters=filters,
custom_cbk=custom_cbk,
is_collection=True
)
text.add_class("spt_main_search")
#.........这里部分代码省略.........
示例12: get_display
# 需要导入模块: from tactic.ui.widget import IconButtonWdg [as 别名]
# 或者: from tactic.ui.widget.IconButtonWdg import add_behavior [as 别名]
def get_display(my):
top = my.top
top.add_class("spt_switcher_top")
'''
This supports supports two menu definitions:
menu - specifies a view for SideBarWdg which will be ingected as menu
config_xml - specifies menu entries. For example:
<display class="tactic.ui.widget.LayoutSwitcherWdg">
<!-- config_xml -->
<config>
<!-- Menu item 1 -->
<element name="my_tasks_default" title="My Tasks">
<display class="tactic.ui.panel.ViewPanelWdg">
<search_type>sthpw/task</search_type>
<show_shelf>false</show_shelf>
<view>my_tasks_default</view>
<target>spt_my_tasks_table_top</target>
</display>
</element>
<!-- Menu item 2 -->
<element ... >
<display ... >
<target ... />
</display>
</element>
</config>
</display>
target - specifies target div to load views when using "menu" kwarg
use_href - updates address bar hash (this is TODO)
'''
menu = my.kwargs.get("menu")
config_xml = my.kwargs.get("config_xml")
target = my.kwargs.get("target")
# TODO: use_href to go to specific layout switcher view
# use_href = my.kwrags.get("use_href")
# Layout switcher button displays menu and assumes right hand position of screen
activator = IconButtonWdg( name="Layout Switcher", icon="BS_TH_LIST")
top.add(activator)
activator.add_class("spt_switcher_activator")
activator.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
var activator = bvr.src_el;
var top = activator.getParent(".spt_switcher_top");
var menu = top.getElement(".spt_switcher_menu");
if (top.hasClass("spt_selected")) {
top.removeClass("spt_selected");
menu.setStyle("display", "none");
} else {
top.addClass("spt_selected");
menu.setStyle("display", "");
var pos = activator.getPosition();
var button_size = activator.getSize();
var menu_size = menu.getSize();
var offset = {
x: button_size.x - menu_size.x,
y: button_size.y
}
menu.position({position: 'upperleft', relativeTo: activator, offset: offset});
var pointer = menu.getElement(".spt_popup_pointer");
pointer.setStyle("margin-left", menu_size.x - button_size.x);
}
'''
} )
# menu_wdg
menu_wdg = DivWdg()
top.add(menu_wdg)
menu_wdg.add_class("spt_switcher_menu")
menu_wdg.add_style("display: none")
menu_wdg.add_style("margin-top", "15px")
menu_wdg.add_style("position", "absolute")
menu_wdg.add_style("z-index", "10")
menu_wdg.add_behavior( {
'type': 'mouseleave',
'cbjs_action': '''
var menu = bvr.src_el;
var top = menu.getParent(".spt_switcher_top");
top.removeClass("spt_selected");
menu.setStyle("display", "none")
'''
} )
# Pointer under activator
pointer_wdg = DivWdg()
menu_wdg.add(pointer_wdg)
pointer_wdg.add('''
<div class="spt_first_arrow_div"> </div>
<div class="spt_second_arrow_div"> </div>
''')
pointer_wdg.add_class("spt_popup_pointer")
#.........这里部分代码省略.........
示例13: str
# 需要导入模块: from tactic.ui.widget import IconButtonWdg [as 别名]
# 或者: from tactic.ui.widget.IconButtonWdg import add_behavior [as 别名]
if mode == "sandbox":
sobject_dir = my.get_base_dir(sobject)
elif mode in ["client_repo", "repository"]:
sobject_dir = my.get_client_repo_dir(sobject)
sobject_lib_dir = my.get_lib_dir(sobject)
sobject_dir = sobject_dir.strip()
sobject_dir = Common.process_unicode_string(sobject_dir)
except TacticException, e:
print "WARNING: ", str(e)
button = IconWdg("No Path Found", IconWdg.CROSS, long=False)
else:
button = IconButtonWdg(title="Explore: %s" % sobject_dir, icon=IconWdg.LOAD)
if sobject_dir == sobject_lib_dir:
button.add_behavior(
{
"type": "click_up",
"cbjs_action": "spt.alert('You are not allowed to browse directories on a web server.');",
}
)
else:
button.add_behavior(
{
"type": "click_up",
"cbjs_action": """var applet = spt.Applet.get(); applet.makedirs('%s'); applet.open_explorer('%s');"""
% (sobject_dir, sobject_dir),
}
)
widget.add(button)
return widget
示例14: get_display
# 需要导入模块: from tactic.ui.widget import IconButtonWdg [as 别名]
# 或者: from tactic.ui.widget.IconButtonWdg import add_behavior [as 别名]
def get_display(my):
sobject = my.get_current_sobject()
use_parent = my.get_option("use_parent")
use_parent = use_parent in ['true', True]
#if use_parent in ['true', True]:
# sobject = sobject.get_parent()
# if not sobject:
# return DivWdg()
my.search_key = SearchKey.get_by_sobject(sobject)
div = DivWdg()
div.add_class("hand")
#div.add_style("width: 100%")
#div.add_style("height: 100%")
target_id = "main_body"
title = "Show Item Details"
if my.widget:
widget = my.widget
else:
widget = IconButtonWdg(title=title, icon=IconWdg.ZOOM)
code = sobject.get_code()
name = sobject.get_value("name", no_exception=True)
if not name:
name = code
tab_element_names = my.kwargs.get("tab_element_names") or ""
detail_view = my.kwargs.get("detail_view") or ""
widget.add_behavior( {
'type': 'click_up',
'search_key': my.search_key,
'use_parent': use_parent,
'tab_element_names': tab_element_names,
'detail_view': detail_view,
'show_task_process': my.show_task_process,
'code': code,
'name': name,
'cbjs_action': '''
spt.tab.set_main_body_tab();
var class_name = 'tactic.ui.tools.SObjectDetailWdg';
var kwargs = {
search_key: bvr.search_key,
use_parent: bvr.use_parent,
tab_element_names: bvr.tab_element_names,
show_task_process: bvr.show_task_process,
detail_view: bvr.detail_view
};
var mode = 'xxx';
var layout = bvr.src_el.getParent(".spt_tool_top");
if (layout != null) {
mode = 'tool'
}
if (mode == 'tool') {
spt.app_busy.show("Loading ...");
var layout = bvr.src_el.getParent(".spt_tool_top");
var element = layout.getElement(".spt_tool_content");
spt.panel.load(element, class_name, kwargs);
spt.app_busy.hide();
}
else {
var element_name = "detail_"+bvr.code;
var title = "Detail ["+bvr.name+"]";
spt.tab.add_new(element_name, title, class_name, kwargs);
}
'''
} )
#link_wdg = my.get_link_wdg(target_id, title, widget)
#div.add( link_wdg )
div.add(widget)
return div
示例15: get_header_wdg
# 需要导入模块: from tactic.ui.widget import IconButtonWdg [as 别名]
# 或者: from tactic.ui.widget.IconButtonWdg import add_behavior [as 别名]
def get_header_wdg(my):
div = DivWdg()
if my.collection_key:
button = IconButtonWdg(title='Remove Selected Items from Collection', icon="BS_MINUS")
div.add(button)
button.add_style("display: inline-block")
button.add_style("vertical-align: top")
button.add_behavior( {
'type': 'click_up',
'collection_key': my.collection_key,
'cbjs_action': '''
var search_keys = spt.table.get_selected_search_keys(false);
if (search_keys.length == 0) {
spt.notify.show_message("Nothing selected to remove");
return;
}
var ok = null;
var cancel = function() { return };
var msg = "Are you sure you wish to remove the selected Assets from the Collection?";
var ok = function() {
var cls = 'tactic.ui.panel.CollectionRemoveCmd';
var kwargs = {
collection_key: bvr.collection_key,
search_keys: search_keys,
}
var server = TacticServerStub.get();
try {
server.execute_cmd(cls, kwargs);
spt.table.remove_selected();
} catch(e) {
spt.alert(spt.exception.handler(e));
}
}
spt.confirm(msg, ok, cancel);
'''
} )
button = IconButtonWdg(title='Delete Collection', icon="BS_TRASH")
#button = ActionButtonWdg(title='Delete Collection', icon="BS_TRASH")
div.add(button)
button.add_style("display: inline-block")
button.add_style("vertical-align: top")
button.add_behavior( {
'type': 'click_up',
'collection_key': my.collection_key,
'cbjs_action': '''
var ok = null;
var cancel = function() { return };
var msg = "Are you sure you wish to delete the Collection?";
var ok = function() {
var cls = 'tactic.ui.panel.CollectionDeleteCmd';
var kwargs = {
collection_key: bvr.collection_key,
}
var server = TacticServerStub.get();
try {
server.execute_cmd(cls, kwargs);
} catch(e) {
spt.alert(e);
return;
}
var top = bvr.src_el.getParent(".spt_collection_top");
if (top) {
var layout = top.getParent(".spt_layout");
spt.table.set_layout(layout);
}
spt.table.run_search();
}
spt.confirm(msg, ok, cancel);
'''
} )
"""
button = IconButtonWdg(title='Download Selected Items', icon="BS_DOWNLOAD")
div.add(button)
button.add_style("display: inline-block")
button.add_style("vertical-align: top")
text_div = DivWdg()
div.add(text_div)
text_div.add_style("width: 200px")
text = LookAheadTextInputWdg(
name="name",
#.........这里部分代码省略.........