use of org.adempiere.webui.component.ListHeader in project adempiere by adempiere.
the class WWFActivity method loadActivities.
/**
* Load Activities
* @return int
*/
public int loadActivities() {
long start = System.currentTimeMillis();
int MAX_ACTIVITIES_IN_LIST = MSysConfig.getIntValue("MAX_ACTIVITIES_IN_LIST", 200, Env.getAD_Client_ID(Env.getCtx()));
model = new ListModelTable();
ArrayList<MWFActivity> list = new ArrayList<MWFActivity>();
String sql = "SELECT * FROM AD_WF_Activity a " + "WHERE a.Processed='N' AND a.WFState='OS' AND (" + // Owner of Activity
" a.AD_User_ID=?" + // Invoker (if no invoker = all)
" OR EXISTS (SELECT * FROM AD_WF_Responsible r WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID" + // #2
" AND COALESCE(r.AD_User_ID,0)=0 AND COALESCE(r.AD_Role_ID,0)=0 AND (a.AD_User_ID=? OR a.AD_User_ID IS NULL))" + // Responsible User
" OR EXISTS (SELECT * FROM AD_WF_Responsible r WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID" + // #3
" AND r.AD_User_ID=?)" + // Responsible Role
" OR EXISTS (SELECT * FROM AD_WF_Responsible r INNER JOIN AD_User_Roles ur ON (r.AD_Role_ID=ur.AD_Role_ID)" + // #4
" WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID AND ur.AD_User_ID=?)" + //
") ORDER BY a.Priority DESC, Created";
int AD_User_ID = Env.getAD_User_ID(Env.getCtx());
MRole role = MRole.get(Env.getCtx(), Env.getAD_Role_ID(Env.getCtx()));
sql = role.addAccessSQL(sql, "a", true, false);
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_User_ID);
pstmt.setInt(2, AD_User_ID);
pstmt.setInt(3, AD_User_ID);
pstmt.setInt(4, AD_User_ID);
rs = pstmt.executeQuery();
while (rs.next()) {
MWFActivity activity = new MWFActivity(Env.getCtx(), rs, null);
list.add(activity);
List<Object> rowData = new ArrayList<Object>();
rowData.add(activity.getPriority());
rowData.add(activity.getNodeName());
rowData.add(activity.getSummary());
model.add(rowData);
if (list.size() > MAX_ACTIVITIES_IN_LIST && MAX_ACTIVITIES_IN_LIST > 0) {
log.warning("More then 200 Activities - ignored");
break;
}
}
} catch (Exception e) {
log.log(Level.SEVERE, sql, e);
} finally {
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
m_activities = new MWFActivity[list.size()];
list.toArray(m_activities);
//
log.fine("#" + m_activities.length + "(" + (System.currentTimeMillis() - start) + "ms)");
m_index = 0;
String[] columns = new String[] { Msg.translate(Env.getCtx(), "Priority"), Msg.translate(Env.getCtx(), "AD_WF_Node_ID"), Msg.translate(Env.getCtx(), "Summary") };
WListItemRenderer renderer = new WListItemRenderer(Arrays.asList(columns));
ListHeader header = new ListHeader();
header.setWidth("30px");
renderer.setListHeader(0, header);
renderer.addTableValueChangeListener(listbox);
model.setNoColumns(columns.length);
listbox.setModel(model);
listbox.setItemRenderer(renderer);
listbox.repaint();
listbox.setFixedLayout(true);
return m_activities.length;
}
use of org.adempiere.webui.component.ListHeader in project adempiere by adempiere.
the class WListItemRendererTest method testUpdateColumn.
/**
* Test method for {@link org.adempiere.webui.component.WListItemRenderer#updateColumn(int, java.lang.String)}.
*/
@Test
public final void testUpdateColumn() {
ListHead head = new ListHead();
ListHeader header;
m_renderer.updateColumn(1, "Address");
assertEquals(2, m_renderer.getNoColumns());
m_renderer.renderListHead(head);
header = (ListHeader) head.getChildren().get(1);
assertEquals("Address", header.getLabel());
}
use of org.adempiere.webui.component.ListHeader in project adempiere by adempiere.
the class WListItemRendererTest method testRenderListHead.
/**
* Test method for {@link org.adempiere.webui.component.WListItemRenderer#renderListHead(org.adempiere.webui.component.ListHead)}.
*/
@Test
public final void testRenderListHead() {
ListHead head = new ListHead();
Object header;
m_renderer.renderListHead(head);
assertEquals(2, head.getChildren().size());
header = head.getChildren().get(1);
assertTrue(header instanceof ListHeader);
assertEquals("Age", ((ListHeader) header).getLabel());
}
use of org.adempiere.webui.component.ListHeader in project adempiere by adempiere.
the class WBrowserListItemRenderer method getListHeaderComponent.
/**
* Create a ListHeader using the given <code>headerValue</code> to
* generate the header text.
* The <code>toString</code> method of the <code>headerValue</code>
* is used to set the header text.
*
* @param headerValue The object to use for generating the header text.
* @param headerIndex The column index of the header
* @param classType
* @return The generated ListHeader
* @see #renderListHead(ListHead)
*/
private Component getListHeaderComponent(Object headerValue, int headerIndex, Class<?> classType) {
ListHeader header = null;
String headerText = headerValue.toString();
if (m_headers.size() <= headerIndex || m_headers.get(headerIndex) == null) {
if (!isColumnVisible(getColumn(headerIndex))) {
header = new ListHeader("");
header.setWidth("0px");
header.setStyle("width: 0px");
} else if (classType != null && classType.isAssignableFrom(IDColumn.class)) {
header = new ListHeader("");
header.setWidth("35px");
} else {
Comparator<Object> ascComparator = getColumnComparator(true, headerIndex);
Comparator<Object> dscComparator = getColumnComparator(false, headerIndex);
header = new ListHeader(headerText);
header.setSort("auto");
header.setSortAscending(ascComparator);
header.setSortDescending(dscComparator);
int width = headerText.trim().length() * 9;
if (width > 300)
width = 300;
else if (classType != null) {
if (classType.equals(String.class)) {
if (width > 0 && width < 180)
width = 180;
} else if (classType.equals(IDColumn.class)) {
header.setSort("none");
if (width == 0)
width = 30;
} else if (width > 0 && width < 100 && (classType == null || !classType.isAssignableFrom(Boolean.class)))
width = 100;
} else if (width > 0 && width < 100)
width = 100;
header.setWidth(width + "px");
}
m_headers.add(header);
} else {
header = m_headers.get(headerIndex);
if (!isColumnVisible(getColumn(headerIndex))) {
header.setLabel("");
header.setWidth("0px");
header.setStyle("width: 0px");
} else if (!header.getLabel().equals(headerText)) {
header.setLabel(headerText);
}
}
header.setAttribute("zk_component_ID", "ListItem_Header_C" + headerIndex);
return header;
}
use of org.adempiere.webui.component.ListHeader in project adempiere by adempiere.
the class FindWindow method initAdvanced.
/**
* initialise Advanced Tab
* @throws IOException
*
**/
private void initAdvanced() throws IOException {
ToolBarButton btnNew = new ToolBarButton();
btnNew.setImage("/images/New24.png");
btnNew.setAttribute("name", "btnNewAdv");
btnNew.addEventListener(Events.ON_CLICK, this);
ToolBarButton btnDelete = new ToolBarButton();
btnDelete.setAttribute("name", "btnDeleteAdv");
btnDelete.setImage("/images/Delete24.png");
btnDelete.addEventListener(Events.ON_CLICK, this);
ToolBarButton btnSave = new ToolBarButton();
btnSave.setAttribute("name", "btnSaveAdv");
btnSave.setImage("/images/Save24.png");
btnSave.addEventListener(Events.ON_CLICK, this);
fQueryName = new Combobox();
fQueryName.setTooltiptext(m_sToolTipText);
fQueryName.setReadonly(false);
fQueryName.addEventListener(Events.ON_FOCUS, this);
fQueryName.addEventListener(Events.ON_BLUR, this);
fQueryName.addEventListener(Events.ON_SELECT, this);
// Get from Action
WAppsAction action = new WAppsAction(ConfirmPanel.A_OK, null, ConfirmPanel.A_OK);
Button btnOk = action.getButton();
btnOk.setName("btnOkAdv");
btnOk.addEventListener(Events.ON_CLICK, this);
//
action = new WAppsAction(ConfirmPanel.A_CANCEL, null, ConfirmPanel.A_CANCEL);
Button btnCancel = action.getButton();
btnCancel.setName("btnCancel");
btnCancel.addEventListener(Events.ON_CLICK, this);
Panel pnlButtonRight = new Panel();
// Change to Standard button order
pnlButtonRight.appendChild(btnCancel);
pnlButtonRight.appendChild(btnOk);
pnlButtonRight.setAlign("right");
ToolBar toolBar = new ToolBar();
toolBar.appendChild(btnNew);
toolBar.appendChild(btnDelete);
toolBar.appendChild(fQueryName);
toolBar.appendChild(btnSave);
toolBar.setWidth("100%");
fQueryName.setStyle("margin-left: 3px; margin-right: 3px; position: relative; top: 5px;");
btnSave.setDisabled(m_AD_Tab_ID <= 0);
Hbox confirmPanel = new Hbox();
confirmPanel.appendChild(pnlButtonRight);
confirmPanel.setWidth("100%");
advancedPanel = new Listbox();
ListHead listhead = new ListHead();
listhead.setSizable(true);
ListHeader lstHAndOr = new ListHeader();
lstHAndOr.setLabel(Msg.getMsg(Env.getCtx(), "And/Or"));
lstHAndOr.setWidth("40px");
ListHeader lstHLeftBracket = new ListHeader();
lstHLeftBracket.setLabel("(");
lstHLeftBracket.setWidth("20px");
ListHeader lstHColumn = new ListHeader();
lstHColumn.setLabel(Msg.translate(Env.getCtx(), "AD_Column_ID"));
lstHColumn.setWidth("100px");
ListHeader lstHOperator = new ListHeader();
lstHOperator.setLabel(Msg.getMsg(Env.getCtx(), "Operator"));
ListHeader lstHQueryValue = new ListHeader();
lstHQueryValue.setLabel(Msg.getMsg(Env.getCtx(), "QueryValue"));
lstHQueryValue.setWidth("170px");
ListHeader lstHQueryTo = new ListHeader();
lstHQueryTo.setLabel(Msg.getMsg(Env.getCtx(), "QueryValue2"));
lstHQueryTo.setWidth("170px");
ListHeader lstHRightBracket = new ListHeader();
lstHRightBracket.setLabel(")");
lstHRightBracket.setWidth("20px");
listhead.appendChild(lstHAndOr);
listhead.appendChild(lstHLeftBracket);
listhead.appendChild(lstHColumn);
listhead.appendChild(lstHOperator);
listhead.appendChild(lstHQueryValue);
listhead.appendChild(lstHQueryTo);
listhead.appendChild(lstHRightBracket);
advancedPanel.appendChild(listhead);
advancedPanel.setVflex(true);
Borderlayout layout = new Borderlayout();
layout.setStyle("height: 100%; width: 99%; position: relative;");
winAdvanced.appendChild(layout);
North north = new North();
layout.appendChild(north);
north.appendChild(toolBar);
Center center = new Center();
layout.appendChild(center);
center.appendChild(advancedPanel);
center.setFlex(true);
South south = new South();
layout.appendChild(south);
south.appendChild(confirmPanel);
winAdvanced.setHeight("100%");
winAdvanced.setWidth("100%");
winAdvanced.addEventListener(Events.ON_OK, this);
}
Aggregations